//private UITextPanel<string> buttonOMF; public override void OnInitialize() { uIElement = new UIElement(); uIElement.Width.Set(0f, 0.8f); uIElement.MaxWidth.Set(600f, 0f); uIElement.Top.Set(220f, 0f); uIElement.Height.Set(-220f, 1f); uIElement.HAlign = 0.5f; uIPanel = new UIPanel(); uIPanel.Width.Set(0f, 1f); uIPanel.Height.Set(-110f, 1f); uIPanel.BackgroundColor = UICommon.MainPanelBackground; uIPanel.PaddingTop = 0f; uIElement.Append(uIPanel); modList = new UIList(); modList.Width.Set(-25f, 1f); modList.Height.Set(-50f, 1f); modList.Top.Set(50f, 0f); modList.ListPadding = 5f; uIPanel.Append(modList); UIScrollbar uIScrollbar = new UIScrollbar(); uIScrollbar.SetView(100f, 1000f); uIScrollbar.Height.Set(-50f, 1f); uIScrollbar.Top.Set(50f, 0f); uIScrollbar.HAlign = 1f; uIPanel.Append(uIScrollbar); modList.SetScrollbar(uIScrollbar); UITextPanel <string> uIHeaderTexTPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModsModsList"), 0.8f, true); uIHeaderTexTPanel.HAlign = 0.5f; uIHeaderTexTPanel.Top.Set(-35f, 0f); uIHeaderTexTPanel.SetPadding(15f); uIHeaderTexTPanel.BackgroundColor = UICommon.DefaultUIBlue; uIElement.Append(uIHeaderTexTPanel); buttonB = new UITextPanel <string>(Language.GetTextValue("UI.Back"), 1f, false); buttonB.Width.Set(-10f, 1f / 3f); buttonB.Height.Set(25f, 0f); buttonB.VAlign = 1f; buttonB.Top.Set(-20f, 0f); buttonB.WithFadedMouseOver(); buttonB.OnClick += BackClick; uIElement.Append(buttonB); //buttonOMF = new UITextPanel<string>(Language.GetTextValue("tModLoader.ModsOpenModsFolder"), 1f, false); //buttonOMF.CopyStyle(buttonB); //buttonOMF.HAlign = 0.5f; //buttonOMF.OnMouseOver += UICommon.FadedMouseOver; //buttonOMF.OnMouseOut += UICommon.FadedMouseOut; //buttonOMF.OnClick += OpenModsFolder; //uIElement.Append(buttonOMF); Append(uIElement); }
public override void OnInitialize() { var area = new UIElement { Width = { Percent = 0.8f }, Top = { Pixels = 200 }, Height = { Pixels = -240, Percent = 1f }, HAlign = 0.5f }; message.Width.Percent = 1f; message.Height.Percent = 0.8f; message.HAlign = 0.5f; area.Append(message); var button = new UITextPanel <string>("Ignore", 0.7f, true) { Width = { Pixels = -10, Percent = 0.5f }, Height = { Pixels = 50 }, VAlign = 1f, Top = { Pixels = -30 } }; button.WithFadedMouseOver(); button.OnClick += IgnoreClick; area.Append(button); var button2 = new UITextPanel <string>("Download", 0.7f, true); button2.CopyStyle(button); button2.HAlign = 1f; button2.WithFadedMouseOver(); button2.OnClick += OpenURL; area.Append(button2); Append(area); }
public override void OnInitialize() { area = new UIElement { Width = { Percent = 0.8f }, Top = { Pixels = 200 }, Height = { Pixels = -210, Percent = 1f }, HAlign = 0.5f }; messageBox = new UIMessageBox("") { Width = { Percent = 1f }, Height = { Pixels = -110, Percent = 1f }, HAlign = 0.5f }; area.Append(messageBox); continueButton = new UITextPanel <string>("", 0.7f, true) { Width = { Pixels = -10, Percent = 0.5f }, Height = { Pixels = 50 }, Top = { Pixels = -108, Percent = 1f } }; continueButton.WithFadedMouseOver(); continueButton.OnClick += ContinueClick; area.Append(continueButton); var openLogsButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.OpenLogs"), 0.7f, true); openLogsButton.CopyStyle(continueButton); openLogsButton.HAlign = 1f; openLogsButton.WithFadedMouseOver(); openLogsButton.OnClick += OpenFile; area.Append(openLogsButton); webHelpButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.OpenWebHelp"), 0.7f, true); webHelpButton.CopyStyle(openLogsButton); webHelpButton.Top.Set(-55f, 1f); webHelpButton.WithFadedMouseOver(); webHelpButton.OnClick += VisitRegisterWebpage; area.Append(webHelpButton); skipLoadButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.SkipToMainMenu"), 0.7f, true); skipLoadButton.CopyStyle(continueButton); skipLoadButton.Top.Set(-55f, 1f); skipLoadButton.WithFadedMouseOver(); skipLoadButton.OnClick += SkipLoad; area.Append(skipLoadButton); exitAndDisableAllButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.ExitAndDisableAll"), 0.7f, true); exitAndDisableAllButton.CopyStyle(skipLoadButton); exitAndDisableAllButton.TextColor = Color.Red; exitAndDisableAllButton.WithFadedMouseOver(); exitAndDisableAllButton.OnClick += ExitAndDisableAll; Append(area); }
public UIModManageItem(string displayname, string name, string version, string author, string downloads, string downloadsversion, string modloaderversion) { this.displayname = displayname; this.version = version; this.author = author; this.name = name; BorderColor = new Color(89, 116, 213) * 0.7f; dividerTexture = TextureManager.Load("Images/UI/Divider"); Height.Pixels = 90; Width.Percent = 1f; SetPadding(6f); string text = displayname + " " + version + " - by " + author + " - " + modloaderversion; modName = new UIText(text) { Left = { Pixels = 10 }, Top = { Pixels = 5 } }; Append(modName); var button = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBMyPublishedModsStats", downloads, downloadsversion)) { Width = { Pixels = 260 }, Height = { Pixels = 30 }, Left = { Pixels = 10 }, Top = { Pixels = 40 } }; button.PaddingTop -= 2f; button.PaddingBottom -= 2f; // button.OnMouseOver += UICommon.FadedMouseOver; // button.OnMouseOut += UICommon.FadedMouseOut; Append(button); button2 = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBUnpublish")); button2.CopyStyle(button); button2.Width.Pixels = 150; button2.Left.Pixels = 360; button2.WithFadedMouseOver(); button2.OnClick += Unpublish; Append(button2); }
public UIModManageItem(string displayname, string name, string version, string author, int downloads, int downloadsversion, string modloaderversion) { Displayname = displayname; Version = version; Author = author; Name = name; BorderColor = new Color(89, 116, 213) * 0.7f; _dividerTexture = UICommon.DividerTexture; Height.Pixels = 128; Width.Percent = 1f; SetPadding(6f); string text = displayname + " " + version + " - by " + author + " - " + modloaderversion; _modName = new UIText(text) { Left = { Pixels = 10 }, Top = { Pixels = 5 } }; Append(_modName); var button = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBMyPublishedModsStats", downloads, downloadsversion)) { Width = { Percent = 1f }, Height = { Pixels = 30 }, Top = { Pixels = 40 } }.WithFadedMouseOver(); button.PaddingTop -= 2f; button.PaddingBottom -= 2f; Append(button); _unpublishButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBUnpublish")); _unpublishButton.CopyStyle(button); _unpublishButton.Width.Set(150, 0f); _unpublishButton.Top.Pixels = 80; _unpublishButton.HAlign = 1f; _unpublishButton.WithFadedMouseOver(); _unpublishButton.OnClick += UnpublishMod; Append(_unpublishButton); }
internal void Populate() { int i = 0; foreach (var item in ConfigManager.Configs) { foreach (var config in item.Value) { //if (config.Mode == ConfigScope.ClientSide) { string configDisplayName = ((LabelAttribute)Attribute.GetCustomAttribute(config.GetType(), typeof(LabelAttribute)))?.Label ?? config.Name; UITextPanel <string> t = new UITextPanel <string>(item.Key.DisplayName + ": " + configDisplayName); //UIText t = new UIText(item.Key.DisplayName + ": " + item.Value.Count); t.OnClick += (a, b) => { Interface.modConfig.SetMod(item.Key, config); Main.InGameUI.SetState(Interface.modConfig); }; t.WithFadedMouseOver(); t.HAlign = 0.5f; UIElement container = new UISortableElement(i++); container.Width.Set(0f, 1f); container.Height.Set(40f, 0f); container.HAlign = 1f; container.Append(t); modList.Add(container); if (config.Mode == ConfigScope.ServerSide) { t.BackgroundColor = Color.Pink * 0.7f; t.OnMouseOver += (a, b) => t.BackgroundColor = Color.Pink; t.OnMouseOut += (a, b) => t.BackgroundColor = Color.Pink * 0.7f; } } } } }
internal static UIPanel MakeSeparateListPanel(object item, object subitem, PropertyFieldWrapper memberInfo, IList array, int index, Func <string> AbridgedTextDisplayFunction) { UIPanel uIPanel = new UIPanel(); uIPanel.CopyStyle(Interface.modConfig.uIPanel); uIPanel.BackgroundColor = UICommon.MainPanelBackground; BackgroundColorAttribute bca = ConfigManager.GetCustomAttribute <BackgroundColorAttribute>(memberInfo, subitem, null); if (bca != null) { uIPanel.BackgroundColor = bca.color; } //uIElement.Append(uIPanel); UIList separateList = new UIList(); separateList.CopyStyle(Interface.modConfig.mainConfigList); separateList.Height.Set(-40f, 1f); separateList.Top.Set(40f, 0f); uIPanel.Append(separateList); int i = 0; int top = 0; UIScrollbar uIScrollbar = new UIScrollbar(); uIScrollbar.SetView(100f, 1000f); uIScrollbar.Height.Set(-40f, 1f); uIScrollbar.Top.Set(40f, 0f); uIScrollbar.HAlign = 1f; uIPanel.Append(uIScrollbar); separateList.SetScrollbar(uIScrollbar); string name = ConfigManager.GetCustomAttribute <LabelAttribute>(memberInfo, subitem, null)?.Label ?? memberInfo.Name; if (index != -1) { name = name + " #" + (index + 1); } Interface.modConfig.subPageStack.Push(name); //UIPanel heading = new UIPanel(); //UIText headingText = new UIText(name); name = string.Join(" > ", Interface.modConfig.subPageStack.Reverse()); //.Aggregate((current, next) => current + "/" + next); UITextPanel <string> heading = new UITextPanel <string>(name); // TODO: ToString as well. Separate label? heading.HAlign = 0f; //heading.Width.Set(-10, 0.5f); //heading.Left.Set(60, 0f); heading.Top.Set(-6, 0); heading.Height.Set(40, 0); //var headingContainer = GetContainer(heading, i++); //headingContainer.Height.Pixels = 40; uIPanel.Append(heading); //headingText.Top.Set(6, 0); //headingText.Left.Set(0, .5f); //headingText.HAlign = .5f; //uIPanel.Append(headingText); //top += 40; UITextPanel <string> back = new UITextPanel <string>("Back"); back.HAlign = 1f; back.Width.Set(50, 0f); back.Top.Set(-6, 0); //top += 40; //var capturedCurrent = Interface.modConfig.currentConfigList; back.OnClick += (a, c) => { Interface.modConfig.uIElement.RemoveChild(uIPanel); Interface.modConfig.configPanelStack.Pop(); Interface.modConfig.uIElement.Append(Interface.modConfig.configPanelStack.Peek()); //Interface.modConfig.configPanelStack.Peek().SetScrollbar(Interface.modConfig.uIScrollbar); //Interface.modConfig.currentConfigList = capturedCurrent; }; back.WithFadedMouseOver(); //var backContainer = GetContainer(back, i++); //backContainer.Height.Pixels = 40; uIPanel.Append(back); //var b = new UIText("Test"); //separateList.Add(b); // Make rest of list // load all mod config options into UIList // TODO: Inheritance with ModConfig? DeclaredOnly? if (true) { int order = 0; bool hasToString = false; if (array != null) { var listType = memberInfo.Type.GetGenericArguments()[0]; hasToString = listType.GetMethod("ToString", new Type[0]).DeclaringType != typeof(object); } else { hasToString = memberInfo.Type.GetMethod("ToString", new Type[0]).DeclaringType != typeof(object); } if (AbridgedTextDisplayFunction != null) { var display = new UITextPanel <FuncStringWrapper>(new FuncStringWrapper() { func = AbridgedTextDisplayFunction, }) { DrawPanel = true }; display.Recalculate(); var container = GetContainer(display, order++); container.Height.Pixels = (int)display.GetOuterDimensions().Height; separateList.Add(container); } //if (hasToString) // _TextDisplayFunction = () => index + 1 + ": " + (array[index]?.ToString() ?? "null"); foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(subitem)) { if (Attribute.IsDefined(variable.MemberInfo, typeof(JsonIgnoreAttribute)) && !Attribute.IsDefined(variable.MemberInfo, typeof(LabelAttribute))) // TODO, appropriately named attribute { continue; } HeaderAttribute header = ConfigManager.GetCustomAttribute <HeaderAttribute>(variable, null, null); if (header != null) { var wrapper = new PropertyFieldWrapper(typeof(HeaderAttribute).GetProperty(nameof(HeaderAttribute.Header))); WrapIt(separateList, ref top, wrapper, header, order++); } WrapIt(separateList, ref top, variable, subitem, order++); } } else { //ignoreSeparatePage just to simplify ToString label--> had some issues. //WrapIt(separateList, ref top, memberInfo, item, 1, ignoreSeparatePage: true); } Interface.modConfig.subPageStack.Pop(); return(uIPanel); }
public override void OnInitialize() { uIElement = new UIElement(); uIElement.Width.Set(0f, 0.8f); uIElement.MaxWidth.Set(600f, 0f); uIElement.Top.Set(160f, 0f); uIElement.Height.Set(-180f, 1f); uIElement.HAlign = 0.5f; uIPanel = new UIPanel(); uIPanel.Width.Set(0f, 1f); uIPanel.Height.Set(-140f, 1f); uIPanel.Top.Set(30f, 0f); uIPanel.BackgroundColor = UICommon.MainPanelBackground; uIElement.Append(uIPanel); UIPanel textBoxBackground = new UIPanel(); textBoxBackground.SetPadding(0); filterTextField = new UIFocusInputTextField("Filter Options"); textBoxBackground.Top.Set(2f, 0f); textBoxBackground.Left.Set(-190, 1f); textBoxBackground.Width.Set(180, 0f); textBoxBackground.Height.Set(30, 0f); uIElement.Append(textBoxBackground); filterTextField.SetText(""); filterTextField.Top.Set(5, 0f); filterTextField.Left.Set(10, 0f); filterTextField.Width.Set(-20, 1f); filterTextField.Height.Set(20, 0); filterTextField.OnTextChange += (a, b) => { updateNeeded = true; }; filterTextField.OnRightClick += (a, b) => { filterTextField.SetText(""); }; textBoxBackground.Append(filterTextField); // TODO: ModConfig Localization support message = new UITextPanel <string>("Notification: "); message.Width.Set(-80f, 1f); message.Height.Set(20f, 0f); message.HAlign = 0.5f; message.VAlign = 1f; message.Top.Set(-65f, 0f); uIElement.Append(message); mainConfigList = new UIList(); mainConfigList.Width.Set(-25f, 1f); mainConfigList.Height.Set(0f, 1f); //mainConfigList.Top.Set(40f, 0f); mainConfigList.ListPadding = 5f; uIPanel.Append(mainConfigList); configPanelStack.Push(uIPanel); //currentConfigList = mainConfigList; uIScrollbar = new UIScrollbar(); uIScrollbar.SetView(100f, 1000f); uIScrollbar.Height.Set(0f, 1f); uIScrollbar.HAlign = 1f; uIPanel.Append(uIScrollbar); mainConfigList.SetScrollbar(uIScrollbar); headerTextPanel = new UITextPanel <string>("Mod Config", 0.8f, true); headerTextPanel.HAlign = 0.5f; headerTextPanel.Top.Set(-50f, 0f); headerTextPanel.SetPadding(15f); headerTextPanel.BackgroundColor = UICommon.DefaultUIBlue; uIElement.Append(headerTextPanel); previousConfigButton = new UITextPanel <string>("<", 1f, false); previousConfigButton.Width.Set(25f, 0); previousConfigButton.Height.Set(25f, 0f); previousConfigButton.VAlign = 1f; previousConfigButton.Top.Set(-65f, 0f); previousConfigButton.HAlign = 0f; previousConfigButton.WithFadedMouseOver(); previousConfigButton.OnClick += PreviousConfig; //uIElement.Append(previousConfigButton); nextConfigButton = new UITextPanel <string>(">", 1f, false); nextConfigButton.CopyStyle(previousConfigButton); nextConfigButton.WithFadedMouseOver(); nextConfigButton.HAlign = 1f; nextConfigButton.OnClick += NextConfig; //uIElement.Append(nextConfigButton); saveConfigButton = new UITextPanel <string>("Save Config", 1f, false); saveConfigButton.Width.Set(-10f, 1f / 4f); saveConfigButton.Height.Set(25f, 0f); saveConfigButton.Top.Set(-20f, 0f); saveConfigButton.WithFadedMouseOver(); saveConfigButton.HAlign = 0.33f; saveConfigButton.VAlign = 1f; saveConfigButton.OnClick += SaveConfig; //uIElement.Append(saveConfigButton); backButton = new UITextPanel <string>("Back", 1f, false); backButton.CopyStyle(saveConfigButton); backButton.HAlign = 0; backButton.WithFadedMouseOver(); backButton.OnMouseOver += (a, b) => { if (pendingChanges) { backButton.BackgroundColor = Color.Red; } }; backButton.OnMouseOut += (a, b) => { if (pendingChanges) { backButton.BackgroundColor = Color.Red * 0.7f; } }; backButton.OnClick += BackClick; uIElement.Append(backButton); revertConfigButton = new UITextPanel <string>("Revert Changes", 1f, false); revertConfigButton.CopyStyle(saveConfigButton); revertConfigButton.WithFadedMouseOver(); revertConfigButton.HAlign = 0.66f; revertConfigButton.OnClick += RevertConfig; //uIElement.Append(revertConfigButton); //float scale = Math.Min(1f, 130f/Main.fontMouseText.MeasureString("Restore Defaults").X); restoreDefaultsConfigButton = new UITextPanel <string>("Restore Defaults", 1f, false); restoreDefaultsConfigButton.CopyStyle(saveConfigButton); restoreDefaultsConfigButton.WithFadedMouseOver(); restoreDefaultsConfigButton.HAlign = 1f; restoreDefaultsConfigButton.OnClick += RestoreDefaults; uIElement.Append(restoreDefaultsConfigButton); uIPanel.BackgroundColor = UICommon.MainPanelBackground; Append(uIElement); }
public UIModItem(LocalMod mod) { this.mod = mod; 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); //base.OnClick += this.ToggleEnabled; string text = mod.DisplayName + " v" + mod.modFile.version; if (mod.tModLoaderVersion < new Version(0, 10)) { text += $" [c/FF0000:({Language.GetTextValue("tModLoader.ModOldWarning")})]"; } if (mod.modFile.HasFile("icon.png")) { try { Texture2D modIconTexture; using (mod.modFile.Open()) using (var s = mod.modFile.GetStream("icon.png")) modIconTexture = Texture2D.FromStream(Main.instance.GraphicsDevice, s); if (modIconTexture.Width == 80 && modIconTexture.Height == 80) { modIcon = new UIImage(modIconTexture) { Left = { Percent = 0f }, Top = { Percent = 0f } }; Append(modIcon); modIconAdjust += 85; } } catch { } } modName = new UIText(text) { Left = new StyleDimension(modIconAdjust + 10f, 0f), Top = { Pixels = 5 } }; Append(modName); var moreInfoButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsMoreInfo")) { Width = { Pixels = 100 }, Height = { Pixels = 36 }, Left = { Pixels = 430 }, Top = { Pixels = 40 } }.WithFadedMouseOver(); moreInfoButton.PaddingTop -= 2f; moreInfoButton.PaddingBottom -= 2f; moreInfoButton.OnClick += Moreinfo; Append(moreInfoButton); toggleModEnabledButton = new UIAutoScaleTextTextPanel <string>(mod.Enabled ? Language.GetTextValue("tModLoader.ModsDisable") : Language.GetTextValue("tModLoader.ModsEnable")) { Width = { Pixels = 100 }, Height = { Pixels = 36 }, Top = { Pixels = 40 } }.WithFadedMouseOver(); toggleModEnabledButton.Left.Pixels = moreInfoButton.Left.Pixels - toggleModEnabledButton.Width.Pixels - 5f; toggleModEnabledButton.PaddingTop -= 2f; toggleModEnabledButton.PaddingBottom -= 2f; toggleModEnabledButton.OnClick += ToggleEnabled; Append(toggleModEnabledButton); Mod loadedMod = ModLoader.GetMod(mod.Name); if (loadedMod != null && ConfigManager.Configs.ContainsKey(loadedMod)) // and has config { configButton = new UITextPanel <string>("Config", 1f, false); configButton.Width.Set(100f, 0f); configButton.Height.Set(30f, 0f); configButton.Left.Set(toggleModEnabledButton.Left.Pixels - configButton.Width.Pixels - 5f, 0f); configButton.Top.Set(40f, 0f); configButton.PaddingTop -= 2f; configButton.PaddingBottom -= 2f; configButton.WithFadedMouseOver(); configButton.OnClick += this.OpenConfig; Append(configButton); if (ConfigManager.ModNeedsReload(loadedMod)) { configChangesRequireReload = true; } } var modRefs = mod.properties.modReferences.Select(x => x.mod).ToArray(); if (modRefs.Length > 0 && !mod.Enabled) { string refs = string.Join(", ", mod.properties.modReferences); var icon = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.ButtonExclamation.png")); var modReferenceIcon = new UIHoverImage(icon, Language.GetTextValue("tModLoader.ModDependencyClickTooltip", refs)) { Left = new StyleDimension(toggleModEnabledButton.Left.Pixels - 24f, 0f), Top = { Pixels = 47 } }; modReferenceIcon.OnClick += (a, b) => { var modList = ModOrganizer.FindMods(); var missing = new List <string>(); foreach (var modRef in modRefs) { ModLoader.EnableMod(modRef); if (!modList.Any(m => m.Name == modRef)) { missing.Add(modRef); } } Main.menuMode = Interface.modsMenuID; if (missing.Any()) { Interface.infoMessage.Show(Language.GetTextValue("tModLoader.ModDependencyModsNotFound", String.Join(",", missing)), Interface.modsMenuID); } }; Append(modReferenceIcon); } if (mod.modFile.ValidModBrowserSignature) { keyImage = new UIHoverImage(Main.itemTexture[ID.ItemID.GoldenKey], Language.GetTextValue("tModLoader.ModsOriginatedFromModBrowser")) { Left = { Pixels = -20, Percent = 1f } }; Append(keyImage); } if (ModLoader.badUnloaders.Contains(mod.Name)) { keyImage = new UIHoverImage(Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.ButtonError.png")), "This mod did not fully unload during last unload.") { Left = { Pixels = modIconAdjust + 4 }, Top = { Pixels = 3 } }; Append(keyImage); modName.Left.Pixels += 20; } if (mod.properties.beta) { keyImage = new UIHoverImage(Main.itemTexture[ID.ItemID.ShadowKey], Language.GetTextValue("tModLoader.BetaModCantPublish")) { Left = { Pixels = -10, Percent = 1f } }; Append(keyImage); } if (loadedMod != null) { loaded = true; int[] values = { loadedMod.items.Count, loadedMod.npcs.Count, loadedMod.tiles.Count, loadedMod.walls.Count, loadedMod.buffs.Count, loadedMod.mountDatas.Count }; string[] localizationKeys = { "ModsXItems", "ModsXNPCs", "ModsXTiles", "ModsXWalls", "ModsXBuffs", "ModsXMounts" }; int xOffset = -40; for (int i = 0; i < values.Length; i++) { if (values[i] > 0) { Texture2D iconTexture = Main.instance.infoIconTexture[i]; keyImage = new UIHoverImage(iconTexture, Language.GetTextValue($"tModLoader.{localizationKeys[i]}", values[i])) { Left = { Pixels = xOffset, Percent = 1f } }; Append(keyImage); xOffset -= 18; } } } }
public override void OnInitialize() { var uIElement = new UIElement { Width = { Percent = 0.8f }, MaxWidth = UICommon.MaxPanelWidth, Top = { Pixels = 220 }, Height = { Pixels = -220, Percent = 1f }, HAlign = 0.5f }; var uIPanel = new UIPanel { Width = { Percent = 1f }, Height = { Pixels = -110, Percent = 1f }, BackgroundColor = UICommon.MainPanelBackground, PaddingTop = 0f }; uIElement.Append(uIPanel); UITextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBPublishEnterPassphrase"), 0.8f, true) { HAlign = 0.5f, Top = { Pixels = -35 }, BackgroundColor = UICommon.DefaultUIBlue }.WithPadding(15); uIElement.Append(UITextPanel); var buttonBack = new UITextPanel <string>(Language.GetTextValue("UI.Back")) { Width = { Pixels = -10, Percent = 0.5f }, Height = { Pixels = 25 }, VAlign = 1f, Top = { Pixels = -65 } }.WithFadedMouseOver(); buttonBack.OnClick += BackClick; uIElement.Append(buttonBack); var buttonSubmit = new UITextPanel <string>(Language.GetTextValue("UI.Submit")); buttonSubmit.CopyStyle(buttonBack); buttonSubmit.HAlign = 1f; buttonSubmit.WithFadedMouseOver(); buttonSubmit.OnClick += SubmitPassphrase; uIElement.Append(buttonSubmit); var buttonVisitWebsite = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBPublishVisitWebsiteForPassphrase")); buttonVisitWebsite.CopyStyle(buttonBack); buttonVisitWebsite.Width.Percent = 1f; buttonVisitWebsite.Top.Pixels = -20; buttonVisitWebsite.WithFadedMouseOver(); buttonVisitWebsite.OnClick += VisitRegisterWebpage; uIElement.Append(buttonVisitWebsite); PasscodeTextField = new UIInputTextField(Language.GetTextValue("tModLoader.MBPublishPastePassphrase")) { HAlign = 0.5f, VAlign = 0.5f, Left = { Pixels = -100, Percent = 0 } }; PasscodeTextField.OnTextChange += OnTextChange; uIPanel.Append(PasscodeTextField); Append(uIElement); }
public override void OnInitialize() { _area = new UIElement { Width = { Percent = 0.8f }, Top = { Pixels = 200 }, Height = { Pixels = -210, Percent = 1f }, HAlign = 0.5f }; UIPanel backPanel = new UIPanel { Width = { Percent = 1f }, Height = { Pixels = -110, Percent = 1f }, BackgroundColor = UICommon.MainPanelBackground }; _area.Append(backPanel); _messageBox = new UIMessageBox(string.Empty) { Width = { Pixels = -25, Percent = 1f }, Height = { Percent = 1f } }; backPanel.Append(_messageBox); UIScrollbar scrollbar = new UIScrollbar { Height = { Pixels = -20, Percent = 1f }, VAlign = 0.5f, HAlign = 1f }.WithView(100f, 1000f); backPanel.Append(scrollbar); _messageBox.SetScrollbar(scrollbar); _exitButton = new UITextPanel <string>(Language.GetTextValue("UI.Back"), 0.7f, true) { Width = { Pixels = -10, Percent = 1f }, Height = { Pixels = 50 }, Top = { Pixels = -108, Percent = 1f } }.WithFadedMouseOver(); _exitButton.OnClick += ExitButtonClick; _area.Append(_exitButton); _previousButton = new UITextPanel <string>("Previous", 0.7f, true); _previousButton.CopyStyle(_exitButton); _previousButton.Width.Set(-10, 0.5f); _previousButton.Top.Set(-55f, 1f); _previousButton.WithFadedMouseOver(); _previousButton.OnClick += PreviousOnClick; if (Index != ChangelogData.Changelogs.Count - 1) { _area.Append(_previousButton); } _nextButton = new UITextPanel <string>("Next", 0.7f, true); _nextButton.CopyStyle(_previousButton); _nextButton.HAlign = 1f; _nextButton.WithFadedMouseOver(); _nextButton.OnClick += NextOnClick; if (Index != 0) { _area.Append(_nextButton); } Append(_area); }
public override void OnInitialize() { var uIElement = new UIElement { Width = { Percent = 0.8f }, MaxWidth = UICommon.MaxPanelWidth, Top = { Pixels = 220 }, Height = { Pixels = -220, Percent = 1f }, HAlign = 0.5f }; var uIPanel = new UIPanel { Width = { Percent = 1f }, Height = { Pixels = -110, Percent = 1f }, BackgroundColor = UICommon.MainPanelBackground, PaddingTop = 0f }; uIElement.Append(uIPanel); UiTextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.EnterSteamID"), 0.8f, true) { HAlign = 0.5f, Top = { Pixels = -35 }, BackgroundColor = UICommon.DefaultUIBlue }.WithPadding(15f); uIElement.Append(UiTextPanel); var button = new UITextPanel <string>(Language.GetTextValue("UI.Back")) { Width = { Pixels = -10, Percent = 0.5f }, Height = { Pixels = 25 }, VAlign = 1f, Top = { Pixels = -65 } }; button.WithFadedMouseOver(); button.OnClick += BackClick; uIElement.Append(button); button = new UITextPanel <string>(Language.GetTextValue("UI.Submit")); button.CopyStyle(button); button.HAlign = 1f; button.WithFadedMouseOver(); button.OnClick += SubmitSteamID; uIElement.Append(button); // TODO Commented code, yuck //UITextPanel<string> button3 = new UITextPanel<string>("Visit Website to Generate Passphrase"); //button3.CopyStyle(button); //button3.Width.Set(0f, 1f); //button3.Top.Set(-20f, 0f); //button3.OnMouseOver += UICommon.FadedMouseOver; //button3.OnMouseOut += UICommon.FadedMouseOut; //button3.OnClick += VisitRegisterWebpage; //uIElement.Append(button3); SteamIdTextField = new UIInputTextField(Language.GetTextValue("tModLoader.PasteSteamID")) { HAlign = 0.5f, VAlign = 0.5f, Left = { Pixels = -100, Percent = 0 } }; SteamIdTextField.OnTextChange += OnTextChange; uIPanel.Append(SteamIdTextField); Append(uIElement); }
public override void OnInitialize() { var uIElement = new UIElement { Width = { Percent = 0.8f }, MaxWidth = UICommon.MaxPanelWidth, Top = { Pixels = 220 }, Height = { Pixels = -220, Percent = 1f }, HAlign = 0.5f }; Append(uIElement); var mainPanel = new UIPanel { Width = { Percent = 1f }, Height = { Pixels = -110, Percent = 1f }, BackgroundColor = UICommon.MainPanelBackground, PaddingTop = 0f }; uIElement.Append(mainPanel); var uITextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.MSCreateMod"), 0.8f, true) { HAlign = 0.5f, Top = { Pixels = -35 }, BackgroundColor = UICommon.DefaultUIBlue }.WithPadding(15); uIElement.Append(uITextPanel); _messagePanel = new UITextPanel <string>(Language.GetTextValue("")) { Width = { Percent = 1f }, Height = { Pixels = 25 }, VAlign = 1f, Top = { Pixels = -20 } }; uIElement.Append(_messagePanel); var buttonBack = new UITextPanel <string>(Language.GetTextValue("UI.Back")) { Width = { Pixels = -10, Percent = 0.5f }, Height = { Pixels = 25 }, VAlign = 1f, Top = { Pixels = -65 } }.WithFadedMouseOver(); buttonBack.OnClick += BackClick; uIElement.Append(buttonBack); var buttonCreate = new UITextPanel <string>(Language.GetTextValue("LegacyMenu.28")); // Create buttonCreate.CopyStyle(buttonBack); buttonCreate.HAlign = 1f; buttonCreate.WithFadedMouseOver(); buttonCreate.OnClick += OKClick; uIElement.Append(buttonCreate); float top = 16; _modName = createAndAppendTextInputWithLabel("ModName (no spaces)", "Type here"); _modName.OnTextChange += (a, b) => { _modName.SetText(_modName.CurrentString.Replace(" ", "")); }; _modDiplayName = createAndAppendTextInputWithLabel("Mod DisplayName", "Type here"); _modAuthor = createAndAppendTextInputWithLabel("Mod Author", "Type here"); _basicSword = createAndAppendTextInputWithLabel("BasicSword (no spaces)", "Leave Blank to Skip"); _modName.OnTab += (a, b) => _modDiplayName.Focused = true; _modDiplayName.OnTab += (a, b) => _modAuthor.Focused = true; _modAuthor.OnTab += (a, b) => _basicSword.Focused = true; _basicSword.OnTab += (a, b) => _modName.Focused = true; UIFocusInputTextField createAndAppendTextInputWithLabel(string label, string hint) { var panel = new UIPanel(); panel.SetPadding(0); panel.Width.Set(0, 1f); panel.Height.Set(40, 0f); panel.Top.Set(top, 0f); top += 46; var modNameText = new UIText(label) { Left = { Pixels = 10 }, Top = { Pixels = 10 } }; panel.Append(modNameText); var textBoxBackground = new UIPanel(); textBoxBackground.SetPadding(0); textBoxBackground.Top.Set(6f, 0f); textBoxBackground.Left.Set(0, .5f); textBoxBackground.Width.Set(0, .5f); textBoxBackground.Height.Set(30, 0f); panel.Append(textBoxBackground); var uIInputTextField = new UIFocusInputTextField(hint) { UnfocusOnTab = true }; uIInputTextField.Top.Set(5, 0f); uIInputTextField.Left.Set(10, 0f); uIInputTextField.Width.Set(-20, 1f); uIInputTextField.Height.Set(20, 0); textBoxBackground.Append(uIInputTextField); mainPanel.Append(panel); return(uIInputTextField); } }
public override void OnInitialize() { UIElement uIElement = new UIElement { Width = { Percent = 0.8f }, MaxWidth = UICommon.MaxPanelWidth, Top = { Pixels = 220 }, Height = { Pixels = -220, Percent = 1f }, HAlign = 0.5f }; Append(uIElement); UIPanel mainPanel = new UIPanel { Width = { Percent = 1f }, Height = { Pixels = -110, Percent = 1f }, BackgroundColor = UICommon.MainPanelBackground, PaddingTop = 0f }; uIElement.Append(mainPanel); UITextPanel <string> uITextPanel = new UITextPanel <string>("Advanced Create Mod", 0.8f, true) { HAlign = 0.5f, Top = { Pixels = -45 }, BackgroundColor = UICommon.DefaultUIBlue }.WithPadding(15); uIElement.Append(uITextPanel); infoTextPanel = new UITextPanel <string>("No Problems Found. If a problem occurs it will be shown here") { Width = { Percent = 1f }, Height = { Pixels = 25 }, VAlign = 1f, Top = { Pixels = -10 } }; uIElement.Append(infoTextPanel); UITextPanel <string> buttonBack = new UITextPanel <string>(Language.GetTextValue("UI.Back")) { Width = { Pixels = -10, Percent = 0.5f }, Height = { Pixels = 25 }, VAlign = 1f, Top = { Pixels = -65 } }.WithFadedMouseOver(); buttonBack.OnClick += BackClick; uIElement.Append(buttonBack); UITextPanel <string> buttonCreate = new UITextPanel <string>("Create"); // Create buttonCreate.CopyStyle(buttonBack); buttonCreate.HAlign = 1f; buttonCreate.WithFadedMouseOver(); buttonCreate.OnClick += OKClick; uIElement.Append(buttonCreate); float top = 16; internalNamePanel = AddInput("Internal Name", mainPanel, ref top, true); displayNamePanel = AddInput("Display Name", mainPanel, ref top); authorsPanel = AddInput("Author(s)", mainPanel, ref top); AddToggle("Test 1?", mainPanel, ref top); AddToggle("Test 2?", mainPanel, ref top); AddToggle("Test 3?", mainPanel, ref top); AddToggle("Test 4?", mainPanel, ref top); AddToggle("Test 5?", mainPanel, ref top); AddInput("Test 6?", mainPanel, ref top); }