YAPOG  0.0.1
Yet Another Pokemon Online Game
BattleInteface.cpp
Go to the documentation of this file.
2 
9 
11 
12 #include "Game.hpp"
13 
17 
18 #include "Game.hpp"
19 
20 namespace ycl
21 {
23 
25  : battleInfoDialogBox_ (nullptr)
26  , pokemonInfoWidget_ (nullptr)
27  , opponentInfoWidget_ (nullptr)
28  , battleMenu_ ()
29  , battleMoveMenu_ ()
30  , currentWidgetName_ ()
31  , currentWidget_ (nullptr)
32  , battleWidgets_ ()
33  {
35 
36  // Init Battle Text Dialog
39 
42 
43  battleInfoDialogBox_->SetPadding (yap::Padding (35, 35, 25, 25));
45  *(new yap::WidgetBackground (
46  "WindowSkins/BasicSkin/Global/DialogBoxBackground.png", true)));
47 
48  battleInfoDialogBox_->SetDefaultColor (sf::Color::White);
49 
52 
55 
56  pokemonInfoWidget_->Show (false);
57  opponentInfoWidget_->Show (false);
58 
62 
64  0 ,
66 
70 
71  battleMenu_.Close ();
74 
75  // Affect events
77  [&] (const yap::MenuItem& sender, const yap::EmptyEventArgs& args)
78  {
79  battleMenu_.Close ();
81  };
82 
84  [&] (const yap::GridMenu& sender, const yap::EmptyEventArgs& args)
85  {
88  battleMenu_.Open ();
89  };
90 
91  this->AddBattleWidget ("PokemonInfo", pokemonInfoWidget_);
92  this->AddBattleWidget ("OpponentInfo", opponentInfoWidget_);
93  this->AddBattleWidget ("BattleInfo", battleInfoDialogBox_);
94  this->AddBattleWidget ("Menu", &battleMenu_);
95  this->AddBattleWidget ("MoveMenu", &battleMoveMenu_);
96  this->AddBattleWidget ("MoveInfo", &battleMoveInfoMenu_);
97  }
98 
100  const yap::String& name,
101  yap::IWidget* battleWidget)
102  {
103  DEFAULT_ADDED_WIDGET_STATE ? battleWidget->Open () : battleWidget->Close ();
104 
105  AddChild (*battleWidget);
106  battleWidgets_.Add (name, battleWidget);
107  }
108 
110  {
111  currentWidgetName_ = name;
112 
114 
117 
120 
121  currentWidget_->Open ();
122  }
123 
125  {
126  if (currentWidget_ == nullptr)
127  return false;
128 
129  currentWidget_->Close ();
130 
131  currentWidget_ = nullptr;
132 
133  return true;
134  }
135 
138  {
139  return *battleInfoDialogBox_;
140  }
141 
143  {
144  return *pokemonInfoWidget_;
145  }
146 
148  {
149  return *opponentInfoWidget_;
150  }
151 
153  {
154  return battleMenu_;
155  }
156 
158  {
159  return battleMoveMenu_;
160  }
161 
163  {
164  return battleMoveInfoMenu_;
165  }
166 
168  {
171  }
172 
174  {
177  battleMenu_.Close ();
178 
182  }
183 }