Skip to content

Commit 66207e1

Browse files
committed
Tidied question box layout.
Improved JSON logging a little bit.
1 parent 4cc8a34 commit 66207e1

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

MTA10/core/CQuestionBox.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ void CQuestionBox::Show ( void )
5959
SString strMsg = m_pMessage->GetText ();
6060
unsigned int uiNumLines = std::count( strMsg.begin(), strMsg.end(), '\n' ) + 1;
6161

62-
float fMsgWidth = 400;
63-
float fMsgHeight = Max < unsigned int > ( 3, uiNumLines ) * m_pMessage->GetFontHeight ();
64-
float fWinWidth = fMsgWidth;
62+
float fMsgWidth = Max ( 400.f, m_pMessage->GetTextExtent () + 50.f );
63+
float fMsgHeight = Max < float > ( 3, uiNumLines ) * m_pMessage->GetFontHeight ();
64+
float fWinWidth = Max ( fMsgWidth, m_uiActiveButtons * ( 112 + 10.f ) );
6565
float fWinHeight = 50 + fMsgHeight + 50 + 30;
6666

6767
CVector2D resolution = CCore::GetSingleton().GetGUI()->GetResolution();
68-
m_pWindow->SetSize ( CVector2D ( fWinWidth, fWinHeight + 10 ), false );
6968
m_pWindow->SetPosition ( CVector2D ( resolution.fX / 2 - fWinWidth / 2, resolution.fY / 2 - fWinHeight / 2 ), false );
69+
m_pWindow->SetSize ( CVector2D ( fWinWidth, fWinHeight + 10 ), false );
7070

71+
m_pMessage->SetPosition ( CVector2D ( fWinWidth / 2 - fMsgWidth / 2, fWinHeight / 2 - fMsgHeight / 2 - 10 ), false );
7172
m_pMessage->SetSize ( CVector2D ( fMsgWidth, fMsgHeight ), false );
72-
m_pMessage->SetPosition ( CVector2D ( 0, fWinHeight / 2 - fMsgHeight / 2 - 10 ), false );
7373
m_pMessage->SetHorizontalAlign ( CGUI_ALIGN_HORIZONTALCENTER );
7474

7575
// Position the buttons evenly across the bottom
@@ -82,11 +82,6 @@ void CQuestionBox::Show ( void )
8282
float fPosX = fWinWidth - ( ( i + 1 ) * fSpaceBetween + i * 112 ) - 112;
8383
m_ButtonList[ i ]->SetPosition ( CVector2D ( fPosX, fWinHeight - 35 ), false );
8484
m_ButtonList[ i ]->SetSize ( CVector2D ( 112, 24 ), false );
85-
m_ButtonList[ i ]->SetVisible ( true );
86-
}
87-
else
88-
{
89-
m_ButtonList[ i ]->SetVisible ( false );
9085
}
9186
}
9287

@@ -103,6 +98,8 @@ void CQuestionBox::Reset ( void )
10398
SetMessage ( "" );
10499
SetCallback ( NULL );
105100
m_uiActiveButtons = 0;
101+
for ( unsigned int i = 0 ; i < m_ButtonList.size () ; i++ )
102+
m_ButtonList[ i ]->SetVisible ( false );
106103
}
107104

108105

@@ -123,9 +120,10 @@ void CQuestionBox::SetButton ( unsigned int uiButton, const SString& strText )
123120
m_uiActiveButtons = Max ( m_uiActiveButtons, uiButton + 1 );
124121
while ( m_ButtonList.size () < m_uiActiveButtons )
125122
{
126-
CGUIButton* pButton = reinterpret_cast < CGUIButton* > ( g_pCore->GetGUI ()->CreateButton ( m_pWindow, "Connect" ) );
123+
CGUIButton* pButton = reinterpret_cast < CGUIButton* > ( g_pCore->GetGUI ()->CreateButton ( m_pWindow, "" ) );
127124
pButton->SetClickHandler ( GUI_CALLBACK ( &CQuestionBox::OnButtonClick, this ) );
128125
pButton->SetUserData ( reinterpret_cast < void* > ( m_ButtonList.size () ) );
126+
pButton->SetVisible ( false );
129127
m_ButtonList.push_back ( pButton );
130128
}
131129

MTA10/core/CSettings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,7 @@ void CSettings::SaveData ( void )
18541854
strMessage += "\n\nDo you want to restart now?";
18551855
CQuestionBox* pQuestionBox = CCore::GetSingleton ().GetLocalGUI ()->GetMainMenu ()->GetQuestionWindow ();
18561856
pQuestionBox->Reset ();
1857-
pQuestionBox->SetTitle ( "Restart required" );
1857+
pQuestionBox->SetTitle ( "RESTART REQUIRED" );
18581858
pQuestionBox->SetMessage ( strMessage );
18591859
pQuestionBox->SetButton ( 0, "No" );
18601860
pQuestionBox->SetButton ( 1, "Yes" );

MTA10/core/CVersionUpdater.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void CVersionUpdater::DoPulse ( void )
9292

9393
if ( m_strStage == "End" )
9494
{
95-
m_strStage == "";
95+
m_strStage = "";
9696
}
9797
}
9898

@@ -307,7 +307,7 @@ void CVersionUpdater::StartDownload ( void )
307307

308308
// Display dialog
309309
GetQuestionBox ().Reset ();
310-
GetQuestionBox ().SetTitle ( "Downloading" );
310+
GetQuestionBox ().SetTitle ( "DOWNLOADING" );
311311
GetQuestionBox ().SetMessage ( "waiting..." );
312312
GetQuestionBox ().SetButton ( 0, "Cancel" );
313313
GetQuestionBox ().Show ();
@@ -359,7 +359,7 @@ void CVersionUpdater::PollDownload ( void )
359359
if ( !bHashOk )
360360
{
361361
GetQuestionBox ().Reset ();
362-
GetQuestionBox ().SetTitle ( "Error downloading" );
362+
GetQuestionBox ().SetTitle ( "ERROR DOWNLOADING" );
363363
GetQuestionBox ().SetMessage ( "The file had an accident on the infomation superhighway" );
364364
GetQuestionBox ().SetButton ( 0, "OK" );
365365
GetQuestionBox ().Show ();
@@ -396,7 +396,7 @@ void CVersionUpdater::PollDownload ( void )
396396
if ( strPathFilename.length () == 0 )
397397
{
398398
GetQuestionBox ().Reset ();
399-
GetQuestionBox ().SetTitle ( "Error saving" );
399+
GetQuestionBox ().SetTitle ( "ERROR SAVING" );
400400
GetQuestionBox ().SetMessage ( "The file wants to stay in ram" );
401401
GetQuestionBox ().SetButton ( 0, "OK" );
402402
GetQuestionBox ().Show ();
@@ -409,7 +409,7 @@ void CVersionUpdater::PollDownload ( void )
409409

410410
// Exit game after button press
411411
GetQuestionBox ().Reset ();
412-
GetQuestionBox ().SetTitle ( "Download complete" );
412+
GetQuestionBox ().SetTitle ( "DOWNLOAD COMPLETE" );
413413
GetQuestionBox ().SetMessage ( m_DownloadInfo.strMsg2 );
414414
GetQuestionBox ().SetButton ( 0, "OK" );
415415
GetQuestionBox ().Show ();

MTA10_Server/mods/deathmatch/logic/lua/CLuaArgument.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ bool CLuaArgument::ReadFromJSONObject ( json_object* object, std::vector < CLuaA
976976
}
977977
else
978978
{
979-
g_pGame->GetScriptDebugging()->LogError ( NULL, "Invalid element specified." );
979+
g_pGame->GetScriptDebugging()->LogError ( NULL, SString ( "Invalid element specified in JSON string '%s'.", szString ) );
980980
m_iType = LUA_TNIL;
981981
}
982982
break;
@@ -990,7 +990,7 @@ bool CLuaArgument::ReadFromJSONObject ( json_object* object, std::vector < CLuaA
990990
}
991991
else
992992
{
993-
g_pGame->GetScriptDebugging()->LogError ( NULL, "Invalid resource specified." );
993+
g_pGame->GetScriptDebugging()->LogError ( NULL, SString ( "Invalid resource specified in JSON string '%s'.", szString ) );
994994
m_iType = LUA_TNIL;
995995
}
996996
break;
@@ -1006,7 +1006,7 @@ bool CLuaArgument::ReadFromJSONObject ( json_object* object, std::vector < CLuaA
10061006
}
10071007
else
10081008
{
1009-
g_pGame->GetScriptDebugging()->LogError ( NULL, "Invalid table reference specified." );
1009+
g_pGame->GetScriptDebugging()->LogError ( NULL, SString ( "Invalid table reference specified in JSON string '%s'.", szString ) );
10101010
m_iType = LUA_TNIL;
10111011
}
10121012
break;

0 commit comments

Comments
 (0)