summaryrefslogtreecommitdiff
path: root/src/gui
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
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')
-rw-r--r--src/gui/charcreatedialog.cpp46
-rw-r--r--src/gui/charcreatedialog.h8
-rw-r--r--src/gui/charselectdialog.h3
-rw-r--r--src/gui/playerbox.cpp6
4 files changed, 41 insertions, 22 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));
+}
diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h
index 5dbc6050..a30aadd3 100644
--- a/src/gui/charcreatedialog.h
+++ b/src/gui/charcreatedialog.h
@@ -22,7 +22,7 @@
#ifndef CHAR_CREATE_H
#define CHAR_CREATE_H
-#include "being.h"
+#include "player.h"
#include "guichanfwd.h"
#include "lockedarray.h"
@@ -34,7 +34,6 @@
#include <vector>
class LocalPlayer;
-class Player;
class PlayerBox;
/**
@@ -82,6 +81,8 @@ class CharCreateDialog : public Window, public gcn::ActionListener
*/
void attemptCharCreate();
+ void updateHair();
+
gcn::TextField *mNameField;
gcn::Label *mNameLabel;
gcn::Button *mNextHairColorButton;
@@ -108,6 +109,9 @@ class CharCreateDialog : public Window, public gcn::ActionListener
Player *mPlayer;
PlayerBox *mPlayerBox;
+ int mHairStyle;
+ int mHairColor;
+
int mSlot;
};
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index 06ce4b55..4427017e 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -24,7 +24,7 @@
#include "gui/widgets/window.h"
-#include "being.h"
+#include "player.h"
#include "guichanfwd.h"
#include "lockedarray.h"
@@ -32,7 +32,6 @@
class LocalPlayer;
class LoginData;
-class Player;
class PlayerBox;
/**
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp
index d00194bd..9a1f4805 100644
--- a/src/gui/playerbox.cpp
+++ b/src/gui/playerbox.cpp
@@ -82,11 +82,11 @@ void PlayerBox::draw(gcn::Graphics *graphics)
{
// Draw character
const int bs = getFrameSize();
-#ifdef TMWSERV_SUPPORT
+//#ifdef TMWSERV_SUPPORT
const int x = getWidth() / 2 + bs;
const int y = getHeight() - bs - 8;
mPlayer->draw(static_cast<Graphics*>(graphics), x, y);
-#else
+/*#else
const int x = getWidth() / 2 - 16 + bs;
const int y = getHeight() / 2 + bs;
for (int i = 0; i < Being::VECTOREND_SPRITE; i++)
@@ -96,7 +96,7 @@ void PlayerBox::draw(gcn::Graphics *graphics)
mPlayer->getSprite(i)->draw(static_cast<Graphics*>(graphics), x, y);
}
}
-#endif
+#endif*/
}
if (config.getValue("guialpha", 0.8) != mAlpha)