diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-11 16:17:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-11 16:17:36 +0300 |
commit | dde2d920e07d651b9571ada0b4c6a8cc58e4982a (patch) | |
tree | a1b7b52d9f35222ff7e30dcf458191bb4ed33ace | |
parent | b6df3c3999d4be067e7314e3887e583c13ad1624 (diff) | |
download | plus-dde2d920e07d651b9571ada0b4c6a8cc58e4982a.tar.gz plus-dde2d920e07d651b9571ada0b4c6a8cc58e4982a.tar.bz2 plus-dde2d920e07d651b9571ada0b4c6a8cc58e4982a.tar.xz plus-dde2d920e07d651b9571ada0b4c6a8cc58e4982a.zip |
add partial support for player look.
can change look in char creation dialog, but cant render different look.
-rw-r--r-- | src/gui/charcreatedialog.cpp | 109 | ||||
-rw-r--r-- | src/gui/charcreatedialog.h | 8 | ||||
-rw-r--r-- | src/resources/chardb.cpp | 16 | ||||
-rw-r--r-- | src/resources/chardb.h | 4 | ||||
-rw-r--r-- | src/resources/colordb.h | 4 | ||||
-rw-r--r-- | src/resources/iteminfo.cpp | 12 | ||||
-rw-r--r-- | src/resources/iteminfo.h | 5 |
7 files changed, 138 insertions, 20 deletions
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index dc65f6ae1..f9dd1e675 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -96,6 +96,10 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, mPrevRaceButton(nullptr), mRaceLabel(nullptr), mRaceNameLabel(nullptr), + mNextLookButton(nullptr), + mPrevLookButton(nullptr), + mLookLabel(nullptr), + mLookNameLabel(nullptr), // TRANSLATORS: char create dialog button mActionButton(new Button(this, _("^"), "action", this)), // TRANSLATORS: char create dialog button @@ -120,6 +124,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, mCancelButton(new Button(this, _("Cancel"), "cancel", this)), mRace(0), mLook(0), + mMinLook(CharDB::getMinLook()), + mMaxLook(CharDB::getMaxLook()), mPlayer(new Being(0, ActorSprite::PLAYER, static_cast<uint16_t>(mRace), nullptr)), mPlayerBox(new PlayerBox(mPlayer, "charcreate_playerbox.xml", @@ -168,6 +174,16 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, mRaceLabel = new Label(this, _("Race:")); mRaceNameLabel = new Label(this, ""); } + if (mMinLook < mMaxLook) + { + // TRANSLATORS: char create dialog button + mNextLookButton = new Button(this, _(">"), "nextlook", this); + // TRANSLATORS: char create dialog button + mPrevLookButton = new Button(this, _("<"), "prevlook", this); + // TRANSLATORS: char create dialog label + mLookLabel = new Label(this, _("Look:")); + mLookNameLabel = new Label(this, ""); + } // Default to a Male character mMale->setSelected(true); @@ -201,21 +217,36 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, const int rightX = 300; const int labelX = 5; const int nameX = 145; - mPrevHairColorButton->setPosition(leftX, 30); - mNextHairColorButton->setPosition(rightX, 30); - mHairColorLabel->setPosition(labelX, 35); - mHairColorNameLabel->setPosition(nameX, 35); - mPrevHairStyleButton->setPosition(leftX, 59); - mNextHairStyleButton->setPosition(rightX, 59); - mHairStyleLabel->setPosition(labelX, 64); - mHairStyleNameLabel->setPosition(nameX, 64); - + int y = 30; + mPrevHairColorButton->setPosition(leftX, y); + mNextHairColorButton->setPosition(rightX, y); + y += 5; + mHairColorLabel->setPosition(labelX, y); + mHairColorNameLabel->setPosition(nameX, y); + y += 24; + mPrevHairStyleButton->setPosition(leftX, y); + mNextHairStyleButton->setPosition(rightX, y); + y += 5; + mHairStyleLabel->setPosition(labelX, y); + mHairStyleNameLabel->setPosition(nameX, y); + + if (mMinLook < mMaxLook) + { + y += 24; + mPrevLookButton->setPosition(leftX, y); + mNextLookButton->setPosition(rightX, y); + y += 5; + mLookLabel->setPosition(labelX, y); + mLookNameLabel->setPosition(nameX, y); // 93 + } if (serverVersion >= 2) { - mPrevRaceButton->setPosition(leftX, 88); - mNextRaceButton->setPosition(rightX, 88); - mRaceLabel->setPosition(labelX, 93); - mRaceNameLabel->setPosition(nameX, 93); + y += 24; + mPrevRaceButton->setPosition(leftX, y); + mNextRaceButton->setPosition(rightX, y); + y += 5; + mRaceLabel->setPosition(labelX, y); + mRaceNameLabel->setPosition(nameX, y); } updateSliders(); @@ -239,6 +270,14 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, add(mActionButton); add(mRotateButton); + if (mMinLook < mMaxLook) + { + add(mNextLookButton); + add(mPrevLookButton); + add(mLookLabel); + add(mLookNameLabel); + } + if (serverVersion >= 2) { add(mNextRaceButton); @@ -262,7 +301,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, updateHair(); if (serverVersion >= 2) updateRace(); - + if (mMinLook < mMaxLook) + updateLook(); updatePlayer(); addKeyListener(this); @@ -354,6 +394,16 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) mRace --; updateRace(); } + else if (id == "nextlook") + { + mLook ++; + updateLook(); + } + else if (id == "prevlook") + { + mLook --; + updateLook(); + } else if (id == "statslider") { updateSliders(); @@ -465,25 +515,26 @@ void CharCreateDialog::setAttributes(const StringVect &labels, const int w = 480; const int h = 350; + const int y = 118 + 29; for (unsigned i = 0, sz = static_cast<unsigned>(labels.size()); i < sz; i++) { mAttributeLabel[i] = new Label(this, labels[i]); mAttributeLabel[i]->setWidth(70); - mAttributeLabel[i]->setPosition(5, 118 + i * 24); + mAttributeLabel[i]->setPosition(5, y + i * 24); mAttributeLabel[i]->adjustSize(); add(mAttributeLabel[i]); mAttributeSlider[i] = new Slider(min, max); - mAttributeSlider[i]->setDimension(gcn::Rectangle(140, 118 + i * 24, + mAttributeSlider[i]->setDimension(gcn::Rectangle(140, y + i * 24, 150, 12)); mAttributeSlider[i]->setActionEventId("statslider"); mAttributeSlider[i]->addActionListener(this); add(mAttributeSlider[i]); mAttributeValue[i] = new Label(this, toString(min)); - mAttributeValue[i]->setPosition(295, 118 + i * 24); + mAttributeValue[i]->setPosition(295, y + i * 24); add(mAttributeValue[i]); } @@ -568,6 +619,28 @@ void CharCreateDialog::updateRace() mRaceNameLabel->adjustSize(); } +void CharCreateDialog::updateLook() +{ + const ItemInfo &item = ItemDB::get(-100 - mRace); + const int sz = item.getColorsSize(); + if (sz > 0) + { + if (mLook < 0) + mLook = sz - 1; + if (mLook > mMaxLook) + mLook = mMaxLook; + if (mLook >= sz) + mLook = 0; + } + else + { + mLook = 0; + } + mPlayer->setSubtype(static_cast<uint16_t>(mRace), mLook); + mLookNameLabel->setCaption(item.getColorName(mLook)); + mLookNameLabel->adjustSize(); +} + void CharCreateDialog::logic() { if (mPlayer) @@ -615,5 +688,5 @@ void CharCreateDialog::setButtonsPosition(const int w, const int h) mCancelButton->getX() - 5 - mCreateButton->getWidth(), h - 5 - mCancelButton->getHeight()); } - mAttributesLeft->setPosition(15, 260); + mAttributesLeft->setPosition(15, 260 + 29); } diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h index a7cb5105c..82e7d7261 100644 --- a/src/gui/charcreatedialog.h +++ b/src/gui/charcreatedialog.h @@ -100,6 +100,8 @@ class CharCreateDialog final : public Window, void updateRace(); + void updateLook(); + CharSelectDialog *mCharSelectDialog; TextField *mNameField; @@ -116,6 +118,10 @@ class CharCreateDialog final : public Window, Button *mPrevRaceButton; Label *mRaceLabel; Label *mRaceNameLabel; + Button *mNextLookButton; + Button *mPrevLookButton; + Label *mLookLabel; + Label *mLookNameLabel; Button *mActionButton; Button *mRotateButton; @@ -137,6 +143,8 @@ class CharCreateDialog final : public Window, int mRace; int mLook; + int mMinLook; + int mMaxLook; Being *mPlayer; PlayerBox *mPlayerBox; diff --git a/src/resources/chardb.cpp b/src/resources/chardb.cpp index 1111177e1..73582e989 100644 --- a/src/resources/chardb.cpp +++ b/src/resources/chardb.cpp @@ -37,6 +37,8 @@ namespace unsigned mMinStat = 0; unsigned mMaxStat = 0; unsigned mSumStat = 0; + unsigned mMinLook = 0; + unsigned mMaxLook = 0; std::vector<int> mDefaultItems; } // namespace @@ -67,6 +69,10 @@ void CharDB::load() { loadMinMax(node, &mMinHairStyle, &mMaxHairStyle); } + else if (xmlNameEqual(node, "look")) + { + loadMinMax(node, &mMinLook, &mMaxLook); + } else if (xmlNameEqual(node, "stat")) { loadMinMax(node, &mMinStat, &mMaxStat); @@ -134,6 +140,16 @@ unsigned CharDB::getSumStat() return mSumStat; } +unsigned CharDB::getMinLook() +{ + return mMinLook; +} + +unsigned CharDB::getMaxLook() +{ + return mMaxLook; +} + const std::vector<int> &CharDB::getDefaultItems() { return mDefaultItems; diff --git a/src/resources/chardb.h b/src/resources/chardb.h index 52f4cb8bc..b61d61e1d 100644 --- a/src/resources/chardb.h +++ b/src/resources/chardb.h @@ -61,6 +61,10 @@ namespace CharDB unsigned getSumStat() A_WARN_UNUSED; + unsigned getMinLook() A_WARN_UNUSED; + + unsigned getMaxLook() A_WARN_UNUSED; + const std::vector<int> &getDefaultItems() A_WARN_UNUSED; } // namespace CharDB diff --git a/src/resources/colordb.h b/src/resources/colordb.h index ad69799d9..3eec3625d 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -37,8 +37,8 @@ namespace ColorDB public: ItemColor(): id(0), - name(""), - color("") + name(), + color() { } ItemColor(const int id0, const std::string &name0, diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index e9a550cda..78740522f 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -309,3 +309,15 @@ void ItemInfo::setSprite(const std::string &animationFile, { mAnimationFiles[static_cast<int>(gender) + race * 4] = animationFile; } + +std::string ItemInfo::getColorName(const int idx) const +{ + if (!mColors) + return std::string(); + + const std::map <int, ColorDB::ItemColor>::const_iterator + it = mColors->find(idx); + if (it == mColors->end()) + return std::string(); + return it->second.name; +} diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index a3b606dc8..3e6d0d249 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -292,6 +292,11 @@ class ItemInfo final bool isProtected() const { return mProtected; } + int getColorsSize() const + { return mColors ? mColors->size() : 0; } + + std::string getColorName(const int idx) const; + int mDrawBefore[10]; int mDrawAfter[10]; int mDrawPriority[10]; |