void InGameMenu::DoLayout() { //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 boost::shared_ptr<GG::Font> font = ClientUI::GetFont(); button_width = std::max(button_width, m_save_btn->MinUsableSize().x); button_width = std::max(button_width, m_load_btn->MinUsableSize().x); button_width = std::max(button_width, m_options_btn->MinUsableSize().x); button_width = std::max(button_width, m_exit_btn->MinUsableSize().x); button_width = std::max(button_width, m_done_btn->MinUsableSize().x); button_width = std::max(MIN_BUTTON_WIDTH, button_width); //calculate necessary button height button_cell_height = std::max(MIN_BUTTON_HEIGHT, m_done_btn->MinUsableSize().y); //culate window width and height mainmenu_width = button_width + H_MAINMENU_MARGIN; mainmenu_height = 5.75 * button_cell_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, m_done_btn->MinUsableSize().y); button_lr += button_ul; m_save_btn->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height); button_lr.y += GG::Y(button_cell_height); m_load_btn->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height); button_lr.y += GG::Y(button_cell_height); m_options_btn->SizeMove(button_ul, button_lr); button_ul.y += GG::Y(button_cell_height); button_lr.y += GG::Y(button_cell_height); m_exit_btn->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_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); 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); }