#include <game_menu.h>
Inheritance diagram for GameMenu:
Public Member Functions | |
GameMenu () | |
~GameMenu () | |
Private Member Functions | |
void | SaveOptions () |
void | OnClic (const Point2i &mousePosition, int button) |
void | Draw (const Point2i &mousePosition) |
void | __sig_ok () |
void | __sig_cancel () |
Private Attributes | |
TeamsSelectionBox * | team_box |
MapSelectionBox * | map_box |
Box * | game_options |
SpinButtonWithPicture * | opt_duration_turn |
SpinButtonWithPicture * | opt_energy_ini |
CheckBox * | opt_scroll_on_border |
Definition at line 31 of file game_menu.h.
GameMenu::GameMenu | ( | ) |
Definition at line 55 of file game_menu.cpp.
00055 : 00056 Menu("menu/bg_play") 00057 { 00058 Profile *res = resource_manager.LoadXMLProfile( "graphism.xml",false); 00059 Rectanglei rectZero(0, 0, 0, 0); 00060 Rectanglei stdRect (0, 0, 130, 30); 00061 00062 Surface window = AppWormux::GetInstance()->video.window; 00063 00064 // Calculate main box size 00065 uint mainBoxWidth = window.GetWidth() - 2*MARGIN_SIDE; 00066 uint mapBoxHeight = (window.GetHeight() - MARGIN_TOP - MARGIN_BOTTOM - 2*MARGIN_SIDE) 00067 - TEAMS_BOX_H - OPTIONS_BOX_H; 00068 00069 // ################################################ 00070 // ## TEAM SELECTION 00071 // ################################################ 00072 team_box = new TeamsSelectionBox(Rectanglei(MARGIN_SIDE, MARGIN_TOP, 00073 mainBoxWidth, TEAMS_BOX_H)); 00074 00075 widgets.AddWidget(team_box); 00076 00077 // ################################################ 00078 // ## MAP SELECTION 00079 // ################################################ 00080 map_box = new MapSelectionBox( Rectanglei(MARGIN_SIDE, team_box->GetPositionY()+team_box->GetSizeY()+ MARGIN_SIDE, 00081 mainBoxWidth, mapBoxHeight), 00082 false); 00083 00084 widgets.AddWidget(map_box); 00085 00086 // ################################################ 00087 // ## GAME OPTIONS 00088 // ################################################ 00089 game_options = new HBox( Rectanglei(MARGIN_SIDE, map_box->GetPositionY()+map_box->GetSizeY()+ MARGIN_SIDE, 00090 mainBoxWidth/2, OPTIONS_BOX_H), true); 00091 game_options->AddWidget(new PictureWidget(Rectanglei(0,0,39,128), "menu/mode_label")); 00092 00093 game_options->SetMargin(50); 00094 00095 opt_duration_turn = new SpinButtonWithPicture(_("Duration of a turn"), "menu/timing_turn", 00096 stdRect, 00097 TPS_TOUR_MIN, 5, 00098 TPS_TOUR_MIN, TPS_TOUR_MAX); 00099 game_options->AddWidget(opt_duration_turn); 00100 00101 opt_energy_ini = new SpinButtonWithPicture(_("Initial energy"), "menu/energy", 00102 stdRect, 00103 100, 5, 00104 50, 200); 00105 game_options->AddWidget(opt_energy_ini); 00106 00107 opt_scroll_on_border = new PictureTextCBox(_("Scroll on border"), "menu/scroll_on_border", stdRect); 00108 game_options->AddWidget(opt_scroll_on_border); 00109 00110 game_options->AddWidget(new NullWidget(Rectanglei(0,0,50,10))); 00111 00112 widgets.AddWidget(game_options); 00113 00114 00115 // Values initialization 00116 00117 // Load game options 00118 GameMode * game_mode = GameMode::GetInstance(); 00119 opt_duration_turn->SetValue(game_mode->duration_turn); 00120 opt_energy_ini->SetValue(game_mode->character.init_energy); 00121 opt_scroll_on_border->SetValue(Config::GetInstance()->GetScrollOnBorder()); 00122 00123 resource_manager.UnLoadXMLProfile(res); 00124 }
Here is the call graph for this function:
GameMenu::~GameMenu | ( | ) |
void GameMenu::__sig_cancel | ( | ) | [private, virtual] |
void GameMenu::__sig_ok | ( | ) | [private, virtual] |
Implements Menu.
Definition at line 153 of file game_menu.cpp.
00154 { 00155 SaveOptions(); 00156 Game::GetInstance()->Start(); 00157 }
Here is the call graph for this function:
void GameMenu::Draw | ( | const Point2i & | mousePosition | ) | [private, virtual] |
void GameMenu::OnClic | ( | const Point2i & | mousePosition, | |
int | button | |||
) | [private, virtual] |
Implements Menu.
Definition at line 130 of file game_menu.cpp.
Here is the call graph for this function:
void GameMenu::SaveOptions | ( | ) | [private] |
Definition at line 135 of file game_menu.cpp.
00136 { 00137 // Map 00138 map_box->ValidMapSelection(); 00139 00140 // teams 00141 team_box->ValidTeamsSelection(); 00142 00143 //Save options in XML 00144 Config::GetInstance()->SetScrollOnBorder(opt_scroll_on_border->GetValue()); 00145 Config::GetInstance()->Save(); 00146 00147 GameMode * game_mode = GameMode::GetInstance(); 00148 game_mode->duration_turn = opt_duration_turn->GetValue() ; 00149 game_mode->character.init_energy = opt_energy_ini->GetValue() ; 00150 00151 }
Here is the call graph for this function:
Here is the caller graph for this function:
Box* GameMenu::game_options [private] |
Definition at line 40 of file game_menu.h.
MapSelectionBox* GameMenu::map_box [private] |
Definition at line 37 of file game_menu.h.
SpinButtonWithPicture* GameMenu::opt_duration_turn [private] |
Definition at line 41 of file game_menu.h.
SpinButtonWithPicture* GameMenu::opt_energy_ini [private] |
Definition at line 42 of file game_menu.h.
CheckBox* GameMenu::opt_scroll_on_border [private] |
Definition at line 43 of file game_menu.h.
TeamsSelectionBox* GameMenu::team_box [private] |
Definition at line 34 of file game_menu.h.