YAPOG  0.0.1
Yet Another Pokemon Online Game
RegistrationScreen.cpp
Go to the documentation of this file.
5 
7 #include "Client/Session.hpp"
8 
9 namespace ycl
10 {
12 
14  : BaseScreen (DEFAULT_NAME, context)
15  , registrationWidget_ ()
16  {
18  }
19 
21  {
22  }
23 
25  {
27 
29  Session& sender,
30  const yap::EmptyEventArgs& args)
31  {
32  nextScreen_ = "MainMenu";
33  };
34 
35  session_.OnRegistrationError += [this] (
36  Session& sender,
37  const yap::EmptyEventArgs& args)
38  {
39  registrationWidget_.SetErrorText ("Failed to register !");
40  };
41 
42  yap::PictureBox* bg = new yap::PictureBox ();
43 
44  yap::RandomHelper* random;
45  int nb = random->GetNext (0, 4242) % 5;
46  switch (nb)
47  {
48  case 0:
49  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/mew.jpg"));
50  break;
51  case 1:
52  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/fete.jpg"));
53  break;
54  case 2:
55  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/rondoudou.jpg"));
56  break;
57  case 3:
58  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/dresseur.jpg"));
59  break;
60  case 4:
61  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/ronflex.gif"));
62  break;
63  default:
64  bg->SetPicture (new yap::Sprite ("WindowSkins/BasicSkin/Background/ronflex.gif"));
65  break;
66  }
67 
68  bg->SetSize (yap::Vector2 (800, 600));
69  guiManager_->AddChild (*bg);
71  }
72 
74  const yap::Time& dt,
75  yap::IDrawingContext& context)
76  {
77  BaseScreen::HandleRun (dt, context);
78  }
79 
81  {
82  if (guiEvent.type == sf::Event::KeyPressed)
83  {
84  if (guiEvent.key.code == sf::Keyboard::Escape)
85  {
86  nextScreen_ = "MainMenu";
87  return true;
88  }
89 
90  if (guiEvent.key.code == sf::Keyboard::Return)
91  {
92  yap::String login =
94  yap::String password =
96  yap::String email =
98 
99  //@todo Check
100 
101  session_.Register (login, password, email);
102 
103  return true;
104  }
105 
106  }
107  return false;
108  }
109 
111  {
116  }
117 
118 } // namespace ycl