xoreos  0.0.5
video.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/util.h"
26 #include "src/common/configman.h"
27 
28 #include "src/aurora/talkman.h"
29 
30 #include "src/graphics/graphics.h"
31 
35 
39 
40 namespace Engines {
41 
42 namespace NWN {
43 
44 OptionsVideoMenu::OptionsVideoMenu(bool isMain, ::Engines::Console *console) : GUI(console) {
45  load("options_video");
46 
47  if (isMain) {
48  WidgetPanel *backdrop = new WidgetPanel(*this, "PNL_MAINMENU", "pnl_mainmenu");
49  backdrop->setPosition(0.0f, 0.0f, 100.0f);
50  addWidget(backdrop);
51  }
52 
53  // TODO: Video quality
54  getWidget("VidQualSlider", true)->setDisabled(true);
55 
56  // TODO: Sky boxes
57  Widget *skyBox = getWidget("SkyboxBox");
58  if (skyBox)
59  skyBox->setDisabled(true);
60 
61  // TODO: Environment shadows
62  getWidget("EnvShadowBox", true)->setDisabled(true);
63 
64  // TODO: Creature shadows
65  getWidget("ShadowSlider", true)->setDisabled(true);
66 
67  _resolution.reset(new OptionsResolutionMenu (isMain, _console));
68  _advanced.reset (new OptionsVideoAdvancedMenu(isMain, _console));
69 }
70 
72 }
73 
75  _gamma = WindowMan.getGamma();
76 
77  if (_gamma == 0.0f) {
78  getWidget("GammaSlider" , true)->setDisabled(true);
79  getWidget("GammaResetButton", true)->setDisabled(true);
80  } else {
81  getWidget("GammaSlider" , true)->setDisabled(false);
82  getWidget("GammaResetButton", true)->setDisabled(false);
83  }
84 
85  int gammaValue = CLIP(_gamma - 0.1f, 0.0f, 1.9f) * 10;
86 
87  getSlider("GammaSlider", true)->setState(gammaValue);
88 
89  _textureLevel = ConfigMan.getInt("texturepack", 1);
90  getSlider("TextureSlider", true)->setState(_textureLevel);
91 
93 
94  GUI::show();
95 }
96 
98  if (widget.getTag() == "GammaSlider") {
99  dynamic_cast<WidgetSlider &>(widget).setSteps(19);
100  return;
101  }
102 
103  if (widget.getTag() == "TextureSlider") {
104  dynamic_cast<WidgetSlider &>(widget).setSteps(3);
105  return;
106  }
107 }
108 
110  if ((widget.getTag() == "CancelButton") ||
111  (widget.getTag() == "XButton")) {
112 
113  revertChanges();
114  _returnCode = 1;
115  return;
116  }
117 
118  if (widget.getTag() == "OkButton") {
119 
120  adoptChanges();
121  _returnCode = 2;
122  return;
123  }
124 
125  if (widget.getTag() == "VideoModeButton") {
126  sub(*_resolution);
127  return;
128  }
129 
130  if (widget.getTag() == "AdvVideoButton") {
131  sub(*_advanced);
132  return;
133  }
134 
135  if (widget.getTag() == "GammaSlider") {
136  float gamma = dynamic_cast<WidgetSlider &>(widget).getState() / 10.0f;
137 
138  WindowMan.setGamma(gamma + 0.1f);
139  return;
140  }
141 
142  if (widget.getTag() == "GammaResetButton") {
143  WindowMan.setGamma(_gamma);
144 
145  int gammaValue = CLIP(_gamma - 0.1f, 0.0f, 1.9f) * 10;
146 
147  getSlider("GammaSlider", true)->setState(gammaValue);
148  return;
149  }
150 
151  if (widget.getTag() == "TextureSlider") {
152  _textureLevel = dynamic_cast<WidgetSlider &>(widget).getState();
153 
155  return;
156  }
157 
158  if (widget.getTag() == "ApplyButton") {
159  ConfigMan.setInt("texturepack", _textureLevel);
160  return;
161  }
162 
163 }
164 
166  getLabel("TextureQualDesc", true)->setText(TalkMan.getString(7031 + _textureLevel));
167 }
168 
170  ConfigMan.setDouble("gamma", WindowMan.getGamma(), true);
171  ConfigMan.setInt("texturepack", _textureLevel);
172 }
173 
175  WindowMan.setGamma(_gamma);
176 }
177 
178 } // End of namespace NWN
179 
180 } // End of namespace Engines
OptionsVideoMenu(bool isMain=false, ::Engines::Console *console=0)
Definition: video.cpp:44
A NWN panel widget.
Definition: panel.h:41
Widget * getWidget(const Common::UString &tag, bool vital=false)
Return a widget in the GUI.
Definition: gui.cpp:314
The global graphics manager.
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
The NWN resolution options menu.
Definition: resolution.h:39
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
The NWN video options menu.
A NWN slider widget.
The global config manager.
A NWN slider widget.
Definition: slider.h:41
virtual void setDisabled(bool disabled)
Disable/Enable the widget.
Definition: widget.cpp:154
Console * _console
Definition: gui.h:70
void show()
Show the GUI.
Definition: video.cpp:74
virtual void show()
Show the GUI.
Definition: gui.cpp:62
WidgetLabel * getLabel(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:270
#define ConfigMan
Shortcut for accessing the config manager.
Definition: configman.h:176
A NWN GUI.
Definition: gui.h:54
Utility templates and functions.
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
The NWN resolution options menu.
WidgetSlider * getSlider(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:282
uint32 sub(GUI &gui, uint32 startCode=kStartCodeNone, bool showSelf=true, bool hideSelf=true)
Open up a sub GUI.
Definition: gui.cpp:349
void load(const Common::UString &resref)
Definition: gui.cpp:77
The NWN advanced video options menu.
#define WindowMan
Shortcut for accessing the window manager.
Definition: windowman.h:137
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: video.cpp:109
A widget in a GUI.
Definition: widget.h:40
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: modelwidget.cpp:71
The global talk manager for Aurora strings.
void setState(int state)
Definition: slider.cpp:69
Common::ScopedPtr< GUI > _resolution
Definition: video.h:49
void initWidget(Widget &widget)
Definition: video.cpp:97
void addWidget(Widget *widget)
Add a widget.
Definition: gui.cpp:250
T CLIP(T v, T amin, T amax)
Definition: util.h:72
A NWN panel widget.
A NWN label widget.
Common::ScopedPtr< GUI > _advanced
Definition: video.h:50
void setText(const Common::UString &text)
Definition: label.cpp:67
The NWN advanced video options menu.
Definition: videoadv.h:35