diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/engine.cpp | 10 | ||||
-rw-r--r-- | src/engine.h | 2 | ||||
-rw-r--r-- | src/game.cpp | 4 | ||||
-rw-r--r-- | src/gui/buddywindow.cpp | 5 | ||||
-rw-r--r-- | src/gui/menu.cpp | 17 | ||||
-rw-r--r-- | src/gui/menu.h | 15 |
6 files changed, 42 insertions, 11 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 2d93a842..459af137 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -66,6 +66,7 @@ ChargeDialog *chargeDialog; TradeWindow *tradeWindow; RequestTradeDialog *requestTradeDialog; BuddyWindow *buddyWindow; +Menu *menu; std::map<int, Spriteset*> monsterset; char hairtable[16][4][2] = { @@ -165,7 +166,12 @@ Engine::Engine() tradeWindow = new TradeWindow(); buddyWindow = new BuddyWindow(); requestTradeDialog = new RequestTradeDialog(); - + + /* Menu items */ + std::vector<MenuItem> items; + items.push_back(MenuItem("First")); + menu = new Menu("Menu", items); + // Initialize window posisitons chatWindow->setPosition(0, screen->h - chatWindow->getHeight()); statusWindow->setPosition(screen->w - statusWindow->getWidth() - 5, 5); @@ -189,6 +195,7 @@ Engine::Engine() requestTradeDialog->getWidth() - 10, chatWindow->getHeight() + 15); equipmentWindow->setPosition(5,140); + menu->setPosition(5,140); // Set initial window visibility chatWindow->setVisible(true); @@ -209,6 +216,7 @@ Engine::Engine() tradeWindow->setVisible(false); buddyWindow->setVisible(false); requestTradeDialog->setVisible(false); + menu->setVisible(false); // Do not focus any text field gui->focusNone(); diff --git a/src/engine.h b/src/engine.h index 548a3453..0f69e04e 100644 --- a/src/engine.h +++ b/src/engine.h @@ -42,6 +42,7 @@ #include "gui/equipment.h" #include "gui/chargedialog.h" #include "gui/item_amount.h" +#include "gui/menu.h" #include "gui/trade.h" #include "gui/requesttrade.h" #include "gui/confirm_dialog.h" @@ -76,6 +77,7 @@ extern RequestTradeDialog *requestTradeDialog; extern TradeWindow *tradeWindow; extern BuddyWindow *buddyWindow; extern ConfirmDialog *quitDialog; +extern Menu *menu; extern std::map<int, Spriteset*> monsterset; char get_x_offset(char, char); char get_y_offset(char, char); diff --git a/src/game.cpp b/src/game.cpp index a8166fae..b849fcdd 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -296,6 +296,10 @@ void do_input() buddyWindow->setVisible(!buddyWindow->isVisible()); used = true; } + else if (keysym.sym == SDLK_m) { + menu->setVisible(!menu->isVisible()); + used = true; + } } if (event.key.keysym.sym == SDLK_ESCAPE) diff --git a/src/gui/buddywindow.cpp b/src/gui/buddywindow.cpp index 2e81c798..b57b32dd 100644 --- a/src/gui/buddywindow.cpp +++ b/src/gui/buddywindow.cpp @@ -22,7 +22,7 @@ */ #include "buddywindow.h" -#include "menuitem.h" +#include "menu.h" BuddyWindow::BuddyWindow(): Window("Buddys") @@ -38,9 +38,6 @@ BuddyWindow::BuddyWindow(): add(scrollArea); addBuddy("Usiu"); // for testing - MenuItem *item = new MenuItem("Test"); - item->setPosition(0, 200 - item->getHeight()); - add(item); } BuddyWindow::~BuddyWindow() diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index c74ca5ea..74721d09 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -23,8 +23,23 @@ #include "menu.h" -Menu::Menu(const std::vector<MenuItem>& items) +Menu::Menu(const std::string& menulabel, std::vector<MenuItem>& items): + Window(menulabel) { + setContentSize(40,60); + fill(items); +} +Menu::~Menu() +{ } +void Menu::fill(std::vector<MenuItem>& items) +{ + for(std::vector<MenuItem>::iterator item = items.begin(); + item != items.end(); ++item) + { + item->setPosition(0,0); + add(&*item); + } +} diff --git a/src/gui/menu.h b/src/gui/menu.h index 3d24827a..a726e6a8 100644 --- a/src/gui/menu.h +++ b/src/gui/menu.h @@ -26,17 +26,22 @@ #include <guichan.hpp> #include "menuitem.h" +#include "window.h" -class Menu : public gcn::Widget -{ +class Menu : public Window { public: /** * Constructor. */ - Menu(const std::vector<MenuItem>& items); + Menu(const std::string& menulabel, std::vector<MenuItem>& items); + + /** + * Destructor. + */ + ~Menu(); + + void fill(std::vector<MenuItem>& items); - private: - int i; }; #endif /* _TMW_MENU_H */ |