diff options
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) |