#include <weapon_menu.h>
Collaboration diagram for WeaponsMenu:
Public Member Functions | |
WeaponsMenu () | |
bool | ActionClic (const Point2i &mousePos) |
void | Draw () |
void | Reset () |
int | GetX () const |
int | GetY () const |
Point2i | GetPosition () const |
int | GetWidth () const |
int | GetHeight () const |
Point2i | GetSize () const |
bool | IsDisplayed () const |
void | NewItem (Weapon *new_item, uint num_sort) |
void | SwitchDisplay () |
void | Hide () |
void | MouseOver (const Point2i &mousePos) |
Public Attributes | |
Sprite * | my_button1 |
Sprite * | my_button2 |
Sprite * | my_button3 |
Sprite * | my_button4 |
Sprite * | my_button5 |
Private Types | |
typedef std::vector< WeaponMenuItem >::iterator | iterator |
typedef std::vector< WeaponMenuItem >::const_iterator | const_iterator |
Private Member Functions | |
void | ComputeSize () |
void | Show () |
void | ShowMotion (int nr_bottons, int button_no, iterator it, int column) |
bool | HideMotion (int nr_buttons, int button_no, iterator it, int column) |
Private Attributes | |
std::vector< WeaponMenuItem > | boutons |
bool | display |
bool | show |
bool | hide |
uint | motion_start_time |
uint | nbr_weapon_type |
uint | max_weapon |
Definition at line 58 of file weapon_menu.h.
typedef std::vector<WeaponMenuItem>::const_iterator WeaponsMenu::const_iterator [private] |
Definition at line 70 of file weapon_menu.h.
typedef std::vector<WeaponMenuItem>::iterator WeaponsMenu::iterator [private] |
Definition at line 69 of file weapon_menu.h.
WeaponsMenu::WeaponsMenu | ( | ) |
Definition at line 202 of file weapon_menu.cpp.
00203 { 00204 display = false; 00205 show = false; 00206 hide = false; 00207 nbr_weapon_type = 0; 00208 motion_start_time = Time::GetInstance()->Read(); 00209 00210 Profile *res = resource_manager.LoadXMLProfile( "graphism.xml", false); 00211 my_button1 = new Sprite( resource_manager.LoadImage(res,"interface/button1_icon")); 00212 my_button1->cache.EnableLastFrameCache(); 00213 my_button2 = new Sprite( resource_manager.LoadImage(res,"interface/button2_icon")); 00214 my_button2->cache.EnableLastFrameCache(); 00215 my_button3 = new Sprite( resource_manager.LoadImage(res,"interface/button3_icon")); 00216 my_button3->cache.EnableLastFrameCache(); 00217 my_button4 = new Sprite( resource_manager.LoadImage(res,"interface/button4_icon")); 00218 my_button4->cache.EnableLastFrameCache(); 00219 my_button5 = new Sprite( resource_manager.LoadImage(res,"interface/button5_icon")); 00220 my_button5->cache.EnableLastFrameCache(); 00221 resource_manager.UnLoadXMLProfile( res); 00222 }
Here is the call graph for this function:
bool WeaponsMenu::ActionClic | ( | const Point2i & | mousePos | ) |
Definition at line 481 of file weapon_menu.cpp.
00482 { 00483 if (!display) return false; 00484 00485 iterator it=boutons.begin(), fin=boutons.end(); 00486 for (; it != fin; ++it) 00487 { 00488 if( it->MouseOn(mousePos) ) 00489 { 00490 ActionHandler::GetInstance()->NewAction (new Action(Action::ACTION_CHANGE_WEAPON, 00491 it -> weapon -> GetType())); 00492 SwitchDisplay(); 00493 return true; 00494 } 00495 } 00496 return false; 00497 }
Here is the call graph for this function:
void WeaponsMenu::ComputeSize | ( | ) | [private] |
Definition at line 256 of file weapon_menu.cpp.
00257 { 00258 max_weapon = 0; 00259 uint nbr_current_type = 0; 00260 00261 iterator it=boutons.begin(), fin=boutons.end(); 00262 for (; it != fin; ++it) 00263 { 00264 if(it != boutons.begin()) 00265 if(((it-1)->weapon_type) != (it->weapon_type)) 00266 { 00267 if(nbr_current_type > max_weapon) 00268 max_weapon = nbr_current_type; 00269 nbr_current_type = 0; 00270 } 00271 if(ActiveTeam().ReadNbAmmos(it->weapon->GetName())>0 00272 || ActiveTeam().ReadNbAmmos(it->weapon->GetName())==INFINITE_AMMO) 00273 nbr_current_type++; 00274 } 00275 00276 if(nbr_current_type > max_weapon) 00277 max_weapon = nbr_current_type; 00278 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponsMenu::Draw | ( | ) |
Definition at line 404 of file weapon_menu.cpp.
00405 { 00406 if (!display) 00407 return; 00408 00409 MouseOver(Mouse::GetInstance()->GetWorldPosition() - camera.GetPosition()); 00410 ComputeSize(); 00411 00412 uint nr_buttons = max_weapon * nbr_weapon_type; 00413 uint button_no = 0; 00414 uint current_type = 0; 00415 00416 iterator it=boutons.begin(), fin=boutons.end(); 00417 for (it=boutons.begin(); it != fin; ++it) 00418 { 00419 if(!it->weapon->CanBeUsedOnClosedMap() 00420 && !world.EstOuvert()) 00421 continue; 00422 00423 if(ActiveTeam().ReadNbAmmos(it->weapon->GetName())<=0 00424 && ActiveTeam().ReadNbAmmos(it->weapon->GetName())!=INFINITE_AMMO) 00425 continue; 00426 00427 if(it->weapon_type!=current_type) 00428 { 00429 button_no = 0; 00430 current_type = it->weapon_type; 00431 } 00432 00433 int column = nbr_weapon_type - current_type; 00434 int row = button_no; 00435 00436 it->position.x = GetWidth() - (int)(BUTTON_WIDTH * (column+0.5)); 00437 it->position.y = BUTTON_ICO_GAP + (row * BUTTON_HEIGHT); 00438 00439 if(show) 00440 ShowMotion(nr_buttons,(column * max_weapon) + row,it,column); 00441 else 00442 if(hide) 00443 if(HideMotion(nr_buttons,(column * max_weapon) + row,it,column)) 00444 return; 00445 00446 it->Draw(); 00447 button_no++; 00448 } 00449 }
Here is the call graph for this function:
Here is the caller graph for this function:
int WeaponsMenu::GetHeight | ( | ) | const |
Definition at line 318 of file weapon_menu.cpp.
00319 { 00320 return BUTTON_ICO_GAP + BUTTON_HEIGHT * max_weapon; 00321 }
Here is the caller graph for this function:
Point2i WeaponsMenu::GetPosition | ( | ) | const |
Definition at line 309 of file weapon_menu.cpp.
00309 { 00310 return AppWormux::GetInstance()->video.window.GetSize() - GetSize() - Point2i(0, Interface::GetInstance()->GetHeight()); 00311 }
Here is the call graph for this function:
Here is the caller graph for this function:
Point2i WeaponsMenu::GetSize | ( | ) | const |
Definition at line 323 of file weapon_menu.cpp.
00324 { 00325 return Point2i( BUTTON_ICO_GAP + ((nbr_weapon_type +1) * BUTTON_WIDTH), BUTTON_ICO_GAP + BUTTON_HEIGHT * max_weapon); 00326 }
Here is the caller graph for this function:
int WeaponsMenu::GetWidth | ( | ) | const |
Definition at line 313 of file weapon_menu.cpp.
00314 { 00315 return BUTTON_ICO_GAP + ((nbr_weapon_type +1) * BUTTON_WIDTH) ; 00316 }
Here is the caller graph for this function:
int WeaponsMenu::GetX | ( | ) | const |
Definition at line 299 of file weapon_menu.cpp.
00300 { 00301 return AppWormux::GetInstance()->video.window.GetWidth()-GetWidth(); 00302 }
Here is the call graph for this function:
int WeaponsMenu::GetY | ( | ) | const |
Definition at line 304 of file weapon_menu.cpp.
00305 { 00306 return AppWormux::GetInstance()->video.window.GetHeight() - GetHeight() - Interface::GetInstance()->GetHeight(); 00307 }
Here is the call graph for this function:
void WeaponsMenu::Hide | ( | ) |
Definition at line 280 of file weapon_menu.cpp.
00281 { 00282 if(display && show) 00283 motion_start_time = Time::GetInstance()->Read() - (ICONS_DRAW_TIME - (Time::GetInstance()->Read()-motion_start_time)); 00284 else 00285 motion_start_time = Time::GetInstance()->Read(); 00286 00287 hide = true; 00288 show = false; 00289 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool WeaponsMenu::HideMotion | ( | int | nr_buttons, | |
int | button_no, | |||
iterator | it, | |||
int | column | |||
) | [private] |
Definition at line 370 of file weapon_menu.cpp.
00371 { 00372 int delta_t=ICONS_DRAW_TIME/(2*nr_buttons); 00373 00374 Time * global_time = Time::GetInstance(); 00375 if((global_time->Read() > motion_start_time + (delta_t*(nr_buttons-button_no))) 00376 && (global_time->Read() < motion_start_time + (ICONS_DRAW_TIME/2)+(delta_t*(nr_buttons-button_no)))) 00377 { 00378 double delta_sin = -(asin((column+1.0)/(column+2.0)) - (M_PI/2)); 00379 00380 uint tps = global_time->Read() - (motion_start_time + delta_t*(nr_buttons-button_no)); 00381 double tps_sin = ((double)tps * ((M_PI/2) + delta_sin)/(ICONS_DRAW_TIME/2)); 00382 tps_sin = ((M_PI/2) + delta_sin) - tps_sin; 00383 00384 it->position.x -= (int)(sin(tps_sin) * BUTTON_WIDTH * (column+2.0)); 00385 it->position.x += BUTTON_WIDTH * (column+1); 00386 } 00387 else 00388 if(global_time->Read() > motion_start_time + (delta_t*(nr_buttons-button_no))) 00389 { 00390 it->position.x += BUTTON_WIDTH * (column+1); 00391 it->Reset(); 00392 } 00393 00394 if(global_time->Read() > motion_start_time + ICONS_DRAW_TIME) 00395 { 00396 hide = false; 00397 display = false; 00398 return true; 00399 } 00400 00401 return false; 00402 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool WeaponsMenu::IsDisplayed | ( | ) | const |
void WeaponsMenu::MouseOver | ( | const Point2i & | mousePos | ) |
Definition at line 451 of file weapon_menu.cpp.
00452 { 00453 static int bouton_sous_souris = -1; // button under mouse cursor 00454 00455 // analized button 00456 int button_no=0; 00457 int nv_bouton_sous_souris=-1; 00458 iterator it=boutons.begin(), fin=boutons.end(); 00459 Interface::GetInstance()->weapon_under_cursor = NULL; 00460 for (; it != fin; ++it) 00461 { 00462 if(it->MouseOn(mousePos)) 00463 { 00464 Interface::GetInstance()->weapon_under_cursor = it->weapon; 00465 nv_bouton_sous_souris = button_no; 00466 if(button_no != bouton_sous_souris) 00467 { // mouse cursor is on a new button 00468 it->ChangeZoom(); 00469 } 00470 } 00471 else 00472 if(button_no == bouton_sous_souris) 00473 { 00474 it->ChangeZoom(); 00475 } 00476 button_no++; 00477 } 00478 bouton_sous_souris = nv_bouton_sous_souris; 00479 }
Here is the call graph for this function:
Here is the caller graph for this function:
Definition at line 225 of file weapon_menu.cpp.
00226 { 00227 WeaponMenuItem item(num_sort); 00228 item.position.Clear(); 00229 item.weapon = new_item; 00230 00231 item.weapon_icon = new Sprite(new_item->GetIcon()); 00232 item.weapon_icon->cache.EnableLastFrameCache(); 00233 00234 boutons.push_back (item); 00235 00236 if(num_sort>nbr_weapon_type) 00237 nbr_weapon_type = num_sort; 00238 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponsMenu::Reset | ( | ) |
Definition at line 333 of file weapon_menu.cpp.
00334 { 00335 display = false; 00336 show = false; 00337 hide = false; 00338 motion_start_time = Time::GetInstance()->Read(); 00339 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponsMenu::Show | ( | ) | [private] |
Definition at line 241 of file weapon_menu.cpp.
00242 { 00243 ShowGameInterface(); 00244 Time * global_time = Time::GetInstance(); 00245 if(display && hide) 00246 motion_start_time = global_time->Read() - (ICONS_DRAW_TIME - (global_time->Read()-motion_start_time)); 00247 else 00248 motion_start_time = global_time->Read(); 00249 00250 display = true; 00251 show = true; 00252 hide = false; 00253 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponsMenu::ShowMotion | ( | int | nr_bottons, | |
int | button_no, | |||
iterator | it, | |||
int | column | |||
) | [private] |
Definition at line 341 of file weapon_menu.cpp.
00342 { 00343 int delta_t=ICONS_DRAW_TIME/(2*nr_buttons); 00344 Time * global_time = Time::GetInstance(); 00345 00346 if((global_time->Read() > motion_start_time + (delta_t*button_no)) 00347 && (global_time->Read() < motion_start_time + (ICONS_DRAW_TIME/2)+(delta_t*(button_no)))) 00348 { 00349 double delta_sin = -(asin((column+1.0)/(column+2.0)) - (M_PI/2)); 00350 00351 uint tps = global_time->Read() - (motion_start_time + delta_t*button_no); 00352 00353 double tps_sin = ((double)tps * ((M_PI/2) + delta_sin)/(ICONS_DRAW_TIME/2)); 00354 00355 it->position.x -= (int)(sin(tps_sin) * BUTTON_WIDTH * (column+2.0)); 00356 it->position.x += (BUTTON_WIDTH * (column+1)); 00357 } 00358 else 00359 if(global_time->Read() < motion_start_time + (delta_t*button_no)) 00360 { 00361 it->position.x += (BUTTON_WIDTH * (column+1)); 00362 } 00363 00364 if(global_time->Read() > motion_start_time + ICONS_DRAW_TIME) 00365 { 00366 show = false; 00367 } 00368 }
Here is the call graph for this function:
Here is the caller graph for this function:
void WeaponsMenu::SwitchDisplay | ( | ) |
std::vector<WeaponMenuItem> WeaponsMenu::boutons [private] |
Definition at line 68 of file weapon_menu.h.
bool WeaponsMenu::display [private] |
Definition at line 72 of file weapon_menu.h.
bool WeaponsMenu::hide [private] |
Definition at line 74 of file weapon_menu.h.
uint WeaponsMenu::max_weapon [private] |
Definition at line 79 of file weapon_menu.h.
uint WeaponsMenu::motion_start_time [private] |
Definition at line 76 of file weapon_menu.h.
Definition at line 61 of file weapon_menu.h.
Definition at line 62 of file weapon_menu.h.
Definition at line 63 of file weapon_menu.h.
Definition at line 64 of file weapon_menu.h.
Definition at line 65 of file weapon_menu.h.
uint WeaponsMenu::nbr_weapon_type [private] |
Definition at line 78 of file weapon_menu.h.
bool WeaponsMenu::show [private] |
Definition at line 73 of file weapon_menu.h.