Skip to content

Commit

Permalink
Major refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Sep 26, 2024
1 parent 3e5daee commit 2ae006d
Show file tree
Hide file tree
Showing 19 changed files with 598 additions and 714 deletions.
2 changes: 1 addition & 1 deletion Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ bool IsLevelUpButtonVisible()
if (ControlMode == ControlTypes::VirtualGamepad) {
return false;
}
if (Stores.IsPlayerInStore() || IsStashOpen) {
if (IsPlayerInStore() || IsStashOpen) {
return false;
}
if (QuestLogIsOpen && GetLeftPanel().contains(GetMainPanel().position + Displacement { 0, -74 })) {
Expand Down
8 changes: 4 additions & 4 deletions Source/controls/game_controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game
if (ControllerActionHeld == GameActionType_NONE) {
ControllerActionHeld = GameActionType_PRIMARY_ACTION;
}
} else if (sgpCurrentMenu != nullptr || Stores.IsPlayerInStore() || QuestLogIsOpen) {
} else if (sgpCurrentMenu != nullptr || IsPlayerInStore() || QuestLogIsOpen) {
*action = GameActionSendKey { SDLK_RETURN, false };
} else {
*action = GameActionSendKey { SDLK_SPACE, false };
Expand Down Expand Up @@ -171,12 +171,12 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game
return true;
}
if (VirtualGamepadState.healthButton.isHeld && VirtualGamepadState.healthButton.didStateChange) {
if (!QuestLogIsOpen && !SpellbookFlag && !Stores.IsPlayerInStore())
if (!QuestLogIsOpen && !SpellbookFlag && !IsPlayerInStore())
*action = GameAction(GameActionType_USE_HEALTH_POTION);
return true;
}
if (VirtualGamepadState.manaButton.isHeld && VirtualGamepadState.manaButton.didStateChange) {
if (!QuestLogIsOpen && !SpellbookFlag && !Stores.IsPlayerInStore())
if (!QuestLogIsOpen && !SpellbookFlag && !IsPlayerInStore())
*action = GameAction(GameActionType_USE_MANA_POTION);
return true;
}
Expand All @@ -196,7 +196,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game

SDL_Keycode translation = SDLK_UNKNOWN;

if (gmenu_is_active() || Stores.IsPlayerInStore())
if (gmenu_is_active() || IsPlayerInStore())
translation = TranslateControllerButtonToGameMenuKey(ctrlEvent.button);
else if (inGameMenu)
translation = TranslateControllerButtonToMenuKey(ctrlEvent.button);
Expand Down
8 changes: 4 additions & 4 deletions Source/controls/plrctrls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ quest_id pcursquest = Q_INVALID;
*/
bool InGameMenu()
{
return Stores.IsPlayerInStore()
return IsPlayerInStore()
|| HelpFlag
|| ChatLogFlag
|| ChatFlag
Expand Down Expand Up @@ -1320,9 +1320,9 @@ void StoreMove(AxisDirection moveDir)
static AxisDirectionRepeater repeater;
moveDir = repeater.Get(moveDir);
if (moveDir.y == AxisDirectionY_UP)
Stores.StoreUp();
StoreUp();
else if (moveDir.y == AxisDirectionY_DOWN)
Stores.StoreDown();
StoreDown();
}

using HandleLeftStickOrDPadFn = void (*)(devilution::AxisDirection);
Expand All @@ -1347,7 +1347,7 @@ HandleLeftStickOrDPadFn GetLeftStickOrDPadGameUIHandler()
if (QuestLogIsOpen) {
return &QuestLogMove;
}
if (Stores.IsPlayerInStore()) {
if (IsPlayerInStore()) {
return &StoreMove;
}
return nullptr;
Expand Down
4 changes: 2 additions & 2 deletions Source/controls/touch/event_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ bool HandleGameMenuInteraction(const SDL_Event &event)

bool HandleStoreInteraction(const SDL_Event &event)
{
if (!Stores.IsPlayerInStore())
if (!IsPlayerInStore())
return false;
if (event.type == SDL_FINGERDOWN)
Stores.CheckStoreButton();
CheckStoreButton();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/controls/touch/renderers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ VirtualGamepadButtonType PrimaryActionButtonRenderer::GetButtonType()

VirtualGamepadButtonType PrimaryActionButtonRenderer::GetTownButtonType()
{
if (Stores.IsPlayerInStore() || pcursmonst != -1)
if (IsPlayerInStore() || pcursmonst != -1)
return GetTalkButtonType(virtualPadButton->isHeld);
return GetBlankButtonType(virtualPadButton->isHeld);
}
Expand Down
70 changes: 35 additions & 35 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void FreeGame()
FreeGMenu();
FreeQuestText();
FreeInfoBoxGfx();
Stores.FreeStoreMem();
FreeStoreMem();

for (Player &player : Players)
ResetPlayerGFX(player);
Expand Down Expand Up @@ -353,8 +353,8 @@ void LeftMouseDown(uint16_t modState)
return;
}

if (Stores.IsPlayerInStore()) {
Stores.CheckStoreButton();
if (IsPlayerInStore()) {
CheckStoreButton();
return;
}

Expand Down Expand Up @@ -417,8 +417,8 @@ void LeftMouseUp(uint16_t modState)
}
if (LevelButtonDown)
CheckLevelButtonUp();
if (Stores.IsPlayerInStore())
Stores.ReleaseStoreButton();
if (IsPlayerInStore())
ReleaseStoreButton();
}

void RightMouseDown(bool isShiftHeld)
Expand All @@ -439,7 +439,7 @@ void RightMouseDown(bool isShiftHeld)
doom_close();
return;
}
if (Stores.IsPlayerInStore())
if (IsPlayerInStore())
return;
if (SpellSelectFlag) {
SetSpell();
Expand Down Expand Up @@ -576,17 +576,17 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
if ((modState & KMOD_ALT) != 0) {
sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen());
SaveOptions();
} else if (Stores.IsPlayerInStore()) {
Stores.StoreEnter();
} else if (IsPlayerInStore()) {
StoreEnter();
} else if (QuestLogIsOpen) {
QuestlogEnter();
} else {
TypeChatMessage();
}
return;
case SDLK_UP:
if (Stores.IsPlayerInStore()) {
Stores.StoreUp();
if (IsPlayerInStore()) {
StoreUp();
} else if (QuestLogIsOpen) {
QuestlogUp();
} else if (HelpFlag) {
Expand All @@ -600,8 +600,8 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
}
return;
case SDLK_DOWN:
if (Stores.IsPlayerInStore()) {
Stores.StoreDown();
if (IsPlayerInStore()) {
StoreDown();
} else if (QuestLogIsOpen) {
QuestlogDown();
} else if (HelpFlag) {
Expand All @@ -615,15 +615,15 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
}
return;
case SDLK_PAGEUP:
if (Stores.IsPlayerInStore()) {
Stores.StorePrior();
if (IsPlayerInStore()) {
StorePrior();
} else if (ChatLogFlag) {
ChatLogScrollTop();
}
return;
case SDLK_PAGEDOWN:
if (Stores.IsPlayerInStore()) {
Stores.StoreNext();
if (IsPlayerInStore()) {
StoreNext();
} else if (ChatLogFlag) {
ChatLogScrollBottom();
}
Expand All @@ -643,12 +643,12 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)

void HandleMouseButtonDown(Uint8 button, uint16_t modState)
{
if (Stores.IsPlayerInStore() && (button == SDL_BUTTON_X1
if (IsPlayerInStore() && (button == SDL_BUTTON_X1
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|| button == 8
#endif
)) {
Stores.StoreESC();
StoreESC();
return;
}

Expand Down Expand Up @@ -752,8 +752,8 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState)
#if SDL_VERSION_ATLEAST(2, 0, 0)
case SDL_MOUSEWHEEL:
if (event.wheel.y > 0) { // Up
if (Stores.IsPlayerInStore()) {
Stores.StoreUp();
if (IsPlayerInStore()) {
StoreUp();
} else if (QuestLogIsOpen) {
QuestlogUp();
} else if (HelpFlag) {
Expand All @@ -766,8 +766,8 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState)
sgOptions.Keymapper.KeyPressed(MouseScrollUpButton);
}
} else if (event.wheel.y < 0) { // down
if (Stores.IsPlayerInStore()) {
Stores.StoreDown();
if (IsPlayerInStore()) {
StoreDown();
} else if (QuestLogIsOpen) {
QuestlogDown();
} else if (HelpFlag) {
Expand Down Expand Up @@ -1492,7 +1492,7 @@ void HelpKeyPressed()
{
if (HelpFlag) {
HelpFlag = false;
} else if (Stores.IsPlayerInStore()) {
} else if (IsPlayerInStore()) {
InfoString = StringOrView {};
AddInfoBoxString(_("No help available")); /// BUGFIX: message isn't displayed
AddInfoBoxString(_("while in stores"));
Expand All @@ -1516,7 +1516,7 @@ void HelpKeyPressed()

void InventoryKeyPressed()
{
if (Stores.IsPlayerInStore())
if (IsPlayerInStore())
return;
invflag = !invflag;
if (!IsLeftPanelOpen() && CanPanelsCoverView()) {
Expand All @@ -1537,7 +1537,7 @@ void InventoryKeyPressed()

void CharacterSheetKeyPressed()
{
if (Stores.IsPlayerInStore())
if (IsPlayerInStore())
return;
if (!IsRightPanelOpen() && CanPanelsCoverView()) {
if (CharFlag) { // We are closing the character sheet
Expand All @@ -1555,7 +1555,7 @@ void CharacterSheetKeyPressed()

void QuestLogKeyPressed()
{
if (Stores.IsPlayerInStore())
if (IsPlayerInStore())
return;
if (!QuestLogIsOpen) {
StartQuestlog();
Expand All @@ -1580,7 +1580,7 @@ void QuestLogKeyPressed()

void DisplaySpellsKeyPressed()
{
if (Stores.IsPlayerInStore())
if (IsPlayerInStore())
return;
CloseCharPanel();
QuestLogIsOpen = false;
Expand All @@ -1596,7 +1596,7 @@ void DisplaySpellsKeyPressed()

void SpellBookKeyPressed()
{
if (Stores.IsPlayerInStore())
if (IsPlayerInStore())
return;
SpellbookFlag = !SpellbookFlag;
if (!IsLeftPanelOpen() && CanPanelsCoverView()) {
Expand Down Expand Up @@ -1761,7 +1761,7 @@ void InitKeymapActions()
SDLK_F3,
[] { gamemenu_load_game(false); },
nullptr,
[&]() { return !gbIsMultiplayer && gbValidSaveFile && !Stores.IsPlayerInStore() && IsGameRunning(); });
[&]() { return !gbIsMultiplayer && gbValidSaveFile && !IsPlayerInStore() && IsGameRunning(); });
#ifndef NOEXIT
sgOptions.Keymapper.AddAction(
"QuitGame",
Expand Down Expand Up @@ -2328,7 +2328,7 @@ void InitPadmapActions()
ControllerButton_NONE,
[] { gamemenu_load_game(false); },
nullptr,
[&]() { return !gbIsMultiplayer && gbValidSaveFile && !Stores.IsPlayerInStore() && IsGameRunning(); });
[&]() { return !gbIsMultiplayer && gbValidSaveFile && !IsPlayerInStore() && IsGameRunning(); });
sgOptions.Padmapper.AddAction(
"Item Highlighting",
N_("Item highlighting"),
Expand Down Expand Up @@ -2778,8 +2778,8 @@ bool PressEscKey()
rv = true;
}

if (Stores.IsPlayerInStore()) {
Stores.StoreESC();
if (IsPlayerInStore()) {
StoreESC();
rv = true;
}

Expand Down Expand Up @@ -2873,7 +2873,7 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir)
InitInfoBoxGfx();
InitHelp();
}
Stores.InitStores();
InitStores();
InitAutomapOnce();
}
if (!setlevel) {
Expand All @@ -2886,9 +2886,9 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir)
}

if (leveltype == DTYPE_TOWN) {
Stores.SetupTownStores();
SetupTownStores();
} else {
Stores.FreeStoreMem();
FreeStoreMem();
}

if (firstflag || lvldir == ENTRY_LOAD) {
Expand Down
6 changes: 3 additions & 3 deletions Source/engine/render/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ void DrawItem(const Surface &out, int8_t itemIndex, Point targetBufferPosition,
const Item &item = Items[itemIndex];
const ClxSprite sprite = item.AnimInfo.currentSprite();
const Point position = targetBufferPosition + item.getRenderingOffset(sprite);
if (!Stores.IsPlayerInStore() && (itemIndex == pcursitem || AutoMapShowItems)) {
if (!IsPlayerInStore() && (itemIndex == pcursitem || AutoMapShowItems)) {
ClxDrawOutlineSkipColorZero(out, GetOutlineColor(item, false), position, sprite);
}
ClxDrawLight(out, position, sprite, lightTableIndex);
Expand Down Expand Up @@ -1197,8 +1197,8 @@ void DrawView(const Surface &out, Point startPosition)
DrawMonsterHealthBar(out);
DrawFloatingNumbers(out, startPosition, offset);

if (Stores.IsPlayerInStore() && !qtextflag)
Stores.DrawSText(out);
if (IsPlayerInStore() && !qtextflag)
DrawSText(out);
if (invflag) {
DrawInv(out);
} else if (SpellbookFlag) {
Expand Down
4 changes: 2 additions & 2 deletions Source/help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void InitHelp()

void DrawHelp(const Surface &out)
{
Stores.DrawSTextHelp();
DrawSTextHelp();
DrawQTextBack(out);

const int lineHeight = LineHeight();
Expand All @@ -210,7 +210,7 @@ void DrawHelp(const Surface &out)
{ .flags = UiFlags::ColorWhitegold | UiFlags::AlignCenter });

const int titleBottom = sy + HeaderHeight();
Stores.DrawSLine(out, titleBottom);
DrawSLine(out, titleBottom);

const int numLines = NumVisibleLines();
const int contentY = titleBottom + DividerLineMarginY() + ContentPaddingY();
Expand Down
2 changes: 1 addition & 1 deletion Source/inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,7 @@ bool UseInvItem(int cii)
return true;
if (pcurs != CURSOR_HAND)
return true;
if (Stores.IsPlayerInStore())
if (IsPlayerInStore())
return true;
if (cii < INVITEM_INV_FIRST)
return false;
Expand Down
Loading

0 comments on commit 2ae006d

Please sign in to comment.