summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-10-03 18:12:52 -0600
committerJared Adams <jaxad0127@gmail.com>2009-10-03 18:12:52 -0600
commit447232f0ad7dd94372424389336b0a53ed332597 (patch)
treef0aded965b96fed35fbe7ff2a9cf10700b923ce8
parent0269b1f766a4e9e8ded91505855cff58c18086e2 (diff)
downloadmana-client-447232f0ad7dd94372424389336b0a53ed332597.tar.gz
mana-client-447232f0ad7dd94372424389336b0a53ed332597.tar.bz2
mana-client-447232f0ad7dd94372424389336b0a53ed332597.tar.xz
mana-client-447232f0ad7dd94372424389336b0a53ed332597.zip
Update the CharSelectDialog after char creation
-rw-r--r--src/gui/charcreatedialog.cpp8
-rw-r--r--src/gui/charcreatedialog.h14
-rw-r--r--src/gui/charselectdialog.cpp32
-rw-r--r--src/gui/charselectdialog.h2
-rw-r--r--src/net/ea/charserverhandler.cpp1
-rw-r--r--src/net/tmwserv/charhandler.cpp40
-rw-r--r--src/net/tmwserv/charhandler.h4
7 files changed, 97 insertions, 4 deletions
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 87be2be3..86a8bf2b 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -50,8 +50,9 @@
#include <guichan/font.hpp>
-CharCreateDialog::CharCreateDialog(Window *parent, int slot):
+CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
Window(_("Create Character"), true, parent),
+ mCharSelectDialog(parent),
mSlot(slot)
{
mPlayer = new Player(0, 0, NULL);
@@ -341,6 +342,11 @@ void CharCreateDialog::setFixedGender(bool fixed, Gender gender)
}
}
+void CharCreateDialog::success()
+{
+ mCharSelectDialog->update(mSlot);
+}
+
void CharCreateDialog::updateHair()
{
mHairStyle %= Being::getNumOfHairstyles();
diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h
index a30aadd3..50089a8d 100644
--- a/src/gui/charcreatedialog.h
+++ b/src/gui/charcreatedialog.h
@@ -28,6 +28,8 @@
#include "gui/widgets/window.h"
+#include "gui/charselectdialog.h"
+
#include <guichan/actionlistener.hpp>
#include <string>
@@ -47,7 +49,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener
/**
* Constructor.
*/
- CharCreateDialog(Window *parent, int slot);
+ CharCreateDialog(CharSelectDialog *parent, int slot);
/**
* Destructor.
@@ -66,6 +68,14 @@ class CharCreateDialog : public Window, public gcn::ActionListener
void setFixedGender(bool fixed, Gender gender = GENDER_FEMALE);
+ /**
+ * Notify the CharSelectDialog the character was created successfully.
+ */
+ void success();
+
+ CharSelectDialog *getSelectDialog()
+ { return mCharSelectDialog; }
+
private:
int getDistributedPoints() const;
@@ -83,6 +93,8 @@ class CharCreateDialog : public Window, public gcn::ActionListener
void updateHair();
+ CharSelectDialog *mCharSelectDialog;
+
gcn::TextField *mNameField;
gcn::Label *mNameLabel;
gcn::Button *mNextHairColorButton;
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 12980e7b..fef319d9 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -98,6 +98,8 @@ class CharEntry : public Container
LocalPlayer *getChar() const
{ return mCharacter; }
+ void setChar(LocalPlayer *chr);
+
void requestFocus();
void update();
@@ -262,6 +264,26 @@ void CharSelectDialog::chooseSelected()
attemptCharSelect();
}
+void CharSelectDialog::update(int slot)
+{
+ if (slot >= 0 && slot < MAX_CHARACTER_COUNT)
+ {
+ mCharInfo->select(slot);
+ mCharEntries[slot]->setChar(mCharInfo->getEntry());
+ mCharEntries[slot]->requestFocus();
+ }
+ else
+ {
+ int slot = mCharInfo->getPos();
+ for (int i = 0; i < MAX_CHARACTER_COUNT; i++)
+ {
+ mCharInfo->select(slot);
+ mCharEntries[slot]->setChar(mCharInfo->getEntry());
+ }
+ mCharInfo->select(slot);
+ }
+}
+
CharEntry::CharEntry(CharSelectDialog *m, char slot, LocalPlayer *chr):
mSlot(slot),
mCharacter(chr),
@@ -285,6 +307,16 @@ CharEntry::CharEntry(CharSelectDialog *m, char slot, LocalPlayer *chr):
update();
}
+void CharEntry::setChar(LocalPlayer *chr)
+{
+ mCharacter = chr;
+
+ if (chr)
+ mPlayerBox->setPlayer(chr);
+
+ update();
+}
+
void CharEntry::requestFocus()
{
mButton->requestFocus();
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index 0bb8e27f..44917d6c 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -62,6 +62,8 @@ class CharSelectDialog : public Window, public gcn::ActionListener
void chooseSelected();
+ void update(int slot = -1);
+
private:
/**
* Communicate character deletion to the server.
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index f854841f..83f8f9fc 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -118,6 +118,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
// Close the character create dialog
if (mCharCreateDialog)
{
+ mCharCreateDialog->success();
mCharCreateDialog->scheduleDelete();
mCharCreateDialog = 0;
}
diff --git a/src/net/tmwserv/charhandler.cpp b/src/net/tmwserv/charhandler.cpp
index ec260d84..841c9a2d 100644
--- a/src/net/tmwserv/charhandler.cpp
+++ b/src/net/tmwserv/charhandler.cpp
@@ -72,6 +72,7 @@ extern ServerInfo gameServer;
extern ServerInfo chatServer;
CharHandler::CharHandler():
+ mCharSelectDialog(0),
mCharCreateDialog(0)
{
static const Uint16 _messages[] = {
@@ -145,6 +146,30 @@ void CharHandler::handleMessage(MessageIn &msg)
}
chars.push_back(info);
+
+ if (mCharSelectDialog)
+ {
+ mCharInfo->select(info.slot);
+
+ LocalPlayer *tempPlayer = new LocalPlayer();
+ tempPlayer->setName(info.name);
+ tempPlayer->setGender(info.gender);
+ tempPlayer->setSprite(Player::HAIR_SPRITE, info.hs * -1,
+ ColorDB::get(info.hc));
+ tempPlayer->setLevel(info.level);
+ tempPlayer->setCharacterPoints(info.charPoints);
+ tempPlayer->setCorrectionPoints(info.corrPoints);
+ tempPlayer->setMoney(info.money);
+
+ for (int i = 0; i < 7; i++)
+ {
+ tempPlayer->setAttributeBase(i, info.attr[i]);
+ }
+
+ mCharInfo->setEntry(tempPlayer);
+
+ mCharSelectDialog->update(info.slot);
+ }
}
break;
@@ -199,10 +224,20 @@ void CharHandler::handleCharCreateResponse(MessageIn &msg)
break;
}
new OkDialog(_("Error"), errorMessage);
+
+ if (mCharCreateDialog)
+ mCharCreateDialog->unlock();
+ }
+ else
+ {
+ if (mCharCreateDialog)
+ {
+ mCharCreateDialog->success();
+ mCharCreateDialog->scheduleDelete();
+ mCharCreateDialog = 0;
+ }
}
- if (mCharCreateDialog)
- mCharCreateDialog->unlock();
}
void CharHandler::handleCharSelectResponse(MessageIn &msg)
@@ -258,6 +293,7 @@ void CharHandler::handleCharSelectResponse(MessageIn &msg)
void CharHandler::setCharCreateDialog(CharCreateDialog *window)
{
+ mCharSelectDialog = window ? window->getSelectDialog() : NULL;
mCharCreateDialog = window;
if (!mCharCreateDialog) return;
diff --git a/src/net/tmwserv/charhandler.h b/src/net/tmwserv/charhandler.h
index 2c62c1d0..5517bd17 100644
--- a/src/net/tmwserv/charhandler.h
+++ b/src/net/tmwserv/charhandler.h
@@ -23,6 +23,9 @@
#define NET_TMWSERV_CHARSERVERHANDLER_H
#include "net/charhandler.h"
+
+#include "gui/charselectdialog.h"
+
#include "net/messagehandler.h"
class LoginData;
@@ -67,6 +70,7 @@ class CharHandler : public MessageHandler, public Net::CharHandler
void handleCharSelectResponse(MessageIn &msg);
LockedArray<LocalPlayer*> *mCharInfo;
+ CharSelectDialog *mCharSelectDialog;
CharCreateDialog *mCharCreateDialog;
};