diff options
-rw-r--r-- | engines/mads/scene.cpp | 2 | ||||
-rw-r--r-- | engines/mads/screen.cpp | 42 | ||||
-rw-r--r-- | engines/mads/screen.h | 9 | ||||
-rw-r--r-- | engines/mads/sprites.h | 2 | ||||
-rw-r--r-- | engines/mads/user_interface.cpp | 18 | ||||
-rw-r--r-- | engines/mads/user_interface.h | 7 |
6 files changed, 63 insertions, 17 deletions
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index ed5fca5f6e..60b33853a4 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -379,7 +379,7 @@ void Scene::doFrame() { _kernelMessages.update(); } - _userInterface._uiSlots.call(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0, + _userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0, _vm->_game->_abortTimers2); // Write any text needed by the interface diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp index e760aa465d..8b05d7acbe 100644 --- a/engines/mads/screen.cpp +++ b/engines/mads/screen.cpp @@ -25,6 +25,7 @@ #include "mads/game.h" #include "mads/screen.h" #include "mads/palette.h" +#include "mads/user_interface.h" namespace MADS { @@ -116,6 +117,47 @@ void DirtyArea::setTextDisplay(const TextDisplay *textDisplay) { MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT); } +void DirtyArea::setUISlot(const UISlot *slot) { + int type = slot->_slotType; + if (type <= -20) + type += 20; + if (type >= 64) + type &= 0xBF; + + MSurface &intSurface = _vm->_game->_scene._userInterface; + switch (type) { + case ST_FULL_SCREEN_REFRESH: + _bounds.left = 0; + _bounds.top = 0; + setArea(intSurface.w, intSurface.h, intSurface.w, intSurface.h); + break; + case ST_MINUS3: + _bounds.left = slot->_position.x; + _bounds.top = slot->_position.y; + // TODO: spritesIndex & frameNumber used as w & h??! + error("TODO: Figure out ST_MINUS3. Maybe need a union?"); + break; + + default: { + SpriteAsset *asset = _vm->_game->_scene._sprites[slot->_spritesIndex]; + MSprite *frame = asset->getFrame(slot->_frameNumber - 1); + int w = frame->w; + int h = frame->h; + + if (slot->_field2 == 200) { + _bounds.left = slot->_position.x; + _bounds.top = slot->_position.y; + } else { + _bounds.left = slot->_position.x + w / 2; + _bounds.top = slot->_position.y + h / 2; + } + + setArea(w, h, intSurface.w, intSurface.h); + break; + } + } +} + /*------------------------------------------------------------------------*/ DirtyAreas::DirtyAreas(MADSEngine *vm) : _vm(vm) { diff --git a/engines/mads/screen.h b/engines/mads/screen.h index 2860462ff1..06053e89dd 100644 --- a/engines/mads/screen.h +++ b/engines/mads/screen.h @@ -47,6 +47,7 @@ enum ScreenTransition { class SpriteSlot; class TextDisplay; +class UISlot; class DirtyArea { private: @@ -62,12 +63,20 @@ public: void setArea(int width, int height, int maxWidth, int maxHeight); + /** + * Set up a dirty area for a sprite slot + */ void setSpriteSlot(const SpriteSlot *spriteSlot); /** * Set up a dirty area for a text display */ void setTextDisplay(const TextDisplay *textDisplay); + + /** + * Set up a dirty area for a UI slot + */ + void setUISlot(const UISlot *slot); }; class DirtyAreas : public Common::Array<DirtyArea> { diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h index cf45be6806..6118924de7 100644 --- a/engines/mads/sprites.h +++ b/engines/mads/sprites.h @@ -31,7 +31,7 @@ namespace MADS { enum SlotType { - ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4, + ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4, ST_MINUS3 = -3, ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1 }; diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp index 2b5e6c4558..f34d68c6ce 100644 --- a/engines/mads/user_interface.cpp +++ b/engines/mads/user_interface.cpp @@ -32,8 +32,6 @@ UISlot::UISlot() { _field2 = 0; _spritesIndex = 0; _frameNumber = 0; - _field6 = 0; - _field8 = 0; } /*------------------------------------------------------------------------*/ @@ -46,22 +44,21 @@ void UISlots::fullRefresh() { push_back(slot); } -void UISlots::add(int v1, int v2, int frameNumber, int spritesIndex) { +void UISlots::add(const Common::Point &pt, int frameNumber, int spritesIndex) { assert(size() < 50); UISlot ie; ie._slotType = -3; ie._field2 = 201; - ie._field6 = v1; - ie._field8 = v2; + ie._position = pt; ie._frameNumber = frameNumber; ie._spritesIndex = spritesIndex; push_back(ie); } -void UISlots::call(int v1, int v2) { - debug("TODO: UISlots::call"); +void UISlots::draw(int v1, int v2) { + } /*------------------------------------------------------------------------*/ @@ -142,7 +139,7 @@ void UserInterface::setup(int id) { copyTo(&_surface); if (_vm->_game->_v1 == 5) - scene._userInterface._uiSlots.call(0, 0); + scene._userInterface._uiSlots.draw(0, 0); scene._action.clear(); drawTextElements(); @@ -468,7 +465,7 @@ void UserInterface::noInventoryAnim() { void UserInterface::refresh() { _uiSlots.clear(); _uiSlots.fullRefresh(); - _uiSlots.call(0, 0); + _uiSlots.draw(0, 0); drawTextElements(); } @@ -496,8 +493,7 @@ void UserInterface::inventoryAnim() { slot._field2 = 200; slot._frameNumber = _invFrameNumber; slot._spritesIndex = _invSpritesIndex; - slot._field6 = 160; - slot._field8 = 3; + slot._position = Common::Point(160, 3); _uiSlots.push_back(slot); } diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h index 8b87b4e65d..a474fe1fa1 100644 --- a/engines/mads/user_interface.h +++ b/engines/mads/user_interface.h @@ -42,18 +42,17 @@ public: int _field2; int _spritesIndex; int _frameNumber; - int _field6; - int _field8; + Common::Point _position; UISlot(); }; class UISlots : public Common::Array<UISlot> { public: - void add(int v1, int v2, int frameNumber, int spritesIndex); + void add(const Common::Point &pt, int frameNumber, int spritesIndex); void fullRefresh(); - void call(int v1, int v2); + void draw(int v1, int v2); }; |