Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QOL: GUI Stores #7474

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMake/Assets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ set(devilutionx_assets
data/resistance.clx
data/stash.clx
data/stashnavbtns.clx
data/store.clx
data/talkbutton.clx
data/xpbar.clx
fonts/12-00.clx
Expand Down
1 change: 1 addition & 0 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ set(libdevilutionx_SRCS
qol/autopickup.cpp
qol/chatlog.cpp
qol/floatingnumbers.cpp
qol/guistore.cpp
qol/itemlabels.cpp
qol/monhealthbar.cpp
qol/stash.cpp
Expand Down
11 changes: 8 additions & 3 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "panels/spell_icons.hpp"
#include "panels/spell_list.hpp"
#include "playerdat.hpp"
#include "qol/guistore.h"
#include "qol/stash.h"
#include "qol/xpbar.h"
#include "stores.h"
Expand Down Expand Up @@ -107,7 +108,7 @@ const Rectangle &GetRightPanel()
}
bool IsLeftPanelOpen()
{
return CharFlag || QuestLogIsOpen || IsStashOpen;
return CharFlag || QuestLogIsOpen || IsStashOpen || IsStoreOpen;
}
bool IsRightPanelOpen()
{
Expand Down Expand Up @@ -686,7 +687,7 @@ bool IsLevelUpButtonVisible()
if (ControlMode == ControlTypes::VirtualGamepad) {
return false;
}
if (ActiveStore != TalkID::None || IsStashOpen) {
if (IsPlayerInStore() || IsStashOpen || IsStoreOpen) {
return false;
}
if (QuestLogIsOpen && GetLeftPanel().contains(GetMainPanel().position + Displacement { 0, -74 })) {
Expand Down Expand Up @@ -768,6 +769,7 @@ void OpenCharPanel()
QuestLogIsOpen = false;
CloseGoldWithdraw();
CloseStash();
CloseStore();
CharFlag = true;
}

Expand Down Expand Up @@ -815,6 +817,7 @@ Point GetPanelPosition(UiPanels panel, Point offset)
case UiPanels::Quest:
case UiPanels::Character:
case UiPanels::Stash:
case UiPanels::Store:
return GetLeftPanel().position + displacement;
case UiPanels::Spell:
case UiPanels::Inventory:
Expand Down Expand Up @@ -1166,6 +1169,7 @@ void CheckMainPanelButtonUp()
CloseCharPanel();
CloseGoldWithdraw();
CloseStash();
CloseStore();
if (!QuestLogIsOpen)
StartQuestlog();
else
Expand All @@ -1183,6 +1187,7 @@ void CheckMainPanelButtonUp()
SpellbookFlag = false;
CloseGoldWithdraw();
CloseStash();
CloseStore();
invflag = !invflag;
CloseGoldDrop();
break;
Expand Down Expand Up @@ -1230,7 +1235,7 @@ 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 (!MainPanelFlag && !trigflag && pcursinvitem == -1 && pcursstashitem == StashStruct::EmptyCell && !SpellSelectFlag && pcurs != CURSOR_HOURGLASS) {
if (!MainPanelFlag && !trigflag && pcursinvitem == -1 && pcursstashitem == StashStruct::EmptyCell && pcursstoreitem == StoreStruct::EmptyCell && !SpellSelectFlag && pcurs != CURSOR_HOURGLASS) {
InfoString = StringOrView {};
InfoColor = UiFlags::ColorWhite;
}
Expand Down
25 changes: 21 additions & 4 deletions Source/controls/game_controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "gmenu.h"
#include "options.h"
#include "panels/spell_list.hpp"
#include "qol/guistore.h"
#include "qol/stash.h"
#include "stores.h"

Expand Down Expand Up @@ -134,7 +135,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game
if (ControllerActionHeld == GameActionType_NONE) {
ControllerActionHeld = GameActionType_PRIMARY_ACTION;
}
} else if (sgpCurrentMenu != nullptr || ActiveStore != TalkID::None || QuestLogIsOpen) {
} else if (sgpCurrentMenu != nullptr || IsPlayerInStore() || QuestLogIsOpen) {
*action = GameActionSendKey { SDLK_RETURN, false };
} else {
*action = GameActionSendKey { SDLK_SPACE, false };
Expand Down Expand Up @@ -171,12 +172,12 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game
return true;
}
if (VirtualGamepadState.healthButton.isHeld && VirtualGamepadState.healthButton.didStateChange) {
if (!QuestLogIsOpen && !SpellbookFlag && ActiveStore == TalkID::None)
if (!QuestLogIsOpen && !SpellbookFlag && !IsPlayerInStore())
*action = GameAction(GameActionType_USE_HEALTH_POTION);
return true;
}
if (VirtualGamepadState.manaButton.isHeld && VirtualGamepadState.manaButton.didStateChange) {
if (!QuestLogIsOpen && !SpellbookFlag && ActiveStore == TalkID::None)
if (!QuestLogIsOpen && !SpellbookFlag && !IsPlayerInStore())
*action = GameAction(GameActionType_USE_MANA_POTION);
return true;
}
Expand All @@ -196,7 +197,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game

SDL_Keycode translation = SDLK_UNKNOWN;

if (gmenu_is_active() || ActiveStore != TalkID::None)
if (gmenu_is_active() || IsPlayerInStore())
translation = TranslateControllerButtonToGameMenuKey(ctrlEvent.button);
else if (inGameMenu)
translation = TranslateControllerButtonToMenuKey(ctrlEvent.button);
Expand Down Expand Up @@ -231,6 +232,22 @@ void PressControllerButton(ControllerButton button)
}
}

if (IsStoreOpen) {
switch (button) {
case ControllerButton_BUTTON_BACK:
// GUISTORE: Special action?
return;
case ControllerButton_BUTTON_LEFTSHOULDER:
// GUISTORE: Previous tab
return;
case ControllerButton_BUTTON_RIGHTSHOULDER:
// GUISTORE: Next tab
return;
default:
return;
}
}

if (PadHotspellMenuActive) {
auto quickSpellAction = [](size_t slot) {
if (SpellSelectFlag) {
Expand Down
Loading