Correct save reloading, add Vac and NGrav tools

This commit is contained in:
Simon Robertshaw 2012-06-12 15:37:46 +01:00
parent f6f83cc276
commit 6f814528fc
6 changed files with 40 additions and 4 deletions

View File

@ -612,7 +612,7 @@ void GameController::ReloadSim()
{ {
if(gameModel->GetSave() && gameModel->GetSave()->GetGameSave()) if(gameModel->GetSave() && gameModel->GetSave()->GetGameSave())
{ {
gameModel->GetSimulation()->Load(gameModel->GetSave()->GetGameSave()); gameModel->SetSave(gameModel->GetSave());
} }
} }

View File

@ -78,6 +78,7 @@ public:
void SetActiveMenu(Menu * menu); void SetActiveMenu(Menu * menu);
void SetActiveTool(int toolSelection, Tool * tool); void SetActiveTool(int toolSelection, Tool * tool);
void SetColour(ui::Colour colour); void SetColour(ui::Colour colour);
void SetToolStrength(float value);
void OpenSearch(); void OpenSearch();
void OpenLogin(); void OpenLogin();
void OpenTags(); void OpenTags();

View File

@ -281,13 +281,13 @@ SaveInfo * GameModel::GetSave()
void GameModel::SetSave(SaveInfo * newSave) void GameModel::SetSave(SaveInfo * newSave)
{ {
if(currentSave) if(currentSave != newSave)
delete currentSave; delete currentSave;
currentSave = newSave; currentSave = newSave;
if(currentSave && currentSave->GetGameSave()) if(currentSave && currentSave->GetGameSave())
{ {
GameSave * saveData = currentSave->GetGameSave(); GameSave * saveData = currentSave->GetGameSave();
SetPaused(saveData->paused); SetPaused(saveData->paused & GetPaused());
sim->gravityMode = saveData->gravityMode; sim->gravityMode = saveData->gravityMode;
sim->air->airMode = saveData->airMode; sim->air->airMode = saveData->airMode;
sim->legacy_enable = saveData->legacyEnable; sim->legacy_enable = saveData->legacyEnable;

View File

@ -9,7 +9,6 @@
#include "Graphics.h" #include "Graphics.h"
#include "Simulation.h" #include "Simulation.h"
#include "Renderer.h" #include "Renderer.h"
#include "SaveLoader.h"
SaveRenderer::SaveRenderer(){ SaveRenderer::SaveRenderer(){

View File

@ -0,0 +1,18 @@
#include "simulation/Tools.h"
#include "simulation/Simulation.h"
//#TPT-Directive ToolClass Tool_NGrv TOOL_NGRV 5
Tool_NGrv::Tool_NGrv()
{
Identifier = "DEFAULT_TOOL_NGRV";
Name = "NGRV";
Colour = PIXPACK(0xAACCFF);
Description = "Creates a short-lasting negative gravity well";
}
int Tool_NGrv::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength)
{
sim->gravmap[((y/CELL)*(XRES/CELL))+(x/CELL)] += 0.03f*strength;
return 1;
}
Tool_NGrv::~Tool_NGrv() {}

View File

@ -0,0 +1,18 @@
#include "simulation/Tools.h"
#include "simulation/Air.h"
//#TPT-Directive ToolClass Tool_Vac TOOL_VAC 2
Tool_Vac::Tool_Vac()
{
Identifier = "DEFAULT_TOOL_VAC";
Name = "VAC";
Colour = PIXPACK(0x000000);
Description = "Removes air pressure";
}
int Tool_Vac::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength)
{
sim->air->pv[y/CELL][x/CELL] -= 0.03f*strength;
return 1;
}
Tool_Vac::~Tool_Vac() {}