xoreos  0.0.5
game.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 
34 
38 
39 namespace Engines {
40 
41 namespace NWN {
42 
43 OptionsGameMenu::OptionsGameMenu(bool isMain, ::Engines::Console *console) : GUI(console) {
44  load("options_game");
45 
46  if (isMain) {
47  WidgetPanel *backdrop = new WidgetPanel(*this, "PNL_MAINMENU", "pnl_mainmenu");
48  backdrop->setPosition(0.0f, 0.0f, 100.0f);
49  addWidget(backdrop);
50  }
51 
52  std::list<Widget *> hideTiles;
53  hideTiles.push_back(getWidget("NeverBox"));
54  hideTiles.push_back(getWidget("AutoBox"));
55  hideTiles.push_back(getWidget("AlwaysBox"));
56  declareGroup(hideTiles);
57 
58  // TODO: Hide second story tiles setting
59  getWidget("NeverBox" , true)->setDisabled(true);
60  getWidget("AutoBox" , true)->setDisabled(true);
61  getWidget("AlwaysBox", true)->setDisabled(true);
62 
63  // TODO: Violence level
64  getWidget("ViolenceSlider", true)->setDisabled(true);
65 
66  _gorepass.reset(new OptionsGorePasswordMenu(isMain, _console));
67  _feedback.reset(new OptionsFeedbackMenu (isMain, _console));
68 }
69 
71 }
72 
74  _difficulty = CLIP(ConfigMan.getInt("difficulty", 0), 0, 2);
75 
76  getSlider("DiffSlider", true)->setState(_difficulty);
77 
79 
80  GUI::show();
81 }
82 
84  if (tag == "DiffEdit")
85  type = kWidgetTypeListBox;
86 }
87 
89  if (widget.getTag() == "DiffSlider") {
90  dynamic_cast<WidgetSlider &>(widget).setSteps(3);
91  return;
92  }
93 
94  if (widget.getTag() == "DiffEdit") {
95  dynamic_cast<WidgetListBox &>(widget).setMode(WidgetListBox::kModeStatic);
96  return;
97  }
98 }
99 
101  if ((widget.getTag() == "CancelButton") ||
102  (widget.getTag() == "XButton")) {
103 
104  revertChanges();
105  _returnCode = 1;
106  return;
107  }
108 
109  if (widget.getTag() == "OkButton") {
110 
111  adoptChanges();
112  _returnCode = 2;
113  return;
114  }
115 
116  if (widget.getTag() == "PasswordButton") {
117  sub(*_gorepass);
118  return;
119  }
120 
121  if (widget.getTag() == "FeedbackButton") {
122  sub(*_feedback);
123  return;
124  }
125 
126  if (widget.getTag() == "DiffSlider") {
127  updateDifficulty(dynamic_cast<WidgetSlider &>(widget).getState());
128  return;
129  }
130 }
131 
132 void OptionsGameMenu::updateDifficulty(int difficulty) {
133  WidgetLabel &diffLabel = *getLabel("DifficultyLabel", true);
134  WidgetListBox &diffDesc = *getListBox("DiffEdit", true);
135 
136  diffDesc.setText("fnt_galahad14", TalkMan.getString(67578 + difficulty), 1.0f);
137 
138  if (difficulty == 0)
139  diffLabel.setText(TalkMan.getString(66786));
140  else if (difficulty == 1)
141  diffLabel.setText(TalkMan.getString(66788));
142  else if (difficulty == 2)
143  diffLabel.setText(TalkMan.getString(66790));
144  else if (difficulty == 3)
145  diffLabel.setText(TalkMan.getString(66792));
146 }
147 
148 
150  ConfigMan.setInt("difficulty", getSlider("DiffSlider", true)->getState(), true);
151 }
152 
154 }
155 
156 } // End of namespace NWN
157 
158 } // End of namespace Engines
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
Common::ScopedPtr< GUI > _feedback
Definition: game.h:54
#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
WidgetListBox * getListBox(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:318
A NWN slider widget.
The global config manager.
The NWN game options menu.
OptionsGameMenu(bool isMain=false, ::Engines::Console *console=0)
Definition: game.cpp:43
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
The NWN violence/gore password options menu.
void declareGroup(const std::list< Widget *> &group)
Put these widgets together into a group.
Definition: gui.cpp:340
void show()
Show the GUI.
Definition: game.cpp:73
A NWN listbox widget.
void setText(const Common::UString &font, const Common::UString &text, float spacing=0.0f)
Definition: listbox.cpp:523
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
void initWidget(Widget &widget)
Definition: game.cpp:88
WidgetSlider * getSlider(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:282
void fixWidgetType(const Common::UString &tag, WidgetType &type)
Definition: game.cpp:83
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
A NWN listbox widget.
Definition: listbox.h:116
Common::ScopedPtr< GUI > _gorepass
Definition: game.h:53
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: game.cpp:100
A NWN label widget.
Definition: label.h:41
void updateDifficulty(int difficulty)
Definition: game.cpp:132
The NWN feedback options menu.
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.
The NWN violence/gore password options menu.
Definition: gorepass.h:35
void setState(int state)
Definition: slider.cpp:69
The NWN feedback options menu.
Definition: feedback.h:35
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.
void setText(const Common::UString &text)
Definition: label.cpp:67