summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-01-14 14:54:39 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-01-14 14:54:39 +0000
commitf842e0b40d8382011f0bc46b1446945d99ac0425 (patch)
tree5ddbb7c146a8ece28a4260d788350b1c2cf0dbed /src/gui
parentcbbcc5489e2f72a76b66ae849cbe8f1dc44246ca (diff)
downloadmana-client-f842e0b40d8382011f0bc46b1446945d99ac0425.tar.gz
mana-client-f842e0b40d8382011f0bc46b1446945d99ac0425.tar.bz2
mana-client-f842e0b40d8382011f0bc46b1446945d99ac0425.tar.xz
mana-client-f842e0b40d8382011f0bc46b1446945d99ac0425.zip
Upgraded to Guichan 0.6.0 (merge from guichan-0.6.0 branch).
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/browserbox.cpp15
-rw-r--r--src/gui/browserbox.h10
-rw-r--r--src/gui/buddywindow.cpp8
-rw-r--r--src/gui/buddywindow.h2
-rw-r--r--src/gui/button.cpp9
-rw-r--r--src/gui/button.h2
-rw-r--r--src/gui/buy.cpp16
-rw-r--r--src/gui/buy.h2
-rw-r--r--src/gui/buysell.cpp8
-rw-r--r--src/gui/buysell.h2
-rw-r--r--src/gui/char_select.cpp40
-rw-r--r--src/gui/char_select.h4
-rw-r--r--src/gui/char_server.cpp8
-rw-r--r--src/gui/char_server.h2
-rw-r--r--src/gui/chat.cpp15
-rw-r--r--src/gui/chat.h11
-rw-r--r--src/gui/chatinput.cpp2
-rw-r--r--src/gui/chatinput.h2
-rw-r--r--src/gui/confirm_dialog.cpp7
-rw-r--r--src/gui/confirm_dialog.h2
-rw-r--r--src/gui/connection.cpp2
-rw-r--r--src/gui/debugwindow.cpp4
-rw-r--r--src/gui/debugwindow.h2
-rw-r--r--src/gui/gccontainer.cpp6
-rw-r--r--src/gui/gccontainer.h9
-rw-r--r--src/gui/help.cpp4
-rw-r--r--src/gui/help.h2
-rw-r--r--src/gui/inttextbox.cpp7
-rw-r--r--src/gui/inttextbox.h3
-rw-r--r--src/gui/inventorywindow.cpp20
-rw-r--r--src/gui/inventorywindow.h6
-rw-r--r--src/gui/item_amount.cpp20
-rw-r--r--src/gui/item_amount.h2
-rw-r--r--src/gui/itemcontainer.cpp35
-rw-r--r--src/gui/itemcontainer.h2
-rw-r--r--src/gui/listbox.cpp33
-rw-r--r--src/gui/listbox.h6
-rw-r--r--src/gui/login.cpp18
-rw-r--r--src/gui/login.h4
-rw-r--r--src/gui/menuwindow.cpp14
-rw-r--r--src/gui/newskill.cpp22
-rw-r--r--src/gui/newskill.h2
-rw-r--r--src/gui/npc_text.cpp4
-rw-r--r--src/gui/npc_text.h2
-rw-r--r--src/gui/npclistdialog.cpp8
-rw-r--r--src/gui/npclistdialog.h2
-rw-r--r--src/gui/ok_dialog.cpp6
-rw-r--r--src/gui/ok_dialog.h2
-rw-r--r--src/gui/register.cpp6
-rw-r--r--src/gui/register.h2
-rw-r--r--src/gui/sell.cpp18
-rw-r--r--src/gui/sell.h2
-rw-r--r--src/gui/setup.cpp8
-rw-r--r--src/gui/setup.h2
-rw-r--r--src/gui/setup_audio.cpp10
-rw-r--r--src/gui/setup_audio.h2
-rw-r--r--src/gui/setup_joystick.cpp5
-rw-r--r--src/gui/setup_joystick.h2
-rw-r--r--src/gui/setup_video.cpp49
-rw-r--r--src/gui/setup_video.h5
-rw-r--r--src/gui/shoplistbox.cpp6
-rw-r--r--src/gui/shoplistbox.h2
-rw-r--r--src/gui/skill.cpp10
-rw-r--r--src/gui/skill.h2
-rw-r--r--src/gui/status.cpp16
-rw-r--r--src/gui/status.h2
-rw-r--r--src/gui/tabbedcontainer.cpp4
-rw-r--r--src/gui/tabbedcontainer.h2
-rw-r--r--src/gui/trade.cpp10
-rw-r--r--src/gui/trade.h2
-rw-r--r--src/gui/updatewindow.cpp6
-rw-r--r--src/gui/updatewindow.h2
-rw-r--r--src/gui/viewport.cpp25
-rw-r--r--src/gui/viewport.h12
-rw-r--r--src/gui/window.cpp121
-rw-r--r--src/gui/window.h19
76 files changed, 363 insertions, 403 deletions
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 95b181ad..bd853cb4 100644
--- a/src/gui/browserbox.h
+++ b/src/gui/browserbox.h
@@ -60,7 +60,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.
@@ -80,7 +80,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.
@@ -90,13 +90,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 e4a96b67..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 c701499c..a8a1ea7e 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -85,8 +85,8 @@ BuyDialog::BuyDialog(Network *network):
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);
@@ -143,11 +143,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;
@@ -161,12 +161,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++;
@@ -177,7 +177,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--;
@@ -191,7 +191,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))
{
MessageOut outMsg(mNetwork);
diff --git a/src/gui/buy.h b/src/gui/buy.h
index 2af6cfe8..b2b88c40 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -74,7 +74,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 e2e0e686..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 604d7244..eb9ce31d 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(Network *network,
@@ -127,9 +127,9 @@ CharSelectDialog::CharSelectDialog(Network *network,
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);
@@ -140,11 +140,11 @@ void CharSelectDialog::action(const std::string& eventId, gcn::Widget* widget)
mCharSelected = true;
attemptCharSelect();
}
- else if (eventId == "cancel")
+ else if (event.getId() == "cancel")
{
state = EXIT_STATE;
}
- else if (eventId == "new")
+ else if (event.getId() == "new")
{
if (n_character < MAX_SLOT + 1)
{
@@ -154,7 +154,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())
@@ -162,11 +162,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();
}
@@ -274,7 +274,7 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network,
mCancelButton = new Button("Cancel", "cancel", this);
mPlayerBox = new PlayerBox(mPlayer);
- mNameField->setEventId("create");
+ mNameField->setActionEventId("create");
int w = 200;
int h = 150;
@@ -319,9 +319,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);
@@ -333,20 +333,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() % NR_HAIR_COLORS + 1);
}
- else if (eventId == "prevcolor") {
+ else if (event.getId() == "prevcolor") {
int prevColor = mPlayer->getHairColor() + NR_HAIR_COLORS - 2;
mPlayer->setHairColor(prevColor % NR_HAIR_COLORS + 1);
}
- else if (eventId == "nextstyle") {
+ else if (event.getId() == "nextstyle") {
mPlayer->setHairStyle(mPlayer->getHairStyle() % NR_HAIR_STYLES + 1);
}
- else if (eventId == "prevstyle") {
+ else if (event.getId() == "prevstyle") {
int prevStyle = mPlayer->getHairStyle() + NR_HAIR_STYLES - 2;
mPlayer->setHairStyle(prevStyle % NR_HAIR_STYLES + 1);
}
diff --git a/src/gui/char_select.h b/src/gui/char_select.h
index 9fc5fabf..d6b53044 100644
--- a/src/gui/char_select.h
+++ b/src/gui/char_select.h
@@ -52,7 +52,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener
LockedArray<LocalPlayer*> *charInfo,
unsigned char sex);
- void action(const std::string &eventId, gcn::Widget *widget);
+ void action(const gcn::ActionEvent &event);
void updatePlayerInfo();
@@ -116,7 +116,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/char_server.cpp b/src/gui/char_server.cpp
index 302caf62..cccdcff1 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -71,7 +71,7 @@ ServerSelectDialog::ServerSelectDialog(LoginData *loginData):
100 - 3 * 5 - mCancelButton->getHeight() -
mScrollArea->getBorderSize()));
- mServerList->setEventId("ok");
+ mServerList->setActionEventId("ok");
//mServerList->addActionListener(this);
@@ -98,16 +98,16 @@ ServerSelectDialog::~ServerSelectDialog()
}
void
-ServerSelectDialog::action(const std::string& eventId, gcn::Widget* widget)
+ServerSelectDialog::action(const gcn::ActionEvent &event)
{
- if (eventId == "ok") {
+ if (event.getId() == "ok") {
mOkButton->setEnabled(false);
const SERVER_INFO *si = server_info[mServerList->getSelected()];
mLoginData->hostname = iptostring(si->address);
mLoginData->port = si->port;
state = CHAR_CONNECT_STATE;
}
- else if (eventId == "cancel") {
+ else if (event.getId() == "cancel") {
state = LOGIN_STATE;
}
}
diff --git a/src/gui/char_server.h b/src/gui/char_server.h
index 3dd66566..26e723f9 100644
--- a/src/gui/char_server.h
+++ b/src/gui/char_server.h
@@ -56,7 +56,7 @@ class ServerSelectDialog : 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:
LoginData *mLoginData;
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index f188b90e..a6e5df83 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -53,7 +53,7 @@ ChatWindow::ChatWindow(Network *network):
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();
@@ -366,9 +366,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++;
@@ -380,8 +381,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 20841873..1269b98e 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -139,7 +139,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.
@@ -179,13 +179,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:
Network *mNetwork;
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 bacc319e..baa1ea34 100644
--- a/src/gui/connection.cpp
+++ b/src/gui/connection.cpp
@@ -35,7 +35,7 @@
namespace {
struct ConnectionActionListener : public gcn::ActionListener
{
- void action(const std::string& eventId, gcn::Widget* widget) { state = EXIT_STATE; }
+ void action(const gcn::ActionEvent &event) { state = EXIT_STATE; }
} listener;
}
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 24bd779c..563f380f 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -100,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<gcn::Widget*> Widgets;
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index 2b9b649a..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 75b63208..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 afc3ac44..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<int>(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 5bcd000d..055a07cb 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)
@@ -128,7 +130,8 @@ void ItemContainer::draw(gcn::Graphics* graphics)
}
}
-void ItemContainer::setWidth(int width)
+void
+ItemContainer::setWidth(int width)
{
gcn::Widget::setWidth(width);
@@ -145,17 +148,20 @@ void ItemContainer::setWidth(int width)
(mMaxItems % columns > 0 ? 1 : 0)) * 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)
{
@@ -164,7 +170,8 @@ void ItemContainer::setSelectedItem(Item *item)
}
}
-void ItemContainer::fireSelectionChangedEvent()
+void
+ItemContainer::fireSelectionChangedEvent()
{
SelectionEvent event(this);
SelectionListeners::iterator i_end = mListeners.end();
@@ -176,14 +183,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) + 2;
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 <guichan/mouseinput.hpp>
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<SelectionListener*> mListeners;
};
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 97814360..cda57103 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("");
@@ -91,9 +91,9 @@ LoginDialog::LoginDialog(LoginData *loginData):
mRegisterButton->setPosition(mKeepCheck->getX() + mKeepCheck->getWidth() + 10,
100 - mRegisterButton->getHeight() - 5);
- mUserField->setEventId("ok");
- mPassField->setEventId("ok");
- mServerField->setEventId("ok");
+ mUserField->setActionEventId("ok");
+ mPassField->setActionEventId("ok");
+ mServerField->setActionEventId("ok");
mUserField->addActionListener(this);
mPassField->addActionListener(this);
@@ -129,9 +129,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())
@@ -154,11 +154,11 @@ LoginDialog::action(const std::string& eventId, gcn::Widget* widget)
state = ACCOUNT_STATE;
}
}
- else if (eventId == "cancel")
+ else if (event.getId() == "cancel")
{
state = EXIT_STATE;
}
- else if (eventId == "register")
+ else if (event.getId() == "register")
{
state = REGISTER_STATE;
}
diff --git a/src/gui/login.h b/src/gui/login.h
index 7218dca8..79e74e13 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 701d9366..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 59cdd9db..c84c9449 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")
+ 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 6b647032..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 895ef1f9..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/register.cpp b/src/gui/register.cpp
index 458452eb..53826304 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -118,13 +118,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 = EXIT_STATE;
}
- 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 5d3f6cd5..6176aef7 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 24556567..c9ac84c3 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -91,8 +91,8 @@ SellDialog::SellDialog(Network *network):
quitButton->setPosition(208, 186);
- mShopItemList->setEventId("item");
- mSlider->setEventId("mSlider");
+ mShopItemList->setActionEventId("item");
+ mSlider->setActionEventId("mSlider");
mShopItemList->setPriceCheck(false);
@@ -158,11 +158,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);
@@ -186,7 +186,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;
@@ -199,13 +199,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++;
@@ -213,7 +213,7 @@ void SellDialog::action(const std::string& eventId, gcn::Widget* widget)
updateButtonsAndLabels = true;
}
- else if (eventId == "-")
+ else if (event.getId() == "-")
{
assert(mAmountItems > 0);
mAmountItems--;
@@ -222,7 +222,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 f27a9751..ab940f41 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -69,7 +69,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/setup.cpp b/src/gui/setup.cpp
index 7deb39ff..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<SetupTab*> mTabs;
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index ac5771ad..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 22d0520e..2bd7ee38 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -157,16 +157,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);
@@ -330,37 +330,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:
@@ -375,11 +375,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
{
@@ -392,7 +392,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 df6dc85e..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 e824f2f0..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 0f149403..6bd696ec 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -361,32 +361,32 @@ 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)
{
// Stats Part
- if (eventId.length() == 3)
+ if (event.getId().length() == 3)
{
- if (eventId == "STR")
+ if (event.getId() == "STR")
{
player_node->raiseAttribute(LocalPlayer::STR);
}
- if (eventId == "AGI")
+ if (event.getId() == "AGI")
{
player_node->raiseAttribute(LocalPlayer::AGI);
}
- if (eventId == "VIT")
+ if (event.getId() == "VIT")
{
player_node->raiseAttribute(LocalPlayer::VIT);
}
- if (eventId == "INT")
+ if (event.getId() == "INT")
{
player_node->raiseAttribute(LocalPlayer::INT);
}
- if (eventId == "DEX")
+ if (event.getId() == "DEX")
{
player_node->raiseAttribute(LocalPlayer::DEX);
}
- if (eventId == "LUK")
+ if (event.getId() == "LUK")
{
player_node->raiseAttribute(LocalPlayer::LUK);
}
diff --git a/src/gui/status.h b/src/gui/status.h
index 6b963d24..de530bc9 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 c1d86d70..06daf3ef 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -258,11 +258,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)
{
@@ -288,12 +288,12 @@ 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")
{
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_TRADE_CANCEL_REQUEST);
}
- else if (eventId == "ok")
+ else if (event.getId() == "ok")
{
std::stringstream tempMoney(mMoneyField->getText());
int tempInt;
@@ -312,7 +312,7 @@ void TradeWindow::action(const std::string& eventId, gcn::Widget* widget)
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_TRADE_ADD_COMPLETE);
}
- else if (eventId == "trade")
+ else if (event.getId() == "trade")
{
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_TRADE_OK);
diff --git a/src/gui/trade.h b/src/gui/trade.h
index 339fc4e3..cf792c19 100644
--- a/src/gui/trade.h
+++ b/src/gui/trade.h
@@ -112,7 +112,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:
Network *mNetwork;
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 3bdd5526..86d0a57c 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 = LOGIN_STATE;
}
diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h
index d2d1d68f..bbecf176 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);
/**
* Add a row to the message field.
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 08ca5141..03e008ba 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -246,7 +246,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)
@@ -258,11 +258,11 @@ Viewport::mousePress(int mx, int my, int button)
mPlayerFollowMouse = false;
- int tilex = mx / 32 + mCameraX;
- int tiley = my / 32 + mCameraY;
+ int tilex = event.getX() / 32 + mCameraX;
+ int tiley = event.getY() / 32 + mCameraY;
// Right click might open a popup
- if (button == gcn::MouseInput::RIGHT)
+ if (event.getButton() == gcn::MouseEvent::RIGHT)
{
Being *being;
FloorItem *floorItem;
@@ -270,12 +270,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;
}
}
@@ -289,7 +289,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)
{
Being *being;
FloorItem *item;
@@ -333,8 +333,7 @@ Viewport::mousePress(int mx, int my, int button)
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(
@@ -349,19 +348,21 @@ 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 / 32 + mCameraX, my / 32 + mCameraY);
+ int destX = event.getX() / 32 + mCameraX;
+ int destY = event.getY() / 32 + mCameraY;
+ player_node->setDestination(destX, destY);
}
}
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 5181e06e..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.
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 648b3763..4f26af79 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;
@@ -280,86 +280,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
@@ -381,18 +355,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);
@@ -401,16 +366,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.