YAPOG  0.0.1
Yet Another Pokemon Online Game
PokemonInfoWidget.cpp
Go to the documentation of this file.
2 
7 #include "Pokemon/Pokemon.hpp"
8 
9 namespace ycl
10 {
12  : pokemon_ (nullptr)
13  , pageNumber_ (0)
14  , pokemonInfoPages_ ()
15  {
16  SetSize (yap::Vector2 (800, 600));
17 
18  IPokemonSummaryWidget* pokemonBasicInfoWidget =
20 
21  IPokemonSummaryWidget* pokemonStatsInfoWidget =
23 
24  IPokemonSummaryWidget* pokemonMoveInfoWidget =
25  new PokemonMoveInfoWidget ();
26 
27  pokemonInfoPages_.Add (pokemonBasicInfoWidget);
28  pokemonInfoPages_.Add (pokemonStatsInfoWidget);
29  pokemonInfoPages_.Add (pokemonMoveInfoWidget);
30  }
31 
33  {
34  for (yap::BaseWidget* widget : pokemonInfoPages_)
35  delete widget;
36  }
37 
39  {
41  {
42  widget->SetSize (GetSize ());
43  widget->Init ();
44  widget->Close ();
45 
46  AddChild (*widget);
47  }
48  }
49 
51  {
52  pokemon_ = pokemon;
53 
54  pokemonInfoPages_[pageNumber_]->SetPokemon (*pokemon_);
56  }
57 
59  {
60  return false;
61  }
62 
64  {
65  if (guiEvent.type == sf::Event::KeyPressed)
66  {
67  if (guiEvent.key.code == sf::Keyboard::Left)
68  {
69  // Play a sound
70  yap::AudioManager::Instance ().PlaySound ("SE/Select.wav");
71 
72  pokemonInfoPages_[pageNumber_]->Close ();
73 
74  if (pageNumber_ == 0)
76  else
77  pageNumber_--;
78 
79  pokemonInfoPages_[pageNumber_]->SetPokemon (*pokemon_);
81 
82  return true;
83  }
84 
85  if (guiEvent.key.code == sf::Keyboard::Right)
86  {
87  // Play a sound
88  yap::AudioManager::Instance ().PlaySound ("SE/Select.wav");
89 
90  pokemonInfoPages_[pageNumber_]->Close ();
91 
93 
94  pokemonInfoPages_[pageNumber_]->SetPokemon (*pokemon_);
96 
97  return true;
98  }
99 
100  if (guiEvent.key.code == sf::Keyboard::Return)
101  {
102  return true;
103  }
104 
105  if (guiEvent.key.code == sf::Keyboard::Escape)
106  {
107  Close ();
108 
109  return true;
110  }
111  }
112 
113  return yap::BaseWidget::HandleOnEvent (guiEvent);
114  }
115 
117  {
118 
119  }
120 
122  {
123 
124  }
125 
127  {
128  }
129 
130  void PokemonInfoWidget::HandleShow (bool isVisible)
131  {
132  }
133 
134  void PokemonInfoWidget::HandleChangeColor (const sf::Color& color)
135  {
136  }
137 
139  {
140  }
141 
142 } // namespace ycl