Browse Source

Clean ups

inv
Anders Jenbo 4 years ago
parent
commit
a76e24d386
  1. 98
      Source/control.cpp
  2. 18
      Source/control.h
  3. 16
      Source/controls/plrctrls.cpp
  4. 13
      Source/controls/touch/renderers.cpp
  5. 22
      Source/diablo.cpp
  6. 4
      Source/error.cpp
  7. 4
      Source/help.cpp
  8. 39
      Source/inv.cpp
  9. 1
      Source/inv.h
  10. 6
      Source/items.cpp
  11. 2
      Source/items.h
  12. 4
      Source/minitext.cpp
  13. 6
      Source/miniwin/misc_msg.cpp
  14. 4
      Source/objects.cpp
  15. 4
      Source/panels/spell_list.cpp
  16. 4
      Source/qol/chatlog.cpp
  17. 30
      Source/scrollrt.cpp

98
Source/control.cpp

@ -57,10 +57,9 @@ namespace devilution {
* @brief Set if the life flask needs to be redrawn during next frame * @brief Set if the life flask needs to be redrawn during next frame
*/ */
bool drawhpflag; bool drawhpflag;
bool dropGoldFlag; bool IsDropGoldOpen;
bool chrbtn[4]; bool chrbtn[4];
bool lvlbtndown; int DropGoldValue;
int dropGoldValue;
/** /**
* @brief Set if the mana flask needs to be redrawn during the next frame * @brief Set if the mana flask needs to be redrawn during the next frame
*/ */
@ -69,14 +68,14 @@ bool chrbtnactive;
int pnumlines; int pnumlines;
UiFlags InfoColor; UiFlags InfoColor;
int sbooktab; int sbooktab;
int8_t initialDropGoldIndex; int8_t InitialDropGoldIndex;
bool talkflag; bool talkflag;
bool sbookflag; bool sbookflag;
bool chrflag; bool chrflag;
bool drawbtnflag; bool drawbtnflag;
std::string InfoString; std::string InfoString;
bool panelflag; bool panelflag;
int initialDropGoldValue; int InitialDropGoldValue;
bool panbtndown; bool panbtndown;
bool spselflag; bool spselflag;
Rectangle MainPanel; Rectangle MainPanel;
@ -129,6 +128,7 @@ std::optional<OwnedCelSprite> pDurIcons;
std::optional<OwnedCelSprite> multiButtons; std::optional<OwnedCelSprite> multiButtons;
std::optional<OwnedCelSprite> pPanelButtons; std::optional<OwnedCelSprite> pPanelButtons;
bool IsLevelUpButtonPressed;
bool PanelButtons[8]; bool PanelButtons[8];
int PanelButtonIndex; int PanelButtonIndex;
char TalkSave[8][MAX_SEND_STR_LEN]; char TalkSave[8][MAX_SEND_STR_LEN];
@ -364,17 +364,17 @@ void ControlUpDown(int v)
void RemoveGold(Player &player, int goldIndex) void RemoveGold(Player &player, int goldIndex)
{ {
int gi = goldIndex - INVITEM_INV_FIRST; int gi = goldIndex - INVITEM_INV_FIRST;
player.InvList[gi]._ivalue -= dropGoldValue; player.InvList[gi]._ivalue -= DropGoldValue;
if (player.InvList[gi]._ivalue > 0) if (player.InvList[gi]._ivalue > 0)
SetPlrHandGoldCurs(player.InvList[gi]); SetPlrHandGoldCurs(player.InvList[gi]);
else else
player.RemoveInvItem(gi); player.RemoveInvItem(gi);
MakeGoldStack(player.HoldItem, dropGoldValue); MakeGoldStack(player.HoldItem, DropGoldValue);
NewCursor(player.HoldItem._iCurs + CURSOR_FIRSTITEM); NewCursor(player.HoldItem._iCurs + CURSOR_FIRSTITEM);
player._pGold = CalculateGold(player); player._pGold = CalculateGold(player);
dropGoldValue = 0; DropGoldValue = 0;
} }
bool IsLevelUpButtonVisible() bool IsLevelUpButtonVisible()
@ -549,7 +549,7 @@ void InitControlPan()
} }
LoadMainPanel(); LoadMainPanel();
panelflag = false; panelflag = false;
lvlbtndown = false; IsLevelUpButtonPressed = false;
pPanelButtons = LoadCel("CtrlPan\\Panel8bu.CEL", 71); pPanelButtons = LoadCel("CtrlPan\\Panel8bu.CEL", 71);
ClearPanBtn(); ClearPanBtn();
if (!IsChatAvailable()) if (!IsChatAvailable())
@ -574,9 +574,9 @@ void InitControlPan()
pQLogCel = LoadCel("Data\\Quest.CEL", SPANEL_WIDTH); pQLogCel = LoadCel("Data\\Quest.CEL", SPANEL_WIDTH);
pGBoxBuff = LoadCel("CtrlPan\\Golddrop.cel", 261); pGBoxBuff = LoadCel("CtrlPan\\Golddrop.cel", 261);
CloseGoldDrop(); CloseGoldDrop();
dropGoldValue = 0; DropGoldValue = 0;
initialDropGoldValue = 0; InitialDropGoldValue = 0;
initialDropGoldIndex = 0; InitialDropGoldIndex = 0;
CalculatePanelAreas(); CalculatePanelAreas();
@ -792,16 +792,16 @@ void CheckBtnUp()
sbookflag = false; sbookflag = false;
IsStashOpen = false; IsStashOpen = false;
invflag = !invflag; invflag = !invflag;
if (dropGoldFlag) { if (IsDropGoldOpen) {
CloseGoldDrop(); CloseGoldDrop();
dropGoldValue = 0; DropGoldValue = 0;
} }
break; break;
case PanelButtonSpellbook: case PanelButtonSpellbook:
CloseInventory(); CloseInventory();
if (dropGoldFlag) { if (IsDropGoldOpen) {
CloseGoldDrop(); CloseGoldDrop();
dropGoldValue = 0; DropGoldValue = 0;
} }
sbookflag = !sbookflag; sbookflag = !sbookflag;
break; break;
@ -899,35 +899,43 @@ void DrawInfoBox(const Surface &out)
PrintInfo(out); PrintInfo(out);
} }
void CheckLvlBtn() bool CheckLevelUpButtonPress()
{ {
if (!IsLevelUpButtonVisible()) { if (!IsLevelUpButtonVisible()) {
return; return false;
} }
auto &mainPanelPosition = GetMainPanel().position; Rectangle button = { GetPanelPosition(UiPanels::Main, { 40, -39 }), { 41, 22 } };
if (!lvlbtndown && MousePosition.x >= 40 + mainPanelPosition.x && MousePosition.x <= 81 + mainPanelPosition.x && MousePosition.y >= -39 + mainPanelPosition.y && MousePosition.y <= -17 + mainPanelPosition.y) if (button.Contains(MousePosition)) {
lvlbtndown = true; IsLevelUpButtonPressed = true;
}
return IsLevelUpButtonPressed;
} }
void ReleaseLvlBtn() void CheckLevelUpButtonRelease()
{ {
auto &mainPanelPosition = GetMainPanel().position; if (!IsLevelUpButtonPressed) {
if (MousePosition.x >= 40 + mainPanelPosition.x && MousePosition.x <= 81 + mainPanelPosition.x && MousePosition.y >= -39 + mainPanelPosition.y && MousePosition.y <= -17 + mainPanelPosition.y) { return;
}
Rectangle button = { GetPanelPosition(UiPanels::Main, { 40, -39 }), { 41, 22 } };
if (button.Contains(MousePosition)) {
QuestLogIsOpen = false; QuestLogIsOpen = false;
IsStashOpen = false; IsStashOpen = false;
chrflag = true; chrflag = true;
} }
lvlbtndown = false; IsLevelUpButtonPressed = false;
} }
void DrawLevelUpIcon(const Surface &out) void DrawLevelUpButton(const Surface &out)
{ {
if (IsLevelUpButtonVisible()) { if (!IsLevelUpButtonVisible()) {
int nCel = lvlbtndown ? 3 : 2; return;
DrawString(out, _("Level Up"), { { PANEL_LEFT + 0, PANEL_TOP - 62 }, { 120, 0 } }, UiFlags::ColorWhite | UiFlags::AlignCenter);
CelDrawTo(out, { 40 + PANEL_X, -17 + PANEL_Y }, *pChrButtons, nCel);
} }
DrawString(out, _("Level Up"), { { PANEL_LEFT + 0, PANEL_TOP - 62 }, { 120, 0 } }, UiFlags::ColorWhite | UiFlags::AlignCenter);
CelDrawTo(out, { 40 + PANEL_X, -17 + PANEL_Y }, *pChrButtons, IsLevelUpButtonPressed ? 3 : 2);
} }
void CheckChrBtns() void CheckChrBtns()
@ -1026,6 +1034,10 @@ void RedBack(const Surface &out)
void DrawGoldSplit(const Surface &out, int amount) void DrawGoldSplit(const Surface &out, int amount)
{ {
if (!IsDropGoldOpen) {
return;
}
const int dialogX = 30; const int dialogX = 30;
CelDrawTo(out, GetPanelPosition(UiPanels::Inventory, { dialogX, 178 }), *pGBoxBuff, 1); CelDrawTo(out, GetPanelPosition(UiPanels::Inventory, { dialogX, 178 }), *pGBoxBuff, 1);
@ -1035,8 +1047,8 @@ void DrawGoldSplit(const Surface &out, int amount)
ngettext( ngettext(
"You have {:d} gold piece. How many do you want to remove?", "You have {:d} gold piece. How many do you want to remove?",
"You have {:d} gold pieces. How many do you want to remove?", "You have {:d} gold pieces. How many do you want to remove?",
initialDropGoldValue), InitialDropGoldValue),
initialDropGoldValue); InitialDropGoldValue);
// Pre-wrap the string at spaces, otherwise DrawString would hard wrap in the middle of words // Pre-wrap the string at spaces, otherwise DrawString would hard wrap in the middle of words
const std::string wrapped = WordWrapString(description, 200); const std::string wrapped = WordWrapString(description, 200);
@ -1055,25 +1067,25 @@ void DrawGoldSplit(const Surface &out, int amount)
DrawString(out, value, GetPanelPosition(UiPanels::Inventory, { dialogX + 37, 128 }), UiFlags::ColorWhite | UiFlags::PentaCursor); DrawString(out, value, GetPanelPosition(UiPanels::Inventory, { dialogX + 37, 128 }), UiFlags::ColorWhite | UiFlags::PentaCursor);
} }
void control_drop_gold(char vkey) void DropGoldKeyPress(char vkey)
{ {
auto &myPlayer = Players[MyPlayerId]; auto &myPlayer = Players[MyPlayerId];
if (myPlayer._pHitPoints >> 6 <= 0) { if (myPlayer._pHitPoints >> 6 <= 0) {
CloseGoldDrop(); CloseGoldDrop();
dropGoldValue = 0; DropGoldValue = 0;
return; return;
} }
if (vkey == DVL_VK_RETURN) { if (vkey == DVL_VK_RETURN) {
if (dropGoldValue > 0) if (DropGoldValue > 0)
RemoveGold(myPlayer, initialDropGoldIndex); RemoveGold(myPlayer, InitialDropGoldIndex);
CloseGoldDrop(); CloseGoldDrop();
} else if (vkey == DVL_VK_ESCAPE) { } else if (vkey == DVL_VK_ESCAPE) {
CloseGoldDrop(); CloseGoldDrop();
dropGoldValue = 0; DropGoldValue = 0;
} else if (vkey == DVL_VK_BACK) { } else if (vkey == DVL_VK_BACK) {
dropGoldValue /= 10; DropGoldValue /= 10;
} }
} }
@ -1271,9 +1283,9 @@ void DiabloHotkeyMsg(uint32_t dwMsg)
void CloseGoldDrop() void CloseGoldDrop()
{ {
if (!dropGoldFlag) if (!IsDropGoldOpen)
return; return;
dropGoldFlag = false; IsDropGoldOpen = false;
SDL_StopTextInput(); SDL_StopTextInput();
} }
@ -1282,10 +1294,10 @@ void GoldDropNewText(string_view text)
for (char vkey : text) { for (char vkey : text) {
int digit = vkey - '0'; int digit = vkey - '0';
if (digit >= 0 && digit <= 9) { if (digit >= 0 && digit <= 9) {
int newGoldValue = dropGoldValue * 10; int newGoldValue = DropGoldValue * 10;
newGoldValue += digit; newGoldValue += digit;
if (newGoldValue <= initialDropGoldValue) { if (newGoldValue <= InitialDropGoldValue) {
dropGoldValue = newGoldValue; DropGoldValue = newGoldValue;
} }
} }
} }

18
Source/control.h

@ -33,25 +33,25 @@ namespace devilution {
#define SPANEL_HEIGHT 352 #define SPANEL_HEIGHT 352
extern bool drawhpflag; extern bool drawhpflag;
extern bool dropGoldFlag; extern bool IsDropGoldOpen;
extern bool chrbtn[4]; extern bool chrbtn[4];
extern bool lvlbtndown; extern int DropGoldValue;
extern int dropGoldValue;
extern bool drawmanaflag; extern bool drawmanaflag;
extern bool chrbtnactive; extern bool chrbtnactive;
extern DVL_API_FOR_TEST int pnumlines; extern DVL_API_FOR_TEST int pnumlines;
extern UiFlags InfoColor; extern UiFlags InfoColor;
extern int sbooktab; extern int sbooktab;
extern int8_t initialDropGoldIndex; extern int8_t InitialDropGoldIndex;
extern bool talkflag; extern bool talkflag;
extern bool sbookflag; extern bool sbookflag;
extern bool chrflag; extern bool chrflag;
extern bool drawbtnflag; extern bool drawbtnflag;
extern std::string InfoString; extern std::string InfoString;
extern bool panelflag; extern bool panelflag;
extern int initialDropGoldValue; extern int InitialDropGoldValue;
extern bool panbtndown; extern bool panbtndown;
extern bool spselflag; extern bool spselflag;
const Rectangle &GetMainPanel(); const Rectangle &GetMainPanel();
const Rectangle &GetLeftPanel(); const Rectangle &GetLeftPanel();
const Rectangle &GetRightPanel(); const Rectangle &GetRightPanel();
@ -163,16 +163,16 @@ void FreeControlPan();
* Sets a string to be drawn in the info box and then draws it. * Sets a string to be drawn in the info box and then draws it.
*/ */
void DrawInfoBox(const Surface &out); void DrawInfoBox(const Surface &out);
void CheckLvlBtn(); bool CheckLevelUpButtonPress();
void ReleaseLvlBtn(); void CheckLevelUpButtonRelease();
void DrawLevelUpIcon(const Surface &out); void DrawLevelUpButton(const Surface &out);
void CheckChrBtns(); void CheckChrBtns();
void ReleaseChrBtns(bool addAllStatPoints); void ReleaseChrBtns(bool addAllStatPoints);
void DrawDurIcon(const Surface &out); void DrawDurIcon(const Surface &out);
void RedBack(const Surface &out); void RedBack(const Surface &out);
void DrawSpellBook(const Surface &out); void DrawSpellBook(const Surface &out);
void DrawGoldSplit(const Surface &out, int amount); void DrawGoldSplit(const Surface &out, int amount);
void control_drop_gold(char vkey); void DropGoldKeyPress(char vkey);
void DrawTalkPan(const Surface &out); void DrawTalkPan(const Surface &out);
bool control_check_talk_btn(); bool control_check_talk_btn();
void control_release_talk_btn(); void control_release_talk_btn();

16
Source/controls/plrctrls.cpp

@ -1727,26 +1727,16 @@ void PerformSpellAction()
void CtrlUseInvItem() void CtrlUseInvItem()
{ {
Item *item;
if (pcursinvitem == -1) if (pcursinvitem == -1)
return; return;
auto &myPlayer = Players[MyPlayerId]; const Item &item = GetInventoryItem(pcursinvitem);
if (item.IsScroll() && spelldata[item._iSpell].sTargeted) {
if (pcursinvitem < INVITEM_INV_FIRST)
item = &myPlayer.InvBody[pcursinvitem];
else if (pcursinvitem <= INVITEM_INV_LAST)
item = &myPlayer.InvList[pcursinvitem - INVITEM_INV_FIRST];
else
item = &myPlayer.SpdList[pcursinvitem - INVITEM_BELT_FIRST];
if (item->IsScroll() && spelldata[item->_iSpell].sTargeted) {
return; return;
} }
int itemId = GetItemIdOnSlot(Slot); int itemId = GetItemIdOnSlot(Slot);
if (item->isEquipment()) { if (item.isEquipment()) {
CheckInvItem(true, false); // auto-equip if it's an equipment CheckInvItem(true, false); // auto-equip if it's an equipment
} else { } else {
UseInvItem(MyPlayerId, pcursinvitem); UseInvItem(MyPlayerId, pcursinvitem);

13
Source/controls/touch/renderers.cpp

@ -455,16 +455,9 @@ VirtualGamepadButtonType SecondaryActionButtonRenderer::GetButtonType()
return GetApplyButtonType(virtualPadButton->isHeld); return GetApplyButtonType(virtualPadButton->isHeld);
if (pcursinvitem != -1) { if (pcursinvitem != -1) {
Item *item; const Item &item = GetInventoryItem(pcursinvitem);
if (pcursinvitem < INVITEM_INV_FIRST) if (!item.IsScroll() || !spelldata[item._iSpell].sTargeted) {
item = &MyPlayer->InvBody[pcursinvitem]; if (!item.isEquipment()) {
else if (pcursinvitem <= INVITEM_INV_LAST)
item = &MyPlayer->InvList[pcursinvitem - INVITEM_INV_FIRST];
else
item = &MyPlayer->SpdList[pcursinvitem - INVITEM_BELT_FIRST];
if (!item->IsScroll() || !spelldata[item->_iSpell].sTargeted) {
if (!item->isEquipment()) {
return GetApplyButtonType(virtualPadButton->isHeld); return GetApplyButtonType(virtualPadButton->isHeld);
} }
} }

22
Source/diablo.cpp

@ -334,7 +334,7 @@ void LeftMouseDown(int wParam)
} else if (chrflag && GetLeftPanel().Contains(MousePosition)) { } else if (chrflag && GetLeftPanel().Contains(MousePosition)) {
CheckChrBtns(); CheckChrBtns();
} else if (invflag && GetRightPanel().Contains(MousePosition)) { } else if (invflag && GetRightPanel().Contains(MousePosition)) {
if (!dropGoldFlag) if (!IsDropGoldOpen)
CheckInvItem(isShiftHeld, isCtrlHeld); CheckInvItem(isShiftHeld, isCtrlHeld);
} else if (IsStashOpen && GetLeftPanel().Contains(MousePosition)) { } else if (IsStashOpen && GetLeftPanel().Contains(MousePosition)) {
if (!IsWithdrawGoldOpen) if (!IsWithdrawGoldOpen)
@ -348,13 +348,12 @@ void LeftMouseDown(int wParam)
NewCursor(CURSOR_HAND); NewCursor(CURSOR_HAND);
} }
} else { } else {
CheckLvlBtn(); if (!CheckLevelUpButtonPress())
if (!lvlbtndown)
LeftMouseCmd(isShiftHeld); LeftMouseCmd(isShiftHeld);
} }
} }
} else { } else {
if (!talkflag && !dropGoldFlag && !IsWithdrawGoldOpen && !gmenu_is_active()) if (!talkflag && !IsDropGoldOpen && !IsWithdrawGoldOpen && !gmenu_is_active())
CheckInvScrn(isShiftHeld, isCtrlHeld); CheckInvScrn(isShiftHeld, isCtrlHeld);
DoPanBtn(); DoPanBtn();
CheckStashButtonPress(MousePosition); CheckStashButtonPress(MousePosition);
@ -373,8 +372,7 @@ void LeftMouseUp(int wParam)
CheckStashButtonRelease(MousePosition); CheckStashButtonRelease(MousePosition);
if (chrbtnactive) if (chrbtnactive)
ReleaseChrBtns(isShiftHeld); ReleaseChrBtns(isShiftHeld);
if (lvlbtndown) CheckLevelUpButtonRelease();
ReleaseLvlBtn();
if (stextflag != STORE_NONE) if (stextflag != STORE_NONE)
ReleaseStoreBtn(); ReleaseStoreBtn();
} }
@ -422,7 +420,7 @@ bool PressSysKey(int wParam)
void ReleaseKey(int vkey) void ReleaseKey(int vkey)
{ {
if (sgnTimeoutCurs != CURSOR_NONE || dropGoldFlag) if (sgnTimeoutCurs != CURSOR_NONE || IsDropGoldOpen)
return; return;
sgOptions.Keymapper.KeyReleased(vkey); sgOptions.Keymapper.KeyReleased(vkey);
} }
@ -473,7 +471,7 @@ void PressKey(int vkey)
return; return;
} }
if (sgnTimeoutCurs != CURSOR_NONE || dropGoldFlag || IsWithdrawGoldOpen) { if (sgnTimeoutCurs != CURSOR_NONE || IsDropGoldOpen || IsWithdrawGoldOpen) {
return; return;
} }
@ -568,8 +566,8 @@ void PressChar(char vkey)
doom_close(); doom_close();
return; return;
} }
if (dropGoldFlag) { if (IsDropGoldOpen) {
control_drop_gold(vkey); DropGoldKeyPress(vkey);
return; return;
} }
if (IsWithdrawGoldOpen) { if (IsWithdrawGoldOpen) {
@ -1978,8 +1976,8 @@ bool PressEscKey()
rv = true; rv = true;
} }
if (dropGoldFlag) { if (IsDropGoldOpen) {
control_drop_gold(DVL_VK_ESCAPE); DropGoldKeyPress(DVL_VK_ESCAPE);
rv = true; rv = true;
} }

4
Source/error.cpp

@ -143,6 +143,10 @@ void ClrDiabloMsg()
void DrawDiabloMsg(const Surface &out) void DrawDiabloMsg(const Surface &out)
{ {
if (!IsDiabloMsgAvailable()) {
return;
}
int dialogStartY = ((gnScreenHeight - PANEL_HEIGHT) / 2) - (ErrorWindowHeight / 2) + 9; int dialogStartY = ((gnScreenHeight - PANEL_HEIGHT) / 2) - (ErrorWindowHeight / 2) + 9;
CelDrawTo(out, { PANEL_X + 101, dialogStartY }, *pSTextSlidCels, 1); CelDrawTo(out, { PANEL_X + 101, dialogStartY }, *pSTextSlidCels, 1);

4
Source/help.cpp

@ -166,6 +166,10 @@ void InitHelp()
void DrawHelp(const Surface &out) void DrawHelp(const Surface &out)
{ {
if (!HelpFlag) {
return;
}
DrawSTextHelp(); DrawSTextHelp();
DrawQTextBack(out); DrawQTextBack(out);

39
Source/inv.cpp

@ -610,9 +610,9 @@ void CheckInvCut(int pnum, Point cursorPosition, bool automaticMove, bool dropIt
return; return;
} }
if (dropGoldFlag) { if (IsDropGoldOpen) {
CloseGoldDrop(); CloseGoldDrop();
dropGoldValue = 0; DropGoldValue = 0;
} }
bool done = false; bool done = false;
@ -1099,14 +1099,14 @@ void StartGoldDrop()
{ {
CloseGoldWithdraw(); CloseGoldWithdraw();
initialDropGoldIndex = pcursinvitem; InitialDropGoldIndex = pcursinvitem;
auto &myPlayer = Players[MyPlayerId]; auto &myPlayer = Players[MyPlayerId];
if (pcursinvitem <= INVITEM_INV_LAST) if (pcursinvitem <= INVITEM_INV_LAST)
initialDropGoldValue = myPlayer.InvList[pcursinvitem - INVITEM_INV_FIRST]._ivalue; InitialDropGoldValue = myPlayer.InvList[pcursinvitem - INVITEM_INV_FIRST]._ivalue;
else else
initialDropGoldValue = myPlayer.SpdList[pcursinvitem - INVITEM_BELT_FIRST]._ivalue; InitialDropGoldValue = myPlayer.SpdList[pcursinvitem - INVITEM_BELT_FIRST]._ivalue;
if (talkflag) if (talkflag)
control_reset_talk(); control_reset_talk();
@ -1115,8 +1115,8 @@ void StartGoldDrop()
SDL_Rect rect = MakeSdlRect(start.x, start.y, 180, 20); SDL_Rect rect = MakeSdlRect(start.x, start.y, 180, 20);
SDL_SetTextInputRect(&rect); SDL_SetTextInputRect(&rect);
dropGoldFlag = true; IsDropGoldOpen = true;
dropGoldValue = 0; DropGoldValue = 0;
SDL_StartTextInput(); SDL_StartTextInput();
} }
@ -1616,9 +1616,9 @@ void CheckInvScrn(bool isShiftHeld, bool isCtrlHeld)
void InvGetItem(int pnum, int ii) void InvGetItem(int pnum, int ii)
{ {
auto &item = Items[ii]; auto &item = Items[ii];
if (dropGoldFlag) { if (IsDropGoldOpen) {
CloseGoldDrop(); CloseGoldDrop();
dropGoldValue = 0; DropGoldValue = 0;
} }
if (dItem[item.position.x][item.position.y] == 0) if (dItem[item.position.x][item.position.y] == 0)
@ -1648,9 +1648,9 @@ void AutoGetItem(int pnum, Item *itemPointer, int ii)
Item &item = *itemPointer; Item &item = *itemPointer;
auto &player = Players[pnum]; auto &player = Players[pnum];
if (dropGoldFlag) { if (IsDropGoldOpen) {
CloseGoldDrop(); CloseGoldDrop();
dropGoldValue = 0; DropGoldValue = 0;
} }
if (dItem[item.position.x][item.position.y] == 0) if (dItem[item.position.x][item.position.y] == 0)
@ -2040,6 +2040,19 @@ bool UseStaff()
return CanUseStaff(myPlayer.InvBody[INVLOC_HAND_LEFT], myPlayer._pRSpell); return CanUseStaff(myPlayer.InvBody[INVLOC_HAND_LEFT], myPlayer._pRSpell);
} }
const Item &GetInventoryItem(int location)
{
Player &myPlayer = Players[MyPlayerId];
if (location < INVITEM_INV_FIRST)
return myPlayer.InvBody[location];
if (location <= INVITEM_INV_LAST)
return myPlayer.InvList[location - INVITEM_INV_FIRST];
return myPlayer.SpdList[location - INVITEM_BELT_FIRST];
}
bool UseInvItem(int pnum, int cii) bool UseInvItem(int pnum, int cii)
{ {
int c; int c;
@ -2117,9 +2130,9 @@ bool UseInvItem(int pnum, int cii)
return true; return true;
} }
if (dropGoldFlag) { if (IsDropGoldOpen) {
CloseGoldDrop(); CloseGoldDrop();
dropGoldValue = 0; DropGoldValue = 0;
} }
if (item->IsScroll() && currlevel == 0 && !spelldata[item->_iSpell].sTownSpell) { if (item->IsScroll() && currlevel == 0 && !spelldata[item->_iSpell].sTownSpell) {

1
Source/inv.h

@ -200,6 +200,7 @@ void RemoveScroll(Player &player);
bool UseScroll(); bool UseScroll();
void UseStaffCharge(Player &player); void UseStaffCharge(Player &player);
bool UseStaff(); bool UseStaff();
const Item &GetInventoryItem(int pcursinvitem);
bool UseInvItem(int pnum, int cii); bool UseInvItem(int pnum, int cii);
void DoTelekinesis(); void DoTelekinesis();
int CalculateGold(Player &player); int CalculateGold(Player &player);

6
Source/items.cpp

@ -2265,7 +2265,7 @@ bool IsItemAvailable(int i)
*sgOptions.Gameplay.testBard && IsAnyOf(i, IDI_BARDSWORD, IDI_BARDDAGGER)); *sgOptions.Gameplay.testBard && IsAnyOf(i, IDI_BARDSWORD, IDI_BARDDAGGER));
} }
BYTE GetOutlineColor(const Item &item, bool checkReq) uint8_t GetOutlineColor(const Item &item, bool checkReq)
{ {
if (checkReq && !item._iStatFlag) if (checkReq && !item._iStatFlag)
return ICOL_RED; return ICOL_RED;
@ -3727,6 +3727,10 @@ bool DoOil(Player &player, int cii)
void DrawUniqueInfo(const Surface &out) void DrawUniqueInfo(const Surface &out)
{ {
if (!ShowUniqueItemInfoBox) {
return;
}
const Point position = GetRightPanel().position - Displacement { SPANEL_WIDTH, 0 }; const Point position = GetRightPanel().position - Displacement { SPANEL_WIDTH, 0 };
if ((chrflag || QuestLogIsOpen || IsStashOpen) && GetLeftPanel().Contains(position)) { if ((chrflag || QuestLogIsOpen || IsStashOpen) && GetLeftPanel().Contains(position)) {
return; return;

2
Source/items.h

@ -423,7 +423,7 @@ extern bool ShowUniqueItemInfoBox;
extern CornerStoneStruct CornerStone; extern CornerStoneStruct CornerStone;
extern bool UniqueItemFlags[128]; extern bool UniqueItemFlags[128];
BYTE GetOutlineColor(const Item &item, bool checkReq); uint8_t GetOutlineColor(const Item &item, bool checkReq);
bool IsItemAvailable(int i); bool IsItemAvailable(int i);
bool IsUniqueAvailable(int i); bool IsUniqueAvailable(int i);
void InitItemGFX(); void InitItemGFX();

4
Source/minitext.cpp

@ -151,6 +151,10 @@ void DrawQTextBack(const Surface &out)
void DrawQText(const Surface &out) void DrawQText(const Surface &out)
{ {
if (!qtextflag) {
return;
}
DrawQTextBack(out); DrawQTextBack(out);
DrawQTextContent(out.subregionY(UI_OFFSET_Y + 49, 260)); DrawQTextContent(out.subregionY(UI_OFFSET_Y + 49, 260));
} }

6
Source/miniwin/misc_msg.cpp

@ -489,14 +489,14 @@ bool FetchMessage_Real(tagMSG *lpMsg)
case SDL_KEYDOWN: case SDL_KEYDOWN:
case SDL_KEYUP: { case SDL_KEYUP: {
#ifdef USE_SDL1 #ifdef USE_SDL1
if (gbRunGame && (IsTalkActive() || dropGoldFlag)) { if (gbRunGame && (IsTalkActive() || IsDropGoldOpen)) {
Uint16 unicode = e.key.keysym.unicode; Uint16 unicode = e.key.keysym.unicode;
if (unicode >= ' ') { if (unicode >= ' ') {
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> convert; std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> convert;
std::string utf8 = convert.to_bytes(unicode); std::string utf8 = convert.to_bytes(unicode);
if (IsTalkActive()) if (IsTalkActive())
control_new_text(utf8); control_new_text(utf8);
if (dropGoldFlag) if (IsDropGoldOpen)
GoldDropNewText(utf8); GoldDropNewText(utf8);
} }
} }
@ -606,7 +606,7 @@ bool FetchMessage_Real(tagMSG *lpMsg)
control_new_text(e.text.text); control_new_text(e.text.text);
break; break;
} }
if (gbRunGame && dropGoldFlag) { if (gbRunGame && IsDropGoldOpen) {
GoldDropNewText(e.text.text); GoldDropNewText(e.text.text);
break; break;
} }

4
Source/objects.cpp

@ -3523,9 +3523,9 @@ bool OperateShrineMurphys(int pnum)
void OperateShrine(int pnum, int i, _sfx_id sType) void OperateShrine(int pnum, int i, _sfx_id sType)
{ {
if (dropGoldFlag) { if (IsDropGoldOpen) {
CloseGoldDrop(); CloseGoldDrop();
dropGoldValue = 0; DropGoldValue = 0;
} }
assert(i >= 0 && i < MAXOBJECTS); assert(i >= 0 && i < MAXOBJECTS);

4
Source/panels/spell_list.cpp

@ -124,6 +124,10 @@ void DrawSpell(const Surface &out)
void DrawSpellList(const Surface &out) void DrawSpellList(const Surface &out)
{ {
if (!spselflag) {
return;
}
InfoString.clear(); InfoString.clear();
ClearPanel(); ClearPanel();

4
Source/qol/chatlog.cpp

@ -140,6 +140,10 @@ void AddMessageToChatLog(const std::string &message, Player *player, UiFlags fla
void DrawChatLog(const Surface &out) void DrawChatLog(const Surface &out)
{ {
if (!ChatLogFlag) {
return;
}
DrawSTextHelp(); DrawSTextHelp();
DrawQTextBack(out); DrawQTextBack(out);

30
Source/scrollrt.cpp

@ -1278,29 +1278,15 @@ void DrawView(const Surface &out, Point startPosition)
} else if (IsStashOpen) { } else if (IsStashOpen) {
DrawStash(out); DrawStash(out);
} }
DrawLevelUpIcon(out); DrawLevelUpButton(out);
if (ShowUniqueItemInfoBox) { DrawUniqueInfo(out);
DrawUniqueInfo(out); DrawQText(out);
} DrawSpellList(out);
if (qtextflag) { DrawGoldSplit(out, DropGoldValue);
DrawQText(out);
}
if (spselflag) {
DrawSpellList(out);
}
if (dropGoldFlag) {
DrawGoldSplit(out, dropGoldValue);
}
DrawGoldWithdraw(out, WithdrawGoldValue); DrawGoldWithdraw(out, WithdrawGoldValue);
if (HelpFlag) { DrawHelp(out);
DrawHelp(out); DrawChatLog(out);
} DrawDiabloMsg(out);
if (ChatLogFlag) {
DrawChatLog(out);
}
if (IsDiabloMsgAvailable()) {
DrawDiabloMsg(out);
}
if (MyPlayerIsDead) { if (MyPlayerIsDead) {
RedBack(out); RedBack(out);
} else if (PauseMode != 0) { } else if (PauseMode != 0) {

Loading…
Cancel
Save