@@ -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
0 commit comments