Browse Source

Modify the calculation of panel position

left/center combination is used, but panel distance is limited
pull/2533/head
Aaron Sun 5 years ago committed by Anders Jenbo
parent
commit
aef812fb5a
  1. 58
      Source/control.cpp
  2. 4
      Source/options.cpp
  3. 4
      Source/options.h

58
Source/control.cpp

@ -236,6 +236,24 @@ spell_id SpellPages[6][7] = {
#define SPLROWICONLS 10
#define SPLICONLAST (gbIsHellfire ? 52 : 43)
void CalculatePanelAreas(void)
{
MainPanel = { { (gnScreenWidth - PANEL_WIDTH) / 2, gnScreenHeight - PANEL_HEIGHT }, { PANEL_WIDTH, PANEL_HEIGHT } };
LeftPanel = { { 0, 0 }, { SPANEL_WIDTH, SPANEL_HEIGHT } };
RightPanel = { { 0, 0 }, { SPANEL_WIDTH, SPANEL_HEIGHT } };
if (gnScreenWidth - 2 * SPANEL_WIDTH > PANEL_WIDTH) {
LeftPanel.position.x = (gnScreenWidth - 2 * SPANEL_WIDTH - PANEL_WIDTH) / 2;
} else {
LeftPanel.position.x = 0;
}
LeftPanel.position.y = (gnScreenHeight - LeftPanel.size.height - PANEL_HEIGHT) / 2;
RightPanel.position.x = gnScreenWidth - RightPanel.size.width - LeftPanel.position.x;
RightPanel.position.y = LeftPanel.position.y;
}
/**
* Draw spell cell onto the given buffer.
* @param out Output buffer
@ -797,46 +815,6 @@ void ClearPanel()
pnumlines = 0;
}
void CalculatePanelAreas(void)
{
MainPanel = { { (gnScreenWidth - PANEL_WIDTH) / 2, gnScreenHeight - PANEL_HEIGHT }, { PANEL_WIDTH, PANEL_HEIGHT } };
LeftPanel = { { 0, 0 }, { SPANEL_WIDTH, SPANEL_HEIGHT } };
RightPanel = { { 0, 0 }, { SPANEL_WIDTH, SPANEL_HEIGHT } };
switch (sgOptions.Gameplay.nSPanelHAlign) {
case 0: // left
LeftPanel.position.x = 0;
break;
case 1: // center
LeftPanel.position.x = (gnScreenWidth / 2 - LeftPanel.size.width) / 2;
break;
case 2: // right
LeftPanel.position.x = gnScreenWidth / 2 - LeftPanel.size.width;
break;
default:
LeftPanel.position.x = 0;
break;
}
switch (sgOptions.Gameplay.nSPanelVAlign) {
case 0: // top
LeftPanel.position.y = 0;
break;
case 1: // center
LeftPanel.position.y = (gnScreenHeight - LeftPanel.size.height - PANEL_HEIGHT) / 2;
break;
case 2: // bottom
LeftPanel.position.y = gnScreenHeight - LeftPanel.size.height - PANEL_HEIGHT;
break;
default:
LeftPanel.position.y = 0;
break;
}
RightPanel.position.x = gnScreenWidth - RightPanel.size.width - LeftPanel.position.x;
RightPanel.position.y = LeftPanel.position.y;
}
Point GetPanelPosition(UiPanels panel, Point offset)
{
Displacement displacement { offset.x, offset.y };

4
Source/options.cpp

@ -264,8 +264,6 @@ void LoadOptions()
sgOptions.Gameplay.bRandomizeQuests = GetIniBool("Game", "Randomize Quests", true);
sgOptions.Gameplay.bShowMonsterType = GetIniBool("Game", "Show Monster Type", false);
sgOptions.Gameplay.bDisableCripplingShrines = GetIniBool("Game", "Disable Crippling Shrines", false);
sgOptions.Gameplay.nSPanelHAlign = GetIniInt("Game", "Side Panel Horizontal Alignment", 0);
sgOptions.Gameplay.nSPanelVAlign = GetIniInt("Game", "Side Panel Vertical Alignment", 1);
GetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress, sizeof(sgOptions.Network.szBindAddress), "0.0.0.0");
sgOptions.Network.nPort = GetIniInt("Network", "Port", 6112);
@ -375,8 +373,6 @@ void SaveOptions()
SetIniValue("Game", "Randomize Quests", sgOptions.Gameplay.bRandomizeQuests);
SetIniValue("Game", "Show Monster Type", sgOptions.Gameplay.bShowMonsterType);
SetIniValue("Game", "Disable Crippling Shrines", sgOptions.Gameplay.bDisableCripplingShrines);
SetIniValue("Game", "Side Panel Horizontal Alignment", sgOptions.Gameplay.nSPanelHAlign);
SetIniValue("Game", "Side Panel Vertical Alignment", sgOptions.Gameplay.nSPanelVAlign);
SetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress);
SetIniValue("Network", "Port", sgOptions.Network.nPort);

4
Source/options.h

@ -118,10 +118,6 @@ struct GameplayOptions {
bool bShowMonsterType;
/** @brief Locally disable clicking on shrines which permanently cripple character. */
bool bDisableCripplingShrines;
/** @brief Side panel horizontal alignment (left/center/right) */
int nSPanelHAlign;
/** @brief Side panel vertical alignment (top/center/bottom) */
int nSPanelVAlign;
};
struct ControllerOptions {

Loading…
Cancel
Save