- episode menu setup.

This commit is contained in:
Christoph Oelckers 2019-11-25 18:41:39 +01:00
parent 556c61b60b
commit d73f915c66
5 changed files with 59 additions and 79 deletions

View file

@ -324,6 +324,7 @@ class FListMenuItem
{ {
protected: protected:
int mXpos, mYpos; int mXpos, mYpos;
int mHeight;
FName mAction; FName mAction;
public: public:
@ -361,6 +362,7 @@ public:
int GetX() { return mXpos; } int GetX() { return mXpos; }
void SetX(int x) { mXpos = x; } void SetX(int x) { mXpos = x; }
void SetY(int x) { mYpos = x; } void SetY(int x) { mYpos = x; }
void SetHeight(int x) { mHeight = x; }
}; };
class FListMenuItemStaticPatch : public FListMenuItem class FListMenuItemStaticPatch : public FListMenuItem
@ -398,7 +400,6 @@ class FListMenuItemSelectable : public FListMenuItem
{ {
protected: protected:
int mHotkey; int mHotkey;
int mHeight;
int mParam; int mParam;
public: public:

View file

@ -991,90 +991,70 @@ void M_ParseMenuDefs()
static void BuildEpisodeMenu() static void BuildEpisodeMenu()
{ {
#if 0
// Build episode menu // Build episode menu
bool success = false; int addedVolumes = 0;
FMenuDescriptor **desc = MenuDescriptors.CheckKey(NAME_Episodemenu); FMenuDescriptor **desc = MenuDescriptors.CheckKey(NAME_EpisodeMenu);
if (desc != NULL) if (desc != NULL)
{ {
if ((*desc)->mType == MDESC_ListMenu) if ((*desc)->mType == MDESC_ListMenu)
{ {
FListMenuDescriptor *ld = static_cast<FListMenuDescriptor*>(*desc); FListMenuDescriptor *ld = static_cast<FListMenuDescriptor*>(*desc);
int posy = ld->mYpos; ld->mSelectedItem = 1;
int topy = posy;
// Get lowest y coordinate of any static item in the menu for (int i = 0; i < MAXVOLUMES; i++)
for(unsigned i = 0; i < ld->mItems.Size(); i++)
{ {
int y = ld->mItems[i]->GetY(); if (gVolumeNames[i].IsNotEmpty())
if (y < topy) topy = y;
}
// center the menu on the screen if the top space is larger than the bottom space
int totalheight = posy + AllEpisodes.Size() * ld->mLinespacing - topy;
if (totalheight < 190 || AllEpisodes.Size() == 1)
{
int newtop = (200 - totalheight + topy) / 2;
int topdelta = newtop - topy;
if (topdelta < 0)
{ {
for(unsigned i = 0; i < ld->mItems.Size(); i++) auto it = new FListMenuItemNativeText(ld->mXpos, 0, 0, gVolumeNames[i][0], gVolumeNames[i], NIT_BigFont, NIT_ActiveState, 1, NAME_SkillMenu, i + 1);
{
ld->mItems[i]->OffsetPositionY(topdelta);
}
posy -= topdelta;
}
ld->mSelectedItem = ld->mItems.Size();
for(unsigned i = 0; i < AllEpisodes.Size(); i++)
{
FListMenuItem *it;
if (AllEpisodes[i].mPicName.IsNotEmpty())
{
FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName);
it = new FListMenuItemPatch(ld->mXpos, posy, ld->mLinespacing, AllEpisodes[i].mShortcut,
tex, NAME_Skillmenu, i);
}
else
{
it = new FListMenuItemText(ld->mXpos, posy, ld->mLinespacing, AllEpisodes[i].mShortcut,
AllEpisodes[i].mEpisodeName, ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_Skillmenu, i);
}
ld->mItems.Push(it); ld->mItems.Push(it);
posy += ld->mLinespacing; addedVolumes++;
if (gVolumeSubtitles[i].IsNotEmpty())
{
//auto it = new FListMenuItemNativeStaticText(ld->mXpos, gVolumeSubtitles[i], NIT_SmallFont);
//ld->mItems.Push(it);
}
} }
if (AllEpisodes.Size() == 1) if (1 /*CheckUserMaps()*/)
{ {
ld->mAutoselect = ld->mSelectedItem; //auto it = new FListMenuItemNativeStaticText(ld->mXpos, "", NIT_SmallFont); // empty entry as spacer.
//ld->mItems.Push(it);
auto it = new FListMenuItemNativeText(ld->mXpos, 0, 0, 0, "$MNU_USERMAP", NIT_BigFont, NIT_ActiveState, 1, NAME_SkillMenu, i + 1);
ld->mItems.Push(it);
addedVolumes++;
if (g_gameType & GAMEFLAG_SW) // fixme: make this game independent.
{
//auto it = new FListMenuItemNativeStaticText(ld->mXpos, "$MNU_SELECTUSERMAP", NIT_SmallFont);
//ld->mItems.Push(it);
}
}
if (addedVolumes == 1)
{
ld->mAutoselect = 0;
} }
success = true;
} }
} }
} }
if (!success) #if 0
if (gVolumeNames[i].IsNotEmpty())
{ {
// Couldn't create the episode menu, either because there's too many episodes or some error occured if (!(gVolumeFlags[i] & EF_HIDEFROMSP))
// Create an option menu for episode selection instead.
FOptionMenuDescriptor *od = new FOptionMenuDescriptor;
if (desc != NULL) delete *desc;
MenuDescriptors[NAME_Episodemenu] = od;
od->mType = MDESC_OptionsMenu;
od->mMenuName = NAME_Episodemenu;
od->mTitle = "$MNU_EPISODE";
od->mSelectedItem = 0;
od->mScrollPos = 0;
od->mClass = NULL;
od->mPosition = -15;
od->mScrollTop = 0;
od->mIndent = 160;
od->mDontDim = false;
for(unsigned i = 0; i < AllEpisodes.Size(); i++)
{ {
FOptionMenuItemSubmenu *it = new FOptionMenuItemSubmenu(AllEpisodes[i].mEpisodeName, "Skillmenu", i); MEL_EPISODE[i] = &ME_EPISODE[i];
od->mItems.Push(it); ME_EPISODE[i] = ME_EPISODE_TEMPLATE;
ME_EPISODE[i].name = gVolumeNames[i];
}
// if (!(EpisodeFlags[i] & EF_HIDEFROMMP))
{
MEOSN_NetEpisodes[k] = gVolumeNames[i];
MEOSV_NetEpisodes[k] = i;
k++;
} }
} }
M_EPISODE.numEntries = g_volumeCnt + 2;
#endif #endif
} }

View file

@ -24,3 +24,13 @@ xx(SaveMenu)
xx(LoadMenu) xx(LoadMenu)
xx(SoundMenu) xx(SoundMenu)
xx(ConfirmPlayerReset) xx(ConfirmPlayerReset)
xx(EpisodeMenu)
xx(SkillMenu)
xx(CustomGameMenu)
xx(CustomSubMenu1)
xx(CustomSubMenu2)
xx(CustomSubMenu3)
xx(CustomSubMenu4)
xx(CustomSubMenu5)
xx(CustomSubMenu6)
xx(CustomSubMenu7)

View file

@ -547,6 +547,7 @@ protected:
numvalidentries--; numvalidentries--;
continue; continue;
} }
entry->SetHeight(height);
totalheight += height; totalheight += height;
} }
if (mDesc->mSpacing <= 0) calculatedentryspacing = std::max(0, (y_lower - y_upper - totalheight) / (numvalidentries > 1 ? numvalidentries - 1 : 1)); if (mDesc->mSpacing <= 0) calculatedentryspacing = std::max(0, (y_lower - y_upper - totalheight) / (numvalidentries > 1 ? numvalidentries - 1 : 1));

View file

@ -19,7 +19,6 @@ LISTMENU "MainMenu"
position 160, 55, 115 position 160, 55, 115
centermenu centermenu
} }
linespacing 15
class "Duke.MainMenu" class "Duke.MainMenu"
NativeTextItem "$MNU_NEWGAME", "n", "PlayerclassMenu" NativeTextItem "$MNU_NEWGAME", "n", "PlayerclassMenu"
//NativeTextItem "$MNU_NEWGAME", "m", "MultiMenu" // In EDuke this replaces "New Game" when in networking mode. Kept here as a reminder (I'm not going to support EDuke's C/S implementation) //NativeTextItem "$MNU_NEWGAME", "m", "MultiMenu" // In EDuke this replaces "New Game" when in networking mode. Kept here as a reminder (I'm not going to support EDuke's C/S implementation)
@ -134,25 +133,14 @@ LISTMENU "EpisodeMenu"
{ {
ScriptId 100 ScriptId 100
// Episode names filled in programmatically // Episode names filled in programmatically
NativeTextItem "", "", "SkillMenu", 1
NativeStaticTextItem ""
NativeTextItem "", "", "SkillMenu", 2
NativeStaticTextItem ""
NativeTextItem "", "", "SkillMenu", 3
NativeStaticTextItem ""
NativeTextItem "", "", "SkillMenu", 4
NativeStaticTextItem ""
NativeTextItem "", "", "SkillMenu", 5
NativeStaticTextItem ""
NativeTextItem "", "", "SkillMenu", 6
NativeStaticTextItem ""
NativeTextItem "", "", "SkillMenu", 7
//Spacer //Spacer
/*
NativeTextItem "$MNU_USERMAP", "u", "UserMap" NativeTextItem "$MNU_USERMAP", "u", "UserMap"
ifgame(ShadowWarrior) ifgame(ShadowWarrior)
{ {
NativeStaticTextItem "$MNU_SELECTUSERMAP" NativeStaticTextItem "$MNU_SELECTUSERMAP"
} }
*/
} }
LISTMENU "SkillMenu" LISTMENU "SkillMenu"