summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/buddywindow.cpp13
-rw-r--r--src/gui/button.cpp7
-rw-r--r--src/gui/button.h3
-rw-r--r--src/gui/buy.cpp17
-rw-r--r--src/gui/buysell.cpp4
-rw-r--r--src/gui/char_select.cpp52
-rw-r--r--src/gui/char_server.cpp8
-rw-r--r--src/gui/confirm_dialog.cpp9
-rw-r--r--src/gui/connection.cpp6
-rw-r--r--src/gui/debugwindow.cpp4
-rw-r--r--src/gui/help.cpp5
-rw-r--r--src/gui/inventorywindow.cpp9
-rw-r--r--src/gui/item_amount.cpp16
-rw-r--r--src/gui/login.cpp12
-rw-r--r--src/gui/menuwindow.cpp4
-rw-r--r--src/gui/newskill.cpp44
-rw-r--r--src/gui/npc_text.cpp5
-rw-r--r--src/gui/npclistdialog.cpp8
-rw-r--r--src/gui/ok_dialog.cpp5
-rw-r--r--src/gui/register.cpp9
-rw-r--r--src/gui/sell.cpp16
-rw-r--r--src/gui/setup.cpp16
-rw-r--r--src/gui/skill.cpp12
-rw-r--r--src/gui/status.cpp18
-rw-r--r--src/gui/tabbedcontainer.cpp8
-rw-r--r--src/gui/trade.cpp18
-rw-r--r--src/gui/updatewindow.cpp8
27 files changed, 90 insertions, 246 deletions
diff --git a/src/gui/buddywindow.cpp b/src/gui/buddywindow.cpp
index cfa21b63..19a2f1e0 100644
--- a/src/gui/buddywindow.cpp
+++ b/src/gui/buddywindow.cpp
@@ -48,17 +48,12 @@ BuddyWindow::BuddyWindow():
7, 5, 110, 170));
add(scrollArea);
- Button *talk = new Button("Talk");
+ Button *talk = new Button("Talk", "Talk", this);
+ Button *remove = new Button("Remove", "Remove", this);
+ Button *cancel = new Button("Cancel", "Cancel", this);
+
talk->setPosition(2,180);
- talk->addActionListener(this);
- talk->setEventId("Talk");
- Button *remove = new Button("Remove");
- remove->addActionListener(this);
- remove->setEventId("Remove");
remove->setPosition(talk->getWidth()+2,180);
- Button *cancel = new Button("Cancel");
- cancel->addActionListener(this);
- cancel->setEventId("Cancel");
cancel->setPosition(talk->getWidth()+remove->getWidth()+2,180);
add(talk);
diff --git a/src/gui/button.cpp b/src/gui/button.cpp
index 8e57181e..9d01095b 100644
--- a/src/gui/button.cpp
+++ b/src/gui/button.cpp
@@ -39,7 +39,8 @@
ImageRect Button::button[4];
int Button::mInstances = 0;
-Button::Button(const std::string& caption):
+Button::Button(const std::string& caption, const std::string &eventId,
+ gcn::ActionListener *listener):
gcn::Button(caption)
{
setBorderSize(0);
@@ -74,6 +75,10 @@ Button::Button(const std::string& caption):
}
mInstances++;
+ setEventId(eventId);
+ if (listener) {
+ addActionListener(listener);
+ }
}
Button::~Button()
diff --git a/src/gui/button.h b/src/gui/button.h
index 86467769..36d8f7a1 100644
--- a/src/gui/button.h
+++ b/src/gui/button.h
@@ -40,7 +40,8 @@ class Button : public gcn::Button {
/**
* Constructor, sets the caption of the button to the given string.
*/
- Button(const std::string& caption);
+ Button(const std::string& caption, const std::string &eventId,
+ gcn::ActionListener *listener);
/**
* Destructor.
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 71f502f2..42c6ff2f 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -53,10 +53,10 @@ BuyDialog::BuyDialog(Network *network):
slider = new Slider(1.0);
quantityLabel = new gcn::Label("0");
moneyLabel = new gcn::Label("Price: 0 GP");
- increaseButton = new Button("+");
- decreaseButton = new Button("-");
- buyButton = new Button("Buy");
- quitButton = new Button("Quit");
+ increaseButton = new Button("+", "+", this);
+ decreaseButton = new Button("-", "-", this);
+ buyButton = new Button("Buy", "buy", this);
+ quitButton = new Button("Quit", "quit", this);
itemDescLabel = new gcn::Label("Description:");
itemEffectLabel = new gcn::Label("Effect:");
@@ -89,18 +89,9 @@ BuyDialog::BuyDialog(Network *network):
itemList->setEventId("item");
slider->setEventId("slider");
- increaseButton->setEventId("+");
- decreaseButton->setEventId("-");
- buyButton->setEventId("buy");
- quitButton->setEventId("quit");
itemList->addActionListener(this);
slider->addActionListener(this);
- increaseButton->addActionListener(this);
- decreaseButton->addActionListener(this);
- buyButton->addActionListener(this);
- quitButton->addActionListener(this);
-
add(scrollArea);
add(slider);
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
index d4c33d30..6e338f08 100644
--- a/src/gui/buysell.cpp
+++ b/src/gui/buysell.cpp
@@ -38,10 +38,8 @@ BuySellDialog::BuySellDialog():
for (const char **curBtn = buttonNames; *curBtn; curBtn++)
{
- Button *btn = new Button(*curBtn);
+ Button *btn = new Button(*curBtn, *curBtn, this);
if (!buyButton) buyButton = btn; // For focus request
- btn->setEventId(*curBtn);
- btn->addActionListener(this);
btn->setPosition(x, y);
add(btn);
x += btn->getWidth() + 10;
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 7ce2a77d..72f0b554 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -71,25 +71,19 @@ void CharDeleteConfirm::action(const std::string &eventId)
CharSelectDialog::CharSelectDialog(Network *network, LockedArray<LocalPlayer*> *charInfo):
Window("Select Character"), mNetwork(network), mCharInfo(charInfo), mCharSelected(false)
{
- selectButton = new Button("Ok");
- cancelButton = new Button("Cancel");
- newCharButton = new Button("New");
- delCharButton = new Button("Delete");
- previousButton = new Button("Previous");
- nextButton = new Button("Next");
+ selectButton = new Button("Ok", "ok", this);
+ cancelButton = new Button("Cancel", "cancel", this);
+ newCharButton = new Button("New", "new", this);
+ delCharButton = new Button("Delete", "delete", this);
+ previousButton = new Button("Previous", "previous", this);
+ nextButton = new Button("Next", "next", this);
+
nameLabel = new gcn::Label("Name");
levelLabel = new gcn::Label("Level");
jobLevelLabel = new gcn::Label("Job Level");
moneyLabel = new gcn::Label("Money");
playerBox = new PlayerBox();
- selectButton->setEventId("ok");
- newCharButton->setEventId("new");
- cancelButton->setEventId("cancel");
- delCharButton->setEventId("delete");
- previousButton->setEventId("previous");
- nextButton->setEventId("next");
-
int w = 195;
int h = 220;
setContentSize(w, h);
@@ -123,14 +117,6 @@ CharSelectDialog::CharSelectDialog(Network *network, LockedArray<LocalPlayer*> *
add(jobLevelLabel);
add(moneyLabel);
- // Set up event listener
- selectButton->addActionListener(this);
- cancelButton->addActionListener(this);
- newCharButton->addActionListener(this);
- delCharButton->addActionListener(this);
- previousButton->addActionListener(this);
- nextButton->addActionListener(this);
-
selectButton->requestFocus();
setLocationRelativeTo(getParent());
updatePlayerInfo();
@@ -250,24 +236,18 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network):
{
nameField = new TextField("");
nameLabel = new gcn::Label("Name:");
- nextHairColorButton = new Button(">");
- prevHairColorButton = new Button("<");
+ nextHairColorButton = new Button(">", "nextcolor", this);
+ prevHairColorButton = new Button("<", "prevcolor", this);
hairColorLabel = new gcn::Label("Hair Color:");
- nextHairStyleButton = new Button(">");
- prevHairStyleButton = new Button("<");
+ nextHairStyleButton = new Button(">", "nextstyle", this);
+ prevHairStyleButton = new Button("<", "prevstyle", this);
hairStyleLabel = new gcn::Label("Hair Style:");
- createButton = new Button("Create");
- cancelButton = new Button("Cancel");
+ createButton = new Button("Create", "create", this);
+ cancelButton = new Button("Cancel", "cancel", this);
playerBox = new PlayerBox();
playerBox->showPlayer = true;
nameField->setEventId("create");
- nextHairColorButton->setEventId("nextcolor");
- prevHairColorButton->setEventId("prevcolor");
- nextHairStyleButton->setEventId("nextstyle");
- prevHairStyleButton->setEventId("prevstyle");
- createButton->setEventId("create");
- cancelButton->setEventId("cancel");
int w = 200;
int h = 150;
@@ -290,12 +270,6 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network):
h - 5 - cancelButton->getHeight());
nameField->addActionListener(this);
- nextHairColorButton->addActionListener(this);
- prevHairColorButton->addActionListener(this);
- nextHairStyleButton->addActionListener(this);
- prevHairStyleButton->addActionListener(this);
- createButton->addActionListener(this);
- cancelButton->addActionListener(this);
add(playerBox);
add(nameField);
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 876bcd0e..37ef0462 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -54,8 +54,8 @@ ServerSelectDialog::ServerSelectDialog(LoginData *loginData):
serverListModel = new ServerListModel();
serverList = new ListBox(serverListModel);
scrollArea = new ScrollArea(serverList);
- okButton = new Button("OK");
- cancelButton = new Button("Cancel");
+ okButton = new Button("OK", "ok", this);
+ cancelButton = new Button("Cancel", "cancel", this);
setContentSize(200, 100);
@@ -72,12 +72,8 @@ ServerSelectDialog::ServerSelectDialog(LoginData *loginData):
scrollArea->getBorderSize()));
serverList->setEventId("ok");
- okButton->setEventId("ok");
- cancelButton->setEventId("cancel");
//serverList->addActionListener(this);
- okButton->addActionListener(this);
- cancelButton->addActionListener(this);
add(scrollArea);
add(okButton);
diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp
index becb8859..2d574157 100644
--- a/src/gui/confirm_dialog.cpp
+++ b/src/gui/confirm_dialog.cpp
@@ -33,8 +33,8 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
Window(title, true, parent)
{
gcn::Label *textLabel = new gcn::Label(msg);
- gcn::Button *yesButton = new Button("Yes");
- gcn::Button *noButton = new Button("No");
+ 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;
@@ -53,11 +53,6 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
yesButton->getX() + yesButton->getWidth() + 5,
h - 5 - noButton->getHeight());
- yesButton->setEventId("yes");
- noButton->setEventId("no");
- yesButton->addActionListener(this);
- noButton->addActionListener(this);
-
add(textLabel);
add(yesButton);
add(noButton);
diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp
index 372537a8..36fa316d 100644
--- a/src/gui/connection.cpp
+++ b/src/gui/connection.cpp
@@ -49,11 +49,9 @@ ConnectionDialog::ConnectionDialog():
{
setContentSize(200, 100);
- Button *cancelButton;
- cancelButton = new Button("Cancel");
+ Button *cancelButton = new Button("Cancel", "cancelButton",
+ &connectionActionListener);
cancelButton->setPosition(5, 100 - 5 - cancelButton->getHeight());
- cancelButton->setEventId("cancel");
- cancelButton->addActionListener(&connectionActionListener);
mProgressBar = new ProgressBar(0.0, 5, cancelButton->getY() - 25,
200 - 10, 20, 128, 128, 128);
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index b629ddab..a327eec3 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -54,10 +54,8 @@ DebugWindow::DebugWindow():
tileMouseLabel = new gcn::Label("[Mouse: 0, 0]");
tileMouseLabel->setPosition(100, 0);
- Button *closeButton = new Button("Close");
- closeButton->setEventId("close");
+ Button *closeButton = new Button("Close", "close", this);
closeButton->setPosition(5, 60);
- closeButton->addActionListener(this);
add(FPSLabel);
add(musicFileLabel);
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index eb30556a..7b56d662 100644
--- a/src/gui/help.cpp
+++ b/src/gui/help.cpp
@@ -41,7 +41,7 @@ HelpWindow::HelpWindow():
browserBox = new BrowserBox();
browserBox->setOpaque(false);
scrollArea = new ScrollArea(browserBox);
- Button *okButton = new Button("Close");
+ Button *okButton = new Button("Close", "close", this);
scrollArea->setDimension(gcn::Rectangle(
5, 5, 445, 335 - okButton->getHeight()));
@@ -49,9 +49,6 @@ HelpWindow::HelpWindow():
450 - okButton->getWidth(),
345 - okButton->getHeight());
- okButton->setEventId("close");
- okButton->addActionListener(this);
-
browserBox->setLinkHandler(this);
add(scrollArea);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 5227152c..0c8fb14e 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -50,19 +50,14 @@ InventoryWindow::InventoryWindow():
setMinHeight(172);
setDefaultSize(115, 25, 322, 172);
- useButton = new Button("Use");
- dropButton = new Button("Drop");
+ useButton = new Button("Use", "use", this);
+ dropButton = new Button("Drop", "drop", this);
items = new ItemContainer(player_node->mInventory.get());
invenScroll = new ScrollArea(items);
invenScroll->setPosition(8, 8);
invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- useButton->setEventId("use");
- dropButton->setEventId("drop");
- useButton->addActionListener(this);
- dropButton->addActionListener(this);
-
itemNameLabel = new gcn::Label("Name:");
itemDescriptionLabel = new gcn::Label("Description:");
itemEffectLabel = new gcn::Label("Effect:");
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp
index 2ac46283..8c66144b 100644
--- a/src/gui/item_amount.cpp
+++ b/src/gui/item_amount.cpp
@@ -39,21 +39,17 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item):
mItemAmountTextBox = new IntTextBox(1);
// New buttons
- Button *minusButton = new Button("-");
- Button *plusButton = new Button("+");
+ 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);
mItemAmountSlide = new Slider(1.0);
- Button *okButton = new Button("Okay");
- Button *cancelButton = new Button("Cancel");
mItemAmountTextBox->setRange(1, mItem->getQuantity());
mItemAmountSlide->setDimension(gcn::Rectangle(5, 120, 180, 10));
// Set button events Id
- minusButton->setEventId("Minus");
- plusButton->setEventId("Plus");
mItemAmountSlide->setEventId("Slide");
- okButton->setEventId("Drop");
- cancelButton->setEventId("Cancel");
// Set position
mItemAmountTextBox->setPosition(35, 10);
@@ -72,11 +68,7 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item):
add(okButton);
add(cancelButton);
- plusButton->addActionListener(this);
- minusButton->addActionListener(this);
mItemAmountSlide->addActionListener(this);
- okButton->addActionListener(this);
- cancelButton->addActionListener(this);
resetAmount();
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index a66273da..691b6406 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -64,9 +64,9 @@ LoginDialog::LoginDialog(LoginData *loginData):
passField = new PasswordField(mLoginData->password);
serverField = new TextField(mLoginData->hostname);
keepCheck = new CheckBox("Keep", false);
- okButton = new Button("OK");
- cancelButton = new Button("Cancel");
- registerButton = new Button("Register");
+ okButton = new Button("OK", "ok", this);
+ cancelButton = new Button("Cancel", "cancel", this);
+ registerButton = new Button("Register", "register", this);
setContentSize(200, 100);
@@ -95,17 +95,11 @@ LoginDialog::LoginDialog(LoginData *loginData):
userField->setEventId("ok");
passField->setEventId("ok");
serverField->setEventId("ok");
- okButton->setEventId("ok");
- cancelButton->setEventId("cancel");
- registerButton->setEventId("register");
userField->addActionListener(this);
passField->addActionListener(this);
serverField->addActionListener(this);
keepCheck->addActionListener(this);
- okButton->addActionListener(this);
- cancelButton->addActionListener(this);
- registerButton->addActionListener(this);
add(userLabel);
add(passLabel);
diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp
index 811a10ab..c18132cf 100644
--- a/src/gui/menuwindow.cpp
+++ b/src/gui/menuwindow.cpp
@@ -59,9 +59,7 @@ MenuWindow::MenuWindow():
int x = 0, y = 3, h = 0;
for (const char **curBtn = buttonNames; *curBtn; curBtn++) {
- gcn::Button *btn = new Button(*curBtn);
- btn->setEventId(*curBtn);
- btn->addActionListener(&menuWindowListener);
+ gcn::Button *btn = new Button(*curBtn, *curBtn, &menuWindowListener);
btn->setPosition(x, y);
add(btn);
x += btn->getWidth() + 3;
diff --git a/src/gui/newskill.cpp b/src/gui/newskill.cpp
index 0baf81a5..c04ad6a0 100644
--- a/src/gui/newskill.cpp
+++ b/src/gui/newskill.cpp
@@ -92,31 +92,19 @@ NewSkillDialog::NewSkillDialog():
resetNSD();
// create controls
- catButton[0] = new Button("Weapons");
- catButton[1] = new Button("Magic");
- catButton[2] = new Button("Craft");
- catButton[3] = new Button("General");
- catButton[4] = new Button("Combat");
- catButton[5] = new Button("E. Resist");
- catButton[6] = new Button("S. Resist");
- catButton[7] = new Button("Hunting");
- catButton[8] = new Button("Stat");
- closeButton = new Button("Close");
+ catButton[0] = new Button("Weapons", "g1", this);
+ catButton[1] = new Button("Magic", "g2", this);
+ catButton[2] = new Button("Craft", "g3", this);
+ catButton[3] = new Button("General", "g4", this);
+ catButton[4] = new Button("Combat", "g5", this);
+ catButton[5] = new Button("E. Resist", "g6", this);
+ catButton[6] = new Button("S. Resist", "g7", this);
+ catButton[7] = new Button("Hunting", "g8", this);
+ catButton[8] = new Button("Stat", "g9", this);
+ closeButton = new Button("Close", "close", this);
// captions
- // events
- catButton[0]->setEventId("g1");
- catButton[1]->setEventId("g2");
- catButton[2]->setEventId("g3");
- catButton[3]->setEventId("g4");
- catButton[4]->setEventId("g5");
- catButton[5]->setEventId("g6");
- catButton[6]->setEventId("g7");
- catButton[7]->setEventId("g8");
- catButton[8]->setEventId("g9");
- closeButton->setEventId("close");
-
// positioning
setContentSize(350, 250);
catButton[0]->setDimension(gcn::Rectangle(0,0,60,20));
@@ -152,18 +140,6 @@ NewSkillDialog::NewSkillDialog():
add(catButton[8]);
add(closeButton);
- // add event detection
- catButton[0]->addActionListener(this);
- catButton[1]->addActionListener(this);
- catButton[2]->addActionListener(this);
- catButton[3]->addActionListener(this);
- catButton[4]->addActionListener(this);
- catButton[5]->addActionListener(this);
- catButton[6]->addActionListener(this);
- catButton[7]->addActionListener(this);
- catButton[8]->addActionListener(this);
- closeButton->addActionListener(this);
-
// finsihing touches
setLocationRelativeTo(getParent());
}
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 27232f3b..1a6bb5ce 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -37,7 +37,7 @@ NpcTextDialog::NpcTextDialog():
mTextBox = new TextBox();
mTextBox->setEditable(false);
gcn::ScrollArea *scrollArea = new ScrollArea(mTextBox);
- Button *okButton = new Button("OK");
+ Button *okButton = new Button("OK", "ok", this);
setContentSize(260, 175);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -48,9 +48,6 @@ NpcTextDialog::NpcTextDialog():
260 - 5 - okButton->getWidth(),
175 - 5 - okButton->getHeight());
- okButton->setEventId("ok");
- okButton->addActionListener(this);
-
add(scrollArea);
add(okButton);
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
index 9b5239f5..34597627 100644
--- a/src/gui/npclistdialog.cpp
+++ b/src/gui/npclistdialog.cpp
@@ -36,8 +36,8 @@ NpcListDialog::NpcListDialog():
{
mItemList = new ListBox(this);
ScrollArea *scrollArea = new ScrollArea(mItemList);
- Button *okButton = new Button("OK");
- Button *cancelButton = new Button("Cancel");
+ Button *okButton = new Button("OK", "ok", this);
+ Button *cancelButton = new Button("Cancel", "cancel", this);
setContentSize(260, 175);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -51,12 +51,8 @@ NpcListDialog::NpcListDialog():
cancelButton->getY());
mItemList->setEventId("item");
- okButton->setEventId("ok");
- cancelButton->setEventId("cancel");
mItemList->addActionListener(this);
- okButton->addActionListener(this);
- cancelButton->addActionListener(this);
add(scrollArea);
add(okButton);
diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp
index 8d2ebc23..2f3f21c5 100644
--- a/src/gui/ok_dialog.cpp
+++ b/src/gui/ok_dialog.cpp
@@ -33,7 +33,7 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg,
Window(title, true, parent)
{
gcn::Label *textLabel = new gcn::Label(msg);
- gcn::Button *okButton = new Button("Ok");
+ gcn::Button *okButton = new Button("Ok", "ok", this);
int w = textLabel->getWidth() + 20;
int h = textLabel->getHeight() + 25 + okButton->getHeight();
@@ -47,9 +47,6 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg,
okButton->setPosition((w - okButton->getWidth()) / 2,
h - 5 - okButton->getHeight());
- okButton->setEventId("ok");
- okButton->addActionListener(this);
-
add(textLabel);
add(okButton);
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index a22d1f73..b86375d4 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -56,8 +56,8 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
maleButton->setEnabled(false);
femaleButton = new RadioButton("Female", "sex", false);
femaleButton->setEnabled(false);
- registerButton = new Button("Register");
- cancelButton = new Button("Cancel");
+ registerButton = new Button("Register", "register", this);
+ cancelButton = new Button("Cancel", "cancel", this);
int width = 200;
int height = 150;
@@ -94,16 +94,11 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
passwordField->setEventId("register");
confirmField->setEventId("register");
serverField->setEventId("register");*/
- registerButton->setEventId("register");
- cancelButton->setEventId("cancel");
-
/*userField->addActionListener(this);
passwordField->addActionListener(this);
confirmField->addActionListener(this);
serverField->addActionListener(this);*/
- registerButton->addActionListener(this);
- cancelButton->addActionListener(this);
add(userLabel);
add(passwordLabel);
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 89aec044..0ab20660 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -58,10 +58,10 @@ SellDialog::SellDialog(Network *network):
moneyLabel = new gcn::Label("Price: 0");
itemDescLabel = new gcn::Label("Description:");
itemEffectLabel = new gcn::Label("Effect:");
- increaseButton = new Button("+");
- decreaseButton = new Button("-");
- sellButton = new Button("Sell");
- quitButton = new Button("Quit");
+ increaseButton = new Button("+", "+", this);
+ decreaseButton = new Button("-", "-", this);
+ sellButton = new Button("Sell", "sell", this);
+ quitButton = new Button("Quit", "quit", this);
sellButton->setEnabled(false);
setContentSize(260, 210);
@@ -93,17 +93,9 @@ SellDialog::SellDialog(Network *network):
itemList->setEventId("item");
slider->setEventId("slider");
- increaseButton->setEventId("+");
- decreaseButton->setEventId("-");
- sellButton->setEventId("sell");
- quitButton->setEventId("quit");
itemList->addActionListener(this);
slider->addActionListener(this);
- increaseButton->addActionListener(this);
- decreaseButton->addActionListener(this);
- sellButton->addActionListener(this);
- quitButton->addActionListener(this);
add(scrollArea);
add(slider);
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index c73d1de0..dade13eb 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -119,20 +119,16 @@ Setup::Setup():
sfxLabel = new gcn::Label("Sfx volume");
musicLabel = new gcn::Label("Music volume");
calibrateLabel = new gcn::Label("Press the button to start calibration");
- calibrateButton = new Button("Calibrate");
- applyButton = new Button("Apply");
- cancelButton = new Button("Cancel");
- resetWinsToDefault = new Button("Reset Windows");
+ calibrateButton = new Button("Calibrate", "calibrate", this);
+ applyButton = new Button("Apply", "apply", this);
+ cancelButton = new Button("Cancel", "cancel", this);
+ resetWinsToDefault = new Button("Reset Windows", "winsToDefault", this);
// Set events
- applyButton->setEventId("apply");
- cancelButton->setEventId("cancel");
- resetWinsToDefault->setEventId("winsToDefault");
alphaSlider->setEventId("guialpha");
sfxSlider->setEventId("sfx");
musicSlider->setEventId("music");
customCursorCheckBox->setEventId("customcursor");
- calibrateButton->setEventId("calibrate");
// Set dimensions/positions
int width = 230;
@@ -167,14 +163,10 @@ Setup::Setup():
applyButton->getY());
// Listen for actions
- applyButton->addActionListener(this);
- cancelButton->addActionListener(this);
- resetWinsToDefault->addActionListener(this);
alphaSlider->addActionListener(this);
sfxSlider->addActionListener(this);
musicSlider->addActionListener(this);
customCursorCheckBox->addActionListener(this);
- calibrateButton->addActionListener(this);
// Assemble dialog
gcn::Container *video = new gcn::Container();
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index f86d2356..44cbd314 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -71,15 +71,12 @@ SkillDialog::SkillDialog():
skillListBox = new ListBox(this);
skillScrollArea = new ScrollArea(skillListBox);
pointsLabel = new gcn::Label("Skill Points:");
- incButton = new Button("Up");
- useButton = new Button("Use");
+ incButton = new Button("Up", "inc", this);
+ useButton = new Button("Use", "use", this);
useButton->setEnabled(false);
- closeButton = new Button("Close");
+ closeButton = new Button("Close", "close", this);
skillListBox->setEventId("skill");
- incButton->setEventId("inc");
- useButton->setEventId("use");
- closeButton->setEventId("close");
skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
skillScrollArea->setDimension(gcn::Rectangle(5, 5, 230, 180));
@@ -98,9 +95,6 @@ SkillDialog::SkillDialog():
add(closeButton);
skillListBox->addActionListener(this);
- incButton->addActionListener(this);
- useButton->addActionListener(this);
- closeButton->addActionListener(this);
setLocationRelativeTo(getParent());
loadWindowState();
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index c6416409..1a300fd1 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -135,18 +135,13 @@ StatusWindow::StatusWindow(LocalPlayer *player):
}
remainingStatsPointsLabel = new gcn::Label();
- // New buttons
- for (int i = 0; i < 6; i++) {
- statsButton[i] = new Button("+");
- }
-
// Set button events Id
- statsButton[0]->setEventId("STR");
- statsButton[1]->setEventId("AGI");
- statsButton[2]->setEventId("VIT");
- statsButton[3]->setEventId("INT");
- statsButton[4]->setEventId("DEX");
- statsButton[5]->setEventId("LUK");
+ statsButton[0] = new Button("+", "STR", this);
+ statsButton[1] = new Button("+", "AGI", this);
+ statsButton[2] = new Button("+", "VIT", this);
+ statsButton[3] = new Button("+", "INT", this);
+ statsButton[4] = new Button("+", "DEX", this);
+ statsButton[5] = new Button("+", "LUK", this);
// Set position
@@ -192,7 +187,6 @@ StatusWindow::StatusWindow(LocalPlayer *player):
add(statsDisplayLabel[i]);
add(statsButton[i]);
add(pointsLabel[i]);
- statsButton[i]->addActionListener(this);
}
add(statsAttackLabel);
add(statsDefenseLabel);
diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp
index 3d08b390..f19524e1 100644
--- a/src/gui/tabbedcontainer.cpp
+++ b/src/gui/tabbedcontainer.cpp
@@ -49,15 +49,13 @@ TabbedContainer::~TabbedContainer()
void TabbedContainer::addTab(gcn::Widget *widget, const std::string &caption)
{
std::stringstream ss;
-
- Button *tab = new Button(caption);
-
int tabNumber = mTabs.size();
ss << tabNumber;
- tab->setEventId(ss.str());
+
+ Button *tab = new Button(caption, ss.str(), this);
+
tab->setSize(TABWIDTH, TABHEIGHT);
- tab->addActionListener(this);
add(tab, TABWIDTH * tabNumber, 0);
mTabs.push_back(tab);
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 9d10774b..370b5410 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -51,10 +51,10 @@ TradeWindow::TradeWindow(Network *network):
{
setContentSize(322, 150);
- addButton = new Button("Add");
- okButton = new Button("Ok");
- cancelButton = new Button("Cancel");
- tradeButton = new Button("Trade");
+ addButton = new Button("Add", "add", this);
+ okButton = new Button("Ok", "ok", this);
+ cancelButton = new Button("Cancel", "cancel", this);
+ tradeButton = new Button("Trade", "trade", this);
myItemContainer = new ItemContainer(myInventory.get());
myItemContainer->setPosition(2, 2);
@@ -72,21 +72,11 @@ TradeWindow::TradeWindow(Network *network):
moneyLabel2 = new gcn::Label("You give:");
moneyField = new TextField();
- addButton->setEventId("add");
- okButton->setEventId("ok");
- cancelButton->setEventId("cancel");
- tradeButton->setEventId("trade");
-
addButton->adjustSize();
okButton->adjustSize();
cancelButton->adjustSize();
tradeButton->adjustSize();
- addButton->addActionListener(this);
- okButton->addActionListener(this);
- cancelButton->addActionListener(this);
- tradeButton->addActionListener(this);
-
tradeButton->setEnabled(false);
itemNameLabel = new gcn::Label("Name:");
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 59382a4e..51be2f2d 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -57,17 +57,13 @@ UpdaterWindow::UpdaterWindow():
mBrowserBox = new BrowserBox();
mBrowserBox->setOpaque(false);
- mCancelButton = new Button("Cancel");
+ mCancelButton = new Button("Cancel", "cancel", this);
mCancelButton->setPosition(5, h - 5 - mCancelButton->getHeight());
- mCancelButton->setEventId("cancel");
- mCancelButton->addActionListener(this);
- mPlayButton = new Button("Play");
+ mPlayButton = new Button("Play", "play", this);
mPlayButton->setPosition(mCancelButton->getX() +
mCancelButton->getWidth() + 5,
h - 5 - mPlayButton->getHeight());
- mPlayButton->setEventId("play");
mPlayButton->setEnabled(false);
- mPlayButton->addActionListener(this);
mProgressBar = new ProgressBar(0.0, 5, mCancelButton->getY() - 20 - 5,
w - 10, 20, 37, 70, 200);
mLabel = new gcn::Label("Connecting...");