CServerPassword::CServerPassword ( CGUI_Impl * pGUI ) { // Create the main window m_pWindow = pGUI->CreateWnd ( "Password Protected Server" ); m_pWindow->SetSize ( Vector2 ( 260, 120 ) ); m_pWindow->SetPosition ( Vector2 ( (pGUI->GetResolution().fX / 2) - 150, (pGUI->GetResolution().fY / 2) - 95 ) ); m_pWindow->SetVisible ( false ); m_pWindow->SetAlwaysOnTop ( true ); m_pWindow->SetSizingEnabled ( false ); m_pWindow->SetAlpha ( 1.0f ); // Create the label m_pLabel = pGUI->CreateLabel ( "Please enter the server password:"******"", m_pWindow ); m_pEdit->SetSize ( Vector2( 220, 24 ) ); m_pEdit->SetPosition ( Vector2 ( 18, 50 ) ); m_pEdit->SetMasked ( true ); // Create the submit button m_pSubmit = pGUI->CreateButton ( "Connect", m_pWindow ); m_pSubmit->SetSize ( Vector2 ( 75, 20 ) ); m_pSubmit->SetPosition ( Vector2 ( 18, 85 ) ); m_pSubmit->SetClickHandler ( GUI_CALLBACK( &CServerPassword::Event_OnSubmitClick, this ) ); // Create the cancel button m_pCancel = pGUI->CreateButton ( "Cancel", m_pWindow ); m_pCancel->SetSize ( Vector2 ( 75, 20 ) ); m_pCancel->SetPosition ( Vector2 ( 100, 85 ) ); m_pCancel->SetClickHandler ( GUI_CALLBACK( &CServerPassword::Event_OnCancelClick, this ) ); }
void CServerBrowser::CreateTab( ServerBrowserType type, const char * szName, float fWidth, float fHeight ) { // Create the gui tab CGUITab_Impl * pTab = m_pTabs->CreateTab( szName ); // Set the tab instance m_pTab[ type ] = pTab; // Create the server grid list m_pServerGridList[ type ] = m_pGUI->CreateGridList( pTab ); m_pServerGridList[ type ]->SetPosition( Vector2( 1, 1 ) ); m_pServerGridList[ type ]->SetSize( Vector2( fWidth, fHeight ) ); m_pServerGridList[ type ]->SetClickHandler( GUI_CALLBACK( &CServerBrowser::Event_OnMouseClick, this ) ); // todo: double click handler // Create the server grid list columns m_pServerGridList[ type ]->AddColumn( "", 0.02f ); m_pServerGridList[ type ]->AddColumn( "Hostname", 0.45f ); m_pServerGridList[ type ]->AddColumn( "Players", 0.13f ); m_pServerGridList[ type ]->AddColumn( "Gamemode", 0.25f ); m_pServerGridList[ type ]->AddColumn( "Ping", 0.14f ); m_pServerGridList[ type ]->AddColumn( "Host", 0.13f ); m_pServerGridList[ type ]->AddColumn( "Port", 0.5f ); // Create the server list instance m_pServerList[ type ] = new CServerList( type, m_pServerQuery ); }
CFavouritesAddByIP::CFavouritesAddByIP ( void ) { CGUI *pManager = g_pCore->GetGUI (); CMainMenu *pMainMenu = CLocalGUI::GetSingleton ().GetMainMenu (); // Create the window m_pWindow = reinterpret_cast < CGUIWindow* > ( pManager->CreateWnd ( NULL, "Add to favourites" ) ); m_pWindow->SetCloseButtonEnabled ( false ); CVector2D resolution = CCore::GetSingleton().GetGUI()->GetResolution(); m_pWindow->SetPosition ( CVector2D ( resolution.fX / 2 - 280.0f / 2, resolution.fY / 2 - 90.0f / 2 ), false ); m_pWindow->SetSize ( CVector2D ( 280.0f, 90.0f ), false ); m_pWindow->SetSizingEnabled ( false ); m_pWindow->SetAlwaysOnTop ( true ); // Create the controls float fPosX = 0.0f; float fButtonWidth = (280.0f - 30.0f) / 2; // Host label m_pLabelHost = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( m_pWindow, "Host:" ) ); m_pLabelHost->SetPosition ( CVector2D ( fPosX + 12.0f, 28.0f ), false ); m_pLabelHost->AutoSize ( "Host:" ); fPosX += 12.0f + m_pLabelHost->GetSize ().fX; // Host edit m_pEditHost = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( m_pWindow ) ); m_pEditHost->SetPosition ( CVector2D ( fPosX + 5.0f, 24.0f ), false ); m_pEditHost->SetSize ( CVector2D ( 154.0f, 24.0f ), false ); m_pEditHost->SetMaxLength ( 128 ); // Just to prevent entering a huge hostname size.. no-one has a hostname over 128 chars i believe fPosX += 5.0f + 154.0f; // Port label m_pLabelPort = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( m_pWindow, ":" ) ); m_pLabelPort->SetPosition ( CVector2D ( fPosX + 3.0f, 28.0f ), false ); m_pLabelPort->AutoSize ( ":" ); fPosX += 3.0f + m_pLabelPort->GetSize ().fX; // Port edit m_pEditPort = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( m_pWindow ) ); m_pEditPort->SetPosition ( CVector2D ( fPosX + 3.0f, 24.0f ), false ); m_pEditPort->SetSize ( CVector2D ( 59.0f, 24.0f ), false ); m_pEditPort->SetMaxLength ( 5 ); fPosX += 3.0f + 59.0f; // Add button m_pButtonAdd = reinterpret_cast < CGUIButton* > ( pManager->CreateButton ( m_pWindow, "Add" ) ); m_pButtonAdd->SetPosition ( CVector2D ( 12.0f, 60.0f ), false ); m_pButtonAdd->SetSize ( CVector2D ( fButtonWidth, 20.0f ), false ); // Cancel button m_pButtonBack = reinterpret_cast < CGUIButton* > ( pManager->CreateButton ( m_pWindow, "Back" ) ); m_pButtonBack->SetPosition ( CVector2D ( 12.0f + fButtonWidth + 6.0f, 60.0f ), false ); m_pButtonBack->SetSize ( CVector2D ( fButtonWidth, 20.0f ), false ); // Register button events m_pButtonBack->SetClickHandler ( GUI_CALLBACK ( &CFavouritesAddByIP::OnButtonBackClick, this ) ); }
//////////////////////////////////////////////////// // // CNewsBrowser::CreateGUI // // // //////////////////////////////////////////////////// void CNewsBrowser::CreateGUI(void) { CreateHeadlines(); CGUI* pManager = g_pCore->GetGUI(); // Create the window m_pWindow = reinterpret_cast<CGUIWindow*>(pManager->CreateWnd(NULL, "NEWS")); m_pWindow->SetCloseButtonEnabled(true); m_pWindow->SetMovable(true); CVector2D resolution = CCore::GetSingleton().GetGUI()->GetResolution(); float yoff = resolution.fY > 600 ? resolution.fY / 12 : 0.0f; m_pWindow->SetPosition(CVector2D(resolution.fX / 2 - 640.0f / 2, resolution.fY / 2 - 480.0f / 2 + yoff), false); m_pWindow->SetSize(CVector2D(640.0f, 480.0f)); m_pWindow->SetSizingEnabled(false); m_pWindow->SetAlwaysOnTop(true); // Create buttons // OK button m_pButtonOK = reinterpret_cast<CGUIButton*>(pManager->CreateButton(m_pWindow, "OK")); m_pButtonOK->SetPosition(CVector2D(560.0f - 60, 480.0f - 30)); m_pButtonOK->SetZOrderingEnabled(false); // Set up the events m_pWindow->SetEnterKeyHandler(GUI_CALLBACK(&CNewsBrowser::OnOKButtonClick, this)); m_pButtonOK->SetClickHandler(GUI_CALLBACK(&CNewsBrowser::OnOKButtonClick, this)); // Create the tab panel and necessary tabs m_pTabPanel = reinterpret_cast<CGUITabPanel*>(pManager->CreateTabPanel(m_pWindow)); m_pTabPanel->SetPosition(CVector2D(0, 20.0f)); m_pTabPanel->SetSize(CVector2D(640.0f, 480.0f - 60)); for (uint i = 0; i < m_NewsitemList.size(); i++) { AddNewsTab(m_NewsitemList[i]); } }
CGUIEdit* CQuestionBox::SetEditbox ( unsigned int uiEditbox, const SString& strText ) { m_uiActiveEditboxes = Max ( m_uiActiveEditboxes, uiEditbox + 1 ); while ( m_EditList.size () < m_uiActiveEditboxes ) { CGUIEdit* pEdit = reinterpret_cast < CGUIEdit* > ( g_pCore->GetGUI ()->CreateEdit ( m_pWindow ) ); pEdit->SetTextAcceptedHandler ( GUI_CALLBACK ( &CQuestionBox::OnButtonClick, this ) ); pEdit->SetUserData ( reinterpret_cast < void* > ( m_EditList.size () ) ); pEdit->SetVisible ( false ); m_EditList.push_back ( pEdit ); } m_EditList[ uiEditbox ]->SetText ( strText ); m_EditList[ uiEditbox ]->SetVisible ( true ); return m_EditList [ uiEditbox ]; }
void CQuestionBox::SetButton ( unsigned int uiButton, const SString& strText ) { m_uiActiveButtons = Max ( m_uiActiveButtons, uiButton + 1 ); while ( m_ButtonList.size () < m_uiActiveButtons ) { CGUIButton* pButton = reinterpret_cast < CGUIButton* > ( g_pCore->GetGUI ()->CreateButton ( m_pWindow, "" ) ); pButton->SetClickHandler ( GUI_CALLBACK ( &CQuestionBox::OnButtonClick, this ) ); pButton->SetUserData ( reinterpret_cast < void* > ( m_ButtonList.size () ) ); pButton->SetVisible ( false ); pButton->SetZOrderingEnabled ( false ); m_ButtonList.push_back ( pButton ); } m_ButtonList[ uiButton ]->SetText ( strText ); m_ButtonList[ uiButton ]->SetVisible ( true ); }
void CServerBrowser::SetupUI( float fX, float fY, float fWidth, float fHeight ) { // Create the gui tab panel m_pTabs = m_pGUI->CreateTabPanel(); m_pTabs->SetPosition( Vector2( fX, fY ) ); m_pTabs->SetSize( Vector2( (fWidth - 260), fHeight ) ); m_pTabs->SetAlwaysOnTop( true ); // Create the players list m_pPlayers = m_pGUI->CreateTabPanel(); m_pPlayers->SetPosition( Vector2( ((fX + fWidth) - 250), fY ) ); m_pPlayers->SetSize( Vector2( 250, fHeight ) ); m_pPlayers->SetAlwaysOnTop( true ); // Create the status label m_pStatusLabel = m_pGUI->CreateLabel ( "", m_pGUI->GetDefaultFont( true ) ); m_pStatusLabel->SetSize ( Vector2 ( (fWidth - 260), 30 ) ); m_pStatusLabel->SetPosition ( Vector2 ( fX, (fY + fHeight + 10) ) ); // Create the players list tabs m_pPlayersTab = m_pPlayers->CreateTab( "Players" ); m_pRulesTab = m_pPlayers->CreateTab( "Rules" ); // Create the players grid list m_pPlayersGridList = m_pGUI->CreateGridList( m_pPlayersTab ); m_pPlayersGridList->SetPosition( Vector2( 1, 1 ) ); m_pPlayersGridList->SetSize( Vector2( 247, (fHeight - 26) ) ); m_pPlayersGridList->AddColumn ( "Name", 0.65f ); m_pPlayersGridList->AddColumn ( "Ping", 0.30f ); // Create the locked image m_pLockedImage = m_pGUI->CreateStaticImage(); m_pLockedImage->SetVisible( false ); m_pLockedImage->LoadFromFile( "locked.png", SharedUtility::GetAbsolutePath( "data\\gui\\images" ) ); m_pLockedImage->SetSize ( Vector2 ( 12, 12 ) ); // Create the tabs CreateTab( INTERNET, "Internet", (fWidth - 262), (fHeight - 26) ); CreateTab( HOSTED, "Hosted", (fWidth - 262), (fHeight - 26) ); // Hide the server browser SetVisible( false ); // Create the message box window m_pMessageBox = m_pGUI->CreateMessageBox ( "", "", "Close" ); m_pMessageBox->SetVisible ( false ); m_pMessageBox->GetWindow()->SetAlwaysOnTop ( true ); m_pMessageBox->SetButtonClickHandler ( 0, Button1ClickHandler, this ); // Create the quick connect window m_pQuickConnectWindow = m_pGUI->CreateWnd ( "Quick Connect" ); m_pQuickConnectWindow->SetSize ( Vector2 ( 260, 155 ) ); m_pQuickConnectWindow->SetPosition ( Vector2 ( (m_pGUI->GetResolution().fX / 2) - 150, (m_pGUI->GetResolution().fY / 2) - 77.5 ) ); m_pQuickConnectWindow->SetVisible ( false ); m_pQuickConnectWindow->SetAlwaysOnTop ( true ); m_pQuickConnectWindow->SetSizingEnabled ( false ); m_pQuickConnectWindow->SetAlpha ( 1.0f ); // Create the quick connect label m_pQuickConnectLabel = m_pGUI->CreateLabel ( "Enter the server IP, Port and Password:"******"last-server-ip")) != 0); // Create the quick connect IP input m_pQuickConnectAddress = m_pGUI->CreateEdit ( (bRestoreInformation ? CVAR_GET_STRING ( "last-server-ip" ) : "127.0.0.1"), m_pQuickConnectWindow ); m_pQuickConnectAddress->SetSize ( Vector2( 160, 24 ) ); m_pQuickConnectAddress->SetPosition ( Vector2 ( 18, 50 ) ); m_pQuickConnectAddress->SetClickHandler ( GUI_CALLBACK ( &CServerBrowser::Event_QuickConnectInputFocus, this ) ); // Create the quick connect port input m_pQuickConnectPort = m_pGUI->CreateEdit ( (bRestoreInformation ? String ( "%d", CVAR_GET_INTEGER ( "last-server-port" ) ) : "27015"), m_pQuickConnectWindow ); m_pQuickConnectPort->SetSize ( Vector2( 55, 24 ) ); m_pQuickConnectPort->SetPosition ( Vector2 ( 183, 50 ) ); m_pQuickConnectPort->SetClickHandler ( GUI_CALLBACK ( &CServerBrowser::Event_QuickConnectInputFocus, this ) ); // Create the quick connect password input m_pQuickConnectPassword = m_pGUI->CreateEdit ( (bRestoreInformation ? CVAR_GET_STRING ( "last-server-password" ) : ""), m_pQuickConnectWindow ); m_pQuickConnectPassword->SetSize ( Vector2( 220, 24 ) ); m_pQuickConnectPassword->SetPosition ( Vector2( 18, 85 ) ); m_pQuickConnectPassword->SetClickHandler ( GUI_CALLBACK ( &CServerBrowser::Event_QuickConnectInputFocus, this ) ); m_pQuickConnectPassword->SetMasked ( true ); // Create the quick connect submit button m_pQuickConnectSubmit = m_pGUI->CreateButton ( "Connect", m_pQuickConnectWindow ); m_pQuickConnectSubmit->SetSize ( Vector2 ( 75, 20 ) ); m_pQuickConnectSubmit->SetPosition ( Vector2 ( 18, 120 ) ); m_pQuickConnectSubmit->SetClickHandler ( GUI_CALLBACK( &CServerBrowser::Event_QuickConnectSubmitClick, this ) ); // Create the quick connect cancel button m_pQuickConnectCancel = m_pGUI->CreateButton ( "Cancel", m_pQuickConnectWindow ); m_pQuickConnectCancel->SetSize ( Vector2 ( 75, 20 ) ); m_pQuickConnectCancel->SetPosition ( Vector2 ( 100, 120 ) ); m_pQuickConnectCancel->SetClickHandler ( GUI_CALLBACK( &CServerBrowser::Event_QuickConnectCancelClick, this ) ); }
CGUIMessageBox_Impl::CGUIMessageBox_Impl(CGUI_Impl* pGUI, const char* szTitle, const char* szCaption, unsigned int uiFlags) { // Initialize m_bAutoDestroy = true; // TODO: If any buttons.. m_pIcon = NULL; m_pButton = NULL; m_pLabelCaption = NULL; // Create window CVector2D ScreenSize = pGUI->GetResolution(); m_pWindow = pGUI->CreateWnd(NULL, szTitle); m_pWindow->SetAlwaysOnTop(true); m_pWindow->SetCloseButtonEnabled(false); m_pWindow->SetSizingEnabled(false); m_pWindow->SetPosition(CVector2D(ScreenSize.fX * 0.5f - MESSAGEBOX_WIDTH * 0.5f, ScreenSize.fY * 0.5f - MESSAGEBOX_HEIGHT * 0.5f)); m_pWindow->SetSize(CVector2D(MESSAGEBOX_WIDTH, MESSAGEBOX_HEIGHT)); // relative 0.35, 0.225 // Create the icon m_pIcon = pGUI->CreateStaticImage(m_pWindow); m_pIcon->SetFrameEnabled(false); m_pIcon->SetPosition(CVector2D(MESSAGEBOX_SPACER, MESSAGEBOX_HEIGHT / 2 - MESSAGEBOX_ICON_SIZE / 2)); m_pIcon->SetSize(CVector2D(MESSAGEBOX_ICON_SIZE, MESSAGEBOX_ICON_SIZE)); if (uiFlags & MB_ICON_INFO) m_pIcon->LoadFromFile(CGUI_ICON_MESSAGEBOX_INFO); else if (uiFlags & MB_ICON_QUESTION) m_pIcon->LoadFromFile(CGUI_ICON_MESSAGEBOX_QUESTION); else if (uiFlags & MB_ICON_WARNING) m_pIcon->LoadFromFile(CGUI_ICON_MESSAGEBOX_WARNING); else if (uiFlags & MB_ICON_ERROR) m_pIcon->LoadFromFile(CGUI_ICON_MESSAGEBOX_ERROR); // Create caption label m_pLabelCaption = pGUI->CreateLabel(m_pWindow, szCaption); m_pLabelCaption->SetPosition(CVector2D(MESSAGEBOX_ICON_SIZE + MESSAGEBOX_SPACER * 2, MESSAGEBOX_SPACER)); m_pLabelCaption->SetSize(CVector2D(MESSAGEBOX_WIDTH - MESSAGEBOX_ICON_SIZE - MESSAGEBOX_SPACER * 3, MESSAGEBOX_HEIGHT - MESSAGEBOX_SPACER * 2)); m_pLabelCaption->SetHorizontalAlign(CGUI_ALIGN_LEFT_WORDWRAP); m_pLabelCaption->SetVerticalAlign(CGUI_ALIGN_VERTICALCENTER); m_pLabelCaption->MoveToBack(); m_pLabelCaption->SetZOrderingEnabled(false); // Create buttons if (uiFlags & MB_BUTTON_OK) { m_pButton = pGUI->CreateButton(m_pWindow, _("OK")); } else if (uiFlags & MB_BUTTON_CANCEL) { m_pButton = pGUI->CreateButton(m_pWindow, _("Cancel")); } else if (uiFlags & MB_BUTTON_YES) { m_pButton = pGUI->CreateButton(m_pWindow, _("Yes")); } if (m_pButton) { m_pButton->SetPosition(CVector2D((MESSAGEBOX_WIDTH - 84) / 2, MESSAGEBOX_HEIGHT * 0.76f)); m_pButton->SetSize(CVector2D(84.0f, 24.0f)); m_pButton->SetZOrderingEnabled(false); SetClickHandler(GUI_CALLBACK(&CGUIMessageBox_Impl::OnResponseHandler, this)); } // Set the KeyDown handler m_pWindow->SetEnterKeyHandler(GUI_CALLBACK(&CGUIMessageBox_Impl::OnResponseHandler, this)); // And finally set the focus to our window m_pWindow->Activate(); }
CQuickConnect::CQuickConnect ( void ) { CGUI *pManager = g_pCore->GetGUI (); // Create the window m_pWindow = reinterpret_cast < CGUIWindow* > ( pManager->CreateWnd ( NULL, "Quick Connect" ) ); m_pWindow->SetCloseButtonEnabled ( false ); //m_pWindow->SetMovable ( false ); CVector2D resolution = CCore::GetSingleton().GetGUI()->GetResolution(); m_pWindow->SetPosition ( CVector2D ( resolution.fX / 2 - 280.0f / 2, resolution.fY / 2 - 120.0f / 2 ), false ); // m_pWindow->SetPosition ( CVector2D ( 0.35f, 0.375f ), true ); m_pWindow->SetSize ( CVector2D ( 280.0f, 120.0f ) ); m_pWindow->SetSizingEnabled ( false ); m_pWindow->SetAlwaysOnTop ( true ); // Create the controls // Host label m_pLabelHost = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( m_pWindow, "Host:" ) ); m_pLabelHost->SetPosition ( CVector2D ( 0.028f, 0.25f ), true ); m_pLabelHost->AutoSize ( "Host:" ); // Host edit m_pEditHost = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( m_pWindow ) ); m_pEditHost->SetPosition ( CVector2D ( 0.17f, 0.2f ), true ); m_pEditHost->SetSize ( CVector2D ( 154.0f, 24.0f ) ); m_pEditHost->SetMaxLength ( 128 ); // Just to prevent entering a huge hostname size.. no-one has a hostname over 128 chars i believe m_pEditHost->SetTextAcceptedHandler( GUI_CALLBACK( &CQuickConnect::OnConnectButtonClick, this ) ); // Port label m_pLabelPort = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( m_pWindow, ":" ) ); m_pLabelPort->SetPosition ( CVector2D ( 0.725f, 0.25f ) ); m_pLabelPort->AutoSize ( ":" ); // Port edit m_pEditPort = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( m_pWindow ) ); m_pEditPort->SetPosition ( CVector2D ( 0.75f, 0.2f ), true ); m_pEditPort->SetSize ( CVector2D ( 59.0f, 24.0f ) ); m_pEditPort->SetMaxLength ( 5 ); m_pEditPort->SetTextAcceptedHandler( GUI_CALLBACK( &CQuickConnect::OnConnectButtonClick, this ) ); // Pass label m_pLabelPass = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( m_pWindow, "Pass:"******"Pass:"******"Connect" ) ); m_pButtonConnect->SetPosition ( CVector2D ( 0.04f, 0.71f ), true ); m_pButtonConnect->SetSize ( CVector2D ( 112.0f, 24.0f ) ); // Cancel button m_pButtonBack = reinterpret_cast < CGUIButton* > ( pManager->CreateButton ( m_pWindow, "Back" ) ); m_pButtonBack->SetPosition ( CVector2D ( 0.56f, 0.71f ), true ); m_pButtonBack->SetSize ( CVector2D ( 112.0f, 24.0f ) ); // Set up event handlers m_pButtonConnect->SetClickHandler ( GUI_CALLBACK ( &CQuickConnect::OnConnectButtonClick, this ) ); m_pButtonBack->SetClickHandler ( GUI_CALLBACK ( &CQuickConnect::OnBackButtonClick, this ) ); }
CMainMenu::CMainMenu(CGUI* pManager) { m_pNewsBrowser = new CNewsBrowser(); ulPreviousTick = GetTickCount32(); m_pHoveredItem = NULL; m_iMoveStartPos = 0; // Initialize m_pManager = pManager; m_bIsVisible = false; m_bIsFullyVisible = false; m_bIsIngame = true; // m_bIsInSubWindow = false; m_bStarted = false; m_fFader = 0; m_ucFade = FADE_INVISIBLE; // Adjust window size to resolution CVector2D ScreenSize = m_pManager->GetResolution(); m_ScreenSize = ScreenSize; int iBackgroundX = 0; int iBackgroundY = 0; int iBackgroundSizeX = ScreenSize.fX; int iBackgroundSizeY; // First let's work out our x and y offsets if (ScreenSize.fX > ScreenSize.fY) // If the monitor is a normal landscape one { float iRatioSizeY = ScreenSize.fY / NATIVE_RES_Y; m_iMenuSizeX = NATIVE_RES_X * iRatioSizeY; m_iMenuSizeY = ScreenSize.fY; m_iXOff = (ScreenSize.fX - m_iMenuSizeX) * 0.5f; m_iYOff = 0; float iRatioSizeX = ScreenSize.fX / NATIVE_RES_X; iBackgroundSizeX = ScreenSize.fX; iBackgroundSizeY = NATIVE_BG_Y * iRatioSizeX; } else // Otherwise our monitor is in a portrait resolution, so we cant fill the background by y { float iRatioSizeX = ScreenSize.fX / NATIVE_RES_X; m_iMenuSizeY = NATIVE_RES_Y * iRatioSizeX; m_iMenuSizeX = ScreenSize.fX; m_iXOff = 0; m_iYOff = (ScreenSize.fY - m_iMenuSizeY) * 0.5f; iBackgroundY = m_iYOff; iBackgroundSizeX = m_iMenuSizeX; iBackgroundSizeY = NATIVE_BG_Y * iRatioSizeX; } // First create our filler black background image, which covers the whole screen m_pFiller = reinterpret_cast<CGUIStaticImage*>(pManager->CreateStaticImage()); m_pFiller->LoadFromFile(CORE_MTA_FILLER); m_pFiller->SetVisible(false); m_pFiller->MoveToBack(); m_pFiller->SetZOrderingEnabled(false); m_pFiller->SetAlwaysOnTop(true); m_pFiller->MoveToBack(); m_pFiller->SetSize(CVector2D(ScreenSize.fX, iBackgroundY), false); // Background image m_pBackground = reinterpret_cast<CGUIStaticImage*>(pManager->CreateStaticImage()); m_pBackground->LoadFromFile(CORE_MTA_STATIC_BG); m_pBackground->SetProperty("InheritsAlpha", "False"); m_pBackground->SetPosition(CVector2D(iBackgroundX, iBackgroundY), false); m_pBackground->SetSize(CVector2D(iBackgroundSizeX, iBackgroundSizeY), false); m_pBackground->SetZOrderingEnabled(false); m_pBackground->SetAlwaysOnTop(true); m_pBackground->MoveToBack(); m_pBackground->SetAlpha(0); m_pBackground->SetVisible(false); m_pFiller2 = reinterpret_cast<CGUIStaticImage*>(pManager->CreateStaticImage()); m_pFiller2->LoadFromFile(CORE_MTA_FILLER); m_pFiller2->SetVisible(false); m_pFiller2->SetZOrderingEnabled(false); m_pFiller2->SetAlwaysOnTop(true); m_pFiller2->MoveToBack(); m_pFiller2->SetPosition(CVector2D(0, iBackgroundY + iBackgroundSizeY)); m_pFiller2->SetSize(ScreenSize, false); m_pCanvas = reinterpret_cast<CGUIScrollPane*>(pManager->CreateScrollPane()); m_pCanvas->SetProperty("ContentPaneAutoSized", "False"); m_pCanvas->SetPosition(CVector2D(m_iXOff, m_iYOff), false); m_pCanvas->SetSize(CVector2D(m_iMenuSizeX, m_iMenuSizeY), false); m_pCanvas->SetZOrderingEnabled(false); m_pCanvas->SetAlwaysOnTop(true); m_pCanvas->MoveToBack(); m_pCanvas->SetVisible(false); // Create our MTA logo CVector2D logoSize = CVector2D((NATIVE_LOGO_X / NATIVE_RES_X) * m_iMenuSizeX, (NATIVE_LOGO_Y / NATIVE_RES_Y) * m_iMenuSizeY); m_pLogo = reinterpret_cast<CGUIStaticImage*>(pManager->CreateStaticImage(m_pCanvas)); m_pLogo->LoadFromFile(CORE_MTA_LOGO); m_pLogo->SetProperty("InheritsAlpha", "False"); m_pLogo->SetSize(logoSize, false); m_pLogo->SetPosition(CVector2D(0.5f * m_iMenuSizeX - logoSize.fX / 2, 0.365f * m_iMenuSizeY - logoSize.fY / 2), false); m_pLogo->SetZOrderingEnabled(false); // Create the image showing the version number m_pVersion = reinterpret_cast<CGUIStaticImage*>(pManager->CreateStaticImage()); m_pVersion->LoadFromFile(CORE_MTA_VERSION); m_pVersion->SetParent(m_pCanvas); m_pVersion->SetPosition(CVector2D(0.845f, 0.528f), true); m_pVersion->SetSize(CVector2D((32 / NATIVE_RES_X) * m_iMenuSizeX, (32 / NATIVE_RES_Y) * m_iMenuSizeY), false); m_pVersion->SetProperty("InheritsAlpha", "False"); float fBase = 0.613f; float fGap = 0.043f; // Our disconnect item is shown/hidden dynamically, so we store it seperately m_pDisconnect = CreateItem(MENU_ITEM_DISCONNECT, "menu_disconnect.png", CVector2D(0.168f, fBase + fGap * 0)); m_pDisconnect->image->SetVisible(false); // Create the menu items // Filepath, Relative position, absolute native size // And the font for the graphics is ? m_menuItems.push_back(CreateItem(MENU_ITEM_QUICK_CONNECT, "menu_quick_connect.png", CVector2D(0.168f, fBase + fGap * 0))); m_menuItems.push_back(CreateItem(MENU_ITEM_BROWSE_SERVERS, "menu_browse_servers.png", CVector2D(0.168f, fBase + fGap * 1))); m_menuItems.push_back(CreateItem(MENU_ITEM_HOST_GAME, "menu_host_game.png", CVector2D(0.168f, fBase + fGap * 2))); m_menuItems.push_back(CreateItem(MENU_ITEM_MAP_EDITOR, "menu_map_editor.png", CVector2D(0.168f, fBase + fGap * 3))); m_menuItems.push_back(CreateItem(MENU_ITEM_SETTINGS, "menu_settings.png", CVector2D(0.168f, fBase + fGap * 4))); m_menuItems.push_back(CreateItem(MENU_ITEM_ABOUT, "menu_about.png", CVector2D(0.168f, fBase + fGap * 5))); m_menuItems.push_back(CreateItem(MENU_ITEM_QUIT, "menu_quit.png", CVector2D(0.168f, fBase + fGap * 6))); // We store the position of the top item, and the second item. These will be useful later float fFirstItemSize = m_menuItems.front()->image->GetSize(false).fY; float fSecondItemSize = m_menuItems[1]->image->GetSize(false).fY; m_iFirstItemCentre = (m_menuItems.front()->image)->GetPosition().fY + fFirstItemSize * 0.5f; m_iSecondItemCentre = (m_menuItems[1]->image)->GetPosition().fY + fSecondItemSize * 0.5f; // Store some mouse over bounding box positions m_menuAX = (0.168f * m_iMenuSizeX) + m_iXOff; // Left side of the items m_menuAY = m_iFirstItemCentre - fFirstItemSize * (CORE_MTA_HOVER_SCALE / CORE_MTA_NORMAL_SCALE) * 0.5f; // Top side of the items m_menuBX = m_menuAX + ((390 / NATIVE_RES_X) * m_iMenuSizeX); // Right side of the items. We add the longest picture (browse_servers) m_menuAY += BODGE_FACTOR_1; m_pMenuArea = reinterpret_cast<CGUIStaticImage*>(pManager->CreateStaticImage(m_pCanvas)); m_pMenuArea->LoadFromFile(CORE_MTA_FILLER); m_pMenuArea->SetPosition(CVector2D(m_menuAX - m_iXOff, m_menuAY - m_iYOff) + BODGE_FACTOR_5, false); m_pMenuArea->SetSize(CVector2D(m_menuBX - m_menuAX, m_menuBY - m_menuAY) + BODGE_FACTOR_6, false); m_pMenuArea->SetAlpha(0); m_pMenuArea->SetZOrderingEnabled(false); m_pMenuArea->SetClickHandler(GUI_CALLBACK(&CMainMenu::OnMenuClick, this)); m_pMenuArea->SetMouseEnterHandler(GUI_CALLBACK(&CMainMenu::OnMenuEnter, this)); m_pMenuArea->SetMouseLeaveHandler(GUI_CALLBACK(&CMainMenu::OnMenuExit, this)); float fDrawSizeX = (365 / NATIVE_RES_X) * m_iMenuSizeX; // Right aligned float fDrawSizeY = (52 / NATIVE_RES_Y) * m_iMenuSizeY; float fDrawPosX = 0.83f * m_iMenuSizeX - fDrawSizeX; float fDrawPosY = 0.60f * m_iMenuSizeY; m_pLatestNews = reinterpret_cast<CGUIStaticImage*>(pManager->CreateStaticImage()); m_pLatestNews->LoadFromFile(CORE_MTA_LATEST_NEWS); m_pLatestNews->SetParent(m_pCanvas); m_pLatestNews->SetPosition(CVector2D(fDrawPosX, fDrawPosY), false); m_pLatestNews->SetSize(CVector2D(fDrawSizeX, fDrawSizeY), false); m_pLatestNews->SetProperty("InheritsAlpha", "False"); m_pLatestNews->SetVisible(false); // Create news item stuff fDrawPosX -= 25; fDrawPosY += fDrawSizeY - 8; for (uint i = 0; i < CORE_MTA_NEWS_ITEMS; i++) { fDrawPosY += 20; // Create our shadow and item CGUILabel* pItemShadow = reinterpret_cast<CGUILabel*>(m_pManager->CreateLabel(m_pCanvas, " ")); CGUILabel* pItem = reinterpret_cast<CGUILabel*>(m_pManager->CreateLabel(m_pCanvas, " ")); pItem->SetFont("sans"); pItemShadow->SetFont("sans"); pItem->SetHorizontalAlign(CGUI_ALIGN_RIGHT); pItemShadow->SetHorizontalAlign(CGUI_ALIGN_RIGHT); pItem->SetSize(CVector2D(fDrawSizeX, 14), false); pItemShadow->SetSize(CVector2D(fDrawSizeX, 15), false); pItem->SetPosition(CVector2D(fDrawPosX, fDrawPosY), false); pItemShadow->SetPosition(CVector2D(fDrawPosX + 1, fDrawPosY + 1), false); pItemShadow->SetTextColor(112, 112, 112); // Set the handlers pItem->SetClickHandler(GUI_CALLBACK(&CMainMenu::OnNewsButtonClick, this)); // Store the item in the array m_pNewsItemLabels[i] = pItem; m_pNewsItemShadowLabels[i] = pItemShadow; // Create our date label fDrawPosY += 15; CGUILabel* pItemDate = reinterpret_cast<CGUILabel*>(m_pManager->CreateLabel(m_pCanvas, " ")); pItemDate->SetFont("default-small"); pItemDate->SetHorizontalAlign(CGUI_ALIGN_RIGHT); pItemDate->SetSize(CVector2D(fDrawSizeX, 13), false); pItemDate->SetPosition(CVector2D(fDrawPosX, fDrawPosY), false); m_pNewsItemDateLabels[i] = pItemDate; // Create 'NEW' sticker CGUILabel*& pLabel = m_pNewsItemNEWLabels[i]; pLabel = reinterpret_cast<CGUILabel*>(pManager->CreateLabel(m_pCanvas, "NEW")); pLabel->SetFont("default-small"); pLabel->SetTextColor(255, 0, 0); pLabel->AutoSize(pLabel->GetText().c_str()); pLabel->SetAlpha(0.7f); pLabel->SetVisible(false); } m_pLogo->MoveToBack(); // Submenus m_QuickConnect.SetVisible(false); m_ServerBrowser.SetVisible(false); m_ServerInfo.Hide(); m_Settings.SetVisible(false); m_Credits.SetVisible(false); m_pNewsBrowser->SetVisible(false); // We're not ingame SetIsIngame(false); // Store the pointer to the graphics subsystem m_pGraphics = CGraphics::GetSingletonPtr(); // Load the server lists CXMLNode* pConfig = CCore::GetSingletonPtr()->GetConfig(); m_ServerBrowser.LoadServerList(pConfig->FindSubNode(CONFIG_NODE_SERVER_FAV), CONFIG_FAVOURITE_LIST_TAG, m_ServerBrowser.GetFavouritesList()); m_ServerBrowser.LoadServerList(pConfig->FindSubNode(CONFIG_NODE_SERVER_REC), CONFIG_RECENT_LIST_TAG, m_ServerBrowser.GetRecentList()); m_ServerBrowser.LoadServerList(pConfig->FindSubNode(CONFIG_NODE_SERVER_HISTORY), CONFIG_HISTORY_LIST_TAG, m_ServerBrowser.GetHistoryList()); // Remove unused node if (CXMLNode* pOldNode = pConfig->FindSubNode(CONFIG_NODE_SERVER_INT)) pConfig->DeleteSubNode(pOldNode); #ifdef CI_BUILD // Add feature branch alert m_pFeatureBranchAlertTexture.reset(reinterpret_cast<CGUITexture*>(m_pManager->CreateTexture())); std::int32_t buffer = 0xFFFF0000; m_pFeatureBranchAlertTexture->LoadFromMemory(&buffer, 1, 1); // HACK: Load red dot m_pFeatureBranchAlertImage.reset(reinterpret_cast<CGUIStaticImage*>(m_pManager->CreateStaticImage(m_pBackground))); m_pFeatureBranchAlertImage->LoadFromTexture(m_pFeatureBranchAlertTexture.get()); m_pFeatureBranchAlertImage->SetPosition({0.0f, 0.0f}, false); m_pFeatureBranchAlertImage->SetSize({ScreenSize.fX, 35.0f}); m_pFeatureBranchAlertLabel.reset(reinterpret_cast<CGUILabel*>(m_pManager->CreateLabel(m_pFeatureBranchAlertImage.get()))); m_pFeatureBranchAlertLabel->SetText( _("You are using a feature-branch build! This is a test build only which cannot be used to connect to public servers!")); m_pFeatureBranchAlertLabel->SetPosition({0.0f, 0.0f}, false); m_pFeatureBranchAlertLabel->SetSize({ScreenSize.fX, 35.0f}); m_pFeatureBranchAlertLabel->SetFont("clear-normal"); m_pFeatureBranchAlertLabel->SetHorizontalAlign(CGUI_ALIGN_HORIZONTALCENTER); m_pFeatureBranchAlertLabel->SetVerticalAlign(CGUI_ALIGN_VERTICALCENTER); #endif }