public override Mod ReadJson(JsonReader reader, Type objectType, Mod existingValue, bool hasExistingValue, JsonSerializer serializer) { JObject item = JObject.Load(reader); if (!item.HasValues) { return(null); } string organization = item.GetValue(nameof(Mod.Organization), StringComparison.OrdinalIgnoreCase).ToObject <string>(); McModInfo modInfo = item.GetValue(nameof(Mod.ModInfo), StringComparison.OrdinalIgnoreCase).ToObject <McModInfo>(serializer); ForgeVersion forgeVersion = item.GetValue(nameof(Mod.ForgeVersion), StringComparison.OrdinalIgnoreCase).ToObject <ForgeVersion>(serializer); ModSide side = ModSide.ClientServer; if (item.TryGetValue(nameof(Mod.Side), StringComparison.OrdinalIgnoreCase, out JToken sideValue)) { side = sideValue.ToObject <ModSide>(); } LaunchSetup launchSetup = null; if (item.TryGetValue(nameof(Mod.LaunchSetup), StringComparison.OrdinalIgnoreCase, out JToken launchValue)) { launchSetup = launchValue.ToObject <LaunchSetup>(); } WorkspaceSetup workspaceSetup = null; if (item.TryGetValue(nameof(Mod.WorkspaceSetup), StringComparison.OrdinalIgnoreCase, out JToken workspaceValue)) { workspaceSetup = workspaceValue.ToObject <WorkspaceSetup>(serializer); } return(new Mod(modInfo, organization, forgeVersion, side, launchSetup, workspaceSetup)); }
internal static UIModDownloadItem FromJson(LocalMod[] installedMods, JObject mod) { string displayname = (string)mod["displayname"]; //reloadButton.SetText("Adding " + displayname + "..."); string name = (string)mod["name"]; string version = (string)mod["version"]; string author = (string)mod["author"]; string download = (string)mod["download"] ?? $"http://javid.ddns.net/tModLoader/download.php?Down=mods/{name}.tmod{(ModBrowser.UIModBrowser.PlatformSupportsTls12 && !ModBrowser.UIModBrowser.AvoidGithub ? "&tls12=y" : "")}"; int downloads = (int)mod["downloads"]; int hot = (int)mod["hot"]; // for now, hotness is just downloadsYesterday string timeStamp = (string)mod["updateTimeStamp"]; //string[] modreferences = ((string)mod["modreferences"]).Split(','); string modreferences = ((string)mod["modreferences"])?.Replace(" ", string.Empty) ?? string.Empty; ModSide modside = ModSide.Both; // TODO: add filter option for modside. string modIconURL = (string)mod["iconurl"]; string modsideString = (string)mod["modside"]; if (modsideString == "Client") { modside = ModSide.Client; } if (modsideString == "Server") { modside = ModSide.Server; } if (modsideString == "NoSync") { modside = ModSide.NoSync; } string modloaderversion = (string)mod["modloaderversion"]; //bool exists = false; // unused? bool update = false; bool updateIsDowngrade = false; var installed = installedMods.FirstOrDefault(m => m.Name == name); if (installed != null) { //exists = true; var cVersion = new Version(version.Substring(1)); if (cVersion > installed.modFile.version) { update = true; } else if (cVersion < installed.modFile.version) { update = updateIsDowngrade = true; } } return(new UIModDownloadItem(displayname, name, version, author, modreferences, modside, modIconURL, download, downloads, hot, timeStamp, update, updateIsDowngrade, installed, modloaderversion)); }
private static LocalMod Make(string name, ModSide side = ModSide.Both, string version = null, IEnumerable <string> refs = null, IEnumerable <string> weakRefs = null, IEnumerable <string> sortAfter = null, IEnumerable <string> sortBefore = null) { return(new LocalMod(new TmodFile(null, name), new BuildProperties { side = side, version = new Version(version ?? "1.0.0.0"), modReferences = refs?.Select(BuildProperties.ModReference.Parse).ToArray() ?? new BuildProperties.ModReference[0], weakReferences = weakRefs?.Select(BuildProperties.ModReference.Parse).ToArray() ?? new BuildProperties.ModReference[0], sortAfter = sortAfter?.ToArray() ?? new string[0], sortBefore = sortBefore?.ToArray() ?? new string[0] })); }
public McMod(McModInfo modInfo, string organization, ForgeVersion forgeVersion, ModSide side = ModSide.ClientServer, LaunchSetup launchSetup = LaunchSetup.Client, WorkspaceSetup workspaceSetup = null) { ModInfo = modInfo; Organization = organization; ForgeVersion = forgeVersion; Side = side; LaunchSetup = launchSetup; WorkspaceSetup = workspaceSetup ?? WorkspaceSetup.NONE; }
public static string ToFriendlyString(this ModSide sortmode) { switch (sortmode) { case ModSide.Both: return("Both"); case ModSide.Client: return("Client"); case ModSide.Server: return("Server"); case ModSide.NoSync: return("NoSync"); } return("Unknown"); }
public override McMod ReadJson(JsonReader reader, Type objectType, McMod existingValue, bool hasExistingValue, JsonSerializer serializer) { JObject item = JObject.Load(reader); if (!item.HasValues) { return(null); } string organization = item.GetValue(nameof(McMod.Organization), StringComparison.OrdinalIgnoreCase).ToObject <string>(); string modname = item.GetValue(nameof(McMod.Name), StringComparison.OrdinalIgnoreCase).ToObject <string>(); string modInfoPath = ModPaths.McModInfoFile(modname); string modInfoContent = File.ReadAllText(modInfoPath); McModInfo modInfo = JsonConvert.DeserializeObject <McModInfo>(modInfoContent, new JsonSerializerSettings { Converters = serializer.Converters }); ForgeVersion forgeVersion = item.GetValue(nameof(McMod.ForgeVersion), StringComparison.OrdinalIgnoreCase).ToObject <ForgeVersion>(serializer); ModSide side = ModSide.ClientServer; if (item.TryGetValue(nameof(McMod.Side), StringComparison.OrdinalIgnoreCase, out JToken sideValue)) { side = sideValue.ToObject <ModSide>(); } LaunchSetup launchSetup = LaunchSetup.Client; if (item.TryGetValue(nameof(McMod.LaunchSetup), StringComparison.OrdinalIgnoreCase, out JToken launchValue)) { launchSetup = launchValue.ToObject <LaunchSetup>(); } WorkspaceSetup workspaceSetup = null; if (item.TryGetValue(nameof(McMod.WorkspaceSetup), StringComparison.OrdinalIgnoreCase, out JToken workspaceValue)) { workspaceSetup = workspaceValue.ToObject <WorkspaceSetup>(serializer); } return(new McMod(modInfo, organization, forgeVersion, side, launchSetup, workspaceSetup)); }
public BuildProperties(bool beta) { this.beta = beta; side = ModSide.Client; dllReferences = Array.Empty <string>(); modReferences = Array.Empty <string>(); weakReferences = Array.Empty <string>(); sortAfter = Array.Empty <string>(); sortBefore = Array.Empty <string>(); buildIgnores = Array.Empty <string>(); author = "noauthor"; version = new Version(0, 0, 0, 1); displayName = "nodisplayname"; homepage = "nohomepage"; description = "nodesc"; noCompile = false; hideCode = false; hideResources = false; includeSource = false; includePDB = false; eacPath = "noeacpath"; buildVersion = new Version(0, 0, 0, 1); }
public UIModDownloadItem(string displayname, string name, string version, string author, string modreferences, ModSide modside, string modIconURL, string download, int downloads, int hot, string timeStamp, bool update, bool updateIsDowngrade, LocalMod installed) { this.displayname = displayname; this.mod = name; this.version = version; this.author = author; this.modreferences = modreferences; this.modside = modside; this.modIconURL = modIconURL; this.download = download; this.downloads = downloads; this.hot = hot; this.timeStamp = timeStamp; this.update = update; this.updateIsDowngrade = updateIsDowngrade; this.installed = installed; this.BorderColor = new Color(89, 116, 213) * 0.7f; this.dividerTexture = TextureManager.Load("Images/UI/Divider"); this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); this.Height.Set(90f, 0f); this.Width.Set(0f, 1f); base.SetPadding(6f); this.left = HasModIcon ? 85f : 0f; string text = displayname + " " + version; this.modName = new UIText(text, 1f, false); this.modName.Left.Set(this.left + 5, 0f); this.modName.Top.Set(5f, 0f); base.Append(this.modName); moreInfoButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo"), 1f, false); moreInfoButton.Width.Set(100f, 0f); moreInfoButton.Height.Set(30f, 0f); moreInfoButton.Left.Set(this.left, 0f); moreInfoButton.Top.Set(40f, 0f); moreInfoButton.PaddingTop -= 2f; moreInfoButton.PaddingBottom -= 2f; moreInfoButton.OnMouseOver += UICommon.FadedMouseOver; moreInfoButton.OnMouseOut += UICommon.FadedMouseOut; moreInfoButton.OnClick += RequestMoreinfo; Append(moreInfoButton); if (update || installed == null) { updateButton = new UITextPanel <string>(this.update ? (updateIsDowngrade ? Language.GetTextValue("tModLoader.MBDowngrade") : Language.GetTextValue("tModLoader.MBUpdate")) : Language.GetTextValue("tModLoader.MBDownload"), 1f, false); updateButton.CopyStyle(moreInfoButton); updateButton.Width.Set(HasModIcon ? 120f : 200f, 0f); updateButton.Left.Set(moreInfoButton.Width.Pixels + moreInfoButton.Left.Pixels + 5f, 0f); updateButton.OnMouseOver += UICommon.FadedMouseOver; updateButton.OnMouseOut += UICommon.FadedMouseOut; updateButton.OnClick += this.DownloadMod; Append(updateButton); } if (modreferences.Length > 0) { Texture2D icon = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.ButtonExclamation.png")); UIHoverImage modReferenceIcon = new UIHoverImage(icon, "Click to view dependency mods:\n" + string.Join("\n", modreferences.Split(',').Select(x => x.Trim()))); modReferenceIcon.Left.Set(-149f, 1f); modReferenceIcon.Top.Set(48f, 0f); modReferenceIcon.OnClick += (s, e) => { UIModDownloadItem modListItem = (UIModDownloadItem)e.Parent; Interface.modBrowser.SpecialModPackFilter = modListItem.modreferences.Split(',').Select(x => x.Trim()).ToList(); Interface.modBrowser.SpecialModPackFilterTitle = "Dependencies"; // Toolong of \n" + modListItem.modName.Text; Interface.modBrowser.filterTextBox.currentString = ""; Interface.modBrowser.updateNeeded = true; Main.PlaySound(SoundID.MenuOpen); }; Append(modReferenceIcon); } OnDoubleClick += RequestMoreinfo; }
protected CodeAttributeDeclaration NewSideAnnotation(ModSide side) => new CodeAttributeDeclaration("SideOnly", NewAnnotationArg(null, NewFieldReferenceType("Side", side.HasFlag(ModSide.Client) ? "CLIENT" : "SERVER")));
public UIModDownloadItem(string displayName, string name, string version, string author, string modReferences, ModSide modSide, string modIconUrl, string downloadUrl, int downloads, int hot, string timeStamp, bool hasUpdate, bool updateIsDowngrade, LocalMod installed, string modloaderversion) { ModName = name; DisplayName = displayName; DownloadUrl = downloadUrl; _author = author; _modReferences = modReferences; _modSide = modSide; _modIconUrl = modIconUrl; if (UIModBrowser.AvoidImgur) { _modIconUrl = null; } _downloads = downloads; _hot = hot; _timeStamp = timeStamp; HasUpdate = hasUpdate; UpdateIsDowngrade = updateIsDowngrade; Installed = installed; BorderColor = new Color(89, 116, 213) * 0.7f; _dividerTexture = UICommon.DividerTexture; _innerPanelTexture = UICommon.InnerPanelTexture; Height.Pixels = 90; Width.Percent = 1f; SetPadding(6f); float leftOffset = HasModIcon ? ModIconAdjust : 0f; _modName = new UIText(displayName) { Left = new StyleDimension(leftOffset + PADDING, 0f), Top = { Pixels = 5 } }; Append(_modName); _moreInfoButton = new UIImage(UICommon.ButtonModInfoTexture) { Width = { Pixels = 36 }, Height = { Pixels = 36 }, Left = { Pixels = leftOffset }, Top = { Pixels = 40 } }; _moreInfoButton.OnClick += ViewModInfo; Append(_moreInfoButton); if (modloaderversion != null) { tMLUpdateRequired = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MBRequiresTMLUpdate", modloaderversion)).WithFadedMouseOver(Color.Orange, Color.Orange * 0.7f); tMLUpdateRequired.BackgroundColor = Color.Orange * 0.7f; tMLUpdateRequired.CopyStyle(_moreInfoButton); tMLUpdateRequired.Width.Pixels = 340; tMLUpdateRequired.Left.Pixels += 36 + PADDING; tMLUpdateRequired.OnClick += (a, b) => { Process.Start("https://github.com/tModLoader/tModLoader/releases/latest"); }; Append(tMLUpdateRequired); } else if (hasUpdate || installed == null) { _updateButton = new UIImage(UpdateIsDowngrade ? UICommon.ButtonDowngradeTexture : UICommon.ButtonDownloadTexture); _updateButton.CopyStyle(_moreInfoButton); _updateButton.Left.Pixels += 36 + PADDING; _updateButton.OnClick += DownloadMod; Append(_updateButton); if (_modReferences.Length > 0) { _updateWithDepsButton = new UIImage(UICommon.ButtonDownloadMultipleTexture); _updateWithDepsButton.CopyStyle(_updateButton); _updateWithDepsButton.Left.Pixels += 36 + PADDING; _updateWithDepsButton.OnClick += DownloadWithDeps; Append(_updateWithDepsButton); } } if (modReferences.Length > 0) { var icon = UICommon.ButtonExclamationTexture; var modReferenceIcon = new UIHoverImage(icon, Language.GetTextValue("tModLoader.MBClickToViewDependencyMods", string.Join("\n", modReferences.Split(',').Select(x => x.Trim())))) { Left = { Pixels = -icon.Width - PADDING, Percent = 1f } }; modReferenceIcon.OnClick += ShowModDependencies; Append(modReferenceIcon); } OnDoubleClick += ViewModInfo; }
public UIModDownloadItem(string displayname, string name, string version, string author, string modreferences, ModSide modside, string download, int downloads, int hot, string timeStamp, bool update, bool updateIsDowngrade, bool exists) { this.displayname = displayname; this.mod = name; this.version = version; this.author = author; this.modreferences = modreferences; this.modside = modside; this.download = download; this.downloads = downloads; this.hot = hot; this.timeStamp = timeStamp; this.update = update; this.updateIsDowngrade = updateIsDowngrade; this.exists = exists; this.BorderColor = new Color(89, 116, 213) * 0.7f; this.dividerTexture = TextureManager.Load("Images/UI/Divider"); this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); this.Height.Set(90f, 0f); this.Width.Set(0f, 1f); base.SetPadding(6f); string text = displayname + " " + version; this.modName = new UIText(text, 1f, false); this.modName.Left.Set(10f, 0f); this.modName.Top.Set(5f, 0f); base.Append(this.modName); UITextPanel <string> button = new UITextPanel <string>("More info", 1f, false); button.Width.Set(100f, 0f); button.Height.Set(30f, 0f); button.Left.Set(5f, 0f); button.Top.Set(40f, 0f); button.PaddingTop -= 2f; button.PaddingBottom -= 2f; button.OnMouseOver += UICommon.FadedMouseOver; button.OnMouseOut += UICommon.FadedMouseOut; button.OnClick += RequestMoreinfo; base.Append(button); if (update || !exists) { updateButton = new UITextPanel <string>(this.update ? (updateIsDowngrade ? "Downgrade" : "Update") : "Download", 1f, false); updateButton.CopyStyle(button); updateButton.Width.Set(200f, 0f); updateButton.Left.Set(button.Width.Pixels + button.Left.Pixels * 2f + 5f, 0f); updateButton.OnMouseOver += UICommon.FadedMouseOver; updateButton.OnMouseOut += UICommon.FadedMouseOut; updateButton.OnClick += this.DownloadMod; base.Append(updateButton); } if (modreferences.Length > 0) { UIHoverImage modReferenceIcon = new UIHoverImage(Main.quicksIconTexture, "This mod depends on: " + modreferences); modReferenceIcon.Left.Set(-135f, 1f); modReferenceIcon.Top.Set(50f, 0f); modReferenceIcon.OnClick += (s, e) => { UIModDownloadItem modListItem = (UIModDownloadItem)e.Parent; Interface.modBrowser.SpecialModPackFilter = modListItem.modreferences.Split(',').ToList(); Interface.modBrowser.SpecialModPackFilterTitle = "Dependencies"; // Toolong of \n" + modListItem.modName.Text; Interface.modBrowser.filterTextBox.currentString = ""; Interface.modBrowser.SortList(); Main.PlaySound(SoundID.MenuOpen); }; Append(modReferenceIcon); } base.OnDoubleClick += RequestMoreinfo; }
private void PopulateFromJSON(LocalMod[] installedMods, string json) { string tls = PlatformSupportsTls12 ? "&tls12=y" : ""; try { JObject jsonObject; try { jsonObject = JObject.Parse(json); } catch (Exception e) { throw new Exception("Bad JSON: " + json, e); } JObject updateObject = (JObject)jsonObject["update"]; if (updateObject != null) { updateAvailable = true; updateText = (string)updateObject["message"]; updateURL = (string)updateObject["url"]; } JArray modlist = (JArray)jsonObject["modlist"]; foreach (JObject mod in modlist.Children <JObject>()) { string displayname = (string)mod["displayname"]; //reloadButton.SetText("Adding " + displayname + "..."); string name = (string)mod["name"]; string version = (string)mod["version"]; string author = (string)mod["author"]; string download = (string)mod["download"] + tls; int downloads = (int)mod["downloads"]; int hot = (int)mod["hot"]; // for now, hotness is just downloadsYesterday string timeStamp = (string)mod["updateTimeStamp"]; //string[] modreferences = ((string)mod["modreferences"]).Split(','); string modreferences = (string)mod["modreferences"]; ModSide modside = ModSide.Both; // TODO: add filter option for modside. string modIconURL = (string)mod["iconurl"]; string modsideString = (string)mod["modside"]; if (modsideString == "Client") { modside = ModSide.Client; } if (modsideString == "Server") { modside = ModSide.Server; } if (modsideString == "NoSync") { modside = ModSide.NoSync; } bool exists = false; bool update = false; bool updateIsDowngrade = false; var installed = installedMods.FirstOrDefault(m => m.Name == name); if (installed != null) { exists = true; var cVersion = new Version(version.Substring(1)); if (cVersion > installed.modFile.version) { update = true; } else if (cVersion < installed.modFile.version) { update = updateIsDowngrade = true; } } UIModDownloadItem modItem = new UIModDownloadItem(displayname, name, version, author, modreferences, modside, modIconURL, download, downloads, hot, timeStamp, update, updateIsDowngrade, installed); items.Add(modItem); } updateNeeded = true; } catch (Exception e) { ErrorLogger.LogModBrowserException(e); return; } }
private void PopulateFromJSON(TmodFile[] installedMods, string json) { try { JObject jsonObject = JObject.Parse(json); JObject updateObject = (JObject)jsonObject["update"]; if (updateObject != null) { updateAvailable = true; updateText = (string)updateObject["message"]; updateURL = (string)updateObject["url"]; } JArray modlist = (JArray)jsonObject["modlist"]; foreach (JObject mod in modlist.Children <JObject>()) { string displayname = (string)mod["displayname"]; //reloadButton.SetText("Adding " + displayname + "..."); string name = (string)mod["name"]; string version = (string)mod["version"]; string author = (string)mod["author"]; string download = (string)mod["download"]; int downloads = (int)mod["downloads"]; int hot = (int)mod["hot"]; // for now, hotness is just downloadsYesterday string timeStamp = (string)mod["updateTimeStamp"]; //string[] modreferences = ((string)mod["modreferences"]).Split(','); string modreferences = (string)mod["modreferences"]; ModSide modside = ModSide.Both; // TODO: add filter option for modside. string modsideString = (string)mod["modside"]; if (modsideString == "Client") { modside = ModSide.Client; } if (modsideString == "Server") { modside = ModSide.Server; } if (modsideString == "NoSync") { modside = ModSide.NoSync; } bool exists = false; bool update = false; bool updateIsDowngrade = false; var installed = installedMods.SingleOrDefault(m => m.name == name); if (installed != null) { exists = true; var cVersion = new Version(version.Substring(1)); if (cVersion > installed.version) { update = true; } else if (cVersion < installed.version) { update = updateIsDowngrade = true; } } UIModDownloadItem modItem = new UIModDownloadItem(displayname, name, version, author, modreferences, modside, download, downloads, hot, timeStamp, update, updateIsDowngrade, installed); modListAll._items.Add(modItem); //add directly to the underlying, SortList will repopulate it anyway } SortList(); } catch (Exception e) { ErrorLogger.LogModBrowserException(e); return; } }
public UIModDownloadItem(string displayname, string name, string version, string author, string modreferences, ModSide modside, string modIconURL, string download, int downloads, int hot, string timeStamp, bool update, bool updateIsDowngrade, LocalMod installed) { this.displayname = displayname; this.mod = name; this.version = version; this.author = author; this.modreferences = modreferences; this.modside = modside; this.modIconURL = modIconURL; this.download = download; this.downloads = downloads; this.hot = hot; this.timeStamp = timeStamp; this.update = update; this.updateIsDowngrade = updateIsDowngrade; this.installed = installed; BorderColor = new Color(89, 116, 213) * 0.7f; dividerTexture = TextureManager.Load("Images/UI/Divider"); innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); Height.Pixels = 90; Width.Percent = 1f; SetPadding(6f); left = HasModIcon ? 85f : 0f; string text = displayname + " " + version; modName = new UIText(text) { Left = new StyleDimension(left + 5, 0f), Top = { Pixels = 5 } }; Append(modName); moreInfoButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo")) { Width = { Pixels = 100 }, Height = { Pixels = 36 }, Left = { Pixels = left }, Top = { Pixels = 40 } }.WithFadedMouseOver(); moreInfoButton.PaddingTop -= 2f; moreInfoButton.PaddingBottom -= 2f; moreInfoButton.OnClick += RequestMoreinfo; Append(moreInfoButton); if (update || installed == null) { updateButton = new UIAutoScaleTextTextPanel <string>(this.update ? (updateIsDowngrade ? Language.GetTextValue("tModLoader.MBDowngrade") : Language.GetTextValue("tModLoader.MBUpdate")) : Language.GetTextValue("tModLoader.MBDownload"), 1f, false); updateButton.CopyStyle(moreInfoButton); updateButton.Width.Pixels = HasModIcon ? 120 : 200; updateButton.Left.Pixels = moreInfoButton.Width.Pixels + moreInfoButton.Left.Pixels + 5f; updateButton.WithFadedMouseOver(); updateButton.OnClick += DownloadMod; Append(updateButton); } if (modreferences.Length > 0) { var icon = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.ButtonExclamation.png")); var modReferenceIcon = new UIHoverImage(icon, Language.GetTextValue("tModLoader.MBClickToViewDependencyMods", string.Join("\n", modreferences.Split(',').Select(x => x.Trim())))) { Left = { Pixels = -149, Percent = 1f }, Top = { Pixels = 48 } }; modReferenceIcon.OnClick += (s, e) => { var modListItem = (UIModDownloadItem)e.Parent; Interface.modBrowser.SpecialModPackFilter = modListItem.modreferences.Split(',').Select(x => x.Trim()).ToList(); Interface.modBrowser.SpecialModPackFilterTitle = Language.GetTextValue("tModLoader.MBFilterDependencies"); // Toolong of \n" + modListItem.modName.Text; Interface.modBrowser.filterTextBox.Text = ""; Interface.modBrowser.updateNeeded = true; Main.PlaySound(SoundID.MenuOpen); }; Append(modReferenceIcon); } OnDoubleClick += RequestMoreinfo; }
public UIModDownloadItem(string displayName, string name, string version, string author, string modReferences, ModSide modSide, string modIconUrl, string downloadUrl, int downloads, int hot, string timeStamp, bool hasUpdate, bool updateIsDowngrade, LocalMod installed) { ModName = name; DisplayName = displayName; DownloadUrl = downloadUrl; _version = version; _author = author; _modReferences = modReferences; _modSide = modSide; _modIconUrl = modIconUrl; _downloads = downloads; _hot = hot; _timeStamp = timeStamp; HasUpdate = hasUpdate; UpdateIsDowngrade = updateIsDowngrade; Installed = installed; BorderColor = new Color(89, 116, 213) * 0.7f; _dividerTexture = TextureManager.Load("Images/UI/Divider"); _innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); Height.Pixels = 120; Width.Percent = 1f; SetPadding(6f); float left = HasModIcon ? 85f : 0f; _modName = new UIText(displayName) { Left = new StyleDimension(left + 5, 0f), Top = { Pixels = 5 } }; Append(_modName); _authorText = new UIText(Language.GetTextValue("tModLoader.ModsByline", author)) { Top = { Pixels = 83 } }; Append(_authorText); if (_timeStamp != "0000-00-00 00:00:00") { try { var myDateTime = DateTime.Parse(_timeStamp); string text = TimeHelper.HumanTimeSpanString(myDateTime); int textWidth = (int)Main.fontMouseText.MeasureString(text).X; _authorText.Left.Set(125 + 5, 0f); } catch (Exception e) { Logging.tML.Error(e.ToString()); } } _moreInfoButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo")) { Width = { Pixels = 100 }, Height = { Pixels = 36 }, Left = { Pixels = left }, Top = { Pixels = 40 } }.WithFadedMouseOver(); _moreInfoButton.PaddingTop -= 2f; _moreInfoButton.PaddingBottom -= 2f; _moreInfoButton.OnClick += RequestMoreInfo; Append(_moreInfoButton); if (hasUpdate || installed == null) { _updateButton = new UIAutoScaleTextTextPanel <string>(UpdateText).WithFadedMouseOver(); _updateButton.CopyStyle(_moreInfoButton); _updateButton.Width.Pixels = 120; _updateButton.Left.Pixels = _moreInfoButton.Width.Pixels + _moreInfoButton.Left.Pixels + 5f; _updateButton.OnClick += DownloadMod; Append(_updateButton); if (_modReferences.Length > 0) { _updateWithDepsButton = new UIAutoScaleTextTextPanel <string>(UpdateWithDepsText).WithFadedMouseOver(); _updateWithDepsButton.CopyStyle(_updateButton); _updateWithDepsButton.Width.Pixels = 220; _updateWithDepsButton.Left.Pixels = _updateButton.Width.Pixels + _updateButton.Left.Pixels + 5f; _updateWithDepsButton.OnClick += DownloadWithDeps; Append(_updateWithDepsButton); } } if (modReferences.Length > 0) { var icon = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.ButtonExclamation.png")); var modReferenceIcon = new UIHoverImage(icon, Language.GetTextValue("tModLoader.MBClickToViewDependencyMods", string.Join("\n", modReferences.Split(',').Select(x => x.Trim())))) { Left = { Pixels = -icon.Width, Percent = 1f }, Top = { Pixels = 83 } }; modReferenceIcon.OnClick += (s, e) => { var modListItem = (UIModDownloadItem)e.Parent; Interface.modBrowser.SpecialModPackFilter = modListItem._modReferences.Split(',').Select(x => x.Trim()).ToList(); Interface.modBrowser.SpecialModPackFilterTitle = Language.GetTextValue("tModLoader.MBFilterDependencies"); // Toolong of \n" + modListItem.modName.Text; Interface.modBrowser.FilterTextBox.Text = ""; Interface.modBrowser.UpdateNeeded = true; Main.PlaySound(SoundID.MenuOpen); }; Append(modReferenceIcon); } OnDoubleClick += RequestMoreInfo; }
public UIModDownloadItem(string displayname, string name, string version, string author, string modreferences, ModSide modside, string modIconURL, string download, int downloads, int hot, string timeStamp, bool update, bool updateIsDowngrade, TmodFile installed) { this.displayname = displayname; this.mod = name; this.version = version; this.author = author; this.modreferences = modreferences; this.modside = modside; this.modIconURL = modIconURL; this.download = download; this.downloads = downloads; this.hot = hot; this.timeStamp = timeStamp; this.update = update; this.updateIsDowngrade = updateIsDowngrade; this.installed = installed; this.BorderColor = new Color(89, 116, 213) * 0.7f; this.dividerTexture = TextureManager.Load("Images/UI/Divider"); this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); this.Height.Set(90f, 0f); this.Width.Set(0f, 1f); base.SetPadding(6f); float left = 0f; if (modIconURL != null) { left += 85; } string text = displayname + " " + version; this.modName = new UIText(text, 1f, false); this.modName.Left.Set(left + 5, 0f); this.modName.Top.Set(5f, 0f); base.Append(this.modName); UITextPanel <string> moreInfoButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo"), 1f, false); moreInfoButton.Width.Set(100f, 0f); moreInfoButton.Height.Set(30f, 0f); moreInfoButton.Left.Set(left, 0f); moreInfoButton.Top.Set(40f, 0f); moreInfoButton.PaddingTop -= 2f; moreInfoButton.PaddingBottom -= 2f; moreInfoButton.OnMouseOver += UICommon.FadedMouseOver; moreInfoButton.OnMouseOut += UICommon.FadedMouseOut; moreInfoButton.OnClick += RequestMoreinfo; Append(moreInfoButton); if (update || installed == null) { updateButton = new UITextPanel <string>(this.update ? (updateIsDowngrade ? Language.GetTextValue("tModLoader.MBDowngrade") : Language.GetTextValue("tModLoader.MBUpdate")) : Language.GetTextValue("tModLoader.MBDownload"), 1f, false); updateButton.CopyStyle(moreInfoButton); updateButton.Width.Set(modIconURL != null ? 120f : 200f, 0f); updateButton.Left.Set(moreInfoButton.Width.Pixels + moreInfoButton.Left.Pixels + 5f, 0f); updateButton.OnMouseOver += UICommon.FadedMouseOver; updateButton.OnMouseOut += UICommon.FadedMouseOut; updateButton.OnClick += this.DownloadMod; Append(updateButton); } if (modreferences.Length > 0) { UIHoverImage modReferenceIcon = new UIHoverImage(Main.quicksIconTexture, "This mod depends on: " + modreferences); modReferenceIcon.Left.Set(-135f, 1f); modReferenceIcon.Top.Set(50f, 0f); modReferenceIcon.OnClick += (s, e) => { UIModDownloadItem modListItem = (UIModDownloadItem)e.Parent; Interface.modBrowser.SpecialModPackFilter = modListItem.modreferences.Split(',').ToList(); Interface.modBrowser.SpecialModPackFilterTitle = "Dependencies"; // Toolong of \n" + modListItem.modName.Text; Interface.modBrowser.filterTextBox.currentString = ""; Interface.modBrowser.updateNeeded = true; Main.PlaySound(SoundID.MenuOpen); }; Append(modReferenceIcon); } OnDoubleClick += RequestMoreinfo; }
public UIModDownloadItem(string displayName, string name, string version, string author, string modReferences, ModSide modSide, string modIconUrl, string downloadUrl, int downloads, int hot, string timeStamp, bool hasUpdate, bool updateIsDowngrade, LocalMod installed, string modloaderversion) { ModName = name; DisplayName = displayName; DownloadUrl = downloadUrl; _version = version; _author = author; _modReferences = modReferences; _modSide = modSide; _modIconUrl = modIconUrl; _downloads = downloads; _hot = hot; _timeStamp = timeStamp; HasUpdate = hasUpdate; UpdateIsDowngrade = updateIsDowngrade; Installed = installed; BorderColor = new Color(89, 116, 213) * 0.7f; _dividerTexture = TextureManager.Load("Images/UI/Divider"); _innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); Height.Pixels = 90; Width.Percent = 1f; SetPadding(6f); float left = HasModIcon ? 85f : 0f; _modName = new UIText(displayName) { Left = new StyleDimension(left + 5, 0f), Top = { Pixels = 5 } }; Append(_modName); if (_timeStamp != "0000-00-00 00:00:00") { try { var myDateTime = DateTime.Parse(_timeStamp); string text = TimeHelper.HumanTimeSpanString(myDateTime); int textWidth = (int)Main.fontMouseText.MeasureString(text).X; } catch (Exception e) { Logging.tML.Error(e.ToString()); } } _moreInfoButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo")) { Width = { Pixels = 100 }, Height = { Pixels = 36 }, Left = { Pixels = left }, Top = { Pixels = 40 } }.WithFadedMouseOver(); _moreInfoButton.PaddingTop -= 2f; _moreInfoButton.PaddingBottom -= 2f; _moreInfoButton.OnClick += RequestMoreInfo; Append(_moreInfoButton); if (modloaderversion != null) { tMLUpdateRequired = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MBRequiresTMLUpdate", modloaderversion)).WithFadedMouseOver(Color.Orange, Color.Orange * 0.7f); tMLUpdateRequired.BackgroundColor = Color.Orange * 0.7f; tMLUpdateRequired.CopyStyle(_moreInfoButton); tMLUpdateRequired.Width.Pixels = 340; tMLUpdateRequired.Left.Pixels = _moreInfoButton.Width.Pixels + _moreInfoButton.Left.Pixels + 5f; tMLUpdateRequired.OnClick += (a, b) => { Process.Start("https://github.com/tModLoader/tModLoader/releases/latest"); }; Append(tMLUpdateRequired); } else if (hasUpdate || installed == null) { _updateButton = new UIImage(UICommon.buttonDownloadTexture); _updateButton.Top.Pixels = 40; _updateButton.Left.Set(-166, 1f); _updateButton.OnClick += DownloadMod; Append(_updateButton); if (_modReferences.Length > 0) { _updateButton.Left.Set(_updateButton.Left.Pixels - _updateButton.Width.Pixels - 6, 1f); _updateWithDepsButton = new UIImage(UICommon.buttonDownloadMultipleTexture); _updateWithDepsButton.CopyStyle(_updateButton); _updateWithDepsButton.Left.Pixels = _updateButton.Width.Pixels + _updateButton.Left.Pixels + 5f; _updateWithDepsButton.OnClick += DownloadWithDeps; Append(_updateWithDepsButton); } } if (modReferences.Length > 0) { var icon = UICommon.buttonExclamationTexture; var modReferenceIcon = new UIHoverImage(icon, Language.GetTextValue("tModLoader.MBClickToViewDependencyMods", string.Join("\n", modReferences.Split(',').Select(x => x.Trim())))) { Left = { Pixels = -icon.Width, Percent = 1f } }; modReferenceIcon.OnClick += (s, e) => { var modListItem = (UIModDownloadItem)e.Parent; Interface.modBrowser.SpecialModPackFilter = modListItem._modReferences.Split(',').Select(x => x.Trim()).ToList(); Interface.modBrowser.SpecialModPackFilterTitle = Language.GetTextValue("tModLoader.MBFilterDependencies"); // Toolong of \n" + modListItem.modName.Text; Interface.modBrowser.FilterTextBox.Text = ""; Interface.modBrowser.UpdateNeeded = true; Main.PlaySound(SoundID.MenuOpen); }; Append(modReferenceIcon); } OnDoubleClick += RequestMoreInfo; }
internal static bool LoadSide(ModSide side) => side != (Main.dedServ ? ModSide.Client : ModSide.Server);
public Side(ModSide side = ModSide.Common) => ValidSide = side;