- 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)
{
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
}

View file

@ -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);
}
}
}
}