Browse Source

Introduce Open/Close/ToggleCharPanel

pull/5974/head
obligaron 3 years ago committed by Anders Jenbo
parent
commit
b916c8e428
  1. 35
      Source/control.cpp
  2. 3
      Source/control.h
  3. 9
      Source/controls/plrctrls.cpp
  4. 15
      Source/diablo.cpp
  5. 2
      Source/qol/chatlog.cpp
  6. 2
      Source/stores.cpp

35
Source/control.cpp

@ -598,6 +598,27 @@ void FocusOnCharInfo()
SetCursorPos(ChrBtnsRect[stat].Center());
}
void OpenCharPanel()
{
QuestLogIsOpen = false;
CloseGoldWithdraw();
IsStashOpen = false;
chrflag = true;
}
void CloseCharPanel()
{
chrflag = false;
}
void ToggleCharPanel()
{
if (chrflag)
CloseCharPanel();
else
OpenCharPanel();
}
void AddPanelString(string_view str)
{
if (InfoString.empty())
@ -742,7 +763,7 @@ void InitControlPan()
InfoString = {};
RedrawComponent(PanelDrawComponent::Health);
RedrawComponent(PanelDrawComponent::Mana);
chrflag = false;
CloseCharPanel();
spselflag = false;
sbooktab = 0;
sbookflag = false;
@ -945,13 +966,10 @@ void CheckBtnUp()
switch (i) {
case PanelButtonCharinfo:
QuestLogIsOpen = false;
CloseGoldWithdraw();
IsStashOpen = false;
chrflag = !chrflag;
ToggleCharPanel();
break;
case PanelButtonQlog:
chrflag = false;
CloseCharPanel();
CloseGoldWithdraw();
IsStashOpen = false;
if (!QuestLogIsOpen)
@ -1088,10 +1106,7 @@ void ReleaseLvlBtn()
{
const Point mainPanelPosition = GetMainPanel().position;
if (MousePosition.x >= 40 + mainPanelPosition.x && MousePosition.x <= 81 + mainPanelPosition.x && MousePosition.y >= -39 + mainPanelPosition.y && MousePosition.y <= -17 + mainPanelPosition.y) {
QuestLogIsOpen = false;
CloseGoldWithdraw();
IsStashOpen = false;
chrflag = true;
OpenCharPanel();
}
lvlbtndown = false;
}

3
Source/control.h

@ -64,6 +64,9 @@ bool IsChatAvailable();
* @brief Moves the mouse to the first attribute "+" button.
*/
void FocusOnCharInfo();
void OpenCharPanel();
void CloseCharPanel();
void ToggleCharPanel();
/**
* @brief Check if the UI can cover the game area entierly

9
Source/controls/plrctrls.cpp

@ -1623,7 +1623,7 @@ void ProcessGameAction(const GameAction &action)
DoSpeedBook();
else
spselflag = false;
chrflag = false;
CloseCharPanel();
QuestLogIsOpen = false;
sbookflag = false;
CloseGoldWithdraw();
@ -1631,11 +1631,8 @@ void ProcessGameAction(const GameAction &action)
}
break;
case GameActionType_TOGGLE_CHARACTER_INFO:
chrflag = !chrflag;
ToggleCharPanel();
if (chrflag) {
QuestLogIsOpen = false;
CloseGoldWithdraw();
IsStashOpen = false;
spselflag = false;
if (pcurs == CURSOR_DISARM)
NewCursor(CURSOR_HAND);
@ -1645,7 +1642,7 @@ void ProcessGameAction(const GameAction &action)
case GameActionType_TOGGLE_QUEST_LOG:
if (!QuestLogIsOpen) {
StartQuestlog();
chrflag = false;
CloseCharPanel();
CloseGoldWithdraw();
IsStashOpen = false;
spselflag = false;

15
Source/diablo.cpp

@ -454,7 +454,7 @@ void ClosePanels()
}
}
CloseInventory();
chrflag = false;
CloseCharPanel();
sbookflag = false;
QuestLogIsOpen = false;
}
@ -1448,7 +1448,7 @@ void HelpKeyPressed()
LastMouseButtonAction = MouseActionType::None;
} else {
CloseInventory();
chrflag = false;
CloseCharPanel();
sbookflag = false;
spselflag = false;
if (qtextflag && leveltype == DTYPE_TOWN) {
@ -1488,9 +1488,8 @@ void CharacterSheetKeyPressed()
{
if (stextflag != TalkID::None)
return;
chrflag = !chrflag;
if (!IsRightPanelOpen() && CanPanelsCoverView()) {
if (!chrflag) { // We closed the character sheet
if (chrflag) { // We are closing the character sheet
if (MousePosition.x > 160 && MousePosition.y < GetMainPanel().position.y) {
SetCursorPos(MousePosition - Displacement { 160, 0 });
}
@ -1500,9 +1499,7 @@ void CharacterSheetKeyPressed()
}
}
}
QuestLogIsOpen = false;
CloseGoldWithdraw();
IsStashOpen = false;
ToggleCharPanel();
}
void QuestLogKeyPressed()
@ -1525,7 +1522,7 @@ void QuestLogKeyPressed()
}
}
}
chrflag = false;
CloseCharPanel();
CloseGoldWithdraw();
IsStashOpen = false;
}
@ -1534,7 +1531,7 @@ void DisplaySpellsKeyPressed()
{
if (stextflag != TalkID::None)
return;
chrflag = false;
CloseCharPanel();
QuestLogIsOpen = false;
CloseInventory();
sbookflag = false;

2
Source/qol/chatlog.cpp

@ -99,7 +99,7 @@ void ToggleChatLog()
} else {
stextflag = TalkID::None;
CloseInventory();
chrflag = false;
CloseCharPanel();
sbookflag = false;
spselflag = false;
if (qtextflag && leveltype == DTYPE_TOWN) {

2
Source/stores.cpp

@ -2331,7 +2331,7 @@ void StartStore(TalkID s)
}
sbookflag = false;
CloseInventory();
chrflag = false;
CloseCharPanel();
RenderGold = false;
QuestLogIsOpen = false;
CloseGoldDrop();

Loading…
Cancel
Save