-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JADE: Add character generation name menu
- Loading branch information
1 parent
f14f853
commit 9d8f7a0
Showing
3 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* 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 | ||
* Character generation name menu. | ||
*/ | ||
|
||
#include "src/aurora/talkman.h" | ||
|
||
#include "src/events/events.h" | ||
|
||
#include "src/engines/jade/gui/chargen/charactername.h" | ||
|
||
#include "src/engines/odyssey/widget.h" | ||
|
||
namespace Engines { | ||
|
||
namespace Jade { | ||
|
||
CharacterName::CharacterName(CharacterGeneration &chargen, CharacterInfo &charInfo) : | ||
CharacterGenerationBase(chargen, charInfo) { | ||
load("keyboard"); | ||
|
||
_labelText = getLabel("LabelText"); | ||
} | ||
|
||
void CharacterName::callbackActive(Widget &widget) { | ||
if (widget.getTag() == "ButtonDefault") { | ||
_charInfo.setName(_charInfo.getDefaultName()); | ||
updateName(); | ||
return; | ||
} | ||
|
||
if (widget.getTag() == "ButtonBack") { | ||
_charInfo.setName(_charInfo.getDefaultName()); | ||
_chargen.showSelection(); | ||
|
||
EventMan.enableTextInput(false); | ||
EventMan.enableKeyRepeat(false); | ||
|
||
return; | ||
} | ||
|
||
if (widget.getTag() == "ButtonDone") { | ||
_chargen.showSummary(); | ||
|
||
EventMan.enableTextInput(false); | ||
EventMan.enableKeyRepeat(false); | ||
|
||
return; | ||
} | ||
|
||
if (widget.getTag() == "bClear") { | ||
_charInfo.setName(""); | ||
updateName(); | ||
|
||
return; | ||
} | ||
} | ||
|
||
void CharacterName::initWidget(Widget &widget) { | ||
if (widget.getTag() == "TitleLabel") | ||
reinterpret_cast<Odyssey::WidgetLabel &>(widget).setText(TalkMan.getString(301)); | ||
} | ||
|
||
void CharacterName::updateName() { | ||
_labelText->setText(_charInfo.getName() + "_"); | ||
} | ||
|
||
void CharacterName::show() { | ||
updateName(); | ||
|
||
EventMan.enableTextInput(true); | ||
EventMan.enableKeyRepeat(true); | ||
|
||
GUI::show(); | ||
} | ||
|
||
void CharacterName::callbackTextInput(const Common::UString &text) { | ||
if (_charInfo.getName().size() >= 20) | ||
return; | ||
|
||
_charInfo.setName(_charInfo.getName() + text); | ||
updateName(); | ||
} | ||
|
||
void CharacterName::callbackKeyInput(const Events::Key &key, const Events::EventType &type) { | ||
if (key == Events::kKeyBackspace && type == Events::kEventKeyDown) { | ||
Common::UString name = _charInfo.getName(); | ||
if (!name.empty()) { | ||
name.erase(--name.end()); | ||
_charInfo.setName(name); | ||
updateName(); | ||
} | ||
} | ||
} | ||
|
||
} // End of namespace Jade | ||
|
||
} // End of namespace Engines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* 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 | ||
* Character generation name menu. | ||
*/ | ||
|
||
#ifndef ENGINES_JADE_GUI_CHARGEN_CHARACTERNAME_H | ||
#define ENGINES_JADE_GUI_CHARGEN_CHARACTERNAME_H | ||
|
||
#include "src/engines/jade/gui/gui.h" | ||
#include "src/engines/jade/gui/chargen/charactergenerationbase.h" | ||
|
||
#include "src/engines/odyssey/label.h" | ||
|
||
namespace Engines { | ||
|
||
namespace Jade { | ||
|
||
class CharacterName : public CharacterGenerationBase { | ||
public: | ||
CharacterName(CharacterGeneration &chargen, CharacterInfo &charInfo); | ||
|
||
void show() override; | ||
|
||
protected: | ||
void callbackActive(Widget &widget) override; | ||
void callbackTextInput(const Common::UString &text) override; | ||
void callbackKeyInput(const Events::Key &key, const Events::EventType &type) override; | ||
|
||
void initWidget(Widget &widget) override; | ||
|
||
private: | ||
void updateName(); | ||
|
||
Odyssey::WidgetLabel *_labelText; | ||
}; | ||
|
||
} // End of namespace Jade | ||
|
||
} // End of namespace Engines | ||
|
||
#endif // ENGINES_JADE_GUI_CHARGEN_CHARACTERNAME_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters