summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/changeemaildialog.cpp6
-rw-r--r--src/gui/changepassworddialog.cpp6
-rw-r--r--src/gui/charselectdialog.cpp14
-rw-r--r--src/gui/charselectdialog.h1
-rw-r--r--src/gui/connectiondialog.cpp3
-rw-r--r--src/gui/connectiondialog.h2
-rw-r--r--src/gui/debugwindow.cpp1
-rw-r--r--src/gui/login.cpp13
-rw-r--r--src/gui/login.h2
-rw-r--r--src/gui/palette.cpp2
-rw-r--r--src/gui/quitdialog.cpp14
-rw-r--r--src/gui/recorder.cpp4
-rw-r--r--src/gui/register.cpp8
-rw-r--r--src/gui/serverdialog.cpp11
-rw-r--r--src/gui/unregisterdialog.cpp6
-rw-r--r--src/gui/updatewindow.cpp17
-rw-r--r--src/gui/viewport.cpp2
-rw-r--r--src/gui/widgets/avatarlistbox.cpp2
-rw-r--r--src/gui/worldselectdialog.cpp8
19 files changed, 66 insertions, 56 deletions
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index d31d569f..b8edb5f6 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -21,7 +21,7 @@
#include "gui/changeemaildialog.h"
-#include "main.h"
+#include "client.h"
#include "log.h"
#include "gui/register.h"
@@ -104,7 +104,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "cancel")
{
- state = STATE_CHAR_SELECT;
+ Client::setState(STATE_CHAR_SELECT);
}
else if (event.getId() == "change_email")
{
@@ -162,7 +162,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
mChangeEmailButton->setEnabled(false);
// Set the new email address
mLoginData->email = newFirstEmail;
- state = STATE_CHANGEEMAIL_ATTEMPT;
+ Client::setState(STATE_CHANGEEMAIL_ATTEMPT);
}
}
}
diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp
index 7ad15db1..5f7c03f9 100644
--- a/src/gui/changepassworddialog.cpp
+++ b/src/gui/changepassworddialog.cpp
@@ -21,7 +21,7 @@
#include "changepassworddialog.h"
-#include "main.h"
+#include "client.h"
#include "log.h"
#include "gui/register.h"
@@ -85,7 +85,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "cancel")
{
- state = STATE_CHAR_SELECT;
+ Client::setState(STATE_CHAR_SELECT);
}
else if (event.getId() == "change_password")
{
@@ -156,7 +156,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
// Set the new password
mLoginData->password = oldPassword;
mLoginData->newPassword = newFirstPass;
- state = STATE_CHANGEPASSWORD_ATTEMPT;
+ Client::setState(STATE_CHANGEPASSWORD_ATTEMPT);
}
}
}
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index ca525285..c2c63248 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -21,9 +21,9 @@
#include "gui/charselectdialog.h"
+#include "client.h"
#include "game.h"
#include "localplayer.h"
-#include "main.h"
#include "units.h"
#include "log.h"
@@ -179,7 +179,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event)
// Check if a button of a character was pressed
const gcn::Widget *sourceParent = event.getSource()->getParent();
int selected = -1;
- for (unsigned i = 0; i < MAX_CHARACTER_COUNT; ++i)
+ for (int i = 0; i < MAX_CHARACTER_COUNT; ++i)
if (mCharacterEntries[i] == sourceParent)
selected = i;
@@ -206,19 +206,19 @@ void CharSelectDialog::action(const gcn::ActionEvent &event)
}
else if (eventId == "switch")
{
- state = STATE_SWITCH_LOGIN;
+ Client::setState(STATE_SWITCH_LOGIN);
}
else if (eventId == "change_password")
{
- state = STATE_CHANGEPASSWORD;
+ Client::setState(STATE_CHANGEPASSWORD);
}
else if (eventId == "change_email")
{
- state = STATE_CHANGEEMAIL;
+ Client::setState(STATE_CHANGEEMAIL);
}
else if (eventId == "unregister")
{
- state = STATE_UNREGISTER;
+ Client::setState(STATE_UNREGISTER);
}
}
@@ -308,7 +308,7 @@ bool CharSelectDialog::selectByName(const std::string &name,
if (mLocked)
return false;
- for (unsigned i = 0; i < MAX_CHARACTER_COUNT; ++i) {
+ for (int i = 0; i < MAX_CHARACTER_COUNT; ++i) {
if (Net::Character *character = mCharacterEntries[i]->getCharacter()) {
if (character->dummy->getName() == name) {
mCharacterEntries[i]->requestFocus();
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index 5a21566f..b6e71715 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -100,6 +100,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener,
gcn::Button *mUnregisterButton;
gcn::Button *mChangeEmailButton;
+ enum { MAX_CHARACTER_COUNT = 3 };
CharacterDisplay *mCharacterEntries[MAX_CHARACTER_COUNT];
LoginData *mLoginData;
diff --git a/src/gui/connectiondialog.cpp b/src/gui/connectiondialog.cpp
index 7d474247..0ef14d5a 100644
--- a/src/gui/connectiondialog.cpp
+++ b/src/gui/connectiondialog.cpp
@@ -21,7 +21,6 @@
#include "connectiondialog.h"
-#include "main.h"
#include "log.h"
#include "gui/widgets/button.h"
@@ -56,7 +55,7 @@ ConnectionDialog::ConnectionDialog(const std::string &text,
void ConnectionDialog::action(const gcn::ActionEvent &)
{
logger->log("Cancel pressed");
- state = mCancelState;
+ Client::setState(mCancelState);
}
void ConnectionDialog::draw(gcn::Graphics *graphics)
diff --git a/src/gui/connectiondialog.h b/src/gui/connectiondialog.h
index 0f826c9a..623a6645 100644
--- a/src/gui/connectiondialog.h
+++ b/src/gui/connectiondialog.h
@@ -22,7 +22,7 @@
#ifndef CONNECTION_H
#define CONNECTION_H
-#include "main.h"
+#include "client.h"
#include "gui/widgets/window.h"
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 317ca93b..2ad0ba4a 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -21,6 +21,7 @@
#include "gui/debugwindow.h"
+#include "client.h"
#include "game.h"
#include "particle.h"
#include "main.h"
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 20a48a44..9eb3f2c0 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -21,7 +21,7 @@
#include "gui/login.h"
-#include "main.h"
+#include "client.h"
#include "configuration.h"
#include "gui/okdialog.h"
@@ -107,18 +107,19 @@ void LoginDialog::action(const gcn::ActionEvent &event)
mRegisterButton->setEnabled(false);
mServerButton->setEnabled(false);
mLoginButton->setEnabled(false);
- state = STATE_LOGIN_ATTEMPT;
+
+ Client::setState(STATE_LOGIN_ATTEMPT);
}
else if (event.getId() == "server")
{
- state = STATE_SWITCH_SERVER;
+ Client::setState(STATE_SWITCH_SERVER);
}
else if (event.getId() == "register")
{
mLoginData->username = mUserField->getText();
mLoginData->password = mPassField->getText();
- state = STATE_REGISTER_PREP;
+ Client::setState(STATE_REGISTER_PREP);
}
}
@@ -140,9 +141,9 @@ void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent)
}
}
-bool LoginDialog::canSubmit()
+bool LoginDialog::canSubmit() const
{
return !mUserField->getText().empty() &&
!mPassField->getText().empty() &&
- state == STATE_LOGIN;
+ Client::getState() == STATE_LOGIN;
}
diff --git a/src/gui/login.h b/src/gui/login.h
index b26ba776..93bae338 100644
--- a/src/gui/login.h
+++ b/src/gui/login.h
@@ -66,7 +66,7 @@ class LoginDialog : public Window, public gcn::ActionListener,
* Returns whether submit can be enabled. This is true in the login
* state, when all necessary fields have some text.
*/
- bool canSubmit();
+ bool canSubmit() const;
gcn::TextField *mUserField;
gcn::TextField *mPassField;
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index b853a8f5..e7c49c89 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -23,7 +23,7 @@
#include "palette.h"
#include "configuration.h"
-#include "game.h"
+#include "client.h"
#include "gui/gui.h"
diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp
index 0645dd7f..6ecc62a6 100644
--- a/src/gui/quitdialog.cpp
+++ b/src/gui/quitdialog.cpp
@@ -21,7 +21,7 @@
#include "gui/quitdialog.h"
-#include "main.h"
+#include "client.h"
#include "gui/sdlinput.h"
@@ -50,7 +50,9 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe):
ContainerPlacer place = getPlacer(0, 0);
- //All states, when we're not logged in to someone.
+ const State state = Client::getState();
+
+ // All states, when we're not logged in to someone.
if (state == STATE_CHOOSE_SERVER ||
state == STATE_CONNECT_SERVER ||
state == STATE_LOGIN ||
@@ -106,19 +108,19 @@ void QuitDialog::action(const gcn::ActionEvent &event)
{
if (mForceQuit->isSelected())
{
- state = STATE_FORCE_QUIT;
+ Client::setState(STATE_FORCE_QUIT);
}
else if (mLogoutQuit->isSelected())
{
- state = STATE_EXIT;
+ Client::setState(STATE_EXIT);
}
else if (mSwitchAccountServer->isSelected())
{
- state = STATE_SWITCH_SERVER;
+ Client::setState(STATE_SWITCH_SERVER);
}
else if (mSwitchCharacter->isSelected())
{
- assert(state == STATE_GAME);
+ assert(Client::getState() == STATE_GAME);
Net::getCharHandler()->switchCharacter();
}
diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp
index 5bb02844..7cb6e055 100644
--- a/src/gui/recorder.cpp
+++ b/src/gui/recorder.cpp
@@ -20,7 +20,7 @@
#include "gui/recorder.h"
-#include "main.h"
+#include "client.h"
#include "gui/chat.h"
@@ -102,7 +102,7 @@ void Recorder::setRecordingFile(const std::string &msg)
* recorded.
*/
localChatTab->chatLog(_("Starting to record..."), BY_SERVER);
- const std::string file = std::string(getHomeDirectory() + msgCopy);
+ const std::string file = Client::getHomeDirectory() + msgCopy;
mStream.open(file.c_str(), std::ios_base::trunc);
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index dd863483..9fbd8cc8 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -21,9 +21,9 @@
#include "gui/register.h"
+#include "client.h"
#include "configuration.h"
#include "log.h"
-#include "main.h"
#include "gui/login.h"
#include "gui/okdialog.h"
@@ -144,7 +144,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "cancel")
{
- state = STATE_LOGIN;
+ Client::setState(STATE_LOGIN);
}
else if (event.getId() == "register" && canSubmit())
{
@@ -232,7 +232,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
mLoginData->email = mEmailField->getText();
mLoginData->registerLogin = true;
- state = STATE_REGISTER_ATTEMPT;
+ Client::setState(STATE_REGISTER_ATTEMPT);
}
}
}
@@ -247,5 +247,5 @@ bool RegisterDialog::canSubmit() const
return !mUserField->getText().empty() &&
!mPasswordField->getText().empty() &&
!mConfirmField->getText().empty() &&
- state == STATE_REGISTER;
+ Client::getState() == STATE_REGISTER;
}
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 091197c5..f439420b 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -21,9 +21,9 @@
#include "gui/serverdialog.h"
+#include "client.h"
#include "configuration.h"
#include "log.h"
-#include "main.h"
#include "gui/okdialog.h"
#include "gui/sdlinput.h"
@@ -149,7 +149,8 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
currentServer.hostname = config.getValue(currentConfig, "");
currentConfig = "MostUsedServerPort" + toString(i);
- currentServer.port = (short) config.getValue(currentConfig, DEFAULT_PORT);
+ currentServer.port = (short) config.getValue(currentConfig,
+ DEFAULT_PORT);
currentConfig = "MostUsedServerType" + toString(i);
currentServer.type = stringToServerType(config
@@ -308,13 +309,13 @@ void ServerDialog::action(const gcn::ActionEvent &event)
mServerInfo->hostname = currentServer.hostname;
mServerInfo->port = currentServer.port;
mServerInfo->type = currentServer.type;
- state = STATE_CONNECT_SERVER;
+ Client::setState(STATE_CONNECT_SERVER);
}
}
else if (event.getId() == "quit")
{
mDownload->cancel();
- state = STATE_FORCE_QUIT;
+ Client::setState(STATE_FORCE_QUIT);
}
else if (event.getId() == "addEntry")
{
@@ -328,7 +329,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
if (key.getValue() == Key::ESCAPE)
{
- state = STATE_EXIT;
+ Client::setState(STATE_EXIT);
}
else if (key.getValue() == Key::ENTER)
{
diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp
index 97b3bf76..8601e76b 100644
--- a/src/gui/unregisterdialog.cpp
+++ b/src/gui/unregisterdialog.cpp
@@ -21,7 +21,7 @@
#include "gui/unregisterdialog.h"
-#include "main.h"
+#include "client.h"
#include "log.h"
#include "gui/okdialog.h"
@@ -95,7 +95,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "cancel")
{
- state = STATE_CHAR_SELECT;
+ Client::setState(STATE_CHAR_SELECT);
}
else if (event.getId() == "unregister")
{
@@ -138,7 +138,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event)
// No errors detected, unregister the new user.
mUnRegisterButton->setEnabled(false);
mLoginData->password = password;
- state = STATE_UNREGISTER_ATTEMPT;
+ Client::setState(STATE_UNREGISTER_ATTEMPT);
}
}
}
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 1d5f001a..743f3936 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -21,9 +21,9 @@
#include "gui/updatewindow.h"
+#include "client.h"
#include "configuration.h"
#include "log.h"
-#include "main.h"
#include "gui/sdlinput.h"
@@ -223,7 +223,7 @@ void UpdaterWindow::action(const gcn::ActionEvent &event)
}
else if (event.getId() == "play")
{
- state = STATE_LOAD_DATA;
+ Client::setState(STATE_LOAD_DATA);
}
}
@@ -234,7 +234,7 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent)
if (key.getValue() == Key::ESCAPE)
{
action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId()));
- state = STATE_WORLD_SELECT;
+ Client::setState(STATE_WORLD_SELECT);
}
else if (key.getValue() == Key::ENTER)
{
@@ -296,15 +296,18 @@ int UpdaterWindow::updateProgress(void *ptr, DownloadStatus status,
float progress = (float) dn / dt;
- if (progress != progress) progress = 0.0f; // check for NaN
- if (progress < 0.0f) progress = 0.0f; // no idea how this could ever happen, but why not check for it anyway.
- if (progress > 1.0f) progress = 1.0f;
+ if (progress != progress)
+ progress = 0.0f; // check for NaN
+ if (progress < 0.0f)
+ progress = 0.0f; // no idea how this could ever happen, but why not check for it anyway.
+ if (progress > 1.0f)
+ progress = 1.0f;
uw->setLabel(
uw->mCurrentFile + " (" + toString((int) (progress * 100)) + "%)");
uw->setProgress(progress);
- if (state != STATE_UPDATE || uw->mDownloadStatus == UPDATE_ERROR)
+ if (Client::getState() != STATE_UPDATE || uw->mDownloadStatus == UPDATE_ERROR)
{
// If the action was canceled return an error code to stop the mThread
return -1;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 8320e7b1..b51d4878 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -21,10 +21,10 @@
#include "gui/viewport.h"
+#include "client.h"
#include "beingmanager.h"
#include "configuration.h"
#include "flooritemmanager.h"
-#include "game.h"
#include "graphics.h"
#include "keyboardconfig.h"
#include "localplayer.h"
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 9cbc7030..cf6dd6f5 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -29,6 +29,8 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "utils/stringutils.h"
+
#include <guichan/font.hpp>
int AvatarListBox::instances = 0;
diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp
index ac229302..3219b83d 100644
--- a/src/gui/worldselectdialog.cpp
+++ b/src/gui/worldselectdialog.cpp
@@ -21,7 +21,7 @@
#include "gui/worldselectdialog.h"
-#include "main.h"
+#include "client.h"
#include "gui/sdlinput.h"
@@ -115,12 +115,12 @@ void WorldSelectDialog::action(const gcn::ActionEvent &event)
Net::getLoginHandler()->chooseServer(mWorldList->getSelected());
// Check in case netcode moves us forward
- if (state == STATE_WORLD_SELECT)
- state = STATE_WORLD_SELECT_ATTEMPT;
+ if (Client::getState() == STATE_WORLD_SELECT)
+ Client::setState(STATE_WORLD_SELECT_ATTEMPT);
}
else if (event.getId() == "login")
{
- state = STATE_LOGIN;
+ Client::setState(STATE_LOGIN);
}
}