1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#include <algorithm>
#include "ProfileActivity.h"
#include "interface/Button.h"
#include "interface/Textbox.h"
#include "interface/Label.h"
#include "interface/Keys.h"
#include "Style.h"
#include "client/Client.h"
#include "client/requestbroker/RequestListener.h"
ProfileActivity::ProfileActivity(std::string username) :
WindowActivity(ui::Point(-1, -1), ui::Point(236, 302))
{
bool editable = Client::Ref().GetAuthUser().ID && Client::Ref().GetAuthUser().Username == username;
class CloseAction: public ui::ButtonAction
{
ProfileActivity * a;
public:
CloseAction(ProfileActivity * a) : a(a) { }
void ActionCallback(ui::Button * sender_)
{
a->Exit();
}
};
class SaveAction: public ui::ButtonAction
{
ProfileActivity * a;
public:
SaveAction(ProfileActivity * a) : a(a) { }
void ActionCallback(ui::Button * sender_)
{
}
};
ui::Button * closeButton = new ui::Button(ui::Point(0, Size.Y-15), ui::Point((Size.X/2)+1, 15), "Close");
closeButton->SetActionCallback(new CloseAction(this));
if(editable)
{
ui::Button * saveButton = new ui::Button(ui::Point(Size.X/2, Size.Y-15), ui::Point(Size.X/2, 15), "Save");
saveButton->SetActionCallback(new SaveAction(this));
AddComponent(saveButton);
}
AddComponent(closeButton);
RequestBroker::Ref().Start(Client::Ref().GetUserInfoAsync(username), this);
}
void ProfileActivity::OnResponseReady(void * userDataPtr)
{
exit(0);
}
void ProfileActivity::OnDraw()
{
Graphics * g = ui::Engine::Ref().g;
g->clearrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255);
}
ProfileActivity::~ProfileActivity() {
RequestBroker::Ref().DetachRequestListener(this);
}
|