diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-01 10:32:43 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-02-01 10:32:43 +0000 |
commit | 6bff53b318937999a70d775bb6ecea2b18576e0f (patch) | |
tree | 66092571b605344a34c7360bccda50e86bc90b30 /src/gui/menuwindow.cpp | |
parent | 0e6385c12f325fa77ad57eba9b578de10d505ff7 (diff) | |
download | mana-6bff53b318937999a70d775bb6ecea2b18576e0f.tar.gz mana-6bff53b318937999a70d775bb6ecea2b18576e0f.tar.bz2 mana-6bff53b318937999a70d775bb6ecea2b18576e0f.tar.xz mana-6bff53b318937999a70d775bb6ecea2b18576e0f.zip |
Simplified button creation code in some windows. Fixed a bug where the game crashes if there's a message dialog from a npc that no longer exists. Reverted properties to private.
Diffstat (limited to 'src/gui/menuwindow.cpp')
-rw-r--r-- | src/gui/menuwindow.cpp | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp index ed32f61d..b243cd57 100644 --- a/src/gui/menuwindow.cpp +++ b/src/gui/menuwindow.cpp @@ -53,43 +53,22 @@ MenuWindow::MenuWindow(): // Buttons // ------------ - gcn::Button *statusButton, *equipmentButton, *skillsButton, - *inventoryButton, *setupButton; - - statusButton = new Button("Status"); - statusButton->setEventId("Status"); - statusButton->addActionListener(&menuWindowListener); - statusButton->setPosition(0, 3); - add(statusButton); - - equipmentButton = new Button("Equipment"); - equipmentButton->setEventId("Equipment"); - equipmentButton->addActionListener(&menuWindowListener); - equipmentButton->setPosition(statusButton->getX() + statusButton->getWidth() + 3, statusButton->getY()); - add(equipmentButton); - - inventoryButton = new Button("Inventory"); - inventoryButton->setEventId("Inventory"); - inventoryButton->addActionListener(&menuWindowListener); - inventoryButton->setPosition(equipmentButton->getX() + equipmentButton->getWidth() + 3, statusButton->getY()); - add(inventoryButton); - - skillsButton = new Button("Skills"); - skillsButton->setEventId("Skills"); - skillsButton->addActionListener(&menuWindowListener); - skillsButton->setPosition(inventoryButton->getX() + inventoryButton->getWidth() + 3, statusButton->getY()); - add(skillsButton); - - setupButton = new Button("Setup"); - setupButton->setEventId("Setup"); - setupButton->addActionListener(&menuWindowListener); - setupButton->setPosition(skillsButton->getX() + skillsButton->getWidth() + 3, statusButton->getY()); - add(setupButton); + char *buttonNames[] = { + "Status", "Equipment", "Inventory", "Skills", "Setup", 0 + }; + int x = 0, y = 3, h = 0; + + for (char **curBtn = buttonNames; *curBtn; curBtn++) { + gcn::Button *btn = new Button(*curBtn); + btn->setEventId(*curBtn); + btn->addActionListener(&menuWindowListener); + btn->setPosition(x, y); + add(btn); + x += btn->getWidth() + 3; + h = btn->getHeight(); + } - int menuWidth = setupButton->getX() + setupButton->getWidth(); - setDefaultSize((graphics->getWidth() - menuWidth - 5), 0, - menuWidth, - (setupButton->getY() + setupButton->getHeight())); + setDefaultSize((graphics->getWidth() - x - 2), 0, x, (y + h)); } void MenuWindow::draw(gcn::Graphics *g) |