- dynamically adjust SW's menu spacing based on language.

This commit is contained in:
Christoph Oelckers 2021-06-26 11:58:40 +02:00
parent 0f7d3d0cbb
commit 3512fe8fba
4 changed files with 52 additions and 1 deletions

View file

@ -44,7 +44,8 @@ LISTMENU "MainMenu"
ifgame(ShadowWarrior)
{
Position 55, 32
Linespacing 21
Linespacing 17
class SWMainMenu
SWLogo
SWTextItem "$MNU_NEWGAME", "n", "EpisodeMenu"
SWTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
@ -116,6 +117,7 @@ LISTMENU "IngameMenu"
{
Position 55, 32
Linespacing 17
class SWMainMenu
SWLogo
SWTextItem "$MNU_NEWGAME", "n", "EpisodeMenu"
SWTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
@ -195,6 +197,7 @@ LISTMENU "SkillMenu"
}
ifgame(ShadowWarrior)
{
class SWMainMenu
CaptionItem "$MNU_DIFFICULTY"
Position 35, 32
Linespacing 17

View file

@ -328,6 +328,36 @@ class ListMenu : Menu
{
mFocusControl = NULL;
}
//=============================================================================
//
//
//
//=============================================================================
void ChangeLineSpacing(int newspace)
{
double top = -32767;
for (int i = 0; i < mDesc.mItems.Size(); i++)
{
let selitem = ListMenuItemSelectable(mDesc.mItems[i]);
if (selitem)
{
let y = mDesc.mItems[i].GetY();
if (top == -32767)
{
top = y;
}
else
{
let newy = top + (y - top) / mDesc.mLineSpacing * newspace;
mDesc.mItems[i].SetY(newy);
}
}
}
mDesc.mLineSpacing = newspace;
}
}

View file

@ -40,6 +40,7 @@ class MenuItemBase : Object native ui version("2.4")
double GetY() { return mYpos; }
double GetX() { return mXpos; }
void SetX(double x) { mXpos = x; }
void SetY(double x) { mYpos = x; }
virtual void OnMenuCreated() {}
}

View file

@ -55,6 +55,23 @@ class SWMenuDelegate : RazeMenuDelegate
}
}
//=============================================================================
//
//
//
//=============================================================================
class SWMainMenu : ListMenu
{
override void Drawer()
{
let p = StringTable.Localize("REQUIRED_CHARACTERS", false);
int newls = (p == "REQUIRED_CHARACTERS")? 17 : 21;
if (newls != mDesc.mLineSpacing) ChangeLineSpacing(newls);
super.Drawer();
}
}
//=============================================================================
//
// logo