diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 30236162b..b5ba18265 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), @@ -223,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); @@ -258,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(); @@ -412,7 +413,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 +472,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,14 +866,19 @@ void GameView::NotifyUserChanged(GameModel * sender) loginButton->SetText("[sign in]"); ((SplitButton*)loginButton)->SetShowSplit(false); ((SplitButton*)loginButton)->SetRightToolTip("Sign in to simulation server"); + + loggedIn = false; } else { loginButton->SetText(sender->GetUser().Username); ((SplitButton*)loginButton)->SetShowSplit(true); ((SplitButton*)loginButton)->SetRightToolTip("Edit profile"); + + loggedIn = true; } - saveSimulationButtonEnabled = sender->GetUser().ID; + // saveSimulationButtonEnabled = sender->GetUser().ID; + saveSimulationButtonEnabled = true; NotifySaveChanged(sender); } @@ -920,11 +926,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); } @@ -1919,20 +1927,32 @@ 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); - searchButton->SetToolTip("Open a simulation from your hard drive"); + + 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); if(isMouseDown || (toolBrush && drawMode == DrawPoints)) @@ -1960,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) @@ -1972,12 +1992,12 @@ 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 - ((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 d67a5addc..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; @@ -121,6 +122,7 @@ private: void enableShiftBehaviour(); void disableShiftBehaviour(); void enableCtrlBehaviour(); + void enableCtrlBehaviour(bool isHighlighted); void disableCtrlBehaviour(); void enableAltBehaviour(); void disableAltBehaviour();