Better hanling of edgeMode and "New Sim" button
This commit is contained in:
parent
d6f832b4f5
commit
90ebd3e54c
@ -1023,7 +1023,7 @@ void GameController::OpenStamps()
|
|||||||
|
|
||||||
void GameController::OpenOptions()
|
void GameController::OpenOptions()
|
||||||
{
|
{
|
||||||
options = new OptionsController(gameModel->GetSimulation(), new OptionsCallback(this));
|
options = new OptionsController(gameModel, new OptionsCallback(this));
|
||||||
ui::Engine::Ref().ShowWindow(options->GetView());
|
ui::Engine::Ref().ShowWindow(options->GetView());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,8 @@ GameModel::GameModel():
|
|||||||
colour(255, 0, 0, 255),
|
colour(255, 0, 0, 255),
|
||||||
toolStrength(1.0f),
|
toolStrength(1.0f),
|
||||||
activeColourPreset(-1),
|
activeColourPreset(-1),
|
||||||
activeMenu(NULL)
|
activeMenu(NULL),
|
||||||
|
edgeMode(0)
|
||||||
{
|
{
|
||||||
sim = new Simulation();
|
sim = new Simulation();
|
||||||
ren = new Renderer(ui::Engine::Ref().g, sim);
|
ren = new Renderer(ui::Engine::Ref().g, sim);
|
||||||
@ -75,7 +76,8 @@ GameModel::GameModel():
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Load config into simulation
|
//Load config into simulation
|
||||||
sim->SetEdgeMode(Client::Ref().GetPrefInteger("Simulation.EdgeMode", 0));
|
edgeMode = Client::Ref().GetPrefInteger("Simulation.EdgeMode", 0);
|
||||||
|
sim->SetEdgeMode(edgeMode);
|
||||||
|
|
||||||
//Load last user
|
//Load last user
|
||||||
if(Client::Ref().GetAuthUser().ID)
|
if(Client::Ref().GetAuthUser().ID)
|
||||||
@ -350,6 +352,17 @@ Tool * GameModel::GetToolFromIdentifier(std::string identifier)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameModel::SetEdgeMode(int edgeMode)
|
||||||
|
{
|
||||||
|
this->edgeMode = edgeMode;
|
||||||
|
sim->SetEdgeMode(edgeMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GameModel::GetEdgeMode()
|
||||||
|
{
|
||||||
|
return this->edgeMode;
|
||||||
|
}
|
||||||
|
|
||||||
std::deque<Snapshot*> GameModel::GetHistory()
|
std::deque<Snapshot*> GameModel::GetHistory()
|
||||||
{
|
{
|
||||||
return history;
|
return history;
|
||||||
@ -512,8 +525,8 @@ void GameModel::SetSave(SaveInfo * newSave)
|
|||||||
sim->grav->start_grav_async();
|
sim->grav->start_grav_async();
|
||||||
else
|
else
|
||||||
sim->grav->stop_grav_async();
|
sim->grav->stop_grav_async();
|
||||||
sim->clear_sim();
|
|
||||||
sim->SetEdgeMode(0);
|
sim->SetEdgeMode(0);
|
||||||
|
sim->clear_sim();
|
||||||
ren->ClearAccumulation();
|
ren->ClearAccumulation();
|
||||||
sim->Load(saveData);
|
sim->Load(saveData);
|
||||||
}
|
}
|
||||||
@ -541,8 +554,8 @@ void GameModel::SetSaveFile(SaveFile * newSave)
|
|||||||
{
|
{
|
||||||
sim->grav->stop_grav_async();
|
sim->grav->stop_grav_async();
|
||||||
}
|
}
|
||||||
sim->clear_sim();
|
|
||||||
sim->SetEdgeMode(0);
|
sim->SetEdgeMode(0);
|
||||||
|
sim->clear_sim();
|
||||||
ren->ClearAccumulation();
|
ren->ClearAccumulation();
|
||||||
sim->Load(saveData);
|
sim->Load(saveData);
|
||||||
}
|
}
|
||||||
@ -733,6 +746,20 @@ void GameModel::ClearSimulation()
|
|||||||
{
|
{
|
||||||
sim->clear_sim();
|
sim->clear_sim();
|
||||||
ren->ClearAccumulation();
|
ren->ClearAccumulation();
|
||||||
|
|
||||||
|
//Load defaults
|
||||||
|
SetPaused(false);
|
||||||
|
sim->gravityMode = 0;
|
||||||
|
sim->air->airMode = 0;
|
||||||
|
sim->legacy_enable = false;
|
||||||
|
sim->water_equal_test = false;
|
||||||
|
sim->grav->stop_grav_async();
|
||||||
|
sim->SetEdgeMode(edgeMode);
|
||||||
|
sim->clear_sim();
|
||||||
|
ren->ClearAccumulation();
|
||||||
|
|
||||||
|
notifySaveChanged();
|
||||||
|
UpdateQuickOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameModel::SetStamp(GameSave * save)
|
void GameModel::SetStamp(GameSave * save)
|
||||||
|
@ -68,6 +68,8 @@ private:
|
|||||||
bool colourSelector;
|
bool colourSelector;
|
||||||
ui::Colour colour;
|
ui::Colour colour;
|
||||||
|
|
||||||
|
int edgeMode;
|
||||||
|
|
||||||
std::string infoTip;
|
std::string infoTip;
|
||||||
std::string toolTip;
|
std::string toolTip;
|
||||||
//bool zoomEnabled;
|
//bool zoomEnabled;
|
||||||
@ -100,6 +102,9 @@ public:
|
|||||||
|
|
||||||
Tool * GetToolFromIdentifier(std::string identifier);
|
Tool * GetToolFromIdentifier(std::string identifier);
|
||||||
|
|
||||||
|
void SetEdgeMode(int edgeMode);
|
||||||
|
int GetEdgeMode();
|
||||||
|
|
||||||
void SetActiveColourPreset(int preset);
|
void SetActiveColourPreset(int preset);
|
||||||
int GetActiveColourPreset();
|
int GetActiveColourPreset();
|
||||||
|
|
||||||
|
@ -8,12 +8,13 @@
|
|||||||
#include "OptionsController.h"
|
#include "OptionsController.h"
|
||||||
#include "dialogues/ErrorMessage.h"
|
#include "dialogues/ErrorMessage.h"
|
||||||
|
|
||||||
OptionsController::OptionsController(Simulation * sim, ControllerCallback * callback_):
|
OptionsController::OptionsController(GameModel * gModel_, ControllerCallback * callback_):
|
||||||
callback(callback_),
|
callback(callback_),
|
||||||
|
gModel(gModel_),
|
||||||
HasExited(false)
|
HasExited(false)
|
||||||
{
|
{
|
||||||
view = new OptionsView();
|
view = new OptionsView();
|
||||||
model = new OptionsModel(sim);
|
model = new OptionsModel(gModel);
|
||||||
model->AddObserver(view);
|
model->AddObserver(view);
|
||||||
|
|
||||||
view->AttachController(this);
|
view->AttachController(this);
|
||||||
|
@ -13,15 +13,17 @@
|
|||||||
#include "OptionsView.h"
|
#include "OptionsView.h"
|
||||||
#include "OptionsModel.h"
|
#include "OptionsModel.h"
|
||||||
|
|
||||||
|
class GameModel;
|
||||||
class OptionsModel;
|
class OptionsModel;
|
||||||
class OptionsView;
|
class OptionsView;
|
||||||
class OptionsController {
|
class OptionsController {
|
||||||
|
GameModel * gModel;
|
||||||
OptionsView * view;
|
OptionsView * view;
|
||||||
OptionsModel * model;
|
OptionsModel * model;
|
||||||
ControllerCallback * callback;
|
ControllerCallback * callback;
|
||||||
public:
|
public:
|
||||||
bool HasExited;
|
bool HasExited;
|
||||||
OptionsController(Simulation * sim, ControllerCallback * callback_);
|
OptionsController(GameModel * gModel_, ControllerCallback * callback_);
|
||||||
void SetHeatSimulation(bool state);
|
void SetHeatSimulation(bool state);
|
||||||
void SetAmbientHeatSimulation(bool state);
|
void SetAmbientHeatSimulation(bool state);
|
||||||
void SetNewtonianGravity(bool state);
|
void SetNewtonianGravity(bool state);
|
||||||
|
@ -6,10 +6,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "simulation/Air.h"
|
#include "simulation/Air.h"
|
||||||
|
#include "game/GameModel.h"
|
||||||
#include "OptionsModel.h"
|
#include "OptionsModel.h"
|
||||||
|
|
||||||
OptionsModel::OptionsModel(Simulation * sim_) {
|
OptionsModel::OptionsModel(GameModel * gModel_) {
|
||||||
sim = sim_;
|
gModel = gModel_;
|
||||||
|
sim = gModel->GetSimulation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsModel::AddObserver(OptionsView* view)
|
void OptionsModel::AddObserver(OptionsView* view)
|
||||||
@ -77,11 +79,11 @@ void OptionsModel::SetAirMode(int airMode)
|
|||||||
|
|
||||||
int OptionsModel::GetEdgeMode()
|
int OptionsModel::GetEdgeMode()
|
||||||
{
|
{
|
||||||
return sim->edgeMode;
|
return gModel->GetEdgeMode();
|
||||||
}
|
}
|
||||||
void OptionsModel::SetEdgeMode(int edgeMode)
|
void OptionsModel::SetEdgeMode(int edgeMode)
|
||||||
{
|
{
|
||||||
sim->SetEdgeMode(edgeMode);
|
gModel->SetEdgeMode(edgeMode);
|
||||||
notifySettingsChanged();
|
notifySettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,14 +11,16 @@
|
|||||||
#include "OptionsView.h"
|
#include "OptionsView.h"
|
||||||
#include "simulation/Simulation.h"
|
#include "simulation/Simulation.h"
|
||||||
|
|
||||||
|
class GameModel;
|
||||||
class Simulation;
|
class Simulation;
|
||||||
class OptionsView;
|
class OptionsView;
|
||||||
class OptionsModel {
|
class OptionsModel {
|
||||||
|
GameModel * gModel;
|
||||||
Simulation * sim;
|
Simulation * sim;
|
||||||
std::vector<OptionsView*> observers;
|
std::vector<OptionsView*> observers;
|
||||||
void notifySettingsChanged();
|
void notifySettingsChanged();
|
||||||
public:
|
public:
|
||||||
OptionsModel(Simulation * sim_);
|
OptionsModel(GameModel * gModel);
|
||||||
void AddObserver(OptionsView* view);
|
void AddObserver(OptionsView* view);
|
||||||
bool GetHeatSimulation();
|
bool GetHeatSimulation();
|
||||||
void SetHeatSimulation(bool state);
|
void SetHeatSimulation(bool state);
|
||||||
|
Loading…
Reference in New Issue
Block a user