From 9f59a84a37e6362a643a38b38a24567a2fdc240d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 20 Feb 2019 00:43:31 +0100 Subject: [PATCH] - allow text substitution for StaticPatch items in ListMenus --- wadsrc/static/menudef.txt | 26 ++++----------- wadsrc/static/zscript/menu/listmenuitems.txt | 33 +++++++++++++++++--- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 7ec552871..a16e42cc8 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -175,7 +175,7 @@ ListMenu "EpisodeMenu" IfGame(Doom, Chex) { Position 48, 63 - StaticPatch 54, 38, "M_EPISOD" + StaticPatch 54, 38, "M_EPISOD", 0 , "$MNU_EPISODE" } IfGame(Strife) { @@ -201,15 +201,15 @@ ListMenu "SkillMenu" IfGame(Doom, Chex) { - StaticPatch 96, 14, "M_NEWG" + StaticPatch 96, 14, "M_NEWG", 0, "$MNU_NEWGANE" } IfGame(Strife) { - StaticPatch 96, 14, "M_NGAME" + StaticPatch 96, 14, "M_NGAME", 0, "$MNU_NEWGANE" } IfGame(Doom, Strife, Chex) { - StaticPatch 54, 38, "M_SKILL" + StaticPatch 54, 38, "M_SKILL", 0, "$MNU_CHOOSESKILL" Position 48, 63 } IfGame (Heretic) @@ -253,14 +253,7 @@ ListMenu "LoadGameMenu" { NetgameMessage "$CLOADNET" } - IfGame(Doom, Strife, Chex) - { - StaticPatchCentered 160, -20, "M_LOADG" - } - IfGame(Heretic, Hexen) - { - StaticTextCentered 160, -10, "$MNU_LOADGAME" - } + StaticTextCentered 160, -10, "$MNU_LOADGAME" Position 80,54 Class "LoadMenu" // uses its own implementation } @@ -273,14 +266,7 @@ ListMenu "LoadGameMenu" ListMenu "SaveGameMenu" { - IfGame(Doom, Strife, Chex) - { - StaticPatchCentered 160, -20, "M_SAVEG" - } - IfGame(Heretic, Hexen) - { - StaticTextCentered 160, -10, "$MNU_SAVEGAME" - } + StaticTextCentered 160, -10, "$MNU_SAVEGAME" Position 80,54 Class "SaveMenu" // uses its own implementation } diff --git a/wadsrc/static/zscript/menu/listmenuitems.txt b/wadsrc/static/zscript/menu/listmenuitems.txt index 99050e1c9..28a0a7b47 100644 --- a/wadsrc/static/zscript/menu/listmenuitems.txt +++ b/wadsrc/static/zscript/menu/listmenuitems.txt @@ -67,12 +67,19 @@ class ListMenuItemStaticPatch : ListMenuItem { TextureID mTexture; bool mCentered; + String mSubstitute; + Font mFont; + int mColor; - void Init(double x, double y, TextureID patch, bool centered = false) + void Init(ListMenuDescriptor desc, double x, double y, TextureID patch, bool centered = false, const char *substitute = "") { Super.Init(x, y); mTexture = patch; mCentered = centered; + mSubstitute = substitute; + mFont = desc.mFont; + mColor = desc.mFontColor; + } override void Drawer(bool selected) @@ -86,14 +93,30 @@ class ListMenuItemStaticPatch : ListMenuItem Vector2 vec = TexMan.GetScaledSize(mTexture); if (mYpos >= 0) { - if (mCentered) x -= vec.X / 2; - screen.DrawTexture (mTexture, true, x, mYpos, DTA_Clean, true); + if (mSubstitute == "" || TexMan.OkForLocalization(mTexture)) + { + if (mCentered) x -= vec.X / 2; + screen.DrawTexture (mTexture, true, x, mYpos, DTA_Clean, true); + } + else + { + if (mCentered) x -= mFont.StringWidth(mSubstitute)/2; + screen.DrawText(mFont, mColor, x, mYpos, mSubstitute, DTA_Clean, true); + } } else { x = (mXpos - 160) * CleanXfac + (Screen.GetWidth()>>1); - if (mCentered) x -= (vec.X * CleanXfac)/2; - screen.DrawTexture (mTexture, true, x, -mYpos*CleanYfac, DTA_CleanNoMove, true); + if (mSubstitute == "" || TexMan.OkForLocalization(mTexture)) + { + if (mCentered) x -= (vec.X * CleanXfac)/2; + screen.DrawTexture (mTexture, true, x, -mYpos*CleanYfac, DTA_CleanNoMove, true); + } + else + { + if (mCentered) x -= (mFont.StringWidth(mSubstitute) * CleanXfac)/2; + screen.DrawText(mFont, mColor, x, mYpos, mSubstitute, DTA_CleanNoMove, true); + } } } }