From a9536b621fdf636fcc83550ffa34ec939cda0b60 Mon Sep 17 00:00:00 2001 From: lukaslw Date: Thu, 12 Jun 2014 00:49:57 +0200 Subject: PRINCE: Inventory - mouse buttons handling progress --- engines/prince/prince.cpp | 108 +++++++++++++++++++++++++++++++++++++--------- engines/prince/prince.h | 10 ++++- engines/prince/script.cpp | 16 +++++++ engines/prince/script.h | 1 + 4 files changed, 113 insertions(+), 22 deletions(-) diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index e8260c4faf..b432cdc765 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -82,8 +82,8 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) _invLineX(134), _invLineY(176), _invLine(5), _invLines(3), _invLineW(70), _invLineH(76), _maxInvW(72), _maxInvH(76), _invLineSkipX(2), _invLineSkipY(3), _showInventoryFlag(false), _inventoryBackgroundRemember(false), _mst_shadow(0), _mst_shadow2(0), _candleCounter(0), _invX1(53), _invY1(18), _invWidth(536), _invHeight(438), - _invCurInside(false), _optionsFlag(false), _currentMob(0), _optionEnabled(0), _invOptionsNumber(5), - _invExamY(120) { + _invCurInside(false), _optionsFlag(false), _optionEnabled(0), _invOptionsNumber(5), _invExamY(120), + _optionsMob(0), _currentPointerNumber(1), _selectedMob(0), _selectedItem(0), _selectedMode(0) { // Debug/console setup DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel"); @@ -1251,7 +1251,7 @@ void PrinceEngine::drawScreen() { playNextFrame(); if (!_inventoryBackgroundRemember) { - _currentMob = hotspot(_graph->_frontScreen, _mobList); + _selectedMob = hotspot(_graph->_frontScreen, _mobList); showTexts(_graph->_frontScreen); } else { _inventoryBackgroundRemember = false; @@ -1496,54 +1496,122 @@ void PrinceEngine::drawInvItems() { void PrinceEngine::inventoryLeftButton() { if (_optionsFlag == 1) { //check_opt - if (_currentMob != 0) { + if (_selectedMob != 0) { //inv_check_mob if (_optionEnabled < _invOptionsNumber) { _optionsFlag = 0; - // ebp = _currentMob; + //do_option } else { return; } } else { - // test bx, RMBMask 7996 ? right mouse button here? + // test bx, RMBMask 7996 ? right mouse button here? - > return; + //disable_use + if (_currentPointerNumber == 2) { + //disableuseuse + changeCursor(1); + _currentPointerNumber = 1; + //exit_normally + } else { + return; + } } } else { - if (_currentMob != 0) { - //if (_currentPointerNumber != 2) { - if (_currentMob != 29) { + if (_selectedMob != 0) { + if (_currentPointerNumber != 2) { + if (_selectedMob != 29) { _optionEnabled = 0; } else { + // map item _optionEnabled = 1; } //do_option - //} else { + } else { //use_item_on_item - //} + + } + } else { + return; } } //do_option - int selectedMob = _currentMob; // no _currentMob just selectedMob as global for _currentMob.mask ? if (_optionEnabled == 0) { - int invObjExamEvent = _script->scanInvObjExamEvents(selectedMob); // test this + int invObjExamEvent = _script->scanInvObjExamEvents(_selectedMob); // test this if (invObjExamEvent == -1) { // do_standard - printAt(0, 216, _invMobList[selectedMob]._examText.c_str(), kNormalWidth / 2, _invExamY); + printAt(0, 216, _invMobList[_selectedMob]._examText.c_str(), kNormalWidth / 2, _invExamY); showTexts(_graph->_screenForInventory); // here? // setSpecVoice(); + // disableuseuse + changeCursor(0); + _currentPointerNumber = 1; + //exit_normally } else { //store_new_pc // storeNewPC(); - _flags->setFlagValue(Flags::CURRMOB, selectedMob); - _currentMob = 0; - //_optionsMob = 0; + _flags->setFlagValue(Flags::CURRMOB, _selectedMob); + _selectedMob = 0; + _optionsMob = 0; + //bye_inv } - } else { + } else if (_optionEnabled == 1) { // not_examine + int invObjUse = _script->scanInvObjUseEvents(_selectedMob); // test this + if (invObjUse == -1) { + // do_standard_use + _selectedMode = 0; + _selectedItem = _selectedMob; + makeInvCursor(_selectedMob); + _currentPointerNumber = 2; + changeCursor(2); + //exit_normally + } else { + //store_new_pc + // storeNewPC(); + _flags->setFlagValue(Flags::CURRMOB, _selectedMob); + _selectedMob = 0; + _optionsMob = 0; + //bye_inv + } + } else if (_optionEnabled == 4) { + // not_use_inv + // do_standard_give + _selectedMode = 1; + _selectedItem = _selectedMob; + makeInvCursor(_selectedMob); + _currentPointerNumber = 2; + changeCursor(2); + //exit_normally + } else { + // use_item_on_item } + //exit_normally + _selectedMob = 0; + _optionsMob = 0; } void PrinceEngine::inventoryRightButton() { + enableOptions(); +} + +void PrinceEngine::enableOptions() { + if (_optionsFlag != 1) { + changeCursor(1); + _currentPointerNumber = 1; + if (_selectedMob != 0) { + //if (_mobType != 0x100) { + _optionsMob = _selectedMob; + // test opt sprite here + //_optionsX = + //_optionsY = + _optionsFlag = 1; + //} + } + } +} + +void PrinceEngine::checkInvOptions() { } @@ -1589,7 +1657,7 @@ void PrinceEngine::displayInventory() { break; } - _currentMob = hotspot(_graph->_screenForInventory, _invMobList); + _selectedMob = hotspot(_graph->_screenForInventory, _invMobList); Common::Event event; Common::EventManager *eventMan = _system->getEventManager(); @@ -1627,7 +1695,7 @@ void PrinceEngine::displayInventory() { } } -void PrinceEngine::makeInvCursor() { +void PrinceEngine::makeInvCursor(int itemNr) { } diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 46c573b0a6..fb30d90918 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -273,7 +273,10 @@ public: void showMask(int maskNr, Graphics::Surface *originalRoomSurface); void clsMasks(); - int _currentMob; // number of selected Mob / inventory item + int _selectedMob; // number of selected Mob / inventory item + int _selectedItem; // number of item on mouse cursor + int _selectedMode; + int _currentPointerNumber; static const int16 kMaxInv = 90; // max amount of inventory items in whole game @@ -283,6 +286,7 @@ public: bool _showInventoryFlag; bool _optionsFlag; int _optionEnabled; + int _optionsMob; int _invOptionsNumber; int _invExamY; bool _inventoryBackgroundRemember; @@ -312,7 +316,9 @@ public: void drawInvItems(); void displayInventory(); void addInvObj(); - void makeInvCursor(); + void makeInvCursor(int itemNr); + void enableOptions(); + void checkInvOptions(); void inventoryLeftButton(); void inventoryRightButton(); diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 4eed60d7e5..9c915ca6bc 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -226,6 +226,22 @@ int Script::scanInvObjExamEvents(int mobMask) { return -1; // or sth else? } +int Script::scanInvObjUseEvents(int mobMask) { + RE tempRE; + int i = 0; + do { + tempRE._mob = (int)READ_UINT16(&_data[_scriptInfo.invObjUse + i * 6]); + debug("mob: %d", tempRE._mob); + tempRE._code = (int)READ_UINT32(&_data[_scriptInfo.invObjUse + i * 6 + 2]); + debug("code: %d", tempRE._code); + if (tempRE._mob == mobMask) { + return tempRE._code; + } + i++; + } while (tempRE._mob != -1); //?? || i <= 1 or without this (no items there) + return -1; // or sth else? +} + void Script::installSingleBackAnim(Common::Array &_backanimList, int offset) { BackgroundAnim newBackgroundAnim; diff --git a/engines/prince/script.h b/engines/prince/script.h index 06b09b94c4..d53f951859 100644 --- a/engines/prince/script.h +++ b/engines/prince/script.h @@ -138,6 +138,7 @@ public: bool loadAllMasks(Common::Array &maskList, int offset); int scanInvObjExamEvents(int mobMask); + int scanInvObjUseEvents(int mobMask); const char *getString(uint32 offset) { return (const char *)(&_data[offset]); -- cgit v1.2.3