public override void OnActivate() { loadProgress.SetText($"Downloading: {name}: ???"); loadProgress.SetProgress(0f); if (modsToDownload != null && modsToDownload.Count > 0) { client = new WebClient(); ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return(true); }); SetCancel(client.CancelAsync); client.DownloadProgressChanged += Client_DownloadProgressChanged; client.DownloadFileCompleted += Client_DownloadFileCompleted; currentDownload = modsToDownload.Dequeue(); loadProgress.SetText($"Downloading: {name}: {currentDownload.displayname}"); client.DownloadFileAsync(new Uri(currentDownload.download), ModLoader.ModPath + Path.DirectorySeparatorChar + "temporaryDownload.tmod"); } else { Interface.modBrowser.ClearItems(); Main.menuMode = Interface.modBrowserID; if (missingMods.Count > 0) { Interface.infoMessage.SetMessage("The following mods were not found on the Mod Browser: " + String.Join(",", missingMods)); Interface.infoMessage.SetGotoMenu(Interface.modBrowserID); Main.menuMode = Interface.infoMessageID; } } }
public override void OnActivate() { loadProgress.SetText(Language.GetTextValue("tModLoader.MBDownloadingMod", name + ": ???")); loadProgress.SetProgress(0f); if (UIModBrowser.PlatformSupportsTls12) // Needed for downloads from Github { ServicePointManager.SecurityProtocol |= (SecurityProtocolType)3072; // SecurityProtocolType.Tls12 } if (modsToDownload != null && modsToDownload.Count > 0) { client = new WebClient(); ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return(true); }); SetCancel(client.CancelAsync); client.DownloadProgressChanged += Client_DownloadProgressChanged; client.DownloadFileCompleted += Client_DownloadFileCompleted; currentDownload = modsToDownload.Dequeue(); loadProgress.SetText(Language.GetTextValue("tModLoader.MBDownloadingMod", $"{name}: {currentDownload.displayname}")); client.DownloadFileAsync(new Uri(currentDownload.download), ModLoader.ModPath + Path.DirectorySeparatorChar + "temporaryDownload.tmod"); } else { Interface.modBrowser.ClearItems(); Main.menuMode = Interface.modBrowserID; if (missingMods.Count > 0) { Interface.infoMessage.SetMessage(Language.GetTextValue("tModLoader.MBModsNotFoundOnline", String.Join(",", missingMods))); Interface.infoMessage.SetGotoMenu(Interface.modBrowserID); Main.menuMode = Interface.infoMessageID; } } }
internal void SetProgressFinding() { if (!Main.dedServ) { loadProgress.SetText("Finding Mods..."); loadProgress.SetProgress(0f); } }
internal void SetProgressFinding() { if (!Main.dedServ) { loadProgress.SetText(Language.GetTextValue("tModLoader.MSFinding")); loadProgress.SetProgress(0f); } }
public override void OnActivate() { loadProgress.SetText(Language.GetTextValue("tModLoader.MBDownloadingMod", name)); loadProgress.SetProgress(0f); if (!UIModBrowser.PlatformSupportsTls12) // Needed for downloads from Github { Interface.errorMessage.Show("TLS 1.2 not supported on this computer.", 0); // github releases return; } ServicePointManager.SecurityProtocol |= (SecurityProtocolType)3072; // SecurityProtocolType.Tls12 client = new WebClient(); ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => true); SetCancel(client.CancelAsync); client.DownloadProgressChanged += Client_DownloadProgressChanged; client.DownloadFileCompleted += Client_DownloadFileCompleted; client.DownloadFileAsync(new Uri(url), file); }
public void SetStatus(string msg) { Logging.tML.Info(msg); loadProgress.SetText(msg); }
private void UpdateDisplayText() { loadProgress.SetText(GetDisplayText()); }
private Exception _Extract() { StreamWriter log = null; try { var dir = Path.Combine(Main.SavePath, "Mod Reader", mod.Name); if (Directory.Exists(dir)) { Directory.Delete(dir, true); } Directory.CreateDirectory(dir); log = new StreamWriter(Path.Combine(dir, "tModReader.txt")) { AutoFlush = true }; if (mod.properties.hideCode) { log.WriteLine(Language.GetTextValue("tModLoader.ExtractHideCodeMessage")); } else if (!mod.properties.includeSource) { log.WriteLine(Language.GetTextValue("tModLoader.ExtractNoSourceCodeMessage")); } if (mod.properties.hideResources) { log.WriteLine(Language.GetTextValue("tModLoader.ExtractHideResourcesMessage")); } log.WriteLine(Language.GetTextValue("tModLoader.ExtractFileListing")); int i = 0; void WriteFile(string name, byte[] content) { //this access is not threadsafe, but it should be atomic enough to not cause issues loadProgress.SetText(name); loadProgress.SetProgress(i++ / (float)mod.modFile.FileCount); bool hidden = codeExtensions.Contains(Path.GetExtension(name)) ? mod.properties.hideCode : mod.properties.hideResources; if (hidden) { log.Write("[hidden] "); } log.WriteLine(name); if (!hidden) { if (name == "Info") { name = "build.txt"; } var path = Path.Combine(dir, name); Directory.CreateDirectory(Path.GetDirectoryName(path)); File.WriteAllBytes(path, content); } } mod.modFile.Read(TmodFile.LoadedState.Streaming, (name, len, reader) => { byte[] data = reader.ReadBytes(len); // check if subject is rawimg, then read it as rawimg and convert back to png if (name.EndsWith(".rawimg")) { using (var ms = new MemoryStream(data)) { var img = ImageIO.RawToTexture2D(Main.instance.GraphicsDevice, ms); using (var pngstream = new MemoryStream()) { img.SaveAsPng(pngstream, img.Width, img.Height); data = pngstream.ToArray(); } } name = Path.ChangeExtension(name, "png"); } WriteFile(name, data); }); foreach (var entry in mod.modFile) { WriteFile(entry.Key, entry.Value); } } catch (Exception e) { log?.WriteLine(e); return(e); } finally { log?.Close(); mod?.modFile.UnloadAssets(); } return(null); }
private Exception _Extract() { StreamWriter log = null; IDisposable modHandle = null; try { var dir = Path.Combine(Main.SavePath, "Mod Reader", mod.Name); if (Directory.Exists(dir)) { Directory.Delete(dir, true); } Directory.CreateDirectory(dir); log = new StreamWriter(Path.Combine(dir, "tModReader.txt")) { AutoFlush = true }; if (mod.properties.hideCode) { log.WriteLine(Language.GetTextValue("tModLoader.ExtractHideCodeMessage")); } else if (!mod.properties.includeSource) { log.WriteLine(Language.GetTextValue("tModLoader.ExtractNoSourceCodeMessage")); } if (mod.properties.hideResources) { log.WriteLine(Language.GetTextValue("tModLoader.ExtractHideResourcesMessage")); } log.WriteLine(Language.GetTextValue("tModLoader.ExtractFileListing")); int i = 0; modHandle = mod.modFile.EnsureOpen(); foreach (var entry in mod.modFile) { var name = entry.Name; ContentConverters.Reverse(ref name, out var converter); //this access is not threadsafe, but it should be atomic enough to not cause issues loadProgress.SetText(name); loadProgress.SetProgress(i++ / (float)mod.modFile.Count); if (name == "tModReader.txt") { continue; } bool hidden = codeExtensions.Contains(Path.GetExtension(name)) ? mod.properties.hideCode : mod.properties.hideResources; if (hidden) { log.Write("[hidden] "); } log.WriteLine(name); if (hidden) { continue; } var path = Path.Combine(dir, name); Directory.CreateDirectory(Path.GetDirectoryName(path)); using (var dst = File.OpenWrite(path)) using (var src = mod.modFile.GetStream(entry)) { if (converter != null) { converter(src, dst); } else { src.CopyTo(dst); } } } ; } catch (Exception e) { log?.WriteLine(e); return(e); } finally { log?.Close(); modHandle?.Dispose(); } return(null); }
private Exception _Extract(TmodFile mod) { StreamWriter log = null; try { var dir = Path.Combine(Main.SavePath, "Mod Reader", mod.name); if (Directory.Exists(dir)) { Directory.Delete(dir, true); } Directory.CreateDirectory(dir); log = new StreamWriter(Path.Combine(dir, "tModReader.txt")) { AutoFlush = true }; var buildProperties = BuildProperties.ReadModFile(mod); if (buildProperties.hideCode) { log.WriteLine("The modder has chosen to hide the code from tModReader."); } else if (!buildProperties.includeSource) { log.WriteLine("The modder has not chosen to include their source code."); } if (buildProperties.hideResources) { log.WriteLine("The modder has chosen to hide resources (ie. images) from tModReader."); } log.WriteLine("Files:"); int i = 0; foreach (var entry in mod) { var name = entry.Key; //this access is not threadsafe, but it should be atomic enough to not cause issues loadProgress.SetText(name); loadProgress.SetProgress(i++ / (float)mod.FileCount); bool hidden = codeExtensions.Contains(Path.GetExtension(name)) ? buildProperties.hideCode : buildProperties.hideResources; if (hidden) { log.Write("[hidden] "); } log.WriteLine(name); if (!hidden) { var path = Path.Combine(dir, name); Directory.CreateDirectory(Path.GetDirectoryName(path)); File.WriteAllBytes(path, entry.Value); } } } catch (Exception e) { log?.WriteLine(e); return(e); } finally { log?.Close(); } return(null); }
public override void OnActivate() { loadProgress.SetText("Uploading: " + name); loadProgress.SetProgress(0f); }
internal void SetReading() { loadProgress.SetText("Reading Properties: " + Path.GetFileName(ModLoader.modToBuild)); }
internal void SetProgressFinding() { loadProgress.SetText("Finding Mods..."); loadProgress.SetProgress(0f); }
public void SetStatus(string msg) { loadProgress.SetText(msg); }
private Exception _Extract() { StreamWriter log = null; try { var dir = Path.Combine(Main.SavePath, "Mod Reader", mod.Name); if (Directory.Exists(dir)) { Directory.Delete(dir, true); } Directory.CreateDirectory(dir); log = new StreamWriter(Path.Combine(dir, "tModReader.txt")) { AutoFlush = true }; if (mod.properties.hideCode) { log.WriteLine(Language.GetTextValue("tModLoader.ExtractHideCodeMessage")); } else if (!mod.properties.includeSource) { log.WriteLine(Language.GetTextValue("tModLoader.ExtractNoSourceCodeMessage")); } if (mod.properties.hideResources) { log.WriteLine(Language.GetTextValue("tModLoader.ExtractHideResourcesMessage")); } log.WriteLine(Language.GetTextValue("tModLoader.ExtractFileListing")); int i = 0; void WriteFile(string name, byte[] content) { //this access is not threadsafe, but it should be atomic enough to not cause issues loadProgress.SetText(name); loadProgress.SetProgress(i++ / (float)mod.modFile.FileCount); bool hidden = codeExtensions.Contains(Path.GetExtension(name)) ? mod.properties.hideCode : mod.properties.hideResources; if (hidden) { log.Write("[hidden] "); } log.WriteLine(name); if (!hidden) { var path = Path.Combine(dir, name); Directory.CreateDirectory(Path.GetDirectoryName(path)); File.WriteAllBytes(path, content); } } mod.modFile.Read(TmodFile.LoadedState.Streaming, (name, len, reader) => WriteFile(name, reader.ReadBytes(len))); foreach (var entry in mod.modFile) { WriteFile(entry.Key, entry.Value); } } catch (Exception e) { log?.WriteLine(e); return(e); } finally { log?.Close(); mod?.modFile.UnloadAssets(); } return(null); }
public override void OnActivate() { loadProgress.SetText(Language.GetTextValue("tModLoader.MBDownloadingMod", name)); loadProgress.SetProgress(0f); }
internal void SetDownloading() { loadProgress.SetText("Downloading: " + Interface.modBrowser.selectedItem.mod); }