Skip to content

Commit 1243405

Browse files
committed
Cleanup stores
1 parent b78ec23 commit 1243405

19 files changed

Lines changed: 1465 additions & 2014 deletions

Source/control.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ bool IsLevelUpButtonVisible()
686686
if (ControlMode == ControlTypes::VirtualGamepad) {
687687
return false;
688688
}
689-
if (ActiveStore != TalkID::None || IsStashOpen) {
689+
if (IsPlayerInStore() || IsStashOpen) {
690690
return false;
691691
}
692692
if (QuestLogIsOpen && GetLeftPanel().contains(GetMainPanel().position + Displacement { 0, -74 })) {

Source/controls/game_controls.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game
134134
if (ControllerActionHeld == GameActionType_NONE) {
135135
ControllerActionHeld = GameActionType_PRIMARY_ACTION;
136136
}
137-
} else if (sgpCurrentMenu != nullptr || ActiveStore != TalkID::None || QuestLogIsOpen) {
137+
} else if (sgpCurrentMenu != nullptr || IsPlayerInStore() || QuestLogIsOpen) {
138138
*action = GameActionSendKey { SDLK_RETURN, false };
139139
} else {
140140
*action = GameActionSendKey { SDLK_SPACE, false };
@@ -171,12 +171,12 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game
171171
return true;
172172
}
173173
if (VirtualGamepadState.healthButton.isHeld && VirtualGamepadState.healthButton.didStateChange) {
174-
if (!QuestLogIsOpen && !SpellbookFlag && ActiveStore == TalkID::None)
174+
if (!QuestLogIsOpen && !SpellbookFlag && !IsPlayerInStore())
175175
*action = GameAction(GameActionType_USE_HEALTH_POTION);
176176
return true;
177177
}
178178
if (VirtualGamepadState.manaButton.isHeld && VirtualGamepadState.manaButton.didStateChange) {
179-
if (!QuestLogIsOpen && !SpellbookFlag && ActiveStore == TalkID::None)
179+
if (!QuestLogIsOpen && !SpellbookFlag && !IsPlayerInStore())
180180
*action = GameAction(GameActionType_USE_MANA_POTION);
181181
return true;
182182
}
@@ -196,7 +196,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game
196196

197197
SDL_Keycode translation = SDLK_UNKNOWN;
198198

199-
if (gmenu_is_active() || ActiveStore != TalkID::None)
199+
if (gmenu_is_active() || IsPlayerInStore())
200200
translation = TranslateControllerButtonToGameMenuKey(ctrlEvent.button);
201201
else if (inGameMenu)
202202
translation = TranslateControllerButtonToMenuKey(ctrlEvent.button);

Source/controls/plrctrls.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ quest_id pcursquest = Q_INVALID;
6565
*/
6666
bool InGameMenu()
6767
{
68-
return ActiveStore != TalkID::None
68+
return IsPlayerInStore()
6969
|| HelpFlag
7070
|| ChatLogFlag
7171
|| ChatFlag
@@ -1347,7 +1347,7 @@ HandleLeftStickOrDPadFn GetLeftStickOrDPadGameUIHandler()
13471347
if (QuestLogIsOpen) {
13481348
return &QuestLogMove;
13491349
}
1350-
if (ActiveStore != TalkID::None) {
1350+
if (IsPlayerInStore()) {
13511351
return &StoreMove;
13521352
}
13531353
return nullptr;

Source/controls/touch/event_handlers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ bool HandleGameMenuInteraction(const SDL_Event &event)
6363

6464
bool HandleStoreInteraction(const SDL_Event &event)
6565
{
66-
if (ActiveStore == TalkID::None)
66+
if (!IsPlayerInStore())
6767
return false;
6868
if (event.type == SDL_FINGERDOWN)
69-
CheckStoreBtn();
69+
CheckStoreButton();
7070
return true;
7171
}
7272

Source/controls/touch/renderers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ VirtualGamepadButtonType PrimaryActionButtonRenderer::GetButtonType()
430430

431431
VirtualGamepadButtonType PrimaryActionButtonRenderer::GetTownButtonType()
432432
{
433-
if (ActiveStore != TalkID::None || pcursmonst != -1)
433+
if (IsPlayerInStore() || pcursmonst != -1)
434434
return GetTalkButtonType(virtualPadButton->isHeld);
435435
return GetBlankButtonType(virtualPadButton->isHeld);
436436
}

Source/diablo.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ void LeftMouseDown(uint16_t modState)
353353
return;
354354
}
355355

356-
if (ActiveStore != TalkID::None) {
357-
CheckStoreBtn();
356+
if (IsPlayerInStore()) {
357+
CheckStoreButton();
358358
return;
359359
}
360360

@@ -417,8 +417,8 @@ void LeftMouseUp(uint16_t modState)
417417
}
418418
if (LevelButtonDown)
419419
CheckLevelButtonUp();
420-
if (ActiveStore != TalkID::None)
421-
ReleaseStoreBtn();
420+
if (IsPlayerInStore())
421+
ReleaseStoreButton();
422422
}
423423

424424
void RightMouseDown(bool isShiftHeld)
@@ -439,7 +439,7 @@ void RightMouseDown(bool isShiftHeld)
439439
doom_close();
440440
return;
441441
}
442-
if (ActiveStore != TalkID::None)
442+
if (IsPlayerInStore())
443443
return;
444444
if (SpellSelectFlag) {
445445
SetSpell();
@@ -576,7 +576,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
576576
if ((modState & KMOD_ALT) != 0) {
577577
sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen());
578578
SaveOptions();
579-
} else if (ActiveStore != TalkID::None) {
579+
} else if (IsPlayerInStore()) {
580580
StoreEnter();
581581
} else if (QuestLogIsOpen) {
582582
QuestlogEnter();
@@ -585,7 +585,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
585585
}
586586
return;
587587
case SDLK_UP:
588-
if (ActiveStore != TalkID::None) {
588+
if (IsPlayerInStore()) {
589589
StoreUp();
590590
} else if (QuestLogIsOpen) {
591591
QuestlogUp();
@@ -600,7 +600,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
600600
}
601601
return;
602602
case SDLK_DOWN:
603-
if (ActiveStore != TalkID::None) {
603+
if (IsPlayerInStore()) {
604604
StoreDown();
605605
} else if (QuestLogIsOpen) {
606606
QuestlogDown();
@@ -615,14 +615,14 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
615615
}
616616
return;
617617
case SDLK_PAGEUP:
618-
if (ActiveStore != TalkID::None) {
618+
if (IsPlayerInStore()) {
619619
StorePrior();
620620
} else if (ChatLogFlag) {
621621
ChatLogScrollTop();
622622
}
623623
return;
624624
case SDLK_PAGEDOWN:
625-
if (ActiveStore != TalkID::None) {
625+
if (IsPlayerInStore()) {
626626
StoreNext();
627627
} else if (ChatLogFlag) {
628628
ChatLogScrollBottom();
@@ -643,7 +643,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
643643

644644
void HandleMouseButtonDown(Uint8 button, uint16_t modState)
645645
{
646-
if (ActiveStore != TalkID::None && (button == SDL_BUTTON_X1
646+
if (IsPlayerInStore() && (button == SDL_BUTTON_X1
647647
#if !SDL_VERSION_ATLEAST(2, 0, 0)
648648
|| button == 8
649649
#endif
@@ -752,7 +752,7 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState)
752752
#if SDL_VERSION_ATLEAST(2, 0, 0)
753753
case SDL_MOUSEWHEEL:
754754
if (event.wheel.y > 0) { // Up
755-
if (ActiveStore != TalkID::None) {
755+
if (IsPlayerInStore()) {
756756
StoreUp();
757757
} else if (QuestLogIsOpen) {
758758
QuestlogUp();
@@ -766,7 +766,7 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState)
766766
sgOptions.Keymapper.KeyPressed(MouseScrollUpButton);
767767
}
768768
} else if (event.wheel.y < 0) { // down
769-
if (ActiveStore != TalkID::None) {
769+
if (IsPlayerInStore()) {
770770
StoreDown();
771771
} else if (QuestLogIsOpen) {
772772
QuestlogDown();
@@ -1492,7 +1492,7 @@ void HelpKeyPressed()
14921492
{
14931493
if (HelpFlag) {
14941494
HelpFlag = false;
1495-
} else if (ActiveStore != TalkID::None) {
1495+
} else if (IsPlayerInStore()) {
14961496
InfoString = StringOrView {};
14971497
AddInfoBoxString(_("No help available")); /// BUGFIX: message isn't displayed
14981498
AddInfoBoxString(_("while in stores"));
@@ -1516,7 +1516,7 @@ void HelpKeyPressed()
15161516

15171517
void InventoryKeyPressed()
15181518
{
1519-
if (ActiveStore != TalkID::None)
1519+
if (IsPlayerInStore())
15201520
return;
15211521
invflag = !invflag;
15221522
if (!IsLeftPanelOpen() && CanPanelsCoverView()) {
@@ -1537,7 +1537,7 @@ void InventoryKeyPressed()
15371537

15381538
void CharacterSheetKeyPressed()
15391539
{
1540-
if (ActiveStore != TalkID::None)
1540+
if (IsPlayerInStore())
15411541
return;
15421542
if (!IsRightPanelOpen() && CanPanelsCoverView()) {
15431543
if (CharFlag) { // We are closing the character sheet
@@ -1555,7 +1555,7 @@ void CharacterSheetKeyPressed()
15551555

15561556
void QuestLogKeyPressed()
15571557
{
1558-
if (ActiveStore != TalkID::None)
1558+
if (IsPlayerInStore())
15591559
return;
15601560
if (!QuestLogIsOpen) {
15611561
StartQuestlog();
@@ -1580,7 +1580,7 @@ void QuestLogKeyPressed()
15801580

15811581
void DisplaySpellsKeyPressed()
15821582
{
1583-
if (ActiveStore != TalkID::None)
1583+
if (IsPlayerInStore())
15841584
return;
15851585
CloseCharPanel();
15861586
QuestLogIsOpen = false;
@@ -1596,7 +1596,7 @@ void DisplaySpellsKeyPressed()
15961596

15971597
void SpellBookKeyPressed()
15981598
{
1599-
if (ActiveStore != TalkID::None)
1599+
if (IsPlayerInStore())
16001600
return;
16011601
SpellbookFlag = !SpellbookFlag;
16021602
if (!IsLeftPanelOpen() && CanPanelsCoverView()) {
@@ -1761,7 +1761,7 @@ void InitKeymapActions()
17611761
SDLK_F3,
17621762
[] { gamemenu_load_game(false); },
17631763
nullptr,
1764-
[&]() { return !gbIsMultiplayer && gbValidSaveFile && ActiveStore == TalkID::None && IsGameRunning(); });
1764+
[&]() { return !gbIsMultiplayer && gbValidSaveFile && !IsPlayerInStore() && IsGameRunning(); });
17651765
#ifndef NOEXIT
17661766
sgOptions.Keymapper.AddAction(
17671767
"QuitGame",
@@ -2328,7 +2328,7 @@ void InitPadmapActions()
23282328
ControllerButton_NONE,
23292329
[] { gamemenu_load_game(false); },
23302330
nullptr,
2331-
[&]() { return !gbIsMultiplayer && gbValidSaveFile && ActiveStore == TalkID::None && IsGameRunning(); });
2331+
[&]() { return !gbIsMultiplayer && gbValidSaveFile && !IsPlayerInStore() && IsGameRunning(); });
23322332
sgOptions.Padmapper.AddAction(
23332333
"Item Highlighting",
23342334
N_("Item highlighting"),
@@ -2778,7 +2778,7 @@ bool PressEscKey()
27782778
rv = true;
27792779
}
27802780

2781-
if (ActiveStore != TalkID::None) {
2781+
if (IsPlayerInStore()) {
27822782
StoreESC();
27832783
rv = true;
27842784
}

Source/engine/render/scrollrt.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ void DrawItem(const Surface &out, int8_t itemIndex, Point targetBufferPosition,
613613
const Item &item = Items[itemIndex];
614614
const ClxSprite sprite = item.AnimInfo.currentSprite();
615615
const Point position = targetBufferPosition + item.getRenderingOffset(sprite);
616-
if (ActiveStore == TalkID::None && (itemIndex == pcursitem || AutoMapShowItems)) {
616+
if (!IsPlayerInStore() && (itemIndex == pcursitem || AutoMapShowItems)) {
617617
ClxDrawOutlineSkipColorZero(out, GetOutlineColor(item, false), position, sprite);
618618
}
619619
ClxDrawLight(out, position, sprite, lightTableIndex);
@@ -1197,8 +1197,8 @@ void DrawView(const Surface &out, Point startPosition)
11971197
DrawMonsterHealthBar(out);
11981198
DrawFloatingNumbers(out, startPosition, offset);
11991199

1200-
if (ActiveStore != TalkID::None && !qtextflag)
1201-
DrawSText(out);
1200+
if (IsPlayerInStore() && !qtextflag)
1201+
DrawStore(out);
12021202
if (invflag) {
12031203
DrawInv(out);
12041204
} else if (SpellbookFlag) {

Source/inv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,7 @@ bool UseInvItem(int cii)
20072007
return true;
20082008
if (pcurs != CURSOR_HAND)
20092009
return true;
2010-
if (ActiveStore != TalkID::None)
2010+
if (IsPlayerInStore())
20112011
return true;
20122012
if (cii < INVITEM_INV_FIRST)
20132013
return false;

0 commit comments

Comments
 (0)