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 ) ); }
void CServerBrowser::CreateTab ( ServerBrowserType type, const char* szName ) { CGUI *pManager = g_pCore->GetGUI (); m_pTab [ type ] = m_pTabs->CreateTab ( szName ); // Create the serverlist m_pServerList [ type ] = reinterpret_cast < CGUIGridList* > ( pManager->CreateGridList ( m_pTab [ type ] ) ); m_pServerList [ type ]->SetPosition ( CVector2D ( 0.02f, 0.10f ), true ); m_pServerList [ type ]->SetSize ( CVector2D ( 0.80f, 0.815f ), true ); m_pServerListRevision [ type ] = 0; // Server player list label m_pServerPlayerListLabel [ type ] = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( m_pTab [ type ], "Player List:" ) ); m_pServerPlayerListLabel [ type ]->SetPosition ( CVector2D ( 0.83f, 0.34f ), true ); m_pServerPlayerListLabel [ type ]->AutoSize ( "Player List:" ); // Server player list m_pServerPlayerList [ type ] = reinterpret_cast < CGUIGridList* > ( pManager->CreateGridList ( m_pTab [ type ] ) ); m_pServerPlayerList [ type ]->SetPosition ( CVector2D ( 0.83f, 0.38f ), true ); m_pServerPlayerList [ type ]->SetSize ( CVector2D ( 0.15f, 0.585f ), true ); m_pServerPlayerList [ type ]->SetIgnoreTextSpacer ( true ); // Filters // Server search edit m_pEditServerSearch [ type ] = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( m_pTab [ type ], "" ) ); m_pEditServerSearch [ type ]->SetPosition ( CVector2D ( 0.02f, 0.04f ), true ); m_pEditServerSearch [ type ]->SetSize ( CVector2D ( 0.19f, 0.05f ), true ); m_pEditServerSearch [ type ]->SetTextChangedHandler( GUI_CALLBACK( &CServerBrowser::OnFilterChanged, this ) ); // Server search icon m_pServerSearchIcon [ type ] = reinterpret_cast < CGUIStaticImage* > ( pManager->CreateStaticImage ( m_pEditServerSearch [ type ] ) ); m_pServerSearchIcon [ type ]->SetPosition ( CVector2D ( 0.85f, 0.15f ), true ); m_pServerSearchIcon [ type ]->SetSize ( CVector2D ( 16, 14 ), false ); m_pServerSearchIcon [ type ]->LoadFromFile ( "cgui\\images\\magnfglasssmall.png" ); // Player search edit m_pEditPlayerSearch [ type ] = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( m_pTab [ type ], "" ) ); m_pEditPlayerSearch [ type ]->SetPosition ( CVector2D ( 0.83f, 0.28f ), true ); m_pEditPlayerSearch [ type ]->SetSize ( CVector2D ( 0.15f, 0.05f ), true ); m_pEditPlayerSearch [ type ]->SetTextChangedHandler( GUI_CALLBACK( &CServerBrowser::OnFilterChanged, this ) ); // Player search icon m_pPlayerSearchIcon [ type ] = reinterpret_cast < CGUIStaticImage* > ( pManager->CreateStaticImage ( m_pEditPlayerSearch [ type ] ) ); m_pPlayerSearchIcon [ type ]->SetPosition ( CVector2D ( 0.8f, 0.15f ), true ); m_pPlayerSearchIcon [ type ]->SetSize ( CVector2D ( 16, 14 ), false ); m_pPlayerSearchIcon [ type ]->LoadFromFile ( "cgui\\images\\magnfglasssmall.png" ); // Include checkboxes m_pIncludeEmpty [ type ] = reinterpret_cast < CGUICheckBox* > ( pManager->CreateCheckBox ( m_pTab [ type ], "Include Empty", true ) ); m_pIncludeEmpty [ type ]->SetPosition ( CVector2D ( 0.225f, 0.045f ), true ); m_pIncludeEmpty [ type ]->SetClickHandler ( GUI_CALLBACK ( &CServerBrowser::OnFilterChanged, this ) ); m_pIncludeFull [ type ] = reinterpret_cast < CGUICheckBox* > ( pManager->CreateCheckBox ( m_pTab [ type ], "Include Full", true ) ); m_pIncludeFull [ type ]->SetPosition ( CVector2D ( 0.38f, 0.045f ), true ); m_pIncludeFull [ type ]->SetClickHandler ( GUI_CALLBACK ( &CServerBrowser::OnFilterChanged, this ) ); m_pIncludeLocked [ type ] = reinterpret_cast < CGUICheckBox* > ( pManager->CreateCheckBox ( m_pTab [ type ], "Include Locked", true ) ); m_pIncludeLocked [ type ]->SetPosition ( CVector2D ( 0.515f, 0.045f ), true ); m_pIncludeLocked [ type ]->SetClickHandler ( GUI_CALLBACK ( &CServerBrowser::OnFilterChanged, this ) ); if ( type != ServerBrowserType::INTERNET && type != ServerBrowserType::LAN ) { m_pIncludeOffline [ type ] = reinterpret_cast < CGUICheckBox* > ( pManager->CreateCheckBox ( m_pTab [ type ], "Include Offline", true ) ); m_pIncludeOffline [ type ]->SetPosition ( CVector2D ( 0.675f, 0.045f ), true ); m_pIncludeOffline [ type ]->SetClickHandler ( GUI_CALLBACK ( &CServerBrowser::OnFilterChanged, this ) ); } else { m_pIncludeOffline [ type ] = NULL; } // Buttons // Connect button m_pButtonConnect [ type ] = reinterpret_cast < CGUIButton* > ( pManager->CreateButton ( m_pTab [ type ], "Connect" ) ); m_pButtonConnect [ type ]->SetPosition ( CVector2D ( 0.83f, 0.05f ), true ); m_pButtonConnect [ type ]->SetSize ( CVector2D ( 0.15f, 0.04f ), true ); m_pButtonConnect [ type ]->SetAlwaysOnTop ( true ); // Refresh button m_pButtonRefresh [ type ] = reinterpret_cast < CGUIButton* > ( pManager->CreateButton ( m_pTab [ type ], "Refresh" ) ); m_pButtonRefresh [ type ]->SetPosition ( CVector2D ( 0.83f, 0.11f ), true ); m_pButtonRefresh [ type ]->SetSize ( CVector2D ( 0.15f, 0.04f ), true ); // Add to Favourites button if ( type == ServerBrowserType::FAVOURITES ) { m_pButtonFavourites [ type ] = reinterpret_cast < CGUIButton* > ( pManager->CreateButton ( m_pTab [ type ], "Remove from Favourites" ) ); } else { m_pButtonFavourites [ type ] = reinterpret_cast < CGUIButton* > ( pManager->CreateButton ( m_pTab [ type ], "Add to Favourites" ) ); } m_pButtonFavourites [ type ]->SetPosition ( CVector2D ( 0.02f, 0.93f ), true ); m_pButtonFavourites [ type ]->SetSize ( CVector2D ( 0.25f, 0.04f ), true ); // Password label m_pLabelPassword [ type ] = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( m_pTab [ type ], "Password:"******"Password:"******"" ) ); m_pEditPassword [ type ]->SetPosition ( CVector2D ( 0.83f, 0.21f ), true ); m_pEditPassword [ type ]->SetSize ( CVector2D ( 0.15f, 0.05f ), true ); m_pEditPassword [ type ]->SetMasked ( true ); m_pEditPassword [ type ]->SetTextAcceptedHandler( GUI_CALLBACK( &CServerBrowser::OnConnectClick, this ) ); // Set up event handlers m_pButtonConnect [ type ]->SetClickHandler ( GUI_CALLBACK ( &CServerBrowser::OnConnectClick, this ) ); m_pButtonRefresh [ type ]->SetClickHandler ( GUI_CALLBACK ( &CServerBrowser::OnRefreshClick, this ) ); m_pButtonFavourites [ type ]->SetClickHandler ( GUI_CALLBACK ( &CServerBrowser::OnFavouritesClick, this ) ); // Server List Columns m_hSerial [ type ] = m_pServerList [ type ]->AddColumn ( "", 0.03f ); m_hLocked [ type ] = m_pServerList [ type ]->AddColumn ( "", 0.03f ); m_hName [ type ] = m_pServerList [ type ]->AddColumn ( "Name", 0.50f ); m_hPlayers [ type ] = m_pServerList [ type ]->AddColumn ( "Players", 0.14f ); m_hPing [ type ] = m_pServerList [ type ]->AddColumn ( "Ping", 0.10f ); m_hGame [ type ] = m_pServerList [ type ]->AddColumn ( "Game", 0.25f ); m_hMap [ type ] = m_pServerList [ type ]->AddColumn ( "Map", 0.25f ); m_hHost [ type ] = m_pServerList [ type ]->AddColumn ( "Host", 0.25f ); // Disable resizing of the first and second columns (Serial Auth & Locked) m_pServerList [ type ]->SetColumnSegmentSizingEnabled(0, false); m_pServerList [ type ]->SetColumnSegmentSizingEnabled(1, false); // Player List Columns m_hPlayerName [ type ] = m_pServerPlayerList [ type ]->AddColumn ( "Name", 0.75f ); }
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 ) ); }