- Ion Fury main menu fixes.

This commit is contained in:
Christoph Oelckers 2019-11-24 20:40:53 +01:00
parent b3b5ac440a
commit 57b542671c
5 changed files with 33 additions and 24 deletions

View file

@ -65,6 +65,7 @@ void DListMenu::Init(DMenu *parent, FListMenuDescriptor *desc)
mParentMenu = parent; mParentMenu = parent;
mDesc = desc; mDesc = desc;
if (mDesc->mScriptId) scriptID = mDesc->mScriptId; if (mDesc->mScriptId) scriptID = mDesc->mScriptId;
#if 0
if (desc->mCenter) if (desc->mCenter)
{ {
int center = 160; int center = 160;
@ -90,6 +91,7 @@ void DListMenu::Init(DMenu *parent, FListMenuDescriptor *desc)
} }
} }
} }
#endif
} }
//============================================================================= //=============================================================================
@ -261,7 +263,7 @@ void DListMenu::Drawer ()
PreDraw(); PreDraw();
for(unsigned i=0;i<mDesc->mItems.Size(); i++) for(unsigned i=0;i<mDesc->mItems.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()) if (mDesc->mSelectedItem >= 0 && mDesc->mSelectedItem < (int)mDesc->mItems.Size())
mDesc->mItems[mDesc->mSelectedItem]->DrawSelector(mDesc->mSelectOfsX, mDesc->mSelectOfsY, mDesc->mSelector); 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; mCentered = centered;
} }
void FListMenuItemStaticPatch::Drawer(const vec2_t& origin, bool selected) void FListMenuItemStaticPatch::Drawer(DListMenu* menu, const vec2_t& origin, bool selected)
{ {
if (!mTexture) if (!mTexture)
{ {
@ -424,7 +426,7 @@ FListMenuItemStaticText::FListMenuItemStaticText(int x, int y, const char *text,
mCentered = centered; 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; const char *text = mText;
if (text != NULL) 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; const char *text = mText;
if (mText.Len()) 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; const char* text = mText;
if (mText.Len()) if (mText.Len() && !mHidden)
{ {
if (*text == '$') text = GStrings(text + 1); 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; 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); DrawTexture (&twod, mTexture, mXpos, mYpos, DTA_Clean, true, TAG_DONE);
} }

View file

@ -297,6 +297,8 @@ public:
// //
//============================================================================= //=============================================================================
class DListMenu;
class FListMenuItem class FListMenuItem
{ {
protected: protected:
@ -319,7 +321,7 @@ public:
virtual bool CheckCoordinate(int x, int y); virtual bool CheckCoordinate(int x, int y);
virtual void Ticker(); 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 Selectable();
virtual bool Activate(); virtual bool Activate();
virtual FName GetAction(int *pparam); virtual FName GetAction(int *pparam);
@ -348,7 +350,7 @@ protected:
public: public:
FListMenuItemStaticPatch(int x, int y, FTexture *patch, bool centered); 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 class FListMenuItemStaticText : public FListMenuItem
@ -362,7 +364,7 @@ protected:
public: public:
FListMenuItemStaticText(int x, int y, const char *text, FFont *font, EColorRange color, bool centered); FListMenuItemStaticText(int x, int y, const char *text, FFont *font, EColorRange color, bool centered);
~FListMenuItemStaticText(); ~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: 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(int x, int y, int height, int hotkey, const FString &text, FFont *font, EColorRange color, EColorRange color2, FName child, int param = 0);
~FListMenuItemText(); ~FListMenuItemText();
void Drawer(const vec2_t& origin, bool selected) override; void Drawer(DListMenu* menu, const vec2_t& origin, bool selected) override;
int GetWidth() override; int GetWidth() override;
}; };
@ -411,7 +413,7 @@ class FListMenuItemNativeText : public FListMenuItemSelectable
public: 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(int x, int y, int height, int hotkey, const FString& text, int fontnum, int palnum, float fontscale, FName child, int param = 0);
~FListMenuItemNativeText(); ~FListMenuItemNativeText();
void Drawer(const vec2_t& origin, bool selected) override; void Drawer(DListMenu* menu, const vec2_t& origin, bool selected) override;
int GetWidth() override; int GetWidth() override;
void DrawSelector(int xofs, int yofs, FTexture* tex) override { } // The text drawer handles this itself. 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; FTexture* mTexture;
public: public:
FListMenuItemPatch(int x, int y, int height, int hotkey, FTexture* patch, FName child, int param = 0); 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; int GetWidth() override;
}; };
@ -460,6 +462,10 @@ public:
{ {
mFocusControl = NULL; mFocusControl = NULL;
} }
const FListMenuDescriptor* Descriptor() const
{
return mDesc;
}
}; };

View file

@ -156,7 +156,7 @@ static bool CheckSkipGameBlock(FScanner &sc)
} }
while (sc.CheckString(",")); while (sc.CheckString(","));
sc.MustGetStringName(")"); sc.MustGetStringName(")");
if (!(filter & 1)) // todo: apply correct filter. if (!(filter & g_gameType))
{ {
SkipSubBlock(sc); SkipSubBlock(sc);
return !sc.CheckString("else"); return !sc.CheckString("else");
@ -279,7 +279,7 @@ static void ParseListMenuBody(FScanner &sc, FListMenuDescriptor *desc)
} }
else if (sc.Compare("Centermenu")) else if (sc.Compare("Centermenu"))
{ {
desc->mCenter = true; desc->mCenter = 0;
} }
else if (sc.Compare("MouseWindow")) else if (sc.Compare("MouseWindow"))
{ {
@ -518,7 +518,7 @@ static void ParseListMenu(FScanner &sc)
desc->mRedirect = NULL; desc->mRedirect = NULL;
desc->mWLeft = 0; desc->mWLeft = 0;
desc->mWRight = 0; desc->mWRight = 0;
desc->mCenter = false; desc->mCenter = 0;
ParseListMenuBody(sc, desc); ParseListMenuBody(sc, desc);
bool scratch = ReplaceMenu(sc, desc); bool scratch = ReplaceMenu(sc, desc);

View file

@ -473,7 +473,7 @@ void GameInterface::DrawNativeMenuText(int fontnum, int state, int xpos, int ypo
int ydim_upper = 0; int ydim_upper = 0;
int ydim_lower = ydim - 1; int ydim_lower = ydim - 1;
int32_t const indent = 0; // not set for any relevant menu int32_t const indent = 0; // not set for any relevant menu
int32_t x = xpos << 16; int32_t x = xpos;
uint8_t status = 0; uint8_t status = 0;
if (state == NIT_SelectedState) 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(); int32_t const height = font.get_yline();
status |= MT_YCenter; 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; vec2_t textsize;
if (dodraw) if (dodraw)
@ -569,7 +569,7 @@ protected:
// totalHeight calculating pass // totalHeight calculating pass
int totalHeight; int totalHeight;
for (int e = 0; e < numvalidentries; ++e) for (unsigned e = 0; e < mDesc->mItems.Size(); ++e)
{ {
auto entry = mDesc->mItems[e]; auto entry = mDesc->mItems[e];
if (!entry->mHidden) if (!entry->mHidden)
@ -610,9 +610,9 @@ class MainMenu : public DukeListMenu
DukeListMenu::PreDraw(); DukeListMenu::PreDraw();
if ((G_GetLogoFlags() & LOGO_NOGAMETITLE) == 0) 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 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()) else if (mDesc->mCaption.IsNotEmpty())
{ {

View file

@ -21,7 +21,7 @@ LISTMENU "MainMenu"
linespacing 15 linespacing 15
class "Duke.MainMenu" class "Duke.MainMenu"
NativeTextItem "$MNU_NEWGAME", "n", "PlayerclassMenu" 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) ifgame(fury)
{ {
NativeTextItem "$MNU_CONTINUE", "l", "LoadGameMenu" NativeTextItem "$MNU_CONTINUE", "l", "LoadGameMenu"