From b6a0307139aadf2ccf333a13f35d55d3c6ea0c11 Mon Sep 17 00:00:00 2001 From: Lemon-King Date: Tue, 18 Jun 2024 18:01:13 -0400 Subject: [PATCH] NewGame: Cleanup Stringlocalize, DropDownList: Localize inside the component Small NewGame cleanup, enough to declutter the DropDownList localization mess --- .../zscript/menu/components/dropdowncombo.zs | 11 +++++++--- resources/assets/zscript/menu/newgame.zs | 20 +++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/resources/assets/zscript/menu/components/dropdowncombo.zs b/resources/assets/zscript/menu/components/dropdowncombo.zs index 7de6114..343828e 100644 --- a/resources/assets/zscript/menu/components/dropdowncombo.zs +++ b/resources/assets/zscript/menu/components/dropdowncombo.zs @@ -3,15 +3,20 @@ class DropDownCombo ui { HXDD_ZF_Frame frame; HXDD_ZF_Label label; HXDD_ZF_DropdownList ddl; - void Create(HXDD_ZF_Frame parent, vector2 position, vector2 dims, String text, HXDD_ZF_DropdownItems items, int defaultSelection, String command, HXDD_ZF_Handler handler) { + void Create(HXDD_ZF_Frame parent, vector2 position, vector2 dims, String label, HXDD_ZF_DropdownItems items, int defaultSelection, String command, HXDD_ZF_Handler handler) { int indent = 25; double labelWidth = dims.x * 0.45; double ddlWidth = dims.x * 0.55; if (items.items.Size() == 0) { - console.printf("DropdownList: %s is empty!", text); + console.printf("DropdownList: %s is empty!", label); items.items.push("EMPTY"); } + for (int i = 0; i < items.items.Size(); i++) { + if (items.items[i].Mid(0,1) == "$") { + items.items[i] = Stringtable.Localize(items.items[i]); + } + } let btNormal = HXDD_ZF_BoxTextures.createTexturePixels( "assets/ui/zforms/CommonBackgroundNormal.png", @@ -46,7 +51,7 @@ class DropDownCombo ui { self.label = HXDD_ZF_Label.create( (indent, 0), (labelWidth, dims.y), - text: text, + text: label.Mid(0,1) == "$" ? Stringtable.Localize(label) : label, alignment: 2 << 4, textScale: 3.5 //cmdHandler: handler, diff --git a/resources/assets/zscript/menu/newgame.zs b/resources/assets/zscript/menu/newgame.zs index af36a4e..ad63ee0 100644 --- a/resources/assets/zscript/menu/newgame.zs +++ b/resources/assets/zscript/menu/newgame.zs @@ -474,14 +474,14 @@ class ZFGameOptions ui { } } DropDownCombo ddl_Episodes = new ("DropDownCombo"); - ddl_Episodes.Create(optionArea, (0, 25), (optionArea.GetWidth() - 32, 50), Stringtable.Localize("$MNU_HEADER_EPISODE"), listEpisodes, parent.selectedEpisode, "episode", cmdHandler); + ddl_Episodes.Create(optionArea, (0, 25), (optionArea.GetWidth() - 32, 50), "$MNU_HEADER_EPISODE", listEpisodes, parent.selectedEpisode, "episode", cmdHandler); HXDD_ZF_DropdownItems skList = new("HXDD_ZF_DropdownItems"); for (int i = 0; i < gameinfo.skills.Size(); i++) { skList.items.push(gameinfo.skills[i].Get(parent.selectedClass)); } self.ddl_Difficulty = new ("DropDownCombo"); - self.ddl_Difficulty.Create(optionArea, (0, 25 + 75), (optionArea.GetWidth() - 32, 50), Stringtable.Localize("$MNU_HEADER_SKILLSELECTION"), skList, parent.selectedSkill, "skill", cmdHandler); + self.ddl_Difficulty.Create(optionArea, (0, 25 + 75), (optionArea.GetWidth() - 32, 50), "$MNU_HEADER_SKILLSELECTION", skList, parent.selectedSkill, "skill", cmdHandler); HXDD_ZF_DropdownItems listArmorMode = new("HXDD_ZF_DropdownItems"); listArmorMode.items.push("$OPT_CLASS_DEFAULT"); @@ -490,7 +490,7 @@ class ZFGameOptions ui { listArmorMode.items.push("$OPT_RANDOM"); //listArmorMode.items.push("Custom"); DropDownCombo ddl_ArmorMode = new ("DropDownCombo"); - ddl_ArmorMode.Create(optionArea, (0, 25 + 150), (optionArea.GetWidth() - 32, 50), Stringtable.Localize("$MNU_HEADER_ARMORMODE"), listArmorMode, 0, "hxdd_armor_mode", cmdHandler); + ddl_ArmorMode.Create(optionArea, (0, 25 + 150), (optionArea.GetWidth() - 32, 50), "$MNU_HEADER_ARMORMODE", listArmorMode, 0, "hxdd_armor_mode", cmdHandler); HXDD_ZF_DropdownItems listProgression = new("HXDD_ZF_DropdownItems"); listProgression.items.push("$OPT_CLASS_DEFAULT"); @@ -499,16 +499,16 @@ class ZFGameOptions ui { listProgression.items.push("$OPT_RANDOM"); //listProgression.items.push("Custom"); DropDownCombo ddl_Progression = new ("DropDownCombo"); - ddl_Progression.Create(optionArea, (0, 25 + 225), (optionArea.GetWidth() - 32, 50), Stringtable.Localize("$MNU_HEADER_PROGRESSIONMODE"), listProgression, 0, "hxdd_progression", cmdHandler); + ddl_Progression.Create(optionArea, (0, 25 + 225), (optionArea.GetWidth() - 32, 50), "$MNU_HEADER_PROGRESSIONMODE", listProgression, 0, "hxdd_progression", cmdHandler); HXDD_ZF_DropdownItems listMapSet = new("HXDD_ZF_DropdownItems"); listMapSet.items.push("$OPT_AUTO_DETECT"); listMapSet.items.push("$OPT_HERETIC"); listMapSet.items.push("$OPT_HEXEN"); DropDownCombo ddl_GameMode = new ("DropDownCombo"); - ddl_GameMode.Create(optionArea, (0, 25 + 300), (optionArea.GetWidth() - 32, 50), Stringtable.Localize("$MNU_HEADER_GAMEMODE"), listMapSet, 0, "hxdd_gamemode", cmdHandler); + ddl_GameMode.Create(optionArea, (0, 25 + 300), (optionArea.GetWidth() - 32, 50), "$MNU_HEADER_GAMEMODE", listMapSet, 0, "hxdd_gamemode", cmdHandler); + - let labelTex = HXDD_ZF_Label.create( (0, 25 + 450), (optionArea.GetWidth(), 50), @@ -523,16 +523,16 @@ class ZFGameOptions ui { listMapSetTex.items.push("Heretic"); listMapSetTex.items.push("Hexen"); DropDownCombo ddl_LavaStyle = new ("DropDownCombo"); - ddl_LavaStyle.Create(optionArea, (0, 25 + 525), (optionArea.GetWidth() - 32, 50), Stringtable.Localize("$MNU_TEXTURE_LAVA_STYLE"), listMapSetTex, 0, "hxdd_lavastyle", cmdHandler); + ddl_LavaStyle.Create(optionArea, (0, 25 + 525), (optionArea.GetWidth() - 32, 50), "$MNU_TEXTURE_LAVA_STYLE", listMapSetTex, 0, "hxdd_lavastyle", cmdHandler); DropDownCombo ddl_WaterStyle = new ("DropDownCombo"); - ddl_WaterStyle.Create(optionArea, (0, 25 + 600), (optionArea.GetWidth() - 32, 50), Stringtable.Localize("$MNU_TEXTURE_WATER_STYLE"), listMapSetTex, 0, "hxdd_waterstyle", cmdHandler); + ddl_WaterStyle.Create(optionArea, (0, 25 + 600), (optionArea.GetWidth() - 32, 50), "$MNU_TEXTURE_WATER_STYLE", listMapSetTex, 0, "hxdd_waterstyle", cmdHandler); DropDownCombo ddl_SludgeStyle = new ("DropDownCombo"); - ddl_SludgeStyle.Create(optionArea, (0, 25 + 675), (optionArea.GetWidth() - 32, 50), Stringtable.Localize("$MNU_TEXTURE_SLUDGE_STYLE"), listMapSetTex, 0, "hxdd_sludgestyle", cmdHandler); + ddl_SludgeStyle.Create(optionArea, (0, 25 + 675), (optionArea.GetWidth() - 32, 50), "$MNU_TEXTURE_SLUDGE_STYLE", listMapSetTex, 0, "hxdd_sludgestyle", cmdHandler); DropDownCombo ddl_IceStyle = new ("DropDownCombo"); - ddl_IceStyle.Create(optionArea, (0, 25 + 750), (optionArea.GetWidth() - 32, 50), Stringtable.Localize("$MNU_TEXTURE_ICE_STYLE"), listMapSetTex, 0, "hxdd_icestyle", cmdHandler); + ddl_IceStyle.Create(optionArea, (0, 25 + 750), (optionArea.GetWidth() - 32, 50), "$MNU_TEXTURE_ICE_STYLE", listMapSetTex, 0, "hxdd_icestyle", cmdHandler); //self.CreateXSwapsOptions(optionArea, 25 + 300 + 150, cmdHandler); }