- allow text substitution for StaticPatch items in ListMenus

This commit is contained in:
Christoph Oelckers 2019-02-20 00:43:31 +01:00
parent 8587f253a8
commit 9f59a84a37
2 changed files with 34 additions and 25 deletions

View File

@ -175,7 +175,7 @@ ListMenu "EpisodeMenu"
IfGame(Doom, Chex) IfGame(Doom, Chex)
{ {
Position 48, 63 Position 48, 63
StaticPatch 54, 38, "M_EPISOD" StaticPatch 54, 38, "M_EPISOD", 0 , "$MNU_EPISODE"
} }
IfGame(Strife) IfGame(Strife)
{ {
@ -201,15 +201,15 @@ ListMenu "SkillMenu"
IfGame(Doom, Chex) IfGame(Doom, Chex)
{ {
StaticPatch 96, 14, "M_NEWG" StaticPatch 96, 14, "M_NEWG", 0, "$MNU_NEWGANE"
} }
IfGame(Strife) IfGame(Strife)
{ {
StaticPatch 96, 14, "M_NGAME" StaticPatch 96, 14, "M_NGAME", 0, "$MNU_NEWGANE"
} }
IfGame(Doom, Strife, Chex) IfGame(Doom, Strife, Chex)
{ {
StaticPatch 54, 38, "M_SKILL" StaticPatch 54, 38, "M_SKILL", 0, "$MNU_CHOOSESKILL"
Position 48, 63 Position 48, 63
} }
IfGame (Heretic) IfGame (Heretic)
@ -253,14 +253,7 @@ ListMenu "LoadGameMenu"
{ {
NetgameMessage "$CLOADNET" NetgameMessage "$CLOADNET"
} }
IfGame(Doom, Strife, Chex) StaticTextCentered 160, -10, "$MNU_LOADGAME"
{
StaticPatchCentered 160, -20, "M_LOADG"
}
IfGame(Heretic, Hexen)
{
StaticTextCentered 160, -10, "$MNU_LOADGAME"
}
Position 80,54 Position 80,54
Class "LoadMenu" // uses its own implementation Class "LoadMenu" // uses its own implementation
} }
@ -273,14 +266,7 @@ ListMenu "LoadGameMenu"
ListMenu "SaveGameMenu" ListMenu "SaveGameMenu"
{ {
IfGame(Doom, Strife, Chex) StaticTextCentered 160, -10, "$MNU_SAVEGAME"
{
StaticPatchCentered 160, -20, "M_SAVEG"
}
IfGame(Heretic, Hexen)
{
StaticTextCentered 160, -10, "$MNU_SAVEGAME"
}
Position 80,54 Position 80,54
Class "SaveMenu" // uses its own implementation Class "SaveMenu" // uses its own implementation
} }

View File

@ -67,12 +67,19 @@ class ListMenuItemStaticPatch : ListMenuItem
{ {
TextureID mTexture; TextureID mTexture;
bool mCentered; 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); Super.Init(x, y);
mTexture = patch; mTexture = patch;
mCentered = centered; mCentered = centered;
mSubstitute = substitute;
mFont = desc.mFont;
mColor = desc.mFontColor;
} }
override void Drawer(bool selected) override void Drawer(bool selected)
@ -86,14 +93,30 @@ class ListMenuItemStaticPatch : ListMenuItem
Vector2 vec = TexMan.GetScaledSize(mTexture); Vector2 vec = TexMan.GetScaledSize(mTexture);
if (mYpos >= 0) if (mYpos >= 0)
{ {
if (mCentered) x -= vec.X / 2; if (mSubstitute == "" || TexMan.OkForLocalization(mTexture))
screen.DrawTexture (mTexture, true, x, mYpos, DTA_Clean, true); {
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 else
{ {
x = (mXpos - 160) * CleanXfac + (Screen.GetWidth()>>1); x = (mXpos - 160) * CleanXfac + (Screen.GetWidth()>>1);
if (mCentered) x -= (vec.X * CleanXfac)/2; if (mSubstitute == "" || TexMan.OkForLocalization(mTexture))
screen.DrawTexture (mTexture, true, x, -mYpos*CleanYfac, DTA_CleanNoMove, true); {
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);
}
} }
} }
} }