From 479f01b5a708ed1e3294ef1d553d37d270cb97c4 Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Fri, 12 Aug 2016 12:42:24 +0200 Subject: MACVENTURE: Implement gui reloading --- engines/macventure/gui.cpp | 21 ++++++++++++++++----- engines/macventure/gui.h | 3 +++ engines/macventure/macventure.cpp | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp index b66e2ee598..85f1cdbea7 100644 --- a/engines/macventure/gui.cpp +++ b/engines/macventure/gui.cpp @@ -112,6 +112,7 @@ Gui::Gui(MacVentureEngine *engine, Common::MacResManager *resman) { _cursor = new Cursor(this); _consoleText = new ConsoleText(this); + _graphics = NULL; initGUI(); } @@ -136,10 +137,7 @@ Gui::~Gui() { if (_dialog) delete _dialog; - Common::HashMap::const_iterator it = _assets.begin(); - for (; it != _assets.end(); it++) { - delete it->_value; - } + clearAssets(); } void Gui::initGUI() { @@ -169,8 +167,12 @@ void Gui::initGUI() { } -void Gui::draw() { +void Gui::reloadInternals() { + loadGraphics(); + clearAssets(); +} +void Gui::draw() { // Will be performance-improved after the milestone _wm.setFullRefresh(true); @@ -352,9 +354,18 @@ void Gui::loadBorder(Graphics::MacWindow * target, MVWindowType type, bool activ } void Gui::loadGraphics() { + if (_graphics) + delete _graphics; _graphics = new Container(_engine->getFilePath(kGraphicPathID)); } +void Gui::clearAssets() { + Common::HashMap::const_iterator it = _assets.begin(); + for (; it != _assets.end(); it++) { + delete it->_value; + } +} + bool Gui::loadMenus() { if (kLoadStaticMenus) { diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h index 185171f6b9..5835202904 100644 --- a/engines/macventure/gui.h +++ b/engines/macventure/gui.h @@ -98,6 +98,8 @@ public: Gui(MacVentureEngine *engine, Common::MacResManager *resman); ~Gui(); + void reloadInternals(); + void draw(); void drawMenu(); void drawTitle(); @@ -211,6 +213,7 @@ private: // Methods void loadBorders(Graphics::MacWindow *target, MVWindowType type); void loadBorder(Graphics::MacWindow *target, MVWindowType type, bool active); void loadGraphics(); + void clearAssets(); // Drawers void drawWindows(); diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index b96a8bfeec..21fb709994 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -248,6 +248,7 @@ void MacVentureEngine::resetInternals() { } void MacVentureEngine::resetGui() { + _gui->reloadInternals(); _gui->updateWindowInfo(kMainGameWindow, getParent(1), _world->getChildren(getParent(1), true)); // HACK! should update all inventories _gui->ensureInventoryOpen(kInventoryStart, 1); -- cgit v1.2.3