diff options
author | sluicebox | 2019-03-25 01:28:13 -0700 |
---|---|---|
committer | Filippos Karapetis | 2019-03-25 11:42:54 +0200 |
commit | 0008fab4f50efc6ec81f35555b421c1a07ad567c (patch) | |
tree | 7f9d457cac7b22c801f840ab8dd203c383b21ede /engines/sci/graphics | |
parent | b2c79fdf4bce6e6a0b459c8aa553f139b072e9a2 (diff) | |
download | scummvm-rg350-0008fab4f50efc6ec81f35555b421c1a07ad567c.tar.gz scummvm-rg350-0008fab4f50efc6ec81f35555b421c1a07ad567c.tar.bz2 scummvm-rg350-0008fab4f50efc6ec81f35555b421c1a07ad567c.zip |
SCI: Fix Mac icon bar crash on restart (KQ6, FPFP)
Add support for reinitializing the mac icon bar when restarting.
Restarting runs the game's init script which calls KPlatform again.
Prior to this, restarting these games would fail an assertion.
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r-- | engines/sci/graphics/maciconbar.cpp | 17 | ||||
-rw-r--r-- | engines/sci/graphics/maciconbar.h | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/engines/sci/graphics/maciconbar.cpp b/engines/sci/graphics/maciconbar.cpp index c5c2fb97af..9b645e485f 100644 --- a/engines/sci/graphics/maciconbar.cpp +++ b/engines/sci/graphics/maciconbar.cpp @@ -49,6 +49,23 @@ GfxMacIconBar::GfxMacIconBar() { } GfxMacIconBar::~GfxMacIconBar() { + freeIcons(); +} + +void GfxMacIconBar::initIcons(uint16 count, reg_t *objs) { + // free icons and reset state in case game is restarting + freeIcons(); + _iconBarItems.clear(); + _lastX = 0; + _inventoryIcon = 0; + _allDisabled = true; + + for (uint16 i = 0; i < count; i++) { + addIcon(objs[i]); + } +} + +void GfxMacIconBar::freeIcons() { if (_inventoryIcon) { _inventoryIcon->free(); delete _inventoryIcon; diff --git a/engines/sci/graphics/maciconbar.h b/engines/sci/graphics/maciconbar.h index 86cbc74039..21d28dfc29 100644 --- a/engines/sci/graphics/maciconbar.h +++ b/engines/sci/graphics/maciconbar.h @@ -38,7 +38,7 @@ public: GfxMacIconBar(); ~GfxMacIconBar(); - void addIcon(reg_t obj); + void initIcons(uint16 count, reg_t *objs); void drawIcons(); void setIconEnabled(int16 index, bool enabled); void setInventoryIcon(int16 icon); @@ -63,6 +63,8 @@ private: Graphics::Surface *createImage(uint32 iconIndex, bool isSelected); void remapColors(Graphics::Surface *surf, const byte *palette); + void freeIcons(); + void addIcon(reg_t obj); void drawIcon(uint16 index, bool selected); void drawSelectedImage(uint16 index); bool isIconEnabled(uint16 index) const; |