diff --git a/Source/control.cpp b/Source/control.cpp index af9a1111422..5cfdec301be 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -67,7 +67,7 @@ namespace devilution { -bool dropGoldFlag; +bool DropGoldFlag; TextInputCursorState GoldDropCursor; char GoldDropText[21]; namespace { @@ -75,23 +75,23 @@ int8_t GoldDropInvIndex; std::optional GoldDropInputState; } // namespace -bool chrbtn[4]; -bool lvlbtndown; -bool chrbtnactive; +bool CharPanelButton[4]; +bool LevelButtonDown; +bool CharPanelButtonActive; UiFlags InfoColor; -int sbooktab; -bool talkflag; -bool sbookflag; -bool chrflag; +int SpellbookTab; +bool ChatFlag; +bool SpellbookFlag; +bool CharFlag; StringOrView InfoString; -bool panelflag; -bool panbtndown; -bool spselflag; +bool MainPanelFlag; +bool MainPanelButtonDown; +bool SpellSelectFlag; Rectangle MainPanel; Rectangle LeftPanel; Rectangle RightPanel; -std::optional pBtmBuff; -OptionalOwnedClxSpriteList pGBoxBuff; +std::optional BottomBuffer; +OptionalOwnedClxSpriteList GoldBoxBuffer; const Rectangle &GetMainPanel() { @@ -107,16 +107,16 @@ const Rectangle &GetRightPanel() } bool IsLeftPanelOpen() { - return chrflag || QuestLogIsOpen || IsStashOpen; + return CharFlag || QuestLogIsOpen || IsStashOpen; } bool IsRightPanelOpen() { - return invflag || sbookflag; + return invflag || SpellbookFlag; } constexpr Size IncrementAttributeButtonSize { 41, 22 }; /** Maps from attribute_id to the rectangle on screen used for attribute increment buttons. */ -Rectangle CharButtonRect[4] = { +Rectangle CharPanelButtonRect[4] = { { { 137, 138 }, IncrementAttributeButtonSize }, { { 137, 166 }, IncrementAttributeButtonSize }, { { 137, 195 }, IncrementAttributeButtonSize }, @@ -126,7 +126,7 @@ Rectangle CharButtonRect[4] = { constexpr Size WidePanelButtonSize { 71, 20 }; constexpr Size PanelButtonSize { 33, 32 }; /** Positions of panel buttons. */ -Rectangle PanelButtonRect[8] = { +Rectangle MainPanelButtonRect[8] = { // clang-format off { { 9, 9 }, WidePanelButtonSize }, // char button { { 9, 35 }, WidePanelButtonSize }, // quests button @@ -141,15 +141,18 @@ Rectangle PanelButtonRect[8] = { Rectangle LevelButtonRect = { { 40, -39 }, { 41, 22 } }; -int beltItems = 8; -Size BeltSize { (INV_SLOT_SIZE_PX + 1) * beltItems, INV_SLOT_SIZE_PX }; +int BeltItems = 8; +Size BeltSize { (INV_SLOT_SIZE_PX + 1) * BeltItems, INV_SLOT_SIZE_PX }; Rectangle BeltRect { { 205, 5 }, BeltSize }; Rectangle SpellButtonRect { { 565, 64 }, { 56, 56 } }; -Rectangle FlaskTopRect = { { 13, 3 }, { 60, 13 } }; -constexpr Size FlaskBottomSize = { 84, 69 }; -Rectangle FlaskBottomRect = { { 0, 16 }, FlaskBottomSize }; +Rectangle FlaskTopRect { { 13, 3 }, { 60, 13 } }; +Rectangle FlaskBottomRect { { 0, 16 }, { 84, 69 } }; + +int MuteButtons = 3; +int MuteButtonPadding = 2; +Rectangle MuteButtonRect { { 172, 69 }, { 61, 16 } }; namespace { @@ -158,7 +161,7 @@ std::optional pManaBuff; OptionalOwnedClxSpriteList talkButtons; OptionalOwnedClxSpriteList pDurIcons; OptionalOwnedClxSpriteList multiButtons; -OptionalOwnedClxSpriteList pPanelButtons; +OptionalOwnedClxSpriteList pMainPanelButtons; enum panel_button_id : uint8_t { PanelButtonCharinfo, @@ -173,9 +176,9 @@ enum panel_button_id : uint8_t { PanelButtonLast = PanelButtonFriendly, }; -bool PanelButtons[PanelButtonLast + 1]; -int TotalSpButtons = 6; -int TotalMpButtons = 8; +bool MainPanelButtons[PanelButtonLast + 1]; +int TotalSpMainPanelButtons = 6; +int TotalMpMainPanelButtons = 8; char TalkSave[8][MAX_SEND_STR_LEN]; uint8_t TalkSaveIndex; uint8_t NextTalkSave; @@ -235,7 +238,7 @@ void DrawFlaskUpper(const Surface &out, const Surface &sourceBuffer, int offset, // Draw the filled part of the flask over the empty part if (filledRows > 0) { - DrawFlaskAbovePanel(out, *pBtmBuff, { offset, FlaskTopRect.position.y + emptyRows }, GetMainPanel().position + Displacement { offset, -FlaskTopRect.size.height + emptyRows }, filledRows); + DrawFlaskAbovePanel(out, *BottomBuffer, { offset, FlaskTopRect.position.y + emptyRows }, GetMainPanel().position + Displacement { offset, -FlaskTopRect.size.height + emptyRows }, filledRows); } } @@ -264,28 +267,39 @@ void DrawFlaskOnPanel(const Surface &out, Point position, const Surface &celBuf, */ void DrawFlaskLower(const Surface &out, const Surface &sourceBuffer, int offset, int fillPer) { - int filled = std::clamp(fillPer, 0, FlaskBottomSize.height); + int filled = std::clamp(fillPer, 0, FlaskBottomRect.size.height); - if (filled < FlaskBottomSize.height) + if (filled < FlaskBottomRect.size.height) DrawFlaskOnPanel(out, GetMainPanel().position + Displacement { offset, 0 }, sourceBuffer, FlaskBottomRect.position.y, FlaskBottomRect.position.y + FlaskBottomRect.size.height - filled); } -void SetButtonStateDown(int btnId) +void SetMainPanelButtonDown(int btnId) +{ + MainPanelButtons[btnId] = true; + RedrawComponent(PanelDrawComponent::ControlButtons); + MainPanelButtonDown = true; +} + +void SetMainPanelButtonUp() { - PanelButtons[btnId] = true; RedrawComponent(PanelDrawComponent::ControlButtons); - panbtndown = true; + MainPanelButtonDown = false; +} + +void SetPanelObjectPosition(UiPanels panel, Rectangle &button) +{ + button.position = GetPanelPosition(panel, button.position); } void PrintInfo(const Surface &out) { - if (talkflag) + if (ChatFlag) return; const int space[] = { 18, 12, 6, 3, 0 }; Rectangle infoBox = InfoBoxRect; - infoBox.position = GetPanelPosition(UiPanels::Main, infoBox.position); + SetPanelObjectPosition(UiPanels::Main, infoBox); const auto newLineCount = static_cast(c_count(InfoString.str(), '\n')); const int spaceIndex = std::min(4, newLineCount); @@ -500,7 +514,7 @@ std::string TextCmdInspect(const std::string_view parameter) StrAppend(ret, _("Inspecting player: ")); StrAppend(ret, player._pName); OpenCharPanel(); - if (!sbookflag) + if (!SpellbookFlag) invflag = true; RedrawEverything(); return ret; @@ -573,7 +587,7 @@ std::vector TextCmdList = { { "/seedinfo", N_("Show seed infos for current level."), "", &TextCmdLevelSeed }, }; -bool CheckTextCommand(const std::string_view text) +bool CheckChatCommand(const std::string_view text) { if (text.size() < 1 || text[0] != '/') return false; @@ -594,9 +608,9 @@ bool CheckTextCommand(const std::string_view text) return true; } -void ResetTalkMsg() +void ResetChatMessage() { - if (CheckTextCommand(TalkMessage)) + if (CheckChatCommand(TalkMessage)) return; uint32_t pmask = 0; @@ -612,7 +626,7 @@ void ResetTalkMsg() void ControlPressEnter() { if (TalkMessage[0] != 0) { - ResetTalkMsg(); + ResetChatMessage(); uint8_t i = 0; for (; i < 8; i++) { if (strcmp(TalkSave[i], TalkMessage) == 0) @@ -633,7 +647,7 @@ void ControlPressEnter() TalkMessage[0] = '\0'; TalkSaveIndex = NextTalkSave; } - control_reset_talk(); + ResetChat(); } void ControlUpDown(int v) @@ -666,7 +680,7 @@ void RemoveGold(Player &player, int goldIndex, int amount) bool IsLevelUpButtonVisible() { - if (spselflag || chrflag || MyPlayer->_pStatPts == 0) { + if (SpellSelectFlag || CharFlag || MyPlayer->_pStatPts == 0) { return false; } if (ControlMode == ControlTypes::VirtualGamepad) { @@ -746,7 +760,7 @@ void FocusOnCharInfo() if (stat == -1) return; - SetCursorPos(CharButtonRect[stat].Center()); + SetCursorPos(CharPanelButtonRect[stat].Center()); } void OpenCharPanel() @@ -754,12 +768,12 @@ void OpenCharPanel() QuestLogIsOpen = false; CloseGoldWithdraw(); CloseStash(); - chrflag = true; + CharFlag = true; } void CloseCharPanel() { - chrflag = false; + CharFlag = false; if (IsInspectingPlayer()) { InspectPlayer = MyPlayer; RedrawEverything(); @@ -769,13 +783,13 @@ void CloseCharPanel() void ToggleCharPanel() { - if (chrflag) + if (CharFlag) CloseCharPanel(); else OpenCharPanel(); } -void AddPanelString(std::string_view str) +void AddInfoBoxString(std::string_view str) { if (InfoString.empty()) InfoString = str; @@ -783,7 +797,7 @@ void AddPanelString(std::string_view str) InfoString = StrCat(InfoString, "\n", str); } -void AddPanelString(std::string &&str) +void AddInfoBoxString(std::string &&str) { if (InfoString.empty()) InfoString = std::move(str); @@ -812,7 +826,7 @@ Point GetPanelPosition(UiPanels panel, Point offset) void DrawPanelBox(const Surface &out, SDL_Rect srcRect, Point targetPosition) { - out.BlitFrom(*pBtmBuff, srcRect, targetPosition); + out.BlitFrom(*BottomBuffer, srcRect, targetPosition); } void DrawLifeFlaskUpper(const Surface &out) @@ -856,16 +870,16 @@ void DrawFlaskValues(const Surface &out, Point pos, int currValue, int maxValue) drawStringWithShadow(StrCat(maxValue), pos + Displacement { GetLineWidth("/", GameFont12) + 1, 0 }); } -void control_update_life_mana() +void UpdateLifeManaPercent() { MyPlayer->UpdateManaPercentage(); MyPlayer->UpdateHitPointPercentage(); } -void InitControlPan() +void InitMainPanel() { if (!HeadlessMode) { - pBtmBuff.emplace(GetMainPanel().size.width, (GetMainPanel().size.height + PanelPaddingHeight) * (IsChatAvailable() ? 2 : 1)); + BottomBuffer.emplace(GetMainPanel().size.width, (GetMainPanel().size.height + PanelPaddingHeight) * (IsChatAvailable() ? 2 : 1)); pManaBuff.emplace(88, 88); pLifeBuff.emplace(88, 88); @@ -873,7 +887,7 @@ void InitControlPan() LoadLargeSpellIcons(); { const OwnedClxSpriteList sprite = LoadCel("ctrlpan\\panel8", GetMainPanel().size.width); - ClxDraw(*pBtmBuff, { 0, (GetMainPanel().size.height + PanelPaddingHeight) - 1 }, sprite[0]); + ClxDraw(*BottomBuffer, { 0, (GetMainPanel().size.height + PanelPaddingHeight) - 1 }, sprite[0]); } { const Point bulbsPosition { 0, 87 }; @@ -882,13 +896,13 @@ void InitControlPan() ClxDraw(*pManaBuff, bulbsPosition, statusPanel[1]); } } - talkflag = false; + ChatFlag = false; ChatInputState = std::nullopt; if (IsChatAvailable()) { if (!HeadlessMode) { { const OwnedClxSpriteList sprite = LoadCel("ctrlpan\\talkpanl", GetMainPanel().size.width); - ClxDraw(*pBtmBuff, { 0, (GetMainPanel().size.height + PanelPaddingHeight) * 2 - 1 }, sprite[0]); + ClxDraw(*BottomBuffer, { 0, (GetMainPanel().size.height + PanelPaddingHeight) * 2 - 1 }, sprite[0]); } multiButtons = LoadCel("ctrlpan\\p8but2", 33); talkButtons = LoadCel("ctrlpan\\talkbutt", 61); @@ -900,33 +914,33 @@ void InitControlPan() for (bool &talkButtonDown : TalkButtonsDown) talkButtonDown = false; } - panelflag = false; - lvlbtndown = false; + MainPanelFlag = false; + LevelButtonDown = false; if (!HeadlessMode) { LoadMainPanel(); - pPanelButtons = LoadCel("ctrlpan\\panel8bu", 71); + pMainPanelButtons = LoadCel("ctrlpan\\panel8bu", 71); static const uint16_t CharButtonsFrameWidths[9] { 95, 41, 41, 41, 41, 41, 41, 41, 41 }; pChrButtons = LoadCel("data\\charbut", CharButtonsFrameWidths); } - ClearPanBtn(); + ResetMainPanelButtons(); if (!HeadlessMode) pDurIcons = LoadCel("items\\duricons", 32); - for (bool &buttonEnabled : chrbtn) + for (bool &buttonEnabled : CharPanelButton) buttonEnabled = false; - chrbtnactive = false; + CharPanelButtonActive = false; InfoString = StringOrView {}; RedrawComponent(PanelDrawComponent::Health); RedrawComponent(PanelDrawComponent::Mana); CloseCharPanel(); - spselflag = false; - sbooktab = 0; - sbookflag = false; + SpellSelectFlag = false; + SpellbookTab = 0; + SpellbookFlag = false; if (!HeadlessMode) { InitSpellBook(); pQLogCel = LoadCel("data\\quest", static_cast(SidePanelSize.width)); - pGBoxBuff = LoadCel("ctrlpan\\golddrop", 261); + GoldBoxBuffer = LoadCel("ctrlpan\\golddrop", 261); } CloseGoldDrop(); CalculatePanelAreas(); @@ -935,70 +949,67 @@ void InitControlPan() InitModifierHints(); } -void DrawCtrlPan(const Surface &out) +void DrawMainPanel(const Surface &out) { DrawPanelBox(out, MakeSdlRect(0, sgbPlrTalkTbl + PanelPaddingHeight, GetMainPanel().size.width, GetMainPanel().size.height), GetMainPanel().position); DrawInfoBox(out); } -void DrawCtrlBtns(const Surface &out) +void DrawMainPanelButtons(const Surface &out) { const Point mainPanelPosition = GetMainPanel().position; - int totalButtons = IsChatAvailable() ? TotalMpButtons : TotalSpButtons; + int totalButtons = IsChatAvailable() ? TotalMpMainPanelButtons : TotalSpMainPanelButtons; - for (int i = 0; i < TotalSpButtons; i++) { - if (!PanelButtons[i]) { - DrawPanelBox(out, MakeSdlRect(PanelButtonRect[i].position.x, PanelButtonRect[i].position.y + PanelPaddingHeight, PanelButtonRect[i].size.width, PanelButtonRect[i].size.height + 1), mainPanelPosition + Displacement { PanelButtonRect[i].position.x, PanelButtonRect[i].position.y }); + for (int i = 0; i < TotalSpMainPanelButtons; i++) { + if (!MainPanelButtons[i]) { + DrawPanelBox(out, MakeSdlRect(MainPanelButtonRect[i].position.x, MainPanelButtonRect[i].position.y + PanelPaddingHeight, MainPanelButtonRect[i].size.width, MainPanelButtonRect[i].size.height + 1), mainPanelPosition + Displacement { MainPanelButtonRect[i].position.x, MainPanelButtonRect[i].position.y }); } else { - Point position = mainPanelPosition + Displacement { PanelButtonRect[i].position.x, PanelButtonRect[i].position.y }; - RenderClxSprite(out, (*pPanelButtons)[i], position); + Point position = mainPanelPosition + Displacement { MainPanelButtonRect[i].position.x, MainPanelButtonRect[i].position.y }; + RenderClxSprite(out, (*pMainPanelButtons)[i], position); RenderClxSprite(out, (*PanelButtonDown)[i], position + Displacement { 4, 0 }); } } if (IsChatAvailable()) { - RenderClxSprite(out, (*multiButtons)[PanelButtons[PanelButtonSendmsg] ? 1 : 0], mainPanelPosition + Displacement { PanelButtonRect[PanelButtonSendmsg].position.x, PanelButtonRect[PanelButtonSendmsg].position.y }); + RenderClxSprite(out, (*multiButtons)[MainPanelButtons[PanelButtonSendmsg] ? 1 : 0], mainPanelPosition + Displacement { MainPanelButtonRect[PanelButtonSendmsg].position.x, MainPanelButtonRect[PanelButtonSendmsg].position.y }); - Point friendlyButtonPosition = mainPanelPosition + Displacement { PanelButtonRect[PanelButtonFriendly].position.x, PanelButtonRect[PanelButtonFriendly].position.y }; + Point friendlyButtonPosition = mainPanelPosition + Displacement { MainPanelButtonRect[PanelButtonFriendly].position.x, MainPanelButtonRect[PanelButtonFriendly].position.y }; if (MyPlayer->friendlyMode) - RenderClxSprite(out, (*multiButtons)[PanelButtons[PanelButtonFriendly] ? 3 : 2], friendlyButtonPosition); + RenderClxSprite(out, (*multiButtons)[MainPanelButtons[PanelButtonFriendly] ? 3 : 2], friendlyButtonPosition); else - RenderClxSprite(out, (*multiButtons)[PanelButtons[PanelButtonFriendly] ? 5 : 4], friendlyButtonPosition); + RenderClxSprite(out, (*multiButtons)[MainPanelButtons[PanelButtonFriendly] ? 5 : 4], friendlyButtonPosition); } } -void ClearPanBtn() +void ResetMainPanelButtons() { - for (bool &panelButton : PanelButtons) + for (bool &panelButton : MainPanelButtons) panelButton = false; - RedrawComponent(PanelDrawComponent::ControlButtons); - panbtndown = false; + SetMainPanelButtonUp(); } -void DoPanBtn() +void CheckMainPanelButton() { const Point mainPanelPosition = GetMainPanel().position; - int totalButtons = IsChatAvailable() ? TotalMpButtons : TotalSpButtons; + int totalButtons = IsChatAvailable() ? TotalMpMainPanelButtons : TotalSpMainPanelButtons; for (int i = 0; i < totalButtons; i++) { - Rectangle button = PanelButtonRect[i]; + Rectangle button = MainPanelButtonRect[i]; - button.position = GetPanelPosition(UiPanels::Main, button.position); + SetPanelObjectPosition(UiPanels::Main, button); if (button.contains(MousePosition)) { - PanelButtons[i] = true; - RedrawComponent(PanelDrawComponent::ControlButtons); - panbtndown = true; + SetMainPanelButtonDown(i); } } Rectangle spellSelectButton = SpellButtonRect; - spellSelectButton.position = GetPanelPosition(UiPanels::Main, spellSelectButton.position); + SetPanelObjectPosition(UiPanels::Main, spellSelectButton); - if (!spselflag && spellSelectButton.contains(MousePosition)) { + if (!SpellSelectFlag && spellSelectButton.contains(MousePosition)) { if ((SDL_GetModState() & KMOD_SHIFT) != 0) { Player &myPlayer = *MyPlayer; myPlayer._pRSpell = SpellID::Invalid; @@ -1011,23 +1022,23 @@ void DoPanBtn() } } -void control_check_btn_press() +void CheckMainPanelButtonDead() { - Rectangle menuButton = PanelButtonRect[PanelButtonMainmenu]; + Rectangle menuButton = MainPanelButtonRect[PanelButtonMainmenu]; - menuButton.position = GetPanelPosition(UiPanels::Main, menuButton.position); + SetPanelObjectPosition(UiPanels::Main, menuButton); if (menuButton.contains(MousePosition)) { - SetButtonStateDown(PanelButtonMainmenu); + SetMainPanelButtonDown(PanelButtonMainmenu); return; } - Rectangle chatButton = PanelButtonRect[PanelButtonSendmsg]; + Rectangle chatButton = MainPanelButtonRect[PanelButtonSendmsg]; - chatButton.position = GetPanelPosition(UiPanels::Main, chatButton.position); + SetPanelObjectPosition(UiPanels::Main, chatButton); if (chatButton.contains(MousePosition)) { - SetButtonStateDown(PanelButtonSendmsg); + SetMainPanelButtonDown(PanelButtonSendmsg); } } @@ -1055,15 +1066,15 @@ void CycleAutomapType() void CheckPanelInfo() { - panelflag = false; + MainPanelFlag = false; InfoString = StringOrView {}; - int totalButtons = IsChatAvailable() ? TotalMpButtons : TotalSpButtons; + int totalButtons = IsChatAvailable() ? TotalMpMainPanelButtons : TotalSpMainPanelButtons; for (int i = 0; i < totalButtons; i++) { - Rectangle button = PanelButtonRect[i]; + Rectangle button = MainPanelButtonRect[i]; - button.position = GetPanelPosition(UiPanels::Main, button.position); + SetPanelObjectPosition(UiPanels::Main, button); if (button.contains(MousePosition)) { if (i != 7) { @@ -1075,44 +1086,44 @@ void CheckPanelInfo() InfoString = _("Player attack"); } if (PanBtnHotKey[i] != nullptr) { - AddPanelString(fmt::format(fmt::runtime(_("Hotkey: {:s}")), _(PanBtnHotKey[i]))); + AddInfoBoxString(fmt::format(fmt::runtime(_("Hotkey: {:s}")), _(PanBtnHotKey[i]))); } InfoColor = UiFlags::ColorWhite; - panelflag = true; + MainPanelFlag = true; } } Rectangle spellSelectButton = SpellButtonRect; - spellSelectButton.position = GetPanelPosition(UiPanels::Main, spellSelectButton.position); + SetPanelObjectPosition(UiPanels::Main, spellSelectButton); - if (!spselflag && spellSelectButton.contains(MousePosition)) { + if (!SpellSelectFlag && spellSelectButton.contains(MousePosition)) { InfoString = _("Select current spell button"); InfoColor = UiFlags::ColorWhite; - panelflag = true; - AddPanelString(_("Hotkey: 's'")); + MainPanelFlag = true; + AddInfoBoxString(_("Hotkey: 's'")); const Player &myPlayer = *MyPlayer; const SpellID spellId = myPlayer._pRSpell; if (IsValidSpell(spellId)) { switch (myPlayer._pRSplType) { case SpellType::Skill: - AddPanelString(fmt::format(fmt::runtime(_("{:s} Skill")), pgettext("spell", GetSpellData(spellId).sNameText))); + AddInfoBoxString(fmt::format(fmt::runtime(_("{:s} Skill")), pgettext("spell", GetSpellData(spellId).sNameText))); break; case SpellType::Spell: { - AddPanelString(fmt::format(fmt::runtime(_("{:s} Spell")), pgettext("spell", GetSpellData(spellId).sNameText))); + AddInfoBoxString(fmt::format(fmt::runtime(_("{:s} Spell")), pgettext("spell", GetSpellData(spellId).sNameText))); const int spellLevel = myPlayer.GetSpellLevel(spellId); - AddPanelString(spellLevel == 0 ? _("Spell Level 0 - Unusable") : fmt::format(fmt::runtime(_("Spell Level {:d}")), spellLevel)); + AddInfoBoxString(spellLevel == 0 ? _("Spell Level 0 - Unusable") : fmt::format(fmt::runtime(_("Spell Level {:d}")), spellLevel)); } break; case SpellType::Scroll: { - AddPanelString(fmt::format(fmt::runtime(_("Scroll of {:s}")), pgettext("spell", GetSpellData(spellId).sNameText))); + AddInfoBoxString(fmt::format(fmt::runtime(_("Scroll of {:s}")), pgettext("spell", GetSpellData(spellId).sNameText))); const int scrollCount = c_count_if(InventoryAndBeltPlayerItemsRange { myPlayer }, [spellId](const Item &item) { return item.isScrollOf(spellId); }); - AddPanelString(fmt::format(fmt::runtime(ngettext("{:d} Scroll", "{:d} Scrolls", scrollCount)), scrollCount)); + AddInfoBoxString(fmt::format(fmt::runtime(ngettext("{:d} Scroll", "{:d} Scrolls", scrollCount)), scrollCount)); } break; case SpellType::Charges: - AddPanelString(fmt::format(fmt::runtime(_("Staff of {:s}")), pgettext("spell", GetSpellData(spellId).sNameText))); - AddPanelString(fmt::format(fmt::runtime(ngettext("{:d} Charge", "{:d} Charges", myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges)), myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges)); + AddInfoBoxString(fmt::format(fmt::runtime(_("Staff of {:s}")), pgettext("spell", GetSpellData(spellId).sNameText))); + AddInfoBoxString(fmt::format(fmt::runtime(ngettext("{:d} Charge", "{:d} Charges", myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges)), myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges)); break; case SpellType::Invalid: break; @@ -1122,31 +1133,30 @@ void CheckPanelInfo() Rectangle belt = BeltRect; - belt.position = GetPanelPosition(UiPanels::Main, belt.position); + SetPanelObjectPosition(UiPanels::Main, belt); if (belt.contains(MousePosition)) pcursinvitem = CheckInvHLight(); if (CheckXPBarInfo()) - panelflag = true; + MainPanelFlag = true; } -void CheckBtnUp() +void CheckMainPanelButtonUp() { bool gamemenuOff = true; - RedrawComponent(PanelDrawComponent::ControlButtons); - panbtndown = false; + SetMainPanelButtonUp(); for (int i = PanelButtonFirst; i <= PanelButtonLast; i++) { - if (!PanelButtons[i]) + if (!MainPanelButtons[i]) continue; - PanelButtons[i] = false; + MainPanelButtons[i] = false; - Rectangle button = PanelButtonRect[i]; + Rectangle button = MainPanelButtonRect[i]; - button.position = GetPanelPosition(UiPanels::Main, button.position); + SetPanelObjectPosition(UiPanels::Main, button); if (!button.contains(MousePosition)) continue; @@ -1173,7 +1183,7 @@ void CheckBtnUp() gamemenuOff = false; break; case PanelButtonInventory: - sbookflag = false; + SpellbookFlag = false; CloseGoldWithdraw(); CloseStash(); invflag = !invflag; @@ -1182,13 +1192,13 @@ void CheckBtnUp() case PanelButtonSpellbook: CloseInventory(); CloseGoldDrop(); - sbookflag = !sbookflag; + SpellbookFlag = !SpellbookFlag; break; case PanelButtonSendmsg: - if (talkflag) - control_reset_talk(); + if (ChatFlag) + ResetChat(); else - control_type_message(); + TypeChatMessage(); break; case PanelButtonFriendly: // Toggle friendly Mode @@ -1203,18 +1213,18 @@ void CheckBtnUp() void FreeControlPan() { - pBtmBuff = std::nullopt; + BottomBuffer = std::nullopt; pManaBuff = std::nullopt; pLifeBuff = std::nullopt; FreeLargeSpellIcons(); FreeSpellBook(); - pPanelButtons = std::nullopt; + pMainPanelButtons = std::nullopt; multiButtons = std::nullopt; talkButtons = std::nullopt; pChrButtons = std::nullopt; pDurIcons = std::nullopt; pQLogCel = std::nullopt; - pGBoxBuff = std::nullopt; + GoldBoxBuffer = std::nullopt; FreeMainPanel(); FreeCharPanel(); FreeModifierHints(); @@ -1223,12 +1233,12 @@ void FreeControlPan() void DrawInfoBox(const Surface &out) { DrawPanelBox(out, { InfoBoxRect.position.x, InfoBoxRect.position.y + PanelPaddingHeight, InfoBoxRect.size.width, InfoBoxRect.size.height }, GetMainPanel().position + Displacement { InfoBoxRect.position.x, InfoBoxRect.position.y }); - if (!panelflag && !trigflag && pcursinvitem == -1 && pcursstashitem == StashStruct::EmptyCell && !spselflag && pcurs != CURSOR_HOURGLASS) { + if (!MainPanelFlag && !trigflag && pcursinvitem == -1 && pcursstashitem == StashStruct::EmptyCell && !SpellSelectFlag && pcurs != CURSOR_HOURGLASS) { InfoString = StringOrView {}; InfoColor = UiFlags::ColorWhite; } Player &myPlayer = *MyPlayer; - if (spselflag || trigflag || pcurs == CURSOR_HOURGLASS) { + if (SpellSelectFlag || trigflag || pcurs == CURSOR_HOURGLASS) { InfoColor = UiFlags::ColorWhite; } else if (!myPlayer.HoldItem.isEmpty()) { if (myPlayer.HoldItem._itype == ItemType::Gold) { @@ -1264,15 +1274,15 @@ void DrawInfoBox(const Surface &out) InfoColor = UiFlags::ColorWhitegold; auto &target = *PlayerUnderCursor; InfoString = std::string_view(target._pName); - AddPanelString(fmt::format(fmt::runtime(_("{:s}, Level: {:d}")), target.getClassName(), target.getCharacterLevel())); - AddPanelString(fmt::format(fmt::runtime(_("Hit Points {:d} of {:d}")), target._pHitPoints >> 6, target._pMaxHP >> 6)); + AddInfoBoxString(fmt::format(fmt::runtime(_("{:s}, Level: {:d}")), target.getClassName(), target.getCharacterLevel())); + AddInfoBoxString(fmt::format(fmt::runtime(_("Hit Points {:d} of {:d}")), target._pHitPoints >> 6, target._pMaxHP >> 6)); } } if (!InfoString.empty()) PrintInfo(out); } -void CheckLvlBtn() +void CheckLevelButton() { if (!IsLevelUpButtonVisible()) { return; @@ -1281,29 +1291,29 @@ void CheckLvlBtn() const Point mainPanelPosition = GetMainPanel().position; Rectangle button = LevelButtonRect; - button.position = GetPanelPosition(UiPanels::Main, button.position); + SetPanelObjectPosition(UiPanels::Main, button); - if (!lvlbtndown && button.contains(MousePosition)) - lvlbtndown = true; + if (!LevelButtonDown && button.contains(MousePosition)) + LevelButtonDown = true; } -void ReleaseLvlBtn() +void CheckLevelButtonUp() { const Point mainPanelPosition = GetMainPanel().position; Rectangle button = LevelButtonRect; - button.position = GetPanelPosition(UiPanels::Main, button.position); + SetPanelObjectPosition(UiPanels::Main, button); if (button.contains(MousePosition)) { OpenCharPanel(); } - lvlbtndown = false; + LevelButtonDown = false; } -void DrawLevelUpIcon(const Surface &out) +void DrawLevelButton(const Surface &out) { if (IsLevelUpButtonVisible()) { - int nCel = lvlbtndown ? 2 : 1; + int nCel = LevelButtonDown ? 2 : 1; DrawString(out, _("Level Up"), { GetMainPanel().position + Displacement { 0, LevelButtonRect.position.y - 23 }, { 120, 0 } }, { .flags = UiFlags::ColorWhite | UiFlags::AlignCenter | UiFlags::KerningFitSpacing }); RenderClxSprite(out, (*pChrButtons)[nCel], GetMainPanel().position + Displacement { LevelButtonRect.position.x, LevelButtonRect.position.y }); @@ -1314,33 +1324,33 @@ void CheckChrBtns() { Player &myPlayer = *MyPlayer; - if (chrbtnactive || myPlayer._pStatPts == 0) + if (CharPanelButtonActive || myPlayer._pStatPts == 0) return; for (auto attribute : enum_values()) { if (myPlayer.GetBaseAttributeValue(attribute) >= myPlayer.GetMaximumAttributeValue(attribute)) continue; auto buttonId = static_cast(attribute); - Rectangle button = CharButtonRect[buttonId]; - button.position = GetPanelPosition(UiPanels::Character, button.position); + Rectangle button = CharPanelButtonRect[buttonId]; + SetPanelObjectPosition(UiPanels::Character, button); if (button.contains(MousePosition)) { - chrbtn[buttonId] = true; - chrbtnactive = true; + CharPanelButton[buttonId] = true; + CharPanelButtonActive = true; } } } void ReleaseChrBtns(bool addAllStatPoints) { - chrbtnactive = false; + CharPanelButtonActive = false; for (auto attribute : enum_values()) { auto buttonId = static_cast(attribute); - if (!chrbtn[buttonId]) + if (!CharPanelButton[buttonId]) continue; - chrbtn[buttonId] = false; - Rectangle button = CharButtonRect[buttonId]; - button.position = GetPanelPosition(UiPanels::Character, button.position); + CharPanelButton[buttonId] = false; + Rectangle button = CharPanelButtonRect[buttonId]; + SetPanelObjectPosition(UiPanels::Character, button); if (button.contains(MousePosition)) { Player &myPlayer = *MyPlayer; int statPointsToAdd = 1; @@ -1408,7 +1418,7 @@ void DrawGoldSplit(const Surface &out) { const int dialogX = 30; - ClxDraw(out, GetPanelPosition(UiPanels::Inventory, { dialogX, 178 }), (*pGBoxBuff)[0]); + ClxDraw(out, GetPanelPosition(UiPanels::Inventory, { dialogX, 178 }), (*GoldBoxBuffer)[0]); const std::string_view amountText = GoldDropText; const TextInputCursorState &cursor = GoldDropCursor; @@ -1466,9 +1476,9 @@ void control_drop_gold(SDL_Keycode vkey) } } -void DrawTalkPan(const Surface &out) +void DrawChatBox(const Surface &out) { - if (!talkflag) + if (!ChatFlag) return; const Point mainPanelPosition = GetMainPanel().position; @@ -1534,45 +1544,51 @@ void DrawTalkPan(const Surface &out) } } -bool control_check_talk_btn() +bool CheckMuteButton() { - if (!talkflag) + if (!ChatFlag) return false; - const Point mainPanelPosition = GetMainPanel().position; + Rectangle buttons = MuteButtonRect; - if (MousePosition.x < 172 + mainPanelPosition.x) - return false; - if (MousePosition.y < 69 + mainPanelPosition.y) - return false; - if (MousePosition.x > 233 + mainPanelPosition.x) - return false; - if (MousePosition.y > 123 + mainPanelPosition.y) + SetPanelObjectPosition(UiPanels::Main, buttons); + + buttons.size.height = (MuteButtons * buttons.size.height) + ((MuteButtons - 1) * MuteButtonPadding); + + if (!buttons.contains(MousePosition)) return false; for (bool &talkButtonDown : TalkButtonsDown) { talkButtonDown = false; } + const Point mainPanelPosition = GetMainPanel().position; + TalkButtonsDown[(MousePosition.y - (69 + mainPanelPosition.y)) / 18] = true; return true; } -void control_release_talk_btn() +void CheckMuteButtonUp() { - if (!talkflag) + if (!ChatFlag) return; for (bool &talkButtonDown : TalkButtonsDown) talkButtonDown = false; - const Point mainPanelPosition = GetMainPanel().position; + Rectangle buttons = MuteButtonRect; - if (MousePosition.x < 172 + mainPanelPosition.x || MousePosition.y < 69 + mainPanelPosition.y || MousePosition.x > 233 + mainPanelPosition.x || MousePosition.y > 123 + mainPanelPosition.y) + SetPanelObjectPosition(UiPanels::Main, buttons); + + buttons.size.height = (MuteButtons * buttons.size.height) + ((MuteButtons - 1) * MuteButtonPadding); + + if (!buttons.contains(MousePosition)) return; - int off = (MousePosition.y - (69 + mainPanelPosition.y)) / 18; + const Point mainPanelPosition = GetMainPanel().position; + + int off = (MousePosition.y - buttons.position.y) / (MuteButtonRect.size.height + MuteButtonPadding); size_t playerId = 0; for (; playerId < Players.size() && off != -1; ++playerId) { @@ -1583,12 +1599,12 @@ void control_release_talk_btn() WhisperList[playerId - 1] = !WhisperList[playerId - 1]; } -void control_type_message() +void TypeChatMessage() { if (!IsChatAvailable()) return; - talkflag = true; + ChatFlag = true; TalkMessage[0] = '\0'; ChatInputState.emplace(TextInputState::Options { .value = TalkMessage, @@ -1605,41 +1621,57 @@ void control_type_message() SDL_StartTextInput(); } -void control_reset_talk() +void ResetChat() { - talkflag = false; + ChatFlag = false; SDL_StopTextInput(); ChatInputState = std::nullopt; sgbPlrTalkTbl = 0; RedrawEverything(); } -bool IsTalkActive() +bool IsChatActive() { if (!IsChatAvailable()) return false; - if (!talkflag) + if (!ChatFlag) return false; return true; } +template +bool HandleInputEvent(const SDL_Event &event, std::optional &inputState) +{ + if (!inputState) { + return false; // No input state to handle + } + + if constexpr (std::is_same_v) { + return HandleTextInputEvent(event, *inputState); + } else if constexpr (std::is_same_v) { + return HandleNumberInputEvent(event, *inputState); + } + + return false; // Unknown input state type +} + bool HandleTalkTextInputEvent(const SDL_Event &event) { - return HandleTextInputEvent(event, *ChatInputState); + return HandleInputEvent(event, ChatInputState); } -bool control_presskeys(SDL_Keycode vkey) +bool CheckKeypress(SDL_Keycode vkey) { if (!IsChatAvailable()) return false; - if (!talkflag) + if (!ChatFlag) return false; switch (vkey) { case SDLK_ESCAPE: - control_reset_talk(); + ResetChat(); return true; case SDLK_RETURN: case SDLK_KP_ENTER: @@ -1681,7 +1713,7 @@ void DiabloHotkeyMsg(uint32_t dwMsg) void OpenGoldDrop(int8_t invIndex, int max) { - dropGoldFlag = true; + DropGoldFlag = true; GoldDropInvIndex = invIndex; GoldDropText[0] = '\0'; GoldDropInputState.emplace(NumberInputState::Options { @@ -1698,10 +1730,10 @@ void OpenGoldDrop(int8_t invIndex, int max) void CloseGoldDrop() { - if (!dropGoldFlag) + if (!DropGoldFlag) return; SDL_StopTextInput(); - dropGoldFlag = false; + DropGoldFlag = false; GoldDropInputState = std::nullopt; GoldDropInvIndex = 0; } @@ -1713,7 +1745,7 @@ int GetGoldDropMax() bool HandleGoldDropTextInputEvent(const SDL_Event &event) { - return HandleNumberInputEvent(event, *GoldDropInputState); + return HandleInputEvent(event, GoldDropInputState); } } // namespace devilution diff --git a/Source/control.h b/Source/control.h index ada5d1dae89..d99cddb86e4 100644 --- a/Source/control.h +++ b/Source/control.h @@ -37,30 +37,30 @@ constexpr Size SidePanelSize { 320, 352 }; constexpr Rectangle InfoBoxRect = { { 177, 46 }, { 288, 64 } }; -extern bool dropGoldFlag; +extern bool DropGoldFlag; extern TextInputCursorState GoldDropCursor; extern char GoldDropText[21]; -extern bool chrbtn[4]; -extern bool lvlbtndown; -extern bool chrbtnactive; +extern bool CharPanelButton[4]; +extern bool LevelButtonDown; +extern bool CharPanelButtonActive; extern UiFlags InfoColor; -extern int sbooktab; -extern bool talkflag; -extern bool sbookflag; -extern bool chrflag; +extern int SpellbookTab; +extern bool ChatFlag; +extern bool SpellbookFlag; +extern bool CharFlag; extern StringOrView InfoString; -extern bool panelflag; -extern bool panbtndown; -extern bool spselflag; +extern bool MainPanelFlag; +extern bool MainPanelButtonDown; +extern bool SpellSelectFlag; const Rectangle &GetMainPanel(); const Rectangle &GetLeftPanel(); const Rectangle &GetRightPanel(); bool IsLeftPanelOpen(); bool IsRightPanelOpen(); -extern std::optional pBtmBuff; -extern OptionalOwnedClxSpriteList pGBoxBuff; -extern Rectangle PanelButtonRect[8]; +extern std::optional BottomBuffer; +extern OptionalOwnedClxSpriteList GoldBoxBuffer; +extern Rectangle MainPanelButtonRect[8]; void CalculatePanelAreas(); bool IsChatAvailable(); @@ -82,8 +82,8 @@ inline bool CanPanelsCoverView() return GetScreenWidth() <= mainPanel.size.width && GetScreenHeight() <= SidePanelSize.height + mainPanel.size.height; } -void AddPanelString(std::string_view str); -void AddPanelString(std::string &&str); +void AddInfoBoxString(std::string_view str); +void AddInfoBoxString(std::string &&str); void DrawPanelBox(const Surface &out, SDL_Rect srcRect, Point targetPosition); Point GetPanelPosition(UiPanels panel, Point offset = { 0, 0 }); @@ -125,28 +125,28 @@ void DrawFlaskValues(const Surface &out, Point pos, int currValue, int maxValue) * * @see Player::UpdateHitPointPercentage() and Player::UpdateManaPercentage() */ -void control_update_life_mana(); +void UpdateLifeManaPercent(); -void InitControlPan(); -void DrawCtrlPan(const Surface &out); +void InitMainPanel(); +void DrawMainPanel(const Surface &out); /** * Draws the control panel buttons in their current state. If the button is in the default * state draw it from the panel cel(extract its sub-rect). Else draw it from the buttons cel. */ -void DrawCtrlBtns(const Surface &out); +void DrawMainPanelButtons(const Surface &out); /** * Clears panel button flags. */ -void ClearPanBtn(); +void ResetMainPanelButtons(); /** * Checks if the mouse cursor is within any of the panel buttons and flag it if so. */ -void DoPanBtn(); +void CheckMainPanelButton(); -void control_check_btn_press(); +void CheckMainPanelButtonDead(); void DoAutoMap(); void CycleAutomapType(); @@ -160,16 +160,16 @@ void CheckPanelInfo(); * Check if the mouse is within a control panel button that's flagged. * Takes appropriate action if so. */ -void CheckBtnUp(); +void CheckMainPanelButtonUp(); void FreeControlPan(); /** * Sets a string to be drawn in the info box and then draws it. */ void DrawInfoBox(const Surface &out); -void CheckLvlBtn(); -void ReleaseLvlBtn(); -void DrawLevelUpIcon(const Surface &out); +void CheckLevelButton(); +void CheckLevelButtonUp(); +void DrawLevelButton(const Surface &out); void CheckChrBtns(); void ReleaseChrBtns(bool addAllStatPoints); void DrawDurIcon(const Surface &out); @@ -177,19 +177,19 @@ void RedBack(const Surface &out); void DrawSpellBook(const Surface &out); void DrawGoldSplit(const Surface &out); void control_drop_gold(SDL_Keycode vkey); -void DrawTalkPan(const Surface &out); -bool control_check_talk_btn(); -void control_release_talk_btn(); -void control_type_message(); -void control_reset_talk(); -bool IsTalkActive(); +void DrawChatBox(const Surface &out); +bool CheckMuteButton(); +void CheckMuteButtonUp(); +void TypeChatMessage(); +void ResetChat(); +bool IsChatActive(); bool HandleTalkTextInputEvent(const SDL_Event &event); -bool control_presskeys(SDL_Keycode vkey); +bool CheckKeypress(SDL_Keycode vkey); void DiabloHotkeyMsg(uint32_t dwMsg); void OpenGoldDrop(int8_t invIndex, int max); void CloseGoldDrop(); int GetGoldDropMax(); bool HandleGoldDropTextInputEvent(const SDL_Event &event); -extern Rectangle CharButtonRect[4]; +extern Rectangle CharPanelButtonRect[4]; } // namespace devilution diff --git a/Source/controls/controller_motion.cpp b/Source/controls/controller_motion.cpp index b59344787b2..23363413c0b 100644 --- a/Source/controls/controller_motion.cpp +++ b/Source/controls/controller_motion.cpp @@ -92,7 +92,7 @@ bool IsPressedForMovement(ControllerButton button) return !PadMenuNavigatorActive && IsControllerButtonPressed(button) && !IsMovementOverriddenByPadmapper(button) - && !(spselflag && TriggersQuickSpellAction(button)); + && !(SpellSelectFlag && TriggersQuickSpellAction(button)); } void SetSimulatingMouseWithPadmapper(bool value) diff --git a/Source/controls/game_controls.cpp b/Source/controls/game_controls.cpp index 9538e1032ce..8799de89f4c 100644 --- a/Source/controls/game_controls.cpp +++ b/Source/controls/game_controls.cpp @@ -129,7 +129,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game return true; } if (VirtualGamepadState.primaryActionButton.isHeld && VirtualGamepadState.primaryActionButton.didStateChange) { - if (!inGameMenu && !QuestLogIsOpen && !sbookflag) { + if (!inGameMenu && !QuestLogIsOpen && !SpellbookFlag) { *action = GameAction(GameActionType_PRIMARY_ACTION); if (ControllerActionHeld == GameActionType_NONE) { ControllerActionHeld = GameActionType_PRIMARY_ACTION; @@ -142,7 +142,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game return true; } if (VirtualGamepadState.secondaryActionButton.isHeld && VirtualGamepadState.secondaryActionButton.didStateChange) { - if (!inGameMenu && !QuestLogIsOpen && !sbookflag) { + if (!inGameMenu && !QuestLogIsOpen && !SpellbookFlag) { *action = GameAction(GameActionType_SECONDARY_ACTION); if (ControllerActionHeld == GameActionType_NONE) ControllerActionHeld = GameActionType_SECONDARY_ACTION; @@ -150,7 +150,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game return true; } if (VirtualGamepadState.spellActionButton.isHeld && VirtualGamepadState.spellActionButton.didStateChange) { - if (!inGameMenu && !QuestLogIsOpen && !sbookflag) { + if (!inGameMenu && !QuestLogIsOpen && !SpellbookFlag) { *action = GameAction(GameActionType_CAST_SPELL); if (ControllerActionHeld == GameActionType_NONE) ControllerActionHeld = GameActionType_CAST_SPELL; @@ -158,25 +158,25 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game return true; } if (VirtualGamepadState.cancelButton.isHeld && VirtualGamepadState.cancelButton.didStateChange) { - if (inGameMenu || DoomFlag || spselflag) + if (inGameMenu || DoomFlag || SpellSelectFlag) *action = GameActionSendKey { SDLK_ESCAPE, false }; else if (invflag) *action = GameAction(GameActionType_TOGGLE_INVENTORY); - else if (sbookflag) + else if (SpellbookFlag) *action = GameAction(GameActionType_TOGGLE_SPELL_BOOK); else if (QuestLogIsOpen) *action = GameAction(GameActionType_TOGGLE_QUEST_LOG); - else if (chrflag) + else if (CharFlag) *action = GameAction(GameActionType_TOGGLE_CHARACTER_INFO); return true; } if (VirtualGamepadState.healthButton.isHeld && VirtualGamepadState.healthButton.didStateChange) { - if (!QuestLogIsOpen && !sbookflag && stextflag == TalkID::None) + if (!QuestLogIsOpen && !SpellbookFlag && stextflag == TalkID::None) *action = GameAction(GameActionType_USE_HEALTH_POTION); return true; } if (VirtualGamepadState.manaButton.isHeld && VirtualGamepadState.manaButton.didStateChange) { - if (!QuestLogIsOpen && !sbookflag && stextflag == TalkID::None) + if (!QuestLogIsOpen && !SpellbookFlag && stextflag == TalkID::None) *action = GameAction(GameActionType_USE_MANA_POTION); return true; } @@ -202,7 +202,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game translation = TranslateControllerButtonToMenuKey(ctrlEvent.button); else if (QuestLogIsOpen) translation = TranslateControllerButtonToQuestLogKey(ctrlEvent.button); - else if (sbookflag) + else if (SpellbookFlag) translation = TranslateControllerButtonToSpellbookKey(ctrlEvent.button); if (translation != SDLK_UNKNOWN) { @@ -233,7 +233,7 @@ void PressControllerButton(ControllerButton button) if (PadHotspellMenuActive) { auto quickSpellAction = [](size_t slot) { - if (spselflag) { + if (SpellSelectFlag) { SetSpeedSpell(slot); return; } diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 377496f0388..6bc065c21cd 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -68,7 +68,7 @@ bool InGameMenu() return stextflag != TalkID::None || HelpFlag || ChatLogFlag - || talkflag + || ChatFlag || qtextflag || gmenu_is_active() || PauseMode == 2 @@ -555,14 +555,14 @@ void AttrIncBtnSnap(AxisDirection dir) if (dir.y == AxisDirectionY_NONE) return; - if (chrbtnactive && MyPlayer->_pStatPts <= 0) + if (CharPanelButtonActive && MyPlayer->_pStatPts <= 0) return; // first, find our cursor location int slot = 0; Rectangle button; for (int i = 0; i < 4; i++) { - button = CharButtonRect[i]; + button = CharPanelButtonRect[i]; button.position = GetPanelPosition(UiPanels::Character, button.position); if (button.contains(MousePosition)) { slot = i; @@ -579,7 +579,7 @@ void AttrIncBtnSnap(AxisDirection dir) } // move cursor to our new location - button = CharButtonRect[slot]; + button = CharPanelButtonRect[slot]; button.position = GetPanelPosition(UiPanels::Character, button.position); SetCursorPos(button.Center()); } @@ -1054,7 +1054,7 @@ bool BlurInventory() CloseInventory(); if (pcurs > CURSOR_HAND) NewCursor(CURSOR_HAND); - if (chrflag) + if (CharFlag) FocusOnCharInfo(); return true; @@ -1242,11 +1242,11 @@ void SpellBookMove(AxisDirection dir) dir = repeater.Get(dir); if (dir.x == AxisDirectionX_LEFT) { - if (sbooktab > 0) - sbooktab--; + if (SpellbookTab > 0) + SpellbookTab--; } else if (dir.x == AxisDirectionX_RIGHT) { - if ((gbIsHellfire && sbooktab < 4) || (!gbIsHellfire && sbooktab < 3)) - sbooktab++; + if ((gbIsHellfire && SpellbookTab < 4) || (!gbIsHellfire && SpellbookTab < 3)) + SpellbookTab++; } } @@ -1335,13 +1335,13 @@ HandleLeftStickOrDPadFn GetLeftStickOrDPadGameUIHandler() if (invflag) { return &CheckInventoryMove; } - if (chrflag && MyPlayer->_pStatPts > 0) { + if (CharFlag && MyPlayer->_pStatPts > 0) { return &AttrIncBtnSnap; } - if (spselflag) { + if (SpellSelectFlag) { return &HotSpellMove; } - if (sbookflag) { + if (SpellbookFlag) { return &SpellBookMove; } if (QuestLogIsOpen) { @@ -1603,21 +1603,21 @@ void ProcessGameAction(const GameAction &action) break; case GameActionType_TOGGLE_QUICK_SPELL_MENU: if (!invflag || BlurInventory()) { - if (!spselflag) + if (!SpellSelectFlag) DoSpeedBook(); else - spselflag = false; + SpellSelectFlag = false; CloseCharPanel(); QuestLogIsOpen = false; - sbookflag = false; + SpellbookFlag = false; CloseGoldWithdraw(); CloseStash(); } break; case GameActionType_TOGGLE_CHARACTER_INFO: ToggleCharPanel(); - if (chrflag) { - spselflag = false; + if (CharFlag) { + SpellSelectFlag = false; if (pcurs == CURSOR_DISARM) NewCursor(CURSOR_HAND); FocusOnCharInfo(); @@ -1629,7 +1629,7 @@ void ProcessGameAction(const GameAction &action) CloseCharPanel(); CloseGoldWithdraw(); CloseStash(); - spselflag = false; + SpellSelectFlag = false; } else { QuestLogIsOpen = false; } @@ -1638,8 +1638,8 @@ void ProcessGameAction(const GameAction &action) if (invflag) { BlurInventory(); } else { - sbookflag = false; - spselflag = false; + SpellbookFlag = false; + SpellSelectFlag = false; invflag = true; if (pcurs == CURSOR_DISARM) NewCursor(CURSOR_HAND); @@ -1649,8 +1649,8 @@ void ProcessGameAction(const GameAction &action) case GameActionType_TOGGLE_SPELL_BOOK: if (BlurInventory()) { CloseInventory(); - spselflag = false; - sbookflag = !sbookflag; + SpellSelectFlag = false; + SpellbookFlag = !SpellbookFlag; } break; } @@ -1888,14 +1888,14 @@ void PerformPrimaryAction() return; } - if (spselflag) { + if (SpellSelectFlag) { SetSpell(); return; } - if (chrflag && !chrbtnactive && MyPlayer->_pStatPts > 0) { + if (CharFlag && !CharPanelButtonActive && MyPlayer->_pStatPts > 0) { CheckChrBtns(); - if (chrbtnactive) + if (CharPanelButtonActive) ReleaseChrBtns(false); return; } @@ -1969,7 +1969,7 @@ bool TryDropItem() void PerformSpellAction() { - if (InGameMenu() || QuestLogIsOpen || sbookflag) + if (InGameMenu() || QuestLogIsOpen || SpellbookFlag) return; if (invflag) { @@ -1994,7 +1994,7 @@ void PerformSpellAction() if (pcurs > CURSOR_HAND) NewCursor(CURSOR_HAND); - if (spselflag) { + if (SpellSelectFlag) { SetSpell(); return; } diff --git a/Source/controls/touch/event_handlers.cpp b/Source/controls/touch/event_handlers.cpp index 9b688c70964..a08f656ac53 100644 --- a/Source/controls/touch/event_handlers.cpp +++ b/Source/controls/touch/event_handlers.cpp @@ -36,10 +36,10 @@ void SimulateMouseMovement(const SDL_Event &event) bool isInLeftPanel = GetLeftPanel().contains(position); bool isInRightPanel = GetRightPanel().contains(position); if (IsStashOpen) { - if (!spselflag && !isInMainPanel && !isInLeftPanel && !isInRightPanel) + if (!SpellSelectFlag && !isInMainPanel && !isInLeftPanel && !isInRightPanel) return; } else if (invflag) { - if (!spselflag && !isInMainPanel && !isInRightPanel) + if (!SpellSelectFlag && !isInMainPanel && !isInRightPanel) return; } @@ -72,7 +72,7 @@ bool HandleStoreInteraction(const SDL_Event &event) void HandleSpellBookInteraction(const SDL_Event &event) { - if (!sbookflag) + if (!SpellbookFlag) return; if (event.type == SDL_FINGERUP) @@ -81,7 +81,7 @@ void HandleSpellBookInteraction(const SDL_Event &event) bool HandleSpeedBookInteraction(const SDL_Event &event) { - if (!spselflag) + if (!SpellSelectFlag) return false; if (event.type == SDL_FINGERUP) SetSpell(); @@ -93,27 +93,27 @@ void HandleBottomPanelInteraction(const SDL_Event &event) if (!gbRunGame || !MyPlayer->HoldItem.isEmpty()) return; - ClearPanBtn(); + ResetMainPanelButtons(); if (event.type != SDL_FINGERUP) { - spselflag = true; - DoPanBtn(); - spselflag = false; + SpellSelectFlag = true; + CheckMainPanelButton(); + SpellSelectFlag = false; } else { - DoPanBtn(); - if (panbtndown) - CheckBtnUp(); + CheckMainPanelButton(); + if (MainPanelButtonDown) + CheckMainPanelButtonUp(); } } void HandleCharacterPanelInteraction(const SDL_Event &event) { - if (!chrflag) + if (!CharFlag) return; if (event.type == SDL_FINGERDOWN) CheckChrBtns(); - else if (event.type == SDL_FINGERUP && chrbtnactive) + else if (event.type == SDL_FINGERUP && CharPanelButtonActive) ReleaseChrBtns(false); } diff --git a/Source/controls/touch/gamepad.cpp b/Source/controls/touch/gamepad.cpp index 06f88d7ef1e..f512dae56c5 100644 --- a/Source/controls/touch/gamepad.cpp +++ b/Source/controls/touch/gamepad.cpp @@ -166,14 +166,14 @@ void InitializeVirtualGamepad() healthButtonArea.position.x = directionPad.area.position.x - (padButtonSize + padButtonSpacing) / 2; healthButtonArea.position.y = directionPad.area.position.y - (directionPadSize + padButtonSize + padButtonSpacing) / 2; healthButtonArea.radius = padButtonSize / 2; - healthButton.isUsable = []() { return !chrflag && !QuestLogIsOpen; }; + healthButton.isUsable = []() { return !CharFlag && !QuestLogIsOpen; }; VirtualPadButton &manaButton = VirtualGamepadState.manaButton; Circle &manaButtonArea = manaButton.area; manaButtonArea.position.x = directionPad.area.position.x + (padButtonSize + padButtonSpacing) / 2; manaButtonArea.position.y = directionPad.area.position.y - (directionPadSize + padButtonSize + padButtonSpacing) / 2; manaButtonArea.radius = padButtonSize / 2; - manaButton.isUsable = []() { return !chrflag && !QuestLogIsOpen; }; + manaButton.isUsable = []() { return !CharFlag && !QuestLogIsOpen; }; } void ActivateVirtualGamepad() diff --git a/Source/controls/touch/renderers.cpp b/Source/controls/touch/renderers.cpp index c8611fb4749..24a87cb3c20 100644 --- a/Source/controls/touch/renderers.cpp +++ b/Source/controls/touch/renderers.cpp @@ -166,7 +166,7 @@ bool InteractsWithCharButton(Point point) if (myPlayer.GetBaseAttributeValue(attribute) >= myPlayer.GetMaximumAttributeValue(attribute)) continue; auto buttonId = static_cast(attribute); - Rectangle button = CharButtonRect[buttonId]; + Rectangle button = CharPanelButtonRect[buttonId]; button.position = GetPanelPosition(UiPanels::Character, button.position); if (button.contains(point)) { return true; @@ -419,7 +419,7 @@ VirtualGamepadButtonType PrimaryActionButtonRenderer::GetButtonType() // NEED: Confirm surface if (qtextflag) return GetTalkButtonType(virtualPadButton->isHeld); - if (chrflag && InteractsWithCharButton(MousePosition)) + if (CharFlag && InteractsWithCharButton(MousePosition)) return GetApplyButtonType(virtualPadButton->isHeld); if (invflag) return GetInventoryButtonType(); @@ -461,7 +461,7 @@ VirtualGamepadButtonType SecondaryActionButtonRenderer::GetButtonType() if (pcursmissile != nullptr || pcurstrig != -1 || pcursquest != Q_INVALID) { return GetStairsButtonType(virtualPadButton->isHeld); } - if (InGameMenu() || QuestLogIsOpen || sbookflag) + if (InGameMenu() || QuestLogIsOpen || SpellbookFlag) return GetBlankButtonType(virtualPadButton->isHeld); if (ObjectUnderCursor != nullptr) return GetObjectButtonType(virtualPadButton->isHeld); @@ -493,7 +493,7 @@ VirtualGamepadButtonType SpellActionButtonRenderer::GetButtonType() return GetEquipButtonType(virtualPadButton->isHeld); } - if (!invflag && !InGameMenu() && !QuestLogIsOpen && !sbookflag) + if (!invflag && !InGameMenu() && !QuestLogIsOpen && !SpellbookFlag) return GetCastButtonType(virtualPadButton->isHeld); return GetBlankButtonType(virtualPadButton->isHeld); } @@ -502,7 +502,7 @@ VirtualGamepadButtonType CancelButtonRenderer::GetButtonType() { if (InGameMenu()) return GetBackButtonType(virtualPadButton->isHeld); - if (DoomFlag || invflag || sbookflag || QuestLogIsOpen || chrflag) + if (DoomFlag || invflag || SpellbookFlag || QuestLogIsOpen || CharFlag) return GetBackButtonType(virtualPadButton->isHeld); return GetBlankButtonType(virtualPadButton->isHeld); } diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 5ef35b2e7aa..14aa831306e 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -606,7 +606,7 @@ void CheckTown() if (EntranceBoundaryContains(missile.position.tile, cursPosition)) { trigflag = true; InfoString = _("Town Portal"); - AddPanelString(fmt::format(fmt::runtime(_("from {:s}")), Players[missile._misource]._pName)); + AddInfoBoxString(fmt::format(fmt::runtime(_("from {:s}")), Players[missile._misource]._pName)); cursPosition = missile.position.tile; } } @@ -620,7 +620,7 @@ void CheckRportal() if (EntranceBoundaryContains(missile.position.tile, cursPosition)) { trigflag = true; InfoString = _("Portal to"); - AddPanelString(!setlevel ? _("The Unholy Altar") : _("level 15")); + AddInfoBoxString(!setlevel ? _("The Unholy Altar") : _("level 15")); cursPosition = missile.position.tile; } } @@ -752,13 +752,13 @@ void CheckCursMove() pcursstashitem = StashStruct::EmptyCell; PlayerUnderCursor = nullptr; ShowUniqueItemInfoBox = false; - panelflag = false; + MainPanelFlag = false; trigflag = false; if (myPlayer._pInvincible) { return; } - if (!myPlayer.HoldItem.isEmpty() || spselflag) { + if (!myPlayer.HoldItem.isEmpty() || SpellSelectFlag) { cursPosition = { mx, my }; return; } @@ -776,7 +776,7 @@ void CheckCursMove() if (IsStashOpen && GetLeftPanel().contains(MousePosition)) { pcursstashitem = CheckStashHLight(MousePosition); } - if (sbookflag && GetRightPanel().contains(MousePosition)) { + if (SpellbookFlag && GetRightPanel().contains(MousePosition)) { return; } if (IsLeftPanelOpen() && GetLeftPanel().contains(MousePosition)) { diff --git a/Source/diablo.cpp b/Source/diablo.cpp index b39ebcffd94..8e483b27afb 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -329,14 +329,14 @@ void LeftMouseDown(uint16_t modState) if (gmenu_left_mouse(true)) return; - if (control_check_talk_btn()) + if (CheckMuteButton()) return; if (sgnTimeoutCurs != CURSOR_NONE) return; if (MyPlayerIsDead) { - control_check_btn_press(); + CheckMainPanelButtonDead(); return; } @@ -348,7 +348,7 @@ void LeftMouseDown(uint16_t modState) return; } - if (spselflag) { + if (SpellSelectFlag) { SetSpell(); return; } @@ -368,16 +368,16 @@ void LeftMouseDown(uint16_t modState) } else if (qtextflag) { qtextflag = false; stream_stop(); - } else if (chrflag && GetLeftPanel().contains(MousePosition)) { + } else if (CharFlag && GetLeftPanel().contains(MousePosition)) { CheckChrBtns(); } else if (invflag && GetRightPanel().contains(MousePosition)) { - if (!dropGoldFlag) + if (!DropGoldFlag) CheckInvItem(isShiftHeld, isCtrlHeld); } else if (IsStashOpen && GetLeftPanel().contains(MousePosition)) { if (!IsWithdrawGoldOpen) CheckStashItem(MousePosition, isShiftHeld, isCtrlHeld); CheckStashButtonPress(MousePosition); - } else if (sbookflag && GetRightPanel().contains(MousePosition)) { + } else if (SpellbookFlag && GetRightPanel().contains(MousePosition)) { CheckSBook(); } else if (!MyPlayer->HoldItem.isEmpty()) { if (!TryOpenDungeonWithMouse()) { @@ -389,15 +389,15 @@ void LeftMouseDown(uint16_t modState) } } } else { - CheckLvlBtn(); - if (!lvlbtndown) + CheckLevelButton(); + if (!LevelButtonDown) LeftMouseCmd(isShiftHeld); } } } else { - if (!talkflag && !dropGoldFlag && !IsWithdrawGoldOpen && !gmenu_is_active()) + if (!ChatFlag && !DropGoldFlag && !IsWithdrawGoldOpen && !gmenu_is_active()) CheckInvScrn(isShiftHeld, isCtrlHeld); - DoPanBtn(); + CheckMainPanelButton(); CheckStashButtonPress(MousePosition); if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM) NewCursor(CURSOR_HAND); @@ -407,16 +407,16 @@ void LeftMouseDown(uint16_t modState) void LeftMouseUp(uint16_t modState) { gmenu_left_mouse(false); - control_release_talk_btn(); - if (panbtndown) - CheckBtnUp(); + CheckMuteButtonUp(); + if (MainPanelButtonDown) + CheckMainPanelButtonUp(); CheckStashButtonRelease(MousePosition); - if (chrbtnactive) { + if (CharPanelButtonActive) { const bool isShiftHeld = (modState & KMOD_SHIFT) != 0; ReleaseChrBtns(isShiftHeld); } - if (lvlbtndown) - ReleaseLvlBtn(); + if (LevelButtonDown) + CheckLevelButtonUp(); if (stextflag != TalkID::None) ReleaseStoreBtn(); } @@ -441,11 +441,11 @@ void RightMouseDown(bool isShiftHeld) } if (stextflag != TalkID::None) return; - if (spselflag) { + if (SpellSelectFlag) { SetSpell(); return; } - if (sbookflag && GetRightPanel().contains(MousePosition)) + if (SpellbookFlag && GetRightPanel().contains(MousePosition)) return; if (TryIconCurs()) return; @@ -479,7 +479,7 @@ void ClosePanels() } CloseInventory(); CloseCharPanel(); - sbookflag = false; + SpellbookFlag = false; QuestLogIsOpen = false; } @@ -490,7 +490,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) if (vkey == SDLK_UNKNOWN) return; - if (gmenu_presskeys(vkey) || control_presskeys(vkey)) { + if (gmenu_presskeys(vkey) || CheckKeypress(vkey)) { return; } @@ -504,7 +504,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen()); SaveOptions(); } else { - control_type_message(); + TypeChatMessage(); } } if (vkey != SDLK_ESCAPE) { @@ -519,7 +519,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) return; } - if (dropGoldFlag) { + if (DropGoldFlag) { control_drop_gold(vkey); return; } @@ -581,7 +581,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) } else if (QuestLogIsOpen) { QuestlogEnter(); } else { - control_type_message(); + TypeChatMessage(); } return; case SDLK_UP: @@ -629,11 +629,11 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) } return; case SDLK_LEFT: - if (AutomapActive && !talkflag) + if (AutomapActive && !ChatFlag) AutomapLeft(); return; case SDLK_RIGHT: - if (AutomapActive && !talkflag) + if (AutomapActive && !ChatFlag) AutomapRight(); return; default: @@ -718,10 +718,10 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState) } #endif - if (IsTalkActive() && HandleTalkTextInputEvent(event)) { + if (IsChatActive() && HandleTalkTextInputEvent(event)) { return; } - if (dropGoldFlag && HandleGoldDropTextInputEvent(event)) { + if (DropGoldFlag && HandleGoldDropTextInputEvent(event)) { return; } if (IsWithdrawGoldOpen && HandleGoldWithdrawTextInputEvent(event)) { @@ -1470,8 +1470,8 @@ void TimeoutCursor(bool bTimeout) sgnTimeoutCurs = pcurs; multi_net_ping(); InfoString = StringOrView {}; - AddPanelString(_("-- Network timeout --")); - AddPanelString(_("-- Waiting for players --")); + AddInfoBoxString(_("-- Network timeout --")); + AddInfoBoxString(_("-- Waiting for players --")); NewCursor(CURSOR_HOURGLASS); RedrawEverything(); } @@ -1494,14 +1494,14 @@ void HelpKeyPressed() HelpFlag = false; } else if (stextflag != TalkID::None) { InfoString = StringOrView {}; - AddPanelString(_("No help available")); /// BUGFIX: message isn't displayed - AddPanelString(_("while in stores")); + AddInfoBoxString(_("No help available")); /// BUGFIX: message isn't displayed + AddInfoBoxString(_("while in stores")); LastMouseButtonAction = MouseActionType::None; } else { CloseInventory(); CloseCharPanel(); - sbookflag = false; - spselflag = false; + SpellbookFlag = false; + SpellSelectFlag = false; if (qtextflag && leveltype == DTYPE_TOWN) { qtextflag = false; stream_stop(); @@ -1524,13 +1524,13 @@ void InventoryKeyPressed() if (MousePosition.x < 480 && MousePosition.y < GetMainPanel().position.y) { SetCursorPos(MousePosition + Displacement { 160, 0 }); } - } else if (!sbookflag) { // We opened the inventory + } else if (!SpellbookFlag) { // We opened the inventory if (MousePosition.x > 160 && MousePosition.y < GetMainPanel().position.y) { SetCursorPos(MousePosition - Displacement { 160, 0 }); } } } - sbookflag = false; + SpellbookFlag = false; CloseGoldWithdraw(); CloseStash(); } @@ -1540,7 +1540,7 @@ void CharacterSheetKeyPressed() if (stextflag != TalkID::None) return; if (!IsRightPanelOpen() && CanPanelsCoverView()) { - if (chrflag) { // We are closing the character sheet + if (CharFlag) { // We are closing the character sheet if (MousePosition.x > 160 && MousePosition.y < GetMainPanel().position.y) { SetCursorPos(MousePosition - Displacement { 160, 0 }); } @@ -1567,7 +1567,7 @@ void QuestLogKeyPressed() if (MousePosition.x > 160 && MousePosition.y < GetMainPanel().position.y) { SetCursorPos(MousePosition - Displacement { 160, 0 }); } - } else if (!chrflag) { // We opened the character quest log + } else if (!CharFlag) { // We opened the character quest log if (MousePosition.x < 480 && MousePosition.y < GetMainPanel().position.y) { SetCursorPos(MousePosition + Displacement { 160, 0 }); } @@ -1585,11 +1585,11 @@ void DisplaySpellsKeyPressed() CloseCharPanel(); QuestLogIsOpen = false; CloseInventory(); - sbookflag = false; - if (!spselflag) { + SpellbookFlag = false; + if (!SpellSelectFlag) { DoSpeedBook(); } else { - spselflag = false; + SpellSelectFlag = false; } LastMouseButtonAction = MouseActionType::None; } @@ -1598,9 +1598,9 @@ void SpellBookKeyPressed() { if (stextflag != TalkID::None) return; - sbookflag = !sbookflag; + SpellbookFlag = !SpellbookFlag; if (!IsLeftPanelOpen() && CanPanelsCoverView()) { - if (!sbookflag) { // We closed the inventory + if (!SpellbookFlag) { // We closed the inventory if (MousePosition.x < 480 && MousePosition.y < GetMainPanel().position.y) { SetCursorPos(MousePosition + Displacement { 160, 0 }); } @@ -1658,8 +1658,8 @@ bool CanPlayerTakeAction() bool CanAutomapBeToggledOff() { // check if every window is closed - if yes, automap can be toggled off - if (!QuestLogIsOpen && !IsWithdrawGoldOpen && !IsStashOpen && !chrflag - && !sbookflag && !invflag && !isGameMenuOpen && !qtextflag && !spselflag + if (!QuestLogIsOpen && !IsWithdrawGoldOpen && !IsStashOpen && !CharFlag + && !SpellbookFlag && !invflag && !isGameMenuOpen && !qtextflag && !SpellSelectFlag && !ChatLogFlag && !HelpFlag) return true; @@ -1693,7 +1693,7 @@ void InitKeymapActions() N_("Hotkey for skill or spell."), i < 4 ? static_cast(SDLK_F5) + i : static_cast(SDLK_UNKNOWN), [i]() { - if (spselflag) { + if (SpellSelectFlag) { SetSpeedSpell(i); return; } @@ -1864,7 +1864,7 @@ void InitKeymapActions() ClosePanels(); HelpFlag = false; ChatLogFlag = false; - spselflag = false; + SpellSelectFlag = false; if (qtextflag && leveltype == DTYPE_TOWN) { qtextflag = false; stream_stop(); @@ -2004,7 +2004,7 @@ void InitPadmapActions() N_("Hotkey for skill or spell."), ControllerButton_NONE, [i]() { - if (spselflag) { + if (SpellSelectFlag) { SetSpeedSpell(i); return; } @@ -2074,20 +2074,20 @@ void InitPadmapActions() } GameAction action; - if (spselflag) + if (SpellSelectFlag) action = GameAction(GameActionType_TOGGLE_QUICK_SPELL_MENU); else if (invflag) action = GameAction(GameActionType_TOGGLE_INVENTORY); - else if (sbookflag) + else if (SpellbookFlag) action = GameAction(GameActionType_TOGGLE_SPELL_BOOK); else if (QuestLogIsOpen) action = GameAction(GameActionType_TOGGLE_QUEST_LOG); - else if (chrflag) + else if (CharFlag) action = GameAction(GameActionType_TOGGLE_CHARACTER_INFO); ProcessGameAction(action); }, nullptr, - [] { return DoomFlag || spselflag || invflag || sbookflag || QuestLogIsOpen || chrflag; }); + [] { return DoomFlag || SpellSelectFlag || invflag || SpellbookFlag || QuestLogIsOpen || CharFlag; }); sgOptions.Padmapper.AddAction( "MoveUp", N_("Move up"), @@ -2355,7 +2355,7 @@ void InitPadmapActions() ClosePanels(); HelpFlag = false; ChatLogFlag = false; - spselflag = false; + SpellSelectFlag = false; if (qtextflag && leveltype == DTYPE_TOWN) { qtextflag = false; stream_stop(); @@ -2788,12 +2788,12 @@ bool PressEscKey() rv = true; } - if (talkflag) { - control_reset_talk(); + if (ChatFlag) { + ResetChat(); rv = true; } - if (dropGoldFlag) { + if (DropGoldFlag) { control_drop_gold(SDLK_ESCAPE); rv = true; } @@ -2803,8 +2803,8 @@ bool PressEscKey() rv = true; } - if (spselflag) { - spselflag = false; + if (SpellSelectFlag) { + SpellSelectFlag = false; rv = true; } @@ -3090,7 +3090,7 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir) IncProgress(); if (firstflag) { - InitControlPan(); + InitMainPanel(); } IncProgress(); UpdateMonsterLights(); diff --git a/Source/engine/render/scrollrt.cpp b/Source/engine/render/scrollrt.cpp index 46c9716fabb..400d54f4dd5 100644 --- a/Source/engine/render/scrollrt.cpp +++ b/Source/engine/render/scrollrt.cpp @@ -207,7 +207,7 @@ bool ShouldShowCursor() return true; if (invflag) return true; - if (chrflag && MyPlayer->_pStatPts > 0) + if (CharFlag && MyPlayer->_pStatPts > 0) return true; return false; @@ -1201,30 +1201,30 @@ void DrawView(const Surface &out, Point startPosition) DrawSText(out); if (invflag) { DrawInv(out); - } else if (sbookflag) { + } else if (SpellbookFlag) { DrawSpellBook(out); } DrawDurIcon(out); - if (chrflag) { + if (CharFlag) { DrawChr(out); } else if (QuestLogIsOpen) { DrawQuestLog(out); } else if (IsStashOpen) { DrawStash(out); } - DrawLevelUpIcon(out); + DrawLevelButton(out); if (ShowUniqueItemInfoBox) { DrawUniqueInfo(out); } if (qtextflag) { DrawQText(out); } - if (spselflag) { + if (SpellSelectFlag) { DrawSpellList(out); } - if (dropGoldFlag) { + if (DropGoldFlag) { DrawGoldSplit(out); } DrawGoldWithdraw(out); @@ -1248,7 +1248,7 @@ void DrawView(const Surface &out, Point startPosition) gmenu_draw(out); doom_draw(out); DrawInfoBox(out); - control_update_life_mana(); // Update life/mana totals before rendering any portion of the flask. + UpdateLifeManaPercent(); // Update life/mana totals before rendering any portion of the flask. DrawLifeFlaskUpper(out); DrawManaFlaskUpper(out); } @@ -1328,7 +1328,7 @@ void DrawMain(int dwHgt, bool drawDesc, bool drawHp, bool drawMana, bool drawSba DoBlitScreen({ mainPanelPosition + Displacement { 204, 5 }, { 232, 28 } }); } if (drawDesc) { - if (talkflag) { + if (ChatFlag) { // When chat input is displayed, the belt is hidden and the chat moves up. DoBlitScreen({ mainPanelPosition + Displacement { 171, 6 }, { 298, 116 } }); } else { @@ -1632,7 +1632,7 @@ void DrawAndBlit() bool drawMana = IsRedrawComponent(PanelDrawComponent::Mana); bool drawControlButtons = IsRedrawComponent(PanelDrawComponent::ControlButtons); bool drawBelt = IsRedrawComponent(PanelDrawComponent::Belt); - bool drawChatInput = talkflag; + bool drawChatInput = ChatFlag; bool drawInfoBox = false; bool drawCtrlPan = false; @@ -1659,7 +1659,7 @@ void DrawAndBlit() DrawView(out, ViewPosition); if (drawCtrlPan) { - DrawCtrlPan(out); + DrawMainPanel(out); } if (drawHealth) { DrawLifeFlaskLower(out); @@ -1670,13 +1670,13 @@ void DrawAndBlit() DrawSpell(out); } if (drawControlButtons) { - DrawCtrlBtns(out); + DrawMainPanelButtons(out); } if (drawBelt) { DrawInvBelt(out); } if (drawChatInput) { - DrawTalkPan(out); + DrawChatBox(out); } DrawXPBar(out); if (*sgOptions.Gameplay.showHealthValues) diff --git a/Source/inv.cpp b/Source/inv.cpp index 18b13687b3a..89a6f53aa1a 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -938,8 +938,8 @@ void StartGoldDrop() ? myPlayer.InvList[invIndex - INVITEM_INV_FIRST]._ivalue : myPlayer.SpdList[invIndex - INVITEM_BELT_FIRST]._ivalue; - if (talkflag) - control_reset_talk(); + if (ChatFlag) + ResetChat(); Point start = GetPanelPosition(UiPanels::Inventory, { 67, 128 }); SDL_Rect rect = MakeSdlRect(start.x, start.y, 180, 20); @@ -1124,7 +1124,7 @@ void DrawInv(const Surface &out) void DrawInvBelt(const Surface &out) { - if (talkflag) { + if (ChatFlag) { return; } @@ -2019,7 +2019,7 @@ bool UseInvItem(int cii) c = cii - INVITEM_INV_FIRST; item = &player.InvList[c]; } else { - if (talkflag) + if (ChatFlag) return true; c = cii - INVITEM_BELT_FIRST; diff --git a/Source/items.cpp b/Source/items.cpp index c3c0b66f6e8..84b1c8c76ed 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1636,90 +1636,90 @@ void PrintItemOil(char iDidx) { switch (iDidx) { case IMISC_OILACC: - AddPanelString(_("increases a weapon's")); - AddPanelString(_("chance to hit")); + AddInfoBoxString(_("increases a weapon's")); + AddInfoBoxString(_("chance to hit")); break; case IMISC_OILMAST: - AddPanelString(_("greatly increases a")); - AddPanelString(_("weapon's chance to hit")); + AddInfoBoxString(_("greatly increases a")); + AddInfoBoxString(_("weapon's chance to hit")); break; case IMISC_OILSHARP: - AddPanelString(_("increases a weapon's")); - AddPanelString(_("damage potential")); + AddInfoBoxString(_("increases a weapon's")); + AddInfoBoxString(_("damage potential")); break; case IMISC_OILDEATH: - AddPanelString(_("greatly increases a weapon's")); - AddPanelString(_("damage potential - not bows")); + AddInfoBoxString(_("greatly increases a weapon's")); + AddInfoBoxString(_("damage potential - not bows")); break; case IMISC_OILSKILL: - AddPanelString(_("reduces attributes needed")); - AddPanelString(_("to use armor or weapons")); + AddInfoBoxString(_("reduces attributes needed")); + AddInfoBoxString(_("to use armor or weapons")); break; case IMISC_OILBSMTH: - AddPanelString(/*xgettext:no-c-format*/ _("restores 20% of an")); - AddPanelString(_("item's durability")); + AddInfoBoxString(/*xgettext:no-c-format*/ _("restores 20% of an")); + AddInfoBoxString(_("item's durability")); break; case IMISC_OILFORT: - AddPanelString(_("increases an item's")); - AddPanelString(_("current and max durability")); + AddInfoBoxString(_("increases an item's")); + AddInfoBoxString(_("current and max durability")); break; case IMISC_OILPERM: - AddPanelString(_("makes an item indestructible")); + AddInfoBoxString(_("makes an item indestructible")); break; case IMISC_OILHARD: - AddPanelString(_("increases the armor class")); - AddPanelString(_("of armor and shields")); + AddInfoBoxString(_("increases the armor class")); + AddInfoBoxString(_("of armor and shields")); break; case IMISC_OILIMP: - AddPanelString(_("greatly increases the armor")); - AddPanelString(_("class of armor and shields")); + AddInfoBoxString(_("greatly increases the armor")); + AddInfoBoxString(_("class of armor and shields")); break; case IMISC_RUNEF: - AddPanelString(_("sets fire trap")); + AddInfoBoxString(_("sets fire trap")); break; case IMISC_RUNEL: case IMISC_GR_RUNEL: - AddPanelString(_("sets lightning trap")); + AddInfoBoxString(_("sets lightning trap")); break; case IMISC_GR_RUNEF: - AddPanelString(_("sets fire trap")); + AddInfoBoxString(_("sets fire trap")); break; case IMISC_RUNES: - AddPanelString(_("sets petrification trap")); + AddInfoBoxString(_("sets petrification trap")); break; case IMISC_FULLHEAL: - AddPanelString(_("restore all life")); + AddInfoBoxString(_("restore all life")); break; case IMISC_HEAL: - AddPanelString(_("restore some life")); + AddInfoBoxString(_("restore some life")); break; case IMISC_MANA: - AddPanelString(_("restore some mana")); + AddInfoBoxString(_("restore some mana")); break; case IMISC_FULLMANA: - AddPanelString(_("restore all mana")); + AddInfoBoxString(_("restore all mana")); break; case IMISC_ELIXSTR: - AddPanelString(_("increase strength")); + AddInfoBoxString(_("increase strength")); break; case IMISC_ELIXMAG: - AddPanelString(_("increase magic")); + AddInfoBoxString(_("increase magic")); break; case IMISC_ELIXDEX: - AddPanelString(_("increase dexterity")); + AddInfoBoxString(_("increase dexterity")); break; case IMISC_ELIXVIT: - AddPanelString(_("increase vitality")); + AddInfoBoxString(_("increase vitality")); break; case IMISC_REJUV: - AddPanelString(_("restore some life and mana")); + AddInfoBoxString(_("restore some life and mana")); break; case IMISC_FULLREJUV: - AddPanelString(_("restore all life and mana")); + AddInfoBoxString(_("restore all life and mana")); break; case IMISC_ARENAPOT: - AddPanelString(_("restore all life and mana")); - AddPanelString(_("(works only in arenas)")); + AddInfoBoxString(_("restore all life and mana")); + AddInfoBoxString(_("(works only in arenas)")); break; } } @@ -1754,32 +1754,32 @@ Point DrawUniqueInfoWindow(const Surface &out) void printItemMiscKBM(const Item &item, const bool isOil, const bool isCastOnTarget) { if (item._iMiscId == IMISC_MAPOFDOOM) { - AddPanelString(_("Right-click to view")); + AddInfoBoxString(_("Right-click to view")); } else if (isOil) { PrintItemOil(item._iMiscId); - AddPanelString(_("Right-click to use")); + AddInfoBoxString(_("Right-click to use")); } else if (isCastOnTarget) { - AddPanelString(_("Right-click to read, then\nleft-click to target")); + AddInfoBoxString(_("Right-click to read, then\nleft-click to target")); } else if (IsAnyOf(item._iMiscId, IMISC_BOOK, IMISC_NOTE, IMISC_SCROLL, IMISC_SCROLLT)) { - AddPanelString(_("Right-click to read")); + AddInfoBoxString(_("Right-click to read")); } } void printItemMiscGenericGamepad(const Item &item, const bool isOil, bool isCastOnTarget) { if (item._iMiscId == IMISC_MAPOFDOOM) { - AddPanelString(_("Activate to view")); + AddInfoBoxString(_("Activate to view")); } else if (isOil) { PrintItemOil(item._iMiscId); if (!invflag) { - AddPanelString(_("Open inventory to use")); + AddInfoBoxString(_("Open inventory to use")); } else { - AddPanelString(_("Activate to use")); + AddInfoBoxString(_("Activate to use")); } } else if (isCastOnTarget) { - AddPanelString(_("Select from spell book, then\ncast spell to read")); + AddInfoBoxString(_("Select from spell book, then\ncast spell to read")); } else if (IsAnyOf(item._iMiscId, IMISC_BOOK, IMISC_NOTE, IMISC_SCROLL, IMISC_SCROLLT)) { - AddPanelString(_("Activate to read")); + AddInfoBoxString(_("Activate to read")); } } @@ -1793,29 +1793,29 @@ void printItemMiscGamepad(const Item &item, bool isOil, bool isCastOnTarget) const std::string_view castButton = ToString(ControllerButton_BUTTON_X); if (item._iMiscId == IMISC_MAPOFDOOM) { - AddPanelString(fmt::format(fmt::runtime(_("{} to view")), activateButton)); + AddInfoBoxString(fmt::format(fmt::runtime(_("{} to view")), activateButton)); } else if (isOil) { PrintItemOil(item._iMiscId); if (!invflag) { - AddPanelString(_("Open inventory to use")); + AddInfoBoxString(_("Open inventory to use")); } else { - AddPanelString(fmt::format(fmt::runtime(_("{} to use")), activateButton)); + AddInfoBoxString(fmt::format(fmt::runtime(_("{} to use")), activateButton)); } } else if (isCastOnTarget) { - AddPanelString(fmt::format(fmt::runtime(_("Select from spell book,\nthen {} to read")), castButton)); + AddInfoBoxString(fmt::format(fmt::runtime(_("Select from spell book,\nthen {} to read")), castButton)); } else if (IsAnyOf(item._iMiscId, IMISC_BOOK, IMISC_NOTE, IMISC_SCROLL, IMISC_SCROLLT)) { - AddPanelString(fmt::format(fmt::runtime(_("{} to read")), activateButton)); + AddInfoBoxString(fmt::format(fmt::runtime(_("{} to read")), activateButton)); } } void PrintItemMisc(const Item &item) { if (item._iMiscId == IMISC_EAR) { - AddPanelString(fmt::format(fmt::runtime(pgettext("player", "Level: {:d}")), item._ivalue)); + AddInfoBoxString(fmt::format(fmt::runtime(pgettext("player", "Level: {:d}")), item._ivalue)); return; } if (item._iMiscId == IMISC_AURIC) { - AddPanelString(_("Doubles gold capacity")); + AddInfoBoxString(_("Doubles gold capacity")); return; } const bool isOil = (item._iMiscId >= IMISC_USEFIRST && item._iMiscId <= IMISC_USELAST) @@ -1854,7 +1854,7 @@ void PrintItemInfo(const Item &item) text.append(fmt::format(fmt::runtime(_(" {:d} Mag")), mag)); if (dex != 0) text.append(fmt::format(fmt::runtime(_(" {:d} Dex")), dex)); - AddPanelString(text); + AddInfoBoxString(text); } } @@ -4098,33 +4098,33 @@ void PrintItemDetails(const Item &item) if (item._iClass == ICLASS_WEAPON) { if (item._iMinDam == item._iMaxDam) { if (item._iMaxDur == DUR_INDESTRUCTIBLE) - AddPanelString(fmt::format(fmt::runtime(_("damage: {:d} Indestructible")), item._iMinDam)); + AddInfoBoxString(fmt::format(fmt::runtime(_("damage: {:d} Indestructible")), item._iMinDam)); else - AddPanelString(fmt::format(fmt::runtime(_(/* TRANSLATORS: Dur: is durability */ "damage: {:d} Dur: {:d}/{:d}")), item._iMinDam, item._iDurability, item._iMaxDur)); + AddInfoBoxString(fmt::format(fmt::runtime(_(/* TRANSLATORS: Dur: is durability */ "damage: {:d} Dur: {:d}/{:d}")), item._iMinDam, item._iDurability, item._iMaxDur)); } else { if (item._iMaxDur == DUR_INDESTRUCTIBLE) - AddPanelString(fmt::format(fmt::runtime(_("damage: {:d}-{:d} Indestructible")), item._iMinDam, item._iMaxDam)); + AddInfoBoxString(fmt::format(fmt::runtime(_("damage: {:d}-{:d} Indestructible")), item._iMinDam, item._iMaxDam)); else - AddPanelString(fmt::format(fmt::runtime(_(/* TRANSLATORS: Dur: is durability */ "damage: {:d}-{:d} Dur: {:d}/{:d}")), item._iMinDam, item._iMaxDam, item._iDurability, item._iMaxDur)); + AddInfoBoxString(fmt::format(fmt::runtime(_(/* TRANSLATORS: Dur: is durability */ "damage: {:d}-{:d} Dur: {:d}/{:d}")), item._iMinDam, item._iMaxDam, item._iDurability, item._iMaxDur)); } } if (item._iClass == ICLASS_ARMOR) { if (item._iMaxDur == DUR_INDESTRUCTIBLE) - AddPanelString(fmt::format(fmt::runtime(_("armor: {:d} Indestructible")), item._iAC)); + AddInfoBoxString(fmt::format(fmt::runtime(_("armor: {:d} Indestructible")), item._iAC)); else - AddPanelString(fmt::format(fmt::runtime(_(/* TRANSLATORS: Dur: is durability */ "armor: {:d} Dur: {:d}/{:d}")), item._iAC, item._iDurability, item._iMaxDur)); + AddInfoBoxString(fmt::format(fmt::runtime(_(/* TRANSLATORS: Dur: is durability */ "armor: {:d} Dur: {:d}/{:d}")), item._iAC, item._iDurability, item._iMaxDur)); } if (item._iMiscId == IMISC_STAFF && item._iMaxCharges != 0) { - AddPanelString(fmt::format(fmt::runtime(_("Charges: {:d}/{:d}")), item._iCharges, item._iMaxCharges)); + AddInfoBoxString(fmt::format(fmt::runtime(_("Charges: {:d}/{:d}")), item._iCharges, item._iMaxCharges)); } if (item._iPrePower != -1) { - AddPanelString(PrintItemPower(item._iPrePower, item)); + AddInfoBoxString(PrintItemPower(item._iPrePower, item)); } if (item._iSufPower != -1) { - AddPanelString(PrintItemPower(item._iSufPower, item)); + AddInfoBoxString(PrintItemPower(item._iSufPower, item)); } if (item._iMagical == ITEM_QUALITY_UNIQUE) { - AddPanelString(_("unique item")); + AddInfoBoxString(_("unique item")); ShowUniqueItemInfoBox = true; curruitem = item; } @@ -4139,34 +4139,34 @@ void PrintItemDur(const Item &item) if (item._iClass == ICLASS_WEAPON) { if (item._iMinDam == item._iMaxDam) { if (item._iMaxDur == DUR_INDESTRUCTIBLE) - AddPanelString(fmt::format(fmt::runtime(_("damage: {:d} Indestructible")), item._iMinDam)); + AddInfoBoxString(fmt::format(fmt::runtime(_("damage: {:d} Indestructible")), item._iMinDam)); else - AddPanelString(fmt::format(fmt::runtime(_("damage: {:d} Dur: {:d}/{:d}")), item._iMinDam, item._iDurability, item._iMaxDur)); + AddInfoBoxString(fmt::format(fmt::runtime(_("damage: {:d} Dur: {:d}/{:d}")), item._iMinDam, item._iDurability, item._iMaxDur)); } else { if (item._iMaxDur == DUR_INDESTRUCTIBLE) - AddPanelString(fmt::format(fmt::runtime(_("damage: {:d}-{:d} Indestructible")), item._iMinDam, item._iMaxDam)); + AddInfoBoxString(fmt::format(fmt::runtime(_("damage: {:d}-{:d} Indestructible")), item._iMinDam, item._iMaxDam)); else - AddPanelString(fmt::format(fmt::runtime(_("damage: {:d}-{:d} Dur: {:d}/{:d}")), item._iMinDam, item._iMaxDam, item._iDurability, item._iMaxDur)); + AddInfoBoxString(fmt::format(fmt::runtime(_("damage: {:d}-{:d} Dur: {:d}/{:d}")), item._iMinDam, item._iMaxDam, item._iDurability, item._iMaxDur)); } if (item._iMiscId == IMISC_STAFF && item._iMaxCharges > 0) { - AddPanelString(fmt::format(fmt::runtime(_("Charges: {:d}/{:d}")), item._iCharges, item._iMaxCharges)); + AddInfoBoxString(fmt::format(fmt::runtime(_("Charges: {:d}/{:d}")), item._iCharges, item._iMaxCharges)); } if (item._iMagical != ITEM_QUALITY_NORMAL) - AddPanelString(_("Not Identified")); + AddInfoBoxString(_("Not Identified")); } if (item._iClass == ICLASS_ARMOR) { if (item._iMaxDur == DUR_INDESTRUCTIBLE) - AddPanelString(fmt::format(fmt::runtime(_("armor: {:d} Indestructible")), item._iAC)); + AddInfoBoxString(fmt::format(fmt::runtime(_("armor: {:d} Indestructible")), item._iAC)); else - AddPanelString(fmt::format(fmt::runtime(_("armor: {:d} Dur: {:d}/{:d}")), item._iAC, item._iDurability, item._iMaxDur)); + AddInfoBoxString(fmt::format(fmt::runtime(_("armor: {:d} Dur: {:d}/{:d}")), item._iAC, item._iDurability, item._iMaxDur)); if (item._iMagical != ITEM_QUALITY_NORMAL) - AddPanelString(_("Not Identified")); + AddInfoBoxString(_("Not Identified")); if (item._iMiscId == IMISC_STAFF && item._iMaxCharges > 0) { - AddPanelString(fmt::format(fmt::runtime(_("Charges: {:d}/{:d}")), item._iCharges, item._iMaxCharges)); + AddInfoBoxString(fmt::format(fmt::runtime(_("Charges: {:d}/{:d}")), item._iCharges, item._iMaxCharges)); } } if (IsAnyOf(item._itype, ItemType::Ring, ItemType::Amulet)) - AddPanelString(_("Not Identified")); + AddInfoBoxString(_("Not Identified")); PrintItemInfo(item); } @@ -4295,8 +4295,8 @@ void UseItem(Player &player, item_misc_id mid, SpellID spellID, int spellFrom) if (&player != MyPlayer) { return; } - if (sbookflag) { - sbookflag = false; + if (SpellbookFlag) { + SpellbookFlag = false; } if (!invflag) { invflag = true; diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 1962308c87f..9a7c4f7599d 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -2382,7 +2382,7 @@ void LoadGame(bool firstflag) int viewX = file.NextBE(); int viewY = file.NextBE(); invflag = file.NextBool8(); - chrflag = file.NextBool8(); + CharFlag = file.NextBool8(); int tmpNummonsters = file.NextBE(); auto savedItemCount = file.NextBE(); int tmpNummissiles = file.NextBE(); @@ -2666,7 +2666,7 @@ void SaveGameData(SaveWriter &saveWriter) file.WriteBE(ViewPosition.x); file.WriteBE(ViewPosition.y); file.WriteLE(invflag ? 1 : 0); - file.WriteLE(chrflag ? 1 : 0); + file.WriteLE(CharFlag ? 1 : 0); file.WriteBE(static_cast(ActiveMonsterCount)); file.WriteBE(ActiveItemCount); // ActiveMissileCount will be a value from 0-125 (for vanilla compatibility). Writing an unsigned value here to avoid diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 95b963af6cd..2074a1ed863 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -2423,8 +2423,8 @@ void AddIdentify(Missile &missile, AddMissileParameter & /*parameter*/) missile._miDelFlag = true; if (&player == MyPlayer) { - if (sbookflag) - sbookflag = false; + if (SpellbookFlag) + SpellbookFlag = false; if (!invflag) { invflag = true; if (ControlMode != ControlTypes::KeyboardAndMouse) @@ -2514,8 +2514,8 @@ void AddItemRepair(Missile &missile, AddMissileParameter & /*parameter*/) missile._miDelFlag = true; if (&player == MyPlayer) { - if (sbookflag) - sbookflag = false; + if (SpellbookFlag) + SpellbookFlag = false; if (!invflag) { invflag = true; if (ControlMode != ControlTypes::KeyboardAndMouse) @@ -2531,8 +2531,8 @@ void AddStaffRecharge(Missile &missile, AddMissileParameter & /*parameter*/) missile._miDelFlag = true; if (&player == MyPlayer) { - if (sbookflag) - sbookflag = false; + if (SpellbookFlag) + SpellbookFlag = false; if (!invflag) { invflag = true; if (ControlMode != ControlTypes::KeyboardAndMouse) diff --git a/Source/monster.cpp b/Source/monster.cpp index d05a0febcf5..e8e70a42b8e 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4308,9 +4308,9 @@ void M_FallenFear(Point position) void PrintMonstHistory(int mt) { if (*sgOptions.Gameplay.showMonsterType) { - AddPanelString(fmt::format(fmt::runtime(_("Type: {:s} Kills: {:d}")), GetMonsterTypeText(MonstersData[mt]), MonsterKillCounts[mt])); + AddInfoBoxString(fmt::format(fmt::runtime(_("Type: {:s} Kills: {:d}")), GetMonsterTypeText(MonstersData[mt]), MonsterKillCounts[mt])); } else { - AddPanelString(fmt::format(fmt::runtime(_("Total kills: {:d}")), MonsterKillCounts[mt])); + AddInfoBoxString(fmt::format(fmt::runtime(_("Total kills: {:d}")), MonsterKillCounts[mt])); } if (MonsterKillCounts[mt] >= 30) { @@ -4342,12 +4342,12 @@ void PrintMonstHistory(int mt) minHP = 4 * minHP + hpBonusHell; maxHP = 4 * maxHP + hpBonusHell; } - AddPanelString(fmt::format(fmt::runtime(_("Hit Points: {:d}-{:d}")), minHP, maxHP)); + AddInfoBoxString(fmt::format(fmt::runtime(_("Hit Points: {:d}-{:d}")), minHP, maxHP)); } if (MonsterKillCounts[mt] >= 15) { int res = (sgGameInitInfo.nDifficulty != DIFF_HELL) ? MonstersData[mt].resistance : MonstersData[mt].resistanceHell; if ((res & (RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMMUNE_MAGIC | IMMUNE_FIRE | IMMUNE_LIGHTNING)) == 0) { - AddPanelString(_("No magic resistance")); + AddInfoBoxString(_("No magic resistance")); } else { if ((res & (RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING)) != 0) { std::string resists = std::string(_("Resists:")); @@ -4357,7 +4357,7 @@ void PrintMonstHistory(int mt) resists.append(_(" Fire")); if ((res & RESIST_LIGHTNING) != 0) resists.append(_(" Lightning")); - AddPanelString(resists); + AddInfoBoxString(resists); } if ((res & (IMMUNE_MAGIC | IMMUNE_FIRE | IMMUNE_LIGHTNING)) != 0) { std::string immune = std::string(_("Immune:")); @@ -4367,7 +4367,7 @@ void PrintMonstHistory(int mt) immune.append(_(" Fire")); if ((res & IMMUNE_LIGHTNING) != 0) immune.append(_(" Lightning")); - AddPanelString(immune); + AddInfoBoxString(immune); } } } @@ -4377,22 +4377,22 @@ void PrintUniqueHistory() { Monster &monster = Monsters[pcursmonst]; if (*sgOptions.Gameplay.showMonsterType) { - AddPanelString(fmt::format(fmt::runtime(_("Type: {:s}")), GetMonsterTypeText(monster.data()))); + AddInfoBoxString(fmt::format(fmt::runtime(_("Type: {:s}")), GetMonsterTypeText(monster.data()))); } int res = monster.resistance & (RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMMUNE_MAGIC | IMMUNE_FIRE | IMMUNE_LIGHTNING); if (res == 0) { - AddPanelString(_("No resistances")); - AddPanelString(_("No Immunities")); + AddInfoBoxString(_("No resistances")); + AddInfoBoxString(_("No Immunities")); } else { if ((res & (RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING)) != 0) - AddPanelString(_("Some Magic Resistances")); + AddInfoBoxString(_("Some Magic Resistances")); else - AddPanelString(_("No resistances")); + AddInfoBoxString(_("No resistances")); if ((res & (IMMUNE_MAGIC | IMMUNE_FIRE | IMMUNE_LIGHTNING)) != 0) { - AddPanelString(_("Some Magic Immunities")); + AddInfoBoxString(_("Some Magic Immunities")); } else { - AddPanelString(_("No Immunities")); + AddInfoBoxString(_("No Immunities")); } } } diff --git a/Source/options.cpp b/Source/options.cpp index c27e7f04641..5275e359528 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -1500,7 +1500,7 @@ void KeymapperOptions::KeyPressed(uint32_t key) const // Check that the action can be triggered and that the chat textbox is not // open. - if (!action.actionPressed || (action.enable && !action.enable()) || talkflag) + if (!action.actionPressed || (action.enable && !action.enable()) || ChatFlag) return; action.actionPressed(); @@ -1519,7 +1519,7 @@ void KeymapperOptions::KeyReleased(SDL_Keycode key) const // Check that the action can be triggered and that the chat or gold textbox is not // open. If either of those textboxes are open, only return if the key can be used for entry into the box - if (!action.actionReleased || (action.enable && !action.enable()) || ((talkflag && IsTextEntryKey(key)) || (dropGoldFlag && IsNumberEntryKey(key)))) + if (!action.actionReleased || (action.enable && !action.enable()) || ((ChatFlag && IsTextEntryKey(key)) || (DropGoldFlag && IsNumberEntryKey(key)))) return; action.actionReleased(); @@ -1874,7 +1874,7 @@ bool PadmapperOptions::CanDeferToMovementHandler(const Action &action) const if (action.boundInput.modifier != ControllerButton_NONE) return false; - if (spselflag) { + if (SpellSelectFlag) { const std::string_view prefix { "QuickSpell" }; const std::string_view key { action.key }; if (key.size() >= prefix.size()) { diff --git a/Source/panels/charpanel.cpp b/Source/panels/charpanel.cpp index 10c3e513963..ad59bf25972 100644 --- a/Source/panels/charpanel.cpp +++ b/Source/panels/charpanel.cpp @@ -255,13 +255,13 @@ void DrawStatButtons(const Surface &out) { if (InspectPlayer->_pStatPts > 0 && !IsInspectingPlayer()) { if (InspectPlayer->_pBaseStr < InspectPlayer->GetMaximumAttributeValue(CharacterAttribute::Strength)) - ClxDraw(out, GetPanelPosition(UiPanels::Character, { 137, 157 }), (*pChrButtons)[chrbtn[static_cast(CharacterAttribute::Strength)] ? 2 : 1]); + ClxDraw(out, GetPanelPosition(UiPanels::Character, { 137, 157 }), (*pChrButtons)[CharPanelButton[static_cast(CharacterAttribute::Strength)] ? 2 : 1]); if (InspectPlayer->_pBaseMag < InspectPlayer->GetMaximumAttributeValue(CharacterAttribute::Magic)) - ClxDraw(out, GetPanelPosition(UiPanels::Character, { 137, 185 }), (*pChrButtons)[chrbtn[static_cast(CharacterAttribute::Magic)] ? 4 : 3]); + ClxDraw(out, GetPanelPosition(UiPanels::Character, { 137, 185 }), (*pChrButtons)[CharPanelButton[static_cast(CharacterAttribute::Magic)] ? 4 : 3]); if (InspectPlayer->_pBaseDex < InspectPlayer->GetMaximumAttributeValue(CharacterAttribute::Dexterity)) - ClxDraw(out, GetPanelPosition(UiPanels::Character, { 137, 214 }), (*pChrButtons)[chrbtn[static_cast(CharacterAttribute::Dexterity)] ? 6 : 5]); + ClxDraw(out, GetPanelPosition(UiPanels::Character, { 137, 214 }), (*pChrButtons)[CharPanelButton[static_cast(CharacterAttribute::Dexterity)] ? 6 : 5]); if (InspectPlayer->_pBaseVit < InspectPlayer->GetMaximumAttributeValue(CharacterAttribute::Vitality)) - ClxDraw(out, GetPanelPosition(UiPanels::Character, { 137, 242 }), (*pChrButtons)[chrbtn[static_cast(CharacterAttribute::Vitality)] ? 8 : 7]); + ClxDraw(out, GetPanelPosition(UiPanels::Character, { 137, 242 }), (*pChrButtons)[CharPanelButton[static_cast(CharacterAttribute::Vitality)] ? 8 : 7]); } } diff --git a/Source/panels/mainpanel.cpp b/Source/panels/mainpanel.cpp index 89d303326c4..05423fef3b8 100644 --- a/Source/panels/mainpanel.cpp +++ b/Source/panels/mainpanel.cpp @@ -35,20 +35,20 @@ void DrawButtonText(const Surface &out, std::string_view text, Rectangle placeme void DrawButtonOnPanel(Point position, std::string_view text, int frame) { - RenderClxSprite(*pBtmBuff, (*PanelButton)[frame], position); + RenderClxSprite(*BottomBuffer, (*PanelButton)[frame], position); int spacing = 2; int width = std::min(GetLineWidth(text, GameFont12, spacing), (*PanelButton)[0].width()); if (width > 38) { spacing = 1; width = std::min(GetLineWidth(text, GameFont12, spacing), (*PanelButton)[0].width()); } - RenderClxSprite(pBtmBuff->subregion(position.x + ((*PanelButton)[0].width() - width) / 2, position.y + 7, width, pBtmBuff->h() - 7), (*PanelButtonGrime)[frame], { 0, 0 }); - DrawButtonText(*pBtmBuff, text, { position, { (*PanelButton)[0].width(), 0 } }, UiFlags::ColorButtonface, spacing); + RenderClxSprite(BottomBuffer->subregion(position.x + ((*PanelButton)[0].width() - width) / 2, position.y + 7, width, BottomBuffer->h() - 7), (*PanelButtonGrime)[frame], { 0, 0 }); + DrawButtonText(*BottomBuffer, text, { position, { (*PanelButton)[0].width(), 0 } }, UiFlags::ColorButtonface, spacing); } void RenderMainButton(const Surface &out, int buttonId, std::string_view text, int frame) { - Point panelPosition { PanelButtonRect[buttonId].position + Displacement { 4, 17 } }; + Point panelPosition { MainPanelButtonRect[buttonId].position + Displacement { 4, 17 } }; DrawButtonOnPanel(panelPosition, text, frame); if (IsChatAvailable()) DrawButtonOnPanel(panelPosition + Displacement { 0, GetMainPanel().size.height + 16 }, text, frame); @@ -98,15 +98,15 @@ void LoadMainPanel() const int talkButtonWidth = (*talkButton)[0].width(); constexpr size_t NumOtherPlayers = 3; - // Render the unpressed voice buttons to pBtmBuff. + // Render the unpressed voice buttons to BottomBuffer. std::string_view text = _("voice"); const int textWidth = GetLineWidth(text, GameFont12, 1); for (size_t i = 0; i < NumOtherPlayers; ++i) { Point position { 176, static_cast(GetMainPanel().size.height + 101 + 18 * i) }; - RenderClxSprite(*pBtmBuff, (*talkButton)[0], position); + RenderClxSprite(*BottomBuffer, (*talkButton)[0], position); int width = std::min(textWidth, (*PanelButton)[0].width()); - RenderClxSprite(pBtmBuff->subregion(position.x + (talkButtonWidth - width) / 2, position.y + 6, width, 9), (*PanelButtonGrime)[1], { 0, 0 }); - DrawButtonText(*pBtmBuff, text, { position, { talkButtonWidth, 0 } }, UiFlags::ColorButtonface); + RenderClxSprite(BottomBuffer->subregion(position.x + (talkButtonWidth - width) / 2, position.y + 6, width, 9), (*PanelButtonGrime)[1], { 0, 0 }); + DrawButtonText(*BottomBuffer, text, { position, { talkButtonWidth, 0 } }, UiFlags::ColorButtonface); } const int talkButtonHeight = (*talkButton)[0].height(); diff --git a/Source/panels/spell_book.cpp b/Source/panels/spell_book.cpp index aab487ba249..0814900002e 100644 --- a/Source/panels/spell_book.cpp +++ b/Source/panels/spell_book.cpp @@ -149,13 +149,13 @@ void DrawSpellBook(const Surface &out) constexpr int SpellBookButtonX = 7; constexpr int SpellBookButtonY = 348; ClxDraw(out, GetPanelPosition(UiPanels::Spell, { 0, 351 }), (*spellBookBackground)[0]); - const int buttonX = gbIsHellfire && sbooktab < 5 - ? SpellBookButtonWidthHellfire * sbooktab - : SpellBookButtonWidthDiablo * sbooktab + const int buttonX = gbIsHellfire && SpellbookTab < 5 + ? SpellBookButtonWidthHellfire * SpellbookTab + : SpellBookButtonWidthDiablo * SpellbookTab // BUGFIX: rendering of page 3 and page 4 buttons are both off-by-one pixel (fixed). - + (sbooktab == 2 || sbooktab == 3 ? 1 : 0); + + (SpellbookTab == 2 || SpellbookTab == 3 ? 1 : 0); - ClxDraw(out, GetPanelPosition(UiPanels::Spell, { SpellBookButtonX + buttonX, SpellBookButtonY }), (*spellBookButtons)[sbooktab]); + ClxDraw(out, GetPanelPosition(UiPanels::Spell, { SpellBookButtonX + buttonX, SpellBookButtonY }), (*spellBookButtons)[SpellbookTab]); Player &player = *InspectPlayer; uint64_t spl = player._pMemSpells | player._pISpells | player._pAblSpells; @@ -164,7 +164,7 @@ void DrawSpellBook(const Surface &out) int yp = 12; const int textPaddingTop = 7; for (size_t pageEntry = 0; pageEntry < SpellBookPageEntries; pageEntry++) { - SpellID sn = GetSpellFromSpellPage(sbooktab, pageEntry); + SpellID sn = GetSpellFromSpellPage(SpellbookTab, pageEntry); if (IsValidSpell(sn) && (spl & GetSpellBitmask(sn)) != 0) { SpellType st = GetSBookTrans(sn, true); SetSpellTrans(st); @@ -209,7 +209,7 @@ void CheckSBook() // padding from the end of the area. Rectangle iconArea = { GetPanelPosition(UiPanels::Spell, { 11, 18 }), Size { 37, SpellBookDescription.height * 7 - 5 } }; if (iconArea.contains(MousePosition) && !IsInspectingPlayer()) { - SpellID sn = GetSpellFromSpellPage(sbooktab, (MousePosition.y - iconArea.position.y) / SpellBookDescription.height); + SpellID sn = GetSpellFromSpellPage(SpellbookTab, (MousePosition.y - iconArea.position.y) / SpellBookDescription.height); Player &player = *InspectPlayer; uint64_t spl = player._pMemSpells | player._pISpells | player._pAblSpells; if (IsValidSpell(sn) && (spl & GetSpellBitmask(sn)) != 0) { @@ -240,7 +240,7 @@ void CheckSBook() // Subtract 1 pixel to account for the gutter between buttons 2/3 hitColumn--; } - sbooktab = hitColumn / buttonWidth; + SpellbookTab = hitColumn / buttonWidth; } } diff --git a/Source/panels/spell_list.cpp b/Source/panels/spell_list.cpp index 26da82c5452..5be1f0b643c 100644 --- a/Source/panels/spell_list.cpp +++ b/Source/panels/spell_list.cpp @@ -158,12 +158,12 @@ void DrawSpellList(const Surface &out) PrintSBookSpellType(out, spellListItem.location, _("Spell"), spellColor); InfoString = fmt::format(fmt::runtime(_("{:s} Spell")), pgettext("spell", spellDataItem.sNameText)); if (spellId == SpellID::HolyBolt) { - AddPanelString(_("Damages undead only")); + AddInfoBoxString(_("Damages undead only")); } if (spellLevel == 0) - AddPanelString(_("Spell Level 0 - Unusable")); + AddInfoBoxString(_("Spell Level 0 - Unusable")); else - AddPanelString(fmt::format(fmt::runtime(_("Spell Level {:d}")), spellLevel)); + AddInfoBoxString(fmt::format(fmt::runtime(_("Spell Level {:d}")), spellLevel)); break; case SpellType::Scroll: { if (!myPlayer.isOnLevel(0)) { @@ -174,7 +174,7 @@ void DrawSpellList(const Surface &out) const int scrollCount = c_count_if(InventoryAndBeltPlayerItemsRange { myPlayer }, [spellId](const Item &item) { return item.isScrollOf(spellId); }); - AddPanelString(fmt::format(fmt::runtime(ngettext("{:d} Scroll", "{:d} Scrolls", scrollCount)), scrollCount)); + AddInfoBoxString(fmt::format(fmt::runtime(ngettext("{:d} Scroll", "{:d} Scrolls", scrollCount)), scrollCount)); } break; case SpellType::Charges: { if (!myPlayer.isOnLevel(0)) { @@ -183,14 +183,14 @@ void DrawSpellList(const Surface &out) PrintSBookSpellType(out, spellListItem.location, _("Staff"), spellColor); InfoString = fmt::format(fmt::runtime(_("Staff of {:s}")), pgettext("spell", spellDataItem.sNameText)); int charges = myPlayer.InvBody[INVLOC_HAND_LEFT]._iCharges; - AddPanelString(fmt::format(fmt::runtime(ngettext("{:d} Charge", "{:d} Charges", charges)), charges)); + AddInfoBoxString(fmt::format(fmt::runtime(ngettext("{:d} Charge", "{:d} Charges", charges)), charges)); } break; case SpellType::Invalid: break; } std::optional fullHotkeyName = GetHotkeyName(spellId, spellListItem.type); if (fullHotkeyName) { - AddPanelString(fmt::format(fmt::runtime(_("Spell Hotkey {:s}")), *fullHotkeyName)); + AddInfoBoxString(fmt::format(fmt::runtime(_("Spell Hotkey {:s}")), *fullHotkeyName)); } } } @@ -253,7 +253,7 @@ void SetSpell() SpellID pSpell; SpellType pSplType; - spselflag = false; + SpellSelectFlag = false; if (!GetSpellListSelection(pSpell, pSplType)) { return; } @@ -332,7 +332,7 @@ void ToggleSpell(size_t slot) void DoSpeedBook() { - spselflag = true; + SpellSelectFlag = true; const Point mainPanelPosition = GetMainPanel().position; int xo = mainPanelPosition.x + 12 + SPLICONLENGTH * 10; int yo = mainPanelPosition.y - 17; diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index a1facb39ffb..bba44697449 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -98,11 +98,11 @@ void DrawPlrMsg(const Surface &out) int y = GetMainPanel().position.y - 13; int width = gnScreenWidth - 20; - if (!talkflag && IsLeftPanelOpen()) { + if (!ChatFlag && IsLeftPanelOpen()) { x += GetLeftPanel().position.x + GetLeftPanel().size.width; width -= GetLeftPanel().size.width; } - if (!talkflag && IsRightPanelOpen()) + if (!ChatFlag && IsRightPanelOpen()) width -= gnScreenWidth - GetRightPanel().position.x; if (width < 300) @@ -113,7 +113,7 @@ void DrawPlrMsg(const Surface &out) for (PlayerMessage &message : Messages) { if (message.text.empty()) break; - if (!talkflag && SDL_GetTicks() - message.time >= 10000) + if (!ChatFlag && SDL_GetTicks() - message.time >= 10000) break; std::string text = WordWrapString(message.text, width); diff --git a/Source/qol/chatlog.cpp b/Source/qol/chatlog.cpp index 0dc9f42bbf1..5e0da7a12b3 100644 --- a/Source/qol/chatlog.cpp +++ b/Source/qol/chatlog.cpp @@ -99,8 +99,8 @@ void ToggleChatLog() stextflag = TalkID::None; CloseInventory(); CloseCharPanel(); - sbookflag = false; - spselflag = false; + SpellbookFlag = false; + SpellSelectFlag = false; if (qtextflag && leveltype == DTYPE_TOWN) { qtextflag = false; stream_stop(); diff --git a/Source/qol/stash.cpp b/Source/qol/stash.cpp index ab573d5861a..a8c77c21c79 100644 --- a/Source/qol/stash.cpp +++ b/Source/qol/stash.cpp @@ -586,8 +586,8 @@ void StartGoldWithdraw() { CloseGoldDrop(); - if (talkflag) - control_reset_talk(); + if (ChatFlag) + ResetChat(); Point start = GetPanelPosition(UiPanels::Stash, { 67, 128 }); SDL_Rect rect = MakeSdlRect(start.x, start.y, 180, 20); @@ -644,7 +644,7 @@ void DrawGoldWithdraw(const Surface &out) const int dialogX = 30; - ClxDraw(out, GetPanelPosition(UiPanels::Stash, { dialogX, 178 }), (*pGBoxBuff)[0]); + ClxDraw(out, GetPanelPosition(UiPanels::Stash, { dialogX, 178 }), (*GoldBoxBuffer)[0]); // Pre-wrap the string at spaces, otherwise DrawString would hard wrap in the middle of words const std::string wrapped = WordWrapString(_("How many gold pieces do you want to withdraw?"), 200); diff --git a/Source/qol/xpbar.cpp b/Source/qol/xpbar.cpp index 6b1efc356b7..eb8df850595 100644 --- a/Source/qol/xpbar.cpp +++ b/Source/qol/xpbar.cpp @@ -65,7 +65,7 @@ void FreeXPBar() void DrawXPBar(const Surface &out) { - if (!*sgOptions.Gameplay.experienceBar || talkflag) + if (!*sgOptions.Gameplay.experienceBar || ChatFlag) return; const Player &player = *MyPlayer; @@ -122,24 +122,24 @@ bool CheckXPBarInfo() const uint8_t charLevel = player.getCharacterLevel(); - AddPanelString(fmt::format(fmt::runtime(_("Level {:d}")), charLevel)); + AddInfoBoxString(fmt::format(fmt::runtime(_("Level {:d}")), charLevel)); if (player.isMaxCharacterLevel()) { // Show a maximum level indicator for max level players. InfoColor = UiFlags::ColorWhitegold; - AddPanelString(fmt::format(fmt::runtime(_("Experience: {:s}")), FormatInteger(player._pExperience))); - AddPanelString(_("Maximum Level")); + AddInfoBoxString(fmt::format(fmt::runtime(_("Experience: {:s}")), FormatInteger(player._pExperience))); + AddInfoBoxString(_("Maximum Level")); return true; } InfoColor = UiFlags::ColorWhite; - AddPanelString(fmt::format(fmt::runtime(_("Experience: {:s}")), FormatInteger(player._pExperience))); + AddInfoBoxString(fmt::format(fmt::runtime(_("Experience: {:s}")), FormatInteger(player._pExperience))); uint32_t nextExperienceThreshold = player.getNextExperienceThreshold(); - AddPanelString(fmt::format(fmt::runtime(_("Next Level: {:s}")), FormatInteger(nextExperienceThreshold))); - AddPanelString(fmt::format(fmt::runtime(_("{:s} to Level {:d}")), FormatInteger(nextExperienceThreshold - player._pExperience), charLevel + 1)); + AddInfoBoxString(fmt::format(fmt::runtime(_("Next Level: {:s}")), FormatInteger(nextExperienceThreshold))); + AddInfoBoxString(fmt::format(fmt::runtime(_("{:s} to Level {:d}")), FormatInteger(nextExperienceThreshold - player._pExperience), charLevel + 1)); return true; } diff --git a/Source/stores.cpp b/Source/stores.cpp index 537de975f84..9870a603613 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -2253,7 +2253,7 @@ void StartStore(TalkID s) if (*sgOptions.Gameplay.showItemGraphicsInStores) { CreateHalfSizeItemSprites(); } - sbookflag = false; + SpellbookFlag = false; CloseInventory(); CloseCharPanel(); RenderGold = false; diff --git a/test/fixtures/memory_map/game.txt b/test/fixtures/memory_map/game.txt index e4cf7861f1a..c6e6402ac3c 100644 --- a/test/fixtures/memory_map/game.txt +++ b/test/fixtures/memory_map/game.txt @@ -6,7 +6,7 @@ LT 32 leveltype R 32 viewX R 32 viewY R 8 invflag -R 8 chrflag +R 8 CharFlag LC 32 NumMonsters LC 32 ItemCount LC 32 NumMissiles