summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-05 21:48:30 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-05 21:48:30 +0300
commit6fee84f3838bdd900e8cfc4a1e4d7f15f35bd6ed (patch)
tree79a54d4c838c85df29b1b95702b71a95c43ceb5a /src/gui
parentd1bb1b375d657f0821ccfebf18fa1c3873314690 (diff)
downloadmanaplus-6fee84f3838bdd900e8cfc4a1e4d7f15f35bd6ed.tar.gz
manaplus-6fee84f3838bdd900e8cfc4a1e4d7f15f35bd6ed.tar.bz2
manaplus-6fee84f3838bdd900e8cfc4a1e4d7f15f35bd6ed.tar.xz
manaplus-6fee84f3838bdd900e8cfc4a1e4d7f15f35bd6ed.zip
Improve constructors in some classes.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/buydialog.cpp8
-rw-r--r--src/gui/buyselldialog.cpp6
-rw-r--r--src/gui/changepassworddialog.cpp13
-rw-r--r--src/gui/charcreatedialog.cpp55
-rw-r--r--src/gui/charcreatedialog.h3
-rw-r--r--src/gui/charselectdialog.cpp15
-rw-r--r--src/gui/charselectdialog.h4
7 files changed, 58 insertions, 46 deletions
diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp
index ffbe042e5..9eba7796b 100644
--- a/src/gui/buydialog.cpp
+++ b/src/gui/buydialog.cpp
@@ -50,15 +50,19 @@
BuyDialog::DialogList BuyDialog::instances;
-BuyDialog::BuyDialog(const int npcId):
+BuyDialog::BuyDialog(const int npcId) :
Window(_("Buy"), false, nullptr, "buy.xml"),
+ ActionListener(),
+ SelectionListener(),
mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick("")
{
init();
}
-BuyDialog::BuyDialog(std::string nick):
+BuyDialog::BuyDialog(std::string nick) :
Window(_("Buy"), false, nullptr, "buy.xml"),
+ ActionListener(),
+ SelectionListener(),
mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick)
{
init();
diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp
index 7fff70fc0..31a1aa315 100644
--- a/src/gui/buyselldialog.cpp
+++ b/src/gui/buyselldialog.cpp
@@ -34,8 +34,9 @@
BuySellDialog::DialogList BuySellDialog::instances;
-BuySellDialog::BuySellDialog(const int npcId):
+BuySellDialog::BuySellDialog(const int npcId) :
Window(_("Shop"), false, nullptr, "buysell.xml"),
+ ActionListener(),
mNpcId(npcId),
mNick(""),
mBuyButton(nullptr)
@@ -43,8 +44,9 @@ BuySellDialog::BuySellDialog(const int npcId):
init();
}
-BuySellDialog::BuySellDialog(std::string nick):
+BuySellDialog::BuySellDialog(std::string nick) :
Window(_("Shop"), false, nullptr, "buysell.xml"),
+ ActionListener(),
mNpcId(-1),
mNick(nick),
mBuyButton(nullptr)
diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp
index 0d38bab4e..be5bdb7c4 100644
--- a/src/gui/changepassworddialog.cpp
+++ b/src/gui/changepassworddialog.cpp
@@ -46,17 +46,18 @@
ChangePasswordDialog::ChangePasswordDialog(LoginData *const data):
Window(_("Change Password"), true, nullptr, "changepassword.xml"),
+ ActionListener(),
+ mOldPassField(new PasswordField),
+ mFirstPassField(new PasswordField),
+ mSecondPassField(new PasswordField),
+ mChangePassButton(new Button(_("Change Password"),
+ "change_password", this)),
+ mCancelButton(new Button(_("Cancel"), "cancel", this)),
mWrongDataNoticeListener(new WrongDataNoticeListener),
mLoginData(data)
{
gcn::Label *const accountLabel = new Label(
strprintf(_("Account: %s"), mLoginData->username.c_str()));
- mOldPassField = new PasswordField;
- mFirstPassField = new PasswordField;
- mSecondPassField = new PasswordField;
- mChangePassButton = new Button(_("Change Password"), "change_password",
- this);
- mCancelButton = new Button(_("Cancel"), "cancel", this);
place(0, 0, accountLabel, 3);
place(0, 1, new Label(_("Password:")), 3);
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 4c553f5e1..37839c7ee 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -67,8 +67,37 @@ static const uint8_t directions[] =
CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
const int slot) :
Window(_("New Character"), true, parent, "charcreate.xml"),
+ ActionListener(),
+ KeyListener(),
mCharSelectDialog(parent),
+ mNameField(new TextField("")),
+ mNameLabel(new Label(_("Name:"))),
+ // TRANSLATORS: This is a narrow symbol used to denote 'next'.
+ // You may change this symbol if your language uses another.
+ mNextHairColorButton(new Button(_(">"), "nextcolor", this)),
+ // TRANSLATORS: This is a narrow symbol used to denote 'previous'.
+ // You may change this symbol if your language uses another.
+ mPrevHairColorButton(new Button(_("<"), "prevcolor", this)),
+ mHairColorLabel(new Label(_("Hair color:"))),
+ mHairColorNameLabel(new Label("")),
+ mNextHairStyleButton(new Button(_(">"), "nextstyle", this)),
+ mPrevHairStyleButton(new Button(_("<"), "prevstyle", this)),
+ mHairStyleLabel(new Label(_("Hair style:"))),
+ mHairStyleNameLabel(new Label("")),
+ mActionButton(new Button(_("^"), "action", this)),
+ mRotateButton(new Button(_(">"), "rotate", this)),
+ mMale(new RadioButton(_("Male"), "gender")),
+ mFemale(new RadioButton(_("Female"), "gender")),
+ mOther(new RadioButton(_("Other"), "gender")),
+ mAttributesLeft(new Label(
+ strprintf(_("Please distribute %d points"), 99))),
+ mMaxPoints(0),
+ mUsedPoints(0),
+ mCreateButton(new Button(_("Create"), "create", this)),
+ mCancelButton(new Button(_("Cancel"), "cancel", this)),
mRace(0),
+ mPlayer(new Being(0, ActorSprite::PLAYER, mRace, nullptr)),
+ mPlayerBox(new PlayerBox(mPlayer, "charcreate_playerbox.xml")),
mSlot(slot),
mAction(0),
mDirection(0)
@@ -77,7 +106,6 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
setSticky(true);
setWindowName("NewCharacter");
- mPlayer = new Being(0, ActorSprite::PLAYER, mRace, nullptr);
mPlayer->setGender(GENDER_MALE);
const std::vector<int> &items = CharDB::getDefaultItems();
int i = 1;
@@ -101,23 +129,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
mHairStyle = (rand() % maxHairStyle) + minHairStyle;
mHairColor = (rand() % maxHairColor) + minHairColor;
- mNameField = new TextField("");
mNameField->setMaximum(24);
- mNameLabel = new Label(_("Name:"));
- // TRANSLATORS: This is a narrow symbol used to denote 'next'.
- // You may change this symbol if your language uses another.
- mNextHairColorButton = new Button(_(">"), "nextcolor", this);
- // TRANSLATORS: This is a narrow symbol used to denote 'previous'.
- // You may change this symbol if your language uses another.
- mPrevHairColorButton = new Button(_("<"), "prevcolor", this);
- mHairColorLabel = new Label(_("Hair color:"));
- mHairColorNameLabel = new Label("");
- mNextHairStyleButton = new Button(_(">"), "nextstyle", this);
- mPrevHairStyleButton = new Button(_("<"), "prevstyle", this);
- mHairStyleLabel = new Label(_("Hair style:"));
- mHairStyleNameLabel = new Label("");
- mActionButton = new Button(_("^"), "action", this);
- mRotateButton = new Button(_(">"), "rotate", this);
if (serverVersion >= 2)
{
@@ -127,12 +139,6 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
mRaceNameLabel = new Label("");
}
- mCreateButton = new Button(_("Create"), "create", this);
- mCancelButton = new Button(_("Cancel"), "cancel", this);
- mMale = new RadioButton(_("Male"), "gender");
- mFemale = new RadioButton(_("Female"), "gender");
- mOther = new RadioButton(_("Other"), "gender");
-
// Default to a Male character
mMale->setSelected(true);
@@ -144,14 +150,11 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
mFemale->addActionListener(this);
mOther->addActionListener(this);
- mPlayerBox = new PlayerBox(mPlayer, "charcreate_playerbox.xml");
mPlayerBox->setWidth(74);
mNameField->setActionEventId("create");
mNameField->addActionListener(this);
- mAttributesLeft = new Label(
- strprintf(_("Please distribute %d points"), 99));
const int w = 480;
const int h = 350;
diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h
index 048363452..83521e301 100644
--- a/src/gui/charcreatedialog.h
+++ b/src/gui/charcreatedialog.h
@@ -135,12 +135,13 @@ class CharCreateDialog : public Window,
gcn::Button *mCreateButton;
gcn::Button *mCancelButton;
+ int mRace;
+
Being *mPlayer;
PlayerBox *mPlayerBox;
int mHairStyle;
int mHairColor;
- int mRace;
int mSlot;
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 829d45d14..6a4de9432 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -132,23 +132,24 @@ class CharacterDisplay : public Container
CharSelectDialog::CharSelectDialog(LoginData *const data):
Window(_("Account and Character Management"), false, nullptr, "char.xml"),
+ ActionListener(),
+ KeyListener(),
mLocked(false),
+ mLoginData(data),
+ mAccountNameLabel(new Label(mLoginData->username)),
+ mLastLoginLabel(new Label(mLoginData->lastLogin)),
+ mSwitchLoginButton(new Button(_("Switch Login"), "switch", this)),
+ mChangePasswordButton(new Button(_("Change Password"),
+ "change_password", this)),
mUnregisterButton(nullptr),
mChangeEmailButton(nullptr),
mCharacterEntries(0),
- mLoginData(data),
mCharHandler(Net::getCharHandler()),
mDeleteDialog(nullptr),
mDeleteIndex(-1)
{
setCloseButton(false);
- mAccountNameLabel = new Label(mLoginData->username);
- mLastLoginLabel = new Label(mLoginData->lastLogin);
- mSwitchLoginButton = new Button(_("Switch Login"), "switch", this);
- mChangePasswordButton = new Button(_("Change Password"), "change_password",
- this);
-
const int optionalActions = Net::getLoginHandler()
->supportedOptionalActions();
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index 0522566f1..398909f8a 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -110,6 +110,8 @@ class CharSelectDialog : public Window,
bool mLocked;
+ LoginData *mLoginData;
+
gcn::Label *mAccountNameLabel;
gcn::Label *mLastLoginLabel;
@@ -121,8 +123,6 @@ class CharSelectDialog : public Window,
/** The player boxes */
std::vector<CharacterDisplay*> mCharacterEntries;
- LoginData *mLoginData;
-
Net::CharHandler *mCharHandler;
TextDialog *mDeleteDialog;
int mDeleteIndex;