Saving and loading other flags from GameSave, remove old saveloader

This commit is contained in:
Simon Robertshaw
2012-06-11 13:39:39 +01:00
parent 5eb9370fc1
commit 3205df3a21
8 changed files with 33 additions and 1824 deletions

View File

@@ -24,14 +24,14 @@ ConsoleView::ConsoleView():
};
commandField = new ui::Textbox(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "");
commandField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
commandField->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
commandField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
commandField->SetActionCallback(new CommandHighlighter(this));
AddComponent(commandField);
FocusComponent(commandField);
commandField->SetBorder(false);
}
void ConsoleView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
void ConsoleView::DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
switch(key)
{
@@ -49,6 +49,9 @@ void ConsoleView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, b
case KEY_UP:
c->PreviousCommand();
break;
default:
Window::DoKeyPress(key, character, shift, ctrl, alt);
break;
}
}

View File

@@ -27,7 +27,7 @@ class ConsoleView: public ui::Window {
public:
ConsoleView();
virtual void OnDraw();
virtual void OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
virtual void DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
void AttachController(ConsoleController * c_) { c = c_; }
void NotifyPreviousCommandsChanged(ConsoleModel * sender);
void NotifyCurrentCommandChanged(ConsoleModel * sender);

View File

@@ -11,6 +11,7 @@
#include "interface/Point.h"
#include "dialogues/ErrorMessage.h"
#include "GameModelException.h"
#include "simulation/Air.h"
using namespace std;
@@ -549,7 +550,14 @@ void GameController::OpenSaveWindow()
{
if(gameModel->GetUser().ID)
{
GameSave * gameSave = gameModel->GetSimulation()->Save();
Simulation * sim = gameModel->GetSimulation();
GameSave * gameSave = sim->Save();
gameSave->paused = gameModel->GetPaused();
gameSave->gravityMode = sim->gravityMode;
gameSave->airMode = sim->air->airMode;
gameSave->legacyEnable = sim->legacy_enable;
gameSave->waterEEnabled = sim->water_equal_test;
gameSave->gravityEnable = sim->grav->ngrav_enable;
if(!gameSave)
{
new ErrorMessage("Error", "Unable to build save.");

View File

@@ -2,6 +2,7 @@
#include "GameModel.h"
#include "GameView.h"
#include "simulation/Simulation.h"
#include "simulation/Air.h"
#include "Renderer.h"
#include "interface/Point.h"
#include "Brush.h"
@@ -283,13 +284,26 @@ void GameModel::SetSave(SaveInfo * newSave)
if(currentSave)
delete currentSave;
currentSave = newSave;
if(currentSave)
if(currentSave && currentSave->GetGameSave())
{
GameSave * saveData = currentSave->GetGameSave();
SetPaused(saveData->paused);
sim->gravityMode = saveData->gravityMode;
sim->air->airMode = saveData->airMode;
sim->legacy_enable = saveData->legacyEnable;
sim->water_equal_test = saveData->waterEEnabled;
if(saveData->gravityEnable && !sim->grav->ngrav_enable)
{
sim->grav->start_grav_async();
}
else if(!saveData->gravityEnable && sim->grav->ngrav_enable)
{
sim->grav->stop_grav_async();
}
sim->clear_sim();
sim->Load(currentSave->GetGameSave());
sim->Load(saveData);
}
notifySaveChanged();
notifyPausedChanged();
}
Simulation * GameModel::GetSimulation()

File diff suppressed because it is too large Load Diff

View File

@@ -1,27 +0,0 @@
/*
* SaveLoader.h
*
* Created on: Jan 26, 2012
* Author: Simon
*/
#ifndef SAVELOADER_H_
#define SAVELOADER_H_
#include "Simulation.h"
class SaveLoader {
public:
static int Info(unsigned char * data, int dataLength, int & width, int & height);
static int Load(unsigned char * data, int dataLength, Simulation * sim, bool replace, int x, int y);
static unsigned char * Build(int & dataLength, Simulation * sim, int orig_x0, int orig_y0, int orig_w, int orig_h);
private:
static int OPSInfo(unsigned char * data, int dataLength, int & width, int & height);
static int OPSLoad(unsigned char * data, int dataLength, Simulation * sim, bool replace, int x, int y);
static unsigned char * OPSBuild(int & dataLength, Simulation * sim, int orig_x0, int orig_y0, int orig_w, int orig_h);
static int PSVInfo(unsigned char * data, int dataLength, int & width, int & height);
static int PSVLoad(unsigned char * data, int dataLength, Simulation * sim, bool replace, int x, int y);
static unsigned char * PSVBuild(int & dataLength, Simulation * sim, int orig_x0, int orig_y0, int orig_w, int orig_h);
};
#endif /* SAVELOADER_H_ */

View File

@@ -6,7 +6,6 @@
//#include "ElementFunctions.h"
#include "Air.h"
#include "Gravity.h"
#include "SaveLoader.h"
#include "elements/Element.h"
#undef LUACONSOLE
@@ -3740,7 +3739,7 @@ killed:
goto movedone;
}
}
if (elements[t].Falldown>1 && !ngrav_enable && gravityMode==0 && parts[i].vy>fabsf(parts[i].vx))
if (elements[t].Falldown>1 && !grav->ngrav_enable && gravityMode==0 && parts[i].vy>fabsf(parts[i].vx))
{
s = 0;
// stagnant is true if FLAG_STAGNANT was set for this particle in previous frame

View File

@@ -99,7 +99,6 @@ public:
//
int gravityMode;
//int airMode;
int ngrav_enable;
int legacy_enable;
int aheat_enable;
int VINE_MODE;