YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
GameMainMenu.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Graphics/Gui/Padding.hpp
"
2
#include "
YAPOG/Graphics/Texture.hpp
"
3
#include "
YAPOG/Graphics/Gui/WidgetBackground.hpp
"
4
#include "
YAPOG/Graphics/Gui/WidgetBorder.hpp
"
5
#include "
YAPOG/Audio/AudioManager.hpp
"
6
7
#include "
Gui/GameMainMenu.hpp
"
8
9
namespace
ycl
10
{
11
const
yap::Menu::Type
GameMainMenu::DEFAULT_ALIGNMENT
=
12
yap::Menu::Type::VERTICAL;
13
const
yap::Padding
GameMainMenu::DEFAULT_PADDING
=
yap::Padding
(5, 5, 5, 5);
14
15
const
sf::Color
GameMainMenu::DEFAULT_ITEM_COLOR
= sf::Color (127, 127, 127);
16
const
yap::LayoutBox::Align
GameMainMenu::DEFAULT_ITEM_ALIGNMENT
=
17
yap::LayoutBox::Align::LEFT;
18
19
GameMainMenu::GameMainMenu
()
20
:
GameMenu
(
21
DEFAULT_ALIGNMENT,
22
DEFAULT_PADDING,
23
DEFAULT_PADDING,
24
false)
25
{
26
}
27
28
void
GameMainMenu::Init
(
const
yap::String
& playerName)
29
{
30
yap::WidgetBackground
* menuBck =
31
new
yap::WidgetBackground
(
"Test/white.png"
,
true
);
32
33
yap::Texture
* ti =
new
yap::Texture
();
34
yap::Texture
* tri =
new
yap::Texture
();
35
yap::Texture
* ri =
new
yap::Texture
();
36
yap::Texture
* bri =
new
yap::Texture
();
37
yap::Texture
* bi =
new
yap::Texture
();
38
yap::Texture
* bli =
new
yap::Texture
();
39
yap::Texture
* li =
new
yap::Texture
();
40
li->
LoadFromFile
(
"WindowSkins/BasicSkin/Global/Cursor.png"
);
41
yap::Texture
* tli =
new
yap::Texture
();
42
yap::WidgetBorder
* menuItemBrd =
43
new
yap::WidgetBorder
(
44
*ti, *tri, *ri, *bri, *bi, *bli, *li, *tli,
false
);
45
46
yap::Texture
* t =
new
yap::Texture
();
47
t->
LoadFromFile
(
"WindowSkins/BasicSkin/Global/TopBorder.png"
);
48
yap::Texture
* tr =
new
yap::Texture
();
49
tr->
LoadFromFile
(
"WindowSkins/BasicSkin/Global/TopRightCorner.png"
);
50
yap::Texture
* r =
new
yap::Texture
();
51
r->
LoadFromFile
(
"WindowSkins/BasicSkin/Global/RightBorder.png"
);
52
yap::Texture
* br =
new
yap::Texture
();
53
br->
LoadFromFile
(
"WindowSkins/BasicSkin/Global/BottomRightCorner.png"
);
54
yap::Texture
* b =
new
yap::Texture
();
55
b->
LoadFromFile
(
"WindowSkins/BasicSkin/Global/BottomBorder.png"
);
56
yap::Texture
* bl =
new
yap::Texture
();
57
bl->
LoadFromFile
(
"WindowSkins/BasicSkin/Global/BottomLeftCorner.png"
);
58
yap::Texture
* l =
new
yap::Texture
();
59
l->
LoadFromFile
(
"WindowSkins/BasicSkin/Global/LeftBorder.png"
);
60
yap::Texture
* tl =
new
yap::Texture
();
61
tl->
LoadFromFile
(
"WindowSkins/BasicSkin/Global/TopLeftCorner.png"
);
62
63
yap::WidgetBorder
* menuBorder =
64
new
yap::WidgetBorder
(*t, *tr, *r, *br, *b, *bl, *l, *tl,
true
);
65
66
SetSelectedBorder
(*menuItemBrd);
67
68
yap::MenuItem
& pokedexItem =
AddItem
(
"POKéDEX"
);
69
pokedexItem.
OnActivated
+= [
this
] (
70
yap::MenuItem
& sender,
71
const
yap::EmptyEventArgs
& args)
72
{
73
OnPokedexItemActivated
(*
this
,
yap::EmptyEventArgs
());
74
};
75
76
yap::MenuItem
& pokemonItem =
AddItem
(
"POKéMON"
);
77
pokemonItem.
OnActivated
+= [
this
] (
78
yap::MenuItem
& sender,
79
const
yap::EmptyEventArgs
& args)
80
{
81
OnPokemonItemActivated
(*
this
,
yap::EmptyEventArgs
());
82
};
83
84
yap::MenuItem
& bagItem =
AddItem
(
"SAC"
);
85
86
yap::MenuItem
& playerItem =
AddItem
(playerName);
87
playerItem.
OnActivated
+= [
this
] (
88
yap::MenuItem
& sender,
89
const
yap::EmptyEventArgs
& args)
90
{
91
OnTrainerCardItemActivated
(*
this
,
yap::EmptyEventArgs
());
92
};
93
94
yap::MenuItem
& optionItem =
AddItem
(
"OPTIONS"
);
95
optionItem.
OnActivated
+= [
this
] (
96
yap::MenuItem
& sender,
97
const
yap::EmptyEventArgs
& args)
98
{
99
OnOptionItemActivated
(*
this
,
yap::EmptyEventArgs
());
100
};
101
102
yap::MenuItem
& exitItem =
AddItem
(
"RETOUR"
);
103
exitItem.
OnActivated
+= [
this
] (
104
yap::MenuItem
& sender,
105
const
yap::EmptyEventArgs
& args)
106
{
107
Close
();
108
yap::AudioManager::Instance
().
ResumePreviousMusic
();
109
};
110
111
SetBackground
(*menuBck);
112
SetBorder
(*menuBorder);
113
}
114
115
GameMainMenu::~GameMainMenu
()
116
{
117
}
118
119
yap::MenuItem
&
GameMainMenu::AddItem
(
const
yap::String
& itemName)
120
{
121
yap::MenuItem
* item =
new
yap::MenuItem
(
true
);
122
item->
SetContent
(itemName);
123
124
item->
ChangeColor
(
DEFAULT_ITEM_COLOR
);
125
126
AddChild
(*item,
DEFAULT_ITEM_ALIGNMENT
);
127
128
return
*item;
129
}
130
}
// namespace ycl
YAPOG.Client
src
Gui
GameMainMenu.cpp
Generated on Mon Sep 17 2012 22:24:21 for YAPOG by
1.8.1.1