diff --git a/source/common/menu/listmenu.cpp b/source/common/menu/listmenu.cpp index 8d1e3f164..39e68cc67 100644 --- a/source/common/menu/listmenu.cpp +++ b/source/common/menu/listmenu.cpp @@ -290,7 +290,7 @@ void FListMenuItem::Ticker() { } -void FListMenuItem::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) +void FListMenuItem::Drawer(DListMenu* menu, const DVector2& origin, bool selected) { } @@ -389,7 +389,7 @@ FListMenuItemStaticPatch::FListMenuItemStaticPatch(int x, int y, FTexture *patch mCentered = centered; } -void FListMenuItemStaticPatch::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) +void FListMenuItemStaticPatch::Drawer(DListMenu* menu, const DVector2& origin, bool selected) { if (!mTexture) { @@ -426,7 +426,7 @@ FListMenuItemStaticText::FListMenuItemStaticText(int x, int y, const char *text, mCentered = centered; } -void FListMenuItemStaticText::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) +void FListMenuItemStaticText::Drawer(DListMenu* menu, const DVector2& origin, bool selected) { const char *text = mText; if (text != NULL) @@ -529,7 +529,7 @@ FListMenuItemText::~FListMenuItemText() { } -void FListMenuItemText::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) +void FListMenuItemText::Drawer(DListMenu* menu, const DVector2& origin, bool selected) { const char *text = mText; if (mText.Len()) @@ -571,14 +571,14 @@ FListMenuItemNativeText::~FListMenuItemNativeText() { } -void FListMenuItemNativeText::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) +void FListMenuItemNativeText::Drawer(DListMenu* menu, const DVector2& origin, bool selected) { const char* text = mText; if (mText.Len() && !mHidden) { if (*text == '$') text = GStrings(text + 1); auto state = selected ? NIT_SelectedState : mEnabled ? NIT_ActiveState : NIT_InactiveState; - gi->DrawNativeMenuText(mFontnum, state, (mXpos << 16) + origin.x, (mYpos << 16) + origin.y, 1.f, text, menu->Descriptor()->mFlags); + gi->DrawNativeMenuText(mFontnum, state, int((origin.X + mXpos) / 65536) , int((origin.Y + mYpos) / 65536), 1.f, text, menu->Descriptor()->mFlags); } } @@ -601,7 +601,7 @@ FListMenuItemPatch::FListMenuItemPatch(int x, int y, int height, int hotkey, FTe mTexture = patch; } -void FListMenuItemPatch::Drawer(DListMenu* menu, const vec2_t& origin, bool selected) +void FListMenuItemPatch::Drawer(DListMenu* menu, const DVector2& 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 13f549c6d..b970a1f2a 100644 --- a/source/common/menu/menu.h +++ b/source/common/menu/menu.h @@ -318,10 +318,11 @@ public: static int MenuTime; DMenu *mParentMenu; - vec2_t origin; + DVector2 origin; int scriptID = INT_MAX; DMenu(DMenu *parent = NULL); + virtual ~DMenu() = default; virtual bool Responder (event_t *ev); virtual bool MenuEvent (int mkey, bool fromcontroller); virtual void Ticker (); @@ -374,7 +375,7 @@ public: virtual bool CheckCoordinate(int x, int y); virtual void Ticker(); - virtual void Drawer(DListMenu *menu, const vec2_t& origin, bool selected); + virtual void Drawer(DListMenu *menu, const DVector2& origin, bool selected); virtual bool Selectable(); virtual bool Activate(FName caller); virtual FName GetAction(int *pparam); @@ -405,7 +406,7 @@ protected: public: FListMenuItemStaticPatch(int x, int y, FTexture *patch, bool centered); - void Drawer(DListMenu* menu, const vec2_t& origin, bool selected); + void Drawer(DListMenu* menu, const DVector2& origin, bool selected); }; class FListMenuItemStaticText : public FListMenuItem @@ -419,7 +420,7 @@ protected: public: FListMenuItemStaticText(int x, int y, const char *text, FFont *font, EColorRange color, bool centered); ~FListMenuItemStaticText(); - void Drawer(DListMenu* menu, const vec2_t& origin, bool selected) override; + void Drawer(DListMenu* menu, const DVector2& origin, bool selected) override; }; //============================================================================= @@ -453,7 +454,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(DListMenu* menu, const vec2_t& origin, bool selected) override; + void Drawer(DListMenu* menu, const DVector2& origin, bool selected) override; int GetWidth() override; }; @@ -467,7 +468,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(DListMenu* menu, const vec2_t& origin, bool selected) override; + void Drawer(DListMenu* menu, const DVector2& origin, bool selected) override; int GetWidth() override; void DrawSelector(int xofs, int yofs, FTexture* tex) override { } // The text drawer handles this itself. }; @@ -478,7 +479,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(DListMenu* menu, const vec2_t& origin, bool selected) override; + void Drawer(DListMenu* menu, const DVector2& origin, bool selected) override; int GetWidth() override; }; diff --git a/source/duke3d/src/d_menu.cpp b/source/duke3d/src/d_menu.cpp index 9a3a89449..ab1837265 100644 --- a/source/duke3d/src/d_menu.cpp +++ b/source/duke3d/src/d_menu.cpp @@ -131,13 +131,13 @@ void Menu_Init(void) #endif } -static void Menu_DrawTopBar(const vec2_t origin) +static void Menu_DrawTopBar(const DVector2 &origin) { if ((G_GetLogoFlags() & LOGO_NOTITLEBAR) == 0) - rotatesprite_fs(origin.x + (MENU_MARGIN_CENTER<<16), origin.y + (19<<16), MF_Redfont.cursorScale, 0,MENUBAR,16,0,10); + rotatesprite_fs(int(origin.X*65536) + (MENU_MARGIN_CENTER<<16), int(origin.Y*65536) + (19<<16), MF_Redfont.cursorScale, 0,MENUBAR,16,0,10); } -static void Menu_DrawTopBarCaption(const char *caption, const vec2_t origin) +static void Menu_DrawTopBarCaption(const char *caption, const DVector2 &origin) { static char t[64]; if (*caption == '$') caption = GStrings(caption + 1); @@ -148,7 +148,7 @@ static void Menu_DrawTopBarCaption(const char *caption, const vec2_t origin) char *p = &t[dstlen-1]; if (*p == ':') *p = '\0'; - captionmenutext(origin.x + (MENU_MARGIN_CENTER<<16), origin.y + (24<<16) + ((15>>1)<<16), t); + captionmenutext(int(origin.X*65536) + (MENU_MARGIN_CENTER<<16), int(origin.Y*65536) + (24<<16) + ((15>>1)<<16), t); } static void Menu_GetFmt(const MenuFont_t* font, uint8_t const status, int32_t* s, int32_t* z) @@ -227,7 +227,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 const indent = 0; // not set for any relevant menu int32_t x = xpos; uint8_t status = 0; @@ -271,14 +271,14 @@ protected: virtual void CallScript(int event, bool getorigin = false) { - ud.returnvar[0] = origin.x; - ud.returnvar[1] = origin.y; + ud.returnvar[0] = int(origin.X * 65536); + ud.returnvar[1] = int(origin.Y * 65536); ud.returnvar[2] = mDesc->mSelectedItem; VM_OnEventWithReturn(event, g_player[screenpeek].ps->i, screenpeek, mDesc->mScriptId); if (getorigin) { - origin.x = ud.returnvar[0]; - origin.y = ud.returnvar[1]; + origin.X = ud.returnvar[0] / 65536.; + origin.Y = ud.returnvar[1] / 65536.; } } @@ -369,9 +369,9 @@ class MainMenu : public DukeListMenu DukeListMenu::PreDraw(); if ((G_GetLogoFlags() & LOGO_NOGAMETITLE) == 0) { - rotatesprite_fs((origin.x << 16) + (MENU_MARGIN_CENTER<<16), (origin.y << 16) + ((28)<<16), 65536L,0,INGAMEDUKETHREEDEE,0,0,10); + rotatesprite_fs(int(origin.X * 65536) + (MENU_MARGIN_CENTER<<16), int(origin.Y * 65536) + ((28)<<16), 65536L,0,INGAMEDUKETHREEDEE,0,0,10); if (PLUTOPAK) // JBF 20030804 - 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); + rotatesprite_fs(int(origin.X * 65536) + ((MENU_MARGIN_CENTER+100)<<16), int(origin.Y * 65536) + (36<<16), 65536L,0,PLUTOPAKSPRITE+2,(sintable[((int32_t) totalclock<<4)&2047]>>11),0,2+8); } } };