xoreos  0.0.5
videoadv.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/maths.h"
27 #include "src/common/configman.h"
28 
29 #include "src/aurora/talkman.h"
30 
31 #include "src/graphics/graphics.h"
32 
37 
39 
40 namespace Engines {
41 
42 namespace NWN {
43 
45  load("options_adv_vid");
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: Grass
54  getWidget("GrassSlider", true)->setDisabled(true);
55 
56  // TODO: Creature wind
57  getWidget("CreatureWind", true)->setDisabled(true);
58 
59  // TODO: Dynamic lights
60  getWidget("LightSlider", true)->setDisabled(true);
61 
62  // TODO: Shadow casting lights
63  getWidget("ShadowLights", true)->setDisabled(true);
64 
65  // TODO: Texture animations
66  getWidget("TexAnimButton", true)->setDisabled(true);
67 
68  // TODO: Environment mapping on creatures
69  getWidget("EnvMappingButton", true)->setDisabled(true);
70 
71  // TODO: High visual effects
72  getWidget("VisEffectsBox", true)->setDisabled(true);
73 
74  // TODO: Shiny water
75  getWidget("ShinyWaterBox", true)->setDisabled(true);
76 
77  // TODO: Use vsync
78  getWidget("VsyncBox", true)->setDisabled(true);
79 }
80 
82 }
83 
85  _oldFSAA = MAX(GfxMan.getCurrentFSAA(), 0);
86  _fsaa = _oldFSAA;
87 
88  int fsaa = _oldFSAA;
89  if (fsaa > 0)
90  fsaa = MAX(0, Common::intLog2(fsaa));
91 
92  getSlider("AntiAliasSlider", true)->setState(fsaa);
93 
94  updateFSAALabel(fsaa);
95 
96  WidgetCheckBox *largeFonts = getCheckBox("UseLargeFont");
97  if (largeFonts)
98  largeFonts->setState(ConfigMan.getBool("largefonts"));
99 
100  GUI::show();
101 }
102 
104  if (tag == "CreatureWind")
105  type = kWidgetTypeSlider;
106 }
107 
109  if (widget.getTag() == "AntiAliasSlider") {
110  int maxFSAA = WindowMan.getMaxFSAA();
111 
112  if (maxFSAA <= 0)
113  // No antialiasing available
114  dynamic_cast<WidgetSlider &>(widget).setDisabled(true);
115  else
116  dynamic_cast<WidgetSlider &>(widget).setSteps(MAX(0, Common::intLog2(maxFSAA)));
117 
118  return;
119  }
120 }
121 
123  if ((widget.getTag() == "CancelButton") ||
124  (widget.getTag() == "XButton")) {
125 
126  revertChanges();
127  _returnCode = 1;
128  return;
129  }
130 
131  if (widget.getTag() == "OkButton") {
132 
133  adoptChanges();
134  _returnCode = 2;
135  return;
136  }
137 
138  if (widget.getTag() == "AntiAliasSlider") {
139  _fsaa = dynamic_cast<WidgetSlider &>(widget).getState();
140 
142  if (_fsaa > 0)
143  _fsaa = 1 << _fsaa;
144 
145  return;
146  }
147 }
148 
150  Common::UString text;
151  if (n == 0)
152  text = TalkMan.getString(67539);
153  else if (n == 1)
154  text = TalkMan.getString(67540);
155  else if (n == 2)
156  text = TalkMan.getString(67542);
157  else
158  text = Common::UString::format("%dx %s", 1 << n, TalkMan.getString(67538).c_str());
159 
160  getLabel("AntialiasLabel", true)->setText(text);
161 }
162 
164  if (_fsaa != _oldFSAA) {
165  GfxMan.setFSAA(_fsaa);
166  ConfigMan.setInt("antialiasing", _fsaa, true);
167  }
168 
169  WidgetCheckBox *largeFonts = getCheckBox("UseLargeFont");
170  if (largeFonts)
171  ConfigMan.setBool("largefonts", largeFonts->getState(), true);
172 }
173 
175  GfxMan.setFSAA(_oldFSAA);
176 }
177 
178 } // End of namespace NWN
179 
180 } // End of namespace Engines
A NWN panel widget.
Definition: panel.h:41
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: videoadv.cpp:122
Widget * getWidget(const Common::UString &tag, bool vital=false)
Return a widget in the GUI.
Definition: gui.cpp:314
A NWN checkbox widget.
Definition: checkbox.h:41
static int intLog2(uint32 v)
Definition: maths.h:83
The global graphics manager.
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
A class holding an UTF-8 string.
Definition: ustring.h:48
A NWN slider widget.
The global config manager.
Mathematical helpers.
A NWN slider widget.
Definition: slider.h:41
virtual void setDisabled(bool disabled)
Disable/Enable the widget.
Definition: widget.cpp:154
WidgetCheckBox * getCheckBox(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:246
A NWN checkbox widget.
void fixWidgetType(const Common::UString &tag, WidgetType &type)
Definition: videoadv.cpp:103
virtual void show()
Show the GUI.
Definition: gui.cpp:62
WidgetLabel * getLabel(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:270
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
Definition: ustring.cpp:718
#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
WidgetSlider * getSlider(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:282
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
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
void setState(bool state)
Definition: checkbox.cpp:101
void addWidget(Widget *widget)
Add a widget.
Definition: gui.cpp:250
T MAX(T a, T b)
Definition: util.h:71
A NWN panel widget.
#define GfxMan
Shortcut for accessing the graphics manager.
Definition: graphics.h:299
A NWN label widget.
OptionsVideoAdvancedMenu(bool isMain=false, ::Engines::Console *console=0)
Definition: videoadv.cpp:44
void setText(const Common::UString &text)
Definition: label.cpp:67