YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
RegistrationScreen.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Graphics/Gui/GuiManager.hpp
"
2
#include "
YAPOG/Graphics/Gui/PictureBox.hpp
"
3
#include "
YAPOG/System/RandomHelper.hpp
"
4
#include "
YAPOG/Graphics/Game/Sprite/Sprite.hpp
"
5
6
#include "
GameScreen/RegistrationScreen.hpp
"
7
#include "
Client/Session.hpp
"
8
9
namespace
ycl
10
{
11
const
yap::ScreenType
RegistrationScreen::DEFAULT_NAME
=
"Registration"
;
12
13
RegistrationScreen::RegistrationScreen
(
yap::IDrawingContext
& context)
14
:
BaseScreen
(DEFAULT_NAME, context)
15
, registrationWidget_ ()
16
{
17
registrationWidget_
.
Init
();
18
}
19
20
RegistrationScreen::~RegistrationScreen
()
21
{
22
}
23
24
void
RegistrationScreen::HandleInit
()
25
{
26
BaseScreen::HandleInit
();
27
28
session_
.
OnRegistrationValidation
+= [
this
] (
29
Session
& sender,
30
const
yap::EmptyEventArgs
& args)
31
{
32
nextScreen_
=
"MainMenu"
;
33
};
34
35
session_
.
OnRegistrationError
+= [
this
] (
36
Session
& sender,
37
const
yap::EmptyEventArgs
& args)
38
{
39
registrationWidget_
.
SetErrorText
(
"Failed to register !"
);
40
};
41
42
yap::PictureBox
* bg =
new
yap::PictureBox
();
43
44
yap::RandomHelper
* random;
45
int
nb = random->
GetNext
(0, 4242) % 5;
46
switch
(nb)
47
{
48
case
0:
49
bg->
SetPicture
(
new
yap::Sprite
(
"WindowSkins/BasicSkin/Background/mew.jpg"
));
50
break
;
51
case
1:
52
bg->
SetPicture
(
new
yap::Sprite
(
"WindowSkins/BasicSkin/Background/fete.jpg"
));
53
break
;
54
case
2:
55
bg->
SetPicture
(
new
yap::Sprite
(
"WindowSkins/BasicSkin/Background/rondoudou.jpg"
));
56
break
;
57
case
3:
58
bg->
SetPicture
(
new
yap::Sprite
(
"WindowSkins/BasicSkin/Background/dresseur.jpg"
));
59
break
;
60
case
4:
61
bg->
SetPicture
(
new
yap::Sprite
(
"WindowSkins/BasicSkin/Background/ronflex.gif"
));
62
break
;
63
default
:
64
bg->
SetPicture
(
new
yap::Sprite
(
"WindowSkins/BasicSkin/Background/ronflex.gif"
));
65
break
;
66
}
67
68
bg->
SetSize
(
yap::Vector2
(800, 600));
69
guiManager_
->
AddChild
(*bg);
70
guiManager_
->
AddChild
(
registrationWidget_
);
71
}
72
73
void
RegistrationScreen::HandleRun
(
74
const
yap::Time
& dt,
75
yap::IDrawingContext
& context)
76
{
77
BaseScreen::HandleRun
(dt, context);
78
}
79
80
bool
RegistrationScreen::HandleOnPriorityEvent
(
const
yap::GuiEvent
& guiEvent)
81
{
82
if
(guiEvent.type == sf::Event::KeyPressed)
83
{
84
if
(guiEvent.key.code == sf::Keyboard::Escape)
85
{
86
nextScreen_
=
"MainMenu"
;
87
return
true
;
88
}
89
90
if
(guiEvent.key.code == sf::Keyboard::Return)
91
{
92
yap::String
login =
93
registrationWidget_
.
GetLoginTextBox
().
GetContent
();
94
yap::String
password =
95
registrationWidget_
.
GetPasswordTextBox
().
GetContent
();
96
yap::String
email =
97
registrationWidget_
.
GetEmailTextBox
().
GetContent
();
98
99
//@todo Check
100
101
session_
.
Register
(login, password, email);
102
103
return
true
;
104
}
105
106
}
107
return
false
;
108
}
109
110
void
RegistrationScreen::HandleDeactivate
()
111
{
112
registrationWidget_
.
GetLoginTextBox
().
Clear
();
113
registrationWidget_
.
GetPasswordTextBox
().
Clear
();
114
registrationWidget_
.
GetEmailTextBox
().
Clear
();
115
registrationWidget_
.
SetErrorText
(
""
);
116
}
117
118
}
// namespace ycl
YAPOG.Client
src
GameScreen
RegistrationScreen.cpp
Generated on Mon Sep 17 2012 22:24:21 for YAPOG by
1.8.1.1