mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-08 23:10:44 +02:00
Saving and loading other flags from GameSave, remove old saveloader
This commit is contained in:
@@ -24,14 +24,14 @@ ConsoleView::ConsoleView():
|
|||||||
};
|
};
|
||||||
commandField = new ui::Textbox(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "");
|
commandField = new ui::Textbox(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "");
|
||||||
commandField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
commandField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||||
commandField->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
|
commandField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||||
commandField->SetActionCallback(new CommandHighlighter(this));
|
commandField->SetActionCallback(new CommandHighlighter(this));
|
||||||
AddComponent(commandField);
|
AddComponent(commandField);
|
||||||
FocusComponent(commandField);
|
FocusComponent(commandField);
|
||||||
commandField->SetBorder(false);
|
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)
|
switch(key)
|
||||||
{
|
{
|
||||||
@@ -49,6 +49,9 @@ void ConsoleView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, b
|
|||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
c->PreviousCommand();
|
c->PreviousCommand();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
Window::DoKeyPress(key, character, shift, ctrl, alt);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ class ConsoleView: public ui::Window {
|
|||||||
public:
|
public:
|
||||||
ConsoleView();
|
ConsoleView();
|
||||||
virtual void OnDraw();
|
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 AttachController(ConsoleController * c_) { c = c_; }
|
||||||
void NotifyPreviousCommandsChanged(ConsoleModel * sender);
|
void NotifyPreviousCommandsChanged(ConsoleModel * sender);
|
||||||
void NotifyCurrentCommandChanged(ConsoleModel * sender);
|
void NotifyCurrentCommandChanged(ConsoleModel * sender);
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include "interface/Point.h"
|
#include "interface/Point.h"
|
||||||
#include "dialogues/ErrorMessage.h"
|
#include "dialogues/ErrorMessage.h"
|
||||||
#include "GameModelException.h"
|
#include "GameModelException.h"
|
||||||
|
#include "simulation/Air.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -549,7 +550,14 @@ void GameController::OpenSaveWindow()
|
|||||||
{
|
{
|
||||||
if(gameModel->GetUser().ID)
|
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)
|
if(!gameSave)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Error", "Unable to build save.");
|
new ErrorMessage("Error", "Unable to build save.");
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#include "GameModel.h"
|
#include "GameModel.h"
|
||||||
#include "GameView.h"
|
#include "GameView.h"
|
||||||
#include "simulation/Simulation.h"
|
#include "simulation/Simulation.h"
|
||||||
|
#include "simulation/Air.h"
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include "interface/Point.h"
|
#include "interface/Point.h"
|
||||||
#include "Brush.h"
|
#include "Brush.h"
|
||||||
@@ -283,13 +284,26 @@ void GameModel::SetSave(SaveInfo * newSave)
|
|||||||
if(currentSave)
|
if(currentSave)
|
||||||
delete currentSave;
|
delete currentSave;
|
||||||
currentSave = newSave;
|
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->clear_sim();
|
||||||
sim->Load(currentSave->GetGameSave());
|
sim->Load(saveData);
|
||||||
}
|
}
|
||||||
notifySaveChanged();
|
notifySaveChanged();
|
||||||
notifyPausedChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Simulation * GameModel::GetSimulation()
|
Simulation * GameModel::GetSimulation()
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -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_ */
|
|
@@ -6,7 +6,6 @@
|
|||||||
//#include "ElementFunctions.h"
|
//#include "ElementFunctions.h"
|
||||||
#include "Air.h"
|
#include "Air.h"
|
||||||
#include "Gravity.h"
|
#include "Gravity.h"
|
||||||
#include "SaveLoader.h"
|
|
||||||
#include "elements/Element.h"
|
#include "elements/Element.h"
|
||||||
|
|
||||||
#undef LUACONSOLE
|
#undef LUACONSOLE
|
||||||
@@ -3740,7 +3739,7 @@ killed:
|
|||||||
goto movedone;
|
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;
|
s = 0;
|
||||||
// stagnant is true if FLAG_STAGNANT was set for this particle in previous frame
|
// stagnant is true if FLAG_STAGNANT was set for this particle in previous frame
|
||||||
|
@@ -99,7 +99,6 @@ public:
|
|||||||
//
|
//
|
||||||
int gravityMode;
|
int gravityMode;
|
||||||
//int airMode;
|
//int airMode;
|
||||||
int ngrav_enable;
|
|
||||||
int legacy_enable;
|
int legacy_enable;
|
||||||
int aheat_enable;
|
int aheat_enable;
|
||||||
int VINE_MODE;
|
int VINE_MODE;
|
||||||
|
Reference in New Issue
Block a user