YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
PokemonFrontInfoWidget.cpp
Go to the documentation of this file.
1
#include "
YAPOG/System/StringHelper.hpp
"
2
#include "
YAPOG/Graphics/Gui/WidgetBackground.hpp
"
3
#include "
YAPOG/Graphics/Gui/WidgetBorder.hpp
"
4
#include "
YAPOG/Graphics/Gui/HorizontalLayout.hpp
"
5
#include "
YAPOG/Graphics/Gui/VerticalLayout.hpp
"
6
#include "
YAPOG/Graphics/Gui/PictureBox.hpp
"
7
#include "
YAPOG/Graphics/Gui/MultiLabelWidget.hpp
"
8
#include "
YAPOG/Game/Pokemon/PokemonInfo.hpp
"
9
#include "
YAPOG/Graphics/Game/Sprite/ISprite.hpp
"
10
#include "
YAPOG/Graphics/Game/Sprite/Sprite.hpp
"
11
12
#include "
Gui/PokemonFrontInfoWidget.hpp
"
13
#include "Pokemon/Pokemon.hpp"
14
15
namespace
ycl
16
{
17
PokemonFrontInfoWidget::PokemonFrontInfoWidget
()
18
: name_ (nullptr)
19
, level_ (nullptr)
20
, gender_ (nullptr)
21
, spriteFront_ (nullptr)
22
, mainLayout_ (nullptr)
23
, levelLayout_ (nullptr)
24
, nameLayout_ (nullptr)
25
, genderLayout_ (nullptr)
26
, levelNameGenderLayout_ (nullptr)
27
, spriteFrontLayout_ (nullptr)
28
, genderMaleIcon_ (nullptr)
29
, genderFemaleIcon_ (nullptr)
30
{
31
// Labels
32
name_
=
new
yap::Label
();
33
level_
=
new
yap::Label
();
34
35
// PictureBoxes
36
gender_
=
new
yap::PictureBox
();
37
spriteFront_
=
new
yap::PictureBox
();
38
39
spriteFront_
->
SetPicture
(
40
new
yap::Sprite
(
"Test/white.png"
));
41
42
// Sprites
43
genderMaleIcon_
=
new
yap::Sprite
(
"Pictures/TeamManager/Male.png"
);
44
genderFemaleIcon_
=
new
yap::Sprite
(
"Pictures/TeamManager/Female.png"
);
45
46
gender_
->
SetPicture
(
genderFemaleIcon_
);
47
48
// Layouts
49
mainLayout_
=
new
yap::VerticalLayout
(
50
yap::Padding
(0, 0, 0, 7),
yap::Padding
(),
false
);
51
52
levelLayout_
=
new
yap::VerticalLayout
(
53
yap::Padding
(),
yap::Padding
(),
false
);
54
55
nameLayout_
=
new
yap::VerticalLayout
(
56
yap::Padding
(),
yap::Padding
(),
false
);
57
58
genderLayout_
=
new
yap::HorizontalLayout
(
59
yap::Padding
(),
yap::Padding
(),
false
);
60
61
levelNameGenderLayout_
=
new
yap::HorizontalLayout
(
62
yap::Padding
(),
yap::Padding
(),
false
);
63
64
spriteFrontLayout_
=
new
yap::VerticalLayout
(
65
yap::Padding
(0, 0, 0, 50),
yap::Padding
(),
false
);
66
}
67
68
void
PokemonFrontInfoWidget::Init
()
69
{
70
SetSize
(
yap::Vector2
(392, 315));
71
72
// Set layouts size
73
mainLayout_
->
SetSize
(
GetSize
());
74
levelLayout_
->
SetSize
(
yap::Vector2
(88, 53));
75
nameLayout_
->
SetSize
(
yap::Vector2
(240, 53));
76
genderLayout_
->
SetSize
(
yap::Vector2
(40, 53));
77
levelNameGenderLayout_
->
SetSize
(
yap::Vector2
(379, 53));
78
spriteFrontLayout_
->
SetSize
(
yap::Vector2
(363, 233));
79
80
// Set the labels text size
81
name_
->
SetTextSize
(40);
82
level_
->
SetTextSize
(40);
83
84
// Hierarchy construction
85
spriteFrontLayout_
->
AddChild
(*
spriteFront_
);
86
87
levelLayout_
->
AddChild
(*
level_
);
88
nameLayout_
->
AddChild
(*
name_
);
89
genderLayout_
->
AddChild
(*
gender_
);
90
91
levelNameGenderLayout_
->
AddChild
(*
levelLayout_
);
92
levelNameGenderLayout_
->
AddChild
(*
nameLayout_
);
93
levelNameGenderLayout_
->
AddChild
(*
genderLayout_
);
94
95
mainLayout_
->
AddChild
(*
levelNameGenderLayout_
);
96
mainLayout_
->
AddChild
(*
spriteFrontLayout_
);
97
98
// Borders
99
/*
100
mainLayout_->SetBorder (*new yap::WidgetBorder ("Test/grey.png"));
101
levelLayout_->SetBorder (*new yap::WidgetBorder ("Test/red.png"));
102
nameLayout_->SetBorder (*new yap::WidgetBorder ("Test/yellow.png"));
103
genderLayout_->SetBorder (*new yap::WidgetBorder ("Test/green.png"));
104
levelNameGenderLayout_->SetBorder (*new yap::WidgetBorder ("Test/red.png"));
105
spriteFrontLayout_->SetBorder (*new yap::WidgetBorder ("Test/blue.png"));
106
*/
107
108
AddChild
(*
mainLayout_
);
109
}
110
111
void
PokemonFrontInfoWidget::SetPokemon
(
const
Pokemon
& pokemon)
112
{
113
// Labels
114
name_
->
SetText
(pokemon.
GetName
());
115
level_
->
SetText
(
"N."
+
116
yap::StringHelper::ToString
117
(static_cast<int>(pokemon.
GetLevel
())) +
" "
);
118
119
// PictureBoxes
120
// @todo Debug this part
121
/*
122
if (pokemon.GetGender () == yap::Gender::Female)
123
gender_->SetPicture (genderFemaleIcon_);
124
else
125
gender_->SetPicture (genderMaleIcon_);
126
*/
127
128
spriteFront_
->
SetPicture
(pokemon.
GetBattleFront
().
Clone
());
129
130
// Refresh layouts to center labels
131
levelLayout_
->
Refresh
();
132
nameLayout_
->
Refresh
();
133
genderLayout_
->
Refresh
();
134
}
135
136
bool
PokemonFrontInfoWidget::IsFocusable
()
const
137
{
138
return
false
;
139
}
140
141
void
PokemonFrontInfoWidget::HandleMove
(
const
yap::Vector2
& offset)
142
{
143
144
}
145
void
PokemonFrontInfoWidget::HandleScale
(
const
yap::Vector2
& factor)
146
{
147
148
}
149
void
PokemonFrontInfoWidget::HandleDraw
(
yap::IDrawingContext
& offset)
150
{
151
152
}
153
void
PokemonFrontInfoWidget::HandleShow
(
bool
isVisible)
154
{
155
}
156
void
PokemonFrontInfoWidget::HandleChangeColor
(
const
sf::Color& color)
157
{
158
}
159
void
PokemonFrontInfoWidget::HandleUpdate
(
const
yap::Time
& dt)
160
{
161
}
162
163
}
// namespace ycl
YAPOG.Client
src
Gui
PokemonFrontInfoWidget.cpp
Generated on Mon Sep 17 2012 22:24:22 for YAPOG by
1.8.1.1