Browse Source

Fix item label text with open stash (#4595)

* Item labels: check if stash is open in IsMouseOverGameArea

* Add IsLeft/RightPanelOpen
pull/4930/head
obligaron 4 years ago committed by Anders Jenbo
parent
commit
3e2bb7bee4
  1. 14
      Source/automap.cpp
  2. 12
      Source/control.cpp
  3. 2
      Source/control.h
  4. 6
      Source/cursor.cpp
  5. 14
      Source/diablo.cpp
  6. 2
      Source/items.cpp
  7. 4
      Source/player.cpp
  8. 4
      Source/plrmsg.cpp
  9. 5
      Source/qol/itemlabels.cpp
  10. 4
      Source/qol/monhealthbar.cpp
  11. 12
      Source/scrollrt.cpp

14
Source/automap.cpp

@ -10,8 +10,6 @@
#include "control.h"
#include "engine/load_file.hpp"
#include "engine/render/automap_render.hpp"
#include "inv.h"
#include "monster.h"
#include "palette.h"
#include "player.h"
#include "setmaps.h"
@ -376,9 +374,9 @@ void SearchAutomapItem(const Surface &out, const Displacement &myPlayerOffset)
};
if (CanPanelsCoverView()) {
if (invflag || sbookflag)
if (IsRightPanelOpen())
screen.x -= 160;
if (chrflag || QuestLogIsOpen)
if (IsLeftPanelOpen())
screen.x += 160;
}
screen.y -= AmLine8;
@ -413,9 +411,9 @@ void DrawAutomapPlr(const Surface &out, const Displacement &myPlayerOffset, int
};
if (CanPanelsCoverView()) {
if (invflag || sbookflag)
if (IsRightPanelOpen())
base.x -= gnScreenWidth / 4;
if (chrflag || QuestLogIsOpen)
if (IsLeftPanelOpen())
base.x += gnScreenWidth / 4;
}
base.y -= AmLine16;
@ -705,10 +703,10 @@ void DrawAutomap(const Surface &out)
screen.y += AutoMapScale * myPlayerOffset.deltaY / 100 / 2;
if (CanPanelsCoverView()) {
if (invflag || sbookflag) {
if (IsRightPanelOpen()) {
screen.x -= gnScreenWidth / 4;
}
if (chrflag || QuestLogIsOpen) {
if (IsLeftPanelOpen()) {
screen.x += gnScreenWidth / 4;
}
}

12
Source/control.cpp

@ -97,6 +97,14 @@ const Rectangle &GetRightPanel()
{
return RightPanel;
}
bool IsLeftPanelOpen()
{
return chrflag || QuestLogIsOpen || IsStashOpen;
}
bool IsRightPanelOpen()
{
return invflag || sbookflag;
}
/** Maps from attribute_id to the rectangle on screen used for attribute increment buttons. */
Rectangle ChrBtnsRect[4] = {
@ -997,13 +1005,13 @@ void DrawDurIcon(const Surface &out)
bool hasRoomUnderPanels = MainPanel.position.y - (RightPanel.position.y + RightPanel.size.height) >= 16 + 32 + 16;
if (!hasRoomBetweenPanels && !hasRoomUnderPanels) {
if ((chrflag || QuestLogIsOpen || IsStashOpen) && (invflag || sbookflag))
if (IsLeftPanelOpen() && IsRightPanelOpen())
return;
}
int x = MainPanel.position.x + MainPanel.size.width - 32 - 16;
if (!hasRoomUnderPanels) {
if ((invflag || sbookflag) && MainPanel.position.x + MainPanel.size.width > RightPanel.position.x)
if (IsRightPanelOpen() && MainPanel.position.x + MainPanel.size.width > RightPanel.position.x)
x -= MainPanel.position.x + MainPanel.size.width - RightPanel.position.x;
}

2
Source/control.h

@ -55,6 +55,8 @@ extern bool spselflag;
const Rectangle &GetMainPanel();
const Rectangle &GetLeftPanel();
const Rectangle &GetRightPanel();
bool IsLeftPanelOpen();
bool IsRightPanelOpen();
extern std::optional<OwnedSurface> pBtmBuff;
extern std::optional<OwnedCelSprite> pGBoxBuff;
extern SDL_Rect PanBtnPos[8];

6
Source/cursor.cpp

@ -263,9 +263,9 @@ void CheckCursMove()
int sy = MousePosition.y;
if (CanPanelsCoverView()) {
if (chrflag || QuestLogIsOpen || IsStashOpen) {
if (IsLeftPanelOpen()) {
sx -= GetScreenWidth() / 4;
} else if (invflag || sbookflag) {
} else if (IsRightPanelOpen()) {
sx += GetScreenWidth() / 4;
}
}
@ -400,7 +400,7 @@ void CheckCursMove()
if (sbookflag && GetRightPanel().Contains(MousePosition)) {
return;
}
if ((chrflag || QuestLogIsOpen || IsStashOpen) && GetLeftPanel().Contains(MousePosition)) {
if (IsLeftPanelOpen() && GetLeftPanel().Contains(MousePosition)) {
return;
}

14
Source/diablo.cpp

@ -430,9 +430,9 @@ void ReleaseKey(int vkey)
void ClosePanels()
{
if (CanPanelsCoverView()) {
if (!chrflag && !QuestLogIsOpen && !IsStashOpen && (invflag || sbookflag) && MousePosition.x < 480 && MousePosition.y < PANEL_TOP) {
if (!IsLeftPanelOpen() && IsRightPanelOpen() && MousePosition.x < 480 && MousePosition.y < PANEL_TOP) {
SetCursorPos(MousePosition + Displacement { 160, 0 });
} else if (!invflag && !sbookflag && (chrflag || QuestLogIsOpen) && MousePosition.x > 160 && MousePosition.y < PANEL_TOP) {
} else if (!IsRightPanelOpen() && IsLeftPanelOpen() && MousePosition.x > 160 && MousePosition.y < PANEL_TOP) {
SetCursorPos(MousePosition - Displacement { 160, 0 });
}
}
@ -1355,7 +1355,7 @@ void InventoryKeyPressed()
if (stextflag != STORE_NONE)
return;
invflag = !invflag;
if (!chrflag && !QuestLogIsOpen && !IsStashOpen && CanPanelsCoverView()) {
if (!IsLeftPanelOpen() && CanPanelsCoverView()) {
if (!invflag) { // We closed the invetory
if (MousePosition.x < 480 && MousePosition.y < GetMainPanel().position.y) {
SetCursorPos(MousePosition + Displacement { 160, 0 });
@ -1376,7 +1376,7 @@ void CharacterSheetKeyPressed()
if (stextflag != STORE_NONE)
return;
chrflag = !chrflag;
if (!invflag && !sbookflag && CanPanelsCoverView()) {
if (!IsRightPanelOpen() && CanPanelsCoverView()) {
if (!chrflag) { // We closed the character sheet
if (MousePosition.x > 160 && MousePosition.y < GetMainPanel().position.y) {
SetCursorPos(MousePosition - Displacement { 160, 0 });
@ -1401,7 +1401,7 @@ void QuestLogKeyPressed()
} else {
QuestLogIsOpen = false;
}
if (!invflag && !sbookflag && CanPanelsCoverView()) {
if (!IsRightPanelOpen() && CanPanelsCoverView()) {
if (!QuestLogIsOpen) { // We closed the quest log
if (MousePosition.x > 160 && MousePosition.y < PANEL_TOP) {
SetCursorPos(MousePosition - Displacement { 160, 0 });
@ -1438,7 +1438,7 @@ void SpellBookKeyPressed()
if (stextflag != STORE_NONE)
return;
sbookflag = !sbookflag;
if (!chrflag && !QuestLogIsOpen && CanPanelsCoverView()) {
if (!IsLeftPanelOpen() && CanPanelsCoverView()) {
if (!sbookflag) { // We closed the invetory
if (MousePosition.x < 480 && MousePosition.y < GetMainPanel().position.y) {
SetCursorPos(MousePosition + Displacement { 160, 0 });
@ -2042,7 +2042,7 @@ bool PressEscKey()
rv = true;
}
if (invflag || chrflag || sbookflag || QuestLogIsOpen) {
if (IsLeftPanelOpen() || IsRightPanelOpen()) {
ClosePanels();
rv = true;
}

2
Source/items.cpp

@ -3770,7 +3770,7 @@ bool DoOil(Player &player, int cii)
void DrawUniqueInfo(const Surface &out)
{
const Point position = GetRightPanel().position - Displacement { SPANEL_WIDTH, 0 };
if ((chrflag || QuestLogIsOpen || IsStashOpen) && GetLeftPanel().Contains(position)) {
if (IsLeftPanelOpen() && GetLeftPanel().Contains(position)) {
return;
}

4
Source/player.cpp

@ -3568,8 +3568,8 @@ void CheckPlrSpell(bool isShiftHeld, spell_id spellID, spell_type spellType)
return;
if (
((chrflag || QuestLogIsOpen || IsStashOpen) && GetLeftPanel().Contains(MousePosition)) // inside left panel
|| ((invflag || sbookflag) && GetRightPanel().Contains(MousePosition)) // inside right panel
(IsLeftPanelOpen() && GetLeftPanel().Contains(MousePosition)) // inside left panel
|| (IsRightPanelOpen() && GetRightPanel().Contains(MousePosition)) // inside right panel
) {
if (spellID != SPL_HEAL
&& spellID != SPL_IDENTIFY

4
Source/plrmsg.cpp

@ -104,11 +104,11 @@ void DrawPlrMsg(const Surface &out)
int y = PANEL_TOP - 13;
int width = gnScreenWidth - 20;
if (!talkflag && (chrflag || QuestLogIsOpen || IsStashOpen)) {
if (!talkflag && IsLeftPanelOpen()) {
x += GetLeftPanel().position.x + GetLeftPanel().size.width;
width -= GetLeftPanel().size.width;
}
if (!talkflag && (invflag || sbookflag))
if (!talkflag && IsRightPanelOpen())
width -= gnScreenWidth - GetRightPanel().position.x;
if (width < 300)

5
Source/qol/itemlabels.cpp

@ -13,6 +13,7 @@
#include "gmenu.h"
#include "inv.h"
#include "itemlabels.h"
#include "qol/stash.h"
#include "utils/language.h"
#include "utils/stdcompat/string_view.hpp"
@ -94,9 +95,9 @@ void AddItemToLabelQueue(int id, int x, int y)
bool IsMouseOverGameArea()
{
if ((invflag || sbookflag) && GetRightPanel().Contains(MousePosition))
if ((IsRightPanelOpen()) && GetRightPanel().Contains(MousePosition))
return false;
if ((chrflag || QuestLogIsOpen) && GetLeftPanel().Contains(MousePosition))
if ((IsLeftPanelOpen()) && GetLeftPanel().Contains(MousePosition))
return false;
if (GetMainPanel().Contains(MousePosition))
return false;

4
Source/qol/monhealthbar.cpp

@ -68,9 +68,9 @@ void DrawMonsterHealthBar(const Surface &out)
Point position = { (gnScreenWidth - width) / 2, 18 };
if (CanPanelsCoverView()) {
if (invflag || sbookflag)
if (IsRightPanelOpen())
position.x -= SPANEL_WIDTH / 2;
if (chrflag || QuestLogIsOpen)
if (IsLeftPanelOpen())
position.x += SPANEL_WIDTH / 2;
}

12
Source/scrollrt.cpp

@ -1021,10 +1021,10 @@ void Zoom(const Surface &out)
int viewportWidth = out.w();
int viewportOffsetX = 0;
if (CanPanelsCoverView()) {
if (chrflag || QuestLogIsOpen || IsStashOpen) {
if (IsLeftPanelOpen()) {
viewportWidth -= SPANEL_WIDTH;
viewportOffsetX = SPANEL_WIDTH;
} else if (invflag || sbookflag) {
} else if (IsRightPanelOpen()) {
viewportWidth -= SPANEL_WIDTH;
}
}
@ -1101,23 +1101,23 @@ void DrawGame(const Surface &fullOut, Point position)
// Skip rendering parts covered by the panels
if (CanPanelsCoverView()) {
if (zoomflag) {
if (chrflag || QuestLogIsOpen || IsStashOpen) {
if (IsLeftPanelOpen()) {
position += Displacement(Direction::East) * 2;
columns -= 4;
sx += SPANEL_WIDTH - TILE_WIDTH / 2;
}
if (invflag || sbookflag) {
if (IsRightPanelOpen()) {
position += Displacement(Direction::East) * 2;
columns -= 4;
sx += -TILE_WIDTH / 2;
}
} else {
if (chrflag || QuestLogIsOpen || IsStashOpen) {
if (IsLeftPanelOpen()) {
position += Direction::East;
columns -= 2;
sx += -TILE_WIDTH / 2 / 2; // SPANEL_WIDTH accounted for in Zoom()
}
if (invflag || sbookflag) {
if (IsRightPanelOpen()) {
position += Direction::East;
columns -= 2;
sx += -TILE_WIDTH / 2 / 2;

Loading…
Cancel
Save