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/setup_audio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/setup_audio.cpp') diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index 6f884e2f..db88ff64 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -108,7 +108,7 @@ void Setup_Audio::cancel() config.setValue("musicVolume", mMusicVolume); } -void Setup_Audio::action(const std::string &event) +void Setup_Audio::action(const std::string& event, gcn::Widget *widget) { if (event == "sfx") { -- 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/setup_audio.cpp') 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 c09825097c0231c57f9ac416fae0003c5d68398c Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Tue, 7 Aug 2007 07:54:13 +0000 Subject: Marked most of the GUI as translatable. --- ChangeLog | 13 +++++++ po/Makevars | 4 +-- src/gui/char_select.cpp | 82 ++++++++++++++++++++++----------------------- src/gui/confirm_dialog.cpp | 5 +-- src/gui/connection.cpp | 6 ++-- src/gui/equipmentwindow.cpp | 5 ++- src/gui/item_amount.cpp | 12 ++++--- src/gui/login.cpp | 16 +++++---- src/gui/menuwindow.cpp | 19 ++++++----- src/gui/minimap.cpp | 5 +-- src/gui/ministatus.cpp | 3 +- src/gui/npc_text.cpp | 6 ++-- src/gui/npclistdialog.cpp | 8 +++-- src/gui/ok_dialog.cpp | 3 +- src/gui/popupmenu.cpp | 25 ++++++++------ src/gui/quitdialog.cpp | 16 +++++---- src/gui/register.cpp | 47 ++++++++++++++------------ src/gui/serverdialog.cpp | 13 +++---- src/gui/setup.cpp | 15 +++++---- src/gui/setup_audio.cpp | 8 +++-- src/gui/setup_joystick.cpp | 18 +++++----- src/gui/setup_video.cpp | 37 ++++++++++---------- src/main.cpp | 5 +-- 23 files changed, 205 insertions(+), 166 deletions(-) (limited to 'src/gui/setup_audio.cpp') diff --git a/ChangeLog b/ChangeLog index cb5cb144..ef1c46c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-08-07 Guillaume Melquiond + + * po/Makevars, src/main.cpp: Replaced PACKAGE by tmw to reduce + preprocessing hell. Set gettext charset to utf8. + * src/gui/menuwindow.cpp, src/gui/connection.cpp, src/gui/register.cpp, + src/gui/equipmentwindow.cpp, src/gui/quitdialog.cpp, src/gui/login.cpp, + src/gui/item_amount.cpp, src/gui/npclistdialog.cpp, src/gui/setup.cpp, + src/gui/char_select.cpp, src/gui/setup_audio.cpp, src/gui/npc_text.cpp, + src/gui/setup_video.cpp, src/gui/ministatus.cpp, src/gui/ok_dialog.cpp, + src/gui/confirm_dialog.cpp, src/gui/setup_joystick.cpp, + src/gui/serverdialog.cpp, src/gui/minimap.cpp, src/gui/popupmenu.cpp: + Marked as translatable. + 2007-08-06 Guillaume Melquiond * src/Makefile.am, src/utils/strprintf.h, src/utils/strprintf.cpp: diff --git a/po/Makevars b/po/Makevars index a72f85a3..76e72f50 100644 --- a/po/Makevars +++ b/po/Makevars @@ -1,9 +1,7 @@ # Makefile variables for PO directory in any package using GNU gettext. # Usually the message domain is the same as the package name. -#PACKAGE = $(PACKAGE_NAME) -DOMAIN = $(PACKAGE) -#VERSION = $(PACKAGE_VERSION) +DOMAIN = tmw # These two variables depend on the location of this directory. subdir = po diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 128a803e..d752cdb3 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -45,6 +45,8 @@ #include "../net/charserverhandler.h" #include "../net/messageout.h" +#include "../utils/gettext.h" +#include "../utils/strprintf.h" #include "../utils/tostring.h" // Defined in main.cpp, used here for setting the char create dialog @@ -63,8 +65,8 @@ class CharDeleteConfirm : public ConfirmDialog }; CharDeleteConfirm::CharDeleteConfirm(CharSelectDialog *m): - ConfirmDialog("Confirm", - "Are you sure you want to delete this character?", m), + ConfirmDialog(_("Confirm"), + _("Are you sure you want to delete this character?"), m), master(m) { } @@ -80,21 +82,21 @@ void CharDeleteConfirm::action(const gcn::ActionEvent &event) CharSelectDialog::CharSelectDialog(LockedArray *charInfo, LoginData *loginData): - Window("Select Character"), + Window(_("Select Character")), mCharInfo(charInfo), mCharSelected(false), mLoginData(loginData) { - mSelectButton = new Button("Ok", "ok", this); - mCancelButton = new Button("Cancel", "cancel", this); - mNewCharButton = new Button("New", "new", this); - mDelCharButton = new Button("Delete", "delete", this); - mPreviousButton = new Button("Previous", "previous", this); - mNextButton = new Button("Next", "next", this); - mUnRegisterButton = new Button("Unregister", "unregister", this); - - mNameLabel = new gcn::Label("Name"); - mLevelLabel = new gcn::Label("Level"); - mMoneyLabel = new gcn::Label("Money"); + mSelectButton = new Button(_("Ok"), "ok", this); + mCancelButton = new Button(_("Cancel"), "cancel", this); + mNewCharButton = new Button(_("New"), "new", this); + mDelCharButton = new Button(_("Delete"), "delete", this); + mPreviousButton = new Button(_("Previous"), "previous", this); + mNextButton = new Button(_("Next"), "next", this); + mUnRegisterButton = new Button(_("Unregister"), "unregister", this); + + mNameLabel = new gcn::Label(strprintf(_("Name: %s"), "")); + mLevelLabel = new gcn::Label(strprintf(_("Level: %d"), 0)); + mMoneyLabel = new gcn::Label(strprintf(_("Money: %d"), 0)); mPlayerBox = new PlayerBox(); int w = 195; @@ -198,9 +200,9 @@ void CharSelectDialog::updatePlayerInfo() if (pi) { - mNameLabel->setCaption(pi->getName()); - mLevelLabel->setCaption("Lvl: " + toString(pi->getLevel())); - mMoneyLabel->setCaption("Money: " + toString(pi->getMoney())); + mNameLabel->setCaption(strprintf(_("Name: %s"), pi->getName().c_str())); + mLevelLabel->setCaption(strprintf(_("Level: %d"), pi->getLevel())); + mMoneyLabel->setCaption(strprintf(_("Money: %d"), pi->getMoney())); if (!mCharSelected) { mNewCharButton->setEnabled(false); @@ -209,9 +211,9 @@ void CharSelectDialog::updatePlayerInfo() } } else { - mNameLabel->setCaption("Name"); - mLevelLabel->setCaption("Level"); - mMoneyLabel->setCaption("Money"); + mNameLabel->setCaption(strprintf(_("Name: %s"), "")); + mLevelLabel->setCaption(strprintf(_("Level: %d"), 0)); + mMoneyLabel->setCaption(strprintf(_("Money: %d"), 0)); mNewCharButton->setEnabled(true); mDelCharButton->setEnabled(false); mSelectButton->setEnabled(false); @@ -259,30 +261,30 @@ std::string CharSelectDialog::getName() } CharCreateDialog::CharCreateDialog(Window *parent, int slot): - Window("Create Character", true, parent), mSlot(slot) + Window(_("Create Character"), true, parent), mSlot(slot) { mPlayer = new Player(0, 0, NULL); mPlayer->setHairStyle(rand() % NR_HAIR_STYLES); mPlayer->setHairColor(rand() % NR_HAIR_COLORS); mNameField = new TextField(""); - mNameLabel = new gcn::Label("Name:"); + mNameLabel = new gcn::Label(_("Name:")); mNextHairColorButton = new Button(">", "nextcolor", this); mPrevHairColorButton = new Button("<", "prevcolor", this); - mHairColorLabel = new gcn::Label("Hair Color:"); + mHairColorLabel = new gcn::Label(_("Hair Color:")); mNextHairStyleButton = new Button(">", "nextstyle", this); mPrevHairStyleButton = new Button("<", "prevstyle", this); - mHairStyleLabel = new gcn::Label("Hair Style:"); - mCreateButton = new Button("Create", "create", this); - mCancelButton = new Button("Cancel", "cancel", this); + mHairStyleLabel = new gcn::Label(_("Hair Style:")); + mCreateButton = new Button(_("Create"), "create", this); + mCancelButton = new Button(_("Cancel"), "cancel", this); mPlayerBox = new PlayerBox(mPlayer); - mAttributeLabel[0] = new gcn::Label("Strength:"); - mAttributeLabel[1] = new gcn::Label("Agility:"); - mAttributeLabel[2] = new gcn::Label("Dexterity:"); - mAttributeLabel[3] = new gcn::Label("Vitality:"); - mAttributeLabel[4] = new gcn::Label("Intelligence:"); - mAttributeLabel[5] = new gcn::Label("Willpower:"); - mAttributeLabel[6] = new gcn::Label("Charisma:"); + mAttributeLabel[0] = new gcn::Label(_("Strength:")); + mAttributeLabel[1] = new gcn::Label(_("Agility:")); + mAttributeLabel[2] = new gcn::Label(_("Dexterity:")); + mAttributeLabel[3] = new gcn::Label(_("Vitality:")); + mAttributeLabel[4] = new gcn::Label(_("Intelligence:")); + mAttributeLabel[5] = new gcn::Label(_("Willpower:")); + mAttributeLabel[6] = new gcn::Label(_("Charisma:")); for (int i=0; i<7; i++) { mAttributeLabel[i]->setWidth(70); @@ -290,7 +292,7 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot): mAttributeValue[i] = new gcn::Label("1"); }; - mAttributesLeft = new gcn::Label("Please distribute # points"); + mAttributesLeft = new gcn::Label(strprintf(_("Please distribute %d points"), 99)); mNameField->setActionEventId("create"); @@ -382,8 +384,8 @@ CharCreateDialog::action(const gcn::ActionEvent &event) ); } else { - new OkDialog("Error", - "Your name needs to be at least 4 characters.", this); + new OkDialog(_("Error"), + _("Your name needs to be at least 4 characters."), this); } } else if (event.getId() == "cancel") { @@ -428,7 +430,7 @@ void CharCreateDialog::UpdateSliders() int pointsLeft = 70 - getDistributedPoints(); if (pointsLeft == 0) { - mAttributesLeft->setCaption("Character stats OK"); + mAttributesLeft->setCaption(_("Character stats OK")); mCreateButton->setEnabled(true); } else @@ -436,13 +438,11 @@ void CharCreateDialog::UpdateSliders() mCreateButton->setEnabled(false); if (pointsLeft > 0) { - mAttributesLeft->setCaption(std::string("Please distribute " + - toString(pointsLeft) + " points")); + mAttributesLeft->setCaption(strprintf(_("Please distribute %d points"), pointsLeft)); } else { - mAttributesLeft->setCaption(std::string("Please remove " + - toString(-pointsLeft) + " points")); + mAttributesLeft->setCaption(strprintf(_("Please remove %d points"), -pointsLeft)); } } diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp index 0ff8be17..65ca27f7 100644 --- a/src/gui/confirm_dialog.cpp +++ b/src/gui/confirm_dialog.cpp @@ -27,14 +27,15 @@ #include "button.h" +#include "../utils/gettext.h" ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, Window *parent): Window(title, true, parent) { gcn::Label *textLabel = new gcn::Label(msg); - gcn::Button *yesButton = new Button("Yes", "yes", this); - gcn::Button *noButton = new Button("No", "no", this); + gcn::Button *yesButton = new Button(_("Yes"), "yes", this); + gcn::Button *noButton = new Button(_("No"), "no", this); int w = textLabel->getWidth() + 20; int inWidth = yesButton->getWidth() + noButton->getWidth() + 5; diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp index 3627689a..17b397ba 100644 --- a/src/gui/connection.cpp +++ b/src/gui/connection.cpp @@ -32,6 +32,8 @@ #include "../main.h" +#include "../utils/gettext.h" + namespace { struct ConnectionActionListener : public gcn::ActionListener { @@ -54,10 +56,10 @@ ConnectionDialog::ConnectionDialog(unsigned char previousState): ConnectionActionListener *connectionListener = new ConnectionActionListener(previousState); - Button *cancelButton = new Button("Cancel", "cancelButton", + 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..."); + gcn::Label *label = new gcn::Label(_("Connecting...")); cancelButton->setPosition(5, 100 - 5 - cancelButton->getHeight()); mProgressBar->setPosition(5, cancelButton->getY() - 25); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 27c97ea0..2ee57cd9 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -31,12 +31,11 @@ #include "../resources/iteminfo.h" #include "../resources/resourcemanager.h" -#include "../utils/tostring.h" +#include "../utils/gettext.h" EquipmentWindow::EquipmentWindow(Equipment *equipment): - Window("Equipment"), mEquipment(equipment) + Window(_("Equipment")), mEquipment(equipment) { - setWindowName("Equipment"); setDefaultSize(5, 230, 200, 120); loadWindowState(); } diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp index f72462f9..2e3ac4ad 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -31,8 +31,10 @@ #include "../item.h" #include "../localplayer.h" +#include "../utils/gettext.h" + ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): - Window("Select amount of items to drop.", true, parent), + Window("", true, parent), mItem(item) { // New labels @@ -41,8 +43,8 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): // New buttons Button *minusButton = new Button("-", "Minus", this); Button *plusButton = new Button("+", "Plus", this); - Button *okButton = new Button("Okay", "Drop", this); - Button *cancelButton = new Button("Cancel", "Cancel", this); + Button *okButton = new Button(_("Ok"), "Drop", this); + Button *cancelButton = new Button(_("Cancel"), "Cancel", this); mItemAmountSlide = new Slider(1.0, mItem->getQuantity()); mItemAmountTextBox->setRange(1, mItem->getQuantity()); @@ -74,11 +76,11 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): switch (usage) { case AMOUNT_TRADE_ADD: - setCaption("Select amount of items to trade."); + setCaption(_("Select amount of items to trade.")); okButton->setActionEventId("AddTrade"); break; case AMOUNT_ITEM_DROP: - setCaption("Select amount of items to drop."); + setCaption(_("Select amount of items to drop.")); okButton->setActionEventId("Drop"); break; default: diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 15ec6314..fccfc05a 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -36,17 +36,19 @@ #include "passwordfield.h" #include "textfield.h" +#include "../utils/gettext.h" + LoginDialog::LoginDialog(LoginData *loginData): - Window("Login"), mLoginData(loginData) + Window(_("Login")), mLoginData(loginData) { - gcn::Label *userLabel = new gcn::Label("Name:"); - gcn::Label *passLabel = new gcn::Label("Password:"); + gcn::Label *userLabel = new gcn::Label(_("Name:")); + gcn::Label *passLabel = new gcn::Label(_("Password:")); mUserField = new TextField(mLoginData->username); mPassField = new PasswordField(mLoginData->password); - mKeepCheck = new CheckBox("Keep", mLoginData->remember); - mOkButton = new Button("OK", "ok", this); - mCancelButton = new Button("Cancel", "cancel", this); - mRegisterButton = new Button("Register", "register", this); + mKeepCheck = new CheckBox(_("Keep"), mLoginData->remember); + mOkButton = new Button(_("Ok"), "ok", this); + mCancelButton = new Button(_("Cancel"), "cancel", this); + mRegisterButton = new Button(_("Register"), "register", this); const int width = 220; const int height = 100; diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp index 943cc6f0..bfa2f1f2 100644 --- a/src/gui/menuwindow.cpp +++ b/src/gui/menuwindow.cpp @@ -30,6 +30,8 @@ #include "button.h" #include "windowcontainer.h" +#include "../utils/gettext.h" + extern Window *setupWindow; extern Window *inventoryWindow; extern Window *equipmentWindow; @@ -47,28 +49,27 @@ namespace { } MenuWindow::MenuWindow(): - Window("") + Window() { setResizable(false); - setWindowName("Menu"); setMovable(false); setTitleBarHeight(0); // Buttons - const char *buttonNames[] = + static char const *buttonNames[] = { - "Status", - "Equipment", - "Inventory", - "Skills", - "Setup", + N_("Status"), + N_("Equipment"), + N_("Inventory"), + N_("Skills"), + N_("Setup"), 0 }; int x = 0, y = 3, h = 0; for (const char **curBtn = buttonNames; *curBtn; curBtn++) { - gcn::Button *btn = new Button(*curBtn, *curBtn, &listener); + gcn::Button *btn = new Button(gettext(*curBtn), *curBtn, &listener); btn->setPosition(x, y); add(btn); x += btn->getWidth() + 3; diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 2720225d..03a37e29 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -29,11 +29,12 @@ #include "../resources/image.h" +#include "../utils/gettext.h" + Minimap::Minimap(): - Window("Map"), + Window(_("MiniMap")), mMapImage(NULL) { - setWindowName("MiniMap"); setDefaultSize(5, 25, 100, 100); loadWindowState(); } diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 9a4c2273..3742be64 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -35,9 +35,8 @@ #include "../utils/tostring.h" MiniStatusWindow::MiniStatusWindow(): - Window("") + Window() { - setWindowName("MiniStatus"); setResizable(false); setMovable(false); setTitleBarHeight(0); diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 2dd223bd..023307a7 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -31,13 +31,15 @@ #include "../npc.h" +#include "../utils/gettext.h" + NpcTextDialog::NpcTextDialog(): - Window("NPC") + Window(_("NPC")) { mTextBox = new TextBox(); mTextBox->setEditable(false); gcn::ScrollArea *scrollArea = new ScrollArea(mTextBox); - Button *okButton = new Button("OK", "ok", this); + Button *okButton = new Button(_("Ok"), "ok", this); setContentSize(260, 175); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 1bcdc8ff..487bdf60 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -31,13 +31,15 @@ #include "../npc.h" +#include "../utils/gettext.h" + NpcListDialog::NpcListDialog(): - Window("NPC") + Window(_("NPC")) { mItemList = new ListBox(this); ScrollArea *scrollArea = new ScrollArea(mItemList); - Button *okButton = new Button("OK", "ok", this); - Button *cancelButton = new Button("Cancel", "cancel", this); + Button *okButton = new Button(_("Ok"), "ok", this); + Button *cancelButton = new Button(_("Cancel"), "cancel", this); setContentSize(260, 175); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp index ca9d2a7b..37d66353 100644 --- a/src/gui/ok_dialog.cpp +++ b/src/gui/ok_dialog.cpp @@ -27,13 +27,14 @@ #include "button.h" +#include "../utils/gettext.h" OkDialog::OkDialog(const std::string &title, const std::string &msg, Window *parent): Window(title, true, parent) { gcn::Label *textLabel = new gcn::Label(msg); - gcn::Button *okButton = new Button("Ok", "ok", this); + gcn::Button *okButton = new Button(_("Ok"), "ok", this); int w = textLabel->getWidth() + 20; int h = textLabel->getHeight() + 25 + okButton->getHeight(); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index f308bbfd..9b1ce409 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -42,6 +42,9 @@ #include "../resources/iteminfo.h" #include "../resources/itemdb.h" +#include "../utils/gettext.h" +#include "../utils/strprintf.h" + extern std::string tradePartnerName; PopupMenu::PopupMenu(): @@ -74,9 +77,9 @@ void PopupMenu::showPopup(int x, int y, Being *being) // Players can be traded with. Later also attack, follow and // add as buddy will be options in this menu. const std::string &name = mBeing->getName(); - mBrowserBox->addRow("@@trade|Trade With " + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str())); - mBrowserBox->addRow("@@attack|Attack " + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); //mBrowserBox->addRow("@@follow|Follow " + name + "@@"); //mBrowserBox->addRow("@@buddy|Add " + name + " to Buddy List@@"); } @@ -85,7 +88,7 @@ void PopupMenu::showPopup(int x, int y, Being *being) case Being::NPC: // NPCs can be talked to (single option, candidate for removal // unless more options would be added) - mBrowserBox->addRow("@@talk|Talk To NPC@@"); + mBrowserBox->addRow(_("@@talk|Talk To NPC@@")); break; default: @@ -95,7 +98,7 @@ void PopupMenu::showPopup(int x, int y, Being *being) //browserBox->addRow("@@look|Look To@@"); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow("@@cancel|Cancel@@"); + mBrowserBox->addRow(_("@@cancel|Cancel@@")); showPopup(x, y); } @@ -107,11 +110,11 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem) // Floor item can be picked up (single option, candidate for removal) std::string name = ItemDB::get(mFloorItem->getItemId()).getName(); - mBrowserBox->addRow("@@pickup|Pick Up " + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@pickup|Pick Up %s@@"), name.c_str())); //browserBox->addRow("@@look|Look To@@"); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow("@@cancel|Cancel@@"); + mBrowserBox->addRow(_("@@cancel|Cancel@@")); showPopup(x, y); } @@ -214,15 +217,15 @@ void PopupMenu::showPopup(int x, int y, Item *item) if (item->isEquipment()) { - mBrowserBox->addRow("@@use|Equip@@"); + mBrowserBox->addRow(_("@@use|Equip@@")); } else - mBrowserBox->addRow("@@use|Use@@"); + mBrowserBox->addRow(_("@@use|Use@@")); - mBrowserBox->addRow("@@drop|Drop@@"); - mBrowserBox->addRow("@@description|Description@@"); + mBrowserBox->addRow(_("@@drop|Drop@@")); + mBrowserBox->addRow(_("@@description|Description@@")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow("@@cancel|Cancel@@"); + mBrowserBox->addRow(_("@@cancel|Cancel@@")); showPopup(x, y); } diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 97be5f46..42c08080 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -31,16 +31,18 @@ #include "button.h" #include "radiobutton.h" +#include "../utils/gettext.h" + QuitDialog::QuitDialog(bool* quitGame, QuitDialog** pointerToMe): - Window("Quit", true, NULL), mQuitGame(quitGame), mMyPointer(pointerToMe) + Window(_("Quit"), true, NULL), mQuitGame(quitGame), mMyPointer(pointerToMe) { - mLogoutQuit = new RadioButton("Quit", "quitdialog"); - mForceQuit = new RadioButton("Quit", "quitdialog"); - mSwitchAccountServer = new RadioButton("Switch server", "quitdialog"); - mSwitchCharacter = new RadioButton("Switch character", "quitdialog"); - mOkButton = new Button("OK", "ok", this); - mCancelButton = new Button("Cancel", "cancel", this); + mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); + mForceQuit = new RadioButton(_("Quit"), "quitdialog"); + mSwitchAccountServer = new RadioButton(_("Switch server"), "quitdialog"); + mSwitchCharacter = new RadioButton(_("Switch character"), "quitdialog"); + mOkButton = new Button(_("Ok"), "ok", this); + mCancelButton = new Button(_("Cancel"), "cancel", this); setContentSize(200, 91); diff --git a/src/gui/register.cpp b/src/gui/register.cpp index c8e01a6c..7e236a7d 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -41,6 +41,9 @@ #include "textfield.h" #include "ok_dialog.h" +#include "../utils/gettext.h" +#include "../utils/strprintf.h" + void WrongDataNoticeListener::setTarget(gcn::TextField *textField) { @@ -57,20 +60,20 @@ WrongDataNoticeListener::action(const gcn::ActionEvent &event) } RegisterDialog::RegisterDialog(LoginData *loginData): - Window("Register"), + Window(_("Register")), mWrongDataNoticeListener(new WrongDataNoticeListener()), mLoginData(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 *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:")); 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); + mRegisterButton = new Button(_("Register"), "register", this); + mCancelButton = new Button(_("Cancel"), "cancel", this); const int width = 220; const int height = 130; @@ -155,45 +158,45 @@ RegisterDialog::action(const gcn::ActionEvent &event) const std::string user = mUserField->getText(); logger->log("RegisterDialog::register Username is %s", user.c_str()); - std::stringstream errorMsg; + std::string errorMsg; int error = 0; if (user.length() < LEN_MIN_USERNAME) { // Name too short - errorMsg << "The username needs to be at least " - << LEN_MIN_USERNAME - << " characters long."; + errorMsg = strprintf + (_("The username needs to be at least %d characters long."), + LEN_MIN_USERNAME); error = 1; } else if (user.length() > LEN_MAX_USERNAME - 1 ) { // Name too long - errorMsg << "The username needs to be less than " - << LEN_MAX_USERNAME - << " characters long."; + errorMsg = strprintf + (_("The username needs to be less than %d characters long."), + LEN_MAX_USERNAME); error = 1; } else if (mPasswordField->getText().length() < LEN_MIN_PASSWORD) { // Pass too short - errorMsg << "The password needs to be at least " - << LEN_MIN_PASSWORD - << " characters long."; + errorMsg = strprintf + (_("The password needs to be at least %d characters long."), + LEN_MIN_PASSWORD); error = 2; } else if (mPasswordField->getText().length() > LEN_MAX_PASSWORD - 1 ) { // Pass too long - errorMsg << "The password needs to be less than " - << LEN_MAX_PASSWORD - << " characters long."; + errorMsg = strprintf + (_("The password needs to be less than %d characters long."), + LEN_MAX_PASSWORD); error = 2; } else if (mPasswordField->getText() != mConfirmField->getText()) { // Password does not match with the confirmation one - errorMsg << "Passwords do not match."; + errorMsg = _("Passwords do not match."); error = 2; } @@ -214,7 +217,7 @@ RegisterDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mPasswordField); } - OkDialog *dlg = new OkDialog("Error", errorMsg.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index b47ce749..2eada7ad 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -39,6 +39,7 @@ #include "../logindata.h" #include "../main.h" +#include "../utils/gettext.h" #include "../utils/tostring.h" const short MAX_SERVERLIST = 5; @@ -98,10 +99,10 @@ void ServersListModel::addElement(Server server) } ServerDialog::ServerDialog(LoginData *loginData): - Window("Choose your Mana World Server"), mLoginData(loginData) + Window(_("Choose your Mana World Server")), mLoginData(loginData) { - gcn::Label *serverLabel = new gcn::Label("Server:"); - gcn::Label *portLabel = new gcn::Label("Port:"); + gcn::Label *serverLabel = new gcn::Label(_("Server:")); + gcn::Label *portLabel = new gcn::Label(_("Port:")); mServerNameField = new TextField(mLoginData->hostname); mPortField = new TextField(toString(mLoginData->port)); @@ -134,8 +135,8 @@ ServerDialog::ServerDialog(LoginData *loginData): mDropDownListener = new DropDownListener(mServerNameField, mPortField, mMostUsedServersListModel, mMostUsedServersListBox); - mOkButton = new Button("OK", "ok", this); - mCancelButton = new Button("Cancel", "cancel", this); + mOkButton = new Button(_("Ok"), "ok", this); + mCancelButton = new Button(_("Cancel"), "cancel", this); setContentSize(200, 100); @@ -201,7 +202,7 @@ ServerDialog::action(const gcn::ActionEvent &event) // Check login if (mServerNameField->getText().empty() || mPortField->getText().empty()) { - OkDialog *dlg = new OkDialog("Error", "Enter the chosen server."); + OkDialog *dlg = new OkDialog(_("Error"), "Enter the chosen server."); dlg->addActionListener(mDropDownListener); } else diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 3add3a18..3ea19059 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -30,6 +30,7 @@ #include "tabbedcontainer.h" #include "../utils/dtor.h" +#include "../utils/gettext.h" extern Window *statusWindow; extern Window *minimap; @@ -40,18 +41,18 @@ extern Window *helpWindow; extern Window *skillDialog; Setup::Setup(): - Window("Setup") + Window(_("Setup")) { int width = 230; int height = 245; setContentSize(width, height); - const char *buttonNames[] = { - "Apply", "Cancel", "Reset Windows", 0 + static char const *buttonNames[] = { + N_("Apply"), N_("Cancel"), N_("Reset Windows"), 0 }; int x = width; for (const char **curBtn = buttonNames; *curBtn; ++curBtn) { - Button *btn = new Button(*curBtn, *curBtn, this); + Button *btn = new Button(gettext(*curBtn), *curBtn, this); x -= btn->getWidth() + 5; btn->setPosition(x, height - btn->getHeight() - 5); add(btn); @@ -64,15 +65,15 @@ Setup::Setup(): SetupTab *tab; tab = new Setup_Video(); - panel->addTab(tab, "Video"); + panel->addTab(tab, _("Video")); mTabs.push_back(tab); tab = new Setup_Audio(); - panel->addTab(tab, "Audio"); + panel->addTab(tab, _("Audio")); mTabs.push_back(tab); tab = new Setup_Joystick(); - panel->addTab(tab, "Joystick"); + panel->addTab(tab, _("Joystick")); mTabs.push_back(tab); add(panel); diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index e5aadf80..89c21e2b 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -33,18 +33,20 @@ #include "../log.h" #include "../sound.h" +#include "../utils/gettext.h" + Setup_Audio::Setup_Audio(): mMusicVolume((int)config.getValue("musicVolume", 60)), mSfxVolume((int)config.getValue("sfxVolume", 100)), mSoundEnabled(config.getValue("sound", 0)), - mSoundCheckBox(new CheckBox("Sound", mSoundEnabled)), + mSoundCheckBox(new CheckBox(_("Sound"), mSoundEnabled)), mSfxSlider(new Slider(0, 128)), mMusicSlider(new Slider(0, 128)) { setOpaque(false); - gcn::Label *sfxLabel = new gcn::Label("Sfx volume"); - gcn::Label *musicLabel = new gcn::Label("Music volume"); + gcn::Label *sfxLabel = new gcn::Label(_("Sfx volume")); + gcn::Label *musicLabel = new gcn::Label(_("Music volume")); mSfxSlider->setActionEventId("sfx"); mMusicSlider->setActionEventId("music"); diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp index 56f411d7..59cfefa4 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -30,12 +30,14 @@ #include "../configuration.h" #include "../joystick.h" +#include "../utils/gettext.h" + extern Joystick *joystick; Setup_Joystick::Setup_Joystick(): - mCalibrateLabel(new gcn::Label("Press the button to start calibration")), - mCalibrateButton(new Button("Calibrate", "calibrate", this)), - mJoystickEnabled(new CheckBox("Enable joystick")) + mCalibrateLabel(new gcn::Label(_("Press the button to start calibration"))), + mCalibrateButton(new Button(_("Calibrate"), "calibrate", this)), + mJoystickEnabled(new CheckBox(_("Enable joystick"))) { setOpaque(false); mJoystickEnabled->setPosition(10, 10); @@ -65,13 +67,13 @@ void Setup_Joystick::action(const gcn::ActionEvent &event) else { if (joystick->isCalibrating()) { - mCalibrateButton->setCaption("Calibrate"); - mCalibrateLabel->setCaption( - "Press the button to start calibration"); + mCalibrateButton->setCaption(_("Calibrate")); + mCalibrateLabel->setCaption + (_("Press the button to start calibration")); joystick->finishCalibration(); } else { - mCalibrateButton->setCaption("Stop"); - mCalibrateLabel->setCaption("Rotate the stick"); + mCalibrateButton->setCaption(_("Stop")); + mCalibrateLabel->setCaption(_("Rotate the stick")); joystick->startCalibration(); } } diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index cd1507a7..ee46396b 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -44,6 +44,7 @@ #include "../log.h" #include "../main.h" +#include "../utils/gettext.h" #include "../utils/tostring.h" extern Graphics *graphics; @@ -109,11 +110,11 @@ Setup_Video::Setup_Video(): mFps((int)config.getValue("fpslimit", 60)), mModeListModel(new ModeListModel()), mModeList(new ListBox(mModeListModel)), - mFsCheckBox(new CheckBox("Full screen", mFullScreenEnabled)), - mOpenGLCheckBox(new CheckBox("OpenGL", mOpenGLEnabled)), - mCustomCursorCheckBox(new CheckBox("Custom cursor", mCustomCursorEnabled)), + mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)), + mOpenGLCheckBox(new CheckBox(_("OpenGL"), mOpenGLEnabled)), + mCustomCursorCheckBox(new CheckBox(_("Custom cursor"), mCustomCursorEnabled)), mAlphaSlider(new Slider(0.2, 1.0)), - mFpsCheckBox(new CheckBox("FPS Limit: ")), + mFpsCheckBox(new CheckBox(_("FPS Limit:"))), mFpsSlider(new Slider(10, 200)), mFpsField(new TextField()), mOriginalScrollLaziness((int) config.getValue("ScrollLaziness", 32)), @@ -129,7 +130,7 @@ Setup_Video::Setup_Video(): setOpaque(false); ScrollArea *scrollArea = new ScrollArea(mModeList); - gcn::Label *alphaLabel = new gcn::Label("Gui opacity"); + gcn::Label *alphaLabel = new gcn::Label(_("Gui opacity")); mModeList->setEnabled(false); #ifndef USE_OPENGL @@ -182,7 +183,7 @@ Setup_Video::Setup_Video(): mOverlayDetailField->addKeyListener(this); mScrollRadiusSlider->setDimension(gcn::Rectangle(10, 120, 75, 10)); - gcn::Label *scrollRadiusLabel = new gcn::Label("Scroll radius"); + gcn::Label *scrollRadiusLabel = new gcn::Label(_("Scroll radius")); scrollRadiusLabel->setPosition(90, 120); mScrollRadiusField->setPosition(180, 120); mScrollRadiusField->setWidth(30); @@ -190,7 +191,7 @@ Setup_Video::Setup_Video(): mScrollRadiusSlider->setValue(mOriginalScrollRadius); mScrollLazinessSlider->setDimension(gcn::Rectangle(10, 140, 75, 10)); - gcn::Label *scrollLazinessLabel = new gcn::Label("Scroll laziness"); + gcn::Label *scrollLazinessLabel = new gcn::Label(_("Scroll laziness")); scrollLazinessLabel->setPosition(90, 140); mScrollLazinessField->setPosition(180, 140); mScrollLazinessField->setWidth(30); @@ -198,20 +199,20 @@ Setup_Video::Setup_Video(): mScrollLazinessSlider->setValue(mOriginalScrollLaziness); mOverlayDetailSlider->setDimension(gcn::Rectangle(10, 160, 75, 10)); - gcn::Label *overlayDetailLabel = new gcn::Label("Ambient FX"); + gcn::Label *overlayDetailLabel = new gcn::Label(_("Ambient FX")); overlayDetailLabel->setPosition(90, 160); mOverlayDetailField->setPosition(180, 160); mOverlayDetailField->setWidth(30); switch (mOverlayDetail) { case 0: - mOverlayDetailField->setCaption("off"); + mOverlayDetailField->setCaption(_("off")); break; case 1: - mOverlayDetailField->setCaption("low"); + mOverlayDetailField->setCaption(_("low")); break; case 2: - mOverlayDetailField->setCaption("high"); + mOverlayDetailField->setCaption(_("high")); break; } mOverlayDetailSlider->setValue(mOverlayDetail); @@ -264,8 +265,8 @@ void Setup_Video::apply() } } } else { - new OkDialog("Switching to full screen", - "Restart needed for changes to take effect."); + new OkDialog(_("Switching to full screen"), + _("Restart needed for changes to take effect.")); } config.setValue("screen", fullscreen ? 1 : 0); } @@ -276,8 +277,8 @@ void Setup_Video::apply() config.setValue("opengl", mOpenGLCheckBox->isMarked() ? 1 : 0); // OpenGL can currently only be changed by restarting, notify user. - new OkDialog("Changing OpenGL", - "Applying change to OpenGL requires restart."); + new OkDialog(_("Changing OpenGL"), + _("Applying change to OpenGL requires restart.")); } // FPS change @@ -365,13 +366,13 @@ void Setup_Video::action(const gcn::ActionEvent &event) switch (val) { case 0: - mOverlayDetailField->setCaption("off"); + mOverlayDetailField->setCaption(_("off")); break; case 1: - mOverlayDetailField->setCaption("low"); + mOverlayDetailField->setCaption(_("low")); break; case 2: - mOverlayDetailField->setCaption("high"); + mOverlayDetailField->setCaption(_("high")); break; } config.setValue("OverlayDetail", val); diff --git a/src/main.cpp b/src/main.cpp index bde0877e..9a51f2e4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -669,8 +669,9 @@ int main(int argc, char *argv[]) #if ENABLE_NLS setlocale(LC_MESSAGES, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); + bindtextdomain("tmw", LOCALEDIR); + bind_textdomain_codeset("tmw", "UTF-8"); + textdomain("tmw"); #endif // Initialize PhysicsFS -- cgit v1.2.3-70-g09d2 From 4b9e2b6c41e740a3eac10078d5fa4fbc63788bbe Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 11 Apr 2008 13:31:52 +0000 Subject: Ported trunk over to Guichan 0.8.0. Based on merge from 0.0 branch, but because of quite a bit of GUI differences there were additional changes and probably additional issues. You have been warned. ;) Merged revisions 4045-4049,4051-4059 via svnmerge from https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/branches/0.0 ........ r4045 | b_lindeijer | 2008-04-07 17:23:07 +0200 (Mon, 07 Apr 2008) | 3 lines Upgraded to Guichan 0.8.0 (merge from guichan-0.8 branch, except for gcn::TabbedArea usage) ........ r4059 | b_lindeijer | 2008-04-09 16:25:42 +0200 (Wed, 09 Apr 2008) | 2 lines Fixed problem with row height in shop list box. ........ --- ChangeLog | 36 +++++++++++++ INSTALL | 2 +- NEWS | 2 + src/CMakeLists.txt | 2 - src/Makefile.am | 4 +- src/gui/button.cpp | 2 +- src/gui/buy.cpp | 5 +- src/gui/buy.h | 9 ++-- src/gui/char_select.cpp | 7 ++- src/gui/chat.cpp | 26 ++++----- src/gui/checkbox.cpp | 6 +-- src/gui/checkbox.h | 2 +- src/gui/guildlistbox.cpp | 19 ++++--- src/gui/guildlistbox.h | 18 ------- src/gui/guildwindow.cpp | 4 +- src/gui/inttextbox.cpp | 2 +- src/gui/inventorywindow.cpp | 2 +- src/gui/inventorywindow.h | 9 ++-- src/gui/itemcontainer.cpp | 17 +++--- src/gui/itemcontainer.h | 20 ++++--- src/gui/itemshortcutwindow.cpp | 9 ++-- src/gui/itemshortcutwindow.h | 7 ++- src/gui/listbox.cpp | 21 -------- src/gui/listbox.h | 31 ----------- src/gui/login.cpp | 2 +- src/gui/playerbox.cpp | 8 +-- src/gui/playerbox.h | 2 +- src/gui/quitdialog.cpp | 12 ++--- src/gui/radiobutton.cpp | 2 +- src/gui/scrollarea.cpp | 24 ++++----- src/gui/scrollarea.h | 2 +- src/gui/selectionlistener.h | 68 ------------------------ src/gui/sell.cpp | 2 +- src/gui/sell.h | 7 ++- src/gui/setup_audio.cpp | 4 +- src/gui/setup_joystick.cpp | 6 +-- src/gui/setup_video.cpp | 18 +++---- src/gui/shoplistbox.cpp | 29 +--------- src/gui/shoplistbox.h | 28 ++-------- src/gui/slider.cpp | 2 +- src/gui/tabbedcontainer.cpp | 4 +- src/gui/textbox.cpp | 4 +- src/gui/textfield.cpp | 8 +-- src/gui/textfield.h | 2 +- src/gui/trade.cpp | 2 +- src/gui/trade.h | 6 +-- src/gui/widgets/dropdown.cpp | 15 +++--- src/gui/widgets/dropdown.h | 2 +- src/gui/window.cpp | 117 ++++++++--------------------------------- src/gui/window.h | 77 +++------------------------ src/gui/windowlistener.h | 86 ------------------------------ 51 files changed, 213 insertions(+), 588 deletions(-) delete mode 100644 src/gui/selectionlistener.h delete mode 100644 src/gui/windowlistener.h (limited to 'src/gui/setup_audio.cpp') diff --git a/ChangeLog b/ChangeLog index 0477f10b..18f172fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,11 @@ Fixed some compiler warnings and don't try to load particle effects when no file is set. +2008-04-09 Bjørn Lindeijer + + * src/gui/shoplistbox.cpp, src/gui/shoplistbox.h: Fixed problem with + row height in shop list box. + 2008-04-08 Bjørn Lindeijer * src/map.cpp, src/gui/viewport.cpp, src/tileset.h, src/map.h, @@ -297,6 +302,15 @@ design decisions. * data/items.xml: Fixed a few messed up slot numbers. +2008-01-28 Bjørn Lindeijer + + * src/gui/sell.cpp, src/gui/window.cpp, src/gui/inventorywindow.h, + src/gui/buy.h, src/gui/itemshortcutwindow.cpp, + src/gui/inventorywindow.cpp, src/gui/buy.cpp, src/gui/sell.h, + src/gui/window.h, src/gui/windowlistener.h, + src/gui/itemshortcutwindow.h, src/CMakeLists.txt, src/Makefile.am: + Used the gcn::WidgetListener instead of our WindowListener. + 2008-01-26 Bjørn Lindeijer * src/gui/truetypefont.cpp: Image alpha should also be set to 1, in @@ -316,6 +330,28 @@ * src/net/beinghandler.cpp, src/resources/spritedef.h: Fixed broken communication of attack directions. +2008-01-23 Bjørn Lindeijer + + * src/gui/char_server.cpp, src/gui/window.cpp, src/gui/checkbox.h, + src/gui/playerbox.h, src/gui/button.cpp, src/gui/chat.cpp, + src/gui/slider.cpp, src/gui/tabbedcontainer.cpp, src/gui/textfield.h, + src/gui/shoplistbox.cpp, src/gui/register.cpp, + src/gui/radiobutton.cpp, src/gui/textbox.cpp, src/gui/login.cpp, + src/gui/setup_audio.cpp, src/gui/setup_video.cpp, + src/gui/textfield.cpp, src/gui/playerbox.cpp, + src/gui/setup_joystick.cpp, src/gui/scrollarea.h, + src/gui/windowlistener.h, src/gui/checkbox.cpp, + src/gui/scrollarea.cpp: Compile against Guichan 0.8.0. Some issues + with ShopListBox left and not trying to use their new TabbedArea, + SelectionListener and WidgetListener yet. Also needs more testing. + * src/gui/trade.cpp, src/gui/sell.cpp, src/gui/inventorywindow.h, + src/gui/selectionlistener.h, src/gui/itemcontainer.h, + src/gui/shoplistbox.cpp, src/gui/shoplistbox.h, src/gui/listbox.h, + src/gui/buy.h, src/gui/inventorywindow.cpp, src/gui/buy.cpp, + src/gui/itemcontainer.cpp, src/gui/sell.h, src/gui/trade.h, + src/gui/listbox.cpp, src/CMakeLists.txt, src/Makefile.am: Used the + gcn::SelectionListener instead of our own. + 2008-01-20 Philipp Sehmisch * data/items.xml: Added max-per-slot property to all items. diff --git a/INSTALL b/INSTALL index ea8a4f81..a346a2e5 100644 --- a/INSTALL +++ b/INSTALL @@ -21,7 +21,7 @@ and some libraries. The required libraries are: * SDL_image http://www.libsdl.org/projects/SDL_image/ * SDL_ttf http://www.libsdl.org/projects/SDL_ttf/ * ENet 1.2 http://enet.bespin.org/ -* Guichan 0.7.x http://guichan.sourceforge.net/ +* Guichan 0.8.x http://guichan.sourceforge.net/ * libxml2 http://www.xmlsoft.org/ * physfs 1.0.x http://icculus.org/physfs/ * zlib 1.2.x http://www.gzip.org/zlib/ diff --git a/NEWS b/NEWS index ebdae676..51a181d0 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +0.0.24.1 (7 April 2008) + 0.0.24 (24 December 2007) - Added female specific hair styles - Added user-definable key settings diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9cda186d..b783efcb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -148,7 +148,6 @@ SET(SRCS gui/scrollarea.h gui/sdlinput.cpp gui/sdlinput.h - gui/selectionlistener.h gui/sell.cpp gui/sell.h gui/serverdialog.cpp @@ -198,7 +197,6 @@ SET(SRCS gui/window.h gui/windowcontainer.cpp gui/windowcontainer.h - gui/windowlistener.h net/beinghandler.cpp net/beinghandler.h net/buysellhandler.cpp diff --git a/src/Makefile.am b/src/Makefile.am index d9b3fc8d..c46fe481 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -102,7 +102,6 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \ gui/scrollarea.h \ gui/sdlinput.cpp \ gui/sdlinput.h \ - gui/selectionlistener.h \ gui/sell.cpp \ gui/sell.h \ gui/serverdialog.cpp \ @@ -150,7 +149,6 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \ gui/window.h \ gui/windowcontainer.cpp \ gui/windowcontainer.h \ - gui/windowlistener.h \ net/beinghandler.h \ net/beinghandler.cpp \ net/buysellhandler.h \ @@ -340,4 +338,4 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \ INCLUDES = \ $(all_includes) \ -DTMW_DATADIR=\""$(pkgdatadir)/"\" \ - -DLOCALEDIR=\""$(localedir)"\" \ No newline at end of file + -DLOCALEDIR=\""$(localedir)"\" diff --git a/src/gui/button.cpp b/src/gui/button.cpp index e47f90f8..c6bc4ccb 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -82,7 +82,7 @@ Button::Button(const std::string& caption, const std::string &actionEventId, void Button::init() { - setBorderSize(0); + setFrameSize(0); if (mInstances == 0) { diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index d2e12a85..49d19675 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -178,9 +178,8 @@ void BuyDialog::action(const gcn::ActionEvent &event) } } -void BuyDialog::selectionChanged(const SelectionEvent &event) +void BuyDialog::valueChanged(const gcn::SelectionEvent &event) { - // Reset amount of items and update labels mAmountItems = 1; mSlider->setValue(1); @@ -192,7 +191,7 @@ void BuyDialog::selectionChanged(const SelectionEvent &event) void BuyDialog::updateButtonsAndLabels() { - int selectedItem = mShopItemList->getSelected(); + const int selectedItem = mShopItemList->getSelected(); int price = 0; if (selectedItem > -1) diff --git a/src/gui/buy.h b/src/gui/buy.h index 4e129611..ec7419be 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -25,9 +25,9 @@ #define _TMW_BUY_H #include +#include #include "window.h" -#include "selectionlistener.h" #include "../guichanfwd.h" @@ -40,7 +40,8 @@ class ListBox; * * \ingroup Interface */ -class BuyDialog : public Window, public gcn::ActionListener, SelectionListener +class BuyDialog : public Window, public gcn::ActionListener, + gcn::SelectionListener { public: /** @@ -82,10 +83,8 @@ class BuyDialog : public Window, public gcn::ActionListener, SelectionListener /** * Updates the labels according to the selected item. - * - * @see SelectionListener::selectionChanged */ - void selectionChanged(const SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event); /** * Returns the name of item number i in the shop inventory. diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index a691f4ec..b2d3b53e 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -323,7 +323,7 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot): mFemale->setPosition( 100, 120 ); // Default to a Male character - mMale->setMarked(true); + mMale->setSelected(true); mMale->setActionEventId("gender"); mFemale->setActionEventId("gender"); @@ -375,13 +375,12 @@ CharCreateDialog::action(const gcn::ActionEvent &event) mCreateButton->setEnabled(false); unsigned int genderSelected; - if( mMale->isMarked() ){ + if (mMale->isSelected()) { genderSelected = GENDER_MALE; } else { genderSelected = GENDER_FEMALE; } - Net::AccountServer::Account::createCharacter( getName(), mPlayer->getHairStyle(), @@ -418,7 +417,7 @@ CharCreateDialog::action(const gcn::ActionEvent &event) UpdateSliders(); } else if (event.getId() == "gender"){ - if( mMale->isMarked() ) { + if (mMale->isSelected()) { mPlayer->setGender(GENDER_MALE); } else { mPlayer->setGender(GENDER_FEMALE); diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index f6b54d29..1efee8ed 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -67,14 +67,14 @@ ChatWindow::ChatWindow(): textOutput->setMaxRow((int) config.getValue("ChatLogLength", 0)); ScrollArea *scrollArea = new ScrollArea(textOutput); scrollArea->setPosition( - scrollArea->getBorderSize(), scrollArea->getBorderSize()); + scrollArea->getFrameSize(), scrollArea->getFrameSize()); scrollArea->setScrollPolicy( gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS); scrollArea->setOpaque(false); GCContainer *tab = new GCContainer(); - tab->setWidth(getWidth() - 2 * tab->getBorderSize()); - tab->setHeight(getHeight() - 2 * tab->getBorderSize()); + tab->setWidth(getWidth() - 2 * tab->getFrameSize()); + tab->setHeight(getHeight() - 2 * tab->getFrameSize()); tab->setOpaque(false); tab->add(scrollArea); @@ -109,15 +109,15 @@ ChatWindow::logic() const gcn::Rectangle area = getChildrenArea(); - mChatInput->setPosition(mChatInput->getBorderSize(), + mChatInput->setPosition(mChatInput->getFrameSize(), area.height - mChatInput->getHeight() - - mChatInput->getBorderSize()); - mChatInput->setWidth(area.width - 2 * mChatInput->getBorderSize()); - mContainer->setWidth(area.width - 2 * mContainer->getBorderSize()); - mContainer->setHeight(area.height - 2 * mContainer->getBorderSize() - + mChatInput->getFrameSize()); + mChatInput->setWidth(area.width - 2 * mChatInput->getFrameSize()); + mContainer->setWidth(area.width - 2 * mContainer->getFrameSize()); + mContainer->setHeight(area.height - 2 * mContainer->getFrameSize() - mChatInput->getHeight() - 5); - mScrollArea->setWidth(area.width - 2 * mScrollArea->getBorderSize()); - mScrollArea->setHeight(area.height - 2 * mScrollArea->getBorderSize() - + mScrollArea->setWidth(area.width - 2 * mScrollArea->getFrameSize()); + mScrollArea->setHeight(area.height - 2 * mScrollArea->getFrameSize() - mChatInput->getHeight() - 26); Window::logic(); } @@ -475,12 +475,12 @@ ChatWindow::createNewChannelTab(std::string channelName) textOutput->setOpaque(false); textOutput->disableLinksAndUserColors(); ScrollArea *scrollArea = new ScrollArea(textOutput); - scrollArea->setPosition(scrollArea->getBorderSize(), scrollArea->getBorderSize()); + scrollArea->setPosition(scrollArea->getFrameSize(), scrollArea->getFrameSize()); scrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS); scrollArea->setOpaque(false); GCContainer *tab = new GCContainer(); - tab->setWidth(getWidth() - 2 * tab->getBorderSize()); - tab->setHeight(getHeight() - 2 * tab->getBorderSize()); + tab->setWidth(getWidth() - 2 * tab->getFrameSize()); + tab->setHeight(getHeight() - 2 * tab->getFrameSize()); tab->add(scrollArea); tab->setOpaque(false); mContainer->addTab(tab, channelName); diff --git a/src/gui/checkbox.cpp b/src/gui/checkbox.cpp index fab4780c..5b300d33 100644 --- a/src/gui/checkbox.cpp +++ b/src/gui/checkbox.cpp @@ -34,8 +34,8 @@ Image *CheckBox::checkBoxChecked; Image *CheckBox::checkBoxDisabled; Image *CheckBox::checkBoxDisabledChecked; -CheckBox::CheckBox(const std::string& caption, bool marked): - gcn::CheckBox(caption, marked) +CheckBox::CheckBox(const std::string& caption, bool selected): + gcn::CheckBox(caption, selected) { if (instances == 0) { @@ -68,7 +68,7 @@ void CheckBox::drawBox(gcn::Graphics* graphics) { Image *box; - if (mMarked) { + if (isSelected()) { if (isEnabled()) { box = checkBoxChecked; } else { diff --git a/src/gui/checkbox.h b/src/gui/checkbox.h index 468a7f38..262e63ae 100644 --- a/src/gui/checkbox.h +++ b/src/gui/checkbox.h @@ -40,7 +40,7 @@ class CheckBox : public gcn::CheckBox { /** * Constructor. */ - CheckBox(const std::string& caption, bool marked = false); + CheckBox(const std::string& caption, bool selected = false); /** * Destructor. diff --git a/src/gui/guildlistbox.cpp b/src/gui/guildlistbox.cpp index 1a392d2d..11661235 100644 --- a/src/gui/guildlistbox.cpp +++ b/src/gui/guildlistbox.cpp @@ -30,27 +30,26 @@ GuildListBox::GuildListBox(): ListBox(NULL) { - } void GuildListBox::draw(gcn::Graphics *graphics) { if (!mListModel) return; - + graphics->setColor(gcn::Color(110, 160, 255)); graphics->setFont(getFont()); - + int fontHeight = getFont()->getHeight(); - + // Draw rectangle below the selected list element if (mSelected >= 0) { graphics->fillRectangle(gcn::Rectangle(0, fontHeight * mSelected, getWidth(), fontHeight)); } - + // TODO: Add online status image - + // Draw the list elements for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); @@ -71,7 +70,7 @@ void GuildListBox::setSelected(int selected) // Update mSelected with bounds checking mSelected = std::min(mListModel->getNumberOfElements() - 1, std::max(-1, selected)); - + gcn::Widget *parent; parent = (gcn::Widget*)getParent(); if (parent) @@ -82,8 +81,8 @@ void GuildListBox::setSelected(int selected) parent->showWidgetPart(this, scroll); } } - - fireSelectionChangedEvent(); + + distributeValueChangedEvent(); } void GuildListBox::mousePressed(gcn::MouseEvent &event) @@ -93,6 +92,6 @@ void GuildListBox::mousePressed(gcn::MouseEvent &event) // TODO: Add guild functions, ie private messaging int y = event.getY(); setSelected(y / getFont()->getHeight()); - generateAction(); + distributeActionEvent(); } } diff --git a/src/gui/guildlistbox.h b/src/gui/guildlistbox.h index befaef1f..262012a4 100644 --- a/src/gui/guildlistbox.h +++ b/src/gui/guildlistbox.h @@ -49,24 +49,6 @@ public: void mousePressed(gcn::MouseEvent &event); - /** - * Adds a listener to the list that's notified each time a change to - * the selection occurs. - */ - void addSelectionListener(SelectionListener *listener) - { - mListeners.push_back(listener); - } - - /** - * Removes a listener from the list that's notified each time a change - * to the selection occurs. - */ - void removeSelectionListener(SelectionListener *listener) - { - mListeners.remove(listener); - } - /** * Sets the index of the selected element. */ diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp index 970c6ce1..eb0faa35 100644 --- a/src/gui/guildwindow.cpp +++ b/src/gui/guildwindow.cpp @@ -173,8 +173,8 @@ void GuildWindow::newGuildTab(const std::string &guildName) // Create new tab GCContainer *tab = new GCContainer(); - tab->setWidth(getWidth() - 2 * tab->getBorderSize()); - tab->setHeight(getHeight() - 2 * tab->getBorderSize()); + tab->setWidth(getWidth() - 2 * tab->getFrameSize()); + tab->setHeight(getHeight() - 2 * tab->getFrameSize()); tab->setOpaque(false); ListBox *list = new ListBox(); list->setListModel(player_node->getGuild(guildName)); diff --git a/src/gui/inttextbox.cpp b/src/gui/inttextbox.cpp index 5ae3dd93..17e87afd 100644 --- a/src/gui/inttextbox.cpp +++ b/src/gui/inttextbox.cpp @@ -51,7 +51,7 @@ IntTextBox::keyPressed(gcn::KeyEvent &event) int i; s >> i; setInt(i); - generateAction(); + distributeActionEvent(); } void IntTextBox::setRange(int min, int max) diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 0ef1ab35..bd224cf0 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -144,7 +144,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event) } } -void InventoryWindow::selectionChanged(const SelectionEvent &event) +void InventoryWindow::valueChanged(const gcn::SelectionEvent &event) { Item *item = mItems->getItem(); ItemInfo const *info = item ? &item->getInfo() : NULL; diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 34883c1c..01fb118c 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -26,10 +26,9 @@ #include #include - +#include #include -#include "selectionlistener.h" #include "window.h" #include "../guichanfwd.h" @@ -45,7 +44,7 @@ class ItemContainer; class InventoryWindow : public Window, public gcn::ActionListener, public gcn::KeyListener, - public SelectionListener + public gcn::SelectionListener { public: /** @@ -82,10 +81,8 @@ class InventoryWindow : public Window, /** * Updates labels to currently selected item. - * - * @see SelectionListener::selectionChanged. */ - void selectionChanged(const SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event); private: void updateButtons(); /**< Updates button states. */ diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 1abb8f0b..eddb6011 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -24,9 +24,9 @@ #include "itemcontainer.h" #include +#include #include "sdlinput.h" -#include "selectionlistener.h" #include "../graphics.h" #include "../inventory.h" @@ -159,20 +159,19 @@ void ItemContainer::setSelectedItem(Item *item) if (mSelectedItem != item) { mSelectedItem = item; - fireSelectionChangedEvent(); + distributeValueChangedEvent(); } } -void -ItemContainer::fireSelectionChangedEvent() +void ItemContainer::distributeValueChangedEvent() { - SelectionEvent event(this); - SelectionListeners::iterator i_end = mListeners.end(); - SelectionListeners::iterator i; + SelectionListenerIterator iter; - for (i = mListeners.begin(); i != i_end; ++i) + for (iter = mSelectionListeners.begin(); iter != mSelectionListeners.end(); + ++iter) { - (*i)->selectionChanged(event); + gcn::SelectionEvent event(this); + (*iter)->valueChanged(event); } } diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index 8be338dd..fad59171 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -34,7 +34,10 @@ class Image; class Inventory; class Item; -class SelectionListener; + +namespace gcn { + class SelectionListener; +} /** * An item container. Used to show items in inventory and trade dialog. @@ -104,18 +107,18 @@ class ItemContainer : public gcn::Widget, * Adds a listener to the list that's notified each time a change to * the selection occurs. */ - void addSelectionListener(SelectionListener *listener) + void addSelectionListener(gcn::SelectionListener *listener) { - mListeners.push_back(listener); + mSelectionListeners.push_back(listener); } /** * Removes a listener from the list that's notified each time a change * to the selection occurs. */ - void removeSelectionListener(SelectionListener *listener) + void removeSelectionListener(gcn::SelectionListener *listener) { - mListeners.remove(listener); + mSelectionListeners.remove(listener); } enum { @@ -145,7 +148,7 @@ class ItemContainer : public gcn::Widget, /** * Sends out selection events to the list of selection listeners. */ - void fireSelectionChangedEvent(); + void distributeValueChangedEvent(); /** * Gets the slot index based on the cursor position. @@ -164,7 +167,10 @@ class ItemContainer : public gcn::Widget, bool mSwapItems; int mDragPosX, mDragPosY; - std::list mListeners; + typedef std::list SelectionListenerList; + typedef SelectionListenerList::iterator SelectionListenerIterator; + + SelectionListenerList mSelectionListeners; }; #endif diff --git a/src/gui/itemshortcutwindow.cpp b/src/gui/itemshortcutwindow.cpp index cf266290..c7b2bd05 100644 --- a/src/gui/itemshortcutwindow.cpp +++ b/src/gui/itemshortcutwindow.cpp @@ -38,7 +38,7 @@ ItemShortcutWindow::ItemShortcutWindow() mItems = new ItemShortcutContainer(); - int border = SCROLL_PADDING * 2 + getPadding() * 2; + const int border = SCROLL_PADDING * 2 + getPadding() * 2; setMinWidth(mItems->getBoxWidth() + border); setMinHeight(mItems->getBoxHeight() + border); setMaxWidth(mItems->getBoxWidth() * mItems->getMaxItems() + border); @@ -50,7 +50,6 @@ ItemShortcutWindow::ItemShortcutWindow() add(mInvenScroll); - addWindowListener(this); loadWindowState("ItemShortcut"); } @@ -65,9 +64,11 @@ void ItemShortcutWindow::logic() Window::logic(); } -void ItemShortcutWindow::windowResized(const WindowEvent &event) +void ItemShortcutWindow::widgetResized(const gcn::Event &event) { - const gcn::Rectangle area = getChildrenArea(); + Window::widgetResized(event); + + const gcn::Rectangle &area = getChildrenArea(); mInvenScroll->setSize( area.width - SCROLL_PADDING, diff --git a/src/gui/itemshortcutwindow.h b/src/gui/itemshortcutwindow.h index 1dde8686..51685e49 100644 --- a/src/gui/itemshortcutwindow.h +++ b/src/gui/itemshortcutwindow.h @@ -25,7 +25,6 @@ #define _TMW_ITEMSHORTCUTWINDOW_H #include "window.h" -#include "windowlistener.h" #include "../guichanfwd.h" @@ -36,7 +35,7 @@ class ItemShortcutContainer; * * \ingroup Interface */ -class ItemShortcutWindow : public Window, WindowListener +class ItemShortcutWindow : public Window { public: /** @@ -55,9 +54,9 @@ class ItemShortcutWindow : public Window, WindowListener void logic(); /** - * Called whenever the window is resized. + * Called whenever the widget changes size. */ - void windowResized(const WindowEvent &event); + void widgetResized(const gcn::Event &event); private: ItemShortcutContainer *mItems; diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index 61c7e078..ac18c2cd 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -23,8 +23,6 @@ #include "listbox.h" -#include "selectionlistener.h" - #include #include #include @@ -67,13 +65,6 @@ void ListBox::draw(gcn::Graphics *graphics) } } -void -ListBox::setSelected(int selected) -{ - gcn::ListBox::setSelected(selected); - fireSelectionChangedEvent(); -} - void ListBox::mouseDragged(gcn::MouseEvent &event) { @@ -81,15 +72,3 @@ ListBox::mouseDragged(gcn::MouseEvent &event) // selection to be updated as is default in many GUIs. mousePressed(event); } - -void ListBox::fireSelectionChangedEvent() -{ - SelectionEvent event(this); - SelectionListeners::iterator i_end = mListeners.end(); - SelectionListeners::iterator i; - - for (i = mListeners.begin(); i != i_end; ++i) - { - (*i)->selectionChanged(event); - } -} diff --git a/src/gui/listbox.h b/src/gui/listbox.h index 21172a22..03a8b541 100644 --- a/src/gui/listbox.h +++ b/src/gui/listbox.h @@ -50,37 +50,6 @@ class ListBox : public gcn::ListBox void draw(gcn::Graphics *graphics); void mouseDragged(gcn::MouseEvent &event); - - /** - * Adds a listener to the list that's notified each time a change to - * the selection occurs. - */ - void addSelectionListener(SelectionListener *listener) - { - mListeners.push_back(listener); - } - - /** - * Removes a listener from the list that's notified each time a change - * to the selection occurs. - */ - void removeSelectionListener(SelectionListener *listener) - { - mListeners.remove(listener); - } - - /** - * Sets the index of the selected element. - */ - virtual void setSelected(int selected); - - protected: - /** - * Sends out selection events to the list of selection listeners. - */ - void fireSelectionChangedEvent(); - - std::list mListeners; }; #endif diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 57ad00c5..f1b32d48 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -94,7 +94,7 @@ LoginDialog::action(const gcn::ActionEvent &event) { mLoginData->username = mUserField->getText(); mLoginData->password = mPassField->getText(); - mLoginData->remember = mKeepCheck->isMarked(); + mLoginData->remember = mKeepCheck->isSelected(); mLoginData->registerLogin = false; mOkButton->setEnabled(false); diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index 8e5f1827..2c633b72 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -39,7 +39,7 @@ ImageRect PlayerBox::background; PlayerBox::PlayerBox(const Player *player): mPlayer(player) { - setBorderSize(2); + setFrameSize(2); if (instances == 0) { @@ -83,7 +83,7 @@ PlayerBox::draw(gcn::Graphics *graphics) { // Draw character int x, y, bs; - bs = getBorderSize(); + bs = getFrameSize(); x = getWidth() / 2 - 16 + bs; y = getHeight() / 2 + bs; mPlayer->draw(static_cast(graphics), x, y); @@ -91,10 +91,10 @@ PlayerBox::draw(gcn::Graphics *graphics) } void -PlayerBox::drawBorder(gcn::Graphics *graphics) +PlayerBox::drawFrame(gcn::Graphics *graphics) { int w, h, bs; - bs = getBorderSize(); + bs = getFrameSize(); w = getWidth() + bs * 2; h = getHeight() + bs * 2; diff --git a/src/gui/playerbox.h b/src/gui/playerbox.h index 6bba1b51..c226e750 100644 --- a/src/gui/playerbox.h +++ b/src/gui/playerbox.h @@ -64,7 +64,7 @@ class PlayerBox : public gcn::ScrollArea /** * Draws the background and border of the scroll area. */ - void drawBorder(gcn::Graphics *graphics); + void drawFrame(gcn::Graphics *graphics); private: const Player *mPlayer; /**< The character used for display */ diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index c9d974a6..7ed4f913 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -65,13 +65,13 @@ QuitDialog::QuitDialog(bool* quitGame, QuitDialog** pointerToMe): state == STATE_LOGIN_ATTEMPT || state == STATE_UPDATE) { - mForceQuit->setMarked(true); + mForceQuit->setSelected(true); add(mForceQuit); } else { // Only added if we are connected to an accountserver or gameserver - mLogoutQuit->setMarked(true); + mLogoutQuit->setSelected(true); add(mLogoutQuit); add(mSwitchAccountServer); @@ -104,11 +104,11 @@ QuitDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "ok") { - if (mForceQuit->isMarked()) + if (mForceQuit->isSelected()) { state = STATE_FORCE_QUIT; } - else if (mLogoutQuit->isMarked()) + else if (mLogoutQuit->isSelected()) { if ((state == STATE_GAME) && (mQuitGame)) { @@ -116,7 +116,7 @@ QuitDialog::action(const gcn::ActionEvent &event) } state = STATE_EXIT; } - else if (mSwitchAccountServer->isMarked()) + else if (mSwitchAccountServer->isSelected()) { if ((state == STATE_GAME) && (mQuitGame)) { @@ -124,7 +124,7 @@ QuitDialog::action(const gcn::ActionEvent &event) } state = STATE_SWITCH_ACCOUNTSERVER_ATTEMPT; } - else if (mSwitchCharacter->isMarked()) + else if (mSwitchCharacter->isSelected()) { if (mQuitGame) *mQuitGame = true; diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp index e318116a..0ac4dea8 100644 --- a/src/gui/radiobutton.cpp +++ b/src/gui/radiobutton.cpp @@ -67,7 +67,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics) { Image *box = NULL; - if (mMarked) { + if (isSelected()) { if (isEnabled()) { box = radioChecked; } else { diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index cf555ef4..97384fa3 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -153,12 +153,12 @@ void ScrollArea::logic() if (getHorizontalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER) { content->setWidth(getChildrenArea().width - - 2 * content->getBorderSize()); + 2 * content->getFrameSize()); } if (getVerticalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER) { content->setHeight(getChildrenArea().height - - 2 * content->getBorderSize()); + 2 * content->getFrameSize()); } } } @@ -204,15 +204,15 @@ void ScrollArea::draw(gcn::Graphics *graphics) { graphics->pushClipArea(getChildrenArea()); - if (content->getBorderSize() > 0) + if (content->getFrameSize() > 0) { gcn::Rectangle rec = content->getDimension(); - rec.x -= content->getBorderSize(); - rec.y -= content->getBorderSize(); - rec.width += 2 * content->getBorderSize(); - rec.height += 2 * content->getBorderSize(); + rec.x -= content->getFrameSize(); + rec.y -= content->getFrameSize(); + rec.width += 2 * content->getFrameSize(); + rec.height += 2 * content->getFrameSize(); graphics->pushClipArea(rec); - content->drawBorder(graphics); + content->drawFrame(graphics); graphics->popClipArea(); } @@ -223,9 +223,9 @@ void ScrollArea::draw(gcn::Graphics *graphics) } } -void ScrollArea::drawBorder(gcn::Graphics *graphics) +void ScrollArea::drawFrame(gcn::Graphics *graphics) { - int bs = getBorderSize(); + int bs = getFrameSize(); int w = getWidth() + bs * 2; int h = getHeight() + bs * 2; @@ -240,10 +240,10 @@ void ScrollArea::setOpaque(bool opaque) mOpaque = opaque; if (mOpaque) { - setBorderSize(2); + setFrameSize(2); } else { - setBorderSize(0); + setFrameSize(0); } } diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index 504842cc..9fb7093d 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -65,7 +65,7 @@ class ScrollArea : public gcn::ScrollArea { /** * Draws the background and border of the scroll area. */ - void drawBorder(gcn::Graphics *graphics); + void drawFrame(gcn::Graphics *graphics); /** * Sets whether the widget should draw its background or not. diff --git a/src/gui/selectionlistener.h b/src/gui/selectionlistener.h deleted file mode 100644 index 917a4871..00000000 --- a/src/gui/selectionlistener.h +++ /dev/null @@ -1,68 +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_SELECTIONLISTENER_H__ -#define _TMW_SELECTIONLISTENER_H__ - -#include -#include - -/** - * An event that characterizes a change in the current selection. - * - * \ingroup GUI - */ -class SelectionEvent : public gcn::Event -{ - public: - /** - * Constructor. - */ - SelectionEvent(gcn::Widget *source): - gcn::Event(source) - { - } -}; - -/** - * The listener that's notified when a selection value changes. - * - * \ingroup GUI - */ -class SelectionListener -{ - public: - /** - * Virtual destructor. - */ - virtual ~SelectionListener() {} - - /** - * Called whenever the value of the selection changes. - */ - virtual void selectionChanged(const SelectionEvent &event) = 0; -}; - -typedef std::list SelectionListeners; - -#endif diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index bc683c0b..e101ad39 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -182,7 +182,7 @@ void SellDialog::action(const gcn::ActionEvent &event) } } -void SellDialog::selectionChanged(const SelectionEvent &event) +void SellDialog::valueChanged(const gcn::SelectionEvent &event) { // Reset amount of items and update labels mAmountItems = 1; diff --git a/src/gui/sell.h b/src/gui/sell.h index cde862d5..63a16770 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -25,10 +25,9 @@ #define _TMW_SELL_H #include +#include #include "window.h" -#include "selectionlistener.h" -#include "windowlistener.h" #include "../guichanfwd.h" @@ -41,7 +40,7 @@ class ShopListBox; * * \ingroup Interface */ -class SellDialog : public Window, gcn::ActionListener, SelectionListener +class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener { public: /** @@ -76,7 +75,7 @@ class SellDialog : public Window, gcn::ActionListener, SelectionListener * * @see SelectionListener::selectionChanged */ - void selectionChanged(const SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event); /** * Gives Player's Money amount diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index 89c21e2b..a02b3c20 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -72,7 +72,7 @@ Setup_Audio::Setup_Audio(): void Setup_Audio::apply() { - if (mSoundCheckBox->isMarked()) + if (mSoundCheckBox->isSelected()) { config.setValue("sound", 1); try { @@ -97,7 +97,7 @@ void Setup_Audio::apply() void Setup_Audio::cancel() { - mSoundCheckBox->setMarked(mSoundEnabled); + mSoundCheckBox->setSelected(mSoundEnabled); sound.setSfxVolume(mSfxVolume); mSfxSlider->setValue(mSfxVolume); diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp index 59cfefa4..dfa446ab 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -45,7 +45,7 @@ Setup_Joystick::Setup_Joystick(): mCalibrateButton->setPosition(10, 30 + mCalibrateLabel->getHeight()); mOriginalJoystickEnabled = (int)config.getValue("joystickEnabled", 0) != 0; - mJoystickEnabled->setMarked(mOriginalJoystickEnabled); + mJoystickEnabled->setSelected(mOriginalJoystickEnabled); mJoystickEnabled->addActionListener(this); @@ -62,7 +62,7 @@ void Setup_Joystick::action(const gcn::ActionEvent &event) if (event.getSource() == mJoystickEnabled) { - joystick->setEnabled(mJoystickEnabled->isMarked()); + joystick->setEnabled(mJoystickEnabled->isSelected()); } else { @@ -85,7 +85,7 @@ void Setup_Joystick::cancel() { joystick->setEnabled(mOriginalJoystickEnabled); } - mJoystickEnabled->setMarked(mOriginalJoystickEnabled); + mJoystickEnabled->setSelected(mOriginalJoystickEnabled); } void Setup_Joystick::apply() diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index ee46396b..fcdb6c51 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -157,7 +157,7 @@ Setup_Video::Setup_Video(): mFpsField->setEnabled(mFps > 0); mFpsSlider->setValue(mFps); mFpsSlider->setEnabled(mFps > 0); - mFpsCheckBox->setMarked(mFps > 0); + mFpsCheckBox->setSelected(mFps > 0); mCustomCursorCheckBox->setActionEventId("customcursor"); mAlphaSlider->setActionEventId("guialpha"); @@ -245,7 +245,7 @@ Setup_Video::~Setup_Video() void Setup_Video::apply() { // Full screen changes - bool fullscreen = mFsCheckBox->isMarked(); + bool fullscreen = mFsCheckBox->isSelected(); if (fullscreen != (config.getValue("screen", 0) == 1)) { // checks for opengl usage @@ -272,9 +272,9 @@ void Setup_Video::apply() } // OpenGL change - if (mOpenGLCheckBox->isMarked() != mOpenGLEnabled) + if (mOpenGLCheckBox->isSelected() != mOpenGLEnabled) { - config.setValue("opengl", mOpenGLCheckBox->isMarked() ? 1 : 0); + config.setValue("opengl", mOpenGLCheckBox->isSelected() ? 1 : 0); // OpenGL can currently only be changed by restarting, notify user. new OkDialog(_("Changing OpenGL"), @@ -315,9 +315,9 @@ Setup_Video::updateSlider(gcn::Slider *slider, gcn::TextField *field, void Setup_Video::cancel() { - mFsCheckBox->setMarked(mFullScreenEnabled); - mOpenGLCheckBox->setMarked(mOpenGLEnabled); - mCustomCursorCheckBox->setMarked(mCustomCursorEnabled); + mFsCheckBox->setSelected(mFullScreenEnabled); + mOpenGLCheckBox->setSelected(mOpenGLEnabled); + mCustomCursorCheckBox->setSelected(mCustomCursorEnabled); mAlphaSlider->setValue(mOpacity); mOverlayDetailSlider->setValue(mOverlayDetail); @@ -341,7 +341,7 @@ void Setup_Video::action(const gcn::ActionEvent &event) else if (event.getId() == "customcursor") { config.setValue("customcursor", - mCustomCursorCheckBox->isMarked() ? 1 : 0); + mCustomCursorCheckBox->isSelected() ? 1 : 0); } else if (event.getId() == "fpslimitslider") { @@ -379,7 +379,7 @@ void Setup_Video::action(const gcn::ActionEvent &event) } else if (event.getId() == "fpslimitcheckbox") { - if (mFpsCheckBox->isMarked()) + if (mFpsCheckBox->isSelected()) { mFps = (int) mFpsSlider->getValue(); } diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index e6d3c516..ba77be47 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -23,8 +23,6 @@ #include "shoplistbox.h" -#include "selectionlistener.h" - #include #include #include @@ -101,37 +99,12 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) } } -void ShopListBox::setSelected(int selected) -{ - if (!mListModel) - { - mSelected = -1; - } - else - { - // Update mSelected with bounds checking - mSelected = std::min(mListModel->getNumberOfElements() - 1, - std::max(-1, selected)); - - gcn::Widget *parent = getParent(); - if (parent && mSelected >= 0) - { - gcn::Rectangle scroll; - scroll.y = mRowHeight * mSelected; - scroll.height = mRowHeight; - parent->showWidgetPart(this, scroll); - } - } - - fireSelectionChangedEvent(); -} - void ShopListBox::mousePressed(gcn::MouseEvent &event) { if (event.getButton() == gcn::MouseEvent::LEFT) { setSelected(event.getY() / mRowHeight); - generateAction(); + distributeActionEvent(); } } diff --git a/src/gui/shoplistbox.h b/src/gui/shoplistbox.h index 44a68445..d5e2d836 100644 --- a/src/gui/shoplistbox.h +++ b/src/gui/shoplistbox.h @@ -27,8 +27,6 @@ #include "listbox.h" #include "shop.h" -class SelectionListener; - /** * A list box, meant to be used inside a scroll area. Same as the Guichan list * box except this one doesn't have a background, instead completely relying @@ -54,30 +52,12 @@ class ShopListBox : public ListBox */ void draw(gcn::Graphics *graphics); - void mousePressed(gcn::MouseEvent &event); - /** - * Adds a listener to the list that's notified each time a change to - * the selection occurs. + * Returns the height of a row. */ - void addSelectionListener(SelectionListener *listener) - { - mListeners.push_back(listener); - } + unsigned int getRowHeight() const { return mRowHeight; } - /** - * Removes a listener from the list that's notified each time a change - * to the selection occurs. - */ - void removeSelectionListener(SelectionListener *listener) - { - mListeners.remove(listener); - } - - /** - * Sets the index of the selected element. - */ - void setSelected(int selected); + void mousePressed(gcn::MouseEvent &event); /** * gives information about the current player's money @@ -104,7 +84,7 @@ class ShopListBox : public ListBox */ ShopItems *mShopItems; - int mRowHeight; /**< Row Height */ + unsigned int mRowHeight; /**< Row Height */ bool mPriceCheck; }; diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp index f0170a1b..c94c7bfb 100644 --- a/src/gui/slider.cpp +++ b/src/gui/slider.cpp @@ -64,7 +64,7 @@ Slider::~Slider() void Slider::init() { int x, y, w, h,o1,o2; - setBorderSize(0); + setFrameSize(0); // Load resources if (mInstances == 0) diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp index 8fb2f598..d6267e65 100644 --- a/src/gui/tabbedcontainer.cpp +++ b/src/gui/tabbedcontainer.cpp @@ -82,8 +82,8 @@ void TabbedContainer::logic() { if (mActiveContent) { mActiveContent->setSize( - getWidth() - 2 * mActiveContent->getBorderSize(), - getHeight() - TABHEIGHT - 2 * mActiveContent->getBorderSize()); + getWidth() - 2 * mActiveContent->getFrameSize(), + getHeight() - TABHEIGHT - 2 * mActiveContent->getFrameSize()); } Container::logic(); diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index 329813e5..84c8ad4b 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -32,14 +32,14 @@ TextBox::TextBox(): gcn::TextBox() { setOpaque(false); - setBorderSize(0); + setFrameSize(0); } TextBox::TextBox(const std::string& text): gcn::TextBox(text) { setOpaque(false); - setBorderSize(0); + setFrameSize(0); } void TextBox::setText(const std::string &text) diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp index 11659b8b..4fd85d36 100644 --- a/src/gui/textfield.cpp +++ b/src/gui/textfield.cpp @@ -44,7 +44,7 @@ ImageRect TextField::skin; TextField::TextField(const std::string& text): gcn::TextField(text) { - setBorderSize(2); + setFrameSize(2); if (instances == 0) { @@ -97,10 +97,10 @@ void TextField::draw(gcn::Graphics *graphics) graphics->drawText(mText, 1 - mXScroll, 1); } -void TextField::drawBorder(gcn::Graphics *graphics) +void TextField::drawFrame(gcn::Graphics *graphics) { int w, h, bs; - bs = getBorderSize(); + bs = getFrameSize(); w = getWidth() + bs * 2; h = getHeight() + bs * 2; @@ -184,7 +184,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) } break; case Key::ENTER: - generateAction(); + distributeActionEvent(); break; case Key::HOME: diff --git a/src/gui/textfield.h b/src/gui/textfield.h index e36380e3..36f921ac 100644 --- a/src/gui/textfield.h +++ b/src/gui/textfield.h @@ -53,7 +53,7 @@ class TextField : public gcn::TextField { /** * Draws the background and border. */ - void drawBorder(gcn::Graphics *graphics); + void drawFrame(gcn::Graphics *graphics); /** * Processes one keypress. diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index bb3d702f..c098c04c 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -147,7 +147,7 @@ void TradeWindow::tradeItem(Item *item, int quantity) item->increaseQuantity(-quantity); } -void TradeWindow::selectionChanged(const SelectionEvent &event) +void TradeWindow::valueChanged(const gcn::SelectionEvent &event) { Item *item; diff --git a/src/gui/trade.h b/src/gui/trade.h index 449de573..c8ece8d9 100644 --- a/src/gui/trade.h +++ b/src/gui/trade.h @@ -25,9 +25,9 @@ #define _TMW_TRADE_H #include +#include #include "window.h" -#include "selectionlistener.h" #include "../guichanfwd.h" @@ -41,7 +41,7 @@ class ScrollArea; * * \ingroup Interface */ -class TradeWindow : public Window, gcn::ActionListener, SelectionListener +class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener { public: /** @@ -84,7 +84,7 @@ class TradeWindow : public Window, gcn::ActionListener, SelectionListener * Updates the labels and makes sure only one item is selected in * either my inventory or partner inventory. */ - void selectionChanged(const SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event); /** * Called when receiving actions from the widgets. diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 6863aa01..b33a55cf 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -42,7 +42,7 @@ DropDown::DropDown(gcn::ListModel *listModel, gcn::DropDown::DropDown(listModel, scrollArea, listBox) { - setBorderSize(2); + setFrameSize(2); // Initialize graphics if (instances == 0) @@ -103,7 +103,7 @@ void DropDown::draw(gcn::Graphics* graphics) if (mDroppedDown) { - h = mOldH; + h = mFoldedUpHeight; } else { @@ -151,19 +151,18 @@ void DropDown::draw(gcn::Graphics* graphics) } } -void DropDown::drawBorder(gcn::Graphics *graphics) +void DropDown::drawFrame(gcn::Graphics *graphics) { - int w, h, bs; - bs = getBorderSize(); - w = getWidth() + bs * 2; - h = getHeight() + bs * 2; + const int bs = getFrameSize(); + const int w = getWidth() + bs * 2; + const int h = getHeight() + bs * 2; static_cast(graphics)->drawImageRect(0, 0, w, h, skin); } void DropDown::drawButton(gcn::Graphics *graphics) { - int height = mDroppedDown ? mOldH : getHeight(); + int height = mDroppedDown ? mFoldedUpHeight : getHeight(); static_cast(graphics)-> drawImage(buttons[mDroppedDown][mPushed], getWidth() - height, 1); diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 37e754af..d0dab7d2 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -64,7 +64,7 @@ class DropDown : public gcn::DropDown void draw(gcn::Graphics* graphics); - void drawBorder(gcn::Graphics* graphics); + void drawFrame(gcn::Graphics* graphics); protected: diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 7629e2e7..75288eb5 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -106,7 +106,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent): instances++; - setBorderSize(0); + setFrameSize(0); setPadding(3); setTitleBarHeight(20); @@ -121,6 +121,8 @@ Window::Window(const std::string& caption, bool modal, Window *parent): // Windows are invisible by default setVisible(false); + + addWidgetListener(this); } Window::~Window() @@ -202,84 +204,12 @@ void Window::draw(gcn::Graphics *graphics) drawChildren(graphics); } -void Window::setContentWidth(int width) -{ - setWidth(width + 2 * getPadding()); -} - -void Window::setContentHeight(int height) -{ - setHeight(height + getPadding() + getTitleBarHeight()); -} - void Window::setContentSize(int width, int height) { setSize(width + 2 * getPadding(), height + getPadding() + getTitleBarHeight()); } -void Window::setSize(int width, int height) -{ - if (width == mDimension.width && height == mDimension.height) return; - - // No call to ancestor! Infinite loop otherwise. - mDimension.width = width; - mDimension.height = height; - - if (mGrip) - { - gcn::Rectangle const &area = getChildrenArea(); - mGrip->setPosition(width - mGrip->getWidth() - area.x, - height - mGrip->getHeight() - area.y); - } - - if (mLayout) - { - int w = width - 2 * getPadding(), - h = height - getPadding() - getTitleBarHeight(); - mLayout->reflow(w, h); - } - - fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_RESIZED)); -} - -void Window::setWidth(int width) -{ - setSize(width, mDimension.height); -} - -void Window::setHeight(int height) -{ - setSize(mDimension.width, height); -} - -void Window::setPosition(int x, int y) -{ - if (x == mDimension.x && y == mDimension.y) return; - - // No call to ancestor! - mDimension.x = x; - mDimension.y = y; - - fireWindowEvent(WindowEvent(this, WindowEvent::WINDOW_MOVED)); -} - -void Window::setDimension(const gcn::Rectangle &dimension) -{ - setPosition(dimension.x, dimension.y); - setSize(dimension.width, dimension.height); -} - -void Window::setX(int x) -{ - setPosition(x, mDimension.y); -} - -void Window::setY(int y) -{ - setPosition(mDimension.x, y); -} - void Window::setLocationRelativeTo(gcn::Widget *widget) { int wx, wy; @@ -331,6 +261,23 @@ void Window::setResizable(bool r) } } +void Window::widgetResized(const gcn::Event &event) +{ + if (mGrip) + { + gcn::Rectangle const &area = getChildrenArea(); + mGrip->setPosition(getWidth() - mGrip->getWidth() - area.x, + getHeight() - mGrip->getHeight() - area.y); + } + + if (mLayout) + { + int w = getWidth() - 2 * getPadding(); + int h = getHeight() - getPadding() - getTitleBarHeight(); + mLayout->reflow(w, h); + } +} + void Window::setCloseButton(bool flag) { mCloseButton = flag; @@ -407,7 +354,7 @@ void Window::mouseReleased(gcn::MouseEvent &event) } // This should be the responsibility of Guichan (and is from 0.8.0 on) - mIsMoving = false; + mMoved = false; } void Window::mouseExited(gcn::MouseEvent &event) @@ -449,7 +396,7 @@ void Window::mouseDragged(gcn::MouseEvent &event) gcn::Window::mouseDragged(event); // Keep guichan window inside screen when it may be moved - if (isMovable() && mIsMoving) + if (isMovable() && mMoved) { int newX = std::max(0, getX()); int newY = std::max(0, getY()); @@ -458,7 +405,7 @@ void Window::mouseDragged(gcn::MouseEvent &event) setPosition(newX, newY); } - if (mouseResize && !mIsMoving) + if (mouseResize && !mMoved) { const int dx = event.getX() - mDragOffsetX; const int dy = event.getY() - mDragOffsetY; @@ -585,24 +532,6 @@ int Window::getResizeHandles(gcn::MouseEvent &event) return resizeHandles; } -void Window::fireWindowEvent(const WindowEvent &event) -{ - WindowListeners::iterator i_end = mListeners.end(); - WindowListeners::iterator i = mListeners.begin(); - - switch (event.getType()) - { - case WindowEvent::WINDOW_MOVED: - for (; i != i_end; ++i) - { (*i)->windowMoved(event); } - break; - case WindowEvent::WINDOW_RESIZED: - for (; i != i_end; ++i) - { (*i)->windowResized(event); } - break; - } -} - Layout &Window::getLayout() { if (!mLayout) mLayout = new Layout; diff --git a/src/gui/window.h b/src/gui/window.h index df756be3..9f5969f0 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -25,11 +25,10 @@ #define _TMW_WINDOW_H__ #include +#include #include "../guichanfwd.h" -#include "windowlistener.h" - class ConfigListener; class ContainerPlacer; class Image; @@ -45,7 +44,7 @@ class WindowContainer; * * \ingroup GUI */ -class Window : public gcn::Window +class Window : public gcn::Window, gcn::WidgetListener { public: friend class WindowConfigListener; @@ -78,56 +77,11 @@ class Window : public gcn::Window */ void draw(gcn::Graphics *graphics); - /** - * Sets the width of the window contents. - */ - void setContentWidth(int width); - - /** - * Sets the height of the window contents. - */ - void setContentHeight(int height); - /** * Sets the size of this window. */ void setContentSize(int width, int height); - /** - * Sets the size of this window. - */ - void setSize(int width, int height); - - /** - * Sets the width of this window. - */ - void setWidth(int width); - - /** - * Sets the height of this window. - */ - void setHeight(int height); - - /** - * Sets the position and size of this window. - */ - void setDimension(const gcn::Rectangle &dimension); - - /** - * Sets the position of this window. - */ - void setPosition(int x, int y); - - /** - * Sets the window x coordinate. - */ - void setX(int x); - - /** - * Sets the window y coordinate. - */ - void setY(int y); - /** * Sets the location relative to the given widget. */ @@ -138,6 +92,11 @@ class Window : public gcn::Window */ void setResizable(bool resize); + /** + * Called whenever the widget changes size. + */ + void widgetResized(const gcn::Event &event); + /** * Sets whether or not the window has a close button. */ @@ -256,20 +215,6 @@ class Window : public gcn::Window */ void resetToDefaultSize(); - /** - * Adds a listener to the list that's notified when the window is - * moved or resized. - */ - void addWindowListener(WindowListener *listener) - { mListeners.push_back(listener); } - - /** - * Removes a listener from the list that's notified when the window is - * moved or resized. - */ - void removeWindowListener(WindowListener *listener) - { mListeners.remove(listener); } - enum ResizeHandles { TOP = 0x01, @@ -349,14 +294,6 @@ class Window : public gcn::Window * where two borders are moved at the same time. */ static const int resizeBorderWidth = 10; - - private: - /** - * Sends out a window event to the list of selection listeners. - */ - void fireWindowEvent(const WindowEvent &event); - - WindowListeners mListeners; }; #endif diff --git a/src/gui/windowlistener.h b/src/gui/windowlistener.h deleted file mode 100644 index 24f6a7b8..00000000 --- a/src/gui/windowlistener.h +++ /dev/null @@ -1,86 +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_WINDOW_LISTENER_H_ -#define _TMW_WINDOW_LISTENER_H_ - -#include -#include - -/** - * An event that characterizes a window move or resize. - * - * \ingroup GUI - */ -class WindowEvent : public gcn::Event -{ - public: - /** - * Constructor. - */ - WindowEvent(gcn::Window *source, int type): - gcn::Event(source) - { - mType = type; - } - - /** - * Returns the event type. - */ - int getType() const - { return mType; } - - enum WindowEventType - { - WINDOW_MOVED, - WINDOW_RESIZED - }; -}; - -/** - * The listener that's notified when a window is moved or resized. - * - * \ingroup GUI - */ -class WindowListener -{ - public: - /** - * Virtual destructor. - */ - virtual ~WindowListener() {} - - /** - * Called whenever the window is moved. - */ - virtual void windowMoved(const WindowEvent &) {} - - /** - * Called whenever the window is resized. - */ - virtual void windowResized(const WindowEvent &) {} -}; - -typedef std::list WindowListeners; - -#endif -- cgit v1.2.3-70-g09d2 From b57ab24cdaa596bf91604279c97fbfdeff1dc93b Mon Sep 17 00:00:00 2001 From: David Athay Date: Fri, 9 May 2008 15:23:32 +0000 Subject: Changed the tabbedarea to be transparant as before. Changed setup window and skills dialog to use the new tabbed area. Removed tabbed container as it is no longer used. Fixed a crash with the chat window. --- ChangeLog | 11 ++++ src/gui/chat.cpp | 9 ++- src/gui/setup.cpp | 14 ++--- src/gui/setup_audio.cpp | 1 + src/gui/setup_joystick.cpp | 2 + src/gui/setup_keyboard.cpp | 1 + src/gui/setup_video.cpp | 1 + src/gui/skill.cpp | 13 +++-- src/gui/tabbedcontainer.cpp | 126 ----------------------------------------- src/gui/tabbedcontainer.h | 67 ---------------------- src/gui/widgets/tabbedarea.cpp | 2 +- src/gui/widgets/tabbedarea.h | 1 - tmw.cbp | 7 +-- 13 files changed, 42 insertions(+), 213 deletions(-) delete mode 100644 src/gui/tabbedcontainer.cpp delete mode 100644 src/gui/tabbedcontainer.h (limited to 'src/gui/setup_audio.cpp') diff --git a/ChangeLog b/ChangeLog index 4b762e38..ca2f06bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-05-09 David Athay + + * src/gui/setup_keyboard.cpp, src/gui/setup.cpp, + src/gui/widgets/tabbedarea.h, src/gui/widgets/tabbedarea.cpp, + src/gui/chat.cpp, src/gui/tabbedcontainer.cpp, src/gui/skill.cpp, + src/gui/setup_audio.cpp, src/gui/setup_video.cpp, + src/gui/setup_joystick.cpp, src/gui/tabbedcontainer.h, tmw.cbp: + Changed the tabbedarea to be transparant as before. Changed setup + window and skills dialog to use the new tabbed area. Removed tabbed + container as it is no longer used. Fixed a crash with the chat window. + 2008-05-08 David Athay * src/net/chathandler.cpp: Fixed initialisation in case. diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 3d63491c..fec2394b 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -152,7 +152,7 @@ ChatWindow::chatLog(std::string line, int own, const std::string &channelName) break; case BY_PLAYER: tmp.nick += ": "; - lineColor = "##5"; // Equiv. to BrowserBox::YELLOW + lineColor = "##3"; // Equiv. to BrowserBox::BLUE break; case BY_OTHER: tmp.nick += ": "; @@ -506,10 +506,17 @@ ChatWindow::createNewChannelTab(const std::string &channelName) BrowserBox *textOutput = new BrowserBox(BrowserBox::AUTO_WRAP); textOutput->setOpaque(false); textOutput->disableLinksAndUserColors(); + textOutput->setMaxRow((int) config.getValue("ChatLogLength", 0)); ScrollArea *scrollArea = new ScrollArea(textOutput); scrollArea->setPosition(scrollArea->getFrameSize(), scrollArea->getFrameSize()); scrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS); scrollArea->setOpaque(false); + scrollArea->setWidth(getChildrenArea().width - 2 * scrollArea->getFrameSize()); + scrollArea->setHeight(getChildrenArea().height - 2 * scrollArea->getFrameSize() - + mChatInput->getHeight() - 5); + scrollArea->logic(); + textOutput->setWidth(scrollArea->getChildrenArea().width); + textOutput->setHeight(scrollArea->getChildrenArea().height); // Add channel to the tabbed area mChatTabs->addTab(channelName, scrollArea); diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index b69cb9f1..d1f8a38a 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -30,7 +30,8 @@ #include "setup_joystick.h" #include "setup_video.h" #include "setup_keyboard.h" -#include "tabbedcontainer.h" + +#include "widgets/tabbedarea.h" #include "../utils/dtor.h" #include "../utils/gettext.h" @@ -63,26 +64,25 @@ Setup::Setup(): add(btn); } - TabbedContainer *panel = new TabbedContainer(); + TabbedArea *panel = new TabbedArea(); panel->setDimension(gcn::Rectangle(5, 5, 250, 205)); - panel->setOpaque(false); SetupTab *tab; tab = new Setup_Video(); - panel->addTab(tab, _("Video")); + panel->addTab(_("Video"), tab); mTabs.push_back(tab); tab = new Setup_Audio(); - panel->addTab(tab, _("Audio")); + panel->addTab(_("Audio"), tab); mTabs.push_back(tab); tab = new Setup_Joystick(); - panel->addTab(tab, _("Joystick")); + panel->addTab(_("Joystick"), tab); mTabs.push_back(tab); tab = new Setup_Keyboard(); - panel->addTab(tab, "Keyboard"); + panel->addTab(_("Keyboard"), tab); mTabs.push_back(tab); add(panel); diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index a02b3c20..1ed4fc94 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -44,6 +44,7 @@ Setup_Audio::Setup_Audio(): mMusicSlider(new Slider(0, 128)) { setOpaque(false); + setDimension(gcn::Rectangle(0, 0, 250, 200)); gcn::Label *sfxLabel = new gcn::Label(_("Sfx volume")); gcn::Label *musicLabel = new gcn::Label(_("Music volume")); diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp index dfa446ab..57adef28 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -40,6 +40,8 @@ Setup_Joystick::Setup_Joystick(): mJoystickEnabled(new CheckBox(_("Enable joystick"))) { setOpaque(false); + setDimension(gcn::Rectangle(0, 0, 250, 200)); + mJoystickEnabled->setPosition(10, 10); mCalibrateLabel->setPosition(10, 25); mCalibrateButton->setPosition(10, 30 + mCalibrateLabel->getHeight()); diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index e88080b5..2b785dd5 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -75,6 +75,7 @@ Setup_Keyboard::Setup_Keyboard(): { keyboard.setSetupKeyboard(this); setOpaque(false); + setDimension(gcn::Rectangle(0, 0, 250, 200)); refreshKeys(); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index fcdb6c51..eb3c3df2 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -128,6 +128,7 @@ Setup_Video::Setup_Video(): mOverlayDetailField(new gcn::Label("")) { setOpaque(false); + setDimension(gcn::Rectangle(0, 0, 250, 200)); ScrollArea *scrollArea = new ScrollArea(mModeList); gcn::Label *alphaLabel = new gcn::Label(_("Gui opacity")); diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 58ec8043..0a3c244a 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -33,7 +33,8 @@ #include "scrollarea.h" #include "windowcontainer.h" #include "progressbar.h" -#include "tabbedcontainer.h" + +#include "widgets/tabbedarea.h" #include "../localplayer.h" @@ -47,23 +48,22 @@ SkillDialog::SkillDialog(): setCloseButton(true); setDefaultSize(windowContainer->getWidth() - 255, 25, 230, 425); - TabbedContainer *panel = new TabbedContainer(); + TabbedArea *panel = new TabbedArea(); panel->setDimension(gcn::Rectangle(5, 5, 225, 420)); - panel->setOpaque(false); Skill_Tab* tab; // Add each type of skill tab to the panel tab = new Skill_Tab("Weapon"); - panel->addTab(tab, _("Weapons")); + panel->addTab(_("Weapons"), tab); mTabs.push_back(tab); tab = new Skill_Tab("Magic"); - panel->addTab(tab, _("Magic")); + panel->addTab(_("Magic"), tab); mTabs.push_back(tab); tab = new Skill_Tab("Craft"); - panel->addTab(tab, _("Crafts")); + panel->addTab(_("Crafts"), tab); mTabs.push_back(tab); add(panel); @@ -105,6 +105,7 @@ void SkillDialog::update() Skill_Tab::Skill_Tab(std::string type): type(type) { setOpaque(false); + setDimension(gcn::Rectangle(0, 0, 225, 420)); int skillNum = getSkillNum(); mSkillNameLabels.resize(skillNum); diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp deleted file mode 100644 index d6267e65..00000000 --- a/src/gui/tabbedcontainer.cpp +++ /dev/null @@ -1,126 +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 - -#include "tabbedcontainer.h" - -#include "button.h" - -#include "../utils/tostring.h" -#include "../utils/dtor.h" - -#define TABWIDTH 60 -#define TABHEIGHT 20 - -TabbedContainer::TabbedContainer(): - mActiveContent(0) -{ -} - -TabbedContainer::~TabbedContainer() -{ - for_each(mTabs.begin(), mTabs.end(), make_dtor(mTabs)); - - mTabs.clear(); - mContents.clear(); -} - -void TabbedContainer::addTab(gcn::Widget *widget, const std::string &caption) -{ - int tabNumber = mTabs.size(); - - Button *tab = new Button(caption, toString(tabNumber), this); - - tab->setSize(TABWIDTH, TABHEIGHT); - add(tab, TABWIDTH * tabNumber, 0); - - mTabs[caption] = tab; - - mContents.push_back(widget); - widget->setPosition(0, TABHEIGHT); - - // If this is the first tab in this container, make it visible - if (!mActiveContent) { - mActiveContent = widget; - add(mActiveContent); - tab->setLogged(true); - } - - mWidgets[widget] = caption; -} - -void TabbedContainer::removeTab(const std::string &caption) -{ - gcn::ActionEvent actionEvent(this, "0"); - action(actionEvent); - remove(mTabs[caption]); - mTabs.erase(caption); -} - -void TabbedContainer::logic() -{ - if (mActiveContent) { - mActiveContent->setSize( - getWidth() - 2 * mActiveContent->getFrameSize(), - getHeight() - TABHEIGHT - 2 * mActiveContent->getFrameSize()); - } - - Container::logic(); -} - -void TabbedContainer::action(const gcn::ActionEvent &event) -{ - int tabNo; - std::stringstream ss(event.getId()); - ss >> tabNo; - - gcn::Widget *newContent = mContents[tabNo]; - - if (newContent) { - if (mActiveContent) { - // Unhighlight old tab - ((Button*)mTabs[mWidgets[mActiveContent]])->setLogged(false); - remove(mActiveContent); - } - mActiveContent = newContent; - // Highlight new tab - ((Button*)mTabs[mWidgets[mActiveContent]])->setLogged(true); - add(newContent); - } -} - -void TabbedContainer::setOpaque(bool opaque) -{ - Container::setOpaque(opaque); -} - -short TabbedContainer::getNumberOfTabs() -{ - return mTabs.size(); -} - -std::string TabbedContainer::getActiveWidget() -{ - return mWidgets[mActiveContent]; -} diff --git a/src/gui/tabbedcontainer.h b/src/gui/tabbedcontainer.h deleted file mode 100644 index 7f8deef9..00000000 --- a/src/gui/tabbedcontainer.h +++ /dev/null @@ -1,67 +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_TABPANE_H -#define _TMW_TABPANE_H - -#include -#include -#include - -#include - -#include - -#include "../guichanfwd.h" - -class TabbedContainer : public gcn::Container, public gcn::ActionListener -{ - public: - TabbedContainer(); - ~TabbedContainer(); - - void addTab(gcn::Widget *widget, const std::string &caption); - - void removeTab(const std::string &caption); - - void logic(); - - void action(const gcn::ActionEvent &event); - - void setOpaque(bool opaque); - - short getNumberOfTabs(); - - std::string getActiveWidget(); - - private: - typedef std::vector Widgets; - typedef Widgets::iterator WidgetIterator; - std::map mTabs; // tabs mapped to their channel name - Widgets mContents; // The contents of the tabs - - std::map mWidgets; - gcn::Widget *mActiveContent; -}; - -#endif diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index a36688e2..7821190b 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -57,7 +57,7 @@ void TabbedArea::draw(gcn::Graphics *graphics) return; } - gcn::TabbedArea::draw(graphics); + drawChildren(graphics); } gcn::Widget* TabbedArea::getWidget(const std::string &name) diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 0c5d18f7..bc623427 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -65,7 +65,6 @@ class TabbedArea : public gcn::TabbedArea * Overload the remove tab function as its broken in guichan 0.8 */ void removeTab(gcn::Tab *tab); - }; #endif diff --git a/tmw.cbp b/tmw.cbp index d1e88a99..efe05a0c 100644 --- a/tmw.cbp +++ b/tmw.cbp @@ -46,10 +46,12 @@