From dcc18eba1769a46aeaee2ff441706cf14f3ada4c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 7 Jul 2012 23:53:20 +0300 Subject: Add support for default equipment in char creation dialog. --- src/gui/charcreatedialog.cpp | 8 ++++++++ src/gui/inventorywindow.cpp | 1 - src/resources/chardb.cpp | 12 ++++++++++++ src/resources/chardb.h | 4 ++++ 4 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 6a2ad0bf3..5611efa4c 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -82,6 +82,14 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mPlayer = new Being(0, ActorSprite::PLAYER, mRace, nullptr); mPlayer->setGender(GENDER_MALE); + const std::vector &items = CharDB::getDefaultItems(); + int i = 1; + for (std::vector::const_iterator it = items.begin(), + it_end = items.end(); + it != it_end; ++ it, i ++) + { + mPlayer->setSprite(i, *it); + } maxHairColor = CharDB::getMaxHairColor(); minHairColor = CharDB::getMinHairColor(); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 0db48cbb8..de2e0e1a4 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -48,7 +48,6 @@ #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/progressbar.h" -#include "gui/widgets/radiobutton.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/tabstrip.h" #include "gui/widgets/textfield.h" diff --git a/src/resources/chardb.cpp b/src/resources/chardb.cpp index f38f13224..6ee5f964f 100644 --- a/src/resources/chardb.cpp +++ b/src/resources/chardb.cpp @@ -36,6 +36,7 @@ namespace unsigned mMinStat = 0; unsigned mMaxStat = 0; unsigned mSumStat = 0; + std::vector mDefaultItems; } void CharDB::load() @@ -69,6 +70,12 @@ void CharDB::load() loadMinMax(node, &mMinStat, &mMaxStat); mSumStat = XML::getProperty(node, "sum", 0); } + else if (xmlNameEqual(node, "item")) + { + int id = XML::getProperty(node, "id", 0); + if (id > 0) + mDefaultItems.push_back(id); + } } delete doc; @@ -123,3 +130,8 @@ unsigned CharDB::getSumStat() { return mSumStat; } + +const std::vector &CharDB::getDefaultItems() +{ + return mDefaultItems; +} diff --git a/src/resources/chardb.h b/src/resources/chardb.h index 60ff31084..d0628fbdf 100644 --- a/src/resources/chardb.h +++ b/src/resources/chardb.h @@ -27,6 +27,8 @@ #include "utils/xml.h" +#include + /** * Char information database. */ @@ -57,6 +59,8 @@ namespace CharDB unsigned getMaxStat(); unsigned getSumStat(); + + const std::vector &getDefaultItems(); } #endif -- cgit v1.2.3-70-g09d2