diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index 51a1bf56c..244e1ba1b 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -324,6 +324,7 @@ class FListMenuItem { protected: int mXpos, mYpos; + int mHeight; FName mAction; public: @@ -361,6 +362,7 @@ public: int GetX() { return mXpos; } void SetX(int x) { mXpos = x; } void SetY(int x) { mYpos = x; } + void SetHeight(int x) { mHeight = x; } }; class FListMenuItemStaticPatch : public FListMenuItem @@ -398,7 +400,6 @@ class FListMenuItemSelectable : public FListMenuItem { protected: int mHotkey; - int mHeight; int mParam; public: diff --git a/source/common/menu/menudef.cpp b/source/common/menu/menudef.cpp index 6f479e368..92316cc5d 100644 --- a/source/common/menu/menudef.cpp +++ b/source/common/menu/menudef.cpp @@ -991,90 +991,70 @@ void M_ParseMenuDefs() static void BuildEpisodeMenu() { -#if 0 // Build episode menu - bool success = false; - FMenuDescriptor **desc = MenuDescriptors.CheckKey(NAME_Episodemenu); + int addedVolumes = 0; + FMenuDescriptor **desc = MenuDescriptors.CheckKey(NAME_EpisodeMenu); if (desc != NULL) { if ((*desc)->mType == MDESC_ListMenu) { FListMenuDescriptor *ld = static_cast(*desc); - int posy = ld->mYpos; - int topy = posy; + ld->mSelectedItem = 1; - // Get lowest y coordinate of any static item in the menu - for(unsigned i = 0; i < ld->mItems.Size(); i++) + for (int i = 0; i < MAXVOLUMES; i++) { - int y = ld->mItems[i]->GetY(); - 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) + if (gVolumeNames[i].IsNotEmpty()) { - for(unsigned i = 0; i < ld->mItems.Size(); i++) - { - 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); - } + auto it = new FListMenuItemNativeText(ld->mXpos, 0, 0, gVolumeNames[i][0], gVolumeNames[i], NIT_BigFont, NIT_ActiveState, 1, NAME_SkillMenu, i + 1); 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 - // 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++) + if (!(gVolumeFlags[i] & EF_HIDEFROMSP)) { - FOptionMenuItemSubmenu *it = new FOptionMenuItemSubmenu(AllEpisodes[i].mEpisodeName, "Skillmenu", i); - od->mItems.Push(it); + MEL_EPISODE[i] = &ME_EPISODE[i]; + 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 } diff --git a/source/common/utility/namedef.h b/source/common/utility/namedef.h index b5425f821..47e37b7c4 100644 --- a/source/common/utility/namedef.h +++ b/source/common/utility/namedef.h @@ -24,3 +24,13 @@ xx(SaveMenu) xx(LoadMenu) xx(SoundMenu) xx(ConfirmPlayerReset) +xx(EpisodeMenu) +xx(SkillMenu) +xx(CustomGameMenu) +xx(CustomSubMenu1) +xx(CustomSubMenu2) +xx(CustomSubMenu3) +xx(CustomSubMenu4) +xx(CustomSubMenu5) +xx(CustomSubMenu6) +xx(CustomSubMenu7) diff --git a/source/duke3d/src/d_menu.cpp b/source/duke3d/src/d_menu.cpp index d4c6c71eb..c62f09588 100644 --- a/source/duke3d/src/d_menu.cpp +++ b/source/duke3d/src/d_menu.cpp @@ -547,6 +547,7 @@ protected: numvalidentries--; continue; } + entry->SetHeight(height); totalheight += height; } if (mDesc->mSpacing <= 0) calculatedentryspacing = std::max(0, (y_lower - y_upper - totalheight) / (numvalidentries > 1 ? numvalidentries - 1 : 1)); diff --git a/wadsrc/static/demolition/menudef.txt b/wadsrc/static/demolition/menudef.txt index 2be188358..bccda7541 100644 --- a/wadsrc/static/demolition/menudef.txt +++ b/wadsrc/static/demolition/menudef.txt @@ -19,7 +19,6 @@ LISTMENU "MainMenu" position 160, 55, 115 centermenu } - linespacing 15 class "Duke.MainMenu" 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) @@ -134,25 +133,14 @@ LISTMENU "EpisodeMenu" { ScriptId 100 // 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 + /* NativeTextItem "$MNU_USERMAP", "u", "UserMap" ifgame(ShadowWarrior) { NativeStaticTextItem "$MNU_SELECTUSERMAP" } + */ } LISTMENU "SkillMenu"