MACVENTURE: Fix startup loading bug

This commit is contained in:
Borja Lorente 2016-08-02 13:58:16 +02:00
parent f0dde375c1
commit d1a31ff5db
3 changed files with 21 additions and 5 deletions

View File

@ -951,6 +951,13 @@ Graphics::MacWindow * Gui::findWindow(WindowReference reference) {
return nullptr;
}
void Gui::ensureInventoryOpen(WindowReference reference, ObjID id) {
assert(reference < 0x80 && reference >= kInventoryStart);
if (reference - kInventoryStart == _inventoryWindows.size()) {
createInventoryWindow(id);
}
}
WindowReference Gui::getObjWindow(ObjID objID) {
switch (objID) {
case 0xfffc: return kExitsWindow;

View File

@ -106,7 +106,6 @@ public:
void updateWindow(WindowReference winID, bool containerOpen);
void invertWindowColors(WindowReference winID);
WindowReference createInventoryWindow(ObjID objRef);
bool tryCloseWindow(WindowReference winID);
@ -138,6 +137,7 @@ public:
void bringToFront(WindowReference window);
void setWindowTitle(WindowReference winID, Common::String string);
void updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array<ObjID> &children);
void ensureInventoryOpen(WindowReference reference, ObjID id);
void addChild(WindowReference target, ObjID child);
void removeChild(WindowReference target, ObjID child);

View File

@ -24,6 +24,7 @@
#include "common/debug-channels.h"
#include "common/debug.h"
#include "common/error.h"
#include "common/config-manager.h"
#include "engines/util.h"
#include "macventure/macventure.h"
@ -129,11 +130,18 @@ Common::Error MacVentureEngine::run() {
_destObject = 0;
_prepared = true;
_cmdReady = true;
int directSaveSlotLoading = ConfMan.getInt("save_slot");
if (directSaveSlotLoading >= 0) {
if (loadGameState(directSaveSlotLoading).getCode() != Common::kNoError) {
error("Could not load game from slot '%d'", directSaveSlotLoading);
}
} else {
_cmdReady = true;
ObjID playerParent = _world->getObjAttr(1, kAttrParentObject);
_currentSelection.push_back(playerParent);// Push the parent of the player
_world->setObjAttr(playerParent, kAttrContainerOpen, 1);
}
_selectedControl = kStartOrResume;
ObjID playerParent = _world->getObjAttr(1, kAttrParentObject);
_currentSelection.push_back(playerParent);// Push the parent of the player
_world->setObjAttr(playerParent, kAttrContainerOpen, 1);
_gui->addChild(kSelfWindow, 1);
_gui->updateWindow(kSelfWindow, false);
@ -194,6 +202,7 @@ void MacVentureEngine::resetInternals() {
void MacVentureEngine::resetGui() {
_gui->updateWindowInfo(kMainGameWindow, getParent(1), _world->getChildren(getParent(1), true));
// HACK! should update all inventories
_gui->ensureInventoryOpen(kInventoryStart, 1);
_gui->updateWindowInfo(kInventoryStart, 1, _world->getChildren(1, true));
updateControls();
updateExits();