diff --git a/source/common/menu/listmenu.cpp b/source/common/menu/listmenu.cpp index 4fd448276..311d0e15d 100644 --- a/source/common/menu/listmenu.cpp +++ b/source/common/menu/listmenu.cpp @@ -65,6 +65,7 @@ void DListMenu::Init(DMenu *parent, FListMenuDescriptor *desc) mParentMenu = parent; mDesc = desc; if (mDesc->mScriptId) scriptID = mDesc->mScriptId; +#if 0 if (desc->mCenter) { int center = 160; @@ -90,6 +91,7 @@ void DListMenu::Init(DMenu *parent, FListMenuDescriptor *desc) } } } +#endif } //============================================================================= @@ -261,7 +263,7 @@ void DListMenu::Drawer () PreDraw(); for(unsigned i=0;imItems.Size(); i++) { - if (mDesc->mItems[i]->mEnabled) mDesc->mItems[i]->Drawer(origin, mDesc->mSelectedItem == (int)i); + if (mDesc->mItems[i]->mEnabled) mDesc->mItems[i]->Drawer(this, origin, mDesc->mSelectedItem == (int)i); } if (mDesc->mSelectedItem >= 0 && mDesc->mSelectedItem < (int)mDesc->mItems.Size()) mDesc->mItems[mDesc->mSelectedItem]->DrawSelector(mDesc->mSelectOfsX, mDesc->mSelectOfsY, mDesc->mSelector); @@ -288,7 +290,7 @@ void FListMenuItem::Ticker() { } -void FListMenuItem::Drawer(const vec2_t& origin, bool selected) +void FListMenuItem::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) { } @@ -387,7 +389,7 @@ FListMenuItemStaticPatch::FListMenuItemStaticPatch(int x, int y, FTexture *patch mCentered = centered; } -void FListMenuItemStaticPatch::Drawer(const vec2_t& origin, bool selected) +void FListMenuItemStaticPatch::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) { if (!mTexture) { @@ -424,7 +426,7 @@ FListMenuItemStaticText::FListMenuItemStaticText(int x, int y, const char *text, mCentered = centered; } -void FListMenuItemStaticText::Drawer(const vec2_t& origin, bool selected) +void FListMenuItemStaticText::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) { const char *text = mText; if (text != NULL) @@ -528,7 +530,7 @@ FListMenuItemText::~FListMenuItemText() { } -void FListMenuItemText::Drawer(const vec2_t& origin, bool selected) +void FListMenuItemText::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) { const char *text = mText; if (mText.Len()) @@ -570,13 +572,14 @@ FListMenuItemNativeText::~FListMenuItemNativeText() { } -void FListMenuItemNativeText::Drawer(const vec2_t& origin, bool selected) +void FListMenuItemNativeText::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) { const char* text = mText; - if (mText.Len()) + if (mText.Len() && !mHidden) { if (*text == '$') text = GStrings(text + 1); - gi->DrawNativeMenuText(mFontnum, selected ? NIT_SelectedState : mEnabled? NIT_ActiveState : NIT_InactiveState, mXpos + origin.x, mYpos + origin.y, 1.f, text, TOR_Center); // needs to be able to handle other orientations, too. + int direction = menu->Descriptor()->mCenter == 0 ? TOR_Center : menu->Descriptor()->mCenter < 0 ? TOR_Right : TOR_Left; + gi->DrawNativeMenuText(mFontnum, selected ? NIT_SelectedState : mEnabled? NIT_ActiveState : NIT_InactiveState, (mXpos << 16) + origin.x, (mYpos << 16) + origin.y, 1.f, text, direction); } } @@ -599,7 +602,7 @@ FListMenuItemPatch::FListMenuItemPatch(int x, int y, int height, int hotkey, FTe mTexture = patch; } -void FListMenuItemPatch::Drawer(const vec2_t& origin, bool selected) +void FListMenuItemPatch::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) { DrawTexture (&twod, mTexture, mXpos, mYpos, DTA_Clean, true, TAG_DONE); } diff --git a/source/common/menu/menu.h b/source/common/menu/menu.h index 7d07c5db5..b3cf00b6b 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -297,6 +297,8 @@ public: // //============================================================================= +class DListMenu; + class FListMenuItem { protected: @@ -319,7 +321,7 @@ public: virtual bool CheckCoordinate(int x, int y); virtual void Ticker(); - virtual void Drawer(const vec2_t &origin, bool selected); + virtual void Drawer(DListMenu *menu, const vec2_t& origin, bool selected); virtual bool Selectable(); virtual bool Activate(); virtual FName GetAction(int *pparam); @@ -348,7 +350,7 @@ protected: public: FListMenuItemStaticPatch(int x, int y, FTexture *patch, bool centered); - void Drawer(const vec2_t& origin, bool selected); + void Drawer(DListMenu* menu, const vec2_t& origin, bool selected); }; class FListMenuItemStaticText : public FListMenuItem @@ -362,7 +364,7 @@ protected: public: FListMenuItemStaticText(int x, int y, const char *text, FFont *font, EColorRange color, bool centered); ~FListMenuItemStaticText(); - void Drawer(const vec2_t& origin, bool selected) override; + void Drawer(DListMenu* menu, const vec2_t& origin, bool selected) override; }; //============================================================================= @@ -397,7 +399,7 @@ class FListMenuItemText : public FListMenuItemSelectable public: FListMenuItemText(int x, int y, int height, int hotkey, const FString &text, FFont *font, EColorRange color, EColorRange color2, FName child, int param = 0); ~FListMenuItemText(); - void Drawer(const vec2_t& origin, bool selected) override; + void Drawer(DListMenu* menu, const vec2_t& origin, bool selected) override; int GetWidth() override; }; @@ -411,7 +413,7 @@ class FListMenuItemNativeText : public FListMenuItemSelectable public: FListMenuItemNativeText(int x, int y, int height, int hotkey, const FString& text, int fontnum, int palnum, float fontscale, FName child, int param = 0); ~FListMenuItemNativeText(); - void Drawer(const vec2_t& origin, bool selected) override; + void Drawer(DListMenu* menu, const vec2_t& origin, bool selected) override; int GetWidth() override; void DrawSelector(int xofs, int yofs, FTexture* tex) override { } // The text drawer handles this itself. }; @@ -422,7 +424,7 @@ class FListMenuItemPatch : public FListMenuItemSelectable FTexture* mTexture; public: FListMenuItemPatch(int x, int y, int height, int hotkey, FTexture* patch, FName child, int param = 0); - void Drawer(const vec2_t& origin, bool selected) override; + void Drawer(DListMenu* menu, const vec2_t& origin, bool selected) override; int GetWidth() override; }; @@ -460,6 +462,10 @@ public: { mFocusControl = NULL; } + const FListMenuDescriptor* Descriptor() const + { + return mDesc; + } }; diff --git a/source/common/menu/menudef.cpp b/source/common/menu/menudef.cpp index 3eeae1acc..97b0dba14 100644 --- a/source/common/menu/menudef.cpp +++ b/source/common/menu/menudef.cpp @@ -156,7 +156,7 @@ static bool CheckSkipGameBlock(FScanner &sc) } while (sc.CheckString(",")); sc.MustGetStringName(")"); - if (!(filter & 1)) // todo: apply correct filter. + if (!(filter & g_gameType)) { SkipSubBlock(sc); return !sc.CheckString("else"); @@ -279,7 +279,7 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc) } else if (sc.Compare("Centermenu")) { - desc->mCenter = true; + desc->mCenter = 0; } else if (sc.Compare("MouseWindow")) { @@ -518,7 +518,7 @@ static void ParseListMenu(FScanner &sc) desc->mRedirect = NULL; desc->mWLeft = 0; desc->mWRight = 0; - desc->mCenter = false; + desc->mCenter = 0; ParseListMenuBody(sc, desc); bool scratch = ReplaceMenu(sc, desc); diff --git a/source/duke3d/src/d_menu.cpp b/source/duke3d/src/d_menu.cpp index 65eaa844f..f5e0d332b 100644 --- a/source/duke3d/src/d_menu.cpp +++ b/source/duke3d/src/d_menu.cpp @@ -473,7 +473,7 @@ void GameInterface::DrawNativeMenuText(int fontnum, int state, int xpos, int ypo int ydim_upper = 0; int ydim_lower = ydim - 1; int32_t const indent = 0; // not set for any relevant menu - int32_t x = xpos << 16; + int32_t x = xpos; uint8_t status = 0; if (state == NIT_SelectedState) @@ -488,7 +488,7 @@ void GameInterface::DrawNativeMenuText(int fontnum, int state, int xpos, int ypo int32_t const height = font.get_yline(); status |= MT_YCenter; - int32_t const y_internal = (ypos + (height >> 17)) << 16;// -menu->scrollPos; + int32_t const y_internal = ypos + ((height >> 17) << 16);// -menu->scrollPos; vec2_t textsize; if (dodraw) @@ -569,7 +569,7 @@ protected: // totalHeight calculating pass int totalHeight; - for (int e = 0; e < numvalidentries; ++e) + for (unsigned e = 0; e < mDesc->mItems.Size(); ++e) { auto entry = mDesc->mItems[e]; if (!entry->mHidden) @@ -610,9 +610,9 @@ class MainMenu : public DukeListMenu DukeListMenu::PreDraw(); if ((G_GetLogoFlags() & LOGO_NOGAMETITLE) == 0) { - rotatesprite_fs(origin.x + (MENU_MARGIN_CENTER<<16), origin.y + ((28)<<16), 65536L,0,INGAMEDUKETHREEDEE,0,0,10); + rotatesprite_fs((origin.x << 16) + (MENU_MARGIN_CENTER<<16), (origin.y << 16) + ((28)<<16), 65536L,0,INGAMEDUKETHREEDEE,0,0,10); if (PLUTOPAK) // JBF 20030804 - rotatesprite_fs(origin.x + ((MENU_MARGIN_CENTER+100)<<16), origin.y + (36<<16), 65536L,0,PLUTOPAKSPRITE+2,(sintable[((int32_t) totalclock<<4)&2047]>>11),0,2+8); + rotatesprite_fs((origin.y << 16) + ((MENU_MARGIN_CENTER+100)<<16), (origin.y << 16) + (36<<16), 65536L,0,PLUTOPAKSPRITE+2,(sintable[((int32_t) totalclock<<4)&2047]>>11),0,2+8); } else if (mDesc->mCaption.IsNotEmpty()) { diff --git a/wadsrc/static/demolition/menudef.txt b/wadsrc/static/demolition/menudef.txt index 0b5f699ea..4d566fa67 100644 --- a/wadsrc/static/demolition/menudef.txt +++ b/wadsrc/static/demolition/menudef.txt @@ -21,7 +21,7 @@ LISTMENU "MainMenu" linespacing 15 class "Duke.MainMenu" NativeTextItem "$MNU_NEWGAME", "n", "PlayerclassMenu" - //NativeTextItem "$MNU_MULTIPLAYER", "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) ifgame(fury) { NativeTextItem "$MNU_CONTINUE", "l", "LoadGameMenu"