Skip to content

Commit b869516

Browse files
committed
Added code to support slightly larger settings panel.
1 parent a67f2d9 commit b869516

File tree

2 files changed

+49
-17
lines changed

2 files changed

+49
-17
lines changed

MTA10/core/CSettings.cpp

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
using namespace std;
2424

25+
#define CORE_MTA_FILLER "cgui\\images\\mta_filler.png"
2526
#define CORE_SETTINGS_UPDATE_INTERVAL 30 // Settings update interval in frames
2627
#define CORE_SETTINGS_HEADERS 3
2728
#define CORE_SETTINGS_HEADER_SPACER " "
@@ -77,25 +78,56 @@ void CSettings::CreateGUI ( void )
7778
CVector2D vecTemp;
7879
CVector2D vecSize;
7980

80-
// Create the window
81-
m_pWindow = reinterpret_cast < CGUIWindow* > ( pManager->CreateWnd ( NULL, _("SETTINGS") ) );
82-
m_pWindow->SetCloseButtonEnabled ( true );
83-
m_pWindow->SetMovable ( true );
84-
8581
CVector2D resolution = CCore::GetSingleton().GetGUI()->GetResolution();
86-
float yoff = resolution.fY > 600 ? resolution.fY / 12 : 0.0f;
87-
m_pWindow->SetPosition ( CVector2D ( resolution.fX / 2 - 560.0f / 2, resolution.fY / 2 - 480.0f / 2 + yoff ), false );
8882

89-
//m_pWindow->SetPosition ( CVector2D ( 0.15f, 0.20f ), true );
90-
m_pWindow->SetSize ( CVector2D ( 560.0f, 480.0f ) );
91-
m_pWindow->SetSizingEnabled ( false );
92-
m_pWindow->SetAlwaysOnTop ( true );
93-
m_pWindow->BringToFront ();
83+
#ifdef SETTINGS_PANEL_MAX_SIZE
84+
// Use this for maxium settings panel size
85+
// Will require content layout changes to make it look good
86+
CVector2D contentSize( 640, 480 );
87+
#else
88+
CVector2D contentSize( 560, 458 );
89+
#endif
90+
float fBottomButtonAreaHeight = 38;
91+
CVector2D tabPanelPosition;
92+
CVector2D tabPanelSize = contentSize - CVector2D( 0, fBottomButtonAreaHeight );
93+
94+
// Window size is content size plus window frame edge dims
95+
CVector2D windowSize = contentSize + CVector2D( 9 + 9, 20 + 2 );
96+
97+
if ( windowSize.fX <= resolution.fX && windowSize.fY <= resolution.fY )
98+
{
99+
// Create window (with frame) if it will fit inside the screen resolution
100+
CGUIWindow* pWindow = reinterpret_cast < CGUIWindow* > ( pManager->CreateWnd ( NULL, _("SETTINGS") ) );
101+
pWindow->SetCloseButtonEnabled ( true );
102+
pWindow->SetMovable ( true );
103+
pWindow->SetPosition ( ( resolution - windowSize ) / 2 );
104+
pWindow->SetSize ( windowSize );
105+
pWindow->SetSizingEnabled ( false );
106+
pWindow->SetAlwaysOnTop ( true );
107+
pWindow->BringToFront ();
108+
m_pWindow = pWindow;
109+
tabPanelPosition = CVector2D( 0, 20 );
110+
}
111+
else
112+
{
113+
// Otherwise use black background image
114+
CGUIStaticImage* pFiller = reinterpret_cast < CGUIStaticImage* > ( pManager->CreateStaticImage () );
115+
pFiller->LoadFromFile ( CORE_MTA_FILLER );
116+
pFiller->SetVisible ( false );
117+
pFiller->SetZOrderingEnabled ( false );
118+
pFiller->SetAlwaysOnTop ( true );
119+
pFiller->MoveToBack ();
120+
pFiller->SetPosition ( ( resolution - contentSize ) / 2 );
121+
pFiller->SetSize ( contentSize );
122+
m_pWindow = pFiller;
123+
tabPanelPosition = CVector2D( 0, 0 );
124+
}
94125

95126
// Create the tab panel and necessary tabs
96127
m_pTabs = reinterpret_cast < CGUITabPanel* > ( pManager->CreateTabPanel ( m_pWindow ) );
97-
m_pTabs->SetPosition ( CVector2D ( 0, 20.0f ) );
98-
m_pTabs->SetSize ( CVector2D ( 560.0f, 420.0f ) );
128+
m_pTabs->SetPosition ( tabPanelPosition );
129+
m_pTabs->SetSize ( tabPanelSize );
130+
99131
pTabMultiplayer = m_pTabs->CreateTab ( _("Multiplayer") );
100132
pTabVideo = m_pTabs->CreateTab ( _("Video") );
101133
pTabAudio = m_pTabs->CreateTab ( _("Audio") );
@@ -109,12 +141,12 @@ void CSettings::CreateGUI ( void )
109141
// Create buttons
110142
// OK button
111143
m_pButtonOK = reinterpret_cast < CGUIButton* > ( pManager->CreateButton ( m_pWindow, _("OK") ) );
112-
m_pButtonOK->SetPosition ( CVector2D ( 0.5f, 0.94f ), true );
144+
m_pButtonOK->SetPosition ( CVector2D ( contentSize.fX * 0.5f, tabPanelSize.fY + tabPanelPosition.fY + 8 ) );
113145
m_pButtonOK->SetZOrderingEnabled ( false );
114146

115147
// Cancel button
116148
m_pButtonCancel = reinterpret_cast < CGUIButton* > ( pManager->CreateButton ( m_pWindow, _("Cancel") ) );
117-
m_pButtonCancel->SetPosition ( CVector2D ( 0.78f, 0.94f ), true );
149+
m_pButtonCancel->SetPosition ( CVector2D ( contentSize.fX * 0.78f, tabPanelSize.fY + tabPanelPosition.fY + 8 ) );
118150
m_pButtonCancel->SetZOrderingEnabled ( false );
119151

120152
/**

MTA10/core/CSettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class CSettings
150150
const static int SecKeyNum = 3; // Number of secondary keys
151151

152152
// Keep these protected so we can access them in the event handlers of CClientGame
153-
CGUIWindow* m_pWindow;
153+
CGUIElement* m_pWindow;
154154
CGUITabPanel* m_pTabs;
155155
CGUIButton* m_pButtonOK;
156156
CGUIButton* m_pButtonCancel;

0 commit comments

Comments
 (0)