xoreos  0.0.5
yesnocancel.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/engines/aurora/gui.h"
26 
29 
31 
32 namespace Engines {
33 
34 namespace NWN {
35 
37  const Common::UString &no, const Common::UString &cancel,
38  ::Engines::Console *console) : GUI(console),
39  _msg(msg), _yes(yes), _no(no), _cancel(cancel) {
40 
41  load("yesnocancelpanel");
42 }
43 
45 }
46 
48  if (widget.getTag() == "MessageLabel") {
49  dynamic_cast<WidgetLabel &>(widget).setText(_msg);
50  }
51 
52  if (widget.getTag() == "YesButton") {
53  if (!_yes.empty())
54  dynamic_cast<WidgetLabel &>(widget).setText(_yes);
55  return;
56  }
57 
58  if (widget.getTag() == "NoButton") {
59  if (!_no.empty())
60  dynamic_cast<WidgetLabel &>(widget).setText(_no);
61  return;
62  }
63 
64  if (widget.getTag() == "CancelButton") {
65  if (!_cancel.empty())
66  dynamic_cast<WidgetLabel &>(widget).setText(_cancel);
67  return;
68  }
69 }
70 
72  // Center the message
73  WidgetLabel &msg = *getLabel("MessageLabel", true);
74  WidgetPanel &pnl = *getPanel("PNL_OK" , true);
75 
76  float pX, pY, pZ;
77  pnl.getPosition(pX, pY, pZ);
78 
79  msg.setPosition(pX - msg.getWidth() / 2.0f, pY - msg.getHeight() / 2.0f, pZ);
80 
81  GUI::show();
82 }
83 
85  if (widget.getTag() == "YesButton") {
86  _returnCode = 1;
87  return;
88  }
89 
90  if (widget.getTag() == "NoButton") {
91  _returnCode = 2;
92  return;
93  }
94 
95  if (widget.getTag() == "CancelButton") {
96  _returnCode = 3;
97  return;
98  }
99 
100 }
101 
102 } // End of namespace NWN
103 
104 } // End of namespace Engines
A NWN panel widget.
Definition: panel.h:41
void initWidget(Widget &widget)
Definition: yesnocancel.cpp:47
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
A class holding an UTF-8 string.
Definition: ustring.h:48
virtual void getPosition(float &x, float &y, float &z) const
Get the widget&#39;s position.
Definition: widget.cpp:140
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
The yes/no/cancel dialog.
A GUI.
virtual void show()
Show the GUI.
Definition: gui.cpp:62
WidgetLabel * getLabel(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:270
A NWN GUI.
Definition: gui.h:54
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
WidgetPanel * getPanel(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:258
void load(const Common::UString &resref)
Definition: gui.cpp:77
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
A NWN label widget.
Definition: label.h:41
float getHeight() const
Get the widget&#39;s height.
Definition: label.cpp:88
A widget in a GUI.
Definition: widget.h:40
void show()
Show the GUI.
Definition: yesnocancel.cpp:71
float getWidth() const
Get the widget&#39;s width.
Definition: label.cpp:84
YesNoCancelDialog(const Common::UString &msg, const Common::UString &yes="", const Common::UString &no="", const Common::UString &cancel="", ::Engines::Console *console=0)
Definition: yesnocancel.cpp:36
A NWN panel widget.
A NWN label widget.
void setText(const Common::UString &text)
Definition: label.cpp:67
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: yesnocancel.cpp:84