diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-08-19 20:23:28 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-08-19 20:23:28 +0000 |
commit | a3fb2940327ff2e1a7c3517a7f0ccfbd965f9110 (patch) | |
tree | 69783b3212f9614d7379e71b04629f795c33976c | |
parent | 034167c22d252f2e3d50bf6c9e345aca57e7cb04 (diff) | |
download | mana-client-a3fb2940327ff2e1a7c3517a7f0ccfbd965f9110.tar.gz mana-client-a3fb2940327ff2e1a7c3517a7f0ccfbd965f9110.tar.bz2 mana-client-a3fb2940327ff2e1a7c3517a7f0ccfbd965f9110.tar.xz mana-client-a3fb2940327ff2e1a7c3517a7f0ccfbd965f9110.zip |
Moved gui window construction from engine.cpp to game.cpp
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/engine.cpp | 127 | ||||
-rw-r--r-- | src/game.cpp | 122 |
3 files changed, 128 insertions, 124 deletions
@@ -1,5 +1,8 @@ 2005-08-19 Björn Steinbrink <B.Steinbrink@gmx.de> + * src/engine.cpp, src/game.cpp: The engine isn't connected to all the gui + windows, so move creation from its constructor into the game.cpp where + most of them are actually used. * src/log.cpp, src/log.h, src/main.cpp: Added support for parsing command line options. Added option to skip the update process. Made logger being created immediately after startup, because some destructors use it. diff --git a/src/engine.cpp b/src/engine.cpp index 4c91a688..72d90a61 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -30,7 +30,6 @@ #include <guichan/widgets/label.hpp> #include "being.h" -#include "configuration.h" #include "floor_item.h" #include "game.h" #include "graphics.h" @@ -41,25 +40,10 @@ #include "graphic/spriteset.h" -//#include "gui/buddywindow.h" -#include "gui/buy.h" -#include "gui/buysell.h" -#include "gui/chargedialog.h" -#include "gui/chat.h" -#include "gui/equipmentwindow.h" #include "gui/gui.h" -#include "gui/help.h" -#include "gui/inventorywindow.h" #include "gui/minimap.h" -#include "gui/npc.h" -#include "gui/npc_text.h" -#include "gui/popupmenu.h" -#include "gui/sell.h" -#include "gui/setup.h" -#include "gui/skill.h" #include "gui/stats.h" #include "gui/status.h" -#include "gui/trade.h" #include "gui/windowcontainer.h" #include "resources/image.h" @@ -67,8 +51,9 @@ #include "resources/itemmanager.h" #include "resources/resourcemanager.h" -extern Being* autoTarget; -extern Graphics* graphics; +extern Being *autoTarget; +extern Graphics *graphics; +extern Minimap *minimap; extern Spriteset *hairset, *playerset; char itemCurrenyQ[10] = "0"; @@ -76,25 +61,6 @@ int camera_x, camera_y; gcn::Label *debugInfo; -ChatWindow *chatWindow; -StatusWindow *statusWindow; -BuyDialog *buyDialog; -SellDialog *sellDialog; -BuySellDialog *buySellDialog; -InventoryWindow *inventoryWindow; -NpcListDialog *npcListDialog; -NpcTextDialog *npcTextDialog; -SkillDialog *skillDialog; -//NewSkillDialog *newSkillWindow; -StatsWindow *statsWindow; -Setup* setupWindow; -Minimap *minimap; -EquipmentWindow *equipmentWindow; -ChargeDialog *chargeDialog; -TradeWindow *tradeWindow; -//BuddyWindow *buddyWindow; -HelpWindow *helpWindow; -PopupMenu *popupMenu; std::map<int, Spriteset*> monsterset; ItemManager *itemDb; /**< Item database object */ @@ -181,72 +147,6 @@ Engine::Engine(): // (Well, the BasicContainer interface isn't that much more useful... ;) dynamic_cast<WindowContainer*>(gui->getTop())->add(debugInfo); - // Create dialogs - chatWindow = new ChatWindow( - config.getValue("homeDir", "") + std::string("/chatlog.txt")); - statusWindow = new StatusWindow(); - buyDialog = new BuyDialog(); - sellDialog = new SellDialog(); - buySellDialog = new BuySellDialog(); - inventoryWindow = new InventoryWindow(); - npcTextDialog = new NpcTextDialog(); - npcListDialog = new NpcListDialog(); - skillDialog = new SkillDialog(); - //newSkillWindow = new NewSkillDialog(); - statsWindow = new StatsWindow(); - setupWindow = new Setup(); - minimap = new Minimap(); - equipmentWindow = new EquipmentWindow(); - chargeDialog = new ChargeDialog(); - tradeWindow = new TradeWindow(); - //buddyWindow = new BuddyWindow(); - helpWindow = new HelpWindow(); - popupMenu = new PopupMenu(); - - // Initialize window posisitons - int screenW = graphics->getWidth(); - int screenH = graphics->getHeight(); - - chatWindow->setPosition(0, screenH - chatWindow->getHeight()); - statusWindow->setPosition(screenW - statusWindow->getWidth() - 5, 5); - inventoryWindow->setPosition(screenW - statusWindow->getWidth() - - inventoryWindow->getWidth() - 10, 5); - statsWindow->setPosition( - screenW - 5 - statsWindow->getWidth(), - statusWindow->getHeight() + 20); - chargeDialog->setPosition( - screenW - 5 - chargeDialog->getWidth(), - screenH - chargeDialog->getHeight() - 15); - tradeWindow->setPosition(screenW - statusWindow->getWidth() - - tradeWindow->getWidth() - 10, - inventoryWindow->getY() + inventoryWindow->getHeight()); - /*buddyWindow->setPosition(10, - minimap->getHeight() + 30);*/ - equipmentWindow->setPosition(5,140); - - // Set initial window visibility - chatWindow->setVisible(true); - statusWindow->setVisible(true); - buyDialog->setVisible(false); - sellDialog->setVisible(false); - buySellDialog->setVisible(false); - inventoryWindow->setVisible(false); - npcTextDialog->setVisible(false); - npcListDialog->setVisible(false); - skillDialog->setVisible(false); - //newSkillWindow->setVisible(false); - statsWindow->setVisible(false); - setupWindow->setVisible(false); - equipmentWindow->setVisible(false); - chargeDialog->setVisible(false); - tradeWindow->setVisible(false); - //buddyWindow->setVisible(false); - helpWindow->setVisible(false); - popupMenu->setVisible(false); - - // Do not focus any text field - gui->focusNone(); - // Load the sprite sets ResourceManager *resman = ResourceManager::getInstance(); Image *npcbmp = resman->getImage("graphics/sprites/npcs.png"); @@ -274,27 +174,6 @@ Engine::Engine(): Engine::~Engine() { - // Delete windows - delete chatWindow; - delete statusWindow; - delete buyDialog; - delete sellDialog; - delete buySellDialog; - delete inventoryWindow; - delete npcListDialog; - delete npcTextDialog; - delete skillDialog; - delete statsWindow; - delete setupWindow; - delete minimap; - delete equipmentWindow; - delete chargeDialog; - //delete newSkillWindow; - delete tradeWindow; - //delete buddyWindow; - delete helpWindow; - delete popupMenu; - // Delete sprite sets //delete monsterset; delete npcset; diff --git a/src/game.cpp b/src/game.cpp index c130870f..f4cffedd 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -43,12 +43,14 @@ #include "gui/buy.h" #include "gui/buysell.h" +#include "gui/chargedialog.h" #include "gui/chat.h" #include "gui/confirm_dialog.h" #include "gui/equipmentwindow.h" #include "gui/gui.h" #include "gui/help.h" #include "gui/inventorywindow.h" +#include "gui/minimap.h" #include "gui/npc.h" #include "gui/npc_text.h" #include "gui/ok_dialog.h" @@ -88,6 +90,26 @@ SDL_Joystick *joypad = NULL; /**< Joypad object */ OkDialog *deathNotice = NULL; ConfirmDialog *exitConfirm = NULL; +ChatWindow *chatWindow; +StatusWindow *statusWindow; +BuyDialog *buyDialog; +SellDialog *sellDialog; +BuySellDialog *buySellDialog; +InventoryWindow *inventoryWindow; +NpcListDialog *npcListDialog; +NpcTextDialog *npcTextDialog; +SkillDialog *skillDialog; +//NewSkillDialog *newSkillWindow; +StatsWindow *statsWindow; +Setup* setupWindow; +Minimap *minimap; +EquipmentWindow *equipmentWindow; +ChargeDialog *chargeDialog; +TradeWindow *tradeWindow; +//BuddyWindow *buddyWindow; +HelpWindow *helpWindow; +PopupMenu *popupMenu; + Inventory *inventory = NULL; const int EMOTION_TIME = 150; /**< Duration of emotion icon */ @@ -161,6 +183,104 @@ Being* createBeing(unsigned int id, unsigned short job, Map *map) return being; } +/** + * Create all the various globally accessible gui windows + */ +void createGuiWindows() +{ + // Create dialogs + chatWindow = new ChatWindow( + config.getValue("homeDir", "") + std::string("/chatlog.txt")); + statusWindow = new StatusWindow(); + buyDialog = new BuyDialog(); + sellDialog = new SellDialog(); + buySellDialog = new BuySellDialog(); + inventoryWindow = new InventoryWindow(); + npcTextDialog = new NpcTextDialog(); + npcListDialog = new NpcListDialog(); + skillDialog = new SkillDialog(); + //newSkillWindow = new NewSkillDialog(); + statsWindow = new StatsWindow(); + setupWindow = new Setup(); + minimap = new Minimap(); + equipmentWindow = new EquipmentWindow(); + chargeDialog = new ChargeDialog(); + tradeWindow = new TradeWindow(); + //buddyWindow = new BuddyWindow(); + helpWindow = new HelpWindow(); + popupMenu = new PopupMenu(); + + // Initialize window posisitons + int screenW = graphics->getWidth(); + int screenH = graphics->getHeight(); + + chatWindow->setPosition(0, screenH - chatWindow->getHeight()); + statusWindow->setPosition(screenW - statusWindow->getWidth() - 5, 5); + inventoryWindow->setPosition(screenW - statusWindow->getWidth() - + inventoryWindow->getWidth() - 10, 5); + statsWindow->setPosition( + screenW - 5 - statsWindow->getWidth(), + statusWindow->getHeight() + 20); + chargeDialog->setPosition( + screenW - 5 - chargeDialog->getWidth(), + screenH - chargeDialog->getHeight() - 15); + tradeWindow->setPosition(screenW - statusWindow->getWidth() - + tradeWindow->getWidth() - 10, + inventoryWindow->getY() + inventoryWindow->getHeight()); + /*buddyWindow->setPosition(10, + minimap->getHeight() + 30);*/ + equipmentWindow->setPosition(5,140); + + // Set initial window visibility + chatWindow->setVisible(true); + statusWindow->setVisible(true); + buyDialog->setVisible(false); + sellDialog->setVisible(false); + buySellDialog->setVisible(false); + inventoryWindow->setVisible(false); + npcTextDialog->setVisible(false); + npcListDialog->setVisible(false); + skillDialog->setVisible(false); + //newSkillWindow->setVisible(false); + statsWindow->setVisible(false); + setupWindow->setVisible(false); + equipmentWindow->setVisible(false); + chargeDialog->setVisible(false); + tradeWindow->setVisible(false); + //buddyWindow->setVisible(false); + helpWindow->setVisible(false); + popupMenu->setVisible(false); + + // Do not focus any text field + gui->focusNone(); +} + +/** + * Destroy all the globally accessible gui windows + */ +void destroyGuiWindows() +{ + delete chatWindow; + delete statusWindow; + delete buyDialog; + delete sellDialog; + delete buySellDialog; + delete inventoryWindow; + delete npcListDialog; + delete npcTextDialog; + delete skillDialog; + delete statsWindow; + delete setupWindow; + delete minimap; + delete equipmentWindow; + delete chargeDialog; + //delete newSkillWindow; + delete tradeWindow; + //delete buddyWindow; + delete helpWindow; + delete popupMenu; +} + void do_init() { std::string path(map_path); @@ -232,6 +352,7 @@ void game() // Needs to be initialised _before_ the engine is created... inventory = new Inventory(); + createGuiWindows(); engine = new Engine(); do_init(); @@ -267,6 +388,7 @@ void game() } delete engine; + destroyGuiWindows(); close_session(); } |