#include <main_menu.h>
Inheritance diagram for Main_Menu:
Public Member Functions | |
Main_Menu () | |
~Main_Menu () | |
menu_item | Run () |
void | Redraw (const Rectanglei &rect, Surface &surf) |
Public Attributes | |
menu_item | choice |
Protected Member Functions | |
void | __sig_ok () |
void | __sig_cancel () |
void | key_ok () |
void | key_cancel () |
Private Member Functions | |
virtual void | DrawBackground (const Point2i &mousePosition) |
void | OnClic (const Point2i &mousePosition, int button) |
void | Draw (const Point2i &mousePosition) |
void | button_clic () |
Private Attributes | |
PictureWidget * | title |
Surface | s_title |
Sprite * | skin_left |
Sprite * | skin_right |
ButtonText * | play |
ButtonText * | network |
ButtonText * | options |
ButtonText * | infos |
ButtonText * | quit |
Text * | version_text |
Text * | website_text |
Definition at line 46 of file main_menu.h.
Main_Menu::Main_Menu | ( | ) |
Definition at line 54 of file main_menu.cpp.
00054 : 00055 Menu("main_menu/bg_main", vNo) 00056 { 00057 int x_button; 00058 double y_scale; 00059 00060 Font * normal_font = Font::GetInstance(Font::FONT_NORMAL); 00061 Font * large_font = Font::GetInstance(Font::FONT_LARGE); 00062 00063 int button_width = 402; 00064 int button_height = 64; 00065 00066 y_scale = (double)AppWormux::GetInstance()->video.window.GetHeight() / DEFAULT_SCREEN_HEIGHT ; 00067 00068 x_button = AppWormux::GetInstance()->video.window.GetWidth()/2 - button_width/2; 00069 00070 Profile *res = resource_manager.LoadXMLProfile( "graphism.xml", false); 00071 00072 skin_left = new Sprite( resource_manager.LoadImage(res,"main_menu/skin_1")); 00073 skin_right = new Sprite( resource_manager.LoadImage(res,"main_menu/skin_2")); 00074 00075 s_title = resource_manager.LoadImage(res,"main_menu/title"); 00076 title = new PictureWidget(Rectanglei(AppWormux::GetInstance()->video.window.GetWidth()/2 - s_title.GetWidth()/2 + 10, 0, 648, 168)); 00077 title->SetSurface(s_title); 00078 00079 int y = int(290 * y_scale) ; 00080 const int y2 = AppWormux::GetInstance()->video.window.GetHeight() + VERSION_DY -20 - button_height; 00081 00082 int dy = std::max((y2-y)/3, button_height); 00083 if(Config::GetInstance()->IsNetworkActivated()) 00084 dy = std::max((y2-y)/4, button_height); 00085 00086 play = new ButtonText(Point2i(x_button, y), 00087 res, "main_menu/button", 00088 _("Play"), 00089 large_font); 00090 y += dy; 00091 00092 if(Config::GetInstance()->IsNetworkActivated()) { 00093 network = new ButtonText( Point2i(x_button, y), 00094 res, "main_menu/button", 00095 _("Network Game"), 00096 large_font ); 00097 y += dy; 00098 } else { 00099 network = NULL; 00100 } 00101 00102 options = new ButtonText(Point2i(x_button, y), 00103 res, "main_menu/button", 00104 _("Options"), 00105 large_font); 00106 y += dy; 00107 00108 infos = new ButtonText(Point2i(x_button, y), 00109 res, "main_menu/button", 00110 _("Credits"), 00111 large_font); 00112 y += dy; 00113 00114 quit = new ButtonText(Point2i(x_button, y), 00115 res, "main_menu/button", 00116 _("Quit"), 00117 large_font); 00118 00119 widgets.AddWidget(play); 00120 if(Config::GetInstance()->IsNetworkActivated()) 00121 widgets.AddWidget(network); 00122 widgets.AddWidget(options); 00123 widgets.AddWidget(infos); 00124 widgets.AddWidget(quit); 00125 widgets.AddWidget(title); 00126 00127 resource_manager.UnLoadXMLProfile( res); 00128 00129 std::string s("Version "+Constants::VERSION); 00130 version_text = new Text(s, green_color, normal_font, false); 00131 00132 std::string s2(Constants::WEB_SITE); 00133 website_text = new Text(s2, green_color, normal_font, false); 00134 }
Here is the call graph for this function:
Main_Menu::~Main_Menu | ( | ) |
Definition at line 46 of file main_menu.cpp.
00047 { 00048 delete skin_left; 00049 delete skin_right; 00050 delete version_text; 00051 delete website_text; 00052 }
void Main_Menu::__sig_cancel | ( | ) | [protected, virtual] |
Implements Menu.
Definition at line 198 of file main_menu.cpp.
00199 { 00200 key_cancel(); 00201 }
Here is the call graph for this function:
void Main_Menu::__sig_ok | ( | ) | [protected, virtual] |
Implements Menu.
Definition at line 203 of file main_menu.cpp.
00204 { 00205 key_ok(); 00206 }
Here is the call graph for this function:
void Main_Menu::button_clic | ( | ) | [private] |
Definition at line 136 of file main_menu.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
void Main_Menu::Draw | ( | const Point2i & | mousePosition | ) | [inline, private, virtual] |
void Main_Menu::DrawBackground | ( | const Point2i & | mousePosition | ) | [private, virtual] |
Reimplemented from Menu.
Definition at line 208 of file main_menu.cpp.
00209 { 00210 Surface& window = AppWormux::GetInstance()->video.window; 00211 00212 Menu::DrawBackground(mousePosition); 00213 skin_left->Blit(window, 0, window.GetHeight() - skin_left->GetHeight()); 00214 skin_right->Blit(window, window.GetWidth() - skin_right->GetWidth(), 00215 window.GetHeight() - skin_right->GetHeight()); 00216 00217 version_text->DrawCenter( window.GetWidth()/2, 00218 window.GetHeight() + VERSION_DY); 00219 website_text->DrawCenter( window.GetWidth()/2, 00220 window.GetHeight() + VERSION_DY/2); 00221 00222 }
Here is the call graph for this function:
void Main_Menu::key_cancel | ( | ) | [protected, virtual] |
Reimplemented from Menu.
Definition at line 192 of file main_menu.cpp.
00193 { 00194 choice = menuQUIT; 00195 close_menu = true; 00196 }
Here is the caller graph for this function:
void Main_Menu::key_ok | ( | ) | [protected, virtual] |
Reimplemented from Menu.
Definition at line 186 of file main_menu.cpp.
00187 { 00188 choice = menuPLAY; 00189 close_menu = true; 00190 }
Here is the caller graph for this function:
void Main_Menu::OnClic | ( | const Point2i & | mousePosition, | |
int | button | |||
) | [private, virtual] |
Implements Menu.
Definition at line 141 of file main_menu.cpp.
00142 { 00143 Widget* b = widgets.Clic(mousePosition,button); 00144 if(b == play) 00145 { 00146 choice = menuPLAY; 00147 close_menu = true; 00148 button_clic(); 00149 } 00150 else if(b == network && Config::GetInstance()->IsNetworkActivated()) 00151 { 00152 choice = menuNETWORK; 00153 close_menu = true; 00154 button_clic(); 00155 } 00156 else if(b == options) 00157 { 00158 choice = menuOPTIONS; 00159 close_menu = true; 00160 button_clic(); 00161 } 00162 else if(b == infos) 00163 { 00164 choice = menuCREDITS; 00165 close_menu = true; 00166 button_clic(); 00167 } 00168 else if(b == quit) 00169 { 00170 choice = menuQUIT; 00171 close_menu = true; 00172 button_clic(); 00173 } 00174 }
Here is the call graph for this function:
void Main_Menu::Redraw | ( | const Rectanglei & | rect, | |
Surface & | surf | |||
) | [virtual] |
Reimplemented from Menu.
Definition at line 224 of file main_menu.cpp.
00225 { 00226 Menu::Redraw(rect, window); 00227 00228 // we never had to redraw texts 00229 // but sometimes we need to redraw the skins... 00230 00231 Rectanglei dest(0, window.GetHeight() - skin_left->GetHeight(), 00232 skin_left->GetWidth(), skin_left->GetHeight()); 00233 dest.Clip(rect); 00234 00235 Rectanglei src(rect.GetPositionX() - 0, 00236 rect.GetPositionY() - (window.GetHeight() - skin_left->GetHeight()), 00237 dest.GetSizeX(), dest.GetSizeY()); 00238 00239 skin_left->Blit(window, src, dest.GetPosition()); 00240 00241 Rectanglei dest2(window.GetWidth() - skin_right->GetWidth(), 00242 window.GetHeight() - skin_right->GetHeight(), 00243 skin_right->GetWidth(), skin_right->GetHeight()); 00244 dest2.Clip(rect); 00245 00246 Rectanglei src2(dest2.GetPositionX() - (window.GetWidth() - skin_right->GetWidth()), 00247 dest2.GetPositionY() - (window.GetHeight() - skin_right->GetHeight()), 00248 dest2.GetSizeX(), dest2.GetSizeY()); 00249 00250 skin_right->Blit(window, src2, dest2.GetPosition()); 00251 00252 00253 }
Here is the call graph for this function:
menu_item Main_Menu::Run | ( | ) |
Definition at line 59 of file main_menu.h.
ButtonText * Main_Menu::infos [private] |
Definition at line 53 of file main_menu.h.
ButtonText * Main_Menu::network [private] |
Definition at line 53 of file main_menu.h.
ButtonText * Main_Menu::options [private] |
Definition at line 53 of file main_menu.h.
ButtonText* Main_Menu::play [private] |
Definition at line 53 of file main_menu.h.
ButtonText * Main_Menu::quit [private] |
Definition at line 53 of file main_menu.h.
Surface Main_Menu::s_title [private] |
Definition at line 49 of file main_menu.h.
Sprite* Main_Menu::skin_left [private] |
Definition at line 51 of file main_menu.h.
Sprite * Main_Menu::skin_right [private] |
Definition at line 51 of file main_menu.h.
PictureWidget* Main_Menu::title [private] |
Definition at line 48 of file main_menu.h.
Text* Main_Menu::version_text [private] |
Definition at line 55 of file main_menu.h.
Text * Main_Menu::website_text [private] |
Definition at line 55 of file main_menu.h.