From 39a36064ac91ad7864c04dfe4d88c97824f070ae Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 16 Mar 2014 17:50:47 -0400 Subject: [PATCH] MADS: In progress text draw methods for user interface --- engines/mads/scene.cpp | 2 +- engines/mads/scene_data.cpp | 9 ++++---- engines/mads/user_interface.cpp | 40 ++++++++++++++++++++++++++++++--- engines/mads/user_interface.h | 28 ++++++++++++++++++++++- 4 files changed, 69 insertions(+), 10 deletions(-) diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 9ece16fab56..0258f15bb87 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -393,7 +393,7 @@ void Scene::doFrame() { // Write any text needed by the interface if (_vm->_game->_abortTimers2) - _userInterface.writeText(); + _userInterface.drawTextElements(); // Draw any elements drawElements((ScreenTransition)_vm->_game->_abortTimers2, _vm->_game->_abortTimers2); diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index 04dfc4be44a..bbc6e1c3b5e 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -45,7 +45,6 @@ ScreenObjects::ScreenObjects(MADSEngine *vm): _vm(vm) { _v7FECA = 0; _v7FED6 = 0; _v8332A = 0; - _selectedObject = 0; _category = CAT_NONE; _objectIndex = 0; _released = false; @@ -70,10 +69,10 @@ void ScreenObjects::check(bool scanFlag) { _v7FECA = false; if ((_vm->_events->_vD6 || _v8332A || _yp || _v8333C) && scanFlag) { - _selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI); - if (_selectedObject > 0) { - _category = (ScrCategory)((*this)[_selectedObject - 1]._category & 7); - _objectIndex = (*this)[_selectedObject - 1]._descId; + scene._userInterface._selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI); + if (scene._userInterface._selectedObject > 0) { + _category = (ScrCategory)((*this)[scene._userInterface._selectedObject - 1]._category & 7); + _objectIndex = (*this)[scene._userInterface._selectedObject - 1]._descId; } // Handling for easy mouse diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp index 3b3fc9379ae..9cff2217c18 100644 --- a/engines/mads/user_interface.cpp +++ b/engines/mads/user_interface.cpp @@ -41,6 +41,7 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) { _screenObjectsCount = 0; _inventoryTopIndex = 0; _objectY = 0; + _selectedObject = -1; byte *pData = _vm->_screen.getBasePtr(0, MADS_SCENE_HEIGHT); setPixels(pData, MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT); @@ -106,7 +107,7 @@ void UserInterface::setup(int id) { scene._imageInterEntries.call(0, 0); scene._action.clear(); - writeText(); + drawTextElements(); loadElements(); scene._dynamicHotspots.refresh(); } @@ -115,10 +116,38 @@ void UserInterface::elementHighlighted() { warning("TODO: UserInterface::elementHighlighted"); } -void UserInterface::writeText() { - warning("TODO: UserInterface::writeText"); +void UserInterface::drawTextElements() { + Scene &scene = _vm->_game->_scene; + if (scene._screenObjects._v832EC) { + drawTalkList(); + } else { + // Draw the actions + drawActions(); + drawInventoryList(); + drawItemVocabList(); + } } +void UserInterface::drawActions() { + for (int idx = 0; idx < 10; ++idx) { + drawVocab(CAT_ACTION, idx); + } +} + +void UserInterface::drawInventoryList() { + int endIndex = MIN((int)_vm->_game->_objects._inventoryList.size(), _inventoryTopIndex + 5); + for (int idx = _inventoryTopIndex; idx < endIndex; ++idx) { + drawVocab(CAT_INV_LIST, idx); + } +} + +void UserInterface::drawItemVocabList() { + +} + +void UserInterface::drawVocab(ScrCategory category, int id) { + +} void UserInterface::setBounds(const Common::Rect &r) { _bounds = r; @@ -273,4 +302,9 @@ void UserInterface::moveRect(Common::Rect &bounds) { bounds.translate(0, MADS_SCENE_HEIGHT); } +void UserInterface::drawTalkList() { + warning("TODO: drawTalkList"); +} + + } // End of namespace MADS diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h index d50a8205639..e3a1b2098e4 100644 --- a/engines/mads/user_interface.h +++ b/engines/mads/user_interface.h @@ -54,6 +54,31 @@ private: * Reposition a bounding rectangle to physical co-ordinates */ void moveRect(Common::Rect &bounds); + + /** + * Draw options during a conversation. + */ + void drawTalkList(); + + /** + * Draw the action list + */ + void drawActions(); + + /** + * Draw the inventory list + */ + void drawInventoryList(); + + /** + * Draw the inventory item vocab list + */ + void drawItemVocabList(); + + /** + * Draw a vocab text entry + */ + void drawVocab(ScrCategory category, int id); public: ScrCategory _category; int _screenObjectsCount; @@ -62,6 +87,7 @@ public: MSurface _surface; int _inventoryTopIndex; int _objectY; + int _selectedObject; public: /** * Constructor @@ -80,7 +106,7 @@ public: void elementHighlighted(); - void writeText(); + void drawTextElements(); void setBounds(const Common::Rect &r); };