From 56d04fcde8afb01cadc4077330b0859ccf567a29 Mon Sep 17 00:00:00 2001 From: boxmein Date: Fri, 1 May 2015 14:44:22 +0300 Subject: [PATCH 1/4] add new form of enableCtrlBehaviour for un-highlighted HDD saving --- src/gui/game/GameView.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index d67a5addc..63726a9c1 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -121,6 +121,7 @@ private: void enableShiftBehaviour(); void disableShiftBehaviour(); void enableCtrlBehaviour(); + void enableCtrlBehaviour(bool isHighlighted); void disableCtrlBehaviour(); void enableAltBehaviour(); void disableAltBehaviour(); From bf001dfd7723430e03a472a984bbb68dfc61faaf Mon Sep 17 00:00:00 2001 From: boxmein Date: Fri, 1 May 2015 14:44:51 +0300 Subject: [PATCH 2/4] enable Ctrl behaviour (eg sae to HDD) without highlighting --- src/gui/game/GameView.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 30236162b..54b6132ac 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -412,7 +412,7 @@ GameView::GameView(): }; pauseButton = new ui::Button(ui::Point(Size.X-16, Size.Y-16), ui::Point(15, 15), "", "Pause/Resume the simulation"); //Pause pauseButton->SetIcon(IconPause); - pauseButton->SetTogglable(true); + pauseButton->SetTogglable(true); pauseButton->SetActionCallback(new PauseAction(this)); AddComponent(pauseButton); @@ -471,9 +471,9 @@ public: int menuID; bool needsClick; MenuAction(GameView * _v, int menuID_) - { + { v = _v; - menuID = menuID_; + menuID = menuID_; if (menuID == SC_DECO) needsClick = true; else @@ -865,6 +865,7 @@ void GameView::NotifyUserChanged(GameModel * sender) loginButton->SetText("[sign in]"); ((SplitButton*)loginButton)->SetShowSplit(false); ((SplitButton*)loginButton)->SetRightToolTip("Sign in to simulation server"); + enableCtrlBehaviour(); } else { @@ -1919,19 +1920,31 @@ void GameView::disableAltBehaviour() } } -void GameView::enableCtrlBehaviour() +void GameView::enableCtrlBehaviour() { + // "Usual" Ctrl-holding behavior uses highlights + enableCtrlBehaviour(true); +} + +void GameView::enableCtrlBehaviour(bool isHighlighted) { if(!ctrlBehaviour) { ctrlBehaviour = true; //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); + if (isHighlighted) { + 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; SetSaveButtonTooltips(); - searchButton->Appearance.BackgroundInactive = searchButton->Appearance.BackgroundHover = ui::Colour(255, 255, 255); - searchButton->Appearance.TextInactive = searchButton->Appearance.TextHover = ui::Colour(0, 0, 0); + + if (isHighlighted) { + searchButton->Appearance.BackgroundInactive = searchButton->Appearance.BackgroundHover = ui::Colour(255, 255, 255); + searchButton->Appearance.TextInactive = searchButton->Appearance.TextHover = ui::Colour(0, 0, 0); + } + searchButton->SetToolTip("Open a simulation from your hard drive"); if (currentSaveType == 2) ((SplitButton*)saveSimulationButton)->SetShowSplit(true); From 424d1d4b473ee7167670db84d4febfc7bda10472 Mon Sep 17 00:00:00 2001 From: boxmein Date: Fri, 1 May 2015 14:45:38 +0300 Subject: [PATCH 3/4] when you're not logged in, displys a not-highlighted HDD save button --- src/gui/game/GameView.cpp | 10 ++++++++-- src/gui/game/GameView.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 54b6132ac..750eeb14f 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -157,6 +157,7 @@ GameView::GameView(): drawSnap(false), shiftBehaviour(false), ctrlBehaviour(false), + loggedIn(false), altBehaviour(false), showHud(true), showDebug(false), @@ -865,13 +866,16 @@ void GameView::NotifyUserChanged(GameModel * sender) loginButton->SetText("[sign in]"); ((SplitButton*)loginButton)->SetShowSplit(false); ((SplitButton*)loginButton)->SetRightToolTip("Sign in to simulation server"); - enableCtrlBehaviour(); + + loggedIn = false; } else { loginButton->SetText(sender->GetUser().Username); ((SplitButton*)loginButton)->SetShowSplit(true); ((SplitButton*)loginButton)->SetRightToolTip("Edit profile"); + + loggedIn = true; } saveSimulationButtonEnabled = sender->GetUser().ID; NotifySaveChanged(sender); @@ -921,11 +925,13 @@ void GameView::NotifySaveChanged(GameModel * sender) if (sender->GetUser().ID) { + loggedIn = true; upVoteButton->Appearance.BorderDisabled = upVoteButton->Appearance.BorderInactive; downVoteButton->Appearance.BorderDisabled = downVoteButton->Appearance.BorderInactive; } else { + loggedIn = false; upVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100); downVoteButton->Appearance.BorderDisabled = ui::Colour(100, 100, 100); } @@ -1990,7 +1996,7 @@ void GameView::SetSaveButtonTooltips() else if (((SplitButton*)saveSimulationButton)->GetShowSplit()) ((SplitButton*)saveSimulationButton)->SetToolTips("Reupload the current simulation", "Modify simulation properties"); else - ((SplitButton*)saveSimulationButton)->SetToolTips("Reupload the current simulation", "Upload a new simulation"); + ((SplitButton*)saveSimulationButton)->SetToolTips("Reupload the current simulation", "Upload a new simulation. Hold Ctrl to save offline."); } void GameView::OnDraw() diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index 63726a9c1..7724df97e 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -40,6 +40,7 @@ private: bool drawSnap; bool shiftBehaviour; bool ctrlBehaviour; + bool loggedIn; bool altBehaviour; bool showHud; bool showDebug; From 7145cacbb922254b1d3523bfe262895d34a85f5f Mon Sep 17 00:00:00 2001 From: boxmein Date: Fri, 1 May 2015 15:53:52 +0300 Subject: [PATCH 4/4] implement HDD saving by default in GameView. update tooltips to describe behaviour. --- src/gui/game/GameView.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 750eeb14f..b5ba18265 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -224,7 +224,7 @@ GameView::GameView(): scrollBar->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; AddComponent(scrollBar); - searchButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(17, 15), "", "Find & open a simulation"); //Open + searchButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(17, 15), "", "Find & open a simulation. Hold Ctrl to load offline saves."); //Open searchButton->SetIcon(IconOpen); currentX+=18; searchButton->SetTogglable(false); @@ -259,14 +259,14 @@ GameView::GameView(): SaveSimulationAction(GameView * _v) { v = _v; } void ActionCallbackRight(ui::Button * sender) { - if(v->CtrlBehaviour()) + if(v->CtrlBehaviour() || !v->loggedIn) v->c->OpenLocalSaveWindow(false); else v->c->OpenSaveWindow(); } void ActionCallbackLeft(ui::Button * sender) { - if(v->CtrlBehaviour()) + if(v->CtrlBehaviour() || !v->loggedIn) v->c->OpenLocalSaveWindow(true); else v->c->SaveAsCurrent(); @@ -877,7 +877,8 @@ void GameView::NotifyUserChanged(GameModel * sender) loggedIn = true; } - saveSimulationButtonEnabled = sender->GetUser().ID; + // saveSimulationButtonEnabled = sender->GetUser().ID; + saveSimulationButtonEnabled = true; NotifySaveChanged(sender); } @@ -1951,7 +1952,7 @@ void GameView::enableCtrlBehaviour(bool isHighlighted) searchButton->Appearance.TextInactive = searchButton->Appearance.TextHover = ui::Colour(0, 0, 0); } - searchButton->SetToolTip("Open a simulation from your hard drive"); + searchButton->SetToolTip("Open a simulation from your hard drive."); if (currentSaveType == 2) ((SplitButton*)saveSimulationButton)->SetShowSplit(true); if(isMouseDown || (toolBrush && drawMode == DrawPoints)) @@ -1979,7 +1980,7 @@ void GameView::disableCtrlBehaviour() 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); - searchButton->SetToolTip("Find & open a simulation"); + searchButton->SetToolTip("Find & open a simulation. Hold Ctrl to load offline saves."); if (currentSaveType == 2) ((SplitButton*)saveSimulationButton)->SetShowSplit(false); if(!shiftBehaviour) @@ -1991,8 +1992,8 @@ void GameView::disableCtrlBehaviour() void GameView::SetSaveButtonTooltips() { - if (ctrlBehaviour) - ((SplitButton*)saveSimulationButton)->SetToolTips("Save the simulation to your hard drive", "Save the simulation to your hard drive"); + if (ctrlBehaviour || !loggedIn) + ((SplitButton*)saveSimulationButton)->SetToolTips("Save the simulation to your hard drive. Login to save online.", "Save the simulation to your hard drive. Login to save online."); else if (((SplitButton*)saveSimulationButton)->GetShowSplit()) ((SplitButton*)saveSimulationButton)->SetToolTips("Reupload the current simulation", "Modify simulation properties"); else