summaryrefslogtreecommitdiff
path: root/src/gui/charcreatedialog.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-08-13 17:30:59 -0600
committerJared Adams <jaxad0127@gmail.com>2009-08-13 17:33:08 -0600
commitf46cfb91278b27f4943f5512778129fe985c678e (patch)
tree0be219d66e723bcca8de2d584d66bc65d040fb26 /src/gui/charcreatedialog.cpp
parentbe85ca9d91ff867faf140328d0bcbb2062b58cdf (diff)
downloadmana-f46cfb91278b27f4943f5512778129fe985c678e.tar.gz
mana-f46cfb91278b27f4943f5512778129fe985c678e.tar.bz2
mana-f46cfb91278b27f4943f5512778129fe985c678e.tar.xz
mana-f46cfb91278b27f4943f5512778129fe985c678e.zip
Clean up Being and it's derivatives
Move stuff only needed for Players into Player (like slots and sprite limits). Move name handling into Being (no need for three copies of this code). Clean up terminology (including Map terminology). Remove hair-related variables.
Diffstat (limited to 'src/gui/charcreatedialog.cpp')
-rw-r--r--src/gui/charcreatedialog.cpp46
1 files changed, 31 insertions, 15 deletions
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index e09eee55..7c2b0ed9 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -59,8 +59,9 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot):
int numberOfHairColors = ColorDB::size();
- mPlayer->setHairStyle(rand() % mPlayer->getNumOfHairstyles(),
- rand() % numberOfHairColors);
+ mHairStyle = rand() % mPlayer->getNumOfHairstyles();
+ mHairColor = rand() % numberOfHairColors;
+ updateHair();
mNameField = new TextField("");
mNameLabel = new Label(_("Name:"));
@@ -153,7 +154,6 @@ CharCreateDialog::~CharCreateDialog()
void CharCreateDialog::action(const gcn::ActionEvent &event)
{
- int numberOfColors = ColorDB::size();
if (event.getId() == "create")
{
if (getName().length() >= 4)
@@ -168,8 +168,8 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
}
Net::getCharHandler()->newCharacter(getName(), mSlot,
- mFemale->isSelected(), mPlayer->getHairStyle(),
- mPlayer->getHairColor(), atts);
+ mFemale->isSelected(), mHairStyle,
+ mHairColor, atts);
}
else
{
@@ -181,19 +181,25 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
else if (event.getId() == "cancel")
scheduleDelete();
else if (event.getId() == "nextcolor")
- mPlayer->setHairStyle(mPlayer->getHairStyle(),
- (mPlayer->getHairColor() + 1) % numberOfColors);
+ {
+ mHairColor++;
+ updateHair();
+ }
else if (event.getId() == "prevcolor")
- mPlayer->setHairStyle(mPlayer->getHairStyle(),
- (mPlayer->getHairColor() + numberOfColors - 1) %
- numberOfColors);
+ {
+ mHairColor--;
+ updateHair();
+ }
else if (event.getId() == "nextstyle")
- mPlayer->setHairStyle(mPlayer->getHairStyle() + 1,
- mPlayer->getHairColor());
+ {
+ mHairStyle++;
+ updateHair();
+ }
else if (event.getId() == "prevstyle")
- mPlayer->setHairStyle(mPlayer->getHairStyle() +
- mPlayer->getNumOfHairstyles() - 1,
- mPlayer->getHairColor());
+ {
+ mHairStyle--;
+ updateHair();
+ }
else if (event.getId() == "statslider") {
updateSliders();
}
@@ -334,3 +340,13 @@ void CharCreateDialog::setFixedGender(bool fixed, Gender gender)
mFemale->setEnabled(false);
}
}
+
+void CharCreateDialog::updateHair()
+{
+ mHairStyle %= Being::getNumOfHairstyles();
+
+ mHairColor %= ColorDB::size();
+
+ mPlayer->setSprite(Player::HAIR_SPRITE,
+ mHairStyle * -1, ColorDB::get(mHairColor));
+}