- 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)
{
StaticPatchCentered 160, -20, "M_LOADG"
}
IfGame(Heretic, Hexen)
{
StaticTextCentered 160, -10, "$MNU_LOADGAME" StaticTextCentered 160, -10, "$MNU_LOADGAME"
}
Position 80,54 Position 80,54
Class "LoadMenu" // uses its own implementation Class "LoadMenu" // uses its own implementation
} }
@ -272,15 +265,8 @@ ListMenu "LoadGameMenu"
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
ListMenu "SaveGameMenu" 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 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)
@ -85,16 +92,32 @@ class ListMenuItemStaticPatch : ListMenuItem
double x = mXpos; double x = mXpos;
Vector2 vec = TexMan.GetScaledSize(mTexture); Vector2 vec = TexMan.GetScaledSize(mTexture);
if (mYpos >= 0) if (mYpos >= 0)
{
if (mSubstitute == "" || TexMan.OkForLocalization(mTexture))
{ {
if (mCentered) x -= vec.X / 2; if (mCentered) x -= vec.X / 2;
screen.DrawTexture (mTexture, true, x, mYpos, DTA_Clean, true); screen.DrawTexture (mTexture, true, x, mYpos, DTA_Clean, true);
} }
else 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); x = (mXpos - 160) * CleanXfac + (Screen.GetWidth()>>1);
if (mSubstitute == "" || TexMan.OkForLocalization(mTexture))
{
if (mCentered) x -= (vec.X * CleanXfac)/2; if (mCentered) x -= (vec.X * CleanXfac)/2;
screen.DrawTexture (mTexture, true, x, -mYpos*CleanYfac, DTA_CleanNoMove, true); 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);
}
}
} }
} }