/
OptionsController.cpp
111 lines (91 loc) · 2.1 KB
/
OptionsController.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "OptionsController.h"
#include "gui/dialogues/ErrorMessage.h"
OptionsController::OptionsController(GameModel * gModel_, ControllerCallback * callback_):
callback(callback_),
gModel(gModel_),
HasExited(false)
{
view = new OptionsView();
model = new OptionsModel(gModel);
model->AddObserver(view);
view->AttachController(this);
}
void OptionsController::SetHeatSimulation(bool state)
{
model->SetHeatSimulation(state);
}
void OptionsController::SetAmbientHeatSimulation(bool state)
{
model->SetAmbientHeatSimulation(state);
}
void OptionsController::SetNewtonianGravity(bool state)
{
model->SetNewtonianGravity(state);
}
void OptionsController::SetWaterEqualisation(bool state)
{
model->SetWaterEqualisation(state);
}
void OptionsController::SetGravityMode(int gravityMode)
{
model->SetGravityMode(gravityMode);
}
void OptionsController::SetAirMode(int airMode)
{
model->SetAirMode(airMode);
}
void OptionsController::SetEdgeMode(int edgeMode)
{
model->SetEdgeMode(edgeMode);
}
void OptionsController::SetFullscreen(bool fullscreen)
{
model->SetFullscreen(fullscreen);
}
void OptionsController::SetShowAvatars(bool showAvatars)
{
model->SetShowAvatars(showAvatars);
}
void OptionsController::SetScale(bool scale)
{
if(scale)
{
if(ui::Engine::Ref().GetMaxWidth() >= ui::Engine::Ref().GetWidth() * 2 && ui::Engine::Ref().GetMaxHeight() >= ui::Engine::Ref().GetHeight() * 2)
model->SetScale(scale);
else
{
new ErrorMessage("Screen resolution error", "Your screen size is too small to use this scale mode.");
model->SetScale(false);
}
}
else
model->SetScale(scale);
}
void OptionsController::SetFastQuit(bool fastquit)
{
model->SetFastQuit(fastquit);
}
OptionsView * OptionsController::GetView()
{
return view;
}
void OptionsController::Exit()
{
if(ui::Engine::Ref().GetWindow() == view)
{
ui::Engine::Ref().CloseWindow();
}
if(callback)
callback->ControllerExit();
HasExited = true;
}
OptionsController::~OptionsController() {
if(ui::Engine::Ref().GetWindow() == view)
{
ui::Engine::Ref().CloseWindow();
}
delete model;
delete view;
if(callback)
delete callback;
}