xoreos  0.0.5
chargenportrait.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 
28 
29 namespace Engines {
30 
31 namespace KotOR2 {
32 
34  Engines::Console *console) :
35  CharacterGenerationBaseMenu(info, console) {
36  load("portcust_p");
37 
38  getLabel("LBL_PORTRAIT")->setFill(_info.getPortrait());
39 }
40 
42  if (widget.getTag() == "BTN_ACCEPT") {
43  accept();
45  return;
46  }
47  if (widget.getTag() == "BTN_CANCEL") {
49  return;
50  }
51 
52  if (widget.getTag() == "BTN_ARRL") {
53  // Get the current skin and face
54  Skin skin = _info.getSkin();
55  unsigned int face = _info.getFace();
56 
57  // Move them to left and go in another skin type if needed
58  if (face == 0) {
59  if (skin == kSkinA)
60  skin = kSkinH;
61  else
62  skin = Skin(skin - 1);
63 
64  if (skin == kSkinH)
65  face = 1;
66  else
67  face = 4;
68  } else {
69  face -= 1;
70  }
71 
72  // Set the new skin and face values
73  _info.setSkin(skin);
74  _info.setFace(face);
75 
76  // And then reset the portrait
77  getLabel("LBL_PORTRAIT")->setFill(_info.getPortrait());
78 
79  return;
80  }
81 
82  if (widget.getTag() == "BTN_ARRR") {
83  // Get the current skin and face
84  Skin skin = _info.getSkin();
85  unsigned int face = _info.getFace();
86 
87  // Move them to right and go in another skin type if needed
88  if (face == ((skin == kSkinH) ? 1 : 4)) {
89  if (skin == kSkinH)
90  skin = kSkinA;
91  else
92  skin = Skin(skin + 1);
93  face = 0;
94  } else {
95  face += 1;
96  }
97 
98  // Set the new skin and face values
99  _info.setSkin(skin);
100  _info.setFace(face);
101 
102  // And then reset the portrait
103  getLabel("LBL_PORTRAIT")->setFill(_info.getPortrait());
104 
105  return;
106  }
107 }
108 
109 } // End of namespace KotOR
110 
111 } // End of namespace Engines
void load(const Common::UString &resref)
Definition: gui.cpp:103
void setFill(const Common::UString &fill)
static const uint32 kReturnCodeAbort
Definition: gui.h:47
A label widget for Star Wars: Knights of the Old Republic and Jade Empire.
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
Skin getSkin() const
Get the skin type of the character.
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
The KotOR 2 character generation portrait menu.
void info(const char *s,...)
Definition: util.cpp:69
void setFace(uint8 face)
Set the face index of the character.
void setSkin(Skin)
Set the skin type of the Character.
WidgetLabel * getLabel(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:204
A widget in a GUI.
Definition: widget.h:40
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
uint8_t getFace() const
Get the current face index of the character.
CharacterGenerationPortraitMenu(CharacterGenerationInfo &info, Console *console=0)
Common::UString getPortrait() const
Get the name of the portrait of this character.