diff options
-rw-r--r-- | src/engine.cpp | 8 | ||||
-rw-r--r-- | src/engine.h | 2 | ||||
-rw-r--r-- | src/game.cpp | 10 | ||||
-rw-r--r-- | src/gui/help.cpp | 33 | ||||
-rw-r--r-- | src/gui/help.h | 5 |
5 files changed, 41 insertions, 17 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 75d4ba2f..60b547a6 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -30,6 +30,7 @@ #include "gui/itemcontainer.h" #include "gui/trade.h" #include "gui/buddywindow.h" +#include "gui/help.h" #include "main.h" #include "being.h" #include "floor_item.h" @@ -63,6 +64,7 @@ ChargeDialog *chargeDialog; TradeWindow *tradeWindow; BuddyWindow *buddyWindow; Menu *menu; +HelpWindow *helpWindow; std::map<int, Spriteset*> monsterset; char hairtable[16][4][2] = { @@ -160,6 +162,7 @@ Engine::Engine() chargeDialog = new ChargeDialog(); tradeWindow = new TradeWindow(); buddyWindow = new BuddyWindow(); + helpWindow = new HelpWindow(); /* Menu items */ std::vector<MenuItem*> items; @@ -204,6 +207,7 @@ Engine::Engine() tradeWindow->setVisible(false); buddyWindow->setVisible(false); menu->setVisible(false); + helpWindow->setVisible(false); // Do not focus any text field gui->focusNone(); @@ -238,6 +242,7 @@ Engine::~Engine() delete buyDialog; delete sellDialog; delete buySellDialog; + delete inventoryWindow; delete npcListDialog; delete npcTextDialog; delete skillDialog; @@ -245,9 +250,12 @@ Engine::~Engine() delete setupWindow; delete minimap; delete equipmentWindow; + delete chargeDialog; delete newSkillWindow; delete tradeWindow; delete buddyWindow; + delete menu; + delete helpWindow; // Delete sprite sets //delete monsterset; diff --git a/src/engine.h b/src/engine.h index 05bcec68..48015b89 100644 --- a/src/engine.h +++ b/src/engine.h @@ -43,6 +43,7 @@ #include "gui/chargedialog.h" #include "gui/menu.h" #include "gui/trade.h" +#include "gui/help.h" #include "resources/resourcemanager.h" #include "map.h" #include "graphic/spriteset.h" @@ -72,6 +73,7 @@ extern ChargeDialog* chargeDialog; extern TradeWindow *tradeWindow; extern BuddyWindow *buddyWindow; extern Menu *menu; +extern HelpWindow *helpWindow; 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 3b4a4420..206da15e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -231,7 +231,15 @@ void do_input() if (keysym.sym == SDLK_F1) { - new HelpWindow(); + if (helpWindow->isVisible()) + { + helpWindow->setVisible(false); + } + else + { + helpWindow->loadHelp("index"); + } + used = true; } if (keysym.sym == SDLK_RETURN) diff --git a/src/gui/help.cpp b/src/gui/help.cpp index 5b652f99..d1e13174 100644 --- a/src/gui/help.cpp +++ b/src/gui/help.cpp @@ -29,7 +29,6 @@ HelpWindow::HelpWindow(): Window("Help") { setContentSize(455, 350); - setResizeable(true); textBox = new TextBox(); textBox->setEditable(false); @@ -48,11 +47,8 @@ HelpWindow::HelpWindow(): add(scrollArea); add(okButton); - //setLocationRelativeTo(getParent()); + setLocationRelativeTo(getParent()); textBox->requestFocus(); - - std::string defHelp = "index"; - loadHelp(defHelp); } HelpWindow::~HelpWindow() @@ -66,16 +62,20 @@ HelpWindow::~HelpWindow() void HelpWindow::action(const std::string& eventId) { - scheduleDelete(); + setVisible(false); } void HelpWindow::mousePress(int mx, int my, int button) { - int x1 = scrollArea->getX() + 10; - int y1 = scrollArea->getY() + 15; - int x2 = x1 + scrollArea->getWidth() - 25; - int y2 = y1 + scrollArea->getHeight(); + getParent()->moveToTop(this); + if (button == gcn::MouseInput::LEFT) { + + int x1 = scrollArea->getX() + 10; + int y1 = scrollArea->getY() + 15; + int x2 = x1 + scrollArea->getWidth() - 25; + int y2 = y1 + scrollArea->getHeight(); + if ((mx >= x1) && (my >= y1) && (mx <= x2) && (my <= y2)) { for (unsigned int i = 0; i < links.size(); i++) @@ -85,14 +85,20 @@ void HelpWindow::mousePress(int mx, int my, int button) int y2 = y1 + textBox->getFont()->getHeight(); if ((my > y1) && (my < y2)) { std::string tmp = links[i].file; - loadHelp(tmp); + loadHelp(links[i].file); } } } - } + else if (hasMouse() && my < (int)(getTitleBarHeight() + getPadding())) + { + mMouseDrag = true; + mMouseXOffset = mx; + mMouseYOffset = my; + } + } } -void HelpWindow::loadHelp(std::string& helpFile) { +void HelpWindow::loadHelp(std::string helpFile) { helpFile = TMW_DATADIR "data/help/" + helpFile + ".txt"; std::ifstream fin; @@ -126,6 +132,7 @@ void HelpWindow::loadHelp(std::string& helpFile) { textBox->addRow(line); } scrollArea->setVerticalScrollAmount(0); + setVisible(true); fin.close(); } diff --git a/src/gui/help.h b/src/gui/help.h index 17821765..6c6bec13 100644 --- a/src/gui/help.h +++ b/src/gui/help.h @@ -24,7 +24,6 @@ #ifndef _TMW_HELP_H #define _TMW_HELP_H -#include <guichan.hpp> #include "window.h" #include "scrollarea.h" #include "button.h" @@ -64,13 +63,13 @@ class HelpWindow : public Window, public gcn::ActionListener /** * Load help in the dialog. */ - void loadHelp(std::string& helpFile); + void loadHelp(std::string helpFile); private: std::vector<HELP_LINK> links; gcn::Button *okButton; gcn::TextBox *textBox; - gcn::ScrollArea *scrollArea; + ScrollArea *scrollArea; }; #endif |