From aff167beefadc32add4b44626cc2f1cbef800c7b Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 30 Jul 2006 14:33:28 +0000 Subject: Updated TMW to be compatible with Guichan 0.5.0 (merged from guichan-0.5.0 branch). --- src/gui/register.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/register.h') diff --git a/src/gui/register.h b/src/gui/register.h index b46eb1ce..5d3f6cd5 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -56,7 +56,7 @@ class RegisterDialog : public Window, public gcn::ActionListener { /** * Called when receiving actions from the widgets. */ - void action(const std::string& eventId); + void action(const std::string& eventId, gcn::Widget* widget); // Made them public to have the possibility to request focus // from external functions. -- cgit v1.2.3-70-g09d2 From 25fe73f89756cb4102f97bcccdb8635a6a56f35d Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Wed, 2 Aug 2006 09:43:57 +0000 Subject: Ported account registration to tmwserv. There's still a disconnection/reconnection between registration and login. --- ChangeLog | 8 ++++++++ src/gui/char_select.cpp | 14 ++++++-------- src/gui/char_select.h | 7 ++----- src/gui/register.cpp | 20 +++++++++++++++----- src/gui/register.h | 1 + src/logindata.h | 2 +- src/main.cpp | 28 ++++++++++++++++++++++++---- src/main.h | 1 + src/net/charserverhandler.cpp | 2 -- src/net/loginhandler.cpp | 34 ++++++++++++++++++++++++++++++++++ src/net/protocol.h | 7 +++++++ 11 files changed, 99 insertions(+), 25 deletions(-) (limited to 'src/gui/register.h') diff --git a/ChangeLog b/ChangeLog index d6049d68..45cd2a9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-08-02 Eugenio Favalli + + * src/gui/char_select.cpp, src/gui/char_select.h, src/gui/register.cpp, + src/gui/register.h, src/logindata.h, src/main.cpp, src/main.h, + src/net/charserverhandler.cpp, src/net/loginhandler.cpp, + src/net/protocol.h: Ported account registration to tmwserv. There's + still a disconnection/reconnection between registration and login. + 2006-08-01 Bjørn Lindeijer * configure.ac: Moved some basic checks above the checks on the diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 934988f4..27b5b55a 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -70,10 +70,9 @@ void CharDeleteConfirm::action(const std::string &eventId, gcn::Widget *widget) } CharSelectDialog::CharSelectDialog(Network *network, - LockedArray *charInfo, - unsigned char sex): + LockedArray *charInfo): Window("Select Character"), mNetwork(network), - mCharInfo(charInfo), mSex(sex), mCharSelected(false) + mCharInfo(charInfo), mCharSelected(false) { mSelectButton = new Button("Ok", "ok", this); mCancelButton = new Button("Cancel", "cancel", this); @@ -86,7 +85,7 @@ CharSelectDialog::CharSelectDialog(Network *network, mLevelLabel = new gcn::Label("Level"); mJobLevelLabel = new gcn::Label("Job Level"); mMoneyLabel = new gcn::Label("Money"); - mPlayerBox = new PlayerBox(sex); + mPlayerBox = new PlayerBox(0); int w = 195; int h = 220; @@ -149,7 +148,7 @@ void CharSelectDialog::action(const std::string &eventId, gcn::Widget *widget) { // Start new character dialog mCharInfo->lock(); - new CharCreateDialog(this, mCharInfo->getPos(), mNetwork, mSex); + new CharCreateDialog(this, mCharInfo->getPos(), mNetwork); mCharInfo->unlock(); } } @@ -228,8 +227,7 @@ void CharSelectDialog::logic() updatePlayerInfo(); } -CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network, - unsigned char sex): +CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network): Window("Create Character", true, parent), mNetwork(network), mSlot(slot) { mNameField = new TextField(""); @@ -242,7 +240,7 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network, mHairStyleLabel = new gcn::Label("Hair Style:"); mCreateButton = new Button("Create", "create", this); mCancelButton = new Button("Cancel", "cancel", this); - mPlayerBox = new PlayerBox(sex); + mPlayerBox = new PlayerBox(0); mPlayerBox->mShowPlayer = true; mNameField->setEventId("create"); diff --git a/src/gui/char_select.h b/src/gui/char_select.h index 20105516..3bf9911e 100644 --- a/src/gui/char_select.h +++ b/src/gui/char_select.h @@ -48,8 +48,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener * Constructor. */ CharSelectDialog(Network *network, - LockedArray *charInfo, - unsigned char sex); + LockedArray *charInfo); void action(const std::string& eventId, gcn::Widget* widget); @@ -75,7 +74,6 @@ class CharSelectDialog : public Window, public gcn::ActionListener PlayerBox *mPlayerBox; - unsigned char mSex; bool mCharSelected; /** @@ -100,8 +98,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener /** * Constructor. */ - CharCreateDialog(Window *parent, int slot, Network *network, - unsigned char sex); + CharCreateDialog(Window *parent, int slot, Network *network); void action(const std::string& eventId, gcn::Widget* widget); diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 38136b87..82e5f716 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -50,10 +50,12 @@ RegisterDialog::RegisterDialog(LoginData *loginData): gcn::Label *userLabel = new gcn::Label("Name:"); gcn::Label *passwordLabel = new gcn::Label("Password:"); gcn::Label *confirmLabel = new gcn::Label("Confirm:"); + gcn::Label *emailLabel = new gcn::Label("Email:"); gcn::Label *serverLabel = new gcn::Label("Server:"); mUserField = new TextField("player"); mPasswordField = new PasswordField(); mConfirmField = new PasswordField(); + mEmailField = new TextField(); mServerField = new TextField(); mMaleButton = new RadioButton("Male", "sex", true); mFemaleButton = new RadioButton("Female", "sex", false); @@ -61,7 +63,7 @@ RegisterDialog::RegisterDialog(LoginData *loginData): mCancelButton = new Button("Cancel", "cancel", this); int width = 200; - int height = 150; + int height = 170; setContentSize(width, height); mUserField->setPosition(65, 5); @@ -72,17 +74,21 @@ RegisterDialog::RegisterDialog(LoginData *loginData): mConfirmField->setPosition( 65, mPasswordField->getY() + mPasswordField->getHeight() + 7); mConfirmField->setWidth(130); + mEmailField->setPosition( + 65, mConfirmField->getY() + mConfirmField->getHeight() + 7); + mEmailField->setWidth(130); mServerField->setPosition( - 65, 23 + mConfirmField->getY() + mConfirmField->getHeight() + 7); + 65, 23 + mEmailField->getY() + mEmailField->getHeight() + 7); mServerField->setWidth(130); userLabel->setPosition(5, mUserField->getY() + 1); passwordLabel->setPosition(5, mPasswordField->getY() + 1); confirmLabel->setPosition(5, mConfirmField->getY() + 1); + emailLabel->setPosition(5, mEmailField->getY() + 1); serverLabel->setPosition(5, mServerField->getY() + 1); mFemaleButton->setPosition(width - mFemaleButton->getWidth() - 10, - mConfirmField->getY() + mConfirmField->getHeight() + 7); + mEmailField->getY() + mEmailField->getHeight() + 7); mMaleButton->setPosition(mFemaleButton->getX() - mMaleButton->getWidth() - 5, mFemaleButton->getY()); @@ -92,11 +98,13 @@ RegisterDialog::RegisterDialog(LoginData *loginData): add(userLabel); add(passwordLabel); + add(emailLabel); add(serverLabel); add(confirmLabel); add(mUserField); add(mPasswordField); add(mConfirmField); + add(mEmailField); add(mServerField); add(mMaleButton); add(mFemaleButton); @@ -176,6 +184,8 @@ RegisterDialog::action(const std::string &eventId, gcn::Widget *widget) error = 2; } + // TODO: Check if a valid email address was given + if (error > 0) { if (error == 1) @@ -202,9 +212,9 @@ RegisterDialog::action(const std::string &eventId, gcn::Widget *widget) mLoginData->port = (short)config.getValue("port", 0); mLoginData->username = mUserField->getText(); mLoginData->password = mPasswordField->getText(); - mLoginData->username += mFemaleButton->isMarked() ? "_F" : "_M"; + mLoginData->email = mEmailField->getText(); - state = ACCOUNT_STATE; + state = REGISTER_ACCOUNT_STATE; } } } diff --git a/src/gui/register.h b/src/gui/register.h index 5d3f6cd5..30dacd3e 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -65,6 +65,7 @@ class RegisterDialog : public Window, public gcn::ActionListener { gcn::TextField *mUserField; gcn::TextField *mPasswordField; gcn::TextField *mConfirmField; + gcn::TextField *mEmailField; gcn::TextField *mServerField; gcn::Button *mRegisterButton; diff --git a/src/logindata.h b/src/logindata.h index f4fcd1b1..70b80bb7 100644 --- a/src/logindata.h +++ b/src/logindata.h @@ -29,12 +29,12 @@ struct LoginData std::string username; std::string password; std::string hostname; + std::string email; short port; int account_ID; int session_ID1; int session_ID2; - char sex; bool remember; }; diff --git a/src/main.cpp b/src/main.cpp index 1bec709f..ce68b7bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -447,6 +447,25 @@ void accountLogin(Network *network, LoginData *loginData) config.setValue("remember", loginData->remember); } +void accountRegister(Network *network, LoginData *loginData) +{ + logger->log("Trying to connect to account server..."); + logger->log("Username is %s", loginData->username.c_str()); + network->connect(loginData->hostname, loginData->port); + network->registerHandler(&loginHandler); + loginHandler.setCharInfo(&charInfo); + loginHandler.setLoginData(loginData); + + // Send login infos + MessageOut *msg = new MessageOut(); + msg->writeShort(PAMSG_REGISTER); + msg->writeLong(0); // client version + msg->writeString(loginData->username); + msg->writeString(loginData->password); + msg->writeString(loginData->email); + network->send(msg); +} + void mapLogin(Network *network, LoginData *loginData) { MessageOut outMsg; @@ -463,7 +482,6 @@ void mapLogin(Network *network, LoginData *loginData) outMsg.writeLong(player_node->mCharId); outMsg.writeLong(loginData->session_ID1); outMsg.writeLong(loginData->session_ID2); - outMsg.writeByte(loginData->sex); } /** Main */ @@ -629,8 +647,7 @@ int main(int argc, char *argv[]) case CHAR_SELECT_STATE: logger->log("State: CHAR_SELECT"); - currentDialog = new CharSelectDialog(network, &charInfo, - 1 - loginData.sex); + currentDialog = new CharSelectDialog(network, &charInfo); if (options.chooseDefault) { ((CharSelectDialog*)currentDialog)->action("ok", NULL); @@ -672,10 +689,13 @@ int main(int argc, char *argv[]) break; case ACCOUNT_STATE: - printf("Account: %i\n", loginData.sex); accountLogin(network, &loginData); break; + case REGISTER_ACCOUNT_STATE: + accountRegister(network, &loginData); + break; + default: state = EXIT_STATE; break; diff --git a/src/main.h b/src/main.h index f8bfb4d9..035b0ec7 100644 --- a/src/main.h +++ b/src/main.h @@ -43,6 +43,7 @@ enum { LOGIN_STATE, ACCOUNT_STATE, REGISTER_STATE, + REGISTER_ACCOUNT_STATE, CHAR_CONNECT_STATE, CHAR_SERVER_STATE, CHAR_SELECT_STATE, diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index 932a6fbc..36a17acf 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -159,8 +159,6 @@ void CharServerHandler::handleMessage(MessageIn *msg) LocalPlayer* CharServerHandler::readPlayerData(MessageIn *msg, int &slot) { LocalPlayer *tempPlayer = new LocalPlayer(mLoginData->account_ID, 0, NULL); - tempPlayer->setSex(1 - mLoginData->sex); - tempPlayer->mCharId = msg->readLong(); tempPlayer->mTotalWeight = 0; tempPlayer->mMaxWeight = 0; diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index 5b8fbd1f..ebc8f535 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -36,6 +36,7 @@ LoginHandler::LoginHandler() { static const Uint16 _messages[] = { APMSG_LOGIN_RESPONSE, + APMSG_REGISTER_RESPONSE, 0 }; handledMessages = _messages; @@ -46,6 +47,7 @@ void LoginHandler::handleMessage(MessageIn *msg) switch (msg->getId()) { case APMSG_LOGIN_RESPONSE: + { int errMsg = msg->readByte(); // Successful login if (errMsg == ERRMSG_OK) @@ -90,6 +92,38 @@ void LoginHandler::handleMessage(MessageIn *msg) } state = ERROR_STATE; } + } + break; + case APMSG_REGISTER_RESPONSE: + { + int errMsg = msg->readByte(); + // Successful registration + if (errMsg == ERRMSG_OK) + { + state = ACCOUNT_STATE; + } + // Registration failed + else { + switch (errMsg) { + case REGISTER_INVALID_VERSION: + errorMessage = "Client has an insufficient version number to login."; + break; + case ERRMSG_INVALID_ARGUMENT: + errorMessage = "Wrong username, password or email address"; + break; + case REGISTER_EXISTS_USERNAME: + errorMessage = "Username already exists"; + break; + case REGISTER_EXISTS_EMAIL: + errorMessage = "Email address already exists"; + break; + default: + errorMessage = "Unknown error"; + break; + } + state = ERROR_STATE; + } + } break; } } diff --git a/src/net/protocol.h b/src/net/protocol.h index 6a13bbd9..6db3762e 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -200,6 +200,13 @@ enum { LOGIN_SERVER_FULL // the server is overloaded }; +// Account register specific return values +enum { + REGISTER_INVALID_VERSION = 0x40, // the user is using an incompatible protocol + REGISTER_EXISTS_USERNAME, // there already is an account with this username + REGISTER_EXISTS_EMAIL // there already is an account with this email address +}; + /** Encodes coords and direction in 3 bytes data */ void set_coordinates(char *data, unsigned short x, unsigned short y, unsigned char direction); -- cgit v1.2.3-70-g09d2 From 2f55e567a965bd315f191b51986038b2daf45525 Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Wed, 2 Aug 2006 10:23:25 +0000 Subject: Removed sex choice. --- ChangeLog | 2 ++ src/gui/gui.cpp | 3 +++ src/gui/register.cpp | 13 ++----------- src/gui/register.h | 2 -- 4 files changed, 7 insertions(+), 13 deletions(-) (limited to 'src/gui/register.h') diff --git a/ChangeLog b/ChangeLog index 45cd2a9a..1648f018 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ src/net/charserverhandler.cpp, src/net/loginhandler.cpp, src/net/protocol.h: Ported account registration to tmwserv. There's still a disconnection/reconnection between registration and login. + * src/gui/gui.cpp, src/register.cpp, src/register.h: Removed sex + choice. 2006-08-01 Bjørn Lindeijer diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 1638f94e..88998f7a 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -27,6 +27,9 @@ #include #include + +// Moved up because of nested inclusion of winnt.h which defines DELETE +// constant as well as guichan does #include #ifdef USE_OPENGL diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 82e5f716..49da10b6 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -57,13 +57,11 @@ RegisterDialog::RegisterDialog(LoginData *loginData): mConfirmField = new PasswordField(); mEmailField = new TextField(); mServerField = new TextField(); - mMaleButton = new RadioButton("Male", "sex", true); - mFemaleButton = new RadioButton("Female", "sex", false); mRegisterButton = new Button("Register", "register", this); mCancelButton = new Button("Cancel", "cancel", this); int width = 200; - int height = 170; + int height = 150; setContentSize(width, height); mUserField->setPosition(65, 5); @@ -78,7 +76,7 @@ RegisterDialog::RegisterDialog(LoginData *loginData): 65, mConfirmField->getY() + mConfirmField->getHeight() + 7); mEmailField->setWidth(130); mServerField->setPosition( - 65, 23 + mEmailField->getY() + mEmailField->getHeight() + 7); + 65, 8 + mEmailField->getY() + mEmailField->getHeight() + 7); mServerField->setWidth(130); userLabel->setPosition(5, mUserField->getY() + 1); @@ -87,11 +85,6 @@ RegisterDialog::RegisterDialog(LoginData *loginData): emailLabel->setPosition(5, mEmailField->getY() + 1); serverLabel->setPosition(5, mServerField->getY() + 1); - mFemaleButton->setPosition(width - mFemaleButton->getWidth() - 10, - mEmailField->getY() + mEmailField->getHeight() + 7); - mMaleButton->setPosition(mFemaleButton->getX() - mMaleButton->getWidth() - 5, - mFemaleButton->getY()); - mRegisterButton->setPosition(5, height - mRegisterButton->getHeight() - 5); mCancelButton->setPosition(10 + mRegisterButton->getWidth(), mRegisterButton->getY()); @@ -106,8 +99,6 @@ RegisterDialog::RegisterDialog(LoginData *loginData): add(mConfirmField); add(mEmailField); add(mServerField); - add(mMaleButton); - add(mFemaleButton); add(mRegisterButton); add(mCancelButton); diff --git a/src/gui/register.h b/src/gui/register.h index 30dacd3e..72a32bb0 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -70,8 +70,6 @@ class RegisterDialog : public Window, public gcn::ActionListener { gcn::Button *mRegisterButton; gcn::Button *mCancelButton; - gcn::RadioButton *mMaleButton; - gcn::RadioButton *mFemaleButton; WrongDataNoticeListener *mWrongDataNoticeListener; OkDialog *mWrongRegisterNotice; -- cgit v1.2.3-70-g09d2 From 97cdacdaf3cfa0970597483d41838906125886bc Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 27 Aug 2006 14:43:31 +0000 Subject: Got rid of server input field since connecting to the account server now happens before the login and register dialogs. --- ChangeLog | 4 ++++ src/gui/login.cpp | 25 +++++++------------------ src/gui/login.h | 1 - src/gui/register.cpp | 24 ++++++++---------------- src/gui/register.h | 1 - 5 files changed, 19 insertions(+), 36 deletions(-) (limited to 'src/gui/register.h') diff --git a/ChangeLog b/ChangeLog index 9382ee08..92b35668 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,10 @@ * src/net/protocol.cpp, src/net/protocol.h, src/net/messagein.cpp, src/net/playerhandler.cpp, src/Makefile.am: Got rid of no longer used protocol.cpp. + * src/gui/login.cpp, src/gui/register.h, src/gui/login.h, + src/gui/register.cpp: Got rid of server input field since connecting + to the account server now happens before the login and register + dialogs. 2006-08-27 Guillaume Melquiond diff --git a/src/gui/login.cpp b/src/gui/login.cpp index cb16dcb4..1d9b6e1e 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -59,53 +59,43 @@ LoginDialog::LoginDialog(LoginData *loginData): { gcn::Label *userLabel = new gcn::Label("Name:"); gcn::Label *passLabel = new gcn::Label("Password:"); - gcn::Label *serverLabel = new gcn::Label("Server:"); mUserField = new TextField(mLoginData->username); mPassField = new PasswordField(mLoginData->password); - mServerField = new TextField(mLoginData->hostname); mKeepCheck = new CheckBox("Keep", mLoginData->remember); mOkButton = new Button("OK", "ok", this); mCancelButton = new Button("Cancel", "cancel", this); mRegisterButton = new Button("Register", "register", this); - setContentSize(200, 100); + setContentSize(200, 91); userLabel->setPosition(5, 5); passLabel->setPosition(5, 14 + userLabel->getHeight()); - serverLabel->setPosition( - 5, 23 + userLabel->getHeight() + passLabel->getHeight()); mUserField->setPosition(65, 5); mPassField->setPosition(65, 14 + userLabel->getHeight()); - mServerField->setPosition( - 65, 23 + userLabel->getHeight() + passLabel->getHeight()); mUserField->setWidth(130); mPassField->setWidth(130); - mServerField->setWidth(130); - mKeepCheck->setPosition(4, 77); + mKeepCheck->setPosition(4, 68); mCancelButton->setPosition( 200 - mCancelButton->getWidth() - 5, - 100 - mCancelButton->getHeight() - 5); + 91 - mCancelButton->getHeight() - 5); mOkButton->setPosition( mCancelButton->getX() - mOkButton->getWidth() - 5, - 100 - mOkButton->getHeight() - 5); - mRegisterButton->setPosition(mKeepCheck->getX() + mKeepCheck->getWidth() + 10, - 100 - mRegisterButton->getHeight() - 5); + 91 - mOkButton->getHeight() - 5); + mRegisterButton->setPosition( + mKeepCheck->getX() + mKeepCheck->getWidth() + 10, + 91 - mRegisterButton->getHeight() - 5); mUserField->setEventId("ok"); mPassField->setEventId("ok"); - mServerField->setEventId("ok"); mUserField->addActionListener(this); mPassField->addActionListener(this); - mServerField->addActionListener(this); mKeepCheck->addActionListener(this); add(userLabel); add(passLabel); - add(serverLabel); add(mUserField); add(mPassField); - add(mServerField); add(mKeepCheck); add(mOkButton); add(mCancelButton); @@ -141,7 +131,6 @@ LoginDialog::action(const std::string &eventId, gcn::Widget *widget) } else { - mLoginData->hostname = mServerField->getText(); mLoginData->username = mUserField->getText(); mLoginData->password = mPassField->getText(); mLoginData->remember = mKeepCheck->isMarked(); diff --git a/src/gui/login.h b/src/gui/login.h index 7218dca8..6d510da7 100644 --- a/src/gui/login.h +++ b/src/gui/login.h @@ -70,7 +70,6 @@ class LoginDialog : public Window, public gcn::ActionListener { private: gcn::TextField *mUserField; gcn::TextField *mPassField; - gcn::TextField *mServerField; gcn::CheckBox *mKeepCheck; gcn::Button *mOkButton; gcn::Button *mCancelButton; diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 8004d30e..00880352 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -51,17 +51,15 @@ RegisterDialog::RegisterDialog(LoginData *loginData): gcn::Label *passwordLabel = new gcn::Label("Password:"); gcn::Label *confirmLabel = new gcn::Label("Confirm:"); gcn::Label *emailLabel = new gcn::Label("Email:"); - gcn::Label *serverLabel = new gcn::Label("Server:"); mUserField = new TextField("player"); mPasswordField = new PasswordField(); mConfirmField = new PasswordField(); mEmailField = new TextField(); - mServerField = new TextField(); mRegisterButton = new Button("Register", "register", this); mCancelButton = new Button("Cancel", "cancel", this); - int width = 200; - int height = 150; + const int width = 200; + const int height = 130; setContentSize(width, height); mUserField->setPosition(65, 5); @@ -75,38 +73,33 @@ RegisterDialog::RegisterDialog(LoginData *loginData): mEmailField->setPosition( 65, mConfirmField->getY() + mConfirmField->getHeight() + 7); mEmailField->setWidth(130); - mServerField->setPosition( - 65, 8 + mEmailField->getY() + mEmailField->getHeight() + 7); - mServerField->setWidth(130); userLabel->setPosition(5, mUserField->getY() + 1); passwordLabel->setPosition(5, mPasswordField->getY() + 1); confirmLabel->setPosition(5, mConfirmField->getY() + 1); emailLabel->setPosition(5, mEmailField->getY() + 1); - serverLabel->setPosition(5, mServerField->getY() + 1); - mRegisterButton->setPosition(5, height - mRegisterButton->getHeight() - 5); - mCancelButton->setPosition(10 + mRegisterButton->getWidth(), - mRegisterButton->getY()); + mCancelButton->setPosition( + width - 5 - mCancelButton->getWidth(), + height - 5 - mCancelButton->getHeight()); + mRegisterButton->setPosition( + mCancelButton->getX() - 5 - mRegisterButton->getWidth(), + mCancelButton->getY()); add(userLabel); add(passwordLabel); add(emailLabel); - add(serverLabel); add(confirmLabel); add(mUserField); add(mPasswordField); add(mConfirmField); add(mEmailField); - add(mServerField); add(mRegisterButton); add(mCancelButton); setLocationRelativeTo(getParent()); mUserField->requestFocus(); mUserField->setCaretPosition(mUserField->getText().length()); - - mServerField->setText(config.getValue("host", "")); } RegisterDialog::~RegisterDialog() @@ -199,7 +192,6 @@ RegisterDialog::action(const std::string &eventId, gcn::Widget *widget) // No errors detected, register the new user. mRegisterButton->setEnabled(false); - mLoginData->hostname = config.getValue("host", "animesites.de"); mLoginData->port = (short)config.getValue("port", 0); mLoginData->username = mUserField->getText(); mLoginData->password = mPasswordField->getText(); diff --git a/src/gui/register.h b/src/gui/register.h index 72a32bb0..8551b9e0 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -66,7 +66,6 @@ class RegisterDialog : public Window, public gcn::ActionListener { gcn::TextField *mPasswordField; gcn::TextField *mConfirmField; gcn::TextField *mEmailField; - gcn::TextField *mServerField; gcn::Button *mRegisterButton; gcn::Button *mCancelButton; -- cgit v1.2.3-70-g09d2 From 29f07d2f98b82674708f1185f26ed3c482992b04 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Thu, 2 Nov 2006 14:11:03 +0000 Subject: Fixed a memory leak and a double deletion. --- ChangeLog | 2 ++ src/gui/register.cpp | 8 +++----- src/gui/register.h | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src/gui/register.h') diff --git a/ChangeLog b/ChangeLog index 25688adb..a650bcb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2006-11-02 Björn Steinbrink + * src/gui/register.cpp, src/gui/register.h: Fixed a memory leak and a + double deletion. * src/main.cpp, src/CMakeLists.txt, src/net/loginhandler.cpp, src/net/charserverhandler.h, src/net/maploginhandler.h, src/net/maploginhandler.cpp, src/net/loginhandler.h, src/Makefile.am: diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 00880352..7cef62a2 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -44,7 +44,6 @@ RegisterDialog::RegisterDialog(LoginData *loginData): Window("Register"), mWrongDataNoticeListener(new WrongDataNoticeListener()), - mWrongRegisterNotice(0), mLoginData(loginData) { gcn::Label *userLabel = new gcn::Label("Name:"); @@ -104,7 +103,7 @@ RegisterDialog::RegisterDialog(LoginData *loginData): RegisterDialog::~RegisterDialog() { - delete mWrongRegisterNotice; + delete mWrongDataNoticeListener; } void @@ -183,9 +182,8 @@ RegisterDialog::action(const std::string &eventId, gcn::Widget *widget) mConfirmField->setText(""); } - delete mWrongRegisterNotice; - mWrongRegisterNotice = new OkDialog("Error", errorMsg.str()); - mWrongRegisterNotice->addActionListener(mWrongDataNoticeListener); + OkDialog *dlg = new OkDialog("Error", errorMsg.str()); + dlg->addActionListener(mWrongDataNoticeListener); } else { diff --git a/src/gui/register.h b/src/gui/register.h index 8551b9e0..4c98788f 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -71,7 +71,6 @@ class RegisterDialog : public Window, public gcn::ActionListener { gcn::Button *mCancelButton; WrongDataNoticeListener *mWrongDataNoticeListener; - OkDialog *mWrongRegisterNotice; LoginData *mLoginData; }; -- cgit v1.2.3-70-g09d2 From d1395845cdc678db2a71326f2e6f20253ed14cac Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 14 Jan 2007 16:45:13 +0000 Subject: Merged 0.0 changes from revision 2988 to 3035 to trunk. --- ChangeLog | 86 ++++++++++++++++++++++-- src/game.cpp | 19 +++--- src/gui/browserbox.cpp | 15 +++-- src/gui/browserbox.h | 10 +-- src/gui/buddywindow.cpp | 8 +-- src/gui/buddywindow.h | 2 +- src/gui/button.cpp | 9 +-- src/gui/button.h | 2 +- src/gui/buy.cpp | 16 ++--- src/gui/buy.h | 2 +- src/gui/buysell.cpp | 8 +-- src/gui/buysell.h | 2 +- src/gui/char_select.cpp | 40 +++++------ src/gui/char_select.h | 4 +- src/gui/chat.cpp | 15 +++-- src/gui/chat.h | 11 +-- src/gui/chatinput.cpp | 2 +- src/gui/chatinput.h | 2 +- src/gui/confirm_dialog.cpp | 7 +- src/gui/confirm_dialog.h | 2 +- src/gui/connection.cpp | 8 ++- src/gui/debugwindow.cpp | 16 +++-- src/gui/debugwindow.h | 2 +- src/gui/gccontainer.cpp | 6 +- src/gui/gccontainer.h | 9 ++- src/gui/help.cpp | 4 +- src/gui/help.h | 2 +- src/gui/inttextbox.cpp | 7 +- src/gui/inttextbox.h | 3 +- src/gui/inventorywindow.cpp | 20 +++--- src/gui/inventorywindow.h | 6 +- src/gui/item_amount.cpp | 20 +++--- src/gui/item_amount.h | 2 +- src/gui/itemcontainer.cpp | 35 ++++++---- src/gui/itemcontainer.h | 2 +- src/gui/listbox.cpp | 33 ++------- src/gui/listbox.h | 6 +- src/gui/login.cpp | 16 ++--- src/gui/login.h | 4 +- src/gui/menuwindow.cpp | 14 ++-- src/gui/newskill.cpp | 24 +++---- src/gui/newskill.h | 2 +- src/gui/npc_text.cpp | 4 +- src/gui/npc_text.h | 2 +- src/gui/npclistdialog.cpp | 8 +-- src/gui/npclistdialog.h | 2 +- src/gui/ok_dialog.cpp | 6 +- src/gui/ok_dialog.h | 2 +- src/gui/playerbox.cpp | 1 - src/gui/register.cpp | 6 +- src/gui/register.h | 2 +- src/gui/sell.cpp | 18 ++--- src/gui/sell.h | 2 +- src/gui/serverdialog.cpp | 23 ++++--- src/gui/serverdialog.h | 5 +- src/gui/setup.cpp | 8 +-- src/gui/setup.h | 2 +- src/gui/setup_audio.cpp | 10 +-- src/gui/setup_audio.h | 2 +- src/gui/setup_joystick.cpp | 5 +- src/gui/setup_joystick.h | 2 +- src/gui/setup_video.cpp | 49 +++++++------- src/gui/setup_video.h | 5 +- src/gui/shoplistbox.cpp | 6 +- src/gui/shoplistbox.h | 2 +- src/gui/skill.cpp | 10 +-- src/gui/skill.h | 2 +- src/gui/status.cpp | 4 +- src/gui/status.h | 2 +- src/gui/tabbedcontainer.cpp | 4 +- src/gui/tabbedcontainer.h | 2 +- src/gui/trade.cpp | 10 +-- src/gui/trade.h | 2 +- src/gui/updatewindow.cpp | 6 +- src/gui/updatewindow.h | 2 +- src/gui/viewport.cpp | 28 ++++---- src/gui/viewport.h | 28 ++++++-- src/gui/window.cpp | 121 +++++++++++---------------------- src/gui/window.h | 19 +++--- src/main.cpp | 10 +-- src/net/playerhandler.cpp | 4 +- src/net/tradehandler.cpp | 4 +- tools/Purger.java | 159 -------------------------------------------- 83 files changed, 495 insertions(+), 597 deletions(-) delete mode 100644 tools/Purger.java (limited to 'src/gui/register.h') diff --git a/ChangeLog b/ChangeLog index 0cbbb214..d091a061 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,53 @@ +2007-01-14 Bjørn Lindeijer + + * src/game.cpp, src/main.cpp, src/gui/trade.cpp, src/gui/sell.cpp, + src/gui/connection.cpp, src/gui/buddywindow.cpp, src/gui/browserbox.h, + src/gui/char_server.cpp, src/gui/window.cpp, src/gui/login.cpp, + src/gui/inttextbox.h, src/gui/viewport.cpp, src/gui/button.h, + src/gui/shoplistbox.h, src/gui/skill.h, src/gui/item_amount.h, + src/gui/setup_audio.h, src/gui/newskill.cpp, src/gui/listbox.h, + src/gui/register.h, src/gui/setup.cpp, src/gui/npclistdialog.h, + src/gui/updatewindow.cpp, src/gui/button.cpp, src/gui/char_select.cpp, + src/gui/login.h, src/gui/setup_audio.cpp, src/gui/item_amount.cpp, + src/gui/setup_joystick.h, src/gui/chat.h, src/gui/npc_text.cpp, + src/gui/setup_video.cpp, src/gui/ok_dialog.cpp, + src/gui/inventorywindow.h, src/gui/gccontainer.cpp, + src/gui/newskill.h, src/gui/buy.h, src/gui/setup.h, + src/gui/itemcontainer.h, src/gui/confirm_dialog.cpp, + src/gui/debugwindow.cpp, src/gui/chat.cpp, src/gui/setup_joystick.cpp, + src/gui/updatewindow.h, src/gui/char_select.h, src/gui/buysell.h, + src/gui/tabbedcontainer.cpp, src/gui/inventorywindow.cpp, + src/gui/help.cpp, src/gui/status.h, src/gui/npc_text.h, + src/gui/setup_video.h, src/gui/menuwindow.cpp, src/gui/browserbox.cpp, + src/gui/ok_dialog.h, src/gui/buy.cpp, src/gui/itemcontainer.cpp, + src/gui/gccontainer.h, src/gui/buddywindow.h, src/gui/sell.h, + src/gui/trade.h, src/gui/inttextbox.cpp, src/gui/char_server.h, + src/gui/window.h, src/gui/shoplistbox.cpp, src/gui/skill.cpp, + src/gui/buysell.cpp, src/gui/confirm_dialog.h, src/gui/debugwindow.h, + src/gui/status.cpp, src/gui/listbox.cpp, src/gui/register.cpp, + src/gui/viewport.h, src/gui/tabbedcontainer.h, + src/gui/npclistdialog.cpp, src/gui/help.h, src/gui/chatinput.h, + src/gui/chatinput.cpp, src/net/tradehandler.cpp, + src/net/playerhandler.cpp: Upgraded to Guichan 0.6.0 (merge from + guichan-0.6.0 branch). + +2007-01-13 Bjørn Lindeijer + + * data/graphics/sprites/Makefile.am, + data/graphics/sprites/CMakeLists.txt: Updated with regard to renaming + of cotton equipment. + +2006-01-13 Eugenio Favalli + + * src/gui/debugwindow.cpp, src/gui/viewport.h: Fixed mouse coordinates + display in debug window. + +2007-01-12 Bjørn Lindeijer + + * src/gui/viewport.cpp: Fixed initialization of mPlayerFollowMouse, + the lack of which sometimes caused the player to start walking when + clicking on the GUI. + 2007-01-11 Björn Steinbrink * data/graphics/images/ambient/CMakeLists.txt, @@ -7,23 +57,43 @@ 2007-01-11 Rogier Polak * src/gui/char_select.cpp, src/net/accountserver/account.h, - src/net/accountserver/account.cpp, src/player.cpp: Fixedd issues + src/net/accountserver/account.cpp, src/player.cpp: Fixed issues with out of range hair style and color, as well as their ordering. * data/graphics/gui/Makefile.am, data/graphics/images/ambient/Makefile.am, data/graphics/sprites/Makefile.am: Some corrections to installed files. +2007-01-09 Philipp Sehmisch + + * data/graphics/icecave.png: Added new tiles and fixes by Nickman and + made some other cosmetical corrections. + 2007-01-07 Bjørn Lindeijer + * data/graphics/sprites/monster-mountsnake.xml, + data/graphics/sprites/monster-mountsnake.png, data/monsters.xml: Added + brown snake by Pauan. * src/gui/status.h, src/gui/status.cpp, src/localplayer.h: Synchronized player attributes with Attributes page on the wiki. Removed job xp bar. +2007-01-07 Philipp Sehmisch + + * data/graphics/chest-cottonshirt-male.png, + data/graphics/chest-cottonshirt-male.xml, + data/graphics/chest-cottonshirt-female.png, + data/graphics/chest-cottonshirt-female.xml, + data/graphics/item001.png, data/equipment.xml: Added female + cottonshirt sprites. + * data/equipment.xml: Fixed some wrong armor values. + 2007-01-05 Björn Steinbrink * src/CMakeLists.txt, data/graphics/sprites/CMakeLists.txt: Fixed installation when using CMake. + * src/CMakeLists.txt, data/graphics/images/ambient/Makefile.am, + data/graphics/sprites/CMakeLists.txt: Synchronized build files. 2007-01-05 Guillaume Melquiond @@ -36,6 +106,10 @@ * src/map.cpp, src/map.h: Declared some methods const. +2007-01-04 Eugenio Favalli + + * tools/Purger.java: Removed purger tool. + 2007-01-03 Guillaume Melquiond * src/resources/mapreader.cpp: Fixed memory leak on error. @@ -285,11 +359,11 @@ 2006-12-09 Bjørn Lindeijer * src/sprite.h, src/gui/playerbox.h, src/gui/char_select.cpp, - src/gui/playerbox.cpp, src/gui/passwordfield.h,src/gui/char_select.h, - src/gui/textfield.h, src/main.cpp, src/being.cpp, src/player.h, - src/floor_item.h, src/being.h: Use new animation system in character - selection/creation. Shows equipment and allowed for some cleanup. Had - a bit of help from the patch by VictorSan. + src/gui/playerbox.cpp, src/gui/passwordfield.h, src/gui/char_select.h, + src/main.cpp, src/being.cpp, src/player.h, src/floor_item.h, + src/being.h: Use new animation system in character selection/creation. + Shows equipment and allowed for some cleanup. Had a bit of help from + the patch by VictorSan. 2006-12-08 Bjørn Lindeijer diff --git a/src/game.cpp b/src/game.cpp index 2af13146..40d78248 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -124,9 +124,11 @@ const int MAX_TIME = 10000; * Listener used for exitting handling. */ namespace { - struct ExitListener : public gcn::ActionListener { - void action(const std::string &eventId, gcn::Widget *widget) { - if (eventId == "yes") { + struct ExitListener : public gcn::ActionListener + { + void action(const gcn::ActionEvent &event) + { + if (event.getId() == "yes") { done = true; } exitConfirm = NULL; @@ -386,10 +388,6 @@ void Game::logic() void Game::handleInput() { - // Get the state of the keyboard keys - Uint8* keys; - keys = SDL_GetKeyState(NULL); - if (joystick != NULL) { joystick->update(); @@ -455,7 +453,7 @@ void Game::handleInput() // Close the config window, cancelling changes if opened else if (setupWindow->isVisible()) { - setupWindow->action("cancel", NULL); + setupWindow->action(gcn::ActionEvent(NULL, "cancel")); } // Else, open the chat edit box else @@ -633,7 +631,12 @@ void Game::handleInput() current_npc == 0 && !chatWindow->isFocused()) { + // Get the state of the keyboard keys + Uint8* keys; + keys = SDL_GetKeyState(NULL); + Uint16 x = player_node->mX / 32, y = player_node->mY / 32; + unsigned char direction = 0; // Translate pressed keys to movement and direction diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 2aec84a5..65fdde64 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -98,7 +98,7 @@ void BrowserBox::disableLinksAndUserColors() mUseLinksAndUserColors = false; } -void BrowserBox::addRow(const std::string& row) +void BrowserBox::addRow(const std::string &row) { std::string tmp = row; std::string newRow; @@ -238,25 +238,28 @@ struct MouseOverLink int mX, mY; }; -void BrowserBox::mousePress(int mx, int my, int button) +void +BrowserBox::mousePressed(gcn::MouseEvent &event) { LinkIterator i = find_if(mLinks.begin(), mLinks.end(), - MouseOverLink(mx, my)); + MouseOverLink(event.getX(), event.getY())); if (i != mLinks.end()) { mLinkHandler->handleLink(i->link); } } -void BrowserBox::mouseMotion(int mx, int my) +void +BrowserBox::mouseMoved(gcn::MouseEvent &event) { LinkIterator i = find_if(mLinks.begin(), mLinks.end(), - MouseOverLink(mx, my)); + MouseOverLink(event.getX(), event.getY())); mSelectedLink = (i != mLinks.end()) ? (i - mLinks.begin()) : -1; } -void BrowserBox::draw(gcn::Graphics* graphics) +void +BrowserBox::draw(gcn::Graphics *graphics) { if (mOpaque) { diff --git a/src/gui/browserbox.h b/src/gui/browserbox.h index a2c9dd9b..666a7754 100644 --- a/src/gui/browserbox.h +++ b/src/gui/browserbox.h @@ -61,7 +61,7 @@ class BrowserBox : public gcn::Widget, public gcn::MouseListener /** * Sets the handler for links. */ - void setLinkHandler(LinkHandler* linkHandler); + void setLinkHandler(LinkHandler *linkHandler); /** * Sets the BrowserBox opacity. @@ -81,7 +81,7 @@ class BrowserBox : public gcn::Widget, public gcn::MouseListener /** * Adds a text row to the browser. */ - void addRow(const std::string& row); + void addRow(const std::string &row); /** * Remove all rows. @@ -91,13 +91,13 @@ class BrowserBox : public gcn::Widget, public gcn::MouseListener /** * Handles mouse actions. */ - void mousePress(int mx, int my, int button); - void mouseMotion(int mx, int my); + void mousePressed(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event); /** * Draws the browser box. */ - void draw(gcn::Graphics* graphics); + void draw(gcn::Graphics *graphics); /** * BrowserBox modes. diff --git a/src/gui/buddywindow.cpp b/src/gui/buddywindow.cpp index 145f0ad2..0ed383ce 100644 --- a/src/gui/buddywindow.cpp +++ b/src/gui/buddywindow.cpp @@ -61,9 +61,9 @@ BuddyWindow::BuddyWindow(): add(cancel); } -void BuddyWindow::action(const std::string &eventId, gcn::Widget *widget) +void BuddyWindow::action(const gcn::ActionEvent &event) { - if (eventId == "Talk") { + if (event.getId() == "Talk") { int selected = mListbox->getSelected(); if ( selected > -1 ) { @@ -71,7 +71,7 @@ void BuddyWindow::action(const std::string &eventId, gcn::Widget *widget) chatWindow->setInputText(who +": "); } } - else if (eventId == "Remove") { + else if (event.getId() == "Remove") { int selected = mListbox->getSelected(); if ( selected > -1 ) { @@ -79,7 +79,7 @@ void BuddyWindow::action(const std::string &eventId, gcn::Widget *widget) mBuddyList->removeBuddy(who); } } - else if (eventId == "Cancel") { + else if (event.getId() == "Cancel") { setVisible(false); } } diff --git a/src/gui/buddywindow.h b/src/gui/buddywindow.h index 8764d008..a3ca4de2 100644 --- a/src/gui/buddywindow.h +++ b/src/gui/buddywindow.h @@ -48,7 +48,7 @@ class BuddyWindow : public Window, public gcn::ActionListener /** * Performs action. */ - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); private: BuddyList *mBuddyList; diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 31f38593..0055c89a 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -37,7 +37,7 @@ ImageRect Button::button[4]; int Button::mInstances = 0; -Button::Button(const std::string& caption, const std::string &eventId, +Button::Button(const std::string& caption, const std::string &actionEventId, gcn::ActionListener *listener): gcn::Button(caption) { @@ -73,7 +73,7 @@ Button::Button(const std::string& caption, const std::string &eventId, } mInstances++; - setEventId(eventId); + setActionEventId(actionEventId); if (listener) { addActionListener(listener); } @@ -92,7 +92,8 @@ Button::~Button() } } -void Button::draw(gcn::Graphics* graphics) +void +Button::draw(gcn::Graphics *graphics) { int mode; @@ -102,7 +103,7 @@ void Button::draw(gcn::Graphics* graphics) else if (isPressed()) { mode = 2; } - else if (hasMouse()) { + else if (mHasMouse) { mode = 1; } else { diff --git a/src/gui/button.h b/src/gui/button.h index 36d8f7a1..1c2ec41b 100644 --- a/src/gui/button.h +++ b/src/gui/button.h @@ -40,7 +40,7 @@ class Button : public gcn::Button { /** * Constructor, sets the caption of the button to the given string. */ - Button(const std::string& caption, const std::string &eventId, + Button(const std::string& caption, const std::string &actionEventId, gcn::ActionListener *listener); /** diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 102dd49e..cb07da22 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -82,8 +82,8 @@ BuyDialog::BuyDialog(): mItemEffectLabel->setDimension(gcn::Rectangle(5, 150, 240, 14)); mItemDescLabel->setDimension(gcn::Rectangle(5, 169, 240, 14)); - mShopItemList->setEventId("item"); - mSlider->setEventId("slider"); + mShopItemList->setActionEventId("item"); + mSlider->setActionEventId("slider"); mShopItemList->addSelectionListener(this); mSlider->addActionListener(this); @@ -140,11 +140,11 @@ void BuyDialog::addItem(short id, int price) mShopItemList->adjustSize(); } -void BuyDialog::action(const std::string &eventId, gcn::Widget *widget) +void BuyDialog::action(const gcn::ActionEvent &event) { int selectedItem = mShopItemList->getSelected(); - if (eventId == "quit") + if (event.getId() == "quit") { setVisible(false); current_npc = 0; @@ -158,12 +158,12 @@ void BuyDialog::action(const std::string &eventId, gcn::Widget *widget) bool updateButtonsAndLabels = false; - if (eventId == "slider") + if (event.getId() == "slider") { mAmountItems = (int)(mSlider->getValue() * mMaxItems); updateButtonsAndLabels = true; } - else if (eventId == "+") + else if (event.getId() == "+") { if (mAmountItems < mMaxItems) { mAmountItems++; @@ -174,7 +174,7 @@ void BuyDialog::action(const std::string &eventId, gcn::Widget *widget) mSlider->setValue(double(mAmountItems)/double(mMaxItems)); updateButtonsAndLabels = true; } - else if (eventId == "-") + else if (event.getId() == "-") { if (mAmountItems > 0) { mAmountItems--; @@ -188,7 +188,7 @@ void BuyDialog::action(const std::string &eventId, gcn::Widget *widget) // TODO: Actually we'd have a bug elsewhere if this check for the number // of items to be bought ever fails, Bertram removed the assertions, is // there a better way to ensure this fails in an _obivous_ way in C++? - else if (eventId == "buy" && (mAmountItems > 0 && + else if (event.getId() == "buy" && (mAmountItems > 0 && mAmountItems <= mMaxItems)) { // XXX Convert for new server diff --git a/src/gui/buy.h b/src/gui/buy.h index b83b6f2f..13116b6e 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -73,7 +73,7 @@ class BuyDialog : public Window, public gcn::ActionListener, SelectionListener /** * Called when receiving actions from the widgets. */ - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); /** * Returns the number of items in the shop inventory. diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index 4bbbb2ff..ae5c7358 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -52,13 +52,13 @@ BuySellDialog::BuySellDialog(): requestFocus(); } -void BuySellDialog::action(const std::string &eventId, gcn::Widget *widget) +void BuySellDialog::action(const gcn::ActionEvent &event) { - if (eventId == "Buy") { + if (event.getId() == "Buy") { current_npc->buy(); - } else if (eventId == "Sell") { + } else if (event.getId() == "Sell") { current_npc->sell(); - } else if (eventId == "Cancel") { + } else if (event.getId() == "Cancel") { current_npc = 0; } setVisible(false); diff --git a/src/gui/buysell.h b/src/gui/buysell.h index 7a90a869..97caf34b 100644 --- a/src/gui/buysell.h +++ b/src/gui/buysell.h @@ -47,7 +47,7 @@ class BuySellDialog : public Window, public gcn::ActionListener /** * Called when receiving actions from the widgets. */ - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); }; #endif diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index ec4dad2e..4c4b99e5 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -48,7 +48,7 @@ class CharDeleteConfirm : public ConfirmDialog { public: CharDeleteConfirm(CharSelectDialog *master); - void action(const std::string &eventId, gcn::Widget *widget); + void action(const gcn::ActionEvent &event); private: CharSelectDialog *master; }; @@ -60,13 +60,13 @@ CharDeleteConfirm::CharDeleteConfirm(CharSelectDialog *m): { } -void CharDeleteConfirm::action(const std::string &eventId, gcn::Widget *widget) +void CharDeleteConfirm::action(const gcn::ActionEvent &event) { - //ConfirmDialog::action(eventId); - if (eventId == "yes") { + //ConfirmDialog::action(event); + if (event.getId() == "yes") { master->attemptCharDelete(); } - ConfirmDialog::action(eventId, widget); + ConfirmDialog::action(event); } CharSelectDialog::CharSelectDialog(LockedArray *charInfo): @@ -122,9 +122,9 @@ CharSelectDialog::CharSelectDialog(LockedArray *charInfo): updatePlayerInfo(); } -void CharSelectDialog::action(const std::string &eventId, gcn::Widget *widget) +void CharSelectDialog::action(const gcn::ActionEvent &event) { - if (eventId == "ok" && n_character > 0) + if (event.getId() == "ok" && n_character > 0) { // Start game mNewCharButton->setEnabled(false); @@ -136,11 +136,11 @@ void CharSelectDialog::action(const std::string &eventId, gcn::Widget *widget) Net::AccountServer::Account::selectCharacter(mCharInfo->getPos()); mCharInfo->lock(); } - else if (eventId == "cancel") + else if (event.getId() == "cancel") { state = STATE_EXIT; } - else if (eventId == "new") + else if (event.getId() == "new") { if (n_character < MAX_SLOT + 1) { @@ -150,7 +150,7 @@ void CharSelectDialog::action(const std::string &eventId, gcn::Widget *widget) mCharInfo->unlock(); } } - else if (eventId == "delete") + else if (event.getId() == "delete") { // Delete character if (mCharInfo->getEntry()) @@ -158,11 +158,11 @@ void CharSelectDialog::action(const std::string &eventId, gcn::Widget *widget) new CharDeleteConfirm(this); } } - else if (eventId == "previous") + else if (event.getId() == "previous") { mCharInfo->prev(); } - else if (eventId == "next") + else if (event.getId() == "next") { mCharInfo->next(); } @@ -253,7 +253,7 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot): mCancelButton = new Button("Cancel", "cancel", this); mPlayerBox = new PlayerBox(mPlayer); - mNameField->setEventId("create"); + mNameField->setActionEventId("create"); int w = 200; int h = 150; @@ -298,9 +298,9 @@ CharCreateDialog::~CharCreateDialog() delete mPlayer; } -void CharCreateDialog::action(const std::string &eventId, gcn::Widget *widget) +void CharCreateDialog::action(const gcn::ActionEvent &event) { - if (eventId == "create") { + if (event.getId() == "create") { if (getName().length() >= 4) { // Attempt to create the character mCreateButton->setEnabled(false); @@ -322,20 +322,20 @@ void CharCreateDialog::action(const std::string &eventId, gcn::Widget *widget) "Your name needs to be at least 4 characters.", this); } } - else if (eventId == "cancel") { + else if (event.getId() == "cancel") { scheduleDelete(); } - else if (eventId == "nextcolor") { + else if (event.getId() == "nextcolor") { mPlayer->setHairColor((mPlayer->getHairColor() + 1) % NR_HAIR_COLORS); } - else if (eventId == "prevcolor") { + else if (event.getId() == "prevcolor") { int prevColor = mPlayer->getHairColor() + NR_HAIR_COLORS - 1; mPlayer->setHairColor(prevColor % NR_HAIR_COLORS); } - else if (eventId == "nextstyle") { + else if (event.getId() == "nextstyle") { mPlayer->setHairStyle((mPlayer->getHairStyle() + 1) % NR_HAIR_STYLES); } - else if (eventId == "prevstyle") { + else if (event.getId() == "prevstyle") { int prevStyle = mPlayer->getHairStyle() + NR_HAIR_STYLES - 1; mPlayer->setHairStyle(prevStyle % NR_HAIR_STYLES); } diff --git a/src/gui/char_select.h b/src/gui/char_select.h index 9d2d77da..d6dee8b5 100644 --- a/src/gui/char_select.h +++ b/src/gui/char_select.h @@ -49,7 +49,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener */ CharSelectDialog(LockedArray *charInfo); - void action(const std::string &eventId, gcn::Widget *widget); + void action(const gcn::ActionEvent &event); void updatePlayerInfo(); @@ -109,7 +109,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener */ ~CharCreateDialog(); - void action(const std::string &eventId, gcn::Widget *widget); + void action(const gcn::ActionEvent &event); std::string getName(); diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 3dc252ab..d992c6dd 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -53,7 +53,7 @@ ChatWindow::ChatWindow(): loadWindowState(); mChatInput = new ChatInput(); - mChatInput->setEventId("chatinput"); + mChatInput->setActionEventId("chatinput"); mChatInput->addActionListener(this); mTextOutput = new BrowserBox(BrowserBox::AUTO_WRAP); @@ -180,9 +180,9 @@ ChatWindow::chatLog(CHATSKILL act) } void -ChatWindow::action(const std::string &eventId, gcn::Widget *widget) +ChatWindow::action(const gcn::ActionEvent &event) { - if (eventId == "chatinput") + if (event.getId() == "chatinput") { std::string message = mChatInput->getText(); @@ -360,9 +360,10 @@ ChatWindow::const_msg(CHATSKILL act) } void -ChatWindow::keyPress(const gcn::Key &key) +ChatWindow::keyPressed(gcn::KeyEvent &event) { - if (key.getValue() == key.DOWN && mCurHist != mHistory.end()) + if (event.getKey().getValue() == gcn::Key::DOWN && + mCurHist != mHistory.end()) { // Move forward through the history HistoryIterator prevHist = mCurHist++; @@ -374,8 +375,8 @@ ChatWindow::keyPress(const gcn::Key &key) mCurHist = prevHist; } } - else if (key.getValue() == key.UP && mCurHist != mHistory.begin() && - mHistory.size() > 0) + else if (event.getKey().getValue() == gcn::Key::UP && + mCurHist != mHistory.begin() && mHistory.size() > 0) { // Move backward through the history mCurHist--; diff --git a/src/gui/chat.h b/src/gui/chat.h index a0a3d1ec..963e5e98 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -138,7 +138,7 @@ class ChatWindow : public Window, public gcn::ActionListener, /** * Performs action. */ - void action(const std::string& actionId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); /** * Request focus for typing chat message. @@ -178,13 +178,16 @@ class ChatWindow : public Window, public gcn::ActionListener, chatSend(const std::string &nick, std::string msg); /** Called when key is pressed */ - void keyPress(const gcn::Key& key); + void + keyPressed(gcn::KeyEvent &event); /** Called to set current text */ - void setInputText(std::string input_str); + void + setInputText(std::string input_str); /** Override to reset mTmpVisible */ - void setVisible(bool visible); + void + setVisible(bool visible); private: bool mTmpVisible; diff --git a/src/gui/chatinput.cpp b/src/gui/chatinput.cpp index 52e91f3a..2aa5a159 100644 --- a/src/gui/chatinput.cpp +++ b/src/gui/chatinput.cpp @@ -28,7 +28,7 @@ ChatInput::ChatInput() setVisible(false); } -void ChatInput::lostFocus() +void ChatInput::focusLost() { setVisible(false); } diff --git a/src/gui/chatinput.h b/src/gui/chatinput.h index 9f543e24..59d0daf3 100644 --- a/src/gui/chatinput.h +++ b/src/gui/chatinput.h @@ -41,7 +41,7 @@ class ChatInput : public TextField * Called if the chat input loses focus. It will set itself to * invisible as result. */ - void lostFocus(); + void focusLost(); }; #endif diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp index 5a70544f..0ff8be17 100644 --- a/src/gui/confirm_dialog.cpp +++ b/src/gui/confirm_dialog.cpp @@ -65,17 +65,18 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, yesButton->requestFocus(); } -void ConfirmDialog::action(const std::string &eventId, gcn::Widget *widget) +void ConfirmDialog::action(const gcn::ActionEvent &event) { // Proxy button events to our listeners ActionListenerIterator i; for (i = mActionListeners.begin(); i != mActionListeners.end(); ++i) { - (*i)->action(eventId, widget); + (*i)->action(event); } // Can we receive anything else anyway? - if (eventId == "yes" || eventId == "no") { + if (event.getId() == "yes" || event.getId() == "no") + { scheduleDelete(); } } diff --git a/src/gui/confirm_dialog.h b/src/gui/confirm_dialog.h index 771ecc36..8728f83f 100644 --- a/src/gui/confirm_dialog.h +++ b/src/gui/confirm_dialog.h @@ -47,7 +47,7 @@ class ConfirmDialog : public Window, public gcn::ActionListener { /** * Called when receiving actions from the widgets. */ - void action(const std::string &eventId, gcn::Widget *widget); + void action(const gcn::ActionEvent &event); }; #endif diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp index 7e977f1f..3627689a 100644 --- a/src/gui/connection.cpp +++ b/src/gui/connection.cpp @@ -38,7 +38,7 @@ namespace { ConnectionActionListener(unsigned char previousState): mPreviousState(previousState) {}; - void action(const std::string &eventId, gcn::Widget *widget) { + void action(const gcn::ActionEvent &event) { state = mPreviousState; } @@ -51,9 +51,11 @@ ConnectionDialog::ConnectionDialog(unsigned char previousState): { setContentSize(200, 100); - ConnectionActionListener *connectionListener = new ConnectionActionListener(previousState); + ConnectionActionListener *connectionListener = + new ConnectionActionListener(previousState); - Button *cancelButton = new Button("Cancel", "cancelButton", connectionListener); + Button *cancelButton = new Button("Cancel", "cancelButton", + connectionListener); mProgressBar = new ProgressBar(0.0, 200 - 10, 20, 128, 128, 128); gcn::Label *label = new gcn::Label("Connecting..."); diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index f8a4154e..563f380f 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -28,6 +28,8 @@ #include #include "button.h" +#include "gui.h" +#include "viewport.h" #include "../game.h" #include "../engine.h" @@ -72,15 +74,15 @@ DebugWindow::logic() // Get the current mouse position int mouseX, mouseY; SDL_GetMouseState(&mouseX, &mouseY); - //int mouseTileX = mouseX / 32 + camera_x; - //int mouseTileY = mouseY / 32 + camera_y; + int mouseTileX = mouseX / 32 + viewport->getCameraX(); + int mouseTileY = mouseY / 32 + viewport->getCameraY(); mFPSLabel->setCaption("[" + toString(fps) + " FPS"); mFPSLabel->adjustSize(); - //mTileMouseLabel->setCaption("[Mouse: " + - // toString(mouseTileX) + ", " + toString(mouseTileY) + "]"); - //mTileMouseLabel->adjustSize(); + mTileMouseLabel->setCaption("[Mouse: " + + toString(mouseTileX) + ", " + toString(mouseTileY) + "]"); + mTileMouseLabel->adjustSize(); Map *currentMap = engine->getCurrentMap(); if (currentMap != NULL) @@ -98,9 +100,9 @@ DebugWindow::logic() } void -DebugWindow::action(const std::string &eventId, gcn::Widget *widget) +DebugWindow::action(const gcn::ActionEvent &event) { - if (eventId == "close") + if (event.getId() == "close") { setVisible(false); } diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h index 61ef44e6..4fd33d83 100644 --- a/src/gui/debugwindow.h +++ b/src/gui/debugwindow.h @@ -53,7 +53,7 @@ class DebugWindow : public Window, public gcn::ActionListener /** * Performs action. */ - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); private: gcn::Label *mMusicFileLabel, *mMapFileLabel; diff --git a/src/gui/gccontainer.cpp b/src/gui/gccontainer.cpp index 3b574622..c22ddfc9 100644 --- a/src/gui/gccontainer.cpp +++ b/src/gui/gccontainer.cpp @@ -55,8 +55,8 @@ void GCContainer::add(gcn::Widget *w, int x, int y, bool delChild) Container::add(w, x, y); } -void GCContainer::_announceDeath(gcn::Widget *w) +void GCContainer::death(const gcn::Event &event) { - mDeathList.remove(w); - Container::_announceDeath(w); + mDeathList.remove(event.getSource()); + Container::death(event); } diff --git a/src/gui/gccontainer.h b/src/gui/gccontainer.h index 46ebfefa..e27eaa96 100644 --- a/src/gui/gccontainer.h +++ b/src/gui/gccontainer.h @@ -32,9 +32,12 @@ class GCContainer : public gcn::Container { public: virtual ~GCContainer(); - virtual void add(gcn::Widget *w, bool delChild=true); - virtual void add(gcn::Widget *w, int x, int y, bool delChild=true); - virtual void _announceDeath(gcn::Widget *w); + + virtual void add(gcn::Widget *w, bool delChild = true); + + virtual void add(gcn::Widget *w, int x, int y, bool delChild = true); + + virtual void death(const gcn::Event &event); protected: typedef std::list Widgets; diff --git a/src/gui/help.cpp b/src/gui/help.cpp index e7429b29..0b010253 100644 --- a/src/gui/help.cpp +++ b/src/gui/help.cpp @@ -54,9 +54,9 @@ HelpWindow::HelpWindow(): setLocationRelativeTo(getParent()); } -void HelpWindow::action(const std::string &eventId, gcn::Widget *widget) +void HelpWindow::action(const gcn::ActionEvent &event) { - if (eventId == "close") + if (event.getId() == "close") { setVisible(false); } diff --git a/src/gui/help.h b/src/gui/help.h index 539ab31b..3c3715a0 100644 --- a/src/gui/help.h +++ b/src/gui/help.h @@ -48,7 +48,7 @@ class HelpWindow : public Window, public LinkHandler, /** * Called when receiving actions from the widgets. */ - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); /** * Handles link action. diff --git a/src/gui/inttextbox.cpp b/src/gui/inttextbox.cpp index 92f21e5f..2a09f255 100644 --- a/src/gui/inttextbox.cpp +++ b/src/gui/inttextbox.cpp @@ -32,12 +32,15 @@ IntTextBox::IntTextBox(int i): { } -void IntTextBox::keyPress(const gcn::Key &key) +void +IntTextBox::keyPressed(gcn::KeyEvent &event) { + const gcn::Key &key = event.getKey(); + if (key.isNumber() || key.getValue() == gcn::Key::BACKSPACE || key.getValue() == gcn::Key::DELETE) { - gcn::TextBox::keyPress(key); + gcn::TextBox::keyPressed(event); } std::stringstream s(gcn::TextBox::getText()); diff --git a/src/gui/inttextbox.h b/src/gui/inttextbox.h index b199cb2f..b5d339ac 100644 --- a/src/gui/inttextbox.h +++ b/src/gui/inttextbox.h @@ -55,7 +55,8 @@ class IntTextBox : public TextBox /** * Responds to key presses. */ - void keyPress(const gcn::Key &key); + void + keyPressed(gcn::KeyEvent &event); private: int mMin; /**< Minimum value */ diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 7f9ba3b9..e533c16c 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -99,7 +99,7 @@ void InventoryWindow::logic() mWeightLabel->adjustSize(); } -void InventoryWindow::action(const std::string &eventId, gcn::Widget *widget) +void InventoryWindow::action(const gcn::ActionEvent &event) { Item *item = mItems->getItem(); @@ -107,7 +107,7 @@ void InventoryWindow::action(const std::string &eventId, gcn::Widget *widget) return; } - if (eventId == "use") { + if (event.getId() == "use") { if (item->isEquipment()) { if (item->isEquipped()) { player_node->unequipItem(item); @@ -120,7 +120,7 @@ void InventoryWindow::action(const std::string &eventId, gcn::Widget *widget) player_node->useItem(item); } } - else if (eventId == "drop") + else if (event.getId() == "drop") { // Choose amount of items to drop new ItemAmountWindow(AMOUNT_ITEM_DROP, this, item); @@ -155,11 +155,11 @@ void InventoryWindow::selectionChanged(const SelectionEvent &event) } } -void InventoryWindow::mouseClick(int x, int y, int button, int count) +void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { - Window::mouseClick(x, y, button, count); + Window::mouseClicked(event); - if (button == gcn::MouseInput::RIGHT) + if (event.getButton() == gcn::MouseEvent::RIGHT) { Item *item = mItems->getItem(); @@ -168,16 +168,16 @@ void InventoryWindow::mouseClick(int x, int y, int button, int count) /* Convert relative to the window coordinates to * absolute screen coordinates. */ - int mx = x + getX(); - int my = y + getY(); + int mx = event.getX() + getX(); + int my = event.getY() + getY(); viewport->showPopup(mx, my, item); } } -void InventoryWindow::mouseMotion(int mx, int my) +void InventoryWindow::mouseDragged(gcn::MouseEvent &event) { int tmpWidth = getWidth(), tmpHeight = getHeight(); - Window::mouseMotion(mx, my); + Window::mouseDragged(event); if (getWidth() != tmpWidth || getHeight() != tmpHeight) { updateWidgets(); } diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index d46e91e7..5ee89fef 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -55,11 +55,11 @@ class InventoryWindow : public Window, gcn::ActionListener, SelectionListener /** * Called when receiving actions from the widgets. */ - void action(const std::string &eventId, gcn::Widget *widget); + void action(const gcn::ActionEvent &event); - void mouseClick(int x, int y, int button, int count); + void mouseClicked(gcn::MouseEvent &event); - void mouseMotion(int mx, int my); + void mouseDragged(gcn::MouseEvent &event); Item* getItem(); diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp index 5ebc0213..f72462f9 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -49,7 +49,7 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): mItemAmountSlide->setDimension(gcn::Rectangle(5, 120, 180, 10)); // Set button events Id - mItemAmountSlide->setEventId("Slide"); + mItemAmountSlide->setActionEventId("Slide"); // Set position mItemAmountTextBox->setPosition(35, 10); @@ -75,11 +75,11 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): switch (usage) { case AMOUNT_TRADE_ADD: setCaption("Select amount of items to trade."); - okButton->setEventId("AddTrade"); + okButton->setActionEventId("AddTrade"); break; case AMOUNT_ITEM_DROP: setCaption("Select amount of items to drop."); - okButton->setEventId("Drop"); + okButton->setActionEventId("Drop"); break; default: break; @@ -95,33 +95,33 @@ void ItemAmountWindow::resetAmount() mItemAmountTextBox->setInt(1); } -void ItemAmountWindow::action(const std::string &eventId, gcn::Widget *widget) +void ItemAmountWindow::action(const gcn::ActionEvent &event) { int amount = mItemAmountTextBox->getInt(); - if (eventId == "Cancel") + if (event.getId() == "Cancel") { scheduleDelete(); } - else if (eventId == "Drop") + else if (event.getId() == "Drop") { player_node->dropItem(mItem, mItemAmountTextBox->getInt()); scheduleDelete(); } - else if (eventId == "AddTrade") + else if (event.getId() == "AddTrade") { tradeWindow->tradeItem(mItem, mItemAmountTextBox->getInt()); scheduleDelete(); } - else if (eventId == "Plus") + else if (event.getId() == "Plus") { amount++; } - else if (eventId == "Minus") + else if (event.getId() == "Minus") { amount--; } - else if (eventId == "Slide") + else if (event.getId() == "Slide") { amount = static_cast(mItemAmountSlide->getValue()); } diff --git a/src/gui/item_amount.h b/src/gui/item_amount.h index a2a17575..01319012 100644 --- a/src/gui/item_amount.h +++ b/src/gui/item_amount.h @@ -54,7 +54,7 @@ class ItemAmountWindow : public Window, public gcn::ActionListener /** * Called when receiving actions from widget. */ - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); /** * Sets default amount value. diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 2c84b19b..308311b7 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -58,7 +58,8 @@ ItemContainer::~ItemContainer() mSelImg->decRef(); } -void ItemContainer::logic() +void +ItemContainer::logic() { gcn::Widget::logic(); @@ -70,7 +71,8 @@ void ItemContainer::logic() } } -void ItemContainer::draw(gcn::Graphics* graphics) +void +ItemContainer::draw(gcn::Graphics *graphics) { int gridWidth = 36; //(item icon width + 4) int gridHeight = 42; //(item icon height + 10) @@ -124,7 +126,8 @@ void ItemContainer::draw(gcn::Graphics* graphics) } } -void ItemContainer::setWidth(int width) +void +ItemContainer::setWidth(int width) { gcn::Widget::setWidth(width); @@ -140,17 +143,20 @@ void ItemContainer::setWidth(int width) setHeight((mMaxItems + columns - 1) / columns * gridHeight); } -Item* ItemContainer::getItem() +Item* +ItemContainer::getItem() { return mSelectedItem; } -void ItemContainer::selectNone() +void +ItemContainer::selectNone() { setSelectedItem(NULL); } -void ItemContainer::setSelectedItem(Item *item) +void +ItemContainer::setSelectedItem(Item *item) { if (mSelectedItem != item) { @@ -159,7 +165,8 @@ void ItemContainer::setSelectedItem(Item *item) } } -void ItemContainer::fireSelectionChangedEvent() +void +ItemContainer::fireSelectionChangedEvent() { SelectionEvent event(this); SelectionListeners::iterator i_end = mListeners.end(); @@ -171,14 +178,18 @@ void ItemContainer::fireSelectionChangedEvent() } } -void ItemContainer::mousePress(int mx, int my, int button) +void +ItemContainer::mousePressed(gcn::MouseEvent &event) { - int gridWidth = 36; //(item icon width + 4) - int gridHeight = 42; //(item icon height + 10) - int columns = getWidth() / gridWidth; + int button = event.getButton(); - if (button == gcn::MouseInput::LEFT || gcn::MouseInput::RIGHT) + if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT) { + int gridWidth = 36; //(item icon width + 4) + int gridHeight = 42; //(item icon height + 10) + int columns = getWidth() / gridWidth; + int mx = event.getX(); + int my = event.getY(); int index = mx / gridWidth + ((my / gridHeight) * columns); if (index > INVENTORY_SIZE) { diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index a2d5f0f7..8c548fcd 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -71,7 +71,7 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener /** * Handles mouse click. */ - void mousePress(int mx, int my, int button); + void mousePressed(gcn::MouseEvent &event); /** * Returns the selected item. diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index d4a2c6cb..a7f6df8d 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -31,8 +31,7 @@ #include ListBox::ListBox(gcn::ListModel *listModel): - gcn::ListBox(listModel), - mMousePressed(false) + gcn::ListBox(listModel) { } @@ -61,39 +60,19 @@ void ListBox::draw(gcn::Graphics *graphics) } } -void ListBox::setSelected(int selected) +void +ListBox::setSelected(int selected) { gcn::ListBox::setSelected(selected); fireSelectionChangedEvent(); } -void ListBox::mousePress(int x, int y, int button) +void +ListBox::mouseDragged(gcn::MouseEvent &event) { - gcn::ListBox::mousePress(x, y, button); - - if (button == gcn::MouseInput::LEFT && hasMouse()) - { - mMousePressed = true; - } -} - -void ListBox::mouseRelease(int x, int y, int button) -{ - gcn::ListBox::mouseRelease(x, y, button); - - mMousePressed = false; -} - -void ListBox::mouseMotion(int x, int y) -{ - gcn::ListBox::mouseMotion(x, y); - // Pretend mouse is pressed continuously while dragged. Causes list // selection to be updated as is default in many GUIs. - if (mMousePressed) - { - mousePress(x, y, gcn::MouseInput::LEFT); - } + mousePressed(event); } void ListBox::fireSelectionChangedEvent() diff --git a/src/gui/listbox.h b/src/gui/listbox.h index deca07cf..1d480eb1 100644 --- a/src/gui/listbox.h +++ b/src/gui/listbox.h @@ -48,9 +48,7 @@ class ListBox : public gcn::ListBox */ void draw(gcn::Graphics *graphics); - void mousePress(int x, int y, int button); - void mouseRelease(int x, int y, int button); - void mouseMotion(int x, int y); + void mouseDragged(gcn::MouseEvent &event); /** * Adds a listener to the list that's notified each time a change to @@ -81,8 +79,6 @@ class ListBox : public gcn::ListBox */ void fireSelectionChangedEvent(); - bool mMousePressed; /**< Keeps track of mouse pressed status. */ - std::list mListeners; }; diff --git a/src/gui/login.cpp b/src/gui/login.cpp index b8d4df2b..664074aa 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -43,9 +43,9 @@ WrongDataNoticeListener::setTarget(gcn::TextField *textField) } void -WrongDataNoticeListener::action(const std::string &eventId, gcn::Widget *widget) +WrongDataNoticeListener::action(const gcn::ActionEvent &event) { - if (eventId == "ok") + if (event.getId() == "ok") { // Reset the field mTarget->setText(""); @@ -85,8 +85,8 @@ LoginDialog::LoginDialog(LoginData *loginData): mKeepCheck->getX() + mKeepCheck->getWidth() + 10, 91 - mRegisterButton->getHeight() - 5); - mUserField->setEventId("ok"); - mPassField->setEventId("ok"); + mUserField->setActionEventId("ok"); + mPassField->setActionEventId("ok"); mUserField->addActionListener(this); mPassField->addActionListener(this); @@ -119,9 +119,9 @@ LoginDialog::~LoginDialog() } void -LoginDialog::action(const std::string &eventId, gcn::Widget *widget) +LoginDialog::action(const gcn::ActionEvent &event) { - if (eventId == "ok") + if (event.getId() == "ok") { // Check login if (mUserField->getText().empty()) @@ -142,11 +142,11 @@ LoginDialog::action(const std::string &eventId, gcn::Widget *widget) state = STATE_LOGIN_ATTEMPT; } } - else if (eventId == "cancel") + else if (event.getId() == "cancel") { state = STATE_EXIT; } - else if (eventId == "register") + else if (event.getId() == "register") { state = STATE_REGISTER; } diff --git a/src/gui/login.h b/src/gui/login.h index 6d510da7..05c0da31 100644 --- a/src/gui/login.h +++ b/src/gui/login.h @@ -38,7 +38,7 @@ class LoginData; class WrongDataNoticeListener : public gcn::ActionListener { public: void setTarget(gcn::TextField *textField); - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); private: gcn::TextField *mTarget; }; @@ -65,7 +65,7 @@ class LoginDialog : public Window, public gcn::ActionListener { /** * Called when receiving actions from the widgets. */ - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); private: gcn::TextField *mUserField; diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp index a1b342f0..ba4c8e94 100644 --- a/src/gui/menuwindow.cpp +++ b/src/gui/menuwindow.cpp @@ -39,7 +39,7 @@ namespace { /** * Called when receiving actions from widget. */ - void action(const std::string &eventId, gcn::Widget *widget); + void action(const gcn::ActionEvent &event); } listener; } @@ -75,26 +75,26 @@ void MenuWindow::draw(gcn::Graphics *graphics) } -void MenuWindowListener::action(const std::string &eventId, gcn::Widget *widget) +void MenuWindowListener::action(const gcn::ActionEvent &event) { Window *window = NULL; - if (eventId == "Status") + if (event.getId() == "Status") { window = statusWindow; } - else if (eventId == "Equipment") + else if (event.getId() == "Equipment") { window = equipmentWindow; } - else if (eventId == "Inventory") + else if (event.getId() == "Inventory") { window = inventoryWindow; } - else if (eventId == "Skills") + else if (event.getId() == "Skills") { window = skillDialog; } - else if (eventId == "Setup") + else if (event.getId() == "Setup") { window = setupWindow; } diff --git a/src/gui/newskill.cpp b/src/gui/newskill.cpp index 7f5de543..6783a546 100644 --- a/src/gui/newskill.cpp +++ b/src/gui/newskill.cpp @@ -121,46 +121,46 @@ NewSkillDialog::NewSkillDialog(): setLocationRelativeTo(getParent()); } -void NewSkillDialog::action(const std::string &eventId, gcn::Widget *widget) +void NewSkillDialog::action(const gcn::ActionEvent &event) { - int osp = startPoint; - if (eventId == "close") + int osp = startPoint; + if (event.getId() == "close") { setVisible(false); } - else if (eventId == "g1") // weapons group 0-9 + else if (event.getId() == "g1") // weapons group 0-9 { startPoint =0; } - else if (eventId == "g2") // magic group 10-19 + else if (event.getId() == "g2") // magic group 10-19 { startPoint =10; } - else if (eventId == "g3") // craft group 20-29 + else if (event.getId() == "g3") // craft group 20-29 { startPoint =20; } - else if (eventId == "g4") // general group 30-39 + else if (event.getId() == "g4") // general group 30-39 { startPoint =30; } - else if (eventId == "g5") // combat group 40-49 + else if (event.getId() == "g5") // combat group 40-49 { startPoint =40; } - else if (eventId == "g6") // e. resist group 50-59 + else if (event.getId() == "g6") // e. resist group 50-59 { startPoint =50; } - else if (eventId == "g7") // s resist group 60-69 + else if (event.getId() == "g7") // s resist group 60-69 { startPoint =60; } - else if (eventId == "g8") // hunting group 70-79 + else if (event.getId() == "g8") // hunting group 70-79 { startPoint =70; } - else if (eventId == "g9") // stats group 80-89 + else if (event.getId() == "g9") // stats group 80-89 { startPoint =80; } diff --git a/src/gui/newskill.h b/src/gui/newskill.h index 224574bd..6e12169f 100644 --- a/src/gui/newskill.h +++ b/src/gui/newskill.h @@ -55,7 +55,7 @@ class NewSkillDialog : public Window, public gcn::ActionListener NewSkillDialog(); // action listener - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); private: void resetNSD(); // updates the values in the dialog box diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 5b7ca439..2dd223bd 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -67,9 +67,9 @@ NpcTextDialog::addText(const std::string &text) } void -NpcTextDialog::action(const std::string &eventId, gcn::Widget *widget) +NpcTextDialog::action(const gcn::ActionEvent &event) { - if (eventId == "ok") + if (event.getId() == "ok") { setText(""); setVisible(false); diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 3ce1215d..869661c4 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -49,7 +49,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener * Called when receiving actions from the widgets. */ void - action(const std::string& eventId, gcn::Widget* widget); + action(const gcn::ActionEvent &event); /** * Sets the text shows in the dialog. diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index d1c3ddcb..1bcdc8ff 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -50,7 +50,7 @@ NpcListDialog::NpcListDialog(): cancelButton->getX() - 5 - okButton->getWidth(), cancelButton->getY()); - mItemList->setEventId("item"); + mItemList->setActionEventId("item"); mItemList->addActionListener(this); @@ -91,11 +91,11 @@ NpcListDialog::reset() } void -NpcListDialog::action(const std::string &eventId, gcn::Widget *widget) +NpcListDialog::action(const gcn::ActionEvent &event) { int choice = 0; - if (eventId == "ok") + if (event.getId() == "ok") { // Send the selected index back to the server int selectedIndex = mItemList->getSelected(); @@ -104,7 +104,7 @@ NpcListDialog::action(const std::string &eventId, gcn::Widget *widget) choice = selectedIndex + 1; } } - else if (eventId == "cancel") + else if (event.getId() == "cancel") { choice = 0xff; // 0xff means cancel } diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index 03b76681..c09b0a8c 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -54,7 +54,7 @@ class NpcListDialog : public Window, public gcn::ActionListener, * Called when receiving actions from the widgets. */ void - action(const std::string& eventId, gcn::Widget* widget); + action(const gcn::ActionEvent &event); /** * Returns the number of items in the choices list. diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp index 4f9623d7..ca9d2a7b 100644 --- a/src/gui/ok_dialog.cpp +++ b/src/gui/ok_dialog.cpp @@ -55,17 +55,17 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, okButton->requestFocus(); } -void OkDialog::action(const std::string &eventId, gcn::Widget *widget) +void OkDialog::action(const gcn::ActionEvent &event) { // Proxy button events to our listeners ActionListenerIterator i; for (i = mActionListeners.begin(); i != mActionListeners.end(); ++i) { - (*i)->action(eventId, widget); + (*i)->action(event); } // Can we receive anything else anyway? - if (eventId == "ok") { + if (event.getId() == "ok") { scheduleDelete(); } } diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h index 8ae08955..a7b24a90 100644 --- a/src/gui/ok_dialog.h +++ b/src/gui/ok_dialog.h @@ -46,7 +46,7 @@ class OkDialog : public Window, public gcn::ActionListener { /** * Called when receiving actions from the widgets. */ - void action(const std::string &eventId, gcn::Widget *widget); + void action(const gcn::ActionEvent &event); }; #endif diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index 5fbe79b7..fad156f1 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -28,7 +28,6 @@ #include "../resources/image.h" #include "../resources/resourcemanager.h" -#include "../resources/spriteset.h" #include "../utils/dtor.h" diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 70cd6dc4..4539e48e 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -108,13 +108,13 @@ RegisterDialog::~RegisterDialog() } void -RegisterDialog::action(const std::string &eventId, gcn::Widget *widget) +RegisterDialog::action(const gcn::ActionEvent &event) { - if (eventId == "cancel") + if (event.getId() == "cancel") { state = STATE_LOGIN; } - else if (eventId == "register") + else if (event.getId() == "register") { const std::string user = mUserField->getText(); logger->log("RegisterDialog::register Username is %s", user.c_str()); diff --git a/src/gui/register.h b/src/gui/register.h index 4c98788f..4ffe451f 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -56,7 +56,7 @@ class RegisterDialog : public Window, public gcn::ActionListener { /** * Called when receiving actions from the widgets. */ - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); // Made them public to have the possibility to request focus // from external functions. diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index b0957f9e..c9878c84 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -87,8 +87,8 @@ SellDialog::SellDialog(): quitButton->setPosition(208, 186); - mShopItemList->setEventId("item"); - mSlider->setEventId("mSlider"); + mShopItemList->setActionEventId("item"); + mSlider->setActionEventId("mSlider"); mShopItemList->setPriceCheck(false); @@ -154,11 +154,11 @@ void SellDialog::addItem(Item *item, int price) mShopItemList->adjustSize(); } -void SellDialog::action(const std::string &eventId, gcn::Widget *widget) +void SellDialog::action(const gcn::ActionEvent &event) { int selectedItem = mShopItemList->getSelected(); - if (eventId == "item") + if (event.getId() == "item") { mAmountItems = 0; mSlider->setValue(0); @@ -182,7 +182,7 @@ void SellDialog::action(const std::string &eventId, gcn::Widget *widget) } mQuantityLabel->adjustSize(); } - else if (eventId == "quit") + else if (event.getId() == "quit") { setVisible(false); current_npc = 0; @@ -195,13 +195,13 @@ void SellDialog::action(const std::string &eventId, gcn::Widget *widget) bool updateButtonsAndLabels = false; - if (eventId == "mSlider") + if (event.getId() == "mSlider") { mAmountItems = (int)(mSlider->getValue() * mMaxItems); updateButtonsAndLabels = true; } - else if (eventId == "+") + else if (event.getId() == "+") { assert(mAmountItems < mMaxItems); mAmountItems++; @@ -209,7 +209,7 @@ void SellDialog::action(const std::string &eventId, gcn::Widget *widget) updateButtonsAndLabels = true; } - else if (eventId == "-") + else if (event.getId() == "-") { assert(mAmountItems > 0); mAmountItems--; @@ -218,7 +218,7 @@ void SellDialog::action(const std::string &eventId, gcn::Widget *widget) updateButtonsAndLabels = true; } - else if (eventId == "sell") + else if (event.getId() == "sell") { // Attempt sell assert(mAmountItems > 0 && mAmountItems <= mMaxItems); diff --git a/src/gui/sell.h b/src/gui/sell.h index ba324576..68bd7b8b 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -68,7 +68,7 @@ class SellDialog : public Window, gcn::ActionListener, SelectionListener /** * Called when receiving actions from the widgets. */ - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); /** * Updates labels according to selected item. diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index bd17bff7..bf29f0d3 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -44,9 +44,9 @@ const short MAX_SERVERLIST = 5; void -DropDownListener::action(const std::string &eventId, gcn::Widget *widget) +DropDownListener::action(const gcn::ActionEvent &event) { - if (eventId == "ok") + if (event.getId() == "ok") { // Reset the text fields and give back the server dialog. mServerNameField->setText(""); @@ -56,13 +56,14 @@ DropDownListener::action(const std::string &eventId, gcn::Widget *widget) mServerNameField->requestFocus(); } - else if (eventId == "changeSelection") + else if (event.getId() == "changeSelection") { // Change the textField Values according to new selection if (currentSelectedIndex != mServersListBox->getSelected()) { Server myServer; - myServer = mServersListModel->getServer(mServersListBox->getSelected()); + myServer = mServersListModel->getServer( + mServersListBox->getSelected()); mServerNameField->setText(myServer.serverName); mServerPortField->setText(toString(myServer.port)); currentSelectedIndex = mServersListBox->getSelected(); @@ -131,7 +132,7 @@ ServerDialog::ServerDialog(LoginData *loginData): mMostUsedServersScrollArea, mMostUsedServersListBox); mDropDownListener = new DropDownListener(mServerNameField, mPortField, - mMostUsedServersListModel, mMostUsedServersListBox); + mMostUsedServersListModel, mMostUsedServersListBox); mOkButton = new Button("OK", "ok", this); mCancelButton = new Button("Cancel", "cancel", this); @@ -157,9 +158,9 @@ ServerDialog::ServerDialog(LoginData *loginData): mCancelButton->getX() - mOkButton->getWidth() - 5, 100 - mOkButton->getHeight() - 5); - mServerNameField->setEventId("ok"); - mPortField->setEventId("ok"); - mMostUsedServersDropDown->setEventId("changeSelection"); + mServerNameField->setActionEventId("ok"); + mPortField->setActionEventId("ok"); + mMostUsedServersDropDown->setActionEventId("changeSelection"); mServerNameField->addActionListener(this); mPortField->addActionListener(this); @@ -193,9 +194,9 @@ ServerDialog::~ServerDialog() } void -ServerDialog::action(const std::string &eventId, gcn::Widget *widget) +ServerDialog::action(const gcn::ActionEvent &event) { - if (eventId == "ok") + if (event.getId() == "ok") { // Check login if (mServerNameField->getText().empty() || mPortField->getText().empty()) @@ -240,7 +241,7 @@ ServerDialog::action(const std::string &eventId, gcn::Widget *widget) state = STATE_CONNECT_ACCOUNT; } } - else if (eventId == "cancel") + else if (event.getId() == "cancel") { state = STATE_EXIT; } diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index d907f340..2bb0609f 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -98,8 +98,7 @@ class DropDownListener : public gcn::ActionListener mServerPortField(serverPortField), mServersListModel(serversListModel), mServersListBox(serversListBox) {}; - void action(const std::string& eventId, - gcn::Widget* widget); + void action(const gcn::ActionEvent &event); private: short currentSelectedIndex; gcn::TextField *mServerNameField; @@ -132,7 +131,7 @@ class ServerDialog : public Window, public gcn::ActionListener /** * Called when receiving actions from the widgets. */ - void action(const std::string &eventId, gcn::Widget *widget); + void action(const gcn::ActionEvent &event); private: gcn::TextField *mServerNameField; diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 78b10498..3add3a18 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -85,19 +85,19 @@ Setup::~Setup() for_each(mTabs.begin(), mTabs.end(), make_dtor(mTabs)); } -void Setup::action(const std::string& event, gcn::Widget *widget) +void Setup::action(const gcn::ActionEvent &event) { - if (event == "Apply") + if (event.getId() == "Apply") { setVisible(false); for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::apply)); } - else if (event == "Cancel") + else if (event.getId() == "Cancel") { setVisible(false); for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel)); } - else if (event == "Reset Windows") + else if (event.getId() == "Reset Windows") { statusWindow->resetToDefaultSize(); minimap->resetToDefaultSize(); diff --git a/src/gui/setup.h b/src/gui/setup.h index 6601ce3d..77173367 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -54,7 +54,7 @@ class Setup : public Window, public gcn::ActionListener * Event handling method. */ void - action(const std::string& eventId, gcn::Widget* widget); + action(const gcn::ActionEvent &event); private: std::list mTabs; diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index db88ff64..e5aadf80 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -46,8 +46,8 @@ Setup_Audio::Setup_Audio(): gcn::Label *sfxLabel = new gcn::Label("Sfx volume"); gcn::Label *musicLabel = new gcn::Label("Music volume"); - mSfxSlider->setEventId("sfx"); - mMusicSlider->setEventId("music"); + mSfxSlider->setActionEventId("sfx"); + mMusicSlider->setActionEventId("music"); mSfxSlider->addActionListener(this); mMusicSlider->addActionListener(this); @@ -108,14 +108,14 @@ void Setup_Audio::cancel() config.setValue("musicVolume", mMusicVolume); } -void Setup_Audio::action(const std::string& event, gcn::Widget *widget) +void Setup_Audio::action(const gcn::ActionEvent &event) { - if (event == "sfx") + if (event.getId() == "sfx") { config.setValue("sfxVolume", (int)mSfxSlider->getValue()); sound.setSfxVolume((int)mSfxSlider->getValue()); } - else if (event == "music") + else if (event.getId() == "music") { config.setValue("musicVolume", (int)mMusicSlider->getValue()); sound.setMusicVolume((int)mMusicSlider->getValue()); diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h index f09f62da..6e722f74 100644 --- a/src/gui/setup_audio.h +++ b/src/gui/setup_audio.h @@ -38,7 +38,7 @@ class Setup_Audio : public SetupTab, public gcn::ActionListener void apply(); void cancel(); - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); private: int mMusicVolume, mSfxVolume; diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp index 685d88cf..56f411d7 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -45,7 +45,6 @@ Setup_Joystick::Setup_Joystick(): mOriginalJoystickEnabled = (int)config.getValue("joystickEnabled", 0) != 0; mJoystickEnabled->setMarked(mOriginalJoystickEnabled); - mJoystickEnabled->setEventId("joystickEnabled"); mJoystickEnabled->addActionListener(this); add(mCalibrateLabel); @@ -53,13 +52,13 @@ Setup_Joystick::Setup_Joystick(): add(mJoystickEnabled); } -void Setup_Joystick::action(const std::string &event, gcn::Widget *widget) +void Setup_Joystick::action(const gcn::ActionEvent &event) { if (!joystick) { return; } - if (event == "joystickEnabled") + if (event.getSource() == mJoystickEnabled) { joystick->setEnabled(mJoystickEnabled->isMarked()); } diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h index 4cc2b3d9..6d3ad129 100644 --- a/src/gui/setup_joystick.h +++ b/src/gui/setup_joystick.h @@ -38,7 +38,7 @@ class Setup_Joystick : public SetupTab, public gcn::ActionListener void apply(); void cancel(); - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); private: gcn::Label *mCalibrateLabel; diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 7a4aae03..8930af3e 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -158,16 +158,16 @@ Setup_Video::Setup_Video(): mFpsSlider->setEnabled(mFps > 0); mFpsCheckBox->setMarked(mFps > 0); - mCustomCursorCheckBox->setEventId("customcursor"); - mAlphaSlider->setEventId("guialpha"); - mFpsCheckBox->setEventId("fpslimitcheckbox"); - mFpsSlider->setEventId("fpslimitslider"); - mScrollRadiusSlider->setEventId("scrollradiusslider"); - mScrollRadiusField->setEventId("scrollradiusfield"); - mScrollLazinessSlider->setEventId("scrolllazinessslider"); - mScrollLazinessField->setEventId("scrolllazinessfield"); - mOverlayDetailSlider->setEventId("overlaydetailslider"); - mOverlayDetailField->setEventId("overlaydetailfield"); + mCustomCursorCheckBox->setActionEventId("customcursor"); + mAlphaSlider->setActionEventId("guialpha"); + mFpsCheckBox->setActionEventId("fpslimitcheckbox"); + mFpsSlider->setActionEventId("fpslimitslider"); + mScrollRadiusSlider->setActionEventId("scrollradiusslider"); + mScrollRadiusField->setActionEventId("scrollradiusfield"); + mScrollLazinessSlider->setActionEventId("scrolllazinessslider"); + mScrollLazinessField->setActionEventId("scrolllazinessfield"); + mOverlayDetailSlider->setActionEventId("overlaydetailslider"); + mOverlayDetailField->setActionEventId("overlaydetailfield"); mCustomCursorCheckBox->addActionListener(this); mAlphaSlider->addActionListener(this); @@ -331,37 +331,37 @@ void Setup_Video::cancel() config.setValue("opengl", mOpenGLEnabled ? 1 : 0); } -void Setup_Video::action(const std::string &event, gcn::Widget *widget) +void Setup_Video::action(const gcn::ActionEvent &event) { - if (event == "guialpha") + if (event.getId() == "guialpha") { config.setValue("guialpha", mAlphaSlider->getValue()); } - else if (event == "customcursor") + else if (event.getId() == "customcursor") { config.setValue("customcursor", mCustomCursorCheckBox->isMarked() ? 1 : 0); } - else if (event == "fpslimitslider") + else if (event.getId() == "fpslimitslider") { - mFps = (int)mFpsSlider->getValue(); + mFps = (int) mFpsSlider->getValue(); mFpsField->setText(toString(mFps)); } - else if (event == "scrollradiusslider") + else if (event.getId() == "scrollradiusslider") { - int val = (int)mScrollRadiusSlider->getValue(); + int val = (int) mScrollRadiusSlider->getValue(); mScrollRadiusField->setText(toString(val)); config.setValue("ScrollRadius", val); } - else if (event == "scrolllazinessslider") + else if (event.getId() == "scrolllazinessslider") { - int val = (int)mScrollLazinessSlider->getValue(); + int val = (int) mScrollLazinessSlider->getValue(); mScrollLazinessField->setText(toString(val)); config.setValue("ScrollLaziness", val); } - else if (event == "overlaydetailslider") + else if (event.getId() == "overlaydetailslider") { - int val = (int)mOverlayDetailSlider->getValue(); + int val = (int) mOverlayDetailSlider->getValue(); switch (val) { case 0: @@ -376,11 +376,11 @@ void Setup_Video::action(const std::string &event, gcn::Widget *widget) } config.setValue("OverlayDetail", val); } - else if (event == "fpslimitcheckbox") + else if (event.getId() == "fpslimitcheckbox") { if (mFpsCheckBox->isMarked()) { - mFps = (int)mFpsSlider->getValue(); + mFps = (int) mFpsSlider->getValue(); } else { @@ -393,7 +393,8 @@ void Setup_Video::action(const std::string &event, gcn::Widget *widget) } } -void Setup_Video::keyPress(const gcn::Key &key) +void +Setup_Video::keyPressed(gcn::KeyEvent &event) { std::stringstream tempFps(mFpsField->getText()); diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index 482d1c65..095fdbd6 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -41,10 +41,11 @@ class Setup_Video : public SetupTab, public gcn::ActionListener, void apply(); void cancel(); - void action(const std::string &eventId, gcn::Widget *widget); + void action(const gcn::ActionEvent &event); /** Called when key is pressed */ - void keyPress(const gcn::Key& key); + void + keyPressed(gcn::KeyEvent &event); private: bool mFullScreenEnabled; diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 4821067c..8cf0b639 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -125,11 +125,12 @@ void ShopListBox::setSelected(int selected) fireSelectionChangedEvent(); } -void ShopListBox::mousePress(int x, int y, int button) +void ShopListBox::mousePressed(gcn::MouseEvent &event) { - if (button == gcn::MouseInput::LEFT && hasMouse()) + if (event.getButton() == gcn::MouseEvent::LEFT) { bool enoughMoney = false; + int y = event.getY(); if (mShopItems && mPriceCheck) { @@ -145,7 +146,6 @@ void ShopListBox::mousePress(int x, int y, int button) { setSelected(y / mRowHeight); generateAction(); - mMousePressed = true; } } } diff --git a/src/gui/shoplistbox.h b/src/gui/shoplistbox.h index 476564b2..1cfb183b 100644 --- a/src/gui/shoplistbox.h +++ b/src/gui/shoplistbox.h @@ -54,7 +54,7 @@ class ShopListBox : public ListBox */ void draw(gcn::Graphics *graphics); - void mousePress(int x, int y, int button); + void mousePressed(gcn::MouseEvent &event); /** * Adds a listener to the list that's notified each time a change to diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 4f552fd7..1b00a732 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -74,7 +74,7 @@ SkillDialog::SkillDialog(): mUseButton->setEnabled(false); mCloseButton = new Button("Close", "close", this); - mSkillListBox->setEventId("skill"); + mSkillListBox->setActionEventId("skill"); skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); skillScrollArea->setDimension(gcn::Rectangle(5, 5, 230, 180)); @@ -103,9 +103,9 @@ SkillDialog::~SkillDialog() cleanList(); } -void SkillDialog::action(const std::string &eventId, gcn::Widget *widget) +void SkillDialog::action(const gcn::ActionEvent &event) { - if (eventId == "inc") + if (event.getId() == "inc") { // Increment skill int selectedSkill = mSkillListBox->getSelected(); @@ -114,13 +114,13 @@ void SkillDialog::action(const std::string &eventId, gcn::Widget *widget) player_node->raiseSkill(mSkillList[selectedSkill]->id); } } - else if (eventId == "skill") + else if (event.getId() == "skill") { mIncButton->setEnabled( mSkillListBox->getSelected() > -1 && player_node->mSkillPoint > 0); } - else if (eventId == "close") + else if (event.getId() == "close") { setVisible(false); } diff --git a/src/gui/skill.h b/src/gui/skill.h index 5555fec4..ed1257b0 100644 --- a/src/gui/skill.h +++ b/src/gui/skill.h @@ -57,7 +57,7 @@ class SkillDialog : public Window, public gcn::ActionListener, */ ~SkillDialog(); - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); void update(); diff --git a/src/gui/status.cpp b/src/gui/status.cpp index bba9f045..9c60752d 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -338,8 +338,10 @@ void StatusWindow::draw(gcn::Graphics *g) Window::draw(g); } -void StatusWindow::action(const std::string &eventId, gcn::Widget *widget) +void StatusWindow::action(const gcn::ActionEvent &event) { + const std::string &eventId = event.getId(); + // Stats Part if (eventId.length() == 3) { diff --git a/src/gui/status.h b/src/gui/status.h index 43dfe8c2..37f8a648 100644 --- a/src/gui/status.h +++ b/src/gui/status.h @@ -51,7 +51,7 @@ class StatusWindow : public Window, public gcn::ActionListener { /** * Called when receiving actions from widget. */ - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); /** * Draw this window diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp index e3d2527b..75f9f3cf 100644 --- a/src/gui/tabbedcontainer.cpp +++ b/src/gui/tabbedcontainer.cpp @@ -78,9 +78,9 @@ void TabbedContainer::logic() Container::logic(); } -void TabbedContainer::action(const std::string &event, gcn::Widget *widget) +void TabbedContainer::action(const gcn::ActionEvent &event) { - std::stringstream ss(event); + std::stringstream ss(event.getId()); int tabNo; ss >> tabNo; diff --git a/src/gui/tabbedcontainer.h b/src/gui/tabbedcontainer.h index 453d8374..2dc017ae 100644 --- a/src/gui/tabbedcontainer.h +++ b/src/gui/tabbedcontainer.h @@ -43,7 +43,7 @@ class TabbedContainer : public gcn::Container, public gcn::ActionListener void logic(); - void action(const std::string &event, gcn::Widget *widget); + void action(const gcn::ActionEvent &event); void setOpaque(bool opaque); diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 82262563..14b1afa6 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -256,11 +256,11 @@ void TradeWindow::selectionChanged(const SelectionEvent &event) } } -void TradeWindow::action(const std::string &eventId, gcn::Widget *widget) +void TradeWindow::action(const gcn::ActionEvent &event) { Item *item = inventoryWindow->getItem(); - if (eventId == "add") + if (event.getId() == "add") { if (!item) { @@ -286,14 +286,14 @@ void TradeWindow::action(const std::string &eventId, gcn::Widget *widget) new ItemAmountWindow(AMOUNT_TRADE_ADD, this, item); } } - else if (eventId == "cancel") + else if (event.getId() == "cancel") { // XXX Convert for new server /* MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST); */ } - else if (eventId == "ok") + else if (event.getId() == "ok") { std::stringstream tempMoney(mMoneyField->getText()); int tempInt; @@ -317,7 +317,7 @@ void TradeWindow::action(const std::string &eventId, gcn::Widget *widget) MessageOut outMsg(CMSG_TRADE_ADD_COMPLETE); */ } - else if (eventId == "trade") + else if (event.getId() == "trade") { // XXX Convert for new server /* diff --git a/src/gui/trade.h b/src/gui/trade.h index ebd05a52..1c64c255 100644 --- a/src/gui/trade.h +++ b/src/gui/trade.h @@ -111,7 +111,7 @@ class TradeWindow : public Window, gcn::ActionListener, SelectionListener /** * Called when receiving actions from the widgets. */ - void action(const std::string &eventId, gcn::Widget *widget); + void action(const gcn::ActionEvent &event); private: typedef std::auto_ptr InventoryPtr; diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 73e4489e..d41dfe13 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -132,9 +132,9 @@ void UpdaterWindow::enable() mPlayButton->requestFocus(); } -void UpdaterWindow::action(const std::string &eventId, gcn::Widget *widget) +void UpdaterWindow::action(const gcn::ActionEvent &event) { - if (eventId == "cancel") + if (event.getId() == "cancel") { // Register the user cancel mUserCancel=true; @@ -148,7 +148,7 @@ void UpdaterWindow::action(const std::string &eventId, gcn::Widget *widget) mDownloadStatus = UPDATE_ERROR; } } - else if (eventId == "play") + else if (event.getId() == "play") { state = STATE_LOGIN; } diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h index 0d1493ee..8c54be27 100644 --- a/src/gui/updatewindow.h +++ b/src/gui/updatewindow.h @@ -79,7 +79,7 @@ class UpdaterWindow : public Window, public gcn::ActionListener */ void loadNews(); - void action(const std::string& eventId, gcn::Widget* widget); + void action(const gcn::ActionEvent &event); void logic(); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 75a16865..671ababa 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -47,6 +47,7 @@ Viewport::Viewport(): mCameraX(0), mCameraY(0), mShowDebugPath(false), + mPlayerFollowMouse(false), mPopupActive(false) { setOpaque(false); @@ -243,7 +244,7 @@ Viewport::logic() } void -Viewport::mousePress(int mx, int my, int button) +Viewport::mousePressed(gcn::MouseEvent &event) { // Check if we are alive and kickin' if (!mMap || !player_node || player_node->mAction == Being::DEAD) @@ -255,11 +256,11 @@ Viewport::mousePress(int mx, int my, int button) mPlayerFollowMouse = false; - int tilex = (mx + mCameraX) / 32; - int tiley = (my + mCameraY) / 32; + int tilex = (event.getX() + mCameraX) / 32; + int tiley = (event.getY() + mCameraY) / 32; // Right click might open a popup - if (button == gcn::MouseInput::RIGHT) + if (event.getButton() == gcn::MouseEvent::RIGHT) { Being *being; FloorItem *floorItem; @@ -267,12 +268,12 @@ Viewport::mousePress(int mx, int my, int button) if ((being = beingManager->findBeing(tilex, tiley)) && being->getType() != Being::LOCALPLAYER) { - showPopup(mx, my, being); + showPopup(event.getX(), event.getY(), being); return; } else if((floorItem = floorItemManager->findByCoordinates(tilex, tiley))) { - showPopup(mx, my, floorItem); + showPopup(event.getX(), event.getY(), floorItem); return; } } @@ -286,7 +287,7 @@ Viewport::mousePress(int mx, int my, int button) } // Left click can cause different actions - if (button == gcn::MouseInput::LEFT) + if (event.getButton() == gcn::MouseEvent::LEFT) { FloorItem *item; @@ -302,13 +303,13 @@ Viewport::mousePress(int mx, int my, int button) Uint8 *keys = SDL_GetKeyState(NULL); if (!(keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT])) { - player_node->setDestination(mx + mCameraX, my + mCameraY); + player_node->setDestination(event.getX() + mCameraX, + event.getY() + mCameraY); } mPlayerFollowMouse = true; } } - - if (button == gcn::MouseInput::MIDDLE) + else if (event.getButton() == gcn::MouseEvent::MIDDLE) { // Find the being nearest to the clicked position Being *target = beingManager->findNearestLivingBeing( @@ -323,19 +324,20 @@ Viewport::mousePress(int mx, int my, int button) } void -Viewport::mouseMotion(int mx, int my) +Viewport::mouseMoved(gcn::MouseEvent &event) { if (!mMap || !player_node) return; if (mPlayerFollowMouse && mWalkTime == player_node->mWalkTime) { - player_node->setDestination(mx + mCameraX, my + mCameraY); + player_node->setDestination(event.getX() + mCameraX, + event.getY() + mCameraY); } } void -Viewport::mouseRelease(int mx, int my, int button) +Viewport::mouseReleased(gcn::MouseEvent &event) { mPlayerFollowMouse = false; } diff --git a/src/gui/viewport.h b/src/gui/viewport.h index df78b1da..80475fbf 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -79,31 +79,33 @@ class Viewport : public WindowContainer, public gcn::MouseListener, /** * Toggles whether the path debug graphics are shown */ - void toggleDebugPath() { mShowDebugPath = !mShowDebugPath; } + void + toggleDebugPath() { mShowDebugPath = !mShowDebugPath; } /** * Handles mouse press on map. */ void - mousePress(int mx, int my, int button); + mousePressed(gcn::MouseEvent &event); /** * Handles mouse move on map */ void - mouseMotion(int mx, int my); + mouseMoved(gcn::MouseEvent &event); /** * Handles mouse button release on map. */ void - mouseRelease(int mx, int my, int button); + mouseReleased(gcn::MouseEvent &event); /** * Shows a popup for an item. * TODO Find some way to get rid of Item here */ - void showPopup(int x, int y, Item *item); + void + showPopup(int x, int y, Item *item); /** * A relevant config option changed. @@ -111,6 +113,18 @@ class Viewport : public WindowContainer, public gcn::MouseListener, void optionChanged(const std::string &name); + /** + * Returns camera x offset in tiles. + */ + int + getCameraX() { return mCameraX; } + + /** + * Returns camera y offset in tiles. + */ + int + getCameraY() { return mCameraY; } + private: /** * Shows a popup for a floor item. @@ -131,8 +145,8 @@ class Viewport : public WindowContainer, public gcn::MouseListener, int mScrollLaziness; float mViewX; /**< Current viewpoint in pixels. */ float mViewY; /**< Current viewpoint in pixels. */ - int mCameraX; - int mCameraY; + int mCameraX; /**< Current viewpoint in tiles. */ + int mCameraY; /**< Current viewpoint in tiles. */ bool mShowDebugPath; /**< Show a path from player to pointer. */ bool mPlayerFollowMouse; diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 1960d6ca..bb60c6ff 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -197,6 +197,12 @@ void Window::setContentHeight(int height) resizeToContent(); } +void Window::setContentSize(int width, int height) +{ + setContentWidth(width); + setContentHeight(height); +} + void Window::setLocationRelativeTo(gcn::Widget *widget) { int wx, wy; @@ -209,12 +215,6 @@ void Window::setLocationRelativeTo(gcn::Widget *widget) getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y)); } -void Window::setContentSize(int width, int height) -{ - setContentWidth(width); - setContentHeight(height); -} - void Window::setMinWidth(unsigned int width) { mMinWinWidth = width; @@ -282,86 +282,60 @@ void Window::add(gcn::Widget *w, int x, int y, bool delChild) mChrome->add(w, x, y, delChild); } -void Window::mousePress(int x, int y, int button) +void Window::mousePressed(gcn::MouseEvent &event) { // Let Guichan move window to top and figure out title bar drag - gcn::Window::mousePress(x, y, button); + gcn::Window::mousePressed(event); - // If the mouse is not inside the content, the press must have been on the - // border, and is a candidate for a resize. - if (isResizable() && button == 1 && + int x = event.getX(); + int y = event.getY(); + + // Activate resizing if the left mouse button was pressed on the grip + mMouseResize = + isResizable() && + event.getButton() == gcn::MouseEvent::LEFT && getGripDimension().isPointInRect(x, y) && - !getChildrenArea().isPointInRect(x, y) && - hasMouse() && - !(mMouseDrag && y > (int)getPadding())) - { - mMouseResize = true; - mMouseXOffset = x; - mMouseYOffset = y; - } + !getChildrenArea().isPointInRect(x, y); } -void Window::mouseMotion(int x, int y) +void Window::mouseDragged(gcn::MouseEvent &event) { - if (mMouseDrag || mMouseResize) + // Let Guichan handle title bar drag + gcn::Window::mouseDragged(event); + + // Keep guichan window inside screen + int newX = std::max(0, getX()); + int newY = std::max(0, getY()); + newX = std::min(windowContainer->getWidth() - getWidth(), newX); + newY = std::min(windowContainer->getHeight() - getHeight(), newY); + setPosition(newX, newY); + + if (mMouseResize && !mIsMoving) { - int dx = x - mMouseXOffset; - int dy = y - mMouseYOffset; gcn::Rectangle newDim = getDimension(); - // Change the dimension according to dragging and moving - if (mMouseResize && isResizable()) - { - // We're dragging bottom right - newDim.height += dy; - newDim.width += dx; - } - else if (mMouseDrag && isMovable()) - { - newDim.x += dx; - newDim.y += dy; - } + // We're dragging bottom right + newDim.width += event.getX() - mDragOffsetX; + newDim.height += event.getY() - mDragOffsetY; - // Keep guichan window inside screen + // Keep guichan window inside screen (supports resizing any side) if (newDim.x < 0) { - if (mMouseResize) - { - newDim.width += newDim.x; - } - + newDim.width += newDim.x; newDim.x = 0; } if (newDim.y < 0) { - if (mMouseResize) - { - newDim.height += newDim.y; - } - + newDim.height += newDim.y; newDim.y = 0; } if (newDim.x + newDim.width > windowContainer->getWidth()) { - if (mMouseResize) - { - newDim.width = windowContainer->getWidth() - newDim.x; - } - else - { - newDim.x = windowContainer->getWidth() - newDim.width; - } + newDim.width = windowContainer->getWidth() - newDim.x; } if (newDim.y + newDim.height > windowContainer->getHeight()) { - if (mMouseResize) - { - newDim.height = windowContainer->getHeight() - newDim.y; - } - else - { - newDim.y = windowContainer->getHeight() - newDim.height; - } + newDim.height = windowContainer->getHeight() - newDim.y; } // Keep the window at least its minimum size @@ -383,18 +357,9 @@ void Window::mouseMotion(int x, int y) newDim.height = mMaxWinHeight; } - // Snap window to edges - //if (x < snapSize) x = 0; - //if (y < snapSize) y = 0; - //if (x + winWidth + snapSize > screen->w) x = screen->w - winWidth; - //if (y + winHeight + snapSize > screen->h) y = screen->h - winHeight; - // Update mouse offset when dragging bottom or right border - if (mMouseResize) - { - mMouseYOffset += newDim.height - getHeight(); - mMouseXOffset += newDim.width - getWidth(); - } + mDragOffsetX += newDim.width - getWidth(); + mDragOffsetY += newDim.height - getHeight(); // Set the new window and content dimensions setDimension(newDim); @@ -403,16 +368,6 @@ void Window::mouseMotion(int x, int y) } } -void -Window::mouseRelease(int x, int y, int button) -{ - if (button == 1) - { - mMouseResize = false; - mMouseDrag = false; - } -} - gcn::Rectangle Window::getGripDimension() { diff --git a/src/gui/window.h b/src/gui/window.h index 158035c0..9ac02287 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -77,12 +77,12 @@ class Window : public gcn::Window /** * Adds a widget to the window. */ - void add(gcn::Widget *wi, bool delChild=true); + void add(gcn::Widget *wi, bool delChild = true); /** * Adds a widget to the window and also specifices its position. */ - void add(gcn::Widget *w, int x, int y, bool delChild=true); + void add(gcn::Widget *w, int x, int y, bool delChild = true); /** * Sets the width of the window contents. @@ -95,14 +95,14 @@ class Window : public gcn::Window void setContentHeight(int height); /** - * Sets the location relative to the given widget. + * Sets the size of this window. */ - void setLocationRelativeTo(gcn::Widget* widget); + void setContentSize(int width, int height); /** - * Sets the size of this window. + * Sets the location relative to the given widget. */ - void setContentSize(int width, int height); + void setLocationRelativeTo(gcn::Widget *widget); /** * Sets whether of not the window can be resized. @@ -146,7 +146,7 @@ class Window : public gcn::Window */ bool isSticky(); - /** + /** * Overloads window setVisible by guichan to allow sticky window * Handling */ @@ -171,9 +171,8 @@ class Window : public gcn::Window * Window dragging and resizing mouse related. These methods also makes * sure the window is not dragged/resized outside of the screen. */ - void mousePress(int x, int y, int button); - void mouseMotion(int mx, int my); - void mouseRelease(int x, int y, int button); + void mousePressed(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event); /** * Gets the position of the resize grip. diff --git a/src/main.cpp b/src/main.cpp index b9eeaeb5..3a448494 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -110,7 +110,8 @@ Net::Connection *chatServerConnection = 0; namespace { struct ErrorListener : public gcn::ActionListener { - void action(const std::string &eventId, gcn::Widget *widget) { + void action(const gcn::ActionEvent &event) + { state = STATE_CHOOSE_SERVER; } } errorListener; @@ -713,15 +714,16 @@ int main(int argc, char *argv[]) logger->log("State: CHAR_SELECT"); currentDialog = new CharSelectDialog(&charInfo); - if (((CharSelectDialog*)currentDialog)-> + if (((CharSelectDialog*) currentDialog)-> selectByName(options.playername)) options.chooseDefault = true; else - ((CharSelectDialog*)currentDialog)->selectByName( + ((CharSelectDialog*) currentDialog)->selectByName( config.getValue("lastCharacter", "")); if (options.chooseDefault) - ((CharSelectDialog*)currentDialog)->action("ok", NULL); + ((CharSelectDialog*) currentDialog)->action( + gcn::ActionEvent(NULL, "ok")); break; case STATE_ERROR: diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp index f16037cf..327edea3 100644 --- a/src/net/playerhandler.cpp +++ b/src/net/playerhandler.cpp @@ -56,7 +56,7 @@ extern Window *buySellDialog; namespace { struct WeightListener : public gcn::ActionListener { - void action(const std::string &eventId, gcn::Widget *widget) + void action(const gcn::ActionEvent &event) { weightNotice = NULL; } @@ -70,7 +70,7 @@ namespace { namespace { struct DeathListener : public gcn::ActionListener { - void action(const std::string &eventId, gcn::Widget *widget) + void action(const gcn::ActionEvent &event) { player_node->revive(); deathNotice = NULL; diff --git a/src/net/tradehandler.cpp b/src/net/tradehandler.cpp index 2ebc160f..b3e80675 100644 --- a/src/net/tradehandler.cpp +++ b/src/net/tradehandler.cpp @@ -41,9 +41,9 @@ std::string tradePartnerName; namespace { struct RequestTradeListener : public gcn::ActionListener { - void action(const std::string &eventId, gcn::Widget *widget) + void action(const gcn::ActionEvent &event) { - player_node->tradeReply(eventId == "yes"); + player_node->tradeReply(event.getId() == "yes"); }; } listener; } diff --git a/tools/Purger.java b/tools/Purger.java deleted file mode 100644 index 1751c8de..00000000 --- a/tools/Purger.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Purger (c) 2006 Eugenio Favalli - * License: GPL, v2 or later - */ - -import java.io.*; -import java.text.*; -import java.util.*; - - public class Purger { - - public static void main(String[] args) { - if (args.length != 2) { - System.out.println( - "Usage: java Purger \n" + - " - folder: is the path to account.txt and athena.txt files.\n" + - " - date: accounts created before this date will be purged (dd/mm/yy)."); - return; - } - - int accounts = 0; - int characters = 0; - int deletedCharacters = 0; - Vector activeAccounts = new Vector(); - - File oldAccount = new File(args[0] + "account.txt"); - File oldAthena = new File(args[0] + "athena.txt"); - File newAccount = new File(args[0] + "account.txt.new"); - File newAthena = new File(args[0] + "athena.txt.new"); - - DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy"); - Date purgeDate; - try { - purgeDate = dateFormat.parse(args[1]); - } - catch (ParseException e) { - System.out.println("ERROR: Wrong date format."); - return; - } - - String line; - try { - FileInputStream fin = new FileInputStream(oldAccount); - BufferedReader input = new BufferedReader( - new InputStreamReader(fin)); - FileOutputStream fout = new FileOutputStream(newAccount); - PrintStream output = new PrintStream(fout); - - while ((line = input.readLine()) != null) { - boolean copy = false; - String[] fields = line.split("\t"); - // Check if we're reading a comment or the last line - if (line.substring(0, 2).equals("//") || fields[1].charAt(0) == '%') { - copy = true; - } - else { - // Server accounts should not be purged - if (!fields[4].equals("S")) { - accounts++; - dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - try { - Date date = dateFormat.parse(fields[3]); - if (date.after(purgeDate)) { - activeAccounts.add(fields[0]); - copy = true; - } - } - catch (ParseException e) { - System.out.println( - "ERROR: Wrong date format in account.txt. (" - + accounts + ": " + line + ")"); - //return; - } - catch (Exception e) { - e.printStackTrace(); - return; - } - } - else { - copy = true; - } - } - if (copy) { - try { - output.println(line); - } - catch (Exception e) { - System.err.println("ERROR: Unable to write file."); - } - } - } - } - catch (FileNotFoundException e ) { - System.out.println( - "ERROR: file " + oldAccount.getAbsolutePath() + " not found."); - return; - } - catch (Exception e) { - System.out.println("ERROR: unable to process account.txt"); - e.printStackTrace(); - return; - } - - input.close(); - output.close(); - - try { - FileInputStream fin = new FileInputStream(oldAthena); - BufferedReader input = new BufferedReader( - new InputStreamReader(fin)); - FileOutputStream fout = new FileOutputStream(newAthena); - PrintStream output = new PrintStream(fout); - - while ((line = input.readLine()) != null) { - boolean copy = false; - String[] fields = line.split("\t"); - // Check if we're reading a comment or the last line - if (line.substring(0, 2).equals("//") - || fields[1].charAt(0) == '%') { - copy = true; - } - else { - characters++; - String id = fields[1].substring(0, fields[1].indexOf(',')); - if (activeAccounts.contains(id)) { - copy = true; - } - else { - deletedCharacters++; - } - } - if (copy) { - output.println(line); - } - } - } - catch (FileNotFoundException e ) { - System.out.println( - "ERROR: file " + oldAthena.getAbsolutePath() + " not found."); - return; - } - catch (Exception e) { - System.out.println("ERROR: unable to process athena.txt"); - e.printStackTrace(); - return; - } - - input.close(); - output.close(); - - System.out.println( - "Removed " + (accounts - activeAccounts.size()) + "/" + - accounts + " accounts."); - System.out.println( - "Removed " + deletedCharacters + "/" - + characters + " characters."); - } - -} \ No newline at end of file -- cgit v1.2.3-70-g09d2 From bfbb797e6c528e0650826e917d498c52362abbb0 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 24 Mar 2007 16:24:43 +0000 Subject: Merged 0.0 changes from revision 3177 to 3234 to trunk. --- ChangeLog | 162 +++++++- data/graphics/gui/deepbox.png | Bin 266 -> 270 bytes data/graphics/gui/mouse.png | Bin 984 -> 1134 bytes data/graphics/gui/slider.png | Bin 502 -> 571 bytes data/graphics/gui/thickborder.png | Bin 480 -> 530 bytes data/graphics/gui/vscroll_blue.png | Bin 368 -> 395 bytes data/graphics/gui/vscroll_grey.png | Bin 342 -> 371 bytes data/graphics/gui/vscroll_red.png | Bin 367 -> 394 bytes data/icons/CMakeLists.txt | 6 +- data/icons/Makefile.am | 7 +- data/icons/tmw-icon.ico | Bin 2238 -> 0 bytes data/icons/tmw-icon.png | Bin 1103 -> 0 bytes data/icons/tmw-icon.xpm | 56 --- data/icons/tmw.ico | Bin 0 -> 22382 bytes data/icons/tmw.png | Bin 0 -> 18176 bytes data/icons/tmw.xpm | 784 +++++++++++++++++++++++++++++++++++++ docs/Makefile.am | 2 + docs/tmw.6 | 74 ++++ src/CMakeLists.txt | 6 +- src/Makefile.am | 6 +- src/animatedsprite.cpp | 1 - src/being.cpp | 14 +- src/being.h | 4 +- src/engine.cpp | 4 +- src/floor_item.cpp | 1 - src/gui/char_select.cpp | 65 +-- src/gui/char_select.h | 12 +- src/gui/equipmentwindow.cpp | 1 - src/gui/itemcontainer.cpp | 8 +- src/gui/login.cpp | 87 ++-- src/gui/login.h | 30 +- src/gui/register.cpp | 89 +++-- src/gui/register.h | 37 +- src/gui/unregisterdialog.cpp | 2 +- src/gui/viewport.cpp | 110 ++++-- src/gui/viewport.h | 24 ++ src/localplayer.cpp | 1 + src/localplayer.h | 12 + src/logindata.h | 4 +- src/main.cpp | 101 +++-- src/monster.h | 1 - src/net/charserverhandler.cpp | 24 +- src/net/charserverhandler.h | 13 + src/net/equipmenthandler.cpp | 5 + src/net/loginhandler.cpp | 2 +- src/net/protocol.h | 1 + src/npc.cpp | 2 - src/resources/animation.h | 1 - src/resources/image.cpp | 124 +++--- src/resources/image.h | 6 + src/resources/imageset.cpp | 65 +++ src/resources/imageset.h | 66 ++++ src/resources/monsterdb.h | 2 +- src/resources/monsterinfo.h | 157 ++++---- src/resources/resourcemanager.cpp | 22 +- src/resources/resourcemanager.h | 8 +- src/resources/spritedef.cpp | 34 +- src/resources/spritedef.h | 10 +- src/resources/spriteset.cpp | 65 --- src/resources/spriteset.h | 69 ---- src/simpleanimation.cpp | 50 +++ src/simpleanimation.h | 65 +++ src/tileset.h | 8 +- src/tmw.rc | 2 +- tmw.cbp | 22 +- 65 files changed, 1922 insertions(+), 612 deletions(-) delete mode 100644 data/icons/tmw-icon.ico delete mode 100644 data/icons/tmw-icon.png delete mode 100644 data/icons/tmw-icon.xpm create mode 100644 data/icons/tmw.ico create mode 100644 data/icons/tmw.png create mode 100644 data/icons/tmw.xpm create mode 100644 docs/tmw.6 create mode 100644 src/resources/imageset.cpp create mode 100644 src/resources/imageset.h delete mode 100644 src/resources/spriteset.cpp delete mode 100644 src/resources/spriteset.h create mode 100644 src/simpleanimation.cpp create mode 100644 src/simpleanimation.h (limited to 'src/gui/register.h') diff --git a/ChangeLog b/ChangeLog index 95cf4044..d0f661a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,23 @@ -2007-03-23 Eugenio Favalli +2007-03-24 Bjørn Lindeijer + + * src/main.cpp: Changed the order of network message handling and + logic, in order to prevent an incoming character delete message from + deleting the player character that was about to be drawn. + * src/gui/char_select.cpp: Removed useless lock/unlock calls. + * src/logindata.h, src/main.cpp, src/gui/login.cpp: Go back to login + or register state on error, depending on what the user was doing. + * src/gui/register.cpp: Actually use the server that is filled in. + * src/net/loginhandler.cpp: Fixed error message. + * src/net/charserverhandler.cpp: Fixed crash since now logic is called + after non-selected characters are deleted, by properly setting deleted + instances to 0 and going back to initial selection. + * src/main.cpp, src/net/network.h, src/net/network.cpp: Make sure that + when a network error occurs, the error message is available and shown + to the user. + * src/gui/register.h, src/gui/register.cpp: Only enable Register + button when all necessary fields are filled in. + +2007-03-23 Eugenio Favalli * tmw.cbp: Updated and fixed Code::Blocks project file. @@ -6,19 +25,116 @@ * src/gui/char_select.cpp, src/gui/inventorywindow.cpp, src/gui/ministatus.cpp, src/gui/ministatus.h, src/gui/skill.cpp, - src/gui/skill.h, src/gui/status.cpp, src/gui/status.h, src/localplayer.cpp - , src/localplayer.h, src/net/buysellhandler: Redesigned the localplayer - class to use getters and setters instead of direct access to the member - variables. - src/net/charserverhandler.cpp, src/net/playerhandler.cpp, - src/net/protocol.h: Implemented communication of attributes between server - and client. + src/gui/skill.h, src/gui/status.cpp, src/gui/status.h, + src/localplayer.cpp, src/localplayer.h, src/net/buysellhandler: + Redesigned the localplayer class to use getters and setters instead of + direct access to the member variables. + * src/net/charserverhandler.cpp, src/net/playerhandler.cpp, + src/net/protocol.h: Implemented communication of attributes between + server and client. + +2007-03-23 Bjørn Lindeijer + + * src/gui/char_select.cpp, src/gui/char_select.h, + src/net/charserverhandler.h, src/net/charserverhandler.cpp: Clarified + the error message when character creation fails and made sure the + character creation dialog doesn't close when creation failed. + +2007-03-22 Bjørn Lindeijer + + * src/gui/login.cpp, src/gui/login.h, src/gui/register.h, + src/gui/register.cpp: Only enable login button when a username, + password and server are filled in. Pass username, password and server + on to the register dialog. Go back to login dialog when canceling + registration. Fixed a crash caused by deleting an OkDialog twice (it + also deletes itself). Made the register dialog a bit wider. Register + dialog no longer clears username field when it is invalid. + * src/main.cpp, data/icons/CMakeLists.txt, data/icons/Makefile.am, + data/icons/tmw-32x32.png: Use a 32x32 non-alpha layered window icon. + * tmw.cbp: Updated project file. + * data/icons/CMakeLists.txt, data/icons/Makefile.am, src/main.cpp, + data/icons/tmw-32x32.png: Removed 32x32 non-alpha layered window icon + again, and instead used the icon in the executable on Windows. + +2007-03-21 Bjørn Lindeijer + + * src/main.cpp, src/gui/viewport.cpp, src/resources/image.h, + src/resources/image.cpp: Reduced amount of useless logging, calculate + nearest power of two in a function and only do the alpha check in + software mode. + * src/gui/login.cpp: Fixed small issue where default server didn't fit + in the server entry field properly. + * src/main.cpp: Display a progress bar and connecting status for each + server and display the version using a gcn::Label. + * src/gui/viewport.cpp, src/monster.h: Avoiding magic numbers where + possible (1002) and also display the target when other players are + targeted. + * src/floor_item.cpp, src/being.cpp, src/main.cpp, src/CMakeLists.txt, + src/gui/equipmentwindow.cpp, src/gui/viewport.cpp, + src/gui/itemcontainer.cpp, src/gui/viewport.h, src/engine.cpp, + src/animatedsprite.cpp, src/tileset.h, src/npc.cpp, src/Makefile.am, + src/being.h, src/resources/imageset.cpp, src/resources/animation.h, + src/resources/spritedef.cpp, src/resources/resourcemanager.h, + src/resources/spriteset.h, src/resources/imageset.h, + src/resources/resourcemanager.cpp, src/resources/spriteset.cpp, + src/resources/spritedef.h: Renamed Spriteset to ImageSet. + +2007-03-20 David Athay + + * src/gui/viewport.cpp: Fixed target cursor animation, and changed + which layer it is drawn after. + * src/gui/viewport.cpp, src/gui/viewport.h: Split drawing the target + cursor and target name into functions. 2007-03-20 Philipp Sehmisch + * data/graphics/gui/mouse.png: Positioned the cursor image more + accurate. * src/gui/char_select.cpp, src/gui/char_select.h, - src/net/charserverhandler.cpp, src/net/protocol.h: Implemented a GUI for - distributing the characters attributes at character creation. + src/net/charserverhandler.cpp, src/net/protocol.h: Implemented a GUI + for distributing the characters attributes at character creation. + +2007-03-19 David Athay + + * src/localplayer.cpp, src/gui/viewport.cpp, src/gui/viewport.h, + src/net/equipmenthandler.cpp, src/localplayer.h, + src/net/protocol.h: Added target cursor. + +2007-03-18 Bjørn Lindeijer + + * docs/Makefile.am, docs/tmw.6: Added man page by Patrick Matthäi. + * src/resources/image.cpp: Restored alpha layer check, since it should + be more efficient in software mode when SDL knows an image doesn't use + the alpha layer. + * data/graphics/gui/thickborder.png, + data/graphics/gui/vscroll_grey.png, data/graphics/gui/slider.png, + data/graphics/gui/vscroll_blue.png, data/graphics/gui/vscroll_red.png, + data/graphics/gui/deepbox.png, + data/graphics/sprites/monster-slime-red.png, + data/graphics/sprites/monster-scorpion-black.png, + data/graphics/sprites/monster-scorpion.png, + data/graphics/sprites/monster-slime-rudolph.png, + data/graphics/sprites/monster-snake.png, + data/graphics/sprites/monster-slime-santa.png, + data/graphics/sprites/monster-maggot.png, + data/graphics/sprites/monster-spider.png, + data/graphics/sprites/monster-scorpion-red.png, + data/graphics/sprites/monster-slime-yellow.png, + data/graphics/sprites/monster-slime-green.png, + data/graphics/sprites/monster-maggot-giant.png: Replaced pink pixels + with transparent ones. + +2007-03-18 Rogier Polak + + * src/main.cpp: Added (-v) version to the arguments. (Applied a patch + by Patrick Matthäi). + * src/resources/image.cpp: Deleted the "pink code", which added + transparancy with SDL_SetColorKey. + +2007-03-18 Bjørn Lindeijer + + * icons/tmw.ico, icons/tmw.png, icons/tmw.xpm: Replaced icons with the + green globe that is also used on the website. 2007-03-16 Philipp Sehmisch @@ -26,6 +142,25 @@ src/net/accountserver/account.hpp: Implemented 7 atribute system in character creation. +2007-03-14 Bjørn Lindeijer + + * src/main.cpp, src/tmw.rc, data/icons/tmw-icon.png, + data/icons/tmw-icon.xpm, data/icons/tmw.ico, data/icons/tmw-icon.ico, + data/icons/Makefile.am, data/icons/tmw.png, data/icons/tmw.xpm, + data/icons/CMakeLists.txt: Renamed icons to make things easier for + Debian packaging, and the "-icon" part was superfluous anyway. + +2007-03-12 Philipp Sehmisch + + * src/simpleanimation.cpp, src/simpleanimation.h, src/CmakeLists.txt, + src/Makefile.am: Added a simple animation class that hosts a looping + animation without the action and direction stuff from AnimatedSprite. + +2007-03-12 Bjørn Lindeijer + + * data/graphics/items/armor-head-rangerhat.png: New version of ranger + hat icon by Pauan. + 2007-03-11 Philipp Sehmisch * src/map.cpp, src/gui/viewport.cpp: Fixed a bug that made the engine @@ -34,10 +169,11 @@ 2007-03-09 Bjørn Lindeijer * data/graphics/gui/target-cursor-blue.png, - data/graphics/gui/target-cursor-red.png: Added targeting cursors by Pauan. + data/graphics/gui/target-cursor-red.png: Added targeting cursors by + Pauan. * data/graphics/sprites/chest-cotton-male.png, - data/graphics/sprites/chest-cotton-female.png: Replaced cotton shirt with - improved version by Pauan. + data/graphics/sprites/chest-cotton-female.png: Replaced cotton shirt + with improved version by Pauan. 2007-03-03 Rogier Polak diff --git a/data/graphics/gui/deepbox.png b/data/graphics/gui/deepbox.png index 814236ed..ed3231f3 100644 Binary files a/data/graphics/gui/deepbox.png and b/data/graphics/gui/deepbox.png differ diff --git a/data/graphics/gui/mouse.png b/data/graphics/gui/mouse.png index 9276fc7c..2eeb0e51 100644 Binary files a/data/graphics/gui/mouse.png and b/data/graphics/gui/mouse.png differ diff --git a/data/graphics/gui/slider.png b/data/graphics/gui/slider.png index 60ec2392..1f6e6b35 100644 Binary files a/data/graphics/gui/slider.png and b/data/graphics/gui/slider.png differ diff --git a/data/graphics/gui/thickborder.png b/data/graphics/gui/thickborder.png index 2bbd7a50..da72c92f 100644 Binary files a/data/graphics/gui/thickborder.png and b/data/graphics/gui/thickborder.png differ diff --git a/data/graphics/gui/vscroll_blue.png b/data/graphics/gui/vscroll_blue.png index aa236883..397501ce 100644 Binary files a/data/graphics/gui/vscroll_blue.png and b/data/graphics/gui/vscroll_blue.png differ diff --git a/data/graphics/gui/vscroll_grey.png b/data/graphics/gui/vscroll_grey.png index 6bb6bc3f..87ba8758 100644 Binary files a/data/graphics/gui/vscroll_grey.png and b/data/graphics/gui/vscroll_grey.png differ diff --git a/data/graphics/gui/vscroll_red.png b/data/graphics/gui/vscroll_red.png index aadf6925..d7ad4a90 100644 Binary files a/data/graphics/gui/vscroll_red.png and b/data/graphics/gui/vscroll_red.png differ diff --git a/data/icons/CMakeLists.txt b/data/icons/CMakeLists.txt index 30d96d86..e50c7ab9 100644 --- a/data/icons/CMakeLists.txt +++ b/data/icons/CMakeLists.txt @@ -1,9 +1,7 @@ SET(FILES - tmw-icon.ico - tmw-icon.png - tmw-icon.xpm + tmw.png ) INSTALL(FILES ${FILES} DESTINATION ${DATA_DIR}/icons) -INSTALL(FILES "tmw-icon.png" DESTINATION share/pixmaps RENAME tmw.png) +INSTALL(FILES "tmw.png" DESTINATION share/pixmaps) diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am index 26dcd623..375edef7 100644 --- a/data/icons/Makefile.am +++ b/data/icons/Makefile.am @@ -1,14 +1,11 @@ iconsdir = $(pkgdatadir)/data/icons -icons_DATA = \ - tmw-icon.ico \ - tmw-icon.png \ - tmw-icon.xpm +icons_DATA = tmw.png install-data-local: $(mkinstalldirs) $(DESTDIR)$(datadir)/pixmaps - $(INSTALL) $(srcdir)/tmw-icon.png $(DESTDIR)$(datadir)/pixmaps/tmw.png + $(INSTALL) $(srcdir)/tmw.png $(DESTDIR)$(datadir)/pixmaps/tmw.png uninstall-local: rm -f $(DESTDIR)$(datadir)/pixmaps/tmw.png diff --git a/data/icons/tmw-icon.ico b/data/icons/tmw-icon.ico deleted file mode 100644 index 5ba6e1b7..00000000 Binary files a/data/icons/tmw-icon.ico and /dev/null differ diff --git a/data/icons/tmw-icon.png b/data/icons/tmw-icon.png deleted file mode 100644 index 2598a620..00000000 Binary files a/data/icons/tmw-icon.png and /dev/null differ diff --git a/data/icons/tmw-icon.xpm b/data/icons/tmw-icon.xpm deleted file mode 100644 index a9e91161..00000000 --- a/data/icons/tmw-icon.xpm +++ /dev/null @@ -1,56 +0,0 @@ -/* XPM */ -static char *dummy[]={ -"32 32 21 1", -". c None", -"f c #003300", -"s c #003333", -"# c #003366", -"d c #006600", -"h c #009933", -"c c #040404", -"m c #0c0c0c", -"a c #3366cc", -"e c #339933", -"g c #33cc33", -"o c #66cc99", -"r c #993300", -"n c #996633", -"b c #99ccff", -"j c #c0c0c0", -"k c #cc6666", -"q c #cc9933", -"i c #cc9999", -"p c #cccc66", -"l c #efd6c6", -"................................", -".........................#......", -"........#................a......", -".......#a..............#aba#....", -"...#.......cccccccc......a......", -"...a......ccdeddcfdcc....#......", -".#ab#....ccccegdheefc...........", -"...#...cccdheeeeehdddc..........", -".......cheheegeeehddfcc.cc......", -"........ccdhedeeehhdcc..cic.....", -".......ccdhgeeeheeddfc.cijc.....", -".......cfddhehhhddfccc.cikcc....", -".......ccccfdhedfdffc..cjliccm..", -"..........cccdfdfcccc.cciiknc...", -".....cccc...cccccc...cceciiicc..", -"....cgoggccccnpqrc..mcgogeckcec.", -"....ccggogggccqpqccmccecciidogcm", -"....cjncgggecpncnrcccnijijikdec.", -".....ciikceccrqqcncrciiliikcnc..", -"....ccccccrcpqpqnrnkdkiiiiiinc..", -"..cccgogeccnqpccpqncdcseinikrc..", -"..cgooogggecnqcnqcpneedddsknegc.", -"..ccccggoooggcnegeceeegdedseogg.", -"...ccrkggggggoogggoeggegeeddcec.", -".....ccrcceggggeggggeggegeeckcc.", -".....mcnilkcgepccceggecceeecic..", -"......mcriikccinkcpeeencceciic..", -"........cijiilikiikccciknccrkc..", -".......cckiknccckiijiiknrc.cc...", -"........cccncc.ccnkknrccc...c...", -"..........ccc....ccccc..........", -"...........m...................."}; diff --git a/data/icons/tmw.ico b/data/icons/tmw.ico new file mode 100644 index 00000000..61d559a3 Binary files /dev/null and b/data/icons/tmw.ico differ diff --git a/data/icons/tmw.png b/data/icons/tmw.png new file mode 100644 index 00000000..93e6c9ae Binary files /dev/null and b/data/icons/tmw.png differ diff --git a/data/icons/tmw.xpm b/data/icons/tmw.xpm new file mode 100644 index 00000000..06ec2865 --- /dev/null +++ b/data/icons/tmw.xpm @@ -0,0 +1,784 @@ +/* XPM */ +static char * tmw_xpm[] = { +"32 32 749 2", +" c None", +". c #E4EB6D", +"+ c #EFF271", +"@ c #E7EF65", +"# c #DDED61", +"$ c #D6E955", +"% c #DAED4D", +"& c #F6F5A0", +"* c #EFEF89", +"= c #ECF084", +"- c #EDF077", +"; c #EAF075", +"> c #E0E960", +", c #D9E757", +"' c #D4EA52", +") c #CFE74D", +"! c #BEE140", +"~ c #C2E43E", +"{ c #B6DF33", +"] c #F8F7C2", +"^ c #F9F7AB", +"/ c #F2F099", +"( c #EEEF80", +"_ c #F3F077", +": c #F8F8B1", +"< c #E8EE6F", +"[ c #E1EB69", +"} c #DBEB5E", +"| c #D5E852", +"1 c #CDE445", +"2 c #CEE843", +"3 c #B6DC34", +"4 c #A9DA2F", +"5 c #B3E02F", +"6 c #B6E630", +"7 c #F1F2E2", +"8 c #F9F9D4", +"9 c #F9F8C5", +"0 c #F8F8CE", +"a c #F9F8D6", +"b c #F9F7CB", +"c c #F9F7B1", +"d c #F9F7A7", +"e c #E7EE73", +"f c #E4EC69", +"g c #DEEB60", +"h c #D8E755", +"i c #D5EB55", +"j c #C2E33F", +"k c #BEE33C", +"l c #B5E339", +"m c #A7DF2E", +"n c #9BDA28", +"o c #95DA24", +"p c #8DD724", +"q c #F9F9F5", +"r c #F9F9EA", +"s c #F9F9E1", +"t c #F9F9F4", +"u c #F9F7DF", +"v c #F9F7D1", +"w c #F9F7C9", +"x c #F9F7B6", +"y c #F9F7AE", +"z c #D7E363", +"A c #E1EC6B", +"B c #DDEC60", +"C c #D8EC61", +"D c #CDE552", +"E c #C6E543", +"F c #BCE440", +"G c #BEE73E", +"H c #ABDF30", +"I c #ACE230", +"J c #8FD720", +"K c #80D01C", +"L c #80D51A", +"M c #F9F9F7", +"N c #F9F9EB", +"O c #F9F9F9", +"P c #F9F7E6", +"Q c #F9F7D3", +"R c #F9F7CE", +"S c #F9F7BF", +"T c #F9F8B9", +"U c #E6EF8F", +"V c #E1EB65", +"W c #E0ED63", +"X c #D1E452", +"Y c #D3E84D", +"Z c #C3E340", +"` c #BBE13E", +" . c #B0DD35", +".. c #ABDD2E", +"+. c #A0DB2A", +"@. c #95D923", +"#. c #7ED31C", +"$. c #7ED31A", +"%. c #80DA18", +"&. c #F4F3EF", +"*. c #F9F9F6", +"=. c #F9F8F5", +"-. c #F9F7EE", +";. c #F9F7E2", +">. c #F9F7D5", +",. c #F9F6C2", +"'. c #F8F69C", +"). c #D4E56D", +"!. c #E4ED73", +"~. c #DBEA60", +"{. c #DDE961", +"]. c #C9E54E", +"^. c #BFE242", +"/. c #BEE33E", +"(. c #B1DE34", +"_. c #ABDE33", +":. c #95D826", +"<. c #8DD620", +"[. c #8DDB20", +"}. c #91DD1E", +"|. c #71D116", +"1. c #50B910", +"2. c #F9F8F7", +"3. c #F9F8F4", +"4. c #F9F7EB", +"5. c #F9F7E1", +"6. c #F9F5CF", +"7. c #F9F6C9", +"8. c #F9F6BF", +"9. c #D6E471", +"0. c #E9F075", +"a. c #E3EC6B", +"b. c #D9E96D", +"c. c #CEE558", +"d. c #CBE44E", +"e. c #BEDE3E", +"f. c #ACDA37", +"g. c #BCE639", +"h. c #AEE135", +"i. c #9EDB2A", +"j. c #8FD822", +"k. c #7CD31B", +"l. c #82DA1C", +"m. c #63CE13", +"n. c #61CE12", +"o. c #F9F9F8", +"p. c #F9F7F5", +"q. c #F9F4DD", +"r. c #F9F5D7", +"s. c #F9F5C9", +"t. c #F9F5B6", +"u. c #E3ED8D", +"v. c #DEE865", +"w. c #E3ED6D", +"x. c #DDEB5E", +"y. c #D3E755", +"z. c #CAE349", +"A. c #CFEB4D", +"B. c #C1E33B", +"C. c #BCE743", +"D. c #B0E02D", +"E. c #95DB28", +"F. c #95DB26", +"G. c #C6E627", +"H. c #E8F433", +"I. c #CAED26", +"J. c #60CD0F", +"K. c #58CD0E", +"L. c #F9F7EC", +"M. c #F9F7F1", +"N. c #F9F4E4", +"O. c #F9F3D7", +"P. c #F9F3CA", +"Q. c #F9F5CA", +"R. c #F9F5BB", +"S. c #F9F8B6", +"T. c #F6F89E", +"U. c #DFEB5C", +"V. c #CEE453", +"W. c #D0E753", +"X. c #CDE543", +"Y. c #C7E842", +"Z. c #C1E53C", +"`. c #A7DC30", +" + c #E6F453", +".+ c #E2F448", +"++ c #D8F03C", +"@+ c #D1ED2E", +"#+ c #D0F033", +"$+ c #CAED2C", +"%+ c #ACE51F", +"&+ c #55CF0F", +"*+ c #F5F6EF", +"=+ c #F9F9F2", +"-+ c #F9F9F1", +";+ c #F9F8F0", +">+ c #F9F7E7", +",+ c #F9F5F0", +"'+ c #F9F3E1", +")+ c #F9F5DB", +"!+ c #F9F6DB", +"~+ c #F9F6BE", +"{+ c #F8F59B", +"]+ c #F9F5A2", +"^+ c #F8F68D", +"/+ c #F7F689", +"(+ c #D7EC65", +"_+ c #CEE84E", +":+ c #BBE23F", +"<+ c #B6E238", +"[+ c #A2DC30", +"}+ c #EBF553", +"|+ c #E4F443", +"1+ c #DCF340", +"2+ c #D4F033", +"3+ c #CEEF2D", +"4+ c #C2E926", +"5+ c #BEEB20", +"6+ c #5CD50E", +"7+ c #53CE0D", +"8+ c #F9F7D9", +"9+ c #F9F6F2", +"0+ c #F9F5EB", +"a+ c #F9F3DA", +"b+ c #F9F6DF", +"c+ c #F9F7D0", +"d+ c #F9F7C2", +"e+ c #F9F7BB", +"f+ c #F8F68F", +"g+ c #F7F58D", +"h+ c #F6F58B", +"i+ c #EEF68B", +"j+ c #BFDF43", +"k+ c #B5DE37", +"l+ c #B5E234", +"m+ c #A7DD30", +"n+ c #E7F248", +"o+ c #D6EF40", +"p+ c #DBF239", +"q+ c #D0ED2F", +"r+ c #C3EB2A", +"s+ c #BCEB26", +"t+ c #B5E81E", +"u+ c #52CE0F", +"v+ c #4ECB0B", +"w+ c #F9F9D9", +"x+ c #F9F9D7", +"y+ c #F9F8F8", +"z+ c #F9F7E9", +"A+ c #F9F6E9", +"B+ c #F9F5E0", +"C+ c #F8F2D6", +"D+ c #F9F3CE", +"E+ c #F9F7CA", +"F+ c #F9F8B5", +"G+ c #F6F691", +"H+ c #F9F699", +"I+ c #F5F68F", +"J+ c #F3F579", +"K+ c #E8F575", +"L+ c #C7E646", +"M+ c #B5DF37", +"N+ c #B9E438", +"O+ c #9CD928", +"P+ c #D7F348", +"Q+ c #DBEF3B", +"R+ c #D1EF35", +"S+ c #D7F230", +"T+ c #C1EA25", +"U+ c #B5E91F", +"V+ c #63DC1E", +"W+ c #48CA0C", +"X+ c #F4F4DC", +"Y+ c #F9F9C3", +"Z+ c #F9F9C5", +"`+ c #F9F9C7", +" @ c #F9F9E8", +".@ c #F9F6DD", +"+@ c #F9F6D6", +"@@ c #F9F3C1", +"#@ c #F9F3BF", +"$@ c #F9F5B8", +"%@ c #F8F8A6", +"&@ c #F6F68F", +"*@ c #F4F791", +"=@ c #ABD746", +"-@ c #C5E449", +";@ c #C1E448", +">@ c #BBE23E", +",@ c #BBE237", +"'@ c #A9DC30", +")@ c #99D927", +"!@ c #D3E32C", +"~@ c #E2F340", +"{@ c #D3ED2D", +"]@ c #CAED2B", +"^@ c #CDF028", +"/@ c #C5EB27", +"(@ c #B0E51C", +"_@ c #91DC13", +":@ c #49CA08", +"<@ c #25B305", +"[@ c #F5F6BE", +"}@ c #F5F5A9", +"|@ c #F3F4B0", +"1@ c #F6F6B0", +"2@ c #F7F8B5", +"3@ c #EDF097", +"4@ c #F5F18F", +"5@ c #F9F7B8", +"6@ c #F9F4B0", +"7@ c #F9F3AE", +"8@ c #F9F3A4", +"9@ c #F9F7A4", +"0@ c #F7F7A0", +"a@ c #F5F682", +"b@ c #D3E75E", +"c@ c #CAE646", +"d@ c #CBE846", +"e@ c #EDF05A", +"f@ c #C6E432", +"g@ c #A9E02E", +"h@ c #99DA27", +"i@ c #B9DB20", +"j@ c #E1F33F", +"k@ c #CEEB2E", +"l@ c #C7EB27", +"m@ c #BBEA26", +"n@ c #B9E722", +"o@ c #A6DF19", +"p@ c #ABE815", +"q@ c #48CB09", +"r@ c #3ECA08", +"s@ c #F8F7A7", +"t@ c #F3F4A0", +"u@ c #F4F59C", +"v@ c #F0F49C", +"w@ c #F2F5A4", +"x@ c #F5F6A0", +"y@ c #EFF28F", +"z@ c #F9F8CD", +"A@ c #F9F6A7", +"B@ c #F9F3A0", +"C@ c #F8F399", +"D@ c #F8F493", +"E@ c #F8F693", +"F@ c #F7F58B", +"G@ c #E8EF65", +"H@ c #C7E445", +"I@ c #C7DB30", +"J@ c #E1ED48", +"K@ c #E8F353", +"L@ c #C3E227", +"M@ c #D9EB2E", +"N@ c #E7F549", +"O@ c #D3EE3B", +"P@ c #CBED2D", +"Q@ c #CDEF27", +"R@ c #BFEC23", +"S@ c #B6E81E", +"T@ c #A9E518", +"U@ c #B1EB1B", +"V@ c #35BE06", +"W@ c #38C306", +"X@ c #F9F9A7", +"Y@ c #F2F38F", +"Z@ c #F2F495", +"`@ c #F3F38D", +" # c #F9F9E9", +".# c #F7F8C5", +"+# c #F8F7D1", +"@# c #F8F6A2", +"## c #F9F7A9", +"$# c #F8F59C", +"%# c #F8F291", +"&# c #F8F58F", +"*# c #F6F789", +"=# c #F2F477", +"-# c #F0F571", +";# c #EAEE52", +"># c #DCEA45", +",# c #EBEF43", +"'# c #E4F04D", +")# c #DEEF45", +"!# c #E1F246", +"~# c #E4F448", +"{# c #DBF039", +"]# c #D9F235", +"^# c #C9ED2B", +"/# c #CAEF2C", +"(# c #CEF22B", +"_# c #B6E91E", +":# c #B1EB21", +"<# c #A9E815", +"[# c #48CF09", +"}# c #40CD06", +"|# c #EDEF6B", +"1# c #EBF07C", +"2# c #E7EB71", +"3# c #E8E865", +"4# c #F8F79E", +"5# c #F8F7A4", +"6# c #F9F69E", +"7# c #F8F48F", +"8# c #F6F280", +"9# c #F6F482", +"0# c #F3F473", +"a# c #EFF169", +"b# c #EDF467", +"c# c #EAF35C", +"d# c #EAF258", +"e# c #E4F052", +"f# c #E4F046", +"g# c #E0F03F", +"h# c #D5EE3B", +"i# c #DFF23E", +"j# c #D7F137", +"k# c #CEED2E", +"l# c #C9EF28", +"m# c #CAF025", +"n# c #B9EA1E", +"o# c #B3E91D", +"p# c #B1EB1A", +"q# c #A6E817", +"r# c #39C506", +"s# c #35C505", +"t# c #B3BC3E", +"u# c #E9F07C", +"v# c #DEE867", +"w# c #F9F79E", +"x# c #F8F793", +"y# c #F8F78F", +"z# c #F7F684", +"A# c #F5F27E", +"B# c #F4F26D", +"C# c #F4F36F", +"D# c #EDF061", +"E# c #EEF363", +"F# c #EDF35C", +"G# c #EEF45C", +"H# c #EAF357", +"I# c #E8F34B", +"J# c #DCEE43", +"K# c #E1F03F", +"L# c #D6ED37", +"M# c #D5EE33", +"N# c #D5F134", +"O# c #D9F232", +"P# c #CEF22D", +"Q# c #C7F22A", +"R# c #9BDB18", +"S# c #A7E518", +"T# c #AEEB1B", +"U# c #95E514", +"V# c #37C306", +"W# c #3CC705", +"X# c #E0EC60", +"Y# c #D1E455", +"Z# c #F7F78F", +"`# c #F7F891", +" $ c #F8F78B", +".$ c #F5F782", +"+$ c #F8F791", +"@$ c #EFF06B", +"#$ c #F3F36D", +"$$ c #EFF36D", +"%$ c #F1F56F", +"&$ c #EDF260", +"*$ c #EDF461", +"=$ c #E7F150", +"-$ c #E9F355", +";$ c #E8F349", +">$ c #E8F442", +",$ c #DDF13E", +"'$ c #DAF038", +")$ c #CEEB26", +"!$ c #D0EE2C", +"~$ c #B9E82A", +"{$ c #C1ED26", +"]$ c #A0E41C", +"^$ c #ABE71B", +"/$ c #99E315", +"($ c #99E415", +"_$ c #33B306", +":$ c #2BBB05", +"<$ c #D9EB5E", +"[$ c #CDE44E", +"}$ c #F6F579", +"|$ c #F4F577", +"1$ c #F3F571", +"2$ c #F4F57C", +"3$ c #F3F363", +"4$ c #F2F475", +"5$ c #F0F567", +"6$ c #A2D93F", +"7$ c #C3E43F", +"8$ c #B6D92E", +"9$ c #A7CD1F", +"0$ c #E4F042", +"a$ c #E4F248", +"b$ c #E5F348", +"c$ c #D7EC39", +"d$ c #DBF33C", +"e$ c #DDF23E", +"f$ c #D1EF2D", +"g$ c #C1E825", +"h$ c #BFEB26", +"i$ c #AEE61B", +"j$ c #A7E318", +"k$ c #B0E818", +"l$ c #9EE615", +"m$ c #6DD30D", +"n$ c #27A603", +"o$ c #2CBE05", +"p$ c #E2ED50", +"q$ c #CBE348", +"r$ c #F6F780", +"s$ c #F5F577", +"t$ c #F3F56F", +"u$ c #EFF469", +"v$ c #F3F471", +"w$ c #F3F46F", +"x$ c #EFF461", +"y$ c #E7F053", +"z$ c #C6E83F", +"A$ c #A4D733", +"B$ c #ABDD2F", +"C$ c #B0DF2E", +"D$ c #A7DD2B", +"E$ c #E4F240", +"F$ c #E8F555", +"G$ c #DDF33C", +"H$ c #E1F53E", +"I$ c #D4F032", +"J$ c #CEF02E", +"K$ c #CAEF2D", +"L$ c #C2EF28", +"M$ c #B5E91B", +"N$ c #93DD13", +"O$ c #93E215", +"P$ c #93E213", +"Q$ c #80DB0D", +"R$ c #45CA05", +"S$ c #2FC204", +"T$ c #CEE743", +"U$ c #C1E23E", +"V$ c #F0F365", +"W$ c #F5F473", +"X$ c #F2F269", +"Y$ c #E9EF57", +"Z$ c #EFF363", +"`$ c #E8F052", +" % c #EBF358", +".% c #B8E439", +"+% c #BCE839", +"@% c #A4DC2A", +"#% c #ABE22D", +"$% c #95D822", +"%% c #E1F240", +"&% c #D6ED32", +"*% c #CFEC2C", +"=% c #D4F02F", +"-% c #CAEE2B", +";% c #C3EB27", +">% c #C6EE25", +",% c #C3EE21", +"'% c #B8ED21", +")% c #AEEA16", +"!% c #79D90F", +"~% c #2EB106", +"{% c #26B808", +"]% c #2CBF05", +"^% c #C9E73B", +"/% c #C5E63C", +"(% c #F0F56B", +"_% c #EEF258", +":% c #F0F265", +"<% c #EFF155", +"[% c #EDF358", +"}% c #EBF550", +"|% c #EBF54D", +"1% c #C9E83B", +"2% c #A4DB28", +"3% c #9EDC2B", +"4% c #8FD622", +"5% c #82D01E", +"6% c #7EC512", +"7% c #C9E827", +"8% c #D0EE2E", +"9% c #C7ED2C", +"0% c #C7EE27", +"a% c #C1EE2A", +"b% c #C2EF24", +"c% c #BEED22", +"d% c #A9E718", +"e% c #3EC307", +"f% c #39C306", +"g% c #38C606", +"h% c #23B603", +"i% c #ACDB2F", +"j% c #B0DF34", +"k% c #EDF35A", +"l% c #EDF553", +"m% c #E2F045", +"n% c #E6F350", +"o% c #E6F448", +"p% c #9CD01E", +"q% c #8BC916", +"r% c #B8DC1B", +"s% c #7CBC0F", +"t% c #95D618", +"u% c #7ED319", +"v% c #BFE118", +"w% c #C6ED2A", +"x% c #C1EA21", +"y% c #C1ED22", +"z% c #B8EA1D", +"A% c #B6EB1D", +"B% c #BCEF1F", +"C% c #53CA07", +"D% c #3FC708", +"E% c #2EBC05", +"F% c #2FBE04", +"G% c #2DBF04", +"H% c #A2CF1F", +"I% c #B1E12F", +"J% c #B5E32E", +"K% c #E8F243", +"L% c #D7EB45", +"M% c #E8F245", +"N% c #DDEF40", +"O% c #E2F342", +"P% c #DFF33E", +"Q% c #E4F542", +"R% c #DAF138", +"S% c #D8F230", +"T% c #CBEB28", +"U% c #D1F02E", +"V% c #C6EC24", +"W% c #CAEF25", +"X% c #BCEB21", +"Y% c #B6EB1E", +"Z% c #ABE91B", +"`% c #A2E616", +" & c #3CC508", +".& c #3EC906", +"+& c #37C305", +"@& c #27B903", +"#& c #209B02", +"$& c #A9DF27", +"%& c #A4DD27", +"&& c #91D623", +"*& c #E3F13C", +"=& c #E4F340", +"-& c #E4F33F", +";& c #E4F43E", +">& c #E2F439", +",& c #D6F033", +"'& c #D5F034", +")& c #CEEF2E", +"!& c #CBED26", +"~& c #CFEF27", +"{& c #D5F22E", +"]& c #B5E620", +"^& c #B9EA1F", +"/& c #84E620", +"(& c #3EB508", +"_& c #58CE0D", +":& c #39CA11", +"<& c #3EC607", +"[& c #3BCA08", +"}& c #28BB04", +"|& c #28BC03", +"1& c #8FD620", +"2& c #97D823", +"3& c #A6E22B", +"4& c #69CB1D", +"5& c #86D61F", +"6& c #E5F740", +"7& c #DCF338", +"8& c #CAEC2D", +"9& c #CDED2B", +"0& c #D1F02C", +"a& c #CDEE27", +"b& c #C1EB22", +"c& c #CFF228", +"d& c #BCE922", +"e& c #3CBB09", +"f& c #50CD0C", +"g& c #4BCD0B", +"h& c #3CC207", +"i& c #42CD09", +"j& c #2EBB04", +"k& c #28B905", +"l& c #28B903", +"m& c #61B113", +"n& c #7ED41A", +"o& c #89D71B", +"p& c #8DDB1A", +"q& c #7CD518", +"r& c #8FDA1B", +"s& c #71D314", +"t& c #7CDA18", +"u& c #BEF232", +"v& c #8BD715", +"w& c #63C207", +"x& c #55C108", +"y& c #5AD111", +"z& c #4BC90B", +"A& c #3EC108", +"B& c #46C908", +"C& c #40CB08", +"D& c #34C205", +"E& c #32C505", +"F& c #22A003", +"G& c #79D818", +"H& c #75D314", +"I& c #67D012", +"J& c #69D313", +"K& c #71D613", +"L& c #67D413", +"M& c #4BC20C", +"N& c #4DCB0E", +"O& c #5AD510", +"P& c #50CA0B", +"Q& c #4BC909", +"R& c #3CC708", +"S& c #42C906", +"T& c #35C206", +"U& c #33C306", +"V& c #30C504", +"W& c #49C30E", +"X& c #71D913", +"Y& c #84E318", +"Z& c #5ECF0E", +"`& c #58D00D", +" * c #5ED40D", +".* c #48C70A", +"+* c #57D40B", +"@* c #37BE06", +"#* c #39C707", +"$* c #37C505", +"%* c #34C705", +"&* c #49BE0B", +"** c #4BD00C", +"=* c #46C609", +"-* c #46D00A", +";* c #33BE06", +">* c #20A904", +" . + @ # $ % ", +" & * = - ; > , ' ) ! ~ { ", +" ] ^ / ( _ : < [ } | 1 2 3 4 5 6 ", +" 7 8 9 0 a b c d e f g h i j k l m n o p ", +" q r s t u v w x y z A B C D E F G H I J K L ", +" M M N O P u Q R S T U V W X Y Z ` ...+.@.#.$.%. ", +" &.O *.O =.-.;.>.R ,.'.).!.~.{.].^./.(._.:.<.[.}.|.1. ", +" O O O 2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.g.h.i.j.k.l.m.n. ", +" o.O *.p.p.3.-.q.r.s.t.u.v.w.x.y.z.A.B.C.D.E.F.G.H.I.J.K. ", +" O o.q L.p.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.`. +.+++@+#+$+%+&+ ", +" *+=+-+;+>+p.,+'+)+!+~+8.{+]+^+/+(+_+:+<+[+}+|+1+2+3+4+5+6+7+ ", +" r N N 8+p.9+0+a+b+c+d+e+d f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+ ", +" w+x+w+y+z+A+B+C+D+E+S F+G+H+I+J+K+L+M+N+O+P+Q+R+S+$+T+U+V+W+ ", +"X+Y+Z+`+ @.@+@6.@@#@$@^ %@&@*@=@-@;@>@,@'@)@!@~@{@]@^@/@(@_@:@<@", +"[@}@|@1@2@3@4@5@6@7@8@9@0@a@b@) c@d@e@f@g@h@i@j@k@l@m@n@o@p@q@r@", +"s@t@u@v@w@x@y@z@A@B@C@D@E@F@G@H@>@I@J@K@L@M@N@O@P@Q@R@S@T@U@V@W@", +"X@Y@Z@`@ #.#+#@###$#%#&#*#=#-#;#>#,#'#)#!#~#{#]#^#/#(#_#:#<#[#}#", +"|#1#2#3#4###5#'.6#7#8#9#0#a#b#c#d#e#f#g#h#i#j#k#l#m#n#o#p#q#r#s#", +"t#u#v#w#s@x#y#z#a@A#B#C#D#E#F#G#H#I#J#K#L#M#N#O#P#Q#R#S#T#U#V#W#", +" X#Y#Z#`# $.$+$@$#$$$%$&$*$=$-$I#;$>$,$'$)$!$~${$]$^$/$($_$:$ ", +" <$[$}$|$*#1$2$3$4$5$6$7$8$9$0$a$b$c$d$e$f$g$h$i$j$k$l$m$n$o$ ", +" p$q$r$s$t$u$v$w$x$y$z$A$B$C$D$E$F$G$H$I$J$K$L$M$N$O$P$Q$R$S$ ", +" T$U$V$W$X$Y$Z$`$ %.%+%@%#%$%%%&%*%=%-%;%>%,%'%)%!%~%{%]% ", +" ^%/%(%_%:%<%[%}%|%1%2%3%4%5%6%7%8%9%0%a%b%c%d%($e%f%g%h% ", +" i%j%k%l%a$m%n%o%p%q%r%s%t%u%v%w%x%y%z%A%B%C%D%E%F%G% ", +" H%I%J%K%L%M%N%O%P%Q%G$R%S%T%U%V%W%X%Y%Z%`% &.&+&@&#& ", +" $&%&&&*&=&-&;&>&,&'&)&!&~&{&]&^&/&(&_&:&<&[&}&|& ", +" 1&2&3&4&5&6&7&8&9&0&a&b&c&d&e&f&g&h&i&j&k&l& ", +" m&n&o&p&q&r&s&t&u&v&w&x&y&z&A&B&C&D&E&F& ", +" G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V& ", +" W&X&Y&Z&`& *.*+*@*#*$*%* ", +" &***=*-*;*>* "}; diff --git a/docs/Makefile.am b/docs/Makefile.am index e106768b..8b57d5bb 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -1,3 +1,5 @@ +man6_MANS = tmw.6 + EXTRA_DIST = packages.txt \ FAQ.txt \ HACKING.txt \ diff --git a/docs/tmw.6 b/docs/tmw.6 new file mode 100644 index 00000000..0dee82c7 --- /dev/null +++ b/docs/tmw.6 @@ -0,0 +1,74 @@ +.TH "TMW" "6" +.SH "NAME" +tmw \- tmw is The Mana World: A fantasy online game +.SH "SYNOPSIS" +\fBtmw\fR +.SH "DESCRIPTION" +This manual page documents briefly the +\fBtmw\fR ingame +commands. +\fBtmw\fR is a great online game based upon the Seiken Densetsu Serie. +It has its own universe, and and its own character management system, which will +give you the opportunity to play in a 2D heroic-fantasy world forever. +.SH "BINARY PARAMETERS" +This program follows the usual GNU command line syntax, with long +options starting with two dashes (`-'). +A summary of options is included below. +.TP +.B \-h, \-\-help +Show summary of options. +.TP +.B \-v, \-\-version +Show version of the program. +.TP +.B \-u, \-\-skipupdate +Skip the update process. +.TP +.B \-U, \-\-username +Login with this username. +.TP +.B \-P, \-\-password +Login with this password. +.TP +.B \-D, \-\-default +Bypass the login process with default settings. +.TP +.B \-p, \-\-playername +Login with this player. +.TP +.B \-C, \-\-configfile +Configuration file to use +.SH "COMMON KEYS" +.TP +.B Arrow Keys: +Move your character around. +.TP +.B Left Ctrl: +Make your character attack. +.TP +.B Key A: +Target nearest monster. +.TP +.B Key G: +Get items on the ground or in a chest. +.TP +.B Alt + 1...9: +Shows an emoticon above your character. +.TP +.B Alt + I: +Shows / Hide inventory window. +.TP +.B Alt + K: +Shows / Hide skills window. +.TP +.B Alt + E: +Shows / Hide equipment window. +.TP +.B Alt + C: +Shows configuration window. +.SH "AUTHOR" +This manual page was written by Patrick Matth\[:a]i +for The Mana World project. +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU General Public License, Version 2 any +later version published by the Free Software Foundation. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4b5bad01..e28e235e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -268,10 +268,10 @@ SET(SRCS resources/sdlimageloader.h resources/soundeffect.cpp resources/soundeffect.h - resources/spriteset.cpp resources/spritedef.h resources/spritedef.cpp - resources/spriteset.h + resources/imageset.h + resources/imageset.cpp utils/base64.cpp utils/base64.h utils/dtor.h @@ -330,6 +330,8 @@ SET(SRCS player.h properties.h serverinfo.h + simpleanimation.cpp + simpleanimation.h sound.cpp sound.h sprite.h diff --git a/src/Makefile.am b/src/Makefile.am index da1bc44d..f1f51b79 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -222,8 +222,8 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \ resources/soundeffect.cpp \ resources/spritedef.h \ resources/spritedef.cpp \ - resources/spriteset.h \ - resources/spriteset.cpp \ + resources/imageset.h \ + resources/imageset.cpp \ resources/buddylist.h \ resources/buddylist.cpp \ utils/base64.cpp \ @@ -284,6 +284,8 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \ player.h \ properties.h \ serverinfo.h \ + simpleanimation.cpp \ + simpleanimation.h \ sound.cpp \ sound.h \ sprite.h \ diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 3d1979a9..7260a512 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -30,7 +30,6 @@ #include "resources/animation.h" #include "resources/image.h" #include "resources/resourcemanager.h" -#include "resources/spriteset.h" #include "utils/xml.h" diff --git a/src/being.cpp b/src/being.cpp index e4a1e9fc..682daddb 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -34,7 +34,7 @@ #include "map.h" #include "resources/resourcemanager.h" -#include "resources/spriteset.h" +#include "resources/imageset.h" #include "gui/gui.h" @@ -42,7 +42,7 @@ #include "utils/tostring.h" int Being::instances = 0; -Spriteset *Being::emotionset = NULL; +ImageSet *Being::emotionSet = NULL; Being::Being(Uint16 id, Uint16 job, Map *map): mJob(job), @@ -72,8 +72,8 @@ Being::Being(Uint16 id, Uint16 job, Map *map): { // Load the emotion set ResourceManager *rm = ResourceManager::getInstance(); - emotionset = rm->getSpriteset("graphics/sprites/emotions.png", 30, 32); - if (!emotionset) logger->error("Unable to load emotions spriteset!"); + emotionSet = rm->getImageSet("graphics/sprites/emotions.png", 30, 32); + if (!emotionSet) logger->error("Unable to load emotions!"); } instances++; @@ -89,8 +89,8 @@ Being::~Being() if (instances == 0) { - emotionset->decRef(); - emotionset = NULL; + emotionSet->decRef(); + emotionSet = NULL; } } @@ -515,7 +515,7 @@ Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY) int px = mPx + offsetX + 3; int py = mPy + offsetY - 60; - graphics->drawImage(emotionset->get(mEmotion - 1), px, py); + graphics->drawImage(emotionSet->get(mEmotion - 1), px, py); } void diff --git a/src/being.h b/src/being.h index c3cba247..332f1b4a 100644 --- a/src/being.h +++ b/src/being.h @@ -41,7 +41,7 @@ class Equipment; class Item; class Map; class Graphics; -class Spriteset; +class ImageSet; /** * A position along a being's path. @@ -397,7 +397,7 @@ class Being : public Sprite Uint16 mStepTime; static int instances; /**< Number of Being instances */ - static Spriteset *emotionset; /**< Emoticons used by beings */ + static ImageSet *emotionSet; /**< Emoticons used by beings */ }; #endif diff --git a/src/engine.cpp b/src/engine.cpp index a3097d49..31bec9ff 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -44,7 +44,6 @@ #include "resources/mapreader.h" #include "resources/monsterdb.h" #include "resources/resourcemanager.h" -#include "resources/spriteset.h" #include "utils/dtor.h" #include "utils/tostring.h" @@ -77,7 +76,8 @@ void Engine::changeMap(const std::string &mapPath) // Notify the minimap and beingManager about the map change Image *mapImage = NULL; - if (newMap->hasProperty("minimap")) { + if (newMap->hasProperty("minimap")) + { ResourceManager *resman = ResourceManager::getInstance(); mapImage = resman->getImage(newMap->getProperty("minimap")); } diff --git a/src/floor_item.cpp b/src/floor_item.cpp index f33f7eb4..5d83e1dd 100644 --- a/src/floor_item.cpp +++ b/src/floor_item.cpp @@ -27,7 +27,6 @@ #include "resources/itemdb.h" #include "resources/iteminfo.h" -#include "resources/spriteset.h" FloorItem::FloorItem(unsigned int id, diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 09ce5b87..128a803e 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -42,9 +42,14 @@ #include "../logindata.h" #include "../net/accountserver/account.h" +#include "../net/charserverhandler.h" +#include "../net/messageout.h" #include "../utils/tostring.h" +// Defined in main.cpp, used here for setting the char create dialog +extern CharServerHandler charServerHandler; + /** * Listener for confirming character deletion. */ @@ -155,14 +160,14 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) } else if (event.getId() == "new") { - //TODO: search the first free slot, and start CharCreateDialog - // maybe add that search to the constructor + // TODO: Search the first free slot, and start CharCreateDialog + // maybe add that search to the constructor. if (!(mCharInfo->getEntry())) { // Start new character dialog - mCharInfo->lock(); - new CharCreateDialog(this, mCharInfo->getPos()); - mCharInfo->unlock(); + CharCreateDialog *charCreateDialog = + new CharCreateDialog(this, mCharInfo->getPos()); + charServerHandler.setCharCreateDialog(charCreateDialog); } } else if (event.getId() == "delete") @@ -344,14 +349,19 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot): setLocationRelativeTo(getParent()); setVisible(true); + mNameField->requestFocus(); } CharCreateDialog::~CharCreateDialog() { delete mPlayer; + + // Make sure the char server handler knows that we're gone + charServerHandler.setCharCreateDialog(0); } -void CharCreateDialog::action(const gcn::ActionEvent &event) +void +CharCreateDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "create") { if (getName().length() >= 4) { @@ -362,15 +372,14 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) mPlayer->getHairStyle(), mPlayer->getHairColor(), 0, // gender - (int)mAttributeSlider[0]->getValue(), // STR - (int)mAttributeSlider[1]->getValue(), // AGI - (int)mAttributeSlider[2]->getValue(), // DEX - (int)mAttributeSlider[3]->getValue(), // VIT - (int)mAttributeSlider[4]->getValue(), // INT - (int)mAttributeSlider[5]->getValue(), // WILL - (int)mAttributeSlider[6]->getValue() // CHAR + (int) mAttributeSlider[0]->getValue(), // STR + (int) mAttributeSlider[1]->getValue(), // AGI + (int) mAttributeSlider[2]->getValue(), // DEX + (int) mAttributeSlider[3]->getValue(), // VIT + (int) mAttributeSlider[4]->getValue(), // INT + (int) mAttributeSlider[5]->getValue(), // WILL + (int) mAttributeSlider[6]->getValue() // CHAR ); - scheduleDelete(); } else { new OkDialog("Error", @@ -399,21 +408,23 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) } } -std::string CharCreateDialog::getName() +const std::string& +CharCreateDialog::getName() { return mNameField->getText(); } void CharCreateDialog::UpdateSliders() { - for (int i=0; i<=6; i++) + for (int i = 0; i < 7; i++) { - // update captions - mAttributeValue[i]->setCaption(toString((int)(mAttributeSlider[i]->getValue()))); + // Update captions + mAttributeValue[i]->setCaption( + toString((int) (mAttributeSlider[i]->getValue()))); mAttributeValue[i]->adjustSize(); } - // update distributed points + // Update distributed points int pointsLeft = 70 - getDistributedPoints(); if (pointsLeft == 0) { @@ -425,24 +436,32 @@ void CharCreateDialog::UpdateSliders() mCreateButton->setEnabled(false); if (pointsLeft > 0) { - mAttributesLeft->setCaption(std::string("Please distribute " + toString(pointsLeft) + " points")); + mAttributesLeft->setCaption(std::string("Please distribute " + + toString(pointsLeft) + " points")); } else { - mAttributesLeft->setCaption(std::string("Please remove " + toString(-pointsLeft) + " points")); + mAttributesLeft->setCaption(std::string("Please remove " + + toString(-pointsLeft) + " points")); } } mAttributesLeft->adjustSize(); } +void +CharCreateDialog::unlock() +{ + mCreateButton->setEnabled(true); +} + int CharCreateDialog::getDistributedPoints() { int points = 0; - for (int i=0; i<7; i++) + for (int i = 0; i < 7; i++) { - points += (int)mAttributeSlider[i]->getValue(); + points += (int) mAttributeSlider[i]->getValue(); } return points; } diff --git a/src/gui/char_select.h b/src/gui/char_select.h index 5066897e..9d9184ea 100644 --- a/src/gui/char_select.h +++ b/src/gui/char_select.h @@ -114,9 +114,17 @@ class CharCreateDialog : public Window, public gcn::ActionListener */ ~CharCreateDialog(); - void action(const gcn::ActionEvent &event); + void + action(const gcn::ActionEvent &event); - std::string getName(); + const std::string& + getName(); + + /** + * Unlocks the dialog, enabling the create character button again. + */ + void + unlock(); private: int getDistributedPoints(); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index ec525c47..ec84491e 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -30,7 +30,6 @@ #include "../resources/iteminfo.h" #include "../resources/resourcemanager.h" -#include "../resources/spriteset.h" #include "../utils/tostring.h" diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 308311b7..a176f226 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -35,7 +35,6 @@ #include "../resources/image.h" #include "../resources/iteminfo.h" #include "../resources/resourcemanager.h" -#include "../resources/spriteset.h" #include "../utils/tostring.h" @@ -65,7 +64,8 @@ ItemContainer::logic() int i = mInventory->getLastUsedSlot() + 1; - if (i != mMaxItems) { + if (i != mMaxItems) + { mMaxItems = i; setWidth(getWidth()); } @@ -192,9 +192,9 @@ ItemContainer::mousePressed(gcn::MouseEvent &event) int my = event.getY(); int index = mx / gridWidth + ((my / gridHeight) * columns); - if (index > INVENTORY_SIZE) { + if (index > INVENTORY_SIZE) index = INVENTORY_SIZE - 1; - } + setSelectedItem(mInventory->getItem(index)); } } diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 9df3b489..15ec6314 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -36,24 +36,6 @@ #include "passwordfield.h" #include "textfield.h" -void -WrongDataNoticeListener::setTarget(gcn::TextField *textField) -{ - mTarget = textField; -} - -void -WrongDataNoticeListener::action(const gcn::ActionEvent &event) -{ - if (event.getId() == "ok") - { - // Reset the field - mTarget->setText(""); - mTarget->setCaretPosition(0); - mTarget->requestFocus(); - } -} - LoginDialog::LoginDialog(LoginData *loginData): Window("Login"), mLoginData(loginData) { @@ -66,28 +48,33 @@ LoginDialog::LoginDialog(LoginData *loginData): mCancelButton = new Button("Cancel", "cancel", this); mRegisterButton = new Button("Register", "register", this); - setContentSize(200, 91); + const int width = 220; + const int height = 100; + + setContentSize(width, height); userLabel->setPosition(5, 5); passLabel->setPosition(5, 14 + userLabel->getHeight()); mUserField->setPosition(65, 5); mPassField->setPosition(65, 14 + userLabel->getHeight()); - mUserField->setWidth(130); - mPassField->setWidth(130); + mUserField->setWidth(width - 70); + mPassField->setWidth(width - 70); mKeepCheck->setPosition(4, 68); mCancelButton->setPosition( - 200 - mCancelButton->getWidth() - 5, - 91 - mCancelButton->getHeight() - 5); + width - mCancelButton->getWidth() - 5, + height - mCancelButton->getHeight() - 5); mOkButton->setPosition( mCancelButton->getX() - mOkButton->getWidth() - 5, - 91 - mOkButton->getHeight() - 5); + height - mOkButton->getHeight() - 5); mRegisterButton->setPosition( mKeepCheck->getX() + mKeepCheck->getWidth() + 10, - 91 - mRegisterButton->getHeight() - 5); + height - mRegisterButton->getHeight() - 5); mUserField->setActionEventId("ok"); mPassField->setActionEventId("ok"); + mUserField->addKeyListener(this); + mPassField->addKeyListener(this); mUserField->addActionListener(this); mPassField->addActionListener(this); mKeepCheck->addActionListener(this); @@ -110,37 +97,27 @@ LoginDialog::LoginDialog(LoginData *loginData): mPassField->requestFocus(); } - mWrongDataNoticeListener = new WrongDataNoticeListener(); + mOkButton->setEnabled(canSubmit()); } LoginDialog::~LoginDialog() { - delete mWrongDataNoticeListener; } void LoginDialog::action(const gcn::ActionEvent &event) { - if (event.getId() == "ok") + if (event.getId() == "ok" && canSubmit()) { - // Check login - if (mUserField->getText().empty()) - { - mWrongDataNoticeListener->setTarget(mPassField); - OkDialog *dlg = new OkDialog("Error", "Enter your username first"); - dlg->addActionListener(mWrongDataNoticeListener); - } - else - { - mLoginData->username = mUserField->getText(); - mLoginData->password = mPassField->getText(); - mLoginData->remember = mKeepCheck->isMarked(); - - mOkButton->setEnabled(false); - mRegisterButton->setEnabled(false); - - state = STATE_LOGIN_ATTEMPT; - } + mLoginData->username = mUserField->getText(); + mLoginData->password = mPassField->getText(); + mLoginData->remember = mKeepCheck->isMarked(); + mLoginData->registerLogin = false; + + mOkButton->setEnabled(false); + mRegisterButton->setEnabled(false); + + state = STATE_LOGIN_ATTEMPT; } else if (event.getId() == "cancel") { @@ -148,6 +125,24 @@ LoginDialog::action(const gcn::ActionEvent &event) } else if (event.getId() == "register") { + // Transfer these fields on to the register dialog + mLoginData->username = mUserField->getText(); + mLoginData->password = mPassField->getText(); + state = STATE_REGISTER; } } + +void +LoginDialog::keyPressed(gcn::KeyEvent &keyEvent) +{ + mOkButton->setEnabled(canSubmit()); +} + +bool +LoginDialog::canSubmit() +{ + return !mUserField->getText().empty() && + !mPassField->getText().empty() && + state == STATE_LOGIN; +} diff --git a/src/gui/login.h b/src/gui/login.h index 05c0da31..d8ae7eaf 100644 --- a/src/gui/login.h +++ b/src/gui/login.h @@ -26,29 +26,21 @@ #include #include +#include #include "window.h" #include "../guichanfwd.h" class LoginData; -/** - * Listener used for handling wrong data. - */ -class WrongDataNoticeListener : public gcn::ActionListener { - public: - void setTarget(gcn::TextField *textField); - void action(const gcn::ActionEvent &event); - private: - gcn::TextField *mTarget; -}; - /** * The login dialog. * * \ingroup Interface */ -class LoginDialog : public Window, public gcn::ActionListener { +class LoginDialog : public Window, public gcn::ActionListener, + public gcn::KeyListener +{ public: /** * Constructor @@ -67,7 +59,19 @@ class LoginDialog : public Window, public gcn::ActionListener { */ void action(const gcn::ActionEvent &event); + /** + * Called when a key is pressed in one of the text fields. + */ + void keyPressed(gcn::KeyEvent &keyEvent); + private: + /** + * Returns whether submit can be enabled. This is true in the login + * state, when all necessary fields have some text. + */ + bool + canSubmit(); + gcn::TextField *mUserField; gcn::TextField *mPassField; gcn::CheckBox *mKeepCheck; @@ -75,8 +79,6 @@ class LoginDialog : public Window, public gcn::ActionListener { gcn::Button *mCancelButton; gcn::Button *mRegisterButton; - WrongDataNoticeListener *mWrongDataNoticeListener; - LoginData *mLoginData; }; diff --git a/src/gui/register.cpp b/src/gui/register.cpp index be15747d..c8e01a6c 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -41,6 +41,21 @@ #include "textfield.h" #include "ok_dialog.h" +void +WrongDataNoticeListener::setTarget(gcn::TextField *textField) +{ + mTarget = textField; +} + +void +WrongDataNoticeListener::action(const gcn::ActionEvent &event) +{ + if (event.getId() == "ok") + { + mTarget->requestFocus(); + } +} + RegisterDialog::RegisterDialog(LoginData *loginData): Window("Register"), mWrongDataNoticeListener(new WrongDataNoticeListener()), @@ -50,28 +65,28 @@ RegisterDialog::RegisterDialog(LoginData *loginData): gcn::Label *passwordLabel = new gcn::Label("Password:"); gcn::Label *confirmLabel = new gcn::Label("Confirm:"); gcn::Label *emailLabel = new gcn::Label("Email:"); - mUserField = new TextField("player"); - mPasswordField = new PasswordField(); + mUserField = new TextField(loginData->username); + mPasswordField = new PasswordField(loginData->password); mConfirmField = new PasswordField(); mEmailField = new TextField(); mRegisterButton = new Button("Register", "register", this); mCancelButton = new Button("Cancel", "cancel", this); - const int width = 200; + const int width = 220; const int height = 130; setContentSize(width, height); mUserField->setPosition(65, 5); - mUserField->setWidth(130); + mUserField->setWidth(width - 70); mPasswordField->setPosition( 65, mUserField->getY() + mUserField->getHeight() + 7); - mPasswordField->setWidth(130); + mPasswordField->setWidth(mUserField->getWidth()); mConfirmField->setPosition( 65, mPasswordField->getY() + mPasswordField->getHeight() + 7); - mConfirmField->setWidth(130); + mConfirmField->setWidth(mUserField->getWidth()); mEmailField->setPosition( 65, mConfirmField->getY() + mConfirmField->getHeight() + 7); - mEmailField->setWidth(130); + mEmailField->setWidth(mUserField->getWidth()); userLabel->setPosition(5, mUserField->getY() + 1); passwordLabel->setPosition(5, mPasswordField->getY() + 1); @@ -79,11 +94,30 @@ RegisterDialog::RegisterDialog(LoginData *loginData): emailLabel->setPosition(5, mEmailField->getY() + 1); mCancelButton->setPosition( - width - 5 - mCancelButton->getWidth(), - height - 5 - mCancelButton->getHeight()); + width - mCancelButton->getWidth() - 5, + height - mCancelButton->getHeight() - 5); mRegisterButton->setPosition( - mCancelButton->getX() - 5 - mRegisterButton->getWidth(), - mCancelButton->getY()); + mCancelButton->getX() - mRegisterButton->getWidth() - 5, + height - mRegisterButton->getHeight() - 5); + + mUserField->addKeyListener(this); + mPasswordField->addKeyListener(this); + mConfirmField->addKeyListener(this); + mEmailField->addKeyListener(this); + + /* TODO: + * This is a quick and dirty way to respond to the ENTER key, regardless of + * which text field is selected. There may be a better way now with the new + * input system of Guichan 0.6.0. See also the login dialog. + */ + mUserField->setActionEventId("register"); + mPasswordField->setActionEventId("register"); + mConfirmField->setActionEventId("register"); + mEmailField->setActionEventId("register"); + mUserField->addActionListener(this); + mPasswordField->addActionListener(this); + mConfirmField->addActionListener(this); + mEmailField->addActionListener(this); add(userLabel); add(passwordLabel); @@ -100,6 +134,8 @@ RegisterDialog::RegisterDialog(LoginData *loginData): setVisible(true); mUserField->requestFocus(); mUserField->setCaretPosition(mUserField->getText().length()); + + mRegisterButton->setEnabled(canSubmit()); } RegisterDialog::~RegisterDialog() @@ -114,7 +150,7 @@ RegisterDialog::action(const gcn::ActionEvent &event) { state = STATE_LOGIN; } - else if (event.getId() == "register") + else if (event.getId() == "register" && canSubmit()) { const std::string user = mUserField->getText(); logger->log("RegisterDialog::register Username is %s", user.c_str()); @@ -122,14 +158,7 @@ RegisterDialog::action(const gcn::ActionEvent &event) std::stringstream errorMsg; int error = 0; - // Check login - if (user.empty()) - { - // No username - errorMsg << "Enter your username first."; - error = 1; - } - else if (user.length() < LEN_MIN_USERNAME) + if (user.length() < LEN_MIN_USERNAME) { // Name too short errorMsg << "The username needs to be at least " @@ -178,9 +207,11 @@ RegisterDialog::action(const gcn::ActionEvent &event) } else if (error == 2) { - mWrongDataNoticeListener->setTarget(this->mPasswordField); // Reset password confirmation + mPasswordField->setText(""); mConfirmField->setText(""); + + mWrongDataNoticeListener->setTarget(this->mPasswordField); } OkDialog *dlg = new OkDialog("Error", errorMsg.str()); @@ -191,7 +222,6 @@ RegisterDialog::action(const gcn::ActionEvent &event) // No errors detected, register the new user. mRegisterButton->setEnabled(false); - mLoginData->port = (short)config.getValue("port", 0); mLoginData->username = mUserField->getText(); mLoginData->password = mPasswordField->getText(); mLoginData->email = mEmailField->getText(); @@ -201,3 +231,18 @@ RegisterDialog::action(const gcn::ActionEvent &event) } } } + +void +RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent) +{ + mRegisterButton->setEnabled(canSubmit()); +} + +bool +RegisterDialog::canSubmit() +{ + return !mUserField->getText().empty() && + !mPasswordField->getText().empty() && + !mConfirmField->getText().empty() && + state == STATE_REGISTER; +} diff --git a/src/gui/register.h b/src/gui/register.h index 4ffe451f..088e8f9b 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -26,23 +26,39 @@ #include #include +#include #include "window.h" #include "../guichanfwd.h" class LoginData; class OkDialog; -class WrongDataNoticeListener; /** - * The login dialog. + * Listener used while dealing with wrong data. It is used to direct the focus + * to the field which contained wrong data when the Ok button was pressed on + * the error notice. + */ +class WrongDataNoticeListener : public gcn::ActionListener { + public: + void setTarget(gcn::TextField *textField); + void action(const gcn::ActionEvent &event); + private: + gcn::TextField *mTarget; +}; + +/** + * The registration dialog. * * \ingroup Interface */ -class RegisterDialog : public Window, public gcn::ActionListener { +class RegisterDialog : public Window, public gcn::ActionListener, + public gcn::KeyListener +{ public: /** - * Constructor + * Constructor. Name, password and server fields will be initialized to + * the information already present in the LoginData instance. * * @see Window::Window */ @@ -58,10 +74,19 @@ class RegisterDialog : public Window, public gcn::ActionListener { */ void action(const gcn::ActionEvent &event); - // Made them public to have the possibility to request focus - // from external functions. + /** + * Called when a key is pressed in one of the text fields. + */ + void keyPressed(gcn::KeyEvent &keyEvent); private: + /** + * Returns whether submit can be enabled. This is true in the register + * state, when all necessary fields have some text. + */ + bool + canSubmit(); + gcn::TextField *mUserField; gcn::TextField *mPasswordField; gcn::TextField *mConfirmField; diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 9a09389d..5558e8fc 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -34,7 +34,7 @@ #include "button.h" #include "checkbox.h" -#include "login.h" +#include "register.h" #include "passwordfield.h" #include "textfield.h" #include "ok_dialog.h" diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index bc635cce..f3e9031c 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -28,15 +28,20 @@ #include "gui.h" #include "popupmenu.h" +#include "../simpleanimation.h" #include "../beingmanager.h" #include "../configuration.h" #include "../flooritemmanager.h" #include "../graphics.h" #include "../localplayer.h" #include "../map.h" +#include "../monster.h" #include "../npc.h" -#include "../resources/monsterdb.h" +#include "../resources/animation.h" +#include "../resources/monsterinfo.h" +#include "../resources/resourcemanager.h" +#include "../resources/imageset.h" #include "../utils/tostring.h" @@ -60,11 +65,39 @@ Viewport::Viewport(): config.addListener("ScrollRadius", this); mPopupMenu = new PopupMenu(); + + // Load target cursors + ResourceManager *resman = ResourceManager::getInstance(); + mInRangeImages = resman->getImageSet( + "graphics/gui/target-cursor-blue.png", 44, 35); + mOutRangeImages = resman->getImageSet( + "graphics/gui/target-cursor-red.png", 44, 35); + Animation *animInRange = new Animation(); + Animation *animOutRange = new Animation(); + + for (unsigned int i = 0; i < mInRangeImages->size(); ++i) + { + animInRange->addFrame(mInRangeImages->get(i), 75, 0, 0); + } + + for (unsigned int j = 0; j < mOutRangeImages->size(); ++j) + { + animOutRange->addFrame(mOutRangeImages->get(j), 75, 0, 0); + } + + mTargetCursorInRange = new SimpleAnimation(animInRange); + mTargetCursorOutRange = new SimpleAnimation(animOutRange); } Viewport::~Viewport() { delete mPopupMenu; + + delete mTargetCursorInRange; + delete mTargetCursorOutRange; + + mInRangeImages->decRef(); + mOutRangeImages->decRef(); } void @@ -158,10 +191,12 @@ Viewport::draw(gcn::Graphics *gcnGraphics) if (mMap) { mMap->draw(graphics, mCameraX, mCameraY, 0); + drawTargetCursor(graphics); mMap->draw(graphics, mCameraX, mCameraY, 1); mMap->draw(graphics, mCameraX, mCameraY, 2); mMap->drawOverlay(graphics, mViewX, mViewY, (int) config.getValue("OverlayDetail", 2)); + drawTargetName(graphics); } // Find a path from the player to the mouse, and draw it. This is for debug @@ -201,28 +236,6 @@ Viewport::draw(gcn::Graphics *gcnGraphics) (*i)->drawEmotion(graphics, -mCameraX, -mCameraY); } - // Draw target marker if needed - Being *target = player_node->getTarget(); - if (target) - { - graphics->setFont(speechFont); - graphics->setColor(gcn::Color(255, 32, 32)); - int dy = (target->getType() == Being::PLAYER) ? 80 : 42; - - std::string mobName = ""; - - if (target->mJob >= 1002) - { - int mobId = target->mJob - 1002; - mobName = MonsterDB::get(mobId).getName(); - - graphics->drawText(mobName, - target->getPixelX() - mCameraX + 15, - target->getPixelY() - mCameraY - dy, - gcn::Graphics::CENTER); - } - } - // Draw contained widgets WindowContainer::draw(gcnGraphics); } @@ -245,6 +258,57 @@ Viewport::logic() mouseY + mCameraY); mWalkTime = player_node->mWalkTime; } + + mTargetCursorInRange->update(10); + mTargetCursorOutRange->update(10); +} + +void +Viewport::drawTargetCursor(Graphics *graphics) +{ + // Draw target marker if needed + Being *target = player_node->getTarget(); + if (target) + { + // Find whether target is in range + int rangeX = abs(target->mX - player_node->mX); + int rangeY = abs(target->mY - player_node->mY); + int attackRange = player_node->getAttackRange(); + + // Draw the target cursor, which one depends if the target is in range + if (rangeX > attackRange || rangeY > attackRange) + { + // Draw the out of range cursor + graphics->drawImage(mTargetCursorOutRange->getCurrentImage(), + target->getPixelX() - mCameraX, + target->getPixelY() - mCameraY); + } + else + { + // Draw the in range cursor + graphics->drawImage(mTargetCursorInRange->getCurrentImage(), + target->getPixelX() - mCameraX, + target->getPixelY() - mCameraY); + } + } +} + +void +Viewport::drawTargetName(Graphics *graphics) +{ + // Draw target marker if needed + Being *target = player_node->getTarget(); + if (target && target->getType() == Being::MONSTER) + { + graphics->setFont(speechFont); + graphics->setColor(gcn::Color(255, 32, 32)); + + const MonsterInfo &mi = static_cast(target)->getInfo(); + graphics->drawText(mi.getName(), + target->getPixelX() - mCameraX + 15, + target->getPixelY() - mCameraY - 42, + gcn::Graphics::CENTER); + } } void diff --git a/src/gui/viewport.h b/src/gui/viewport.h index f1cadd98..84efeff3 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -33,8 +33,11 @@ class Map; class Being; class FloorItem; +class ImageSet; class Item; class PopupMenu; +class Graphics; +class SimpleAnimation; /** * The viewport on the map. Displays the current map and handles mouse input @@ -138,6 +141,18 @@ class Viewport : public WindowContainer, public gcn::MouseListener, */ void showPopup(int x, int y, Being *being); + /** + * Draws range based target cursor + */ + void + drawTargetCursor(Graphics *graphics); + + /** + * Draws target name + */ + void + drawTargetName(Graphics *graphics); + Map *mMap; /**< The current map. */ @@ -149,6 +164,15 @@ class Viewport : public WindowContainer, public gcn::MouseListener, int mCameraY; /**< Current viewpoint in tiles. */ bool mShowDebugPath; /**< Show a path from player to pointer. */ + ImageSet *mInRangeImages; /**< Images of in range target cursor. */ + ImageSet *mOutRangeImages; /**< Images of out of range target cursor.*/ + + /** Animated in range target cursor. */ + SimpleAnimation *mTargetCursorInRange; + + /** Animated out of range target cursor. */ + SimpleAnimation *mTargetCursorOutRange; + bool mPlayerFollowMouse; int mWalkTime; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 7f595ef1..97371677 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -38,6 +38,7 @@ LocalPlayer *player_node = NULL; LocalPlayer::LocalPlayer(): Player(65535, 0, NULL), + mAttackRange(0), mInventory(new Inventory()), mAttributeBase(NB_BASE_ATTRIBUTES, 0), mAttributeEffective(NB_BASE_ATTRIBUTES, 0), diff --git a/src/localplayer.h b/src/localplayer.h index 299cf85a..fb7703dd 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -152,6 +152,16 @@ class LocalPlayer : public Player void dropItem(Item *item, int quantity); void pickUp(FloorItem *item); + /** + * Sets the attack range. + */ + void setAttackRange(int range) { mAttackRange = range; } + + /** + * Gets the attack range. + */ + int getAttackRange() const { return mAttackRange; } + /** * Sents a trade request to the given being. */ @@ -213,6 +223,8 @@ class LocalPlayer : public Player int getMaxHP() const { return mMaxHP; } + Uint16 mAttackRange; + void setHP(int value) { mHP = value; } diff --git a/src/logindata.h b/src/logindata.h index 0a01331c..fbbbb573 100644 --- a/src/logindata.h +++ b/src/logindata.h @@ -36,8 +36,8 @@ struct LoginData int session_ID1; int session_ID2; - bool remember; - bool registerLogin; + bool remember; /**< Whether to store the username and host. */ + bool registerLogin; /**< Whether an account is being registered. */ void clear() { diff --git a/src/main.cpp b/src/main.cpp index aad6a68c..bbbf0fd1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,9 +30,13 @@ #include #include -#include +#ifdef WIN32 +#include +#endif +#include #include +#include #include @@ -63,11 +67,11 @@ #include "gui/login.h" #include "gui/quitdialog.h" #include "gui/ok_dialog.h" +#include "gui/progressbar.h" #include "gui/register.h" #include "gui/updatewindow.h" #include "gui/textfield.h" - #include "net/charserverhandler.h" #include "net/connection.h" #include "net/loginhandler.h" @@ -86,7 +90,6 @@ #include "resources/itemdb.h" #include "resources/monsterdb.h" #include "resources/resourcemanager.h" -#include "resources/spriteset.h" #include "utils/dtor.h" #include "utils/tostring.h" @@ -103,23 +106,13 @@ unsigned char screen_mode; Sound sound; Music *bgm; -Configuration config; /**< Xml file configuration reader */ +Configuration config; /**< XML file configuration reader */ Logger *logger; /**< Log object */ Net::Connection *accountServerConnection = 0; Net::Connection *gameServerConnection = 0; Net::Connection *chatServerConnection = 0; -namespace { - struct ErrorListener : public gcn::ActionListener - { - void action(const gcn::ActionEvent &event) - { - state = STATE_CHOOSE_SERVER; - } - } errorListener; -} - /** * A structure holding the values of various options that can be passed from * the command line. @@ -131,12 +124,14 @@ struct Options */ Options(): printHelp(false), + printVersion(false), skipUpdate(false), chooseDefault(false), serverPort(0) {}; bool printHelp; + bool printVersion; bool skipUpdate; bool chooseDefault; std::string playername; @@ -237,7 +232,16 @@ void initEngine() SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); SDL_WM_SetCaption("The Mana World", NULL); - SDL_WM_SetIcon(IMG_Load(TMW_DATADIR "data/icons/tmw-icon.png"), NULL); +#ifdef WIN32 + static SDL_SysWMinfo pInfo; + SDL_GetWMInfo(&pInfo); + HICON icon = LoadIcon(GetModuleHandle(NULL), "A"); + SetClassLong(pInfo.window, GCL_HICON, (LONG) icon); +#else + SDL_Surface *icon = IMG_Load(TMW_DATADIR "data/icons/tmw.png"); + SDL_SetAlpha(icon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); + SDL_WM_SetIcon(icon, NULL); +#endif ResourceManager *resman = ResourceManager::getInstance(); @@ -356,6 +360,7 @@ void printHelp() "tmw\n\n" "Options:\n" " -h --help : Display this help\n" + " -v --version : Display the version\n" " -u --skipupdate : Skip the update process\n" " -U --username : Login with this username\n" " -P --password : Login with this password\n" @@ -366,12 +371,23 @@ void printHelp() " -C --configfile : Configuration file to use\n"; } +void printVersion() +{ +#ifdef PACKAGE_VERSION + std::cout << "The Mana World version " << PACKAGE_VERSION << std::endl; +#else + std::cout << "The Mana World version " << + "(local build?, PACKAGE_VERSION is not defined)" << std::endl; +#endif +} + void parseOptions(int argc, char *argv[], Options &options) { - const char *optstring = "huU:P:Dp:s:o:C:"; + const char *optstring = "hvuU:P:Dp:s:o:C:"; const struct option long_options[] = { { "help", no_argument, 0, 'h' }, + { "version", no_argument, 0, 'v' }, { "skipupdate", no_argument, 0, 'u' }, { "username", required_argument, 0, 'U' }, { "password", required_argument, 0, 'P' }, @@ -395,6 +411,9 @@ void parseOptions(int argc, char *argv[], Options &options) case 'h': options.printHelp = true; break; + case 'v': + options.printVersion = true; + break; case 'u': options.skipUpdate = true; break; @@ -449,6 +468,16 @@ LoginHandler loginHandler; LogoutHandler logoutHandler; LockedArray charInfo(MAX_SLOT + 1); +namespace { + struct ErrorListener : public gcn::ActionListener + { + void action(const gcn::ActionEvent &event) + { + state = STATE_CHOOSE_SERVER; + } + } errorListener; +} + // TODO Find some nice place for these functions void accountLogin(LoginData *loginData) { @@ -466,15 +495,17 @@ void accountLogin(LoginData *loginData) // Clear the password, avoids auto login when returning to login loginData->password = ""; - //remove _M or _F from username after a login for registration purpose + // Remove _M or _F from username after a login for registration purpose if (loginData->registerLogin) { - loginData->registerLogin = false; - loginData->username = loginData->username.substr(0, loginData->username.length() - 2); + loginData->username = + loginData->username.substr(0, loginData->username.length() - 2); } + // TODO This is not the best place to save the config, but at least better // than the login gui window - if (loginData->remember) { + if (loginData->remember) + { config.setValue("host", loginData->hostname); config.setValue("username", loginData->username); } @@ -557,7 +588,7 @@ void logoutThenExit() logoutHandler.reset(); logoutHandler.setScenario(LOGOUT_EXIT); - //Can't logout if we were not logged in ... + // Can't logout if we were not logged in ... if (accountServerConnection->isConnected()) { Net::AccountServer::logout(); @@ -616,10 +647,6 @@ void initXML() /** Main */ int main(int argc, char *argv[]) { -#ifdef PACKAGE_VERSION - std::cout << "The Mana World v" << PACKAGE_VERSION << std::endl; -#endif - // Parse command line options Options options; parseOptions(argc, argv, options); @@ -628,6 +655,11 @@ int main(int argc, char *argv[]) printHelp(); return 0; } + else if (options.printVersion) + { + printVersion(); + return 0; + } // Initialize PhysicsFS PHYSFS_init(argv[0]); @@ -647,10 +679,16 @@ int main(int argc, char *argv[]) initConfiguration(options); initEngine(); + Game *game = NULL; Window *currentDialog = NULL; QuitDialog* quitDialog = NULL; Image *login_wallpaper = NULL; - Game *game = NULL; + + gcn::Container *top = static_cast(gui->getTop()); +#ifdef PACKAGE_VERSION + gcn::Label *versionLabel = new gcn::Label(PACKAGE_VERSION); + top->add(versionLabel, 2, 2); +#endif sound.playMusic(TMW_DATADIR "data/music/Magick - Real.ogg"); @@ -715,8 +753,8 @@ int main(int argc, char *argv[]) guiInput->pushInput(event); } - gui->logic(); Net::flush(); + gui->logic(); if (!login_wallpaper) { @@ -729,10 +767,6 @@ int main(int argc, char *argv[]) } graphics->drawImage(login_wallpaper, 0, 0); -#ifdef PACKAGE_VERSION - graphics->setFont(gui->getFont()); - graphics->drawText(PACKAGE_VERSION, 0, 0); -#endif gui->draw(); graphics->updateScreen(); @@ -759,7 +793,6 @@ int main(int argc, char *argv[]) accountServerConnection->isConnected()) { reconnectAccount(token); - state = STATE_WAIT; } @@ -936,6 +969,10 @@ int main(int argc, char *argv[]) Net::ChatServer::connect(chatServerConnection, token); sound.fadeOutMusic(1000); +#ifdef PACKAGE_VERSION + delete versionLabel; + versionLabel = NULL; +#endif currentDialog = NULL; logger->log("State: GAME"); diff --git a/src/monster.h b/src/monster.h index 18fa703e..39bbf3d7 100644 --- a/src/monster.h +++ b/src/monster.h @@ -43,7 +43,6 @@ class Monster : public Being */ virtual void handleAttack(); - protected: /** * Returns the MonsterInfo, with static data about this monster. */ diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index 34fc188d..820aaea4 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -34,11 +34,13 @@ #include "../main.h" #include "../gui/ok_dialog.h" +#include "../gui/char_select.h" extern Net::Connection *gameServerConnection; extern Net::Connection *chatServerConnection; -CharServerHandler::CharServerHandler() +CharServerHandler::CharServerHandler(): + mCharCreateDialog(0) { static const Uint16 _messages[] = { APMSG_CHAR_CREATE_RESPONSE, @@ -99,6 +101,13 @@ CharServerHandler::handleMessage(MessageIn &msg) mCharInfo->unlock(); mCharInfo->select(slot); mCharInfo->setEntry(tempPlayer); + + // Close the character create dialog + if (mCharCreateDialog) + { + mCharCreateDialog->scheduleDelete(); + mCharCreateDialog = 0; + } break; case APMSG_CHAR_SELECT_RESPONSE: @@ -154,6 +163,9 @@ CharServerHandler::handleCharCreateResponse(MessageIn &msg) } new OkDialog("Error", message); } + + if (mCharCreateDialog) + mCharCreateDialog->unlock(); } void @@ -177,15 +189,20 @@ CharServerHandler::handleCharSelectResponse(MessageIn &msg) // Keep the selected character and delete the others player_node = mCharInfo->getEntry(); + int slot = mCharInfo->getPos(); mCharInfo->unlock(); mCharInfo->select(0); do { LocalPlayer *tmp = mCharInfo->getEntry(); if (tmp != player_node) + { delete tmp; + mCharInfo->setEntry(0); + } mCharInfo->next(); } while (mCharInfo->getPos()); + mCharInfo->select(slot); mCharInfo->clear(); //player_node will be deleted by ~Game @@ -204,8 +221,11 @@ CharServerHandler::readPlayerData(MessageIn &msg, int &slot) tempPlayer->setHairColor(msg.readByte()); tempPlayer->setLevel(msg.readByte()); tempPlayer->setMoney(msg.readLong()); - for (int i = 0; i < 7; i++) { + + for (int i = 0; i < 7; i++) + { tempPlayer->setAttributeBase(i, msg.readByte()); } + return tempPlayer; } diff --git a/src/net/charserverhandler.h b/src/net/charserverhandler.h index 342641d7..4a4fe0c3 100644 --- a/src/net/charserverhandler.h +++ b/src/net/charserverhandler.h @@ -28,9 +28,13 @@ #include "../lockedarray.h" +class CharCreateDialog; class LocalPlayer; class LoginData; +/** + * Deals with incoming messages related to character selection. + */ class CharServerHandler : public MessageHandler { public: @@ -45,6 +49,14 @@ class CharServerHandler : public MessageHandler mCharInfo = charInfo; } + /** + * Sets the character create dialog. The handler will clean up this + * dialog when a new character is succesfully created, and will unlock + * the dialog when a new character failed to be created. + */ + void setCharCreateDialog(CharCreateDialog *window) + { mCharCreateDialog = window; } + protected: void handleCharCreateResponse(MessageIn &msg); @@ -53,6 +65,7 @@ class CharServerHandler : public MessageHandler handleCharSelectResponse(MessageIn &msg); LockedArray *mCharInfo; + CharCreateDialog *mCharCreateDialog; LocalPlayer* readPlayerData(MessageIn &msg, int &slot); diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp index 1c0fd4ca..c0072a45 100644 --- a/src/net/equipmenthandler.cpp +++ b/src/net/equipmenthandler.cpp @@ -43,6 +43,7 @@ EquipmentHandler::EquipmentHandler() 0x01d7, SMSG_PLAYER_UNEQUIP, SMSG_PLAYER_ARROW_EQUIP, + SMSG_PLAYER_ATTACK_RANGE, 0 }; handledMessages = _messages; @@ -191,6 +192,10 @@ void EquipmentHandler::handleMessage(MessageIn &msg) index, equipPoint, type, position); break; + case SMSG_PLAYER_ATTACK_RANGE: + player_node->setAttackRange(msg.readShort()); + break; + case SMSG_PLAYER_ARROW_EQUIP: itemId = msg.readShort(); diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index c68a620a..90f2dbd5 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -88,7 +88,7 @@ void LoginHandler::handleMessage(MessageIn &msg) { switch (errMsg) { case REGISTER_INVALID_VERSION: - errorMessage = "Client has an insufficient version number to login."; + errorMessage = "Client has an insufficient version number to login."; break; case ERRMSG_INVALID_ARGUMENT: errorMessage = "Wrong username, password or email address"; diff --git a/src/net/protocol.h b/src/net/protocol.h index a9ee0e5b..b5dc2996 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -44,6 +44,7 @@ #define SMSG_PLAYER_EQUIPMENT 0x00a4 #define SMSG_PLAYER_EQUIP 0x00aa #define SMSG_PLAYER_UNEQUIP 0x00ac +#define SMSG_PLAYER_ATTACK_RANGE 0x013a #define SMSG_PLAYER_ARROW_EQUIP 0x013c #define SMSG_PLAYER_ARROW_MESSAGE 0x013b #define SMSG_PLAYER_SKILLS 0x010f diff --git a/src/npc.cpp b/src/npc.cpp index ccd085b6..2d291104 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -28,8 +28,6 @@ #include "gui/gui.h" -class Spriteset; - NPC *current_npc = 0; NPC::NPC(Uint16 id, Uint16 job, Map *map): diff --git a/src/resources/animation.h b/src/resources/animation.h index 54142bcb..d0d11c69 100644 --- a/src/resources/animation.h +++ b/src/resources/animation.h @@ -29,7 +29,6 @@ #include class Image; -class Spriteset; /** * A single frame in an animation, with a delay and an offset. diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 58325213..a27783d4 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -80,7 +80,7 @@ Image* Image::load(void *buffer, unsigned int bufferSize, tmpImage = IMG_Load_RW(rw, 1); } - if (tmpImage == NULL) { + if (!tmpImage) { logger->log("Error, image load failed: %s", IMG_GetError()); return NULL; } @@ -99,87 +99,28 @@ Image* Image::load(void *buffer, unsigned int bufferSize, amask = 0xff000000; #endif - // Convert the image to a 32 bit software surface for processing - SDL_Surface *formatImage = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, 32, - rmask, gmask, bmask, amask); - - if (formatImage == NULL) { - logger->log("Error, image load failed: not enough memory"); - SDL_FreeSurface(tmpImage); - return NULL; - } - - SDL_Surface *image = SDL_ConvertSurface( - tmpImage, formatImage->format, SDL_SWSURFACE); - - SDL_FreeSurface(formatImage); - - if (image == NULL) { - logger->log("Error, image load failed: not enough memory"); - return NULL; - } - - bool hasPink = false; - bool hasAlpha = false; - int i; - Uint32 pink = SDL_MapRGB(image->format, 255, 0, 255); - - // Figure out whether the image has pink pixels - for (i = 0; i < image->w * image->h; ++i) - { - if (((Uint32*)image->pixels)[i] == pink) - { - hasPink = true; - break; - } - } - - // Figure out whether the image uses its alpha layer - for (i = 0; i < image->w * image->h; ++i) - { - Uint8 r, g, b, a; - SDL_GetRGBA( - ((Uint32*)image->pixels)[i], - image->format, - &r, &g, &b, &a); - - if (a != 255) - { - hasAlpha = true; - break; - } - } - - SDL_FreeSurface(image); - - if (hasPink && !hasAlpha) { - SDL_SetColorKey(tmpImage, SDL_SRCCOLORKEY, - SDL_MapRGB(tmpImage->format, 255, 0, 255)); - } else if (hasAlpha) { - SDL_SetAlpha(tmpImage, SDL_SRCALPHA, SDL_ALPHA_OPAQUE); - } - #ifdef USE_OPENGL if (mUseOpenGL) { int width = tmpImage->w; int height = tmpImage->h; - int realWidth = 1, realHeight = 1; + int realWidth = powerOfTwo(width); + int realHeight = powerOfTwo(height); - while (realWidth < width && realWidth < 1024) { - realWidth *= 2; - } - - while (realHeight < height && realHeight < 1024) { - realHeight *= 2; + if (realWidth < width || realHeight < height) + { + logger->log("Warning: image too large, cropping to %dx%d texture!", + tmpImage->w, tmpImage->h); } + // Make sure the alpha channel is not used, but copied to destination SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE); + SDL_Surface *oldImage = tmpImage; - tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight, 32, - rmask, gmask, bmask, amask); + tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight, + 32, rmask, gmask, bmask, amask); - if (tmpImage == NULL) { + if (!tmpImage) { logger->log("Error, image convert failed: out of memory"); return NULL; } @@ -189,8 +130,6 @@ Image* Image::load(void *buffer, unsigned int bufferSize, GLuint texture; glGenTextures(1, &texture); - logger->log("Binding texture %d (%dx%d)", - texture, tmpImage->w, tmpImage->h); glBindTexture(GL_TEXTURE_2D, texture); if (SDL_MUSTLOCK(tmpImage)) { @@ -246,8 +185,27 @@ Image* Image::load(void *buffer, unsigned int bufferSize, } #endif - // Set color key and alpha blending optins, and convert the surface to the - // current display format + bool hasAlpha = false; + + // Figure out whether the image uses its alpha layer + for (int i = 0; i < tmpImage->w * tmpImage->h; ++i) + { + Uint8 r, g, b, a; + SDL_GetRGBA( + ((Uint32*) tmpImage->pixels)[i], + tmpImage->format, + &r, &g, &b, &a); + + if (a != 255) + { + hasAlpha = true; + break; + } + } + + SDL_Surface *image; + + // Convert the surface to the current display format if (hasAlpha) { image = SDL_DisplayFormatAlpha(tmpImage); } @@ -256,7 +214,7 @@ Image* Image::load(void *buffer, unsigned int bufferSize, } SDL_FreeSurface(tmpImage); - if (image == NULL) { + if (!image) { logger->log("Error: Image convert failed."); return NULL; } @@ -315,10 +273,22 @@ float Image::getAlpha() } #ifdef USE_OPENGL -void Image::setLoadAsOpenGL(bool useOpenGL) +void +Image::setLoadAsOpenGL(bool useOpenGL) { Image::mUseOpenGL = useOpenGL; } + +int +Image::powerOfTwo(int input) +{ + int value = 1; + while (value < input && value < 1024) + { + value <<= 1; + } + return value; +} #endif //============================================================================ diff --git a/src/resources/image.h b/src/resources/image.h index 03bf0cbc..cad21dcd 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -126,6 +126,12 @@ class Image : public Resource #ifdef USE_OPENGL Image(const std::string &idPath, GLuint glimage, int width, int height, int texWidth, int texHeight); + + /** + * Returns the first power of two equal or bigger than the input. + */ + static int + powerOfTwo(int input); #endif Image(const std::string &idPath, SDL_Surface *image); diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp new file mode 100644 index 00000000..677c024b --- /dev/null +++ b/src/resources/imageset.cpp @@ -0,0 +1,65 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "imageset.h" + +#include "../log.h" + +#include "image.h" + +#include "../utils/dtor.h" + +ImageSet::ImageSet(const std::string& idPath, + Image *img, + int width, int height): + Resource(idPath) +{ + for (int y = 0; y + height <= img->getHeight(); y += height) + { + for (int x = 0; x + width <= img->getWidth(); x += width) + { + mImages.push_back(img->getSubImage(x, y, width, height)); + } + } + mWidth = width; + mHeight = height; +} + +ImageSet::~ImageSet() +{ + for_each(mImages.begin(), mImages.end(), make_dtor(mImages)); +} + +Image* +ImageSet::get(size_type i) +{ + if (i >= mImages.size()) + { + logger->log("Warning: Sprite #%i does not exist in this image set", i); + return NULL; + } + else + { + return mImages[i]; + } +} diff --git a/src/resources/imageset.h b/src/resources/imageset.h new file mode 100644 index 00000000..3469a3bb --- /dev/null +++ b/src/resources/imageset.h @@ -0,0 +1,66 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#ifndef _TMW_IMAGESET_H +#define _TMW_IMAGESET_H + +#include + +#include "resource.h" + +class Image; + + +/** + * Stores a set of subimages originating from a single image. + */ +class ImageSet : public Resource +{ + public: + /* + * Cuts the passed image in a grid of sub images. + */ + ImageSet(const std::string &idPath, Image *img, int w, int h); + + /** + * Destructor. + */ + ~ImageSet(); + + int getWidth() { return mWidth; }; + + int getHeight() { return mHeight; }; + + typedef std::vector::size_type size_type; + Image* get(size_type i); + + size_type size() { return mImages.size(); } + + private: + std::vector mImages; + + int mHeight; /**< Height of the images in the image set. */ + int mWidth; /**< Width of the images in the image set. */ +}; + +#endif diff --git a/src/resources/monsterdb.h b/src/resources/monsterdb.h index 048638c2..46a33b06 100644 --- a/src/resources/monsterdb.h +++ b/src/resources/monsterdb.h @@ -39,7 +39,7 @@ namespace MonsterDB void unload(); - const MonsterInfo& get (int id); + const MonsterInfo& get(int id); typedef std::map MonsterInfos; typedef MonsterInfos::iterator MonsterInfoIterator; diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h index 413dafa0..05d4c014 100644 --- a/src/resources/monsterinfo.h +++ b/src/resources/monsterinfo.h @@ -1,74 +1,83 @@ -/* - * The Mana World - * Copyright 2004 The Mana World Development Team - * - * This file is part of The Mana World. - * - * The Mana World is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * The Mana World is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with The Mana World; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id: monsterinfo.h 2650 2006-09-03 15:00:47Z b_lindeijer $ - */ - -#ifndef _TMW_MONSTERINFO_H_ -#define _TMW_MONSTERINFO_H_ - -#include -#include -#include - - -enum SoundEvent -{ - EVENT_HIT, - EVENT_MISS, - EVENT_HURT, - EVENT_DIE -}; - - -class MonsterInfo -{ - public: - MonsterInfo(); - - ~MonsterInfo(); - - void - setName(std::string name) { mName = name; } ; - - void - setSprite(std::string filename) { mSprite = filename; } - - void - addSound (SoundEvent event, std::string filename); - - const std::string& - getName () const { return mName; }; - - const std::string& - getSprite () const { return mSprite; }; - - std::string - getSound (SoundEvent event) const; - - private: - - std::string mName; - std::string mSprite; - - std::map* > mSounds; -}; - -#endif +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id: monsterinfo.h 2650 2006-09-03 15:00:47Z b_lindeijer $ + */ + +#ifndef _TMW_MONSTERINFO_H_ +#define _TMW_MONSTERINFO_H_ + +#include +#include +#include + +enum SoundEvent +{ + EVENT_HIT, + EVENT_MISS, + EVENT_HURT, + EVENT_DIE +}; + +/** + * Holds information about a certain type of monster. This includes the name + * of the monster, the sprite to display and the sounds the monster makes. + * + * @see MonsterDB + */ +class MonsterInfo +{ + public: + /** + * Constructor. + */ + MonsterInfo(); + + /** + * Destructor. + */ + ~MonsterInfo(); + + void + setName(std::string name) { mName = name; } ; + + void + setSprite(std::string filename) { mSprite = filename; } + + void + addSound (SoundEvent event, std::string filename); + + const std::string& + getName () const { return mName; }; + + const std::string& + getSprite () const { return mSprite; }; + + std::string + getSound (SoundEvent event) const; + + private: + std::string mName; + std::string mSprite; + + std::map* > mSounds; +}; + +#endif diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 2059a5c3..448e7f80 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -31,7 +31,7 @@ #include "image.h" #include "music.h" #include "soundeffect.h" -#include "spriteset.h" +#include "imageset.h" #include "spritedef.h" #include "../log.h" @@ -46,7 +46,7 @@ ResourceManager::ResourceManager() ResourceManager::~ResourceManager() { - // Release any remaining spritedefs first because they depend on spritesets + // Release any remaining spritedefs first because they depend on image sets ResourceIterator iter = mResources.begin(); while (iter != mResources.end()) { @@ -63,11 +63,11 @@ ResourceManager::~ResourceManager() } } - // Release any remaining spritesets first because they depend on images + // Release any remaining image sets first because they depend on images iter = mResources.begin(); while (iter != mResources.end()) { - if (dynamic_cast(iter->second) != 0) + if (dynamic_cast(iter->second) != 0) { cleanUp(iter->second); ResourceIterator toErase = iter; @@ -232,8 +232,8 @@ ResourceManager::getSoundEffect(const std::string &idPath) return dynamic_cast(get(SOUND_EFFECT, idPath)); } -Spriteset* -ResourceManager::getSpriteset(const std::string &imagePath, int w, int h) +ImageSet* +ResourceManager::getImageSet(const std::string &imagePath, int w, int h) { std::stringstream ss; ss << imagePath << "[" << w << "x" << h << "]"; @@ -243,7 +243,7 @@ ResourceManager::getSpriteset(const std::string &imagePath, int w, int h) if (resIter != mResources.end()) { resIter->second->incRef(); - return dynamic_cast(resIter->second); + return dynamic_cast(resIter->second); } Image *img = getImage(imagePath); @@ -252,13 +252,13 @@ ResourceManager::getSpriteset(const std::string &imagePath, int w, int h) return NULL; } - Spriteset *spriteset = new Spriteset(idPath, img, w, h); - spriteset->incRef(); - mResources[idPath] = spriteset; + ImageSet *imageSet = new ImageSet(idPath, img, w, h); + imageSet->incRef(); + mResources[idPath] = imageSet; img->decRef(); - return spriteset; + return imageSet; } SpriteDef* diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index e176e337..db29e6d3 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -33,7 +33,7 @@ class Resource; class Image; class Music; class SoundEffect; -class Spriteset; +class ImageSet; class SpriteDef; /** @@ -143,11 +143,11 @@ class ResourceManager getSoundEffect(const std::string &idPath); /** - * Creates a spriteset based on the image referenced by the given + * Creates a image set based on the image referenced by the given * path and the supplied sprite sizes */ - Spriteset* - getSpriteset(const std::string &imagePath, int w, int h); + ImageSet* + getImageSet(const std::string &imagePath, int w, int h); /** * Creates a sprite definition based on a given path and the supplied diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index feb6f8f8..d29bd847 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -28,7 +28,7 @@ #include "animation.h" #include "action.h" #include "resourcemanager.h" -#include "spriteset.h" +#include "imageset.h" #include "image.h" #include "../utils/xml.h" @@ -135,30 +135,30 @@ SpriteDef::loadImageSet(xmlNodePtr node) std::string imageSrc = XML::getProperty(node, "src", ""); ResourceManager *resman = ResourceManager::getInstance(); - Spriteset *spriteset = resman->getSpriteset(imageSrc, width, height); + ImageSet *imageSet = resman->getImageSet(imageSrc, width, height); - if (!spriteset) + if (!imageSet) { logger->error("Couldn't load imageset!"); } - mSpritesets[name] = spriteset; + mImageSets[name] = imageSet; } void SpriteDef::loadAction(xmlNodePtr node, int variant_offset) { const std::string actionName = XML::getProperty(node, "name", ""); - const std::string imagesetName = XML::getProperty(node, "imageset", ""); + const std::string imageSetName = XML::getProperty(node, "imageset", ""); - SpritesetIterator si = mSpritesets.find(imagesetName); - if (si == mSpritesets.end()) + ImageSetIterator si = mImageSets.find(imageSetName); + if (si == mImageSets.end()) { logger->log("Warning: imageset \"%s\" not defined in %s", - imagesetName.c_str(), getIdPath().c_str()); + imageSetName.c_str(), getIdPath().c_str()); return; } - Spriteset *imageset = si->second; + ImageSet *imageSet = si->second; SpriteAction actionType = makeSpriteAction(actionName); if (actionType == ACTION_INVALID) @@ -183,14 +183,14 @@ SpriteDef::loadAction(xmlNodePtr node, int variant_offset) { if (xmlStrEqual(animationNode->name, BAD_CAST "animation")) { - loadAnimation(animationNode, action, imageset, variant_offset); + loadAnimation(animationNode, action, imageSet, variant_offset); } } } void SpriteDef::loadAnimation(xmlNodePtr animationNode, - Action *action, Spriteset *imageset, + Action *action, ImageSet *imageSet, int variant_offset) { std::string directionName = @@ -215,8 +215,8 @@ SpriteDef::loadAnimation(xmlNodePtr animationNode, int delay = XML::getProperty(frameNode, "delay", 0); int offsetX = XML::getProperty(frameNode, "offsetX", 0); int offsetY = XML::getProperty(frameNode, "offsetY", 0); - offsetY -= imageset->getHeight() - 32; - offsetX -= imageset->getWidth() / 2 - 16; + offsetY -= imageSet->getHeight() - 32; + offsetX -= imageSet->getWidth() / 2 - 16; if (xmlStrEqual(frameNode->name, BAD_CAST "frame")) { @@ -228,7 +228,7 @@ SpriteDef::loadAnimation(xmlNodePtr animationNode, continue; } - Image *img = imageset->get(index + variant_offset); + Image *img = imageSet->get(index + variant_offset); if (!img) { @@ -251,7 +251,7 @@ SpriteDef::loadAnimation(xmlNodePtr animationNode, while (end >= start) { - Image *img = imageset->get(start + variant_offset); + Image *img = imageSet->get(start + variant_offset); if (!img) { @@ -296,8 +296,8 @@ SpriteDef::substituteAction(SpriteAction complete, SpriteAction with) SpriteDef::~SpriteDef() { - for (SpritesetIterator i = mSpritesets.begin(); - i != mSpritesets.end(); ++i) + for (ImageSetIterator i = mImageSets.begin(); + i != mImageSets.end(); ++i) { i->second->decRef(); } diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 057129ad..6d335b02 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -32,7 +32,7 @@ #include class Action; -class Spriteset; +class ImageSet; enum SpriteAction { @@ -111,7 +111,7 @@ class SpriteDef : public Resource */ void loadAnimation(xmlNodePtr animationNode, - Action *action, Spriteset *imageset, + Action *action, ImageSet *imageSet, int variant_offset); /** @@ -140,12 +140,12 @@ class SpriteDef : public Resource makeSpriteDirection(const std::string &direction); - typedef std::map Spritesets; - typedef Spritesets::iterator SpritesetIterator; + typedef std::map ImageSets; + typedef ImageSets::iterator ImageSetIterator; typedef std::map Actions; - Spritesets mSpritesets; + ImageSets mImageSets; Actions mActions; Action *mAction; SpriteDirection mDirection; diff --git a/src/resources/spriteset.cpp b/src/resources/spriteset.cpp deleted file mode 100644 index 96bcef0c..00000000 --- a/src/resources/spriteset.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * The Mana World - * Copyright 2004 The Mana World Development Team - * - * This file is part of The Mana World. - * - * The Mana World is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * The Mana World is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with The Mana World; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -#include "spriteset.h" - -#include "../log.h" - -#include "image.h" - -#include "../utils/dtor.h" - -Spriteset::Spriteset(const std::string& idPath, - Image *img, - int width, int height): - Resource(idPath) -{ - for (int y = 0; y + height <= img->getHeight(); y += height) - { - for (int x = 0; x + width <= img->getWidth(); x += width) - { - mSpriteset.push_back(img->getSubImage(x, y, width, height)); - } - } - mWidth = width; - mHeight = height; -} - -Spriteset::~Spriteset() -{ - for_each(mSpriteset.begin(), mSpriteset.end(), make_dtor(mSpriteset)); -} - -Image* -Spriteset::get(size_type i) -{ - if (i >= mSpriteset.size()) - { - logger->log("Warning: Sprite #%i does not exist in this spriteset", i); - return NULL; - } - else - { - return mSpriteset[i]; - } -} diff --git a/src/resources/spriteset.h b/src/resources/spriteset.h deleted file mode 100644 index 7f6b42df..00000000 --- a/src/resources/spriteset.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The Mana World - * Copyright 2004 The Mana World Development Team - * - * This file is part of The Mana World. - * - * The Mana World is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * The Mana World is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with The Mana World; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * $Id$ - */ - -#ifndef _TMW_SPRITESET_H -#define _TMW_SPRITESET_H - -#include - -#include "resource.h" - -class Image; - - -/** - * Stores a set of subimages originating from a single image. - * - * TODO: Should probably be renamed to ImageSet or TileSet. - */ -class Spriteset : public Resource -{ - public: - /* - * Cuts the passed image in a grid of sub images. - */ - Spriteset(const std::string &idPath, Image *img, int w, int h); - - /** - * Destructor. - */ - ~Spriteset(); - - int getWidth() { return mWidth; }; - - int getHeight() { return mHeight; }; - - typedef std::vector::size_type size_type; - Image* get(size_type i); - - size_type size() { return mSpriteset.size(); } - - private: - // Vector storing the whole spriteset. - std::vector mSpriteset; - // Height and width of the images in the spriteset - int mHeight; - int mWidth; -}; - -#endif diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp new file mode 100644 index 00000000..5fc35bcd --- /dev/null +++ b/src/simpleanimation.cpp @@ -0,0 +1,50 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "simpleanimation.h" + + +void SimpleAnimation::update(unsigned int timePassed) +{ + mAnimationTime += timePassed; + while (mAnimationTime > mCurrentFrame->delay) + { + mAnimationTime -= mCurrentFrame->delay; + mAnimationPhase++; + if (mAnimationPhase >= mAnimation->getLength()) + { + mAnimationPhase = 0; + } + mCurrentFrame = mAnimation->getFrame(mAnimationPhase); + } +} + +Image *SimpleAnimation::getCurrentImage() const +{ + return mCurrentFrame->image; +} + +SimpleAnimation::~SimpleAnimation() +{ + delete mAnimation; +} diff --git a/src/simpleanimation.h b/src/simpleanimation.h new file mode 100644 index 00000000..a56c31da --- /dev/null +++ b/src/simpleanimation.h @@ -0,0 +1,65 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#ifndef _TMW_SIMPLEANIMAION_H +#define _TMW_SIMPLEANIMAION_H + +#include "resources/animation.h" + +class Frame; + +/** + * This class is a leightweight alternative to the AnimatedSprite class. + * It hosts a looping animation without actions and directions. + */ +class SimpleAnimation +{ + public: + SimpleAnimation(Animation *animation): + mAnimation(animation), + mAnimationTime(0), + mAnimationPhase(0), + mCurrentFrame(mAnimation->getFrame(0)) + {}; + + ~SimpleAnimation(); + + void update(unsigned int timePassed); + + Image *getCurrentImage() const; + + private: + /** The hosted animation. */ + Animation *mAnimation; + + /** Time in game ticks the current frame is shown. */ + unsigned int mAnimationTime; + + /** Index of current animation frame. */ + unsigned int mAnimationPhase; + + /** Current animation frame. */ + Frame *mCurrentFrame; +}; + +#endif diff --git a/src/tileset.h b/src/tileset.h index 27bc28c3..7521a3e5 100644 --- a/src/tileset.h +++ b/src/tileset.h @@ -24,19 +24,19 @@ #ifndef _TMW_TILESET_H_ #define _TMW_TILESET_H_ -#include "resources/spriteset.h" +#include "resources/imageset.h" /** - * A tileset, which is basically just a spriteset but it stores a firstgid. + * A tileset, which is basically just an image set but it stores a firstgid. */ -class Tileset : public Spriteset +class Tileset : public ImageSet { public: /** * Constructor. */ Tileset(Image *img, int w, int h, int firstGid): - Spriteset("", img, w, h), + ImageSet("", img, w, h), mFirstGid(firstGid) { } diff --git a/src/tmw.rc b/src/tmw.rc index ee5f99cd..673b2387 100644 --- a/src/tmw.rc +++ b/src/tmw.rc @@ -2,7 +2,7 @@ #include "winver.h" -A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "data/icons/tmw-icon.ico" +A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "data/icons/tmw.ico" 1 VERSIONINFO FILEVERSION VER_MAJOR,VER_MINOR,VER_RELEASE,VER_BUILD diff --git a/tmw.cbp b/tmw.cbp index 96ef5a36..c66a5719 100644 --- a/tmw.cbp +++ b/tmw.cbp @@ -1262,6 +1262,16 @@