Пример #1
0
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);
}
Пример #2
0
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));
}
Пример #3
0
	_OwqWindow(BMessenger target, const BMessage* prefs = 0)
			: BWindow(	BRect(100, 100, 300, 300),
						"Open From Query",
						B_TITLED_WINDOW_LOOK,
						B_NORMAL_WINDOW_FEEL,
						B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE),
			  mTarget(target), mFilePanel(0), mOnBox(0), mNameCtrl(0), mFileButton(0), mSkipBox(0),
			  mRef(0)
	{
		BRect	b = Bounds();
		BView*	v = new BView( b, "bg", B_FOLLOW_ALL, 0 );
		float	bottom = b.bottom;
		if (v) {
			v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
			float	cbH = check_box_height( v );
			BRect	f(5, 5, b.right - 5, 5 + cbH);
			mOnBox = new BCheckBox( f, "on_box", "On", new BMessage( OWQ_ON_MSG ) );
			if( mOnBox ) {
				mOnBox->SetValue( B_CONTROL_ON );
				v->AddChild( mOnBox );
			}
			f.OffsetBy( 0, f.Height() + 10 );
			f.bottom = f.top + text_control_height( v );
			mNameCtrl = new BTextControl( f, "name_ctrl", "Name: ", "", new BMessage( OWQ_NAME_MSG ) );
			if( mNameCtrl ) {
				mNameCtrl->SetDivider( v->StringWidth( "Name:" ) + 10 );
				v->AddChild( mNameCtrl );
			}
			f.OffsetBy( 0, f.Height() + 10 );
			f.bottom = f.top + button_height( v );
			mFileButton = new BButton( f, "file_ctrl", "Choose Query", new BMessage( OWQ_CHOOSE_FILE_MSG ) );
			if( mFileButton ) v->AddChild( mFileButton );

/* I've turned off skip for now -- I think just having it on
 * is easier than explaining it.
 */
#if 0
			f.OffsetBy( 0, f.Height() + 5 );
			f.bottom = f.top + cbH;
			mSkipBox = new BCheckBox( f, "skip_box", "Skip top level", new BMessage( OWQ_SKIP_MSG ) );
			if( mSkipBox ) v->AddChild( mSkipBox );
#endif
			f.top = f.bottom + 10;
			f.bottom = f.top + button_height( v );
			float	buttonW = 60;
			f.left = f.right - buttonW;
			BButton*	button = new BButton( f, "ok_button", "OK", new BMessage( OK_MSG ) );
			if( button ) {
				v->AddChild( button );
				button->MakeDefault( true );
			}
			f.OffsetBy( 0-(buttonW + 10), 0 );
			button = new BButton( f, "cancel_button", "Cancel", new BMessage( CANCEL_MSG ) );
			if( button ) v->AddChild( button );

			bottom = f.bottom + 5;
			AddChild( v );
		}

		ResizeTo( b.Width(), bottom );
		if( prefs ) SetPrefs( prefs );

		bool	enable = false;
		if( mOnBox && mOnBox->Value() == B_CONTROL_ON ) enable = true;
		SetControlEnable(enable);
	}
Пример #4
0
/////////////////////////////////
// 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);
}