xoreos  0.0.5
graphicsadv.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/configman.h"
26 
27 #include "src/aurora/talkman.h"
28 
30 
32 
35 
36 namespace Engines {
37 
38 namespace KotOR {
39 
41  load("optgraphicsadv");
42 
44 
45  // Hardcoded, the gui file returns incorrect values
46  getButton("BTN_TEXQUALLEFT", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
47  getButton("BTN_TEXQUALLEFT", true)->setStaticHighlight();
48  getButton("BTN_TEXQUALRIGHT", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
49  getButton("BTN_TEXQUALRIGHT", true)->setStaticHighlight();
50  getButton("BTN_ANTIALIASLEFT", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
51  getButton("BTN_ANTIALIASLEFT", true)->setStaticHighlight();
52  getButton("BTN_ANTIALIASRIGHT", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
53  getButton("BTN_ANTIALIASRIGHT", true)->setStaticHighlight();
54  getButton("BTN_ANISOTROPYLEFT", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
55  getButton("BTN_ANISOTROPYLEFT", true)->setStaticHighlight();
56  getButton("BTN_ANISOTROPYRIGHT", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
57  getButton("BTN_ANISOTROPYRIGHT", true)->setStaticHighlight();
58  getCheckBox("CB_FRAMEBUFF", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
59  getCheckBox("CB_VSYNC", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
60  getCheckBox("CB_SOFTSHADOWS", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
61 
62  readConfig();
63 }
64 
66 }
67 
69  readConfig();
70  displayConfig();
71 
72  GUI::show();
73 }
74 
76  if (widget.getTag() == "BTN_TEXQUALRIGHT") {
78  if (_textureQuality > 2) {
79  _textureQuality = 2;
80  }
82  return;
83  }
84 
85  if (widget.getTag() == "BTN_TEXQUALLEFT") {
87  if (_textureQuality < 0) {
88  _textureQuality = 0;
89  }
91  return;
92  }
93 
94  if (widget.getTag() == "BTN_ANTIALIASRIGHT") {
95  _antiAliasing++;
96  if (_antiAliasing > 3) {
97  _antiAliasing = 3;
98  }
100  return;
101  }
102 
103  if (widget.getTag() == "BTN_ANTIALIASLEFT") {
104  _antiAliasing--;
105  if (_antiAliasing < 0) {
106  _antiAliasing = 0;
107  }
109  return;
110  }
111 
112  if (widget.getTag() == "BTN_ANISOTROPYRIGHT") {
113  _anisotropy++;
114  if (_anisotropy > 4) {
115  _anisotropy = 4;
116  }
118  return;
119  }
120 
121  if (widget.getTag() == "BTN_ANISOTROPYLEFT") {
122  _anisotropy--;
123  if (_anisotropy < 0) {
124  _anisotropy = 0;
125  }
127  return;
128  }
129 
130  if (widget.getTag() == "BTN_DEFAULT") {
131  setDefault();
132  displayConfig();
133  }
134 
135  if (widget.getTag() == "BTN_CANCEL") {
136  _returnCode = 1;
137  return;
138  }
139 
140  if (widget.getTag() == "BTN_BACK") {
141  adoptChanges();
142  _returnCode = 1;
143  return;
144  }
145 
146  if (widget.getTag() == "CB_FRAMEBUFF") {
147  _frameBufferEffects = getCheckBoxState("CB_FRAMEBUFF");
148  return;
149  }
150 
151  if (widget.getTag() == "CB_SOFTSHADOWS") {
152  _softShadows = getCheckBoxState("CB_SOFTSHADOWS");
153  return;
154  }
155 
156  if (widget.getTag() == "CB_VSYNC") {
157  _vsync = getCheckBoxState("CB_VSYNC");
158  return;
159  }
160 }
161 
163  _textureQuality = ConfigMan.getDefaultInt("texturepack");
164  _antiAliasing = ConfigMan.getDefaultInt("antialiasing");
165  _anisotropy = ConfigMan.getDefaultInt("anisotropy");
166  _frameBufferEffects = ConfigMan.getDefaultBool("framebuffereffects");
167  _softShadows = ConfigMan.getDefaultBool("softshadows");
168  _vsync = ConfigMan.getDefaultBool("vsync");
169 }
170 
172  _textureQuality = CLIP(ConfigMan.getInt("texturepack"), 0, 2);
173  _antiAliasing = CLIP(ConfigMan.getInt("antialiasing"), 0, 3);
174  _anisotropy = CLIP(ConfigMan.getInt("anisotropy"), 0, 4);
175 
176  _frameBufferEffects = ConfigMan.getBool("framebuffereffects");
177  _softShadows = ConfigMan.getBool("softshadows");
178  _vsync = ConfigMan.getBool("vsync");
179 }
180 
185 
186  setCheckBoxState("CB_FRAMEBUFF", _frameBufferEffects);
187  setCheckBoxState("CB_SOFTSHADOWS", _softShadows);
188  setCheckBoxState("CB_VSYNC", _vsync);
189 }
190 
192  WidgetButton &texQualButton = *getButton("BTN_TEXQUAL", true);
193  WidgetButton &leftButton = *getButton("BTN_TEXQUALLEFT", true);
194  WidgetButton &rightButton = *getButton("BTN_TEXQUALRIGHT", true);
195 
196  texQualButton.setText(TalkMan.getString(48003 + textureQuality));
197 
198  if (_textureQuality == 0) {
199  leftButton.hide();
200  } else {
201  leftButton.show();
202  }
203 
204  if (_textureQuality == 2) {
205  rightButton.hide();
206  } else {
207  rightButton.show();
208  }
209 }
210 
212  WidgetButton &antiAliasButton = *getButton("BTN_ANTIALIAS", true);
213  WidgetButton &leftButton = *getButton("BTN_ANTIALIASLEFT", true);
214  WidgetButton &rightButton = *getButton("BTN_ANTIALIASRIGHT", true);
215 
216  Common::UString text;
217 
218  if (antiAliasing == 0)
219  text = TalkMan.getString(47996);
220  else if (antiAliasing == 1)
221  text = TalkMan.getString(47997);
222  else if (antiAliasing == 2)
223  text = TalkMan.getString(47999);
224  else if (antiAliasing == 3)
225  text = TalkMan.getString(49125);
226 
227  antiAliasButton.setText(text);
228 
229  if (_antiAliasing == 0) {
230  leftButton.hide();
231  } else {
232  leftButton.show();
233  }
234 
235  if (_antiAliasing == 3) {
236  rightButton.hide();
237  } else {
238  rightButton.show();
239  }
240 }
241 
243  WidgetButton &anisotropyButton = *getButton("BTN_ANISOTROPY", true);
244  WidgetButton &leftButton = *getButton("BTN_ANISOTROPYLEFT", true);
245  WidgetButton &rightButton = *getButton("BTN_ANISOTROPYRIGHT", true);
246 
247  anisotropyButton.setText(TalkMan.getString(49079 + anisotropy));
248 
249  if (_anisotropy == 0) {
250  leftButton.hide();
251  } else {
252  leftButton.show();
253  }
254 
255  if (_anisotropy == 4) {
256  rightButton.hide();
257  } else {
258  rightButton.show();
259  }
260 }
261 
263  ConfigMan.setInt("texturepack", _textureQuality, true);
264  ConfigMan.setInt("antialiasing", _antiAliasing, true);
265  ConfigMan.setInt("anisotropy", _anisotropy, true);
266  ConfigMan.setBool("framebuffereffects", _softShadows, true);
267  ConfigMan.setBool("softshadows", _softShadows, true);
268  ConfigMan.setBool("vsync", _vsync, true);
269 }
270 
271 } // End of namespace KotOR
272 
273 } // End of namespace Engines
void load(const Common::UString &resref)
Definition: gui.cpp:103
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: graphicsadv.cpp:75
OptionsGraphicsAdvancedMenu(::Engines::Console *console=0)
Definition: graphicsadv.cpp:40
static const Common::UString & kBackgroundTypeMenu
Definition: guibackground.h:42
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
virtual void hide()
Hide the widget.
A class holding an UTF-8 string.
Definition: ustring.h:48
The global config manager.
A button widget for Star Wars: Knights of the Old Republic and Jade Empire.
A checkbox widget for Star Wars: Knights of the Old Repulic and Jade Empire.
bool getCheckBoxState(const Common::UString &tag)
Definition: gui.cpp:312
The advanced graphics menu.
WidgetButton * getButton(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:228
#define ConfigMan
Shortcut for accessing the config manager.
Definition: configman.h:176
virtual void show()
Show the widget.
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
void updateTextureQuality(int textureQuality)
void addBackground(const Common::UString &background, bool front=false)
Definition: gui.cpp:300
virtual void show()
Show the GUI.
Definition: gui.cpp:69
A widget in a GUI.
virtual void show()
Show the GUI.
Definition: graphicsadv.cpp:68
A widget in a GUI.
Definition: widget.h:40
The global talk manager for Aurora strings.
void setColor(float r, float g, float b, float a)
WidgetCheckBox * getCheckBox(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:240
void setText(const Common::UString &text)
void setStaticHighlight()
Definition: button.cpp:69
A KotOR GUI.
Definition: gui.h:57
T CLIP(T v, T amin, T amax)
Definition: util.h:72
void setCheckBoxState(const Common::UString &tag, bool state)
Definition: gui.cpp:307