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