xoreos  0.0.5
gameplay.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 
26 #include "src/common/util.h"
27 #include "src/common/configman.h"
28 
29 #include "src/aurora/talkman.h"
30 
37 
38 namespace Engines {
39 
40 namespace KotOR {
41 
43  load("optgameplay");
44 
46 
49 
50  // Hardcoded, the gui file returns 1.0, 1.0, 1.0, 1.0
51  getButton("BTN_DIFFLEFT", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
52  getButton("BTN_DIFFLEFT", true)->setStaticHighlight();
53  getButton("BTN_DIFFRIGHT", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
54  getButton("BTN_DIFFRIGHT", true)->setStaticHighlight();
55  getCheckBox("CB_LEVELUP", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
56  getCheckBox("CB_INVERTCAM", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
57  getCheckBox("CB_AUTOSAVE", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
58  getCheckBox("CB_REVERSE", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
59  getCheckBox("CB_DISABLEMOVE", true)->setColor(0.0f, 0.658824f, 0.980392f, 1.0f);
60 
61  readConfig();
62 }
63 
65 }
66 
68  readConfig();
69  displayConfig();
70 
71  GUI::show();
72 }
73 
75 
76  if (widget.getTag() == "BTN_DIFFRIGHT") {
77  _difficulty++;
78  if (_difficulty > 2) {
79  _difficulty = 2;
80  }
82  return;
83  }
84 
85  if (widget.getTag() == "BTN_DIFFLEFT") {
86  _difficulty--;
87  if (_difficulty < 0) {
88  _difficulty = 0;
89  }
91  return;
92  }
93 
94  if (widget.getTag() == "BTN_MOUSE") {
95  adoptChanges();
97  return;
98  }
99 
100  if (widget.getTag() == "BTN_KEYMAP") {
101  adoptChanges();
103  return;
104  }
105 
106  if (widget.getTag() == "BTN_DEFAULT") {
107  setDefault();
108  displayConfig();
109  }
110 
111  if (widget.getTag() == "BTN_BACK") {
112  adoptChanges();
113  _returnCode = 1;
114  return;
115  }
116 
117  if (widget.getTag() == "CB_LEVELUP") {
118  _autoLevelUp = getCheckBoxState("CB_LEVELUP");
119  return;
120  }
121 
122  if (widget.getTag() == "CB_INVERTCAM") {
123  _mouseMove = getCheckBoxState("CB_INVERTCAM");
124  return;
125  }
126 
127  if (widget.getTag() == "CB_AUTOSAVE") {
128  _autoSave = getCheckBoxState("CB_AUTOSAVE");
129  return;
130  }
131 
132  if (widget.getTag() == "CB_REVERSE") {
133  _reverseMinigameY = getCheckBoxState("CB_REVERSE");
134  return;
135  }
136 
137  if (widget.getTag() == "CB_DISABLEMOVE") {
138  _combatMovement = getCheckBoxState("CB_DISABLEMOVE");
139  return;
140  }
141 }
142 
144  _difficulty = ConfigMan.getDefaultInt("difficulty");
145 
146  _autoLevelUp = ConfigMan.getDefaultBool("autolevelup");
147  _mouseMove = ConfigMan.getDefaultBool("mousemove");
148  _autoSave = ConfigMan.getDefaultBool("autosave");
149  _reverseMinigameY = ConfigMan.getDefaultBool("reverseminigameyaxis");
150  _combatMovement = ConfigMan.getDefaultBool("combatmovement");
151 }
152 
154  _difficulty = CLIP(ConfigMan.getInt("difficulty"), 0, 2);
155 
156  _autoLevelUp = ConfigMan.getBool("autolevelup");
157  _mouseMove = ConfigMan.getBool("mousemove");
158  _autoSave = ConfigMan.getBool("autosave");
159  _reverseMinigameY = ConfigMan.getBool("reverseminigameyaxis");
160  _combatMovement = ConfigMan.getBool("combatmovement");
161 }
162 
165 
166  setCheckBoxState("CB_LEVELUP", _autoLevelUp);
167  setCheckBoxState("CB_INVERTCAM", _mouseMove);
168  setCheckBoxState("CB_AUTOSAVE", _autoSave);
169  setCheckBoxState("CB_REVERSE", _reverseMinigameY);
170  setCheckBoxState("CB_DISABLEMOVE", _combatMovement);
171 }
172 
174  WidgetButton &diffButton = *getButton("BTN_DIFFICULTY", true);
175  WidgetButton &leftButton = *getButton("BTN_DIFFLEFT", true);
176  WidgetButton &rightButton = *getButton("BTN_DIFFRIGHT", true);
177 
178  diffButton.setText(TalkMan.getString(42335 + difficulty));
179 
180  if (_difficulty == 0) {
181  leftButton.hide();
182  } else {
183  leftButton.show();
184  }
185 
186  if (_difficulty == 2) {
187  rightButton.hide();
188  } else {
189  rightButton.show();
190  }
191 }
192 
194  ConfigMan.setInt("difficulty", _difficulty, true);
195  ConfigMan.setBool("autolevelup", _autoLevelUp, true);
196  ConfigMan.setBool("mousemove", _mouseMove, true);
197  ConfigMan.setBool("autosave", _autoSave, true);
198  ConfigMan.setBool("reverseminigameyaxis", _reverseMinigameY, true);
199  ConfigMan.setBool("combatmovement", _combatMovement, true);
200 }
201 
202 } // End of namespace KotOR
203 
204 } // End of namespace Engines
void load(const Common::UString &resref)
Definition: gui.cpp:103
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.
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.
virtual void show()
Show the GUI.
Definition: gameplay.cpp:67
Console * _console
Definition: gui.h:70
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: gameplay.cpp:74
Common::ScopedPtr< GUI > _keyboardconfiguration
Definition: gameplay.h:55
bool getCheckBoxState(const Common::UString &tag)
Definition: gui.cpp:312
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
Utility templates and functions.
virtual void show()
Show the widget.
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
uint32 sub(GUI &gui, uint32 startCode=kStartCodeNone, bool showSelf=true, bool hideSelf=true)
Open up a sub GUI.
Definition: gui.cpp:349
void addBackground(const Common::UString &background, bool front=false)
Definition: gui.cpp:300
virtual void show()
Show the GUI.
Definition: gui.cpp:69
The mouse settings menu.
A widget in a GUI.
A widget in a GUI.
Definition: widget.h:40
The gameplay menu.
OptionsGameplayMenu(::Engines::Console *console=0)
Definition: gameplay.cpp:42
The global talk manager for Aurora strings.
void setColor(float r, float g, float b, float a)
void updateDifficulty(int difficulty)
Definition: gameplay.cpp:173
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
The keyboard mapping menu.
T CLIP(T v, T amin, T amax)
Definition: util.h:72
void setCheckBoxState(const Common::UString &tag, bool state)
Definition: gui.cpp:307
Common::ScopedPtr< GUI > _mousesettings
Definition: gameplay.h:54