diff --git a/Source/DiabloUI/ui_item.h b/Source/DiabloUI/ui_item.h index c0194be8e..5322b36c8 100644 --- a/Source/DiabloUI/ui_item.h +++ b/Source/DiabloUI/ui_item.h @@ -43,6 +43,14 @@ enum class UiFlags { // clang-format on }; +enum class UiPanels { + Main, + Quest, + Character, + Spell, + Inventory, +}; + inline UiFlags operator|(UiFlags lhs, UiFlags rhs) { using T = std::underlying_type_t; diff --git a/Source/control.cpp b/Source/control.cpp index b5568fb27..732fbbecd 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -30,6 +30,7 @@ #include "trigs.h" #include "utils/language.h" #include "utils/sdl_geometry.h" +#include "options.h" namespace devilution { /** @@ -61,6 +62,9 @@ bool panelflag; int initialDropGoldValue; bool panbtndown; bool spselflag; +Rectangle MainPanel; +Rectangle LeftPanel; +Rectangle RightPanel; extern std::array quickSpellActionIndexes; @@ -455,7 +459,7 @@ int DrawDurIcon4Item(const Surface &out, ItemStruct *pItem, int x, int c) void PrintSBookStr(const Surface &out, Point position, const char *text) { - DrawString(out, text, { { RIGHT_PANEL_X + SPLICONLENGTH + position.x, RIGHT_PANEL_Y + position.y }, { 222, 0 } }, UiFlags::ColorSilver); + DrawString(out, text, { GetPanelPosition(UiPanels::Spell, { SPLICONLENGTH + position.x, position.y }), { 222, 0 } }, UiFlags::ColorSilver); } spell_type GetSBookTrans(spell_id ii, bool townok) @@ -793,6 +797,64 @@ void ClearPanel() pnumlines = 0; } +void CalculatePanelAreas(void) +{ + MainPanel = { { (gnScreenWidth - PANEL_WIDTH) / 2, gnScreenHeight - PANEL_HEIGHT }, { PANEL_WIDTH, PANEL_HEIGHT } }; + LeftPanel = { { 0, 0 }, { SPANEL_WIDTH, SPANEL_HEIGHT } }; + RightPanel = { { 0, 0 }, { SPANEL_WIDTH, SPANEL_HEIGHT } }; + + switch (sgOptions.Gameplay.nSPanelHAlign) { + case 0: // left + LeftPanel.position.x = 0; + break; + case 1: // center + LeftPanel.position.x = (gnScreenWidth / 2 - LeftPanel.size.width) / 2; + break; + case 2: // right + LeftPanel.position.x = gnScreenWidth / 2 - LeftPanel.size.width; + break; + default: + LeftPanel.position.x = 0; + break; + } + + switch (sgOptions.Gameplay.nSPanelVAlign) { + case 0: // top + LeftPanel.position.y = 0; + break; + case 1: // center + LeftPanel.position.y = (gnScreenHeight - LeftPanel.size.height - PANEL_HEIGHT) / 2; + break; + case 2: // bottom + LeftPanel.position.y = gnScreenHeight - LeftPanel.size.height - PANEL_HEIGHT; + break; + default: + LeftPanel.position.y = 0; + break; + } + + RightPanel.position.x = gnScreenWidth - RightPanel.size.width - LeftPanel.position.x; + RightPanel.position.y = LeftPanel.position.y; +} + +Point GetPanelPosition(UiPanels panel, Point offset) +{ + Displacement displacement { offset.x, offset.y }; + + switch (panel) { + case UiPanels::Main: + return MainPanel.position + displacement; + case UiPanels::Quest: + case UiPanels::Character: + return LeftPanel.position + displacement; + case UiPanels::Spell: + case UiPanels::Inventory: + return RightPanel.position + displacement; + default: + return MainPanel.position + displacement; + } +} + void DrawPanelBox(const Surface &out, SDL_Rect srcRect, Point targetPosition) { out.BlitFrom(pBtmBuff, srcRect, targetPosition); @@ -913,6 +975,8 @@ void InitControlPan() dropGoldValue = 0; initialDropGoldValue = 0; initialDropGoldIndex = 0; + + CalculatePanelAreas(); } void DrawCtrlPan(const Surface &out) @@ -1316,16 +1380,16 @@ void DrawChr(const Surface &out) auto &myPlayer = Players[MyPlayerId]; - CelDrawTo(out, { LEFT_PANEL_X, LEFT_PANEL_Y + 351 }, *pChrPanel, 1); - DrawString(out, myPlayer._pName, { { LEFT_PANEL_X + 20, LEFT_PANEL_Y + 32 }, { 131, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); + CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 0, 351 }), *pChrPanel, 1); + DrawString(out, myPlayer._pName, { GetPanelPosition(UiPanels::Character, { 20, 32 }), { 131, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); - DrawString(out, _(ClassStrTbl[static_cast(myPlayer._pClass)]), { { LEFT_PANEL_X + 168, LEFT_PANEL_Y + 32 }, { 131, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); + DrawString(out, _(ClassStrTbl[static_cast(myPlayer._pClass)]), { GetPanelPosition(UiPanels::Character, { 168, 32 }), { 131, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); sprintf(chrstr, "%i", myPlayer._pLevel); - DrawString(out, chrstr, { { LEFT_PANEL_X + 66, LEFT_PANEL_Y + 69 }, { 43, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 66, 69 }), { 43, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); sprintf(chrstr, "%i", myPlayer._pExperience); - DrawString(out, chrstr, { { LEFT_PANEL_X + 216, LEFT_PANEL_Y + 69 }, { 84, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 216, 69 }), { 84, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); if (myPlayer._pLevel == MAXCHARLEVEL - 1) { strcpy(chrstr, _("None")); @@ -1334,10 +1398,10 @@ void DrawChr(const Surface &out) sprintf(chrstr, "%i", myPlayer._pNextExper); style = UiFlags::ColorSilver; } - DrawString(out, chrstr, { { LEFT_PANEL_X + 216, LEFT_PANEL_Y + 97 }, { 84, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 216, 97 }), { 84, 0 } }, style | UiFlags::AlignCenter); sprintf(chrstr, "%i", myPlayer._pGold); - DrawString(out, chrstr, { { LEFT_PANEL_X + 216, LEFT_PANEL_Y + 146 }, { 84, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 216, 146 }), { 84, 0 } }, UiFlags::ColorSilver | UiFlags::AlignCenter); style = UiFlags::ColorSilver; if (myPlayer._pIBonusAC > 0) @@ -1345,7 +1409,7 @@ void DrawChr(const Surface &out) if (myPlayer._pIBonusAC < 0) style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer.GetArmor()); - DrawString(out, chrstr, { { LEFT_PANEL_X + 258, LEFT_PANEL_Y + 183 }, { 43, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 258, 183 }), { 43, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorSilver; if (myPlayer._pIBonusToHit > 0) @@ -1353,7 +1417,7 @@ void DrawChr(const Surface &out) if (myPlayer._pIBonusToHit < 0) style = UiFlags::ColorRed; sprintf(chrstr, "%i%%", (myPlayer.InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_BOW ? myPlayer.GetRangedToHit() : myPlayer.GetMeleeToHit())); - DrawString(out, chrstr, { { LEFT_PANEL_X + 258, LEFT_PANEL_Y + 211 }, { 43, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 258, 211 }), { 43, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorSilver; if (myPlayer._pIBonusDam > 0) @@ -1384,9 +1448,9 @@ void DrawChr(const Surface &out) } sprintf(chrstr, "%i-%i", mindam, maxdam); if (mindam >= 100 || maxdam >= 100) - DrawString(out, chrstr, { { LEFT_PANEL_X + 254, LEFT_PANEL_Y + 239 }, { 51, 0 } }, style | UiFlags::AlignCenter, -1); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 254, 239 }), { 51, 0 } }, style | UiFlags::AlignCenter, -1); else - DrawString(out, chrstr, { { LEFT_PANEL_X + 258, LEFT_PANEL_Y + 239 }, { 43, 0 } }, style | UiFlags::AlignCenter, 0); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 258, 239 }), { 43, 0 } }, style | UiFlags::AlignCenter, 0); style = UiFlags::ColorBlue; if (myPlayer._pMagResist == 0) @@ -1397,7 +1461,7 @@ void DrawChr(const Surface &out) style = UiFlags::ColorGold; strcpy(chrstr, _(/* TRANSLATORS: UI Constrains. Keep translation short please!*/ "MAX")); } - DrawString(out, chrstr, { { LEFT_PANEL_X + 257, LEFT_PANEL_Y + 276 }, { 43, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 257, 276 }), { 43, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorBlue; if (myPlayer._pFireResist == 0) @@ -1408,7 +1472,7 @@ void DrawChr(const Surface &out) style = UiFlags::ColorGold; strcpy(chrstr, _("MAX")); } - DrawString(out, chrstr, { { LEFT_PANEL_X + 257, LEFT_PANEL_Y + 304 }, { 43, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 257, 304 }), { 43, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorBlue; if (myPlayer._pLghtResist == 0) @@ -1419,31 +1483,31 @@ void DrawChr(const Surface &out) style = UiFlags::ColorGold; strcpy(chrstr, _("MAX")); } - DrawString(out, chrstr, { { LEFT_PANEL_X + 257, LEFT_PANEL_Y + 332 }, { 43, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 257, 332 }), { 43, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorSilver; sprintf(chrstr, "%i", myPlayer._pBaseStr); if (myPlayer.GetMaximumAttributeValue(CharacterAttribute::Strength) == myPlayer._pBaseStr) style = UiFlags::ColorGold; - DrawString(out, chrstr, { { LEFT_PANEL_X + 95, LEFT_PANEL_Y + 155 }, { 31, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 95, 155 }), { 31, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorSilver; sprintf(chrstr, "%i", myPlayer._pBaseMag); if (myPlayer.GetMaximumAttributeValue(CharacterAttribute::Magic) == myPlayer._pBaseMag) style = UiFlags::ColorGold; - DrawString(out, chrstr, { { LEFT_PANEL_X + 95, LEFT_PANEL_Y + 183 }, { 31, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 95, 183 }), { 31, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorSilver; sprintf(chrstr, "%i", myPlayer._pBaseDex); if (myPlayer.GetMaximumAttributeValue(CharacterAttribute::Dexterity) == myPlayer._pBaseDex) style = UiFlags::ColorGold; - DrawString(out, chrstr, { { LEFT_PANEL_X + 95, LEFT_PANEL_Y + 211 }, { 31, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 95, 211 }), { 31, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorSilver; sprintf(chrstr, "%i", myPlayer._pBaseVit); if (myPlayer.GetMaximumAttributeValue(CharacterAttribute::Vitality) == myPlayer._pBaseVit) style = UiFlags::ColorGold; - DrawString(out, chrstr, { { LEFT_PANEL_X + 95, LEFT_PANEL_Y + 239 }, { 31, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 95, 239 }), { 31, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorSilver; if (myPlayer._pStrength > myPlayer._pBaseStr) @@ -1451,7 +1515,7 @@ void DrawChr(const Surface &out) if (myPlayer._pStrength < myPlayer._pBaseStr) style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pStrength); - DrawString(out, chrstr, { { LEFT_PANEL_X + 143, LEFT_PANEL_Y + 155 }, { 30, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 143, 155 }), { 30, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorSilver; if (myPlayer._pMagic > myPlayer._pBaseMag) @@ -1459,7 +1523,7 @@ void DrawChr(const Surface &out) if (myPlayer._pMagic < myPlayer._pBaseMag) style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pMagic); - DrawString(out, chrstr, { { LEFT_PANEL_X + 143, LEFT_PANEL_Y + 183 }, { 30, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 143, 183 }), { 30, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorSilver; if (myPlayer._pDexterity > myPlayer._pBaseDex) @@ -1467,7 +1531,7 @@ void DrawChr(const Surface &out) if (myPlayer._pDexterity < myPlayer._pBaseDex) style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pDexterity); - DrawString(out, chrstr, { { LEFT_PANEL_X + 143, LEFT_PANEL_Y + 211 }, { 30, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 143, 211 }), { 30, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorSilver; if (myPlayer._pVitality > myPlayer._pBaseVit) @@ -1475,7 +1539,7 @@ void DrawChr(const Surface &out) if (myPlayer._pVitality < myPlayer._pBaseVit) style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pVitality); - DrawString(out, chrstr, { { LEFT_PANEL_X + 143, LEFT_PANEL_Y + 239 }, { 30, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 143, 239 }), { 30, 0 } }, style | UiFlags::AlignCenter); if (myPlayer._pStatPts > 0) { if (CalcStatDiff(myPlayer) < myPlayer._pStatPts) { @@ -1484,36 +1548,36 @@ void DrawChr(const Surface &out) } if (myPlayer._pStatPts > 0) { sprintf(chrstr, "%i", myPlayer._pStatPts); - DrawString(out, chrstr, { { LEFT_PANEL_X + 95, LEFT_PANEL_Y + 266 }, { 31, 0 } }, UiFlags::ColorRed | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 95, 266 }), { 31, 0 } }, UiFlags::ColorRed | UiFlags::AlignCenter); if (myPlayer._pBaseStr < myPlayer.GetMaximumAttributeValue(CharacterAttribute::Strength)) - CelDrawTo(out, { LEFT_PANEL_X + 137, LEFT_PANEL_Y + 159 }, *pChrButtons, chrbtn[static_cast(CharacterAttribute::Strength)] ? 3 : 2); + CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 159 }), *pChrButtons, chrbtn[static_cast(CharacterAttribute::Strength)] ? 3 : 2); if (myPlayer._pBaseMag < myPlayer.GetMaximumAttributeValue(CharacterAttribute::Magic)) - CelDrawTo(out, { LEFT_PANEL_X + 137, LEFT_PANEL_Y + 187 }, *pChrButtons, chrbtn[static_cast(CharacterAttribute::Magic)] ? 5 : 4); + CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 187 }), *pChrButtons, chrbtn[static_cast(CharacterAttribute::Magic)] ? 5 : 4); if (myPlayer._pBaseDex < myPlayer.GetMaximumAttributeValue(CharacterAttribute::Dexterity)) - CelDrawTo(out, { LEFT_PANEL_X + 137, LEFT_PANEL_Y + 216 }, *pChrButtons, chrbtn[static_cast(CharacterAttribute::Dexterity)] ? 7 : 6); + CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 216 }), *pChrButtons, chrbtn[static_cast(CharacterAttribute::Dexterity)] ? 7 : 6); if (myPlayer._pBaseVit < myPlayer.GetMaximumAttributeValue(CharacterAttribute::Vitality)) - CelDrawTo(out, { LEFT_PANEL_X + 137, LEFT_PANEL_Y + 244 }, *pChrButtons, chrbtn[static_cast(CharacterAttribute::Vitality)] ? 9 : 8); + CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 244 }), *pChrButtons, chrbtn[static_cast(CharacterAttribute::Vitality)] ? 9 : 8); } style = UiFlags::ColorSilver; if (myPlayer._pMaxHP > myPlayer._pMaxHPBase) style = UiFlags::ColorBlue; sprintf(chrstr, "%i", myPlayer._pMaxHP >> 6); - DrawString(out, chrstr, { { LEFT_PANEL_X + 95, LEFT_PANEL_Y + 304 }, { 31, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 95, 304 }), { 31, 0 } }, style | UiFlags::AlignCenter); if (myPlayer._pHitPoints != myPlayer._pMaxHP) style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pHitPoints >> 6); - DrawString(out, chrstr, { { LEFT_PANEL_X + 143, LEFT_PANEL_Y + 304 }, { 31, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 143, 304 }), { 31, 0 } }, style | UiFlags::AlignCenter); style = UiFlags::ColorSilver; if (myPlayer._pMaxMana > myPlayer._pMaxManaBase) style = UiFlags::ColorBlue; sprintf(chrstr, "%i", myPlayer._pMaxMana >> 6); - DrawString(out, chrstr, { { LEFT_PANEL_X + 95, LEFT_PANEL_Y + 332 }, { 31, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 95, 332 }), { 31, 0 } }, style | UiFlags::AlignCenter); if (myPlayer._pMana != myPlayer._pMaxMana) style = UiFlags::ColorRed; sprintf(chrstr, "%i", myPlayer._pMana >> 6); - DrawString(out, chrstr, { { LEFT_PANEL_X + 143, LEFT_PANEL_Y + 332 }, { 31, 0 } }, style | UiFlags::AlignCenter); + DrawString(out, chrstr, { GetPanelPosition(UiPanels::Character, { 143, 332 }), { 31, 0 } }, style | UiFlags::AlignCenter); } void CheckLvlBtn() @@ -1568,7 +1632,9 @@ void CheckChrBtns() continue; } auto buttonId = static_cast(attribute); - if (ChrBtnsRect[buttonId].Contains({ MousePosition.x - LEFT_PANEL_X, MousePosition.y - LEFT_PANEL_Y })) { + Rectangle button = ChrBtnsRect[buttonId]; + button.position = GetPanelPosition(UiPanels::Character, button.position); + if (button.Contains(MousePosition)) { chrbtn[buttonId] = true; chrbtnactive = true; } @@ -1584,7 +1650,9 @@ void ReleaseChrBtns(bool addAllStatPoints) continue; chrbtn[buttonId] = false; - if (ChrBtnsRect[buttonId].Contains({ MousePosition.x - LEFT_PANEL_X, MousePosition.y - LEFT_PANEL_Y })) { + Rectangle button = ChrBtnsRect[buttonId]; + button.position = GetPanelPosition(UiPanels::Character, button.position); + if (button.Contains(MousePosition)) { auto &myPlayer = Players[MyPlayerId]; int statPointsToAdd = 1; if (addAllStatPoints) @@ -1649,16 +1717,16 @@ void RedBack(const Surface &out) void DrawSpellBook(const Surface &out) { - CelDrawTo(out, { RIGHT_PANEL_X, RIGHT_PANEL_Y + 351 }, *pSpellBkCel, 1); + CelDrawTo(out, GetPanelPosition(UiPanels::Spell, { 0, 351 }), *pSpellBkCel, 1); if (gbIsHellfire && sbooktab < 5) { - CelDrawTo(out, { RIGHT_PANEL_X + 61 * sbooktab + 7, RIGHT_PANEL_Y + 348 }, *pSBkBtnCel, sbooktab + 1); + CelDrawTo(out, GetPanelPosition(UiPanels::Spell, { 61 * sbooktab + 7, 348 }), *pSBkBtnCel, sbooktab + 1); } else { // BUGFIX: rendering of page 3 and page 4 buttons are both off-by-one pixel (fixed). - int sx = RIGHT_PANEL_X + 76 * sbooktab + 7; + int sx = 76 * sbooktab + 7; if (sbooktab == 2 || sbooktab == 3) { sx++; } - CelDrawTo(out, { sx, RIGHT_PANEL_Y + 348 }, *pSBkBtnCel, sbooktab + 1); + CelDrawTo(out, GetPanelPosition(UiPanels::Spell, { sx, 348 }), *pSBkBtnCel, sbooktab + 1); } auto &myPlayer = Players[MyPlayerId]; uint64_t spl = myPlayer._pMemSpells | myPlayer._pISpells | myPlayer._pAblSpells; @@ -1669,7 +1737,7 @@ void DrawSpellBook(const Surface &out) if (sn != SPL_INVALID && (spl & GetSpellBitmask(sn)) != 0) { spell_type st = GetSBookTrans(sn, true); SetSpellTrans(st); - const Point spellCellPosition { RIGHT_PANEL_X + 11, RIGHT_PANEL_Y + yp }; + const Point spellCellPosition = GetPanelPosition(UiPanels::Spell, { 11, yp }); DrawSpellCel(out, spellCellPosition, *pSBkIconCels, SpellITbl[sn]); if (sn == myPlayer._pRSpell && st == myPlayer._pRSplType) { SetSpellTrans(RSPLTYPE_SKILL); @@ -1717,8 +1785,10 @@ void DrawSpellBook(const Surface &out) void CheckSBook() { - if (MousePosition.x >= RIGHT_PANEL_X + 11 && MousePosition.x < RIGHT_PANEL_X + 48 && MousePosition.y >= RIGHT_PANEL_Y + 18 && MousePosition.y < RIGHT_PANEL_Y + 314) { - spell_id sn = SpellPages[sbooktab][(MousePosition.y - RIGHT_PANEL_Y - 18) / 43]; + Rectangle iconArea = { GetPanelPosition(UiPanels::Spell, { 11, 18 }), { 48 - 11, 314 - 18 } }; + Rectangle tabArea = { GetPanelPosition(UiPanels::Spell, { 7, 320 }), { 311 - 7, 349 - 320 } }; + if (iconArea.Contains(MousePosition)) { + spell_id sn = SpellPages[sbooktab][(MousePosition.y - RightPanel.position.y - 18) / 43]; auto &myPlayer = Players[MyPlayerId]; uint64_t spl = myPlayer._pMemSpells | myPlayer._pISpells | myPlayer._pAblSpells; if (sn != SPL_INVALID && (spl & GetSpellBitmask(sn)) != 0) { @@ -1734,16 +1804,16 @@ void CheckSBook() force_redraw = 255; } } - if (MousePosition.x >= RIGHT_PANEL_X + 7 && MousePosition.x < RIGHT_PANEL_X + 311 && MousePosition.y >= RIGHT_PANEL_Y + SPANEL_WIDTH && MousePosition.y < RIGHT_PANEL_Y + 349) { - sbooktab = (MousePosition.x - (RIGHT_PANEL_X + 7)) / (gbIsHellfire ? 61 : 76); + if (tabArea.Contains(MousePosition)) { + sbooktab = (MousePosition.x - (RightPanel.position.x + 7)) / (gbIsHellfire ? 61 : 76); } } void DrawGoldSplit(const Surface &out, int amount) { - const int dialogX = RIGHT_PANEL_X + 30; + const int dialogX = 30; - CelDrawTo(out, { dialogX, RIGHT_PANEL_Y + 178 }, *pGBoxBuff, 1); + CelDrawTo(out, GetPanelPosition(UiPanels::Inventory, { dialogX, 178 }), *pGBoxBuff, 1); constexpr auto BufferSize = sizeof(tempstr) / sizeof(*tempstr); @@ -1769,7 +1839,7 @@ void DrawGoldSplit(const Surface &out, int amount) // The split gold dialog is roughly 4 lines high, but we need at least one line for the player to input an amount. // Using a clipping region 50 units high (approx 3 lines with a lineheight of 17) to ensure there is enough room left // for the text entered by the player. - DrawString(out, tempstr, { { dialogX + 31, RIGHT_PANEL_Y + 87 }, { 200, 50 } }, UiFlags::ColorGold | UiFlags::AlignCenter, 1, 17); + DrawString(out, tempstr, { GetPanelPosition(UiPanels::Inventory, { dialogX + 31, 87 }), { 200, 50 } }, UiFlags::ColorGold | UiFlags::AlignCenter, 1, 17); tempstr[0] = '\0'; if (amount > 0) { @@ -1778,7 +1848,7 @@ void DrawGoldSplit(const Surface &out, int amount) } // Even a ten digit amount of gold only takes up about half a line. There's no need to wrap or clip text here so we // use the Point form of DrawString. - DrawString(out, tempstr, Point { dialogX + 37, RIGHT_PANEL_Y + 140 }, UiFlags::ColorSilver, 1, -1, true); + DrawString(out, tempstr, GetPanelPosition(UiPanels::Inventory, { dialogX + 37, 140 }), UiFlags::ColorSilver, 1, -1, true); } void control_drop_gold(char vkey) diff --git a/Source/control.h b/Source/control.h index 4a3e8938b..a99914416 100644 --- a/Source/control.h +++ b/Source/control.h @@ -27,10 +27,6 @@ namespace devilution { #define SPANEL_WIDTH 320 #define SPANEL_HEIGHT 352 -#define LEFT_PANEL_X 0 -#define LEFT_PANEL_Y ((gnScreenHeight - PANEL_HEIGHT - SPANEL_HEIGHT) / 2) -#define RIGHT_PANEL_X (gnScreenWidth - SPANEL_WIDTH) -#define RIGHT_PANEL_Y LEFT_PANEL_Y extern bool drawhpflag; extern bool dropGoldFlag; @@ -55,6 +51,9 @@ extern bool panelflag; extern int initialDropGoldValue; extern bool panbtndown; extern bool spselflag; +extern Rectangle MainPanel; +extern Rectangle LeftPanel; +extern Rectangle RightPanel; /** * @brief Check if the UI can cover the game area entierly @@ -72,6 +71,7 @@ void ToggleSpell(int slot); void AddPanelString(const char *str); void ClearPanel(); void DrawPanelBox(const Surface &out, SDL_Rect srcRect, Point targetPosition); +Point GetPanelPosition(UiPanels panel, Point offset = { 0, 0 }); /** * Draws the top dome of the life flask (that part that protrudes out of the control panel). diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index bc508575f..30d0d0332 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -465,8 +465,11 @@ void AttrIncBtnSnap(AxisDirection dir) // first, find our cursor location int slot = 0; + Rectangle button; for (int i = 0; i < 4; i++) { - if (ChrBtnsRect[i].Contains(MousePosition)) { + button = ChrBtnsRect[i]; + button.position = GetPanelPosition(UiPanels::Character, button.position); + if (button.Contains(MousePosition)) { slot = i; break; } @@ -481,14 +484,16 @@ void AttrIncBtnSnap(AxisDirection dir) } // move cursor to our new location - int x = ChrBtnsRect[slot].position.x + (ChrBtnsRect[slot].size.width / 2); - int y = ChrBtnsRect[slot].position.y + (ChrBtnsRect[slot].size.height / 2); + button = ChrBtnsRect[slot]; + button.position = GetPanelPosition(UiPanels::Character, button.position); + int x = button.position.x + (button.size.width / 2); + int y = button.position.y + (button.size.height / 2); SetCursorPos(x, y); } Point InvGetEquipSlotCoord(const inv_body_loc invSlot) { - Point result { RIGHT_PANEL_X, RIGHT_PANEL_Y }; + Point result = GetPanelPosition(UiPanels::Inventory); result.x -= (icursW28 - 1) * (InventorySlotSizeInPixels.width / 2); switch (invSlot) { case INVLOC_HEAD: @@ -558,7 +563,7 @@ Point InvGetEquipSlotCoordFromInvSlot(const inv_xy_slot slot) Point InvGetSlotCoord(int slot) { assert(slot <= SLOTXY_INV_LAST); - return { InvRect[slot].x + RIGHT_PANEL_X, InvRect[slot].y + RIGHT_PANEL_Y }; + return GetPanelPosition(UiPanels::Inventory, InvRect[slot]); } /** @@ -567,7 +572,7 @@ Point InvGetSlotCoord(int slot) Point BeltGetSlotCoord(int slot) { assert(slot >= SLOTXY_BELT_FIRST && slot <= SLOTXY_BELT_LAST); - return { InvRect[slot].x + PANEL_LEFT, InvRect[slot].y + PANEL_TOP }; + return GetPanelPosition(UiPanels::Main, InvRect[slot]); } /** diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 20e32ffea..2490bb342 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -423,21 +423,21 @@ void CheckCursMove() cursmy = my; return; } - if (MousePosition.y > PANEL_TOP && MousePosition.x >= PANEL_LEFT && MousePosition.x <= PANEL_LEFT + PANEL_WIDTH) { + if (MainPanel.Contains(MousePosition)) { CheckPanelInfo(); return; } if (DoomFlag) { return; } - if (invflag && MousePosition.x > RIGHT_PANEL_X && MousePosition.x < RIGHT_PANEL_X + SPANEL_WIDTH && MousePosition.y > RIGHT_PANEL_Y && MousePosition.y < RIGHT_PANEL_Y + SPANEL_HEIGHT) { + if (invflag && RightPanel.Contains(MousePosition)) { pcursinvitem = CheckInvHLight(); return; } - if (sbookflag && MousePosition.x > RIGHT_PANEL_X && MousePosition.x < RIGHT_PANEL_X + SPANEL_WIDTH && MousePosition.y > RIGHT_PANEL_Y && MousePosition.y < RIGHT_PANEL_Y + SPANEL_HEIGHT) { + if (sbookflag && RightPanel.Contains(MousePosition)) { return; } - if ((chrflag || QuestLogIsOpen) && MousePosition.x > LEFT_PANEL_X && MousePosition.x < LEFT_PANEL_X + SPANEL_WIDTH && MousePosition.y > LEFT_PANEL_Y && MousePosition.y < LEFT_PANEL_Y + SPANEL_HEIGHT) { + if ((chrflag || QuestLogIsOpen) && LeftPanel.Contains(MousePosition)) { return; } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index bfbb7ff1c..254518050 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -327,19 +327,19 @@ void LeftMouseDown(int wParam) bool isShiftHeld = (wParam & DVL_MK_SHIFT) != 0; - if (MousePosition.y < PANEL_TOP || MousePosition.x < PANEL_LEFT || MousePosition.x >= PANEL_LEFT + PANEL_WIDTH) { + if (!MainPanel.Contains(MousePosition)) { if (!gmenu_is_active() && !TryIconCurs()) { - if (QuestLogIsOpen && MousePosition.x > LEFT_PANEL_X + 32 && MousePosition.x < LEFT_PANEL_X + 288 && MousePosition.y > LEFT_PANEL_Y + 32 && MousePosition.y < LEFT_PANEL_Y + 308) { + if (QuestLogIsOpen && LeftPanel.Contains(MousePosition)) { QuestlogESC(); } else if (qtextflag) { qtextflag = false; stream_stop(); - } else if (chrflag && MousePosition.x > LEFT_PANEL_X && MousePosition.x < LEFT_PANEL_X + SPANEL_WIDTH && MousePosition.y > LEFT_PANEL_Y && MousePosition.y < LEFT_PANEL_Y + SPANEL_HEIGHT) { + } else if (chrflag && LeftPanel.Contains(MousePosition)) { CheckChrBtns(); - } else if (invflag && MousePosition.x > RIGHT_PANEL_X && MousePosition.x < RIGHT_PANEL_X + SPANEL_WIDTH && MousePosition.y > RIGHT_PANEL_Y && MousePosition.y < RIGHT_PANEL_Y + SPANEL_HEIGHT) { + } else if (invflag && RightPanel.Contains(MousePosition)) { if (!dropGoldFlag) CheckInvItem(isShiftHeld); - } else if (sbookflag && MousePosition.x > RIGHT_PANEL_X && MousePosition.x < RIGHT_PANEL_X + SPANEL_WIDTH && MousePosition.y > RIGHT_PANEL_Y && MousePosition.y < RIGHT_PANEL_Y + SPANEL_HEIGHT) { + } else if (sbookflag && RightPanel.Contains(MousePosition)) { CheckSBook(); } else if (pcurs >= CURSOR_FIRSTITEM) { if (TryInvPut()) { @@ -395,10 +395,9 @@ void RightMouseDown() SetSpell(); return; } - if (MousePosition.y <= RIGHT_PANEL_Y || MousePosition.y >= RIGHT_PANEL_Y + SPANEL_HEIGHT - || ((!sbookflag || MousePosition.x <= RIGHT_PANEL_X || MousePosition.x >= RIGHT_PANEL_X + SPANEL_WIDTH) + if ((!sbookflag || !RightPanel.Contains(MousePosition)) && !TryIconCurs() - && (pcursinvitem == -1 || !UseInvItem(MyPlayerId, pcursinvitem)))) { + && (pcursinvitem == -1 || !UseInvItem(MyPlayerId, pcursinvitem))) { if (pcurs == CURSOR_HAND) { if (pcursinvitem == -1 || !UseInvItem(MyPlayerId, pcursinvitem)) CheckPlrSpell(); diff --git a/Source/inv.cpp b/Source/inv.cpp index d74d7027c..01189a625 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -364,8 +364,8 @@ void CheckInvPaste(int pnum, Point cursorPosition) bool done = false; int r = 0; for (; r < NUM_XY_SLOTS && !done; r++) { - int xo = RIGHT_PANEL_X; - int yo = RIGHT_PANEL_Y; + int xo = RightPanel.position.x; + int yo = RightPanel.position.y; if (r >= SLOTXY_BELT_FIRST) { xo = PANEL_LEFT; yo = PANEL_TOP; @@ -708,8 +708,8 @@ void CheckInvCut(int pnum, Point cursorPosition, bool automaticMove) uint32_t r = 0; for (; r < NUM_XY_SLOTS; r++) { - int xo = RIGHT_PANEL_X; - int yo = RIGHT_PANEL_Y; + int xo = RightPanel.position.x; + int yo = RightPanel.position.y; if (r >= SLOTXY_BELT_FIRST) { xo = PANEL_LEFT; yo = PANEL_TOP; @@ -1126,7 +1126,7 @@ void InitInv() void DrawInv(const Surface &out) { - CelDrawTo(out, { RIGHT_PANEL_X, RIGHT_PANEL_Y + 351 }, *pInvCels, 1); + CelDrawTo(out, GetPanelPosition(UiPanels::Inventory, { 0, 351 }), *pInvCels, 1); Size slotSize[] = { { 2, 2 }, //head @@ -1154,7 +1154,7 @@ void DrawInv(const Surface &out) if (!myPlayer.InvBody[slot].isEmpty()) { int screenX = slotPos[slot].x; int screenY = slotPos[slot].y; - InvDrawSlotBack(out, { RIGHT_PANEL_X + screenX, RIGHT_PANEL_Y + screenY }, { slotSize[slot].width * InventorySlotSizeInPixels.width, slotSize[slot].height * InventorySlotSizeInPixels.height }); + InvDrawSlotBack(out, GetPanelPosition(UiPanels::Inventory, { screenX, screenY }), { slotSize[slot].width * InventorySlotSizeInPixels.width, slotSize[slot].height * InventorySlotSizeInPixels.height }); int frame = myPlayer.InvBody[slot]._iCurs + CURSOR_FIRSTITEM; @@ -1171,7 +1171,7 @@ void DrawInv(const Surface &out) const auto &cel = GetInvItemSprite(frame); const int celFrame = GetInvItemFrame(frame); - const Point position { RIGHT_PANEL_X + screenX, RIGHT_PANEL_Y + screenY }; + const Point position = GetPanelPosition(UiPanels::Inventory, { screenX, screenY }); if (pcursinvitem == slot) { CelBlitOutlineTo(out, GetOutlineColor(myPlayer.InvBody[slot], true), position, cel, celFrame, false); @@ -1184,12 +1184,12 @@ void DrawInv(const Surface &out) if (myPlayer._pClass != HeroClass::Barbarian || (myPlayer.InvBody[slot]._itype != ITYPE_SWORD && myPlayer.InvBody[slot]._itype != ITYPE_MACE)) { - InvDrawSlotBack(out, { RIGHT_PANEL_X + slotPos[INVLOC_HAND_RIGHT].x, RIGHT_PANEL_Y + slotPos[INVLOC_HAND_RIGHT].y }, { slotSize[INVLOC_HAND_RIGHT].width * InventorySlotSizeInPixels.width, slotSize[INVLOC_HAND_RIGHT].height * InventorySlotSizeInPixels.height }); + InvDrawSlotBack(out, GetPanelPosition(UiPanels::Inventory, slotPos[INVLOC_HAND_RIGHT]), { slotSize[INVLOC_HAND_RIGHT].width * InventorySlotSizeInPixels.width, slotSize[INVLOC_HAND_RIGHT].height * InventorySlotSizeInPixels.height }); LightTableIndex = 0; cel_transparency_active = true; - const int dstX = RIGHT_PANEL_X + slotPos[INVLOC_HAND_RIGHT].x + (frameSize.width == InventorySlotSizeInPixels.width ? INV_SLOT_HALF_SIZE_PX : 0) - 1; - const int dstY = RIGHT_PANEL_Y + slotPos[INVLOC_HAND_RIGHT].y; + const int dstX = RightPanel.position.x + slotPos[INVLOC_HAND_RIGHT].x + (frameSize.width == InventorySlotSizeInPixels.width ? INV_SLOT_HALF_SIZE_PX : 0) - 1; + const int dstY = RightPanel.position.y + slotPos[INVLOC_HAND_RIGHT].y; CelClippedBlitLightTransTo(out, { dstX, dstY }, cel, celFrame); cel_transparency_active = false; @@ -1203,7 +1203,7 @@ void DrawInv(const Surface &out) if (myPlayer.InvGrid[i] != 0) { InvDrawSlotBack( out, - InvRect[i + SLOTXY_INV_FIRST] + Displacement { RIGHT_PANEL_X, RIGHT_PANEL_Y - 1 }, + GetPanelPosition(UiPanels::Inventory, InvRect[i + SLOTXY_INV_FIRST]) + Displacement { 0, -1 }, InventorySlotSizeInPixels); } } @@ -1215,7 +1215,7 @@ void DrawInv(const Surface &out) const auto &cel = GetInvItemSprite(frame); const int celFrame = GetInvItemFrame(frame); - const Point position { InvRect[j + SLOTXY_INV_FIRST].x + RIGHT_PANEL_X, InvRect[j + SLOTXY_INV_FIRST].y + RIGHT_PANEL_Y - 1 }; + const Point position = GetPanelPosition(UiPanels::Inventory, InvRect[j + SLOTXY_INV_FIRST]) + Displacement { 0, -1 }; if (pcursinvitem == ii + INVITEM_INV_FIRST) { CelBlitOutlineTo( out, @@ -1880,8 +1880,8 @@ char CheckInvHLight() { uint32_t r = 0; for (; r < NUM_XY_SLOTS; r++) { - int xo = RIGHT_PANEL_X; - int yo = RIGHT_PANEL_Y; + int xo = RightPanel.position.x; + int yo = RightPanel.position.y; if (r >= SLOTXY_BELT_FIRST) { xo = PANEL_LEFT; yo = PANEL_TOP; diff --git a/Source/items.cpp b/Source/items.cpp index eb2c8ddd4..bde7509ab 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -2025,14 +2025,14 @@ void PrintItemOil(char iDidx) void DrawUniqueInfoWindow(const Surface &out) { - CelDrawTo(out, { RIGHT_PANEL_X - SPANEL_WIDTH + 24, RIGHT_PANEL_Y + 327 }, *pSTextBoxCels, 1); - DrawHalfTransparentRectTo(out, RIGHT_PANEL_X - SPANEL_WIDTH + 27, RIGHT_PANEL_Y + 28, 265, 297); + CelDrawTo(out, GetPanelPosition(UiPanels::Inventory, { 24 - SPANEL_WIDTH, 327 }), *pSTextBoxCels, 1); + DrawHalfTransparentRectTo(out, RightPanel.position.x - SPANEL_WIDTH + 27, RightPanel.position.y + 28, 265, 297); } void DrawUniqueInfoDevider(const Surface &out, int y) { - BYTE *src = out.at(26 + RIGHT_PANEL_X - SPANEL_WIDTH, RIGHT_PANEL_Y + 25); - BYTE *dst = out.at(26 + RIGHT_PANEL_X - SPANEL_WIDTH, RIGHT_PANEL_Y + y * 12 + 38); + BYTE *src = out.at(26 + RightPanel.position.x - SPANEL_WIDTH, RightPanel.position.y + 25); + BYTE *dst = out.at(26 + RightPanel.position.x - SPANEL_WIDTH, RightPanel.position.y + y * 12 + 38); for (int i = 0; i < 3; i++, src += out.pitch(), dst += out.pitch()) memcpy(dst, src, 267); // BUGFIX: should be 267 (fixed) @@ -4129,13 +4129,13 @@ void PrintItemPower(char plidx, ItemStruct *x) void DrawUniqueInfo(const Surface &out) { - if ((chrflag || QuestLogIsOpen) && RIGHT_PANEL_X - SPANEL_WIDTH < LEFT_PANEL_X + SPANEL_WIDTH) { + if ((chrflag || QuestLogIsOpen) && LeftPanel.Contains({ RightPanel.position.x - SPANEL_WIDTH, RightPanel.position.y })) { return; } DrawUniqueInfoWindow(GlobalBackBuffer()); - Rectangle rect { { 32 + RIGHT_PANEL_X - SPANEL_WIDTH, 44 + RIGHT_PANEL_Y + 2 * 12 }, { 257, 0 } }; + Rectangle rect { { 32 + RightPanel.position.x - SPANEL_WIDTH, 44 + RightPanel.position.y + 2 * 12 }, { 257, 0 } }; const UItemStruct &uitem = UniqueItemList[curruitem._iUid]; DrawString(out, _(uitem.UIName), rect, UiFlags::AlignCenter); diff --git a/Source/options.cpp b/Source/options.cpp index b8bd14487..f29b33652 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -264,6 +264,8 @@ void LoadOptions() sgOptions.Gameplay.bRandomizeQuests = GetIniBool("Game", "Randomize Quests", true); sgOptions.Gameplay.bShowMonsterType = GetIniBool("Game", "Show Monster Type", false); sgOptions.Gameplay.bDisableCripplingShrines = GetIniBool("Game", "Disable Crippling Shrines", false); + sgOptions.Gameplay.nSPanelHAlign = GetIniInt("Game", "Side Panel Horizontal Alignment", 0); + sgOptions.Gameplay.nSPanelVAlign = GetIniInt("Game", "Side Panel Vertical Alignment", 1); GetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress, sizeof(sgOptions.Network.szBindAddress), "0.0.0.0"); sgOptions.Network.nPort = GetIniInt("Network", "Port", 6112); @@ -373,6 +375,8 @@ void SaveOptions() SetIniValue("Game", "Randomize Quests", sgOptions.Gameplay.bRandomizeQuests); SetIniValue("Game", "Show Monster Type", sgOptions.Gameplay.bShowMonsterType); SetIniValue("Game", "Disable Crippling Shrines", sgOptions.Gameplay.bDisableCripplingShrines); + SetIniValue("Game", "Side Panel Horizontal Alignment", sgOptions.Gameplay.nSPanelHAlign); + SetIniValue("Game", "Side Panel Vertical Alignment", sgOptions.Gameplay.nSPanelVAlign); SetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress); SetIniValue("Network", "Port", sgOptions.Network.nPort); diff --git a/Source/options.h b/Source/options.h index aed0d6e44..9a2aaf20d 100644 --- a/Source/options.h +++ b/Source/options.h @@ -118,6 +118,10 @@ struct GameplayOptions { bool bShowMonsterType; /** @brief Locally disable clicking on shrines which permanently cripple character. */ bool bDisableCripplingShrines; + /** @brief Side panel horizontal alignment (left/center/right) */ + int nSPanelHAlign; + /** @brief Side panel vertical alignment (top/center/bottom) */ + int nSPanelVAlign; }; struct ControllerOptions { diff --git a/Source/player.cpp b/Source/player.cpp index 8f5e1c717..49551d2f2 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -3544,12 +3544,12 @@ void CheckPlrSpell() if (pcurs != CURSOR_HAND) return; - if (MousePosition.y >= PANEL_TOP && MousePosition.x >= PANEL_LEFT && MousePosition.x <= PANEL_LEFT + PANEL_WIDTH) // inside main panel + if (MainPanel.Contains(MousePosition)) // inside main panel return; if ( - ((chrflag || QuestLogIsOpen) && MousePosition.x > LEFT_PANEL_X && MousePosition.x < LEFT_PANEL_X + SPANEL_WIDTH && MousePosition.y > LEFT_PANEL_Y && MousePosition.y < LEFT_PANEL_Y + SPANEL_HEIGHT) // inside left panel - || ((invflag || sbookflag) && MousePosition.x > RIGHT_PANEL_X && MousePosition.x < RIGHT_PANEL_X + SPANEL_WIDTH && MousePosition.y > RIGHT_PANEL_Y && MousePosition.y < RIGHT_PANEL_Y + SPANEL_HEIGHT) // inside right panel + ((chrflag || QuestLogIsOpen) && LeftPanel.Contains(MousePosition)) // inside left panel + || ((invflag || sbookflag) && RightPanel.Contains(MousePosition)) // inside right panel ) { if (rspell != SPL_HEAL && rspell != SPL_IDENTIFY diff --git a/Source/qol/itemlabels.cpp b/Source/qol/itemlabels.cpp index f08f56bbe..dea922903 100644 --- a/Source/qol/itemlabels.cpp +++ b/Source/qol/itemlabels.cpp @@ -93,11 +93,11 @@ void AddItemToLabelQueue(int id, int x, int y) bool IsMouseOverGameArea() { - if ((invflag || sbookflag) && MousePosition.x > RIGHT_PANEL_X && MousePosition.x < RIGHT_PANEL_X + SPANEL_WIDTH && MousePosition.y > RIGHT_PANEL_Y && MousePosition.y < RIGHT_PANEL_Y + SPANEL_HEIGHT) + if ((invflag || sbookflag) && RightPanel.Contains(MousePosition)) return false; - if ((chrflag || QuestLogIsOpen) && MousePosition.x > LEFT_PANEL_X && MousePosition.x < LEFT_PANEL_X + SPANEL_WIDTH && MousePosition.y > LEFT_PANEL_Y && MousePosition.y < LEFT_PANEL_Y + SPANEL_HEIGHT) + if ((chrflag || QuestLogIsOpen) && LeftPanel.Contains(MousePosition)) return false; - if (MousePosition.y >= PANEL_TOP && MousePosition.x >= PANEL_LEFT && MousePosition.x <= PANEL_LEFT + PANEL_WIDTH) + if (MainPanel.Contains(MousePosition)) return false; return true; diff --git a/Source/quests.cpp b/Source/quests.cpp index 1e4f7dce3..8acbfd03c 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -252,11 +252,11 @@ void PrintQLString(const Surface &out, int x, int line, const char *str) int sx = x + std::max((257 - width) / 2, 0); int sy = line * 12 + 44; if (qline == line) { - CelDrawTo(out, { LEFT_PANEL_X + sx - 20, LEFT_PANEL_Y + sy + 1 }, *pSPentSpn2Cels, PentSpn2Spin()); + CelDrawTo(out, GetPanelPosition(UiPanels::Quest, { sx - 20, sy + 1 }), *pSPentSpn2Cels, PentSpn2Spin()); } - DrawString(out, str, { { LEFT_PANEL_X + sx, LEFT_PANEL_Y + sy }, { 257, 0 } }, UiFlags::ColorSilver); + DrawString(out, str, { GetPanelPosition(UiPanels::Quest, { sx, sy }), { 257, 0 } }, UiFlags::ColorSilver); if (qline == line) { - CelDrawTo(out, { LEFT_PANEL_X + sx + width + 7, LEFT_PANEL_Y + sy + 1 }, *pSPentSpn2Cels, PentSpn2Spin()); + CelDrawTo(out, GetPanelPosition(UiPanels::Quest, { sx + width + 7, sy + 1 }), *pSPentSpn2Cels, PentSpn2Spin()); } } @@ -730,8 +730,8 @@ void ResyncQuests() void DrawQuestLog(const Surface &out) { - DrawString(out, _("Quest Log"), { { LEFT_PANEL_X + 32, LEFT_PANEL_Y + 44 }, { 257, 0 } }, UiFlags::AlignCenter); - CelDrawTo(out, { LEFT_PANEL_X, LEFT_PANEL_Y + 351 }, *pQLogCel, 1); + DrawString(out, _("Quest Log"), { GetPanelPosition(UiPanels::Quest, { 32, 44 }), { 257, 0 } }, UiFlags::AlignCenter); + CelDrawTo(out, GetPanelPosition(UiPanels::Quest, { 0, 351 }), *pQLogCel, 1); int line = qtopline; for (int i = 0; i < numqlines; i++) { PrintQLString(out, 32, line, _(QuestData[qlist[i]]._qlstr)); @@ -798,7 +798,10 @@ void QuestlogEnter() void QuestlogESC() { - int y = (MousePosition.y - LEFT_PANEL_Y - 32) / 12; + Rectangle innerArea = { { LeftPanel.position.x + 32, LeftPanel.position.y + 32 }, { 288 - 32, 308 - 32 } }; + int y = (MousePosition.y - LeftPanel.position.y - 32) / 12; + if (!innerArea.Contains(MousePosition)) + return; for (int i = 0; i < numqlines; i++) { if (y == qtopline + 2 * i) { qline = y; diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index b3bced3c8..0c1d12408 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1212,7 +1212,7 @@ void DrawView(const Surface &out, int startX, int startY) DrawQuestLog(out); } if (!chrflag && Players[MyPlayerId]._pStatPts != 0 && !spselflag - && (!QuestLogIsOpen || PANEL_Y >= LEFT_PANEL_Y + SPANEL_HEIGHT + 74 || PANEL_X >= LEFT_PANEL_X + SPANEL_WIDTH)) { + && (!QuestLogIsOpen || !LeftPanel.Contains(MainPanel.position + Displacement { 0, -74 }))) { DrawLevelUpIcon(out); } if (ShowUniqueItemInfoBox) {