void MainMenu::InitWindow( const glm::ivec2 Size ) { Win = sfg::Window::Create( sfg::Window::Style::BACKGROUND | sfg::Window::Style::TITLEBAR | sfg::Window::Style::SHADOW ); Win->SetRequisition( sf::Vector2f( Size.x, Size.y ) ); updatePosition(); // create buttons and link them to methods sfg::Button::Ptr btnResume( sfg::Button::Create( "Resume" ) ); btnResume->GetSignal( sfg::Button::OnLeftClick ).Connect( std::bind( &MainMenu::BtnResumeClick, this )); sfg::Button::Ptr btnNew( sfg::Button::Create( "New Simulation" ) ); btnNew->GetSignal( sfg::Button::OnLeftClick ).Connect( std::bind( &MainMenu::BtnNewClick, this )); // exit button sfg::Button::Ptr btnExit( sfg::Button::Create( "Exit Program" ) ); btnExit->GetSignal( sfg::Button::OnLeftClick ).Connect( std::bind( &MainMenu::BtnExitClick, this )); // save and load sfg::Button::Ptr btnSave( sfg::Button::Create( "Save Simulation" ) ); btnSave->GetSignal( sfg::Button::OnLeftClick ).Connect( std::bind( &MainMenu::BtnSaveClick, this )); sfg::Button::Ptr btnLoad( sfg::Button::Create( "Load Simulation" ) ); btnLoad->GetSignal( sfg::Button::OnLeftClick ).Connect( std::bind( &MainMenu::BtnLoadClick, this )); // options sfg::Button::Ptr btnOptions( sfg::Button::Create( "Options" ) ); // main box, vertical sfg::Box::Ptr box( sfg::Box::Create( sfg::Box::Orientation::VERTICAL, 3.0f ) ); box->Pack( btnResume, false, false ); box->Pack( btnNew, false, false ); box->Pack( btnSave, false, false ); box->Pack( btnLoad, false, false ); box->Pack( btnOptions, false, false ); box->Pack( btnExit, false, false ); // Create a window and add the box layouter to it. Also set the window's title. Win->SetTitle( "Main Menu [ESC]" ); Win->Add( box ); Module::Get()->QueueEvent( Event( "SCREEN_ADD_WINDOW", Win ) ); fb = std::make_shared<sbe::FileBrowse> ( glm::ivec2{600,400} ); }
int CUIManager::MainMenu() { gpGeneral->ClearScreen(false, false, true); CBox box(150, 200, 340, 240, 200, 50, 170); gpGeneral->DrawTextBrush("MAIN MENU", 205, 205, 255, 255, 50, 50); CButton btnSingleGame(1, 200, 265, 240, 30, 150, 20, 230); #if 0 CButton btnNetGame(2, 200, 305, 240, 30, 150, 20, 230); #endif CButton btnOptions(3, 200, 345, 240, 30, 150, 20, 230); CButton btnQuit(4, 200, 385, 240, 30, 150, 20, 230); const char *szSingleGame = msg("menu_singlegame"); #if 0 const char *szNetGame = msg("menu_netgame"); #endif const char *szOptions = msg("menu_options"); const char *szQuit = msg("menu_quit"); const char *szCopyright = msg("copyright"); gpGeneral->DrawText(szSingleGame, 320 - strlen(szSingleGame) * 4, 272, 255, 255, 50); #if 0 gpGeneral->DrawText(szNetGame, 320 - strlen(szNetGame) * 4, 312, 255, 255, 50); #endif gpGeneral->DrawText(szOptions, 320 - strlen(szOptions) * 4, 352, 255, 255, 50); gpGeneral->DrawText(szQuit, 320 - strlen(szQuit) * 4, 392, 255, 255, 50); gpGeneral->DrawText(szCopyright, 320 - strlen(szCopyright) * 4, 460, 255, 255, 255); while (1) { int key = gpGeneral->ReadKey() - SDLK_LAST; switch (key) { case 1: case 2: case 3: return key; break; case 4: UserQuit(); break; } } }