hold shift when saving or loading stamps to not save / load pressure, closes #491
This commit is contained in:
parent
99c568f136
commit
6931f35520
@ -327,13 +327,13 @@ std::string GameController::GetSignText(int signID)
|
|||||||
return gameModel->GetSimulation()->signs[signID].text;
|
return gameModel->GetSimulation()->signs[signID].text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::PlaceSave(ui::Point position)
|
void GameController::PlaceSave(ui::Point position, bool includePressure)
|
||||||
{
|
{
|
||||||
GameSave *placeSave = gameModel->GetPlaceSave();
|
GameSave *placeSave = gameModel->GetPlaceSave();
|
||||||
if (placeSave)
|
if (placeSave)
|
||||||
{
|
{
|
||||||
HistorySnapshot();
|
HistorySnapshot();
|
||||||
if (!gameModel->GetSimulation()->Load(position.X, position.Y, placeSave))
|
if (!gameModel->GetSimulation()->Load(position.X, position.Y, placeSave, includePressure))
|
||||||
{
|
{
|
||||||
gameModel->SetPaused(placeSave->paused | gameModel->GetPaused());
|
gameModel->SetPaused(placeSave->paused | gameModel->GetPaused());
|
||||||
Client::Ref().MergeStampAuthorInfo(placeSave->authors);
|
Client::Ref().MergeStampAuthorInfo(placeSave->authors);
|
||||||
@ -567,10 +567,10 @@ void GameController::ToolClick(int toolSelection, ui::Point point)
|
|||||||
activeTool->Click(sim, cBrush, point);
|
activeTool->Click(sim, cBrush, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GameController::StampRegion(ui::Point point1, ui::Point point2)
|
std::string GameController::StampRegion(ui::Point point1, ui::Point point2, bool includePressure)
|
||||||
{
|
{
|
||||||
GameSave * newSave;
|
GameSave * newSave;
|
||||||
newSave = gameModel->GetSimulation()->Save(point1.X, point1.Y, point2.X, point2.Y);
|
newSave = gameModel->GetSimulation()->Save(point1.X, point1.Y, point2.X, point2.Y, includePressure);
|
||||||
if(newSave)
|
if(newSave)
|
||||||
{
|
{
|
||||||
newSave->paused = gameModel->GetPaused();
|
newSave->paused = gameModel->GetPaused();
|
||||||
@ -586,10 +586,10 @@ std::string GameController::StampRegion(ui::Point point1, ui::Point point2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::CopyRegion(ui::Point point1, ui::Point point2)
|
void GameController::CopyRegion(ui::Point point1, ui::Point point2, bool includePressure)
|
||||||
{
|
{
|
||||||
GameSave * newSave;
|
GameSave * newSave;
|
||||||
newSave = gameModel->GetSimulation()->Save(point1.X, point1.Y, point2.X, point2.Y);
|
newSave = gameModel->GetSimulation()->Save(point1.X, point1.Y, point2.X, point2.Y, includePressure);
|
||||||
if(newSave)
|
if(newSave)
|
||||||
{
|
{
|
||||||
Json::Value clipboardInfo;
|
Json::Value clipboardInfo;
|
||||||
@ -604,9 +604,9 @@ void GameController::CopyRegion(ui::Point point1, ui::Point point2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::CutRegion(ui::Point point1, ui::Point point2)
|
void GameController::CutRegion(ui::Point point1, ui::Point point2, bool includePressure)
|
||||||
{
|
{
|
||||||
CopyRegion(point1, point2);
|
CopyRegion(point1, point2, includePressure);
|
||||||
gameModel->GetSimulation()->clear_area(point1.X, point1.Y, point2.X-point1.X, point2.Y-point1.Y);
|
gameModel->GetSimulation()->clear_area(point1.X, point1.Y, point2.X-point1.X, point2.Y-point1.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,9 +89,9 @@ public:
|
|||||||
void DrawRect(int toolSelection, ui::Point point1, ui::Point point2);
|
void DrawRect(int toolSelection, ui::Point point1, ui::Point point2);
|
||||||
void DrawLine(int toolSelection, ui::Point point1, ui::Point point2);
|
void DrawLine(int toolSelection, ui::Point point1, ui::Point point2);
|
||||||
void DrawFill(int toolSelection, ui::Point point);
|
void DrawFill(int toolSelection, ui::Point point);
|
||||||
std::string StampRegion(ui::Point point1, ui::Point point2);
|
std::string StampRegion(ui::Point point1, ui::Point point2, bool includePressure);
|
||||||
void CopyRegion(ui::Point point1, ui::Point point2);
|
void CopyRegion(ui::Point point1, ui::Point point2, bool includePressure);
|
||||||
void CutRegion(ui::Point point1, ui::Point point2);
|
void CutRegion(ui::Point point1, ui::Point point2, bool includePressure);
|
||||||
void Update();
|
void Update();
|
||||||
void SetPaused(bool pauseState);
|
void SetPaused(bool pauseState);
|
||||||
void SetPaused();
|
void SetPaused();
|
||||||
@ -133,7 +133,7 @@ public:
|
|||||||
void OpenStamps();
|
void OpenStamps();
|
||||||
void OpenElementSearch();
|
void OpenElementSearch();
|
||||||
void OpenColourPicker();
|
void OpenColourPicker();
|
||||||
void PlaceSave(ui::Point position);
|
void PlaceSave(ui::Point position, bool includePressure);
|
||||||
void ClearSim();
|
void ClearSim();
|
||||||
void ReloadSim();
|
void ReloadSim();
|
||||||
void Vote(int direction);
|
void Vote(int direction);
|
||||||
|
@ -1253,7 +1253,7 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
|
|||||||
if (thumbY+(placeSaveThumb->Height) >= YRES)
|
if (thumbY+(placeSaveThumb->Height) >= YRES)
|
||||||
thumbY = YRES-placeSaveThumb->Height;
|
thumbY = YRES-placeSaveThumb->Height;
|
||||||
|
|
||||||
c->PlaceSave(ui::Point(thumbX, thumbY));
|
c->PlaceSave(ui::Point(thumbX, thumbY), !shiftBehaviour);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1263,11 +1263,11 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
|
|||||||
int x1 = (selectPoint2.X<selectPoint1.X) ? selectPoint2.X : selectPoint1.X;
|
int x1 = (selectPoint2.X<selectPoint1.X) ? selectPoint2.X : selectPoint1.X;
|
||||||
int y1 = (selectPoint2.Y<selectPoint1.Y) ? selectPoint2.Y : selectPoint1.Y;
|
int y1 = (selectPoint2.Y<selectPoint1.Y) ? selectPoint2.Y : selectPoint1.Y;
|
||||||
if (selectMode ==SelectCopy)
|
if (selectMode ==SelectCopy)
|
||||||
c->CopyRegion(ui::Point(x1, y1), ui::Point(x2, y2));
|
c->CopyRegion(ui::Point(x1, y1), ui::Point(x2, y2), !shiftBehaviour);
|
||||||
else if (selectMode == SelectCut)
|
else if (selectMode == SelectCut)
|
||||||
c->CutRegion(ui::Point(x1, y1), ui::Point(x2, y2));
|
c->CutRegion(ui::Point(x1, y1), ui::Point(x2, y2), !shiftBehaviour);
|
||||||
else if (selectMode == SelectStamp)
|
else if (selectMode == SelectStamp)
|
||||||
c->StampRegion(ui::Point(x1, y1), ui::Point(x2, y2));
|
c->StampRegion(ui::Point(x1, y1), ui::Point(x2, y2), !shiftBehaviour);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selectMode = SelectNone;
|
selectMode = SelectNone;
|
||||||
|
@ -1680,17 +1680,19 @@ int LuaScriptInterface::simulation_saveStamp(lua_State * l)
|
|||||||
int y = luaL_optint(l,2,0);
|
int y = luaL_optint(l,2,0);
|
||||||
int w = luaL_optint(l,3,XRES-1);
|
int w = luaL_optint(l,3,XRES-1);
|
||||||
int h = luaL_optint(l,4,YRES-1);
|
int h = luaL_optint(l,4,YRES-1);
|
||||||
std::string name = luacon_controller->StampRegion(ui::Point(x, y), ui::Point(x+w, y+h));
|
int includePressure = luaL_optint(l,5,1);
|
||||||
|
std::string name = luacon_controller->StampRegion(ui::Point(x, y), ui::Point(x+w, y+h), includePressure);
|
||||||
lua_pushstring(l, name.c_str());
|
lua_pushstring(l, name.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaScriptInterface::simulation_loadStamp(lua_State * l)
|
int LuaScriptInterface::simulation_loadStamp(lua_State * l)
|
||||||
{
|
{
|
||||||
int i = -1, x, y;
|
int i = -1;
|
||||||
SaveFile * tempfile = NULL;
|
SaveFile * tempfile = NULL;
|
||||||
x = luaL_optint(l,2,0);
|
int x = luaL_optint(l,2,0);
|
||||||
y = luaL_optint(l,3,0);
|
int y = luaL_optint(l,3,0);
|
||||||
|
int includePressure = luaL_optint(l,4,1);
|
||||||
if (lua_isstring(l, 1)) //Load from 10 char name, or full filename
|
if (lua_isstring(l, 1)) //Load from 10 char name, or full filename
|
||||||
{
|
{
|
||||||
const char * filename = luaL_optstring(l, 1, "");
|
const char * filename = luaL_optstring(l, 1, "");
|
||||||
@ -1707,7 +1709,7 @@ int LuaScriptInterface::simulation_loadStamp(lua_State * l)
|
|||||||
|
|
||||||
if (tempfile)
|
if (tempfile)
|
||||||
{
|
{
|
||||||
if (!luacon_sim->Load(x, y, tempfile->GetGameSave()))
|
if (!luacon_sim->Load(x, y, tempfile->GetGameSave(), includePressure))
|
||||||
{
|
{
|
||||||
//luacon_sim->sys_pause = (tempfile->GetGameSave()->paused | luacon_model->GetPaused())?1:0;
|
//luacon_sim->sys_pause = (tempfile->GetGameSave()->paused | luacon_model->GetPaused())?1:0;
|
||||||
lua_pushinteger(l, 1);
|
lua_pushinteger(l, 1);
|
||||||
|
@ -26,12 +26,12 @@
|
|||||||
#include "lua/LuaScriptHelper.h"
|
#include "lua/LuaScriptHelper.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int Simulation::Load(GameSave * save)
|
int Simulation::Load(GameSave * save, bool includePressure)
|
||||||
{
|
{
|
||||||
return Load(0, 0, save);
|
return Load(0, 0, save, includePressure);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Simulation::Load(int fullX, int fullY, GameSave * save)
|
int Simulation::Load(int fullX, int fullY, GameSave * save, bool includePressure)
|
||||||
{
|
{
|
||||||
int blockX, blockY, x, y, r;
|
int blockX, blockY, x, y, r;
|
||||||
|
|
||||||
@ -207,11 +207,14 @@ int Simulation::Load(int fullX, int fullY, GameSave * save)
|
|||||||
fvx[saveBlockY+blockY][saveBlockX+blockX] = save->fanVelX[saveBlockY][saveBlockX];
|
fvx[saveBlockY+blockY][saveBlockX+blockX] = save->fanVelX[saveBlockY][saveBlockX];
|
||||||
fvy[saveBlockY+blockY][saveBlockX+blockX] = save->fanVelY[saveBlockY][saveBlockX];
|
fvy[saveBlockY+blockY][saveBlockX+blockX] = save->fanVelY[saveBlockY][saveBlockX];
|
||||||
}
|
}
|
||||||
pv[saveBlockY+blockY][saveBlockX+blockX] = save->pressure[saveBlockY][saveBlockX];
|
if (includePressure)
|
||||||
vx[saveBlockY+blockY][saveBlockX+blockX] = save->velocityX[saveBlockY][saveBlockX];
|
{
|
||||||
vy[saveBlockY+blockY][saveBlockX+blockX] = save->velocityY[saveBlockY][saveBlockX];
|
pv[saveBlockY+blockY][saveBlockX+blockX] = save->pressure[saveBlockY][saveBlockX];
|
||||||
if (save->hasAmbientHeat)
|
vx[saveBlockY+blockY][saveBlockX+blockX] = save->velocityX[saveBlockY][saveBlockX];
|
||||||
hv[saveBlockY+blockY][saveBlockX+blockX] = save->ambientHeat[saveBlockY][saveBlockX];
|
vy[saveBlockY+blockY][saveBlockX+blockX] = save->velocityY[saveBlockY][saveBlockX];
|
||||||
|
if (save->hasAmbientHeat)
|
||||||
|
hv[saveBlockY+blockY][saveBlockX+blockX] = save->ambientHeat[saveBlockY][saveBlockX];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,12 +224,12 @@ int Simulation::Load(int fullX, int fullY, GameSave * save)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameSave * Simulation::Save()
|
GameSave * Simulation::Save(bool includePressure)
|
||||||
{
|
{
|
||||||
return Save(0, 0, XRES-1, YRES-1);
|
return Save(0, 0, XRES-1, YRES-1, includePressure);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2)
|
GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2, bool includePressure)
|
||||||
{
|
{
|
||||||
int blockX, blockY, blockX2, blockY2, blockW, blockH;
|
int blockX, blockY, blockX2, blockY2, blockW, blockH;
|
||||||
//Normalise incoming coords
|
//Normalise incoming coords
|
||||||
@ -310,11 +313,14 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2)
|
|||||||
newSave->fanVelX[saveBlockY][saveBlockX] = fvx[saveBlockY+blockY][saveBlockX+blockX];
|
newSave->fanVelX[saveBlockY][saveBlockX] = fvx[saveBlockY+blockY][saveBlockX+blockX];
|
||||||
newSave->fanVelY[saveBlockY][saveBlockX] = fvy[saveBlockY+blockY][saveBlockX+blockX];
|
newSave->fanVelY[saveBlockY][saveBlockX] = fvy[saveBlockY+blockY][saveBlockX+blockX];
|
||||||
}
|
}
|
||||||
newSave->pressure[saveBlockY][saveBlockX] = pv[saveBlockY+blockY][saveBlockX+blockX];
|
if (includePressure)
|
||||||
newSave->velocityX[saveBlockY][saveBlockX] = vx[saveBlockY+blockY][saveBlockX+blockX];
|
{
|
||||||
newSave->velocityY[saveBlockY][saveBlockX] = vy[saveBlockY+blockY][saveBlockX+blockX];
|
newSave->pressure[saveBlockY][saveBlockX] = pv[saveBlockY+blockY][saveBlockX+blockX];
|
||||||
newSave->ambientHeat[saveBlockY][saveBlockX] = hv[saveBlockY+blockY][saveBlockX+blockX];
|
newSave->velocityX[saveBlockY][saveBlockX] = vx[saveBlockY+blockY][saveBlockX+blockX];
|
||||||
newSave->hasAmbientHeat = true;
|
newSave->velocityY[saveBlockY][saveBlockX] = vy[saveBlockY+blockY][saveBlockX+blockX];
|
||||||
|
newSave->ambientHeat[saveBlockY][saveBlockX] = hv[saveBlockY+blockY][saveBlockX+blockX];
|
||||||
|
newSave->hasAmbientHeat = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,10 +114,10 @@ public:
|
|||||||
int sandcolour;
|
int sandcolour;
|
||||||
int sandcolour_frame;
|
int sandcolour_frame;
|
||||||
|
|
||||||
int Load(GameSave * save);
|
int Load(GameSave * save, bool includePressure = true);
|
||||||
int Load(int x, int y, GameSave * save);
|
int Load(int x, int y, GameSave * save, bool includePressure = true);
|
||||||
GameSave * Save();
|
GameSave * Save(bool includePressure = true);
|
||||||
GameSave * Save(int x1, int y1, int x2, int y2);
|
GameSave * Save(int x1, int y1, int x2, int y2, bool includePressure = true);
|
||||||
void SaveSimOptions(GameSave * gameSave);
|
void SaveSimOptions(GameSave * gameSave);
|
||||||
SimulationSample GetSample(int x, int y);
|
SimulationSample GetSample(int x, int y);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user