diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/charcreatedialog.cpp | 8 | ||||
-rw-r--r-- | src/gui/charcreatedialog.h | 14 | ||||
-rw-r--r-- | src/gui/charselectdialog.cpp | 32 | ||||
-rw-r--r-- | src/gui/charselectdialog.h | 2 |
4 files changed, 54 insertions, 2 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. |