Merge pull request #254 from boxmein/offline-saving

Save to HDD by default when not logged in
This commit is contained in:
jacob1 2015-05-11 10:51:11 -04:00
commit 16b7f7d7bf
2 changed files with 39 additions and 17 deletions

View File

@ -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();
@ -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
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();
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");
}
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()

View File

@ -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();