diff options
Diffstat (limited to 'engines/mads/screen.cpp')
-rw-r--r-- | engines/mads/screen.cpp | 106 |
1 files changed, 106 insertions, 0 deletions
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; } |