Skip to content

Commit

Permalink
Add IsPlayerInStore()
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Sep 20, 2024
1 parent 76d43b4 commit 71a6eaa
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Source/controls/game_controls.cpp
Original file line number Diff line number Diff line change
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.activeStore == TalkID::None)
if (!QuestLogIsOpen && !SpellbookFlag && !Stores.IsPlayerInStore())
*action = GameAction(GameActionType_USE_HEALTH_POTION);
return true;
}
if (VirtualGamepadState.manaButton.isHeld && VirtualGamepadState.manaButton.didStateChange) {
if (!QuestLogIsOpen && !SpellbookFlag && Stores.activeStore == TalkID::None)
if (!QuestLogIsOpen && !SpellbookFlag && !Stores.IsPlayerInStore())
*action = GameAction(GameActionType_USE_MANA_POTION);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/controls/touch/event_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool HandleGameMenuInteraction(const SDL_Event &event)

bool HandleStoreInteraction(const SDL_Event &event)
{
if (Stores.activeStore == TalkID::None)
if (!Stores.IsPlayerInStore())
return false;
if (event.type == SDL_FINGERDOWN)
Stores.CheckStoreBtn();
Expand Down
4 changes: 2 additions & 2 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ void InitKeymapActions()
SDLK_F3,
[] { gamemenu_load_game(false); },
nullptr,
[&]() { return !gbIsMultiplayer && gbValidSaveFile && Stores.activeStore == TalkID::None && IsGameRunning(); });
[&]() { return !gbIsMultiplayer && gbValidSaveFile && !Stores.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.activeStore == TalkID::None && IsGameRunning(); });
[&]() { return !gbIsMultiplayer && gbValidSaveFile && !Stores.IsPlayerInStore() && IsGameRunning(); });
sgOptions.Padmapper.AddAction(
"Item Highlighting",
N_("Item highlighting"),
Expand Down
2 changes: 1 addition & 1 deletion 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.activeStore == TalkID::None && (itemIndex == pcursitem || AutoMapShowItems)) {
if (!Stores.IsPlayerInStore() && (itemIndex == pcursitem || AutoMapShowItems)) {
ClxDrawOutlineSkipColorZero(out, GetOutlineColor(item, false), position, sprite);
}
ClxDrawLight(out, position, sprite, lightTableIndex);
Expand Down
6 changes: 3 additions & 3 deletions Source/qol/itemlabels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void ResetItemlabelHighlighted()

bool IsHighlightingLabelsEnabled()
{
return Stores.activeStore == TalkID::None && highlightKeyPressed != *sgOptions.Gameplay.showItemLabels;
return !Stores.IsPlayerInStore() && highlightKeyPressed != *sgOptions.Gameplay.showItemLabels;
}

void AddItemToLabelQueue(int id, Point position)
Expand Down Expand Up @@ -193,15 +193,15 @@ void DrawItemNameLabels(const Surface &out)
if (!gmenu_is_active()
&& PauseMode == 0
&& !MyPlayerIsDead
&& Stores.activeStore == TalkID::None
&& !Stores.IsPlayerInStore()
&& IsMouseOverGameArea()
&& LastMouseButtonAction == MouseActionType::None) {
isLabelHighlighted = true;
cursPosition = item.position;
pcursitem = label.id;
}
}
if (pcursitem == label.id && Stores.activeStore == TalkID::None)
if (pcursitem == label.id && !Stores.IsPlayerInStore())
FillRect(clippedOut, label.pos.x, label.pos.y, label.width, labelHeight, PAL8_BLUE + 6);
else
DrawHalfTransparentRectTo(clippedOut, label.pos.x, label.pos.y, label.width, labelHeight);
Expand Down
5 changes: 5 additions & 0 deletions Source/stores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2547,4 +2547,9 @@ void StoreSession::ReleaseStoreBtn()
countdownScrollDown = -1;
}

bool StoreSession::IsPlayerInStore() const
{
activeStore != TalkID::None;

Check warning on line 2552 in Source/stores.cpp

View workflow job for this annotation

GitHub Actions / build

'!=': result of expression not used
}

Check failure on line 2553 in Source/stores.cpp

View workflow job for this annotation

GitHub Actions / build

'devilution::StoreSession::IsPlayerInStore': must return a value

} // namespace devilution
1 change: 1 addition & 0 deletions Source/stores.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ class StoreSession {
void StoreEnter();
void CheckStoreBtn();
void ReleaseStoreBtn();
bool IsPlayerInStore() const;

// private:
TalkID activeStore; // Currently active store
Expand Down

0 comments on commit 71a6eaa

Please sign in to comment.