aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorwhiterandrek2018-05-25 17:45:18 +0300
committerEugene Sandulenko2018-06-28 23:51:32 +0200
commit9b5dac452df50deb9b01b8c49b911c7c91a41643 (patch)
treec3501fdb88acd12c7ce16f0288c4287cea88fd98 /engines
parent04a0c4ead6e76f4eb4dcef8faa1d8d3138465289 (diff)
downloadscummvm-rg350-9b5dac452df50deb9b01b8c49b911c7c91a41643.tar.gz
scummvm-rg350-9b5dac452df50deb9b01b8c49b911c7c91a41643.tar.bz2
scummvm-rg350-9b5dac452df50deb9b01b8c49b911c7c91a41643.zip
PINK: add state saving/loading of Inventory
Diffstat (limited to 'engines')
-rw-r--r--engines/pink/objects/inventory.cpp33
-rw-r--r--engines/pink/objects/inventory.h3
2 files changed, 35 insertions, 1 deletions
diff --git a/engines/pink/objects/inventory.cpp b/engines/pink/objects/inventory.cpp
index 13d0dfdc6f..4a7d02d9be 100644
--- a/engines/pink/objects/inventory.cpp
+++ b/engines/pink/objects/inventory.cpp
@@ -118,7 +118,7 @@ bool InventoryMgr::start(bool playOpening) {
_rightArrow = _lead->getPage()->findActor(kInventoryRightArrowActor);
_leftArrow = _lead->getPage()->findActor(kInventoryLeftArrowActor);
- if (playOpening){
+ if (playOpening) {
_window->setAction(kOpenAction);
_state = kOpening;
}
@@ -195,4 +195,35 @@ InventoryItem *InventoryMgr::getCurrentItem() {
return _item;
}
+void InventoryMgr::loadState(Archive &archive) {
+ _state = (State) archive.readByte();
+ _isClickedOnItem = archive.readByte();
+
+ for (uint i = 0; i < _items.size(); ++i) {
+ _items[i]->_currentOwner = archive.readString();
+ }
+
+ const Common::String currItemName = archive.readString();
+ if (!currItemName.empty()) {
+ _item = nullptr;
+ _isClickedOnItem = 0;
+ } else {
+ _item = findInventoryItem(currItemName);
+ }
+}
+
+void InventoryMgr::saveState(Archive &archive) {
+ archive.writeByte(_state);
+ archive.writeByte(_isClickedOnItem);
+
+ for (uint i = 0; i < _items.size(); ++i) {
+ archive.writeString(_items[i]->_currentOwner);
+ }
+
+ if (_item)
+ archive.writeString(_item->_currentOwner);
+ else
+ archive.writeString(Common::String());
+}
+
} // End of namespace Pink
diff --git a/engines/pink/objects/inventory.h b/engines/pink/objects/inventory.h
index f09e1e8161..104a8e80cb 100644
--- a/engines/pink/objects/inventory.h
+++ b/engines/pink/objects/inventory.h
@@ -53,6 +53,9 @@ public:
virtual void deserialize(Archive &archive);
virtual void toConsole();
+ void loadState(Archive &archive);
+ void saveState(Archive &archive);
+
void update();
void onClick(Common::Point point);