Reinstate inversion of inclusion of pressure when shift is held

This feature was removed temporarily in a407aba.

Whether pressure is included when saving or loading is
determined as follows:

 * load-like operations (which invoke Simulation::Load) always
   include pressure;
 * save-like operations (which invoke Simulation::Save) include
   pressure if the Simulation.IncludePressure preference node
   is true;
 * finally the state of the shift key inverts the decision.
This commit is contained in:
Tamás Bálint Misius
2019-07-16 18:32:58 +02:00
parent a407aba087
commit dbd5999d1c
6 changed files with 24 additions and 23 deletions

View File

@@ -106,7 +106,7 @@ Command Line
| ---------------------- | ------------------------------------------------ | ---------------------------------------------------- |
| `scale:SIZE` | Change window scale factor | `scale:2` |
| `kiosk` | Fullscreen mode | |
| `proxy\:SERVER[:PORT]` | Proxy server to use | `proxy\:wwwcache.lancs.ac.uk:8080` |
| `proxy:SERVER[:PORT]` | Proxy server to use | `proxy:wwwcache.lancs.ac.uk:8080` |
| `open FILE` | Opens the file as a stamp or game save | |
| `ddir DIRECTORY` | Directory used for saving stamps and preferences | |
| `ptsave:SAVEID[#NAME]` | Open online save, used by ptsave: URLs | `ptsave:2198#Destroyable_city_5_wth_metro~dima-gord` |

View File

@@ -83,6 +83,7 @@ class GameController::SearchCallback: public ControllerCallback
GameController * cc;
public:
SearchCallback(GameController * cc_) { cc = cc_; }
void ControllerExit() override
{
if(cc->search->GetLoadedSave())
@@ -90,7 +91,7 @@ public:
try
{
cc->HistorySnapshot();
cc->gameModel->SetSave(cc->search->GetLoadedSave());
cc->gameModel->SetSave(cc->search->GetLoadedSave(), cc->gameView->ShiftBehaviour());
cc->search->ReleaseLoadedSave();
}
catch(GameModelException & ex)
@@ -372,7 +373,7 @@ void GameController::PlaceSave(ui::Point position)
if (placeSave)
{
HistorySnapshot();
if (!gameModel->GetSimulation()->Load(placeSave, Client::Ref().GetPrefBool("Simulation.LoadPressure", true), position.X, position.Y))
if (!gameModel->GetSimulation()->Load(placeSave, !gameView->ShiftBehaviour(), position.X, position.Y))
{
gameModel->SetPaused(placeSave->paused | gameModel->GetPaused());
Client::Ref().MergeStampAuthorInfo(placeSave->authors);
@@ -610,7 +611,7 @@ void GameController::ToolClick(int toolSelection, ui::Point point)
ByteString GameController::StampRegion(ui::Point point1, ui::Point point2)
{
GameSave * newSave = gameModel->GetSimulation()->Save(gameModel->GetIncludePressure(), point1.X, point1.Y, point2.X, point2.Y);
GameSave * newSave = gameModel->GetSimulation()->Save(gameModel->GetIncludePressure() != gameView->ShiftBehaviour(), point1.X, point1.Y, point2.X, point2.Y);
if(newSave)
{
newSave->paused = gameModel->GetPaused();
@@ -629,7 +630,7 @@ ByteString GameController::StampRegion(ui::Point point1, ui::Point point2)
void GameController::CopyRegion(ui::Point point1, ui::Point point2)
{
GameSave * newSave = gameModel->GetSimulation()->Save(gameModel->GetIncludePressure(), point1.X, point1.Y, point2.X, point2.Y);
GameSave * newSave = gameModel->GetSimulation()->Save(gameModel->GetIncludePressure() != gameView->ShiftBehaviour(), point1.X, point1.Y, point2.X, point2.Y);
if(newSave)
{
Json::Value clipboardInfo;
@@ -1259,7 +1260,7 @@ void GameController::OpenSearch(String searchText)
void GameController::OpenLocalSaveWindow(bool asCurrent)
{
Simulation * sim = gameModel->GetSimulation();
GameSave * gameSave = sim->Save(gameModel->GetIncludePressure());
GameSave * gameSave = sim->Save(gameModel->GetIncludePressure() != gameView->ShiftBehaviour());
if(!gameSave)
{
new ErrorMessage("Error", "Unable to build save.");
@@ -1286,7 +1287,7 @@ void GameController::OpenLocalSaveWindow(bool asCurrent)
virtual ~LocalSaveCallback() {}
void FileSaved(SaveFile* file) override
{
c->gameModel->SetSaveFile(file);
c->gameModel->SetSaveFile(file, c->gameView->ShiftBehaviour());
}
};
@@ -1302,7 +1303,7 @@ void GameController::OpenLocalSaveWindow(bool asCurrent)
Client::Ref().SaveAuthorInfo(&localSaveInfo);
gameSave->authors = localSaveInfo;
gameModel->SetSaveFile(&tempSave);
gameModel->SetSaveFile(&tempSave, gameView->ShiftBehaviour());
Client::Ref().MakeDirectory(LOCAL_SAVE_DIR);
std::vector<char> saveData = gameSave->Serialise();
if (saveData.size() == 0)
@@ -1317,13 +1318,13 @@ void GameController::OpenLocalSaveWindow(bool asCurrent)
void GameController::LoadSaveFile(SaveFile * file)
{
gameModel->SetSaveFile(file);
gameModel->SetSaveFile(file, gameView->ShiftBehaviour());
}
void GameController::LoadSave(SaveInfo * save)
{
gameModel->SetSave(save);
gameModel->SetSave(save, gameView->ShiftBehaviour());
}
void GameController::OpenSavePreview(int saveID, int saveDate, bool instant)
@@ -1478,7 +1479,7 @@ void GameController::OpenSaveWindow()
if(gameModel->GetUser().UserID)
{
Simulation * sim = gameModel->GetSimulation();
GameSave * gameSave = sim->Save(gameModel->GetIncludePressure());
GameSave * gameSave = sim->Save(gameModel->GetIncludePressure() != gameView->ShiftBehaviour());
if(!gameSave)
{
new ErrorMessage("Error", "Unable to build save.");
@@ -1525,7 +1526,7 @@ void GameController::SaveAsCurrent()
if(gameModel->GetSave() && gameModel->GetUser().UserID && gameModel->GetUser().Username == gameModel->GetSave()->GetUserName())
{
Simulation * sim = gameModel->GetSimulation();
GameSave * gameSave = sim->Save(gameModel->GetIncludePressure());
GameSave * gameSave = sim->Save(gameModel->GetIncludePressure() != gameView->ShiftBehaviour());
if(!gameSave)
{
new ErrorMessage("Error", "Unable to build save.");
@@ -1587,7 +1588,7 @@ void GameController::ChangeBrush()
void GameController::ClearSim()
{
HistorySnapshot();
gameModel->SetSave(NULL);
gameModel->SetSave(NULL, false);
gameModel->ClearSimulation();
}
@@ -1614,12 +1615,12 @@ void GameController::ReloadSim()
if(gameModel->GetSave() && gameModel->GetSave()->GetGameSave())
{
HistorySnapshot();
gameModel->SetSave(gameModel->GetSave());
gameModel->SetSave(gameModel->GetSave(), gameView->ShiftBehaviour());
}
else if(gameModel->GetSaveFile() && gameModel->GetSaveFile()->GetGameSave())
{
HistorySnapshot();
gameModel->SetSaveFile(gameModel->GetSaveFile());
gameModel->SetSaveFile(gameModel->GetSaveFile(), gameView->ShiftBehaviour());
}
}

View File

@@ -635,7 +635,7 @@ SaveInfo * GameModel::GetSave()
return currentSave;
}
void GameModel::SetSave(SaveInfo * newSave)
void GameModel::SetSave(SaveInfo * newSave, bool invertIncludePressure)
{
if(currentSave != newSave)
{
@@ -664,7 +664,7 @@ void GameModel::SetSave(SaveInfo * newSave)
sim->grav->stop_grav_async();
sim->clear_sim();
ren->ClearAccumulation();
if (!sim->Load(saveData, GetIncludePressure()))
if (!sim->Load(saveData, !invertIncludePressure))
{
// This save was created before logging existed
// Add in the correct info
@@ -696,7 +696,7 @@ SaveFile * GameModel::GetSaveFile()
return currentFile;
}
void GameModel::SetSaveFile(SaveFile * newSave)
void GameModel::SetSaveFile(SaveFile * newSave, bool invertIncludePressure)
{
if(currentFile != newSave)
{
@@ -729,7 +729,7 @@ void GameModel::SetSaveFile(SaveFile * newSave)
}
sim->clear_sim();
ren->ClearAccumulation();
if (!sim->Load(saveData, GetIncludePressure()))
if (!sim->Load(saveData, !invertIncludePressure))
{
Client::Ref().OverwriteAuthorInfo(saveData->authors);
}

View File

@@ -162,8 +162,8 @@ public:
void SetVote(int direction);
SaveInfo * GetSave();
SaveFile * GetSaveFile();
void SetSave(SaveInfo * newSave);
void SetSaveFile(SaveFile * newSave);
void SetSave(SaveInfo * newSave, bool invertIncludePressure);
void SetSaveFile(SaveFile * newSave, bool invertIncludePressure);
void AddObserver(GameView * observer);
bool GetPaused();

View File

@@ -410,7 +410,7 @@ OptionsView::OptionsView():
includePressure = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Include Pressure", "");
autowidth(includePressure);
includePressure->SetActionCallback(new IncludePressureAction(this));
tempLabel = new ui::Label(ui::Point(includePressure->Position.X+Graphics::textwidth(includePressure->GetText())+20, currentY), ui::Point(1, 16), "\bg- When saving, loading, stamping, etc.");
tempLabel = new ui::Label(ui::Point(includePressure->Position.X+Graphics::textwidth(includePressure->GetText())+20, currentY), ui::Point(1, 16), "\bg- When saving, copying, stamping, etc.");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;

View File

@@ -1681,7 +1681,7 @@ int LuaScriptInterface::simulation_loadStamp(lua_State * l)
if (tempfile)
{
if (!luacon_sim->Load(tempfile->GetGameSave(), luacon_model->GetIncludePressure(), x, y))
if (!luacon_sim->Load(tempfile->GetGameSave(), !luacon_controller->GetView()->ShiftBehaviour(), x, y))
{
//luacon_sim->sys_pause = (tempfile->GetGameSave()->paused | luacon_model->GetPaused())?1:0;
lua_pushinteger(l, 1);