From 9628a11245acc1b2c8dd213a4dd30a3fb9930e01 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 16 Jul 2013 16:55:39 -0400 Subject: [PATCH] save to server button is disabled when not logged in, but tags are viewable (read only) --- src/gui/game/GameController.cpp | 17 ++++++----------- src/gui/game/GameView.cpp | 6 +++++- src/gui/game/GameView.h | 33 +++++++++++++++++---------------- src/gui/tags/TagsView.cpp | 6 +++++- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 241bc9e1e..bd69f2b00 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -1162,21 +1162,16 @@ void GameController::OpenColourPicker() void GameController::OpenTags() { - if(gameModel->GetUser().ID) + if(gameModel->GetSave() && gameModel->GetSave()->GetID()) { - if(gameModel->GetSave() && gameModel->GetSave()->GetID()) - { - tagsWindow = new TagsController(new TagsCallback(this), gameModel->GetSave()); - ui::Engine::Ref().ShowWindow(tagsWindow->GetView()); - } - else - { - new ErrorMessage("Error", "No save open"); - } + if (tagsWindow) + delete tagsWindow; + tagsWindow = new TagsController(new TagsCallback(this), gameModel->GetSave()); + ui::Engine::Ref().ShowWindow(tagsWindow->GetView()); } else { - new ErrorMessage("Error", "You need to login to edit tags."); + new ErrorMessage("Error", "No save open"); } } diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 1b811e04b..027f06bf5 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -836,6 +836,7 @@ void GameView::NotifyUserChanged(GameModel * sender) ((SplitButton*)loginButton)->SetShowSplit(true); ((SplitButton*)loginButton)->SetRightToolTip("Edit profile"); } + saveSimulationButtonEnabled = sender->GetUser().ID; NotifySaveChanged(sender); } @@ -892,7 +893,7 @@ void GameView::NotifySaveChanged(GameModel * sender) downVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100); } - tagSimulationButton->Enabled = (sender->GetSave()->GetID() && sender->GetUser().ID); + tagSimulationButton->Enabled = sender->GetSave()->GetID(); if(sender->GetSave()->GetID()) { std::stringstream tagsStream; @@ -951,6 +952,7 @@ void GameView::NotifySaveChanged(GameModel * sender) tagSimulationButton->SetText("[no tags set]"); currentSaveType = 0; } + saveSimulationButton->Enabled = (saveSimulationButtonEnabled || ctrlBehaviour); c->HistorySnapshot(); } @@ -1813,6 +1815,7 @@ void GameView::enableCtrlBehaviour() //Show HDD save & load buttons saveSimulationButton->Appearance.BackgroundInactive = saveSimulationButton->Appearance.BackgroundHover = ui::Colour(255, 255, 255); saveSimulationButton->Appearance.TextInactive = saveSimulationButton->Appearance.TextHover = ui::Colour(0, 0, 0); + saveSimulationButton->Enabled = true; searchButton->Appearance.BackgroundInactive = searchButton->Appearance.BackgroundHover = ui::Colour(255, 255, 255); searchButton->Appearance.TextInactive = searchButton->Appearance.TextHover = ui::Colour(0, 0, 0); if (currentSaveType == 2) @@ -1837,6 +1840,7 @@ void GameView::disableCtrlBehaviour() saveSimulationButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0); saveSimulationButton->Appearance.BackgroundHover = ui::Colour(20, 20, 20); saveSimulationButton->Appearance.TextInactive = saveSimulationButton->Appearance.TextHover = ui::Colour(255, 255, 255); + saveSimulationButton->Enabled = saveSimulationButtonEnabled; searchButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0); searchButton->Appearance.BackgroundHover = ui::Colour(20, 20, 20); searchButton->Appearance.TextInactive = searchButton->Appearance.TextHover = ui::Colour(255, 255, 255); diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index f7f636124..f37c34bb0 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -81,15 +81,16 @@ private: float lastLogEntry; ui::Button * scrollBar; ui::Button * searchButton; - ui::Button * reloadButton; - ui::Button * saveSimulationButton; - ui::Button * downVoteButton; - ui::Button * upVoteButton; - ui::Button * tagSimulationButton; - ui::Button * clearSimButton; - ui::Button * loginButton; - ui::Button * simulationOptionButton; - ui::Button * displayModeButton; + ui::Button * reloadButton; + ui::Button * saveSimulationButton; + bool saveSimulationButtonEnabled; + ui::Button * downVoteButton; + ui::Button * upVoteButton; + ui::Button * tagSimulationButton; + ui::Button * clearSimButton; + ui::Button * loginButton; + ui::Button * simulationOptionButton; + ui::Button * displayModeButton; ui::Button * pauseButton; ui::Point currentMouse; @@ -125,18 +126,18 @@ private: void enableAltBehaviour(); void disableAltBehaviour(); public: - GameView(); - virtual ~GameView(); + GameView(); + virtual ~GameView(); - //Breaks MVC, but any other way is going to be more of a mess. - ui::Point GetMousePosition(); - void SetSample(SimulationSample sample); + //Breaks MVC, but any other way is going to be more of a mess. + ui::Point GetMousePosition(); + void SetSample(SimulationSample sample); void SetHudEnable(bool hudState); bool GetHudEnable(); void SetDebugHUD(bool mode); bool GetDebugHUD(); - bool CtrlBehaviour(){ return ctrlBehaviour; } - bool ShiftBehaviour(){ return shiftBehaviour; } + bool CtrlBehaviour(){ return ctrlBehaviour; } + bool ShiftBehaviour(){ return shiftBehaviour; } void ExitPrompt(); SelectMode GetSelectMode() { return selectMode; } void BeginStampSelection(); diff --git a/src/gui/tags/TagsView.cpp b/src/gui/tags/TagsView.cpp index 1cef7be8f..e3812d168 100644 --- a/src/gui/tags/TagsView.cpp +++ b/src/gui/tags/TagsView.cpp @@ -56,9 +56,13 @@ TagsView::TagsView(): addButton->SetActionCallback(new AddTagAction(this)); AddComponent(addButton); - title = new ui::Label(ui::Point(5, 5), ui::Point(185, 16), "Manage tags: \bgTags are only to \nbe used to improve search results"); + if (!Client::Ref().GetAuthUser().ID) + addButton->Enabled = false; + + title = new ui::Label(ui::Point(5, 5), ui::Point(185, 28), "Manage tags: \bgTags are only to \nbe used to improve search results"); title->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; title->Appearance.VerticalAlign = ui::Appearance::AlignTop; + title->SetMultiline(true); AddComponent(title); }