- use original menu spacing for skill and episode menus if all elements are patches.

This commit is contained in:
Christoph Oelckers 2021-08-10 21:08:26 +02:00
parent f29eff5b4c
commit 99c66071fb
4 changed files with 69 additions and 10 deletions

View file

@ -571,8 +571,21 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs)
if (y < topy) topy = y;
}
int spacing = ld->mLinespacing;
for (unsigned i = 0; i < AllEpisodes.Size(); i++)
{
if (AllEpisodes[i].mPicName.IsNotEmpty())
{
FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName);
if (AllEpisodes[i].mEpisodeName.IsEmpty() || OkForLocalization(tex, AllEpisodes[i].mEpisodeName))
continue;
}
if ((gameinfo.gametype & GAME_DoomStrifeChex) && spacing == 16) spacing = 18;
break;
}
// center the menu on the screen if the top space is larger than the bottom space
int totalheight = posy + AllEpisodes.Size() * ld->mLinespacing - topy;
int totalheight = posy + AllEpisodes.Size() * spacing - topy;
if (totalheight < 190 || AllEpisodes.Size() == 1)
{
@ -613,15 +626,15 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs)
{
FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName);
if (AllEpisodes[i].mEpisodeName.IsEmpty() || OkForLocalization(tex, AllEpisodes[i].mEpisodeName))
it = CreateListMenuItemPatch(posx, posy, ld->mLinespacing, AllEpisodes[i].mShortcut, tex, NAME_Skillmenu, i);
it = CreateListMenuItemPatch(posx, posy, spacing, AllEpisodes[i].mShortcut, tex, NAME_Skillmenu, i);
}
if (it == nullptr)
{
it = CreateListMenuItemText(posx, posy, ld->mLinespacing, AllEpisodes[i].mShortcut,
it = CreateListMenuItemText(posx, posy, spacing, AllEpisodes[i].mShortcut,
AllEpisodes[i].mEpisodeName, ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_Skillmenu, i);
}
ld->mItems.Push(it);
posy += ld->mLinespacing;
posy += spacing;
}
if (AllEpisodes.Size() == 1)
{
@ -1073,9 +1086,10 @@ void M_StartupSkillMenu(FNewGameStartup *gs)
}
}
if (done != restart)
int spacing = ld->mLinespacing;
//if (done != restart)
{
done = restart;
//done = restart;
ld->mSelectedItem = ld->mItems.Size() + defindex;
int posy = y;
@ -1088,8 +1102,20 @@ void M_StartupSkillMenu(FNewGameStartup *gs)
if (y < topy) topy = y;
}
for (unsigned i = 0; i < MenuSkills.Size(); i++)
{
if (MenuSkills[i]->PicName.IsNotEmpty())
{
FTextureID tex = GetMenuTexture(MenuSkills[i]->PicName);
if (MenuSkills[i]->MenuName.IsEmpty() || OkForLocalization(tex, MenuSkills[i]->MenuName))
continue;
}
if ((gameinfo.gametype & GAME_DoomStrifeChex) && spacing == 16) spacing = 18;
break;
}
// center the menu on the screen if the top space is larger than the bottom space
int totalheight = posy + MenuSkills.Size() * ld->mLinespacing - topy;
int totalheight = posy + MenuSkills.Size() * spacing - topy;
if (totalheight < 190 || MenuSkills.Size() == 1)
{
@ -1157,16 +1183,16 @@ void M_StartupSkillMenu(FNewGameStartup *gs)
{
FTextureID tex = GetMenuTexture(skill.PicName);
if (skill.MenuName.IsEmpty() || OkForLocalization(tex, skill.MenuName))
li = CreateListMenuItemPatch(posx, y, ld->mLinespacing, skill.Shortcut, tex, action, SkillIndices[i]);
li = CreateListMenuItemPatch(posx, y, spacing, skill.Shortcut, tex, action, SkillIndices[i]);
}
if (li == nullptr)
{
li = CreateListMenuItemText(posx, y, ld->mLinespacing, skill.Shortcut,
li = CreateListMenuItemText(posx, y, spacing, skill.Shortcut,
pItemText? *pItemText : skill.MenuName, ld->mFont, color,ld->mFontColor2, action, SkillIndices[i]);
}
ld->mItems.Push(li);
GC::WriteBarrier(*desc, li);
y += ld->mLinespacing;
y += spacing;
}
if (AllEpisodes[gs->Episode].mNoSkill || MenuSkills.Size() == 1)
{

View file

@ -209,6 +209,7 @@ ListMenu "EpisodeMenu"
{
Position 48, 63
StaticPatch 54, 38, "M_EPISOD", 0 , "$MNU_EPISODE"
linespacing 16
}
IfGame(Strife)
{
@ -234,6 +235,7 @@ ListMenu "SkillMenu"
IfGame(Doom, Chex)
{
StaticPatch 96, 14, "M_NEWG", 0, "$MNU_NEWGAME"
linespacing 16
}
IfGame(Strife)
{

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