diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mads/game.cpp | 6 | ||||
-rw-r--r-- | engines/mads/game.h | 2 | ||||
-rw-r--r-- | engines/mads/hotspots.cpp | 6 | ||||
-rw-r--r-- | engines/mads/inventory.cpp | 6 | ||||
-rw-r--r-- | engines/mads/scene.cpp | 12 | ||||
-rw-r--r-- | engines/mads/scene.h | 1 | ||||
-rw-r--r-- | engines/mads/scene_data.cpp | 106 | ||||
-rw-r--r-- | engines/mads/scene_data.h | 47 | ||||
-rw-r--r-- | engines/mads/screen.cpp | 106 | ||||
-rw-r--r-- | engines/mads/screen.h | 54 | ||||
-rw-r--r-- | engines/mads/user_interface.cpp | 34 | ||||
-rw-r--r-- | engines/mads/user_interface.h | 6 |
12 files changed, 193 insertions, 193 deletions
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index e65330a5d4..06ea2a5437 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -40,7 +40,7 @@ Game *Game::init(MADSEngine *vm) { } Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm), - _scene(vm), _player(vm) { + _scene(vm), _screenObjects(vm), _player(vm) { _sectionNumber = _priorSectionNumber = 0; _difficultyLevel = DIFFICULTY_HARD; _saveSlot = -1; @@ -163,8 +163,8 @@ void Game::sectionLoop() { _vm->_dialogs->_defaultPosition = Common::Point(-1, -1); _visitedScenes.add(_scene._nextSceneId); - _scene._screenObjects._v8333C = true; - _scene._screenObjects._v832EC = 0; + _screenObjects._v8333C = true; + _screenObjects._v832EC = 0; _scene._userInterface._scrollerY = 0; _v3 = -1; diff --git a/engines/mads/game.h b/engines/mads/game.h index 6ef1ca9ef5..444e2fa372 100644 --- a/engines/mads/game.h +++ b/engines/mads/game.h @@ -29,6 +29,7 @@ #include "mads/game_data.h" #include "mads/inventory.h" #include "mads/player.h" +#include "mads/screen.h" namespace MADS { @@ -112,6 +113,7 @@ public: static Game *init(MADSEngine *vm); public: Player _player; + ScreenObjects _screenObjects; int _sectionNumber; int _priorSectionNumber; int _currentSectionNumber; diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp index b33b4b2f28..df56a69e5a 100644 --- a/engines/mads/hotspots.cpp +++ b/engines/mads/hotspots.cpp @@ -126,12 +126,12 @@ void DynamicHotspots::refresh() { DynamicHotspot &dh = (*this)[i]; if ((*this)[i]._active) { - switch (_vm->_game->_scene._screenObjects._v832EC) { + switch (_vm->_game->_screenObjects._v832EC) { case 0: case 2: - _vm->_game->_scene._screenObjects.add(dh._bounds, _vm->_game->_scene._layer, + _vm->_game->_screenObjects.add(dh._bounds, _vm->_game->_scene._layer, CAT_12, dh._descId); - _vm->_game->_scene._screenObjects._v8333C = true; + _vm->_game->_screenObjects._v8333C = true; break; default: break; diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp index b697462cae..1443761ada 100644 --- a/engines/mads/inventory.cpp +++ b/engines/mads/inventory.cpp @@ -116,7 +116,7 @@ void InventoryObjects::addToInventory(int objectId) { (*this)[objectId]._roomNumber = PLAYER_INVENTORY; - if (_vm->_game->_v1 == 5 && !_vm->_game->_scene._screenObjects._v832EC) { + if (_vm->_game->_v1 == 5 && !_vm->_game->_screenObjects._v832EC) { userInterface.categoryChanged(); userInterface.selectObject(userInterface._selectedInvIndex); } @@ -137,7 +137,7 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) { int selectedIndex = userInterface._selectedInvIndex; bool noSelection = selectedIndex < 0; - if (_vm->_game->_v1 == 5 && !scene._screenObjects._v832EC) + if (_vm->_game->_v1 == 5 && !_vm->_game->_screenObjects._v832EC) userInterface.selectObject(-1); // Remove the item from the inventory list @@ -158,7 +158,7 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) { newIndex = 0; } - if (_vm->_game->_v1 == 5 && !scene._screenObjects._v832EC) { + if (_vm->_game->_v1 == 5 && !_vm->_game->_screenObjects._v832EC) { userInterface.categoryChanged(); userInterface.selectObject(newIndex); } diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 02ef916958..741ba82be4 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -30,7 +30,7 @@ namespace MADS { Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm), _dirtyAreas(_vm), _dynamicHotspots(vm), _kernelMessages(vm), - _screenObjects(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), + _sequences(vm), _sprites(vm), _spriteSlots(vm), _textDisplay(vm), _userInterface(vm) { _priorSceneId = 0; _nextSceneId = 0; @@ -162,7 +162,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { _interfaceY = MADS_SCENE_HEIGHT; _spritesCount = _sprites.size(); - _userInterface.setup(_screenObjects._v832EC); + _userInterface.setup(_vm->_game->_screenObjects._v832EC); warning("TODO: showMouse"); @@ -289,7 +289,7 @@ void Scene::doFrame() { if (_dynamicHotspots._changed) _dynamicHotspots.refresh(); - _screenObjects.check(player._stepEnabled && !_action._startWalkFlag && + _vm->_game->_screenObjects.check(player._stepEnabled && !_action._startWalkFlag && !_vm->_game->_abortTimers2); } @@ -331,9 +331,9 @@ void Scene::doFrame() { // Cursor update code CursorType cursorId = CURSOR_ARROW; - if (_action._v83338 == 1 && !_screenObjects._v7FECA && - _screenObjects._category == CAT_HOTSPOT) { - int idx = _screenObjects._selectedObject - _userInterface._screenObjectsCount; + if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA && + _vm->_game->_screenObjects._category == CAT_HOTSPOT) { + int idx = _vm->_game->_screenObjects._selectedObject - _userInterface._screenObjectsCount; if (idx >= (int)_hotspots.size()) { idx -= _hotspots.size(); _vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor; diff --git a/engines/mads/scene.h b/engines/mads/scene.h index f5163bb43d..9493eda532 100644 --- a/engines/mads/scene.h +++ b/engines/mads/scene.h @@ -89,7 +89,6 @@ public: Common::String _talkFont; int _textSpacing; Hotspots _hotspots; - ScreenObjects _screenObjects; DirtyAreas _dirtyAreas; int _v1; SceneInfo *_sceneInfo; diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index 8980bd4428..625eec758e 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -30,112 +30,6 @@ namespace MADS { -ScreenObject::ScreenObject() { - _category = CAT_NONE; - _descId = 0; - _layer = 0; -} - -/*------------------------------------------------------------------------*/ - -ScreenObjects::ScreenObjects(MADSEngine *vm): _vm(vm) { - _v8333C = false; - _v832EC = 0; - _v7FECA = 0; - _v7FED6 = 0; - _v8332A = 0; - _category = CAT_NONE; - _objectIndex = 0; - _released = false; -} - -void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId) { - assert(size() < 100); - - ScreenObject so; - so._bounds = bounds; - so._category = category; - so._descId = descId; - so._layer = layer; - - push_back(so); -} - -void ScreenObjects::check(bool scanFlag) { - Scene &scene = _vm->_game->_scene; - - if (!_vm->_events->_mouseButtons || _v832EC) - _v7FECA = false; - - if ((_vm->_events->_vD6 || _v8332A || _vm->_game->_scene._userInterface._scrollerY || _v8333C) && scanFlag) { - scene._userInterface._selectedInvIndex = scanBackwards(_vm->_events->currentPos(), LAYER_GUI); - if (scene._userInterface._selectedInvIndex > 0) { - _category = (ScrCategory)((*this)[scene._userInterface._selectedInvIndex - 1]._category & 7); - _objectIndex = (*this)[scene._userInterface._selectedInvIndex - 1]._descId; - } - - // Handling for easy mouse - ScrCategory category = scene._userInterface._category; - if (_vm->_easyMouse && !_vm->_events->_vD4 && category != _category - && scene._userInterface._category != CAT_NONE) { - _released = true; - if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) { - scene._userInterface.elementHighlighted(); - } - } - - _released = _vm->_events->_mouseReleased; - if (_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_vD4)) - scene._userInterface._category = _category; - - if (!_vm->_events->_mouseButtons || _vm->_easyMouse) { - if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) { - scene._userInterface.elementHighlighted(); - } - } - - if (_vm->_events->_mouseButtons || (_vm->_easyMouse && scene._action._v83338 > 1 - && scene._userInterface._category == CAT_INV_LIST) || - (_vm->_easyMouse && scene._userInterface._category == CAT_HOTSPOT)) { - scene._action.checkActionAtMousePos(); - } - - if (_vm->_events->_mouseReleased) { - scene.leftClick(); - scene._userInterface._category = CAT_NONE; - } - - if (_vm->_events->_mouseButtons || _vm->_easyMouse || scene._userInterface._scrollerY) - proc1(); - - if (_vm->_events->_mouseButtons || _vm->_easyMouse) - scene._action.set(); - - _v8333C = 0; - } - - scene._action.refresh(); - - // Loop through image inter list - warning("TODO: imageInterList loop"); -} - -int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) { - for (int i = (int)size() - 1; i >= 0; --i) { - if ((*this)[i]._bounds.contains(pt) && ((*this)[i]._layer == layer)) - return i + 1; - } - - // Entry not found - return 0; -} - -void ScreenObjects::proc1() { - warning("TODO: ScreenObjects::proc1"); -} - -/*------------------------------------------------------------------------*/ - void SceneNode::load(Common::SeekableReadStream *f) { _walkPos.x = f->readSint16LE(); _walkPos.y = f->readSint16LE(); diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h index 1543669f7f..d29d4e319a 100644 --- a/engines/mads/scene_data.h +++ b/engines/mads/scene_data.h @@ -51,10 +51,6 @@ class SpriteSlot; #define TEXT_DISPLAY_MAX_SIZE 40 #define DIRTY_AREAS_SIZE (SPRITE_SLOTS_MAX_SIZE + TEXT_DISPLAY_MAX_SIZE) -enum Layer { - LAYER_GUI = 19 -}; - class VerbInit { public: int _id; @@ -65,49 +61,6 @@ public: VerbInit(int id, int action1, int action2): _id(id), _action1(action1), _action2(action2) {} }; -class ScreenObject { -public: - Common::Rect _bounds; - ScrCategory _category; - int _descId; - int _layer; - - ScreenObject(); -}; - -class ScreenObjects: public Common::Array<ScreenObject> { -private: - MADSEngine *_vm; - - int scanBackwards(const Common::Point &pt, int layer); - - void proc1(); -public: - int _v832EC; - int _v7FECA; - int _v7FED6; - int _v8332A; - int _v8333C; - int _selectedObject; - ScrCategory _category; - int _objectIndex; - bool _released; - - /* - * Constructor - */ - ScreenObjects(MADSEngine *vm); - - /** - * Add a new item to the list - */ - void add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId); - - /** - */ - void check(bool scanFlag); -}; - class SceneLogic { protected: MADSEngine *_vm; diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp index 8b05d7acbe..608456e2e3 100644 --- a/engines/mads/screen.cpp +++ b/engines/mads/screen.cpp @@ -243,6 +243,112 @@ void DirtyAreas::reset() { /*------------------------------------------------------------------------*/ +ScreenObject::ScreenObject() { + _category = CAT_NONE; + _descId = 0; + _layer = 0; +} + +/*------------------------------------------------------------------------*/ + +ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) { + _v8333C = false; + _v832EC = 0; + _v7FECA = 0; + _v7FED6 = 0; + _v8332A = 0; + _category = CAT_NONE; + _objectIndex = 0; + _released = false; +} + +void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId) { + assert(size() < 100); + + ScreenObject so; + so._bounds = bounds; + so._category = category; + so._descId = descId; + so._layer = layer; + + push_back(so); +} + +void ScreenObjects::check(bool scanFlag) { + Scene &scene = _vm->_game->_scene; + + if (!_vm->_events->_mouseButtons || _v832EC) + _v7FECA = false; + + if ((_vm->_events->_vD6 || _v8332A || _vm->_game->_scene._userInterface._scrollerY || _v8333C) && scanFlag) { + scene._userInterface._selectedInvIndex = scanBackwards(_vm->_events->currentPos(), LAYER_GUI); + if (scene._userInterface._selectedInvIndex > 0) { + _category = (ScrCategory)((*this)[scene._userInterface._selectedInvIndex - 1]._category & 7); + _objectIndex = (*this)[scene._userInterface._selectedInvIndex - 1]._descId; + } + + // Handling for easy mouse + ScrCategory category = scene._userInterface._category; + if (_vm->_easyMouse && !_vm->_events->_vD4 && category != _category + && scene._userInterface._category != CAT_NONE) { + _released = true; + if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) { + scene._userInterface.elementHighlighted(); + } + } + + _released = _vm->_events->_mouseReleased; + if (_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_vD4)) + scene._userInterface._category = _category; + + if (!_vm->_events->_mouseButtons || _vm->_easyMouse) { + if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) { + scene._userInterface.elementHighlighted(); + } + } + + if (_vm->_events->_mouseButtons || (_vm->_easyMouse && scene._action._v83338 > 1 + && scene._userInterface._category == CAT_INV_LIST) || + (_vm->_easyMouse && scene._userInterface._category == CAT_HOTSPOT)) { + scene._action.checkActionAtMousePos(); + } + + if (_vm->_events->_mouseReleased) { + scene.leftClick(); + scene._userInterface._category = CAT_NONE; + } + + if (_vm->_events->_mouseButtons || _vm->_easyMouse || scene._userInterface._scrollerY) + proc1(); + + if (_vm->_events->_mouseButtons || _vm->_easyMouse) + scene._action.set(); + + _v8333C = 0; + } + + scene._action.refresh(); + + // Loop through image inter list + warning("TODO: imageInterList loop"); +} + +int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) { + for (int i = (int)size() - 1; i >= 0; --i) { + if ((*this)[i]._bounds.contains(pt) && ((*this)[i]._layer == layer)) + return i + 1; + } + + // Entry not found + return 0; +} + +void ScreenObjects::proc1() { + warning("TODO: ScreenObjects::proc1"); +} + +/*------------------------------------------------------------------------*/ + ScreenSurface::ScreenSurface() { _dataP = nullptr; } diff --git a/engines/mads/screen.h b/engines/mads/screen.h index 06053e89dd..9033206852 100644 --- a/engines/mads/screen.h +++ b/engines/mads/screen.h @@ -32,6 +32,16 @@ namespace MADS { #define MADS_SCREEN_WIDTH 320 #define MADS_SCREEN_HEIGHT 200 +enum ScrCategory { + CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3, + CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_TALK_ENTRY = 6, CAT_INV_SCROLLER = 7, + CAT_12 = 12 +}; + +enum Layer { + LAYER_GUI = 19 +}; + enum ScreenTransition { kTransitionNone = 0, kTransitionFadeIn, kTransitionFadeOutIn, @@ -112,6 +122,50 @@ public: void reset(); }; + +class ScreenObject { +public: + Common::Rect _bounds; + ScrCategory _category; + int _descId; + int _layer; + + ScreenObject(); +}; + +class ScreenObjects : public Common::Array<ScreenObject> { +private: + MADSEngine *_vm; + + int scanBackwards(const Common::Point &pt, int layer); + + void proc1(); +public: + int _v832EC; + int _v7FECA; + int _v7FED6; + int _v8332A; + int _v8333C; + int _selectedObject; + ScrCategory _category; + int _objectIndex; + bool _released; + + /* + * Constructor + */ + ScreenObjects(MADSEngine *vm); + + /** + * Add a new item to the list + */ + void add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId); + + /** + */ + void check(bool scanFlag); +}; + class ScreenSurface : public MSurface { private: /** diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp index 5a15293222..f46a4c4150 100644 --- a/engines/mads/user_interface.cpp +++ b/engines/mads/user_interface.cpp @@ -151,7 +151,6 @@ void UISlots::draw(bool updateFlag, bool delFlag) { for (uint idx = 0; idx < size(); ++idx) { DirtyArea &dirtyArea = userInterface._dirtyAreas[idx]; - UISlot &slot = (*this)[idx]; if (dirtyArea._active && dirtyArea._textActive && dirtyArea._bounds.width() > 0 && dirtyArea._bounds.height() > 0) { @@ -238,7 +237,7 @@ void UserInterface::load(const Common::String &resName) { void UserInterface::setup(int id) { Scene &scene = _vm->_game->_scene; - if (scene._screenObjects._v832EC != id) { + if (_vm->_game->_screenObjects._v832EC != id) { Common::String resName = _vm->_game->_aaName; // Strip off any extension @@ -256,7 +255,7 @@ void UserInterface::setup(int id) { load(resName); _surface.copyTo(this); } - scene._screenObjects._v832EC = id; + _vm->_game->_screenObjects._v832EC = id; scene._userInterface._uiSlots.clear(); scene._userInterface._uiSlots.fullRefresh(); @@ -279,8 +278,7 @@ void UserInterface::elementHighlighted() { } void UserInterface::drawTextElements() { - Scene &scene = _vm->_game->_scene; - if (scene._screenObjects._v832EC) { + if (_vm->_game->_screenObjects._v832EC) { drawTalkList(); } else { // Draw the actions @@ -406,15 +404,15 @@ void UserInterface::setBounds(const Common::Rect &r) { void UserInterface::loadElements() { Scene &scene = _vm->_game->_scene; Common::Rect bounds; - scene._screenObjects.clear(); + _vm->_game->_screenObjects.clear(); - if (!scene._screenObjects._v832EC) { + if (!_vm->_game->_screenObjects._v832EC) { // Set up screen objects for the inventory scroller for (int idx = 1; idx <= 3; ++idx) { getBounds(CAT_INV_SCROLLER, idx, bounds); moveRect(bounds); - scene._screenObjects.add(bounds, LAYER_GUI, CAT_INV_SCROLLER, idx); + _vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_INV_SCROLLER, idx); } // Set up actions @@ -422,7 +420,7 @@ void UserInterface::loadElements() { getBounds(CAT_ACTION, idx, bounds); moveRect(bounds); - scene._screenObjects.add(bounds, LAYER_GUI, CAT_ACTION, idx); + _vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_ACTION, idx); } // Set up inventory list @@ -430,7 +428,7 @@ void UserInterface::loadElements() { getBounds(CAT_INV_LIST, idx, bounds); moveRect(bounds); - scene._screenObjects.add(bounds, LAYER_GUI, CAT_INV_LIST, idx); + _vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_INV_LIST, idx); } // Set up the inventory vocab list @@ -438,28 +436,28 @@ void UserInterface::loadElements() { getBounds(CAT_INV_VOCAB, idx, bounds); moveRect(bounds); - scene._screenObjects.add(bounds, LAYER_GUI, CAT_INV_VOCAB, idx); + _vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_INV_VOCAB, idx); } // Set up the inventory item picture - scene._screenObjects.add(Common::Rect(160, 159, 231, 194), LAYER_GUI, + _vm->_game->_screenObjects.add(Common::Rect(160, 159, 231, 194), LAYER_GUI, CAT_INV_ANIM, 0); } - if (!scene._screenObjects._v832EC || scene._screenObjects._v832EC == 2) { + if (!_vm->_game->_screenObjects._v832EC || _vm->_game->_screenObjects._v832EC == 2) { for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) { Hotspot &hs = scene._hotspots[hotspotIdx]; - scene._screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx); + _vm->_game->_screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx); } } - if (scene._screenObjects._v832EC == 1) { + if (_vm->_game->_screenObjects._v832EC == 1) { // setup areas for talk entries for (int idx = 0; idx < 5; ++idx) { getBounds(CAT_TALK_ENTRY, idx, bounds); moveRect(bounds); - scene._screenObjects.add(bounds, LAYER_GUI, CAT_TALK_ENTRY, idx); + _vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_TALK_ENTRY, idx); } } } @@ -585,7 +583,7 @@ void UserInterface::noInventoryAnim() { _invSpritesIndex = -1; } - if (!scene._screenObjects._v832EC) + if (!_vm->_game->_screenObjects._v832EC) refresh(); } @@ -599,7 +597,7 @@ void UserInterface::refresh() { void UserInterface::inventoryAnim() { Scene &scene = _vm->_game->_scene; - if (scene._screenObjects._v832EC == 1 || scene._screenObjects._v832EC == 2 + if (_vm->_game->_screenObjects._v832EC == 1 || _vm->_game->_screenObjects._v832EC == 2 || _invSpritesIndex < 0) return; diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h index 07c3f74c31..b4c581d1c2 100644 --- a/engines/mads/user_interface.h +++ b/engines/mads/user_interface.h @@ -31,12 +31,6 @@ namespace MADS { -enum ScrCategory { - CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3, - CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_TALK_ENTRY = 6, CAT_INV_SCROLLER = 7, - CAT_12 = 12 -}; - class UISlot { public: int _slotType; |