From 27efea7d495fdf755f7e94edb1f39103b6f8f072 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 14 Sep 2014 12:45:55 +0300 Subject: Move setCharCreateDialog from ea namespace into eathena and tmwa. --- src/net/tmwa/charserverhandler.cpp | 40 ++++++++++++++++++++++++++++++++++++++ src/net/tmwa/charserverhandler.h | 8 ++++++++ 2 files changed, 48 insertions(+) (limited to 'src/net/tmwa') diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 3fed3b568..b9997320a 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -44,9 +44,11 @@ #include "resources/iteminfo.h" +#include "resources/db/chardb.h" #include "resources/db/itemdb.h" #include "utils/dtor.h" +#include "utils/gettext.h" #include "debug.h" @@ -335,6 +337,44 @@ void CharServerHandler::connect() mNetwork->skip(4); } +void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window) +{ + mCharCreateDialog = window; + + if (!mCharCreateDialog) + return; + + StringVect attributes; + // TRANSLATORS: playe stat + attributes.push_back(_("Strength:")); + // TRANSLATORS: playe stat + attributes.push_back(_("Agility:")); + // TRANSLATORS: playe stat + attributes.push_back(_("Vitality:")); + // TRANSLATORS: playe stat + attributes.push_back(_("Intelligence:")); + // TRANSLATORS: playe stat + attributes.push_back(_("Dexterity:")); + // TRANSLATORS: playe stat + attributes.push_back(_("Luck:")); + + const Token &token = + static_cast(Net::getLoginHandler())->getToken(); + + int minStat = CharDB::getMinStat(); + if (!minStat) + minStat = 1; + int maxStat = CharDB::getMaxStat(); + if (!maxStat) + maxStat = 9; + int sumStat = CharDB::getSumStat(); + if (!sumStat) + sumStat = 30; + + mCharCreateDialog->setAttributes(attributes, sumStat, minStat, maxStat); + mCharCreateDialog->setFixedGender(true, token.sex); +} + void CharServerHandler::processCharLogin(Net::MessageIn &msg) { BLOCK_START("CharServerHandler::processCharLogin") diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h index b8cb5182e..0fd6f1f93 100644 --- a/src/net/tmwa/charserverhandler.h +++ b/src/net/tmwa/charserverhandler.h @@ -69,6 +69,14 @@ class CharServerHandler final : public MessageHandler, void setNewPincode(const std::string &pin A_UNUSED) override final { } + /** + * Sets the character create dialog. The handler will clean up this + * dialog when a new character is succesfully created, and will unlock + * the dialog when a new character failed to be created. + */ + void setCharCreateDialog(CharCreateDialog *const window) + override final; + protected: void readPlayerData(Net::MessageIn &msg, Net::Character *const character, -- cgit v1.2.3-70-g09d2