diff options
author | Paul Gilbert | 2014-08-24 12:32:11 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-08-24 12:32:11 -0400 |
commit | 89a3c43da1318644b14531b69ed1b38708a6413a (patch) | |
tree | da2628c6963a4bef68ca83027972bb2334197ce8 /engines/access/inventory.cpp | |
parent | 1073646c8e20940ec606edac06ffd3e2eb015f49 (diff) | |
download | scummvm-rg350-89a3c43da1318644b14531b69ed1b38708a6413a.tar.gz scummvm-rg350-89a3c43da1318644b14531b69ed1b38708a6413a.tar.bz2 scummvm-rg350-89a3c43da1318644b14531b69ed1b38708a6413a.zip |
ACCESS: More work on inventory screen setup
Diffstat (limited to 'engines/access/inventory.cpp')
-rw-r--r-- | engines/access/inventory.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 6c56f6b90b..80336e4dcc 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -54,6 +54,11 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { for (uint i = 0; i < _inv.size(); ++i) _names.push_back(names[i]); + + for (uint i = 0; i < 26; ++i) { + const int *r = INVCOORDS[i]; + _invCoords.push_back(Common::Rect(r[0], r[1], r[0] + r[2], r[1] + r[3])); + } } int &InventoryManager::operator[](int idx) { @@ -95,7 +100,7 @@ int InventoryManager::newDisplayInv() { getList(); initFields(); - files.loadScreen(99, 0); + _vm->_files->loadScreen(&_vm->_buffer1, 99, 0); _vm->_buffer1.copyTo(&_vm->_buffer2); _vm->copyBF2Vid(); @@ -267,9 +272,26 @@ void InventoryManager::putInvIcon(int itemIndex, int itemId) { } void InventoryManager::chooseItem() { + EventsManager &events = *_vm->_events; _vm->_useItem = -1; - - error("TODO: chooseItem"); + int selIndex; + + while (!_vm->shouldQuit()) { + g_system->delayMillis(10); + + // Poll events and wait for a click on a known area + events.pollEvents(); + if (!events._leftButton || ((selIndex = coordIndexOf()) == -1)) + continue; + + if (selIndex > 23) { + if (selIndex == 25) + _vm->_useItem = -1; + break; + } else if (selIndex < (int)_items.size()) { + warning("TODO: Combine items"); + } + } } void InventoryManager::freeInvCells() { @@ -277,4 +299,16 @@ void InventoryManager::freeInvCells() { _vm->_objectsTable[99] = nullptr; } +int InventoryManager::coordIndexOf() { + const Common::Point pt = _vm->_events->_mousePos; + + for (int i = 0; i < (int)_invCoords.size(); ++i) { + if (_invCoords[i].contains(pt)) + return i; + } + + return -1; +} + + } // End of namespace Access |