Skip to content

Commit

Permalink
KOTOR: Add a menu to change the portrait
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed Jun 26, 2017
1 parent 2532959 commit 8d53801
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 0 deletions.
112 changes: 112 additions & 0 deletions src/engines/kotor/gui/chargen/chargenportrait.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* xoreos is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* xoreos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xoreos. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* The menu for modifying the portrait of the.
*/

#include "src/engines/kotor/gui/widgets/kotorwidget.h"
#include "src/engines/kotor/gui/widgets/button.h"
#include "src/engines/kotor/gui/widgets/label.h"

#include "src/engines/kotor/gui/chargen/chargenportrait.h"
#include "src/engines/kotor/gui/chargen/chargeninfo.h"

namespace Engines {

namespace KotOR {

CharacterGenerationPortraitMenu::CharacterGenerationPortraitMenu(CharacterGenerationInfo &info,
Console *console) : CharacterGenerationBaseMenu(info, console) {

load("portcust");

addBackground(kBackgroundTypeMenu);

getLabel("LBL_PORTRAIT")->setFill(_info.getPortrait());
}

void CharacterGenerationPortraitMenu::callbackActive(Widget &widget) {
if (widget.getTag() == "BTN_BACK") {
_returnCode = 1;
return;
}
if (widget.getTag() == "BTN_ACCEPT") {
accept();
_returnCode = 1;
return;
}

if (widget.getTag() == "BTN_ARRL") {
// Get the current skin and face
Skin skin = _info.getSkin();
uint8_t face = _info.getFace();

// Move them to left and go in another skin type if needed
if (face == 0) {
if (skin == kSkinA)
skin = kSkinC;
else
skin = Skin(skin - 1);
face = 4;
} else {
face -= 1;
}

// Set the new skin and face values
_info.setSkin(skin);
_info.setFace(face);

// And then reset the portrait
getLabel("LBL_PORTRAIT")->setFill(_info.getPortrait());

return;
}

if (widget.getTag() == "BTN_ARRR") {
// Get the current skin and face
Skin skin = _info.getSkin();
uint8_t face = _info.getFace();

// Move them to right and go in another skin type if needed
if (face == 4) {
if (skin == kSkinC)
skin = kSkinA;
else
skin = Skin(skin + 1);
face = 0;
} else {
face += 1;
}

// Set the new skin and face values
_info.setSkin(skin);
_info.setFace(face);

// And then reset the portrait
getLabel("LBL_PORTRAIT")->setFill(_info.getPortrait());

return;
}
}

} // End of namespace KotOR

} // End of namespace Engines
50 changes: 50 additions & 0 deletions src/engines/kotor/gui/chargen/chargenportrait.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* xoreos is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* xoreos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xoreos. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* The menu for modifying the portrait of the.
*/

#ifndef ENGINES_KOTOR_GUI_CHARGEN_CHARGENPOTRAIT_H
#define ENGINES_KOTOR_GUI_CHARGEN_CHARGENPOTRAIT_H

#include "src/engines/kotor/gui/gui.h"

#include "src/engines/kotor/gui/chargen/chargenbase.h"

namespace Engines {

namespace KotOR {

class CharacterGenerationInfo;

class CharacterGenerationPortraitMenu : public CharacterGenerationBaseMenu {
public:
CharacterGenerationPortraitMenu(CharacterGenerationInfo &chargen, ::Engines::Console *console = 0);

private:
void callbackActive(Widget &widget);
};

} // End of namespace KotOR

} // End of namespace Engines

#endif // ENGINES_KOTOR_GUI_CHARGEN_CHARGENPOTRAIT_H
2 changes: 2 additions & 0 deletions src/engines/kotor/gui/chargen/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ src_engines_kotor_libkotor_la_SOURCES += \
src/engines/kotor/gui/chargen/customchar.h \
src/engines/kotor/gui/chargen/chargeninfo.h \
src/engines/kotor/gui/chargen/chargenbase.h \
src/engines/kotor/gui/chargen/chargenportrait.h \
$(EMPTY)

src_engines_kotor_libkotor_la_SOURCES += \
Expand All @@ -37,4 +38,5 @@ src_engines_kotor_libkotor_la_SOURCES += \
src/engines/kotor/gui/chargen/customchar.cpp \
src/engines/kotor/gui/chargen/chargeninfo.cpp \
src/engines/kotor/gui/chargen/chargenbase.cpp \
src/engines/kotor/gui/chargen/chargenportrait.cpp \
$(EMPTY)

0 comments on commit 8d53801

Please sign in to comment.