diff options
author | Joseph-Eugene Winzer | 2017-12-26 17:54:55 +0100 |
---|---|---|
committer | Thierry Crozat | 2018-01-23 02:15:44 +0000 |
commit | 586162760259fb226dfc8f3a3175f0ac290407b8 (patch) | |
tree | 99c292e12b475f5503f57cc1e3daddd8f5996c26 /engines | |
parent | 996d5c082e8bae3f14c7adf4c4ac94c5ca8ffd30 (diff) | |
download | scummvm-rg350-586162760259fb226dfc8f3a3175f0ac290407b8.tar.gz scummvm-rg350-586162760259fb226dfc8f3a3175f0ac290407b8.tar.bz2 scummvm-rg350-586162760259fb226dfc8f3a3175f0ac290407b8.zip |
SUPERNOVA: Implements money object for inventory
Diffstat (limited to 'engines')
-rw-r--r-- | engines/supernova/msn_def.h | 5 | ||||
-rw-r--r-- | engines/supernova/rooms.cpp | 3 | ||||
-rw-r--r-- | engines/supernova/state.cpp | 26 |
3 files changed, 19 insertions, 15 deletions
diff --git a/engines/supernova/msn_def.h b/engines/supernova/msn_def.h index 8837f1ddcc..874d71e4d0 100644 --- a/engines/supernova/msn_def.h +++ b/engines/supernova/msn_def.h @@ -552,7 +552,10 @@ enum StringID { kStringTelomat18, kStringTelomat19, kStringTelomat20, kStringTelomat21, kStringAlarm, // Add two placeholder strings at the end for variable text - kStringPlaceholder1, kStringPlaceholder2 + kStringPlaceholder1, kStringPlaceholder2, + + // String for money in inventory + kStringInventoryMoney }; static StringID guiCommands[] = { diff --git a/engines/supernova/rooms.cpp b/engines/supernova/rooms.cpp index 0c80d1106d..4f325aa1fc 100644 --- a/engines/supernova/rooms.cpp +++ b/engines/supernova/rooms.cpp @@ -116,6 +116,9 @@ Intro::Intro(SupernovaEngine *vm, GameManager *gm) { _objectState[3] = Object(_id, kStringDiscman, kStringDiscmanDescription, DISCMAN, TAKE | COMBINABLE, 255, 255, 0, NULLROOM, 0); + _objectState[4] = + Object(_id, kStringInventoryMoney, kStringDefaultDescription, MONEY, + TAKE | COMBINABLE, 255, 255, 0); _shouldExit = false; diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp index 347e9dc7f5..71d6bc20d9 100644 --- a/engines/supernova/state.cpp +++ b/engines/supernova/state.cpp @@ -100,6 +100,7 @@ bool GameManager::deserialize(Common::ReadStream *in, int version) { _state._greatFlag = in->readUint16LE(); _state._timeRobot = in->readSint16LE(); _state._money = in->readSint16LE(); + _vm->setGameString(kStringInventoryMoney, Common::String::format("%d Xa", _state._money)); _state._coins = in->readByte(); _state._shoes = in->readByte(); if (version >= 6) @@ -1452,7 +1453,6 @@ void GameManager::takeObject(Object &obj) { if (obj._section != 0) _vm->renderImage(obj._section); - obj.setProperty(CARRIED); obj._click = obj._click2 = 255; _inventory.add(obj); if (_inventory.getSize() > _inventoryScroll + 8) { @@ -1482,6 +1482,7 @@ void GameManager::drawInventory() { _guiInventory[i].width(), _guiInventory[i].height(), _guiInventory[i]._bgColor); + _vm->renderText(_inventory.get(i + _inventoryScroll)->_name, _guiInventory[i]._textPosition.x, _guiInventory[i]._textPosition.y, @@ -1803,20 +1804,17 @@ void GameManager::shot(int a, int b) { } void GameManager::takeMoney(int amount) { + Object *moneyObject = _rooms[INTRO]->getObject(4); _state._money += amount; - if (amount > 0) - great(0); - // TODO: kmaxobject - 1? -// _rooms[OFFICE_R1]->getObject(5)->_name = _rooms[OFFICE_R1]->getObject(kMaxObject - 1); -// _rooms[OFFICE_R1]->object[5].name = &(_rooms[OFFICE_R1]->object[MAX_OBJECT-1]); -// strcpy(_rooms[OFFICE_R1]->object[5].name,ltoa((long)_state.money)); -// strcat(_rooms[OFFICE_R1]->object[5].name," Xa"); - - if (_state._money) { - if (!_rooms[OFFICE_R1]->getObject(5)->hasProperty(CARRIED)) - takeObject(*_rooms[OFFICE_R1]->getObject(5)); - } else - _inventory.remove(*_rooms[OFFICE_R1]->getObject(5)); + _vm->setGameString(kStringInventoryMoney, Common::String::format("%d Xa", _state._money)); + + if (_state._money > 0) { + takeObject(*moneyObject); + if (amount > 0) + great(0); + } else { + _inventory.remove(*moneyObject); + } } void GameManager::drawStatus() { |