diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2013-03-16 17:45:18 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2013-03-16 17:45:18 (GMT) |
| commit | f05044ab68e51ce9c374f6af09284051efcda449 (patch) | |
| tree | 6ae35ed5f6f3395593fc0d2c90780d8162f302e7 /src/profile/ProfileActivity.cpp | |
| parent | d383d6d7e5e1d3ca0856c02ebbcea5e9b8b2ff4e (diff) | |
| download | powder-f05044ab68e51ce9c374f6af09284051efcda449.zip powder-f05044ab68e51ce9c374f6af09284051efcda449.tar.gz | |
APIRequest, Aync methods for client, Profile edit/viewer (WIP)
Diffstat (limited to 'src/profile/ProfileActivity.cpp')
| -rw-r--r-- | src/profile/ProfileActivity.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/profile/ProfileActivity.cpp b/src/profile/ProfileActivity.cpp new file mode 100644 index 0000000..1b3a1f8 --- /dev/null +++ b/src/profile/ProfileActivity.cpp @@ -0,0 +1,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); +} + |
