summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2013-04-07 13:40:00 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2013-04-07 13:40:00 (GMT)
commitb4fb55f86e9add3248166278bb566f210dacf636 (patch)
tree2a1fa8d339fdf03741998873a523258a87dea739 /src
parent8d312ecdfadb7c68d00caf01effe0c1e0a45cb76 (diff)
downloadpowder-b4fb55f86e9add3248166278bb566f210dacf636.zip
powder-b4fb55f86e9add3248166278bb566f210dacf636.tar.gz
Allow signing out and editing profile from the old login button, add a button to edit avatar (directs to the website at the moment) Allow viewing profiles by clicking avatars
Diffstat (limited to 'src')
-rw-r--r--src/gui/game/GameController.cpp6
-rw-r--r--src/gui/game/GameController.h1
-rw-r--r--src/gui/game/GameView.cpp17
-rw-r--r--src/gui/preview/PreviewView.cpp17
-rw-r--r--src/gui/preview/PreviewView.h1
-rw-r--r--src/gui/profile/ProfileActivity.cpp26
6 files changed, 61 insertions, 7 deletions
diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp
index 8df5036..5f72398 100644
--- a/src/gui/game/GameController.cpp
+++ b/src/gui/game/GameController.cpp
@@ -1068,6 +1068,12 @@ void GameController::OpenLocalBrowse()
void GameController::OpenLogin()
{
+ loginWindow = new LoginController();
+ ui::Engine::Ref().ShowWindow(loginWindow->GetView());
+}
+
+void GameController::OpenProfile()
+{
if(Client::Ref().GetAuthUser().ID)
{
new ProfileActivity(Client::Ref().GetAuthUser().Username);
diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h
index 644d25c..c34d44a 100644
--- a/src/gui/game/GameController.h
+++ b/src/gui/game/GameController.h
@@ -108,6 +108,7 @@ public:
void LoadSave(SaveInfo * save);
void OpenSearch();
void OpenLogin();
+ void OpenProfile();
void OpenTags();
void OpenSavePreview(int saveID, int saveDate);
void OpenSavePreview();
diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp
index c11a59d..676eec8 100644
--- a/src/gui/game/GameView.cpp
+++ b/src/gui/game/GameView.cpp
@@ -46,6 +46,7 @@ public:
{
}
+ void SetRightToolTip(std::string tooltip) { toolTip2 = tooltip; }
bool GetShowSplit() { return showSplit; }
void SetShowSplit(bool split) { showSplit = split; }
SplitButtonAction * GetSplitActionCallback() { return splitActionCallback; }
@@ -335,20 +336,24 @@ GameView::GameView():
clearSimButton->SetActionCallback(new ClearSimAction(this));
AddComponent(clearSimButton);
- class LoginAction : public ui::ButtonAction
+ class LoginAction : public SplitButtonAction
{
GameView * v;
public:
LoginAction(GameView * _v) { v = _v; }
- void ActionCallback(ui::Button * sender)
+ void ActionCallbackLeft(ui::Button * sender)
{
v->c->OpenLogin();
}
+ void ActionCallbackRight(ui::Button * sender)
+ {
+ v->c->OpenProfile();
+ }
};
- loginButton = new ui::Button(ui::Point(Size.X-141, Size.Y-16), ui::Point(92, 15), "[sign in]", "Sign into simulation server");
+ loginButton = new SplitButton(ui::Point(Size.X-141, Size.Y-16), ui::Point(92, 15), "[sign in]", "Sign into simulation server", "Edit Profile", 19);
loginButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
loginButton->SetIcon(IconLogin);
- loginButton->SetActionCallback(new LoginAction(this));
+ ((SplitButton*)loginButton)->SetSplitActionCallback(new LoginAction(this));
AddComponent(loginButton);
class SimulationOptionAction : public ui::ButtonAction
@@ -802,10 +807,14 @@ void GameView::NotifyUserChanged(GameModel * sender)
if(!sender->GetUser().ID)
{
loginButton->SetText("[sign in]");
+ ((SplitButton*)loginButton)->SetShowSplit(false);
+ ((SplitButton*)loginButton)->SetRightToolTip("Sign in to simulation server");
}
else
{
loginButton->SetText(sender->GetUser().Username);
+ ((SplitButton*)loginButton)->SetShowSplit(true);
+ ((SplitButton*)loginButton)->SetRightToolTip("Edit profile");
}
NotifySaveChanged(sender);
}
diff --git a/src/gui/preview/PreviewView.cpp b/src/gui/preview/PreviewView.cpp
index 4211732..27584c9 100644
--- a/src/gui/preview/PreviewView.cpp
+++ b/src/gui/preview/PreviewView.cpp
@@ -10,6 +10,7 @@
#include "gui/Style.h"
#include "Format.h"
#include "gui/search/Thumbnail.h"
+#include "gui/profile/ProfileActivity.h"
#include "client/Client.h"
#include "gui/interface/ScrollPanel.h"
#include "gui/interface/AvatarButton.h"
@@ -47,6 +48,20 @@ public:
}
};
+class PreviewView::AvatarAction: public ui::AvatarButtonAction
+{
+ PreviewView * v;
+public:
+ AvatarAction(PreviewView * v_){ v = v_; }
+ virtual void ActionCallback(ui::AvatarButton * sender)
+ {
+ if(sender->GetUsername().size() > 0)
+ {
+ new ProfileActivity(sender->GetUsername());
+ }
+ }
+};
+
PreviewView::PreviewView():
ui::Window(ui::Point(-1, -1), ui::Point((XRES/2)+210, (YRES/2)+150)),
savePreview(NULL),
@@ -166,6 +181,7 @@ PreviewView::PreviewView():
if(showAvatars)
{
avatarButton = new ui::AvatarButton(ui::Point(4, (YRES/2)+4), ui::Point(34, 34), "");
+ avatarButton->SetActionCallback(new AvatarAction(this));
AddComponent(avatarButton);
}
@@ -546,6 +562,7 @@ void PreviewView::NotifyCommentsChanged(PreviewModel * sender)
if(showAvatars)
{
tempAvatar = new ui::AvatarButton(ui::Point(2, currentY+7), ui::Point(26, 26), comments->at(i)->authorName);
+ tempAvatar->SetActionCallback(new AvatarAction(this));
commentComponents.push_back(tempAvatar);
commentsPanel->AddChild(tempAvatar);
}
diff --git a/src/gui/preview/PreviewView.h b/src/gui/preview/PreviewView.h
index 2fef5ac..c01644c 100644
--- a/src/gui/preview/PreviewView.h
+++ b/src/gui/preview/PreviewView.h
@@ -23,6 +23,7 @@ class PreviewView: public ui::Window {
class SubmitCommentAction;
class LoginAction;
class AutoCommentSizeAction;
+ class AvatarAction;
PreviewController * c;
VideoBuffer * savePreview;
ui::Button * openButton;
diff --git a/src/gui/profile/ProfileActivity.cpp b/src/gui/profile/ProfileActivity.cpp
index 54da81e..fe6ab80 100644
--- a/src/gui/profile/ProfileActivity.cpp
+++ b/src/gui/profile/ProfileActivity.cpp
@@ -49,11 +49,13 @@ ProfileActivity::ProfileActivity(std::string username) :
}
};
- 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));
+ ui::Button * closeButton = new ui::Button(ui::Point(0, Size.Y-15), ui::Point(Size.X, 15), "Close");
+ closeButton->SetActionCallback(new CloseAction(this));
if(editable)
{
+ closeButton->Size.X = (Size.X/2)+1;
+
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);
@@ -67,6 +69,17 @@ ProfileActivity::ProfileActivity(std::string username) :
void ProfileActivity::setUserInfo(UserInfo newInfo)
{
+ class EditAvatarAction: public ui::ButtonAction
+ {
+ ProfileActivity * a;
+ public:
+ EditAvatarAction(ProfileActivity * a) : a(a) { }
+ void ActionCallback(ui::Button * sender_)
+ {
+ OpenURI("http://" SERVER "/Profile/Avatar.html");
+ }
+ };
+
info = newInfo;
if(!info.Biography.length() && !editable)
@@ -79,11 +92,18 @@ void ProfileActivity::setUserInfo(UserInfo newInfo)
AddComponent(avatar);
int currentY = 5;
- ui::Label * title = new ui::Label(ui::Point(4, currentY), ui::Point(Size.X-8-(40+8), 15), info.Username);
+ if(editable)
+ {
+ ui::Button * editAvatar = new ui::Button(ui::Point(Size.X - (40 + 16 + 75), currentY), ui::Point(75, 15), "Edit Avatar");
+ editAvatar->SetActionCallback(new EditAvatarAction(this));
+ AddComponent(editAvatar);
+ }
+ ui::Label * title = new ui::Label(ui::Point(4, currentY), ui::Point(Size.X-8-(40+8+75), 15), info.Username);
title->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
AddComponent(title);
currentY += 20;
+
ui::Label * locationTitle = new ui::Label(ui::Point(4, currentY), ui::Point(Size.X-8-(40+8), 15), "Location");
locationTitle->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
AddComponent(locationTitle);