summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2009-10-04 00:36:46 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2009-10-04 00:36:46 +0200
commiteb22b66b0821e49ed550d30d20d9db5af535e6a3 (patch)
treea54ee9996bf235741f95945fd81be99a6e686eca /src/gui
parent076bcc1f8361c705d7dbe9088b18cca7d7fe21de (diff)
downloadmana-client-eb22b66b0821e49ed550d30d20d9db5af535e6a3.tar.gz
mana-client-eb22b66b0821e49ed550d30d20d9db5af535e6a3.tar.bz2
mana-client-eb22b66b0821e49ed550d30d20d9db5af535e6a3.tar.xz
mana-client-eb22b66b0821e49ed550d30d20d9db5af535e6a3.zip
Replaced setNetworkOptions with LoginHandler::supportedOptionalActions
Better to ask when needed that rely on static booleans to be set from somewhere. Also tried to fix the layouting a bit, but it's still not perfect.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/changeemaildialog.cpp3
-rw-r--r--src/gui/changepassworddialog.cpp1
-rw-r--r--src/gui/changepassworddialog.h3
-rw-r--r--src/gui/charselectdialog.cpp65
-rw-r--r--src/gui/charselectdialog.h31
-rw-r--r--src/gui/widgets/layout.h8
6 files changed, 46 insertions, 65 deletions
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index 62d2a3f7..15e54895 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -99,8 +99,7 @@ ChangeEmailDialog::~ChangeEmailDialog()
delete mWrongDataNoticeListener;
}
-void
-ChangeEmailDialog::action(const gcn::ActionEvent &event)
+void ChangeEmailDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "cancel")
{
diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp
index 9d66d13a..cabccc8f 100644
--- a/src/gui/changepassworddialog.cpp
+++ b/src/gui/changepassworddialog.cpp
@@ -156,6 +156,5 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
state = STATE_CHANGEPASSWORD_ATTEMPT;
scheduleDelete();
}
-
}
}
diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h
index 18c13606..17c628db 100644
--- a/src/gui/changepassworddialog.h
+++ b/src/gui/changepassworddialog.h
@@ -37,7 +37,8 @@ class WrongDataNoticeListener;
*
* \ingroup Interface
*/
-class ChangePasswordDialog : public Window, public gcn::ActionListener {
+class ChangePasswordDialog : public Window, public gcn::ActionListener
+{
public:
/**
* Constructor
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 6407e05e..13dc8dd6 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -49,6 +49,7 @@
#include "net/charhandler.h"
#include "net/logindata.h"
+#include "net/loginhandler.h"
#include "net/messageout.h"
#include "net/net.h"
@@ -112,25 +113,19 @@ class CharEntry : public Container
Button *mButton;
};
-bool CharSelectDialog::doAllowUnregister = true;
-bool CharSelectDialog::doAllowChangeEmail = true;
-
CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo,
LoginData *loginData):
Window(_("Account and Character Management")),
mCharInfo(charInfo),
- mLoginData(loginData)
+ mLoginData(loginData),
+ mCharHandler(Net::getCharHandler())
{
setCloseButton(false);
mAccountNameLabel = new Label(loginData->username);
-
mSwitchLoginButton = new Button(_("Switch Login"), "switch", this);
- mUnregisterButton = new Button(_("Unregister"), "unregister", this);
-
mChangePasswordButton = new Button(_("Change Password"), "change_password",
this);
- mChangeEmailButton = new Button(_("Change Email"), "change_email", this);
for (int i = 0; i < MAX_CHARACTER_COUNT; i++)
{
@@ -138,33 +133,34 @@ CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo,
mCharEntries[i] = new CharEntry(this, i, charInfo->getEntry());
}
- place(0, 0, mAccountNameLabel, 6);
+ int optionalActions = Net::getLoginHandler()->supportedOptionalActions();
- place(0, 1, mSwitchLoginButton, 3);
+ ContainerPlacer place;
+ place = getPlacer(0, 0);
- if (doAllowUnregister)
- place(3, 1, mUnregisterButton, 3);
+ place(0, 0, mAccountNameLabel, 2);
+ place(0, 1, mSwitchLoginButton);
- place(0, 2, mChangePasswordButton, 3);
+ if (optionalActions & Net::LoginHandler::Unregister) {
+ gcn::Button *unregisterButton = new Button(_("Unregister"),
+ "unregister", this);
+ place(3, 1, unregisterButton);
+ }
- if (doAllowChangeEmail)
- place(3, 2, mChangeEmailButton, 3);
+ place(0, 2, mChangePasswordButton);
- place(0, 3, mCharEntries[0], 2, 3);
- place(2, 3, mCharEntries[1], 2, 3);
- place(4, 3, mCharEntries[2], 2, 3);
+ if (optionalActions & Net::LoginHandler::ChangeEmail) {
+ gcn::Button *changeEmailButton = new Button(_("Change Email"),
+ "change_email", this);
+ place(3, 2, changeEmailButton);
+ }
- int width = mAccountNameLabel->getWidth();
- width = std::max(width, mSwitchLoginButton->getWidth() +
- mUnregisterButton->getWidth());
- width = std::max(width, mChangePasswordButton->getWidth() +
- mChangeEmailButton->getWidth());
- width = std::max(width, 3 * mCharEntries[0]->getWidth());
+ place = getPlacer(0, 1);
+ place(0, 0, mCharEntries[0]);
+ place(1, 0, mCharEntries[1]);
+ place(2, 0, mCharEntries[2]);
- reflowLayout(width + 10, mAccountNameLabel->getHeight() +
- mSwitchLoginButton->getHeight() +
- mChangePasswordButton->getHeight() +
- mCharEntries[0]->getHeight() + 20);
+ reflowLayout();
center();
mCharEntries[0]->requestFocus();
@@ -195,7 +191,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event)
// Start new character dialog
CharCreateDialog *charCreateDialog =
new CharCreateDialog(this, mCharInfo->getPos());
- Net::getCharHandler()->setCharCreateDialog(charCreateDialog);
+ mCharHandler->setCharCreateDialog(charCreateDialog);
}
}
else if (event.getId() == "delete")
@@ -221,13 +217,13 @@ void CharSelectDialog::action(const gcn::ActionEvent &event)
void CharSelectDialog::attemptCharDelete()
{
- Net::getCharHandler()->deleteCharacter(mCharInfo->getPos(), mCharInfo->getEntry());
+ mCharHandler->deleteCharacter(mCharInfo->getPos(), mCharInfo->getEntry());
mCharInfo->lock();
}
void CharSelectDialog::attemptCharSelect()
{
- Net::getCharHandler()->chooseCharacter(mCharInfo->getPos(), mCharInfo->getEntry());
+ mCharHandler->chooseCharacter(mCharInfo->getPos(), mCharInfo->getEntry());
mCharInfo->lock();
}
@@ -266,13 +262,6 @@ void CharSelectDialog::chooseSelected()
attemptCharSelect();
}
-void CharSelectDialog::setNetworkOptions(bool allowUnregister,
- bool allowChangeEmail)
-{
- doAllowUnregister = allowUnregister;
- doAllowChangeEmail = allowChangeEmail;
-}
-
CharEntry::CharEntry(CharSelectDialog *m, char slot, LocalPlayer *chr):
mSlot(slot),
mCharacter(chr),
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index e1c8071e..0bb8e27f 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -36,6 +36,10 @@ class LocalPlayer;
class LoginData;
class PlayerBox;
+namespace Net {
+class CharHandler;
+}
+
/**
* Character selection dialog.
*
@@ -58,34 +62,29 @@ class CharSelectDialog : public Window, public gcn::ActionListener
void chooseSelected();
- static void setNetworkOptions(bool allowUnregister,
- bool allowChangeEmail);
-
private:
+ /**
+ * Communicate character deletion to the server.
+ */
+ void attemptCharDelete();
+
+ /**
+ * Communicate character selection to the server.
+ */
+ void attemptCharSelect();
+
LockedArray<LocalPlayer*> *mCharInfo;
gcn::Label *mAccountNameLabel;
gcn::Button *mSwitchLoginButton;
gcn::Button *mChangePasswordButton;
- gcn::Button *mChangeEmailButton;
- gcn::Button *mUnregisterButton;
CharEntry *mCharEntries[MAX_CHARACTER_COUNT];
LoginData *mLoginData;
- /**
- * Communicate character deletion to the server.
- */
- void attemptCharDelete();
-
- /**
- * Communicate character selection to the server.
- */
- void attemptCharSelect();
-
- static bool doAllowUnregister, doAllowChangeEmail;
+ Net::CharHandler *mCharHandler;
};
#endif
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
index b9359e91..994c25fe 100644
--- a/src/gui/widgets/layout.h
+++ b/src/gui/widgets/layout.h
@@ -34,7 +34,6 @@ class LayoutCell;
class ContainerPlacer
{
public:
-
ContainerPlacer(gcn::Container *c = NULL, LayoutCell *l = NULL):
mContainer(c), mCell(l)
{}
@@ -58,7 +57,6 @@ class ContainerPlacer
(int x, int y, gcn::Widget *, int w = 1, int h = 1);
private:
-
gcn::Container *mContainer;
LayoutCell *mCell;
};
@@ -164,7 +162,6 @@ class LayoutCell
friend class LayoutArray;
public:
-
enum Alignment
{
LEFT, RIGHT, CENTER, FILL
@@ -235,7 +232,6 @@ class LayoutCell
void computeSizes();
private:
-
// Copy not allowed, as the cell may own an array.
LayoutCell(LayoutCell const &);
LayoutCell &operator=(LayoutCell const &);
@@ -283,10 +279,9 @@ class LayoutCell
* pixels between rows and between columns, and a margin of 6 pixels around the
* whole layout.
*/
-class Layout: public LayoutCell
+class Layout : public LayoutCell
{
public:
-
Layout();
/**
@@ -313,7 +308,6 @@ class Layout: public LayoutCell
};
private:
-
bool mComputed;
};