YAPOG  0.0.1
Yet Another Pokemon Online Game
MainMenuScreen.cpp
Go to the documentation of this file.
6 
9 #include "Gui/MainMenu.hpp"
10 
11 namespace ycl
12 {
14 
16  : BaseScreen (DEFAULT_NAME, context)
17  {
18  }
19 
21  {
22  }
23 
25  {
27 
28  MainMenu* mainMenu = new MainMenu ();
29  mainMenu->Init ();
30 
31  yap::PictureBox* bg = new yap::PictureBox ();
32 
33  yap::RandomHelper* random;
34  int nb = random->GetNext (0, 4242) % 5;
35  switch (nb)
36  {
37  case 0:
38  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/mew.jpg"));
39  break;
40  case 1:
41  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/fete.jpg"));
42  break;
43  case 2:
44  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/rondoudou.jpg"));
45  break;
46  case 3:
47  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/dresseur.jpg"));
48  break;
49  case 4:
50  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/ronflex.gif"));
51  break;
52  default:
53  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/ronflex.gif"));
54  break;
55  }
56  bg->SetSize (yap::Vector2 (800, 600));
57  guiManager_->AddChild (*bg);
58 
59  mainMenu->GetLoginItem ().OnActivated +=
60  [&] (const yap::MenuItem& sender, const yap::EmptyEventArgs& args)
61  {
62  nextScreen_ = "Login";
63  };
64 
65  mainMenu->GetRegistrationItem ().OnActivated +=
66  [&] (const yap::MenuItem& sender, const yap::EmptyEventArgs& args)
67  {
68  nextScreen_ = "Registration";
69  };
70 
71  mainMenu->GetExitItem ().OnActivated +=
72  [&] (const yap::MenuItem& sender, const yap::EmptyEventArgs& args)
73  {
74  ExitGame ();
75  };
76 
77  guiManager_->AddChild (*mainMenu);
78 
79  yap::AudioManager::Instance ().PlayMusic ("BGM/Opening.ogg");
80  }
81 
83  const yap::Time& dt,
84  yap::IDrawingContext& context)
85  {
86  BaseScreen::HandleRun (dt, context);
87  }
88 } // namespace ycl