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
This commit is contained in:
parent
8d312ecdfa
commit
b4fb55f86e
@ -1067,6 +1067,12 @@ void GameController::OpenLocalBrowse()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameController::OpenLogin()
|
void GameController::OpenLogin()
|
||||||
|
{
|
||||||
|
loginWindow = new LoginController();
|
||||||
|
ui::Engine::Ref().ShowWindow(loginWindow->GetView());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameController::OpenProfile()
|
||||||
{
|
{
|
||||||
if(Client::Ref().GetAuthUser().ID)
|
if(Client::Ref().GetAuthUser().ID)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +108,7 @@ public:
|
|||||||
void LoadSave(SaveInfo * save);
|
void LoadSave(SaveInfo * save);
|
||||||
void OpenSearch();
|
void OpenSearch();
|
||||||
void OpenLogin();
|
void OpenLogin();
|
||||||
|
void OpenProfile();
|
||||||
void OpenTags();
|
void OpenTags();
|
||||||
void OpenSavePreview(int saveID, int saveDate);
|
void OpenSavePreview(int saveID, int saveDate);
|
||||||
void OpenSavePreview();
|
void OpenSavePreview();
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void SetRightToolTip(std::string tooltip) { toolTip2 = tooltip; }
|
||||||
bool GetShowSplit() { return showSplit; }
|
bool GetShowSplit() { return showSplit; }
|
||||||
void SetShowSplit(bool split) { showSplit = split; }
|
void SetShowSplit(bool split) { showSplit = split; }
|
||||||
SplitButtonAction * GetSplitActionCallback() { return splitActionCallback; }
|
SplitButtonAction * GetSplitActionCallback() { return splitActionCallback; }
|
||||||
@ -335,20 +336,24 @@ GameView::GameView():
|
|||||||
clearSimButton->SetActionCallback(new ClearSimAction(this));
|
clearSimButton->SetActionCallback(new ClearSimAction(this));
|
||||||
AddComponent(clearSimButton);
|
AddComponent(clearSimButton);
|
||||||
|
|
||||||
class LoginAction : public ui::ButtonAction
|
class LoginAction : public SplitButtonAction
|
||||||
{
|
{
|
||||||
GameView * v;
|
GameView * v;
|
||||||
public:
|
public:
|
||||||
LoginAction(GameView * _v) { v = _v; }
|
LoginAction(GameView * _v) { v = _v; }
|
||||||
void ActionCallback(ui::Button * sender)
|
void ActionCallbackLeft(ui::Button * sender)
|
||||||
{
|
{
|
||||||
v->c->OpenLogin();
|
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->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||||
loginButton->SetIcon(IconLogin);
|
loginButton->SetIcon(IconLogin);
|
||||||
loginButton->SetActionCallback(new LoginAction(this));
|
((SplitButton*)loginButton)->SetSplitActionCallback(new LoginAction(this));
|
||||||
AddComponent(loginButton);
|
AddComponent(loginButton);
|
||||||
|
|
||||||
class SimulationOptionAction : public ui::ButtonAction
|
class SimulationOptionAction : public ui::ButtonAction
|
||||||
@ -802,10 +807,14 @@ void GameView::NotifyUserChanged(GameModel * sender)
|
|||||||
if(!sender->GetUser().ID)
|
if(!sender->GetUser().ID)
|
||||||
{
|
{
|
||||||
loginButton->SetText("[sign in]");
|
loginButton->SetText("[sign in]");
|
||||||
|
((SplitButton*)loginButton)->SetShowSplit(false);
|
||||||
|
((SplitButton*)loginButton)->SetRightToolTip("Sign in to simulation server");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loginButton->SetText(sender->GetUser().Username);
|
loginButton->SetText(sender->GetUser().Username);
|
||||||
|
((SplitButton*)loginButton)->SetShowSplit(true);
|
||||||
|
((SplitButton*)loginButton)->SetRightToolTip("Edit profile");
|
||||||
}
|
}
|
||||||
NotifySaveChanged(sender);
|
NotifySaveChanged(sender);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "gui/Style.h"
|
#include "gui/Style.h"
|
||||||
#include "Format.h"
|
#include "Format.h"
|
||||||
#include "gui/search/Thumbnail.h"
|
#include "gui/search/Thumbnail.h"
|
||||||
|
#include "gui/profile/ProfileActivity.h"
|
||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
#include "gui/interface/ScrollPanel.h"
|
#include "gui/interface/ScrollPanel.h"
|
||||||
#include "gui/interface/AvatarButton.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():
|
PreviewView::PreviewView():
|
||||||
ui::Window(ui::Point(-1, -1), ui::Point((XRES/2)+210, (YRES/2)+150)),
|
ui::Window(ui::Point(-1, -1), ui::Point((XRES/2)+210, (YRES/2)+150)),
|
||||||
savePreview(NULL),
|
savePreview(NULL),
|
||||||
@ -166,6 +181,7 @@ PreviewView::PreviewView():
|
|||||||
if(showAvatars)
|
if(showAvatars)
|
||||||
{
|
{
|
||||||
avatarButton = new ui::AvatarButton(ui::Point(4, (YRES/2)+4), ui::Point(34, 34), "");
|
avatarButton = new ui::AvatarButton(ui::Point(4, (YRES/2)+4), ui::Point(34, 34), "");
|
||||||
|
avatarButton->SetActionCallback(new AvatarAction(this));
|
||||||
AddComponent(avatarButton);
|
AddComponent(avatarButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,6 +562,7 @@ void PreviewView::NotifyCommentsChanged(PreviewModel * sender)
|
|||||||
if(showAvatars)
|
if(showAvatars)
|
||||||
{
|
{
|
||||||
tempAvatar = new ui::AvatarButton(ui::Point(2, currentY+7), ui::Point(26, 26), comments->at(i)->authorName);
|
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);
|
commentComponents.push_back(tempAvatar);
|
||||||
commentsPanel->AddChild(tempAvatar);
|
commentsPanel->AddChild(tempAvatar);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ class PreviewView: public ui::Window {
|
|||||||
class SubmitCommentAction;
|
class SubmitCommentAction;
|
||||||
class LoginAction;
|
class LoginAction;
|
||||||
class AutoCommentSizeAction;
|
class AutoCommentSizeAction;
|
||||||
|
class AvatarAction;
|
||||||
PreviewController * c;
|
PreviewController * c;
|
||||||
VideoBuffer * savePreview;
|
VideoBuffer * savePreview;
|
||||||
ui::Button * openButton;
|
ui::Button * openButton;
|
||||||
|
@ -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)
|
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");
|
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));
|
saveButton->SetActionCallback(new SaveAction(this));
|
||||||
AddComponent(saveButton);
|
AddComponent(saveButton);
|
||||||
@ -67,6 +69,17 @@ ProfileActivity::ProfileActivity(std::string username) :
|
|||||||
|
|
||||||
void ProfileActivity::setUserInfo(UserInfo newInfo)
|
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;
|
info = newInfo;
|
||||||
|
|
||||||
if(!info.Biography.length() && !editable)
|
if(!info.Biography.length() && !editable)
|
||||||
@ -79,11 +92,18 @@ void ProfileActivity::setUserInfo(UserInfo newInfo)
|
|||||||
AddComponent(avatar);
|
AddComponent(avatar);
|
||||||
|
|
||||||
int currentY = 5;
|
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;
|
title->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||||
AddComponent(title);
|
AddComponent(title);
|
||||||
currentY += 20;
|
currentY += 20;
|
||||||
|
|
||||||
|
|
||||||
ui::Label * locationTitle = new ui::Label(ui::Point(4, currentY), ui::Point(Size.X-8-(40+8), 15), "Location");
|
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;
|
locationTitle->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||||
AddComponent(locationTitle);
|
AddComponent(locationTitle);
|
||||||
|
Reference in New Issue
Block a user