summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-08-19 20:23:28 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-08-19 20:23:28 +0000
commita3fb2940327ff2e1a7c3517a7f0ccfbd965f9110 (patch)
tree69783b3212f9614d7379e71b04629f795c33976c /src/game.cpp
parent034167c22d252f2e3d50bf6c9e345aca57e7cb04 (diff)
downloadmana-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
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp122
1 files changed, 122 insertions, 0 deletions
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();
}