summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-09 00:11:05 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-09 00:11:05 +0300
commit7b06428d3a428828d15a758a4abaee14bfad58a9 (patch)
tree6ce4a59d8d0d78ad88f4d13908f0937f7c85e6e0 /src/gui
parenta54c5dfccb56dc8996f5c7b2a2299a2cb2257f08 (diff)
downloadplus-7b06428d3a428828d15a758a4abaee14bfad58a9.tar.gz
plus-7b06428d3a428828d15a758a4abaee14bfad58a9.tar.bz2
plus-7b06428d3a428828d15a758a4abaee14bfad58a9.tar.xz
plus-7b06428d3a428828d15a758a4abaee14bfad58a9.zip
Add race in char creation dialog. Change client protocol version to 4.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/charcreatedialog.cpp66
-rw-r--r--src/gui/charcreatedialog.h6
2 files changed, 66 insertions, 6 deletions
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index ae4401572..973273e95 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -22,6 +22,7 @@
#include "gui/charcreatedialog.h"
+#include "client.h"
#include "game.h"
#include "localplayer.h"
#include "main.h"
@@ -44,6 +45,7 @@
#include "net/net.h"
#include "resources/colordb.h"
+#include "resources/itemdb.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -53,9 +55,10 @@
CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
Window(_("Create Character"), true, parent),
mCharSelectDialog(parent),
+ mRace(0),
mSlot(slot)
{
- mPlayer = new Being(0, ActorSprite::PLAYER, 0, NULL);
+ mPlayer = new Being(0, ActorSprite::PLAYER, mRace, NULL);
mPlayer->setGender(GENDER_MALE);
int numberOfHairColors = ColorDB::getHairSize();
@@ -76,6 +79,14 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mNextHairStyleButton = new Button(_(">"), "nextstyle", this);
mPrevHairStyleButton = new Button(_("<"), "prevstyle", this);
mHairStyleLabel = new Label(_("Hair style:"));
+
+ if (serverVersion >= 2)
+ {
+ mNextRaceButton = new Button(_(">"), "nextrace", this);
+ mPrevRaceButton = new Button(_("<"), "prevrace", this);
+ mRaceLabel = new Label(_("Race:"));
+ }
+
mCreateButton = new Button(_("Create"), "create", this);
mCancelButton = new Button(_("Cancel"), "cancel", this);
mMale = new RadioButton(_("Male"), "gender");
@@ -112,6 +123,14 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mPrevHairStyleButton->setPosition(90, 64);
mNextHairStyleButton->setPosition(165, 64);
mHairStyleLabel->setPosition(5, 70);
+
+ if (serverVersion >= 2)
+ {
+ mPrevRaceButton->setPosition(90, 93);
+ mNextRaceButton->setPosition(165, 93);
+ mRaceLabel->setPosition(5, 100);
+ }
+
mAttributesLeft->setPosition(15, 280);
updateSliders();
mCancelButton->setPosition(
@@ -133,6 +152,14 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
add(mNextHairStyleButton);
add(mPrevHairStyleButton);
add(mHairStyleLabel);
+
+ if (serverVersion >= 2)
+ {
+ add(mNextRaceButton);
+ add(mPrevRaceButton);
+ add(mRaceLabel);
+ }
+
add(mAttributesLeft);
add(mCreateButton);
add(mCancelButton);
@@ -177,9 +204,7 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
++characterSlot;
Net::getCharHandler()->newCharacter(getName(), characterSlot,
- mFemale->isSelected(),
- mHairStyle,
- mHairColor, atts);
+ mFemale->isSelected(), mHairStyle, mHairColor, mRace, atts);
}
else
{
@@ -212,6 +237,16 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
mHairStyle--;
updateHair();
}
+ else if (event.getId() == "nextrace")
+ {
+ mRace++;
+ updateRace();
+ }
+ else if (event.getId() == "prevrace")
+ {
+ mRace--;
+ updateRace();
+ }
else if (event.getId() == "statslider")
{
updateSliders();
@@ -353,8 +388,8 @@ void CharCreateDialog::setFixedGender(bool fixed, Gender gender)
if (fixed)
{
- mMale->setEnabled(false);
- mFemale->setEnabled(false);
+ mMale->setVisible(false);
+ mFemale->setVisible(false);
}
}
@@ -371,3 +406,22 @@ void CharCreateDialog::updateHair()
mPlayer->setSprite(Net::getCharHandler()->hairSprite(),
mHairStyle * -1, ColorDB::getHairColor(mHairColor));
}
+
+void CharCreateDialog::updateRace()
+{
+ int id;
+ if (mRace < 0)
+ {
+ mRace = 0;
+ id = -100;
+ }
+ else
+ {
+ id = -100 - mRace;
+ while (id < -100 && !ItemDB::exists(id))
+ id ++;
+ mRace = -100 - id;
+ }
+
+ mPlayer->setSubtype(mRace);
+}
diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h
index 7a029ac2f..2f0f83513 100644
--- a/src/gui/charcreatedialog.h
+++ b/src/gui/charcreatedialog.h
@@ -86,6 +86,8 @@ class CharCreateDialog : public Window, public gcn::ActionListener
void updateHair();
+ void updateRace();
+
CharSelectDialog *mCharSelectDialog;
gcn::TextField *mNameField;
@@ -96,6 +98,9 @@ class CharCreateDialog : public Window, public gcn::ActionListener
gcn::Button *mNextHairStyleButton;
gcn::Button *mPrevHairStyleButton;
gcn::Label *mHairStyleLabel;
+ gcn::Button *mNextRaceButton;
+ gcn::Button *mPrevRaceButton;
+ gcn::Label *mRaceLabel;
gcn::RadioButton *mMale;
gcn::RadioButton *mFemale;
@@ -116,6 +121,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener
int mHairStyle;
int mHairColor;
+ int mRace;
int mSlot;
};