void InGameMenu::DoLayout() { //size calculation consts and variables const GG::X MIN_BUTTON_WIDTH(160); const GG::Y MIN_BUTTON_HEIGHT(40); const GG::X H_BUTTON_MARGIN(16); //horizontal empty space const GG::Y V_BUTTON_MARGIN(16); //vertical empty space GG::X button_width(0); //width of the buttons GG::Y button_height(0); //height of the buttons const GG::X H_MAINMENU_MARGIN(40); //horizontal empty space const GG::Y V_MAINMENU_MARGIN(40); //vertical empty space GG::X mainmenu_width(0); //width of the mainmenu GG::Y mainmenu_height(0); //height of the mainmenu //calculate necessary button width boost::shared_ptr<GG::Font> font = ClientUI::GetFont(); button_width = std::max(button_width, font->TextExtent(m_save_btn->Text()).x); button_width = std::max(button_width, font->TextExtent(m_load_btn->Text()).x); button_width = std::max(button_width, font->TextExtent(m_options_btn->Text()).x); button_width = std::max(button_width, font->TextExtent(m_exit_btn->Text()).x); button_width = std::max(button_width, font->TextExtent(m_done_btn->Text()).x); button_width += H_BUTTON_MARGIN; button_width = std::max(MIN_BUTTON_WIDTH, button_width); //calculate necessary button height button_height = std::max(MIN_BUTTON_HEIGHT, font->Height() + V_BUTTON_MARGIN); //culate window width and height mainmenu_width = button_width + H_MAINMENU_MARGIN; mainmenu_height = 5.75 * button_height + V_MAINMENU_MARGIN; // 8 rows + 0.75 before exit button // place buttons GG::Pt button_ul(GG::X(15), GG::Y(12)); GG::Pt button_lr(button_width, ClientUI::GetFont()->Lineskip() + 6); button_lr += button_ul; m_save_btn->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_height); button_lr.y += GG::Y(button_height); m_load_btn->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_height); button_lr.y += GG::Y(button_height); m_options_btn->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_height); button_lr.y += GG::Y(button_height); m_exit_btn->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_height) * 1.75; button_lr.y += GG::Y(button_height) * 1.75; m_done_btn->SizeMove(button_ul, button_lr); // position menu window GG::Pt ul(GG::GUI::GetGUI()->AppWidth() * 0.5 - mainmenu_width/2, GG::GUI::GetGUI()->AppHeight() * 0.5 - mainmenu_height/2); GG::Pt lr(GG::GUI::GetGUI()->AppWidth() * 0.5 + mainmenu_width/2, GG::GUI::GetGUI()->AppHeight() * 0.5 + mainmenu_height/2); this->SizeMove(ul, lr); }
void IntroScreen::DoLayout() { m_splash->Resize(this->Size()); m_logo->Resize(GG::Pt(this->Width(), this->Height() / 10)); m_version->MoveTo(GG::Pt(this->Width() - m_version->Width(), this->Height() - m_version->Height())); //size calculation consts and variables const GG::X MIN_BUTTON_WIDTH(160); const GG::Y MIN_BUTTON_HEIGHT(40); const GG::X H_BUTTON_MARGIN(16); //horizontal empty space const GG::Y V_BUTTON_MARGIN(16); //vertical empty space GG::X button_width(0); //width of the buttons GG::Y button_height(0); //height of the buttons const GG::X H_MAINMENU_MARGIN(40); //horizontal empty space const GG::Y V_MAINMENU_MARGIN(40); //vertical empty space GG::X mainmenu_width(0); //width of the mainmenu GG::Y mainmenu_height(0); //height of the mainmenu //calculate necessary button width boost::shared_ptr<GG::Font> font = ClientUI::GetFont(); button_width += H_BUTTON_MARGIN; button_width = std::max(MIN_BUTTON_WIDTH, button_width); //calculate necessary button height button_height = std::max(MIN_BUTTON_HEIGHT, font->Height() + V_BUTTON_MARGIN); //culate window width and height mainmenu_width = button_width + H_MAINMENU_MARGIN; mainmenu_height = 8.75 * button_height + V_MAINMENU_MARGIN; // 8 rows + 0.75 before exit button // position menu window GG::Pt ul(Width() * GetOptionsDB().Get<double>("UI.main-menu.x") - mainmenu_width/2, Height() * GetOptionsDB().Get<double>("UI.main-menu.y") - mainmenu_height/2); GG::Pt lr(Width() * GetOptionsDB().Get<double>("UI.main-menu.x") + mainmenu_width/2, Height() * GetOptionsDB().Get<double>("UI.main-menu.y") + mainmenu_height/2); m_menu->SizeMove(ul, lr); //create buttons GG::Y button_y(12); //relativ buttonlocation GG::X button_x(15); m_single_player->MoveTo(GG::Pt(button_x, button_y)); button_y += button_height; m_quick_start->MoveTo(GG::Pt(button_x, button_y)); button_y += button_height; m_multi_player->MoveTo(GG::Pt(button_x, button_y)); button_y += button_height; m_load_game->MoveTo(GG::Pt(button_x, button_y)); button_y += button_height; m_options->MoveTo(GG::Pt(button_x, button_y)); button_y += button_height; m_about->MoveTo(GG::Pt(button_x, button_y)); button_y += button_height; m_credits->MoveTo(GG::Pt(button_x, button_y)); button_y += 1.75 * button_height; m_exit_game->MoveTo(GG::Pt(button_x, button_y)); }
///////////////////////////////// // IntroScreen ///////////////////////////////// IntroScreen::IntroScreen() : GG::Wnd(GG::X0, GG::Y0, GG::GUI::GetGUI()->AppWidth(), GG::GUI::GetGUI()->AppHeight(), GG::Flags<GG::WndFlag>()), m_single_player(0), m_quick_start(0), m_multi_player(0), m_load_game(0), m_options(0), m_about(0), m_credits(0), m_exit_game(0), m_credits_wnd(0), m_menu(0), m_splash(0), m_logo(0), m_version(0) { m_menu = new CUIWnd(UserString("INTRO_WINDOW_TITLE"), GG::X1, GG::Y1, MAIN_MENU_WIDTH, MAIN_MENU_HEIGHT, GG::ONTOP | GG::INTERACTIVE); m_splash = new GG::StaticGraphic(GG::X0, GG::Y0, Width(), Height(), ClientUI::GetTexture(ClientUI::ArtDir() / "splash.png"), GG::GRAPHIC_FITGRAPHIC, GG::INTERACTIVE); m_logo = new GG::StaticGraphic(GG::X0, GG::Y0, Width(), Height() / 10, ClientUI::GetTexture(ClientUI::ArtDir() / "logo.png"), GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); m_version = new GG::TextControl(GG::X0, GG::Y0, FreeOrionVersionString(), ClientUI::GetFont(), ClientUI::TextColor()); m_version->MoveTo(GG::Pt(Width() - m_version->Width(), Height() - m_version->Height())); AttachChild(m_splash); m_splash->AttachChild(m_logo); m_splash->AttachChild(m_menu); m_splash->AttachChild(m_version); //size calculation consts and variables const GG::X MIN_BUTTON_WIDTH(160); const GG::Y MIN_BUTTON_HEIGHT(40); const GG::X H_BUTTON_MARGIN(16); //horizontal empty space const GG::Y V_BUTTON_MARGIN(16); //vertical empty space GG::X button_width(0); //width of the buttons GG::Y button_height(0); //height of the buttons const GG::X H_MAINMENU_MARGIN(40); //horizontal empty space const GG::Y V_MAINMENU_MARGIN(40); //vertical empty space GG::X mainmenu_width(0); //width of the mainmenu GG::Y mainmenu_height(0); //height of the mainmenu //calculate necessary button width boost::shared_ptr<GG::Font> font = ClientUI::GetFont(); button_width = std::max(font->TextExtent(UserString("INTRO_BTN_SINGLE_PLAYER")).x, button_width); button_width = std::max(font->TextExtent(UserString("INTRO_BTN_QUICK_START")).x, button_width); button_width = std::max(font->TextExtent(UserString("INTRO_BTN_MULTI_PLAYER")).x, button_width); button_width = std::max(font->TextExtent(UserString("INTRO_BTN_LOAD_GAME")).x, button_width); button_width = std::max(font->TextExtent(UserString("INTRO_BTN_OPTIONS")).x, button_width); button_width = std::max(font->TextExtent(UserString("INTRO_BTN_ABOUT")).x, button_width); button_width = std::max(font->TextExtent(UserString("INTRO_BTN_CREDITS")).x, button_width); button_width = std::max(font->TextExtent(UserString("INTRO_BTN_EXIT")).x, button_width); button_width += H_BUTTON_MARGIN; button_width = std::max(MIN_BUTTON_WIDTH, button_width); //calculate necessary button height button_height = std::max(MIN_BUTTON_HEIGHT, font->Height() + V_BUTTON_MARGIN); //culate window width and height mainmenu_width = button_width + H_MAINMENU_MARGIN; mainmenu_height = 8.75 * button_height + V_MAINMENU_MARGIN; // 8 rows + 0.75 before exit button // position menu window GG::Pt ul(Width() * GetOptionsDB().Get<double>("UI.main-menu.x") - mainmenu_width/2, Height() * GetOptionsDB().Get<double>("UI.main-menu.y") - mainmenu_height/2); GG::Pt lr(Width() * GetOptionsDB().Get<double>("UI.main-menu.x") + mainmenu_width/2, Height() * GetOptionsDB().Get<double>("UI.main-menu.y") + mainmenu_height/2); m_menu->SizeMove(ul, lr); //create buttons GG::Y button_y(12); //relativ buttonlocation GG::X button_x(15); m_single_player = new CUIButton(button_x, button_y, button_width, UserString("INTRO_BTN_SINGLE_PLAYER")); button_y += button_height; m_quick_start = new CUIButton(button_x, button_y, button_width, UserString("INTRO_BTN_QUICK_START")); button_y += button_height; m_multi_player = new CUIButton(button_x, button_y, button_width, UserString("INTRO_BTN_MULTI_PLAYER")); button_y += button_height; m_load_game = new CUIButton(button_x, button_y, button_width, UserString("INTRO_BTN_LOAD_GAME")); button_y += button_height; m_options = new CUIButton(button_x, button_y, button_width, UserString("INTRO_BTN_OPTIONS")); button_y += button_height; m_about = new CUIButton(button_x, button_y, button_width, UserString("INTRO_BTN_ABOUT")); button_y += button_height; m_credits = new CUIButton(button_x, button_y, button_width, UserString("INTRO_BTN_CREDITS")); button_y += 1.75 * button_height; m_exit_game = new CUIButton(button_x, button_y, button_width, UserString("INTRO_BTN_EXIT")); //attach buttons m_menu->AttachChild(m_single_player); m_menu->AttachChild(m_quick_start); m_menu->AttachChild(m_multi_player); m_menu->AttachChild(m_load_game); m_menu->AttachChild(m_options); m_menu->AttachChild(m_about); m_menu->AttachChild(m_credits); m_menu->AttachChild(m_exit_game); //connect signals and slots GG::Connect(m_single_player->ClickedSignal, &IntroScreen::OnSinglePlayer, this); GG::Connect(m_quick_start->ClickedSignal, &IntroScreen::OnQuickStart, this); GG::Connect(m_multi_player->ClickedSignal, &IntroScreen::OnMultiPlayer, this); GG::Connect(m_load_game->ClickedSignal, &IntroScreen::OnLoadGame, this); GG::Connect(m_options->ClickedSignal, &IntroScreen::OnOptions, this); GG::Connect(m_about->ClickedSignal, &IntroScreen::OnAbout, this); GG::Connect(m_credits->ClickedSignal, &IntroScreen::OnCredits, this); GG::Connect(m_exit_game->ClickedSignal, &IntroScreen::OnExitGame, this); }
void IntroScreen::DoLayout() { m_splash->Resize(this->Size()); m_logo->Resize(GG::Pt(this->Width(), this->Height() / 10)); m_version->MoveTo(GG::Pt(this->Width() - m_version->Width(), this->Height() - m_version->Height())); //size calculation consts and variables const GG::X MIN_BUTTON_WIDTH(160); const GG::Y MIN_BUTTON_HEIGHT(40); GG::X button_width(0); //width of the buttons GG::Y button_cell_height(0); //height of the buttons const GG::X H_MAINMENU_MARGIN(40); //horizontal empty space const GG::Y V_MAINMENU_MARGIN(40); //vertical empty space GG::X mainmenu_width(0); //width of the mainmenu GG::Y mainmenu_height(0); //height of the mainmenu //calculate necessary button width button_width = std::max(button_width, m_single_player->MinUsableSize().x); button_width = std::max(button_width, m_quick_start->MinUsableSize().x); button_width = std::max(button_width, m_multi_player->MinUsableSize().x); button_width = std::max(button_width, m_load_game->MinUsableSize().x); button_width = std::max(button_width, m_options->MinUsableSize().x); button_width = std::max(button_width, m_pedia->MinUsableSize().x); button_width = std::max(button_width, m_about->MinUsableSize().x); button_width = std::max(button_width, m_website->MinUsableSize().x); button_width = std::max(button_width, m_credits->MinUsableSize().x); button_width = std::max(button_width, m_exit_game->MinUsableSize().x); button_width = std::max(MIN_BUTTON_WIDTH, button_width); //calculate necessary button height button_cell_height = std::max(MIN_BUTTON_HEIGHT, m_exit_game->MinUsableSize().y); //culate window width and height mainmenu_width = button_width + H_MAINMENU_MARGIN; mainmenu_height = 10.75 * button_cell_height + V_MAINMENU_MARGIN; // 10 rows + 0.75 before exit button // place buttons GG::Pt button_ul(GG::X(15), GG::Y(12)); GG::Pt button_lr(button_width, m_exit_game->MinUsableSize().y); button_lr += button_ul; m_single_player->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height); button_lr.y += GG::Y(button_cell_height); m_quick_start->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height); button_lr.y += GG::Y(button_cell_height); m_multi_player->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height); button_lr.y += GG::Y(button_cell_height); m_load_game->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height); button_lr.y += GG::Y(button_cell_height); m_options->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height); button_lr.y += GG::Y(button_cell_height); m_pedia->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height); button_lr.y += GG::Y(button_cell_height); m_about->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height); button_lr.y += GG::Y(button_cell_height); m_website->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height); button_lr.y += GG::Y(button_cell_height); m_credits->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height) * 1.75; button_lr.y += GG::Y(button_cell_height) * 1.75; m_exit_game->SizeMove(button_ul, button_lr); // position menu window GG::Pt ul(Width() * GetOptionsDB().Get<double>("UI.main-menu.x") - mainmenu_width/2, Height() * GetOptionsDB().Get<double>("UI.main-menu.y") - mainmenu_height/2); GG::Pt lr(Width() * GetOptionsDB().Get<double>("UI.main-menu.x") + mainmenu_width/2, Height() * GetOptionsDB().Get<double>("UI.main-menu.y") + mainmenu_height/2); m_menu->SizeMove(ul, lr); }