YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
PokemonInfoWidget.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Audio/AudioManager.hpp
"
2
3
#include "
Gui/PokemonInfoWidget.hpp
"
4
#include "
Gui/PokemonBasicInfoWidget.hpp
"
5
#include "
Gui/PokemonStatsInfoWidget.hpp
"
6
#include "
Gui/PokemonMoveInfoWidget.hpp
"
7
#include "Pokemon/Pokemon.hpp"
8
9
namespace
ycl
10
{
11
PokemonInfoWidget::PokemonInfoWidget
()
12
: pokemon_ (nullptr)
13
, pageNumber_ (0)
14
, pokemonInfoPages_ ()
15
{
16
SetSize
(
yap::Vector2
(800, 600));
17
18
IPokemonSummaryWidget
* pokemonBasicInfoWidget =
19
new
PokemonBasicInfoWidget
();
20
21
IPokemonSummaryWidget
* pokemonStatsInfoWidget =
22
new
PokemonStatsInfoWidget
();
23
24
IPokemonSummaryWidget
* pokemonMoveInfoWidget =
25
new
PokemonMoveInfoWidget
();
26
27
pokemonInfoPages_
.
Add
(pokemonBasicInfoWidget);
28
pokemonInfoPages_
.
Add
(pokemonStatsInfoWidget);
29
pokemonInfoPages_
.
Add
(pokemonMoveInfoWidget);
30
}
31
32
PokemonInfoWidget::~PokemonInfoWidget
()
33
{
34
for
(
yap::BaseWidget
* widget :
pokemonInfoPages_
)
35
delete
widget;
36
}
37
38
void
PokemonInfoWidget::Init
()
39
{
40
for
(
IPokemonSummaryWidget
* widget :
pokemonInfoPages_
)
41
{
42
widget->SetSize (
GetSize
());
43
widget->Init ();
44
widget->Close ();
45
46
AddChild
(*widget);
47
}
48
}
49
50
void
PokemonInfoWidget::SetPokemon
(
Pokemon
* pokemon)
51
{
52
pokemon_
= pokemon;
53
54
pokemonInfoPages_
[
pageNumber_
]->SetPokemon (*
pokemon_
);
55
pokemonInfoPages_
[
pageNumber_
]->Open ();
56
}
57
58
bool
PokemonInfoWidget::IsFocusable
()
const
59
{
60
return
false
;
61
}
62
63
bool
PokemonInfoWidget::HandleOnEvent
(
const
yap::GuiEvent
& guiEvent)
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)
75
pageNumber_
=
pokemonInfoPages_
.
Count
() - 1;
76
else
77
pageNumber_
--;
78
79
pokemonInfoPages_
[
pageNumber_
]->SetPokemon (*
pokemon_
);
80
pokemonInfoPages_
[
pageNumber_
]->Open ();
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
92
pageNumber_
= (
pageNumber_
+ 1) %
pokemonInfoPages_
.
Count
();
93
94
pokemonInfoPages_
[
pageNumber_
]->SetPokemon (*
pokemon_
);
95
pokemonInfoPages_
[
pageNumber_
]->Open ();
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
116
void
PokemonInfoWidget::HandleMove
(
const
yap::Vector2
& offset)
117
{
118
119
}
120
121
void
PokemonInfoWidget::HandleScale
(
const
yap::Vector2
& factor)
122
{
123
124
}
125
126
void
PokemonInfoWidget::HandleDraw
(
yap::IDrawingContext
& context)
127
{
128
}
129
130
void
PokemonInfoWidget::HandleShow
(
bool
isVisible)
131
{
132
}
133
134
void
PokemonInfoWidget::HandleChangeColor
(
const
sf::Color& color)
135
{
136
}
137
138
void
PokemonInfoWidget::HandleUpdate
(
const
yap::Time
& dt)
139
{
140
}
141
142
}
// namespace ycl
YAPOG.Client
src
Gui
PokemonInfoWidget.cpp
Generated on Mon Sep 17 2012 22:24:22 for YAPOG by
1.8.1.1