diff options
author | Borja Lorente | 2016-07-16 19:57:36 +0200 |
---|---|---|
committer | Borja Lorente | 2016-08-14 18:55:17 +0200 |
commit | a06f291280e0897beed18e63e269938dfa45ccef (patch) | |
tree | fa589f2c5cdda38677f343c89429aa8cce71a903 /engines/macventure/gui.cpp | |
parent | 734b453c86bb20b2cb52c4f695f8a770b97be459 (diff) | |
download | scummvm-rg350-a06f291280e0897beed18e63e269938dfa45ccef.tar.gz scummvm-rg350-a06f291280e0897beed18e63e269938dfa45ccef.tar.bz2 scummvm-rg350-a06f291280e0897beed18e63e269938dfa45ccef.zip |
MACVENTURE: Add basic game save/load feature
Diffstat (limited to 'engines/macventure/gui.cpp')
-rw-r--r-- | engines/macventure/gui.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp index d8deb4b568..6c9ccf6a2f 100644 --- a/engines/macventure/gui.cpp +++ b/engines/macventure/gui.cpp @@ -335,8 +335,8 @@ WindowReference Gui::createInventoryWindow(ObjID objRef) { newWindow->setDimensions(newData.bounds); newWindow->setCallback(inventoryWindowCallback, this); - //loadBorder(newWindow, "border_no_scroll_inac.bmp", false); - //loadBorder(newWindow, "border_no_scroll_act.bmp", true); + loadBorder(newWindow, "border_no_scroll_inac.bmp", false); + loadBorder(newWindow, "border_no_scroll_act.bmp", true); _inventoryWindows.push_back(newWindow); debug("Create new inventory window. Reference: %d", newData.refcon); @@ -686,13 +686,12 @@ void Gui::drawWindowTitle(WindowReference target, Graphics::ManagedSurface * sur } void Gui::drawDraggedObject() { - if (_draggedObj.id != 0) { + if (_draggedObj.id != 0 && + _engine->isObjVisible(_draggedObj.id)) { ensureAssetLoaded(_draggedObj.id); ImageAsset *asset = _assets[_draggedObj.id]; _draggedSurface.create(asset->getWidth(), asset->getHeight(), _screen.format); - _screen.copyRectToSurface(_draggedSurface, _draggedObj.pos.x, _draggedObj.pos.y, - Common::Rect(asset->getWidth() - 1, asset->getHeight() - 1)); asset->blitInto(&_draggedSurface, 0, 0, kBlitBIC); @@ -820,6 +819,14 @@ void Gui::getTextFromUser() { _engine->clickToContinue(); } +void Gui::loadGame(int slot) { + _engine->loadGameState(slot); +} + +void Gui::saveInto(int slot) { + _engine->saveGameState(slot, "desc"); + _engine->preparedToRun(); +} void Gui::moveDraggedObject(Common::Point target) { Common::Point newPos = target + _draggedObj.mouseOffset; @@ -857,9 +864,11 @@ WindowReference Gui::findWindowAtPoint(Common::Point point) { Graphics::MacWindow *win; for (it = _windowData->begin(); it != _windowData->end(); it++) { win = findWindow(it->refcon); - if (win && win->getDimensions().contains(point) && it->refcon != kDiplomaWindow) { //HACK, diploma should be cosnidered - if (win->isActive()) - return it->refcon; + if (win && it->refcon != kDiplomaWindow) { //HACK, diploma should be cosnidered + if (win->getDimensions().contains(point)) { + if (win->isActive()) + return it->refcon; + } } } return kNoWindow; @@ -869,6 +878,7 @@ Common::Point Gui::getWindowSurfacePos(WindowReference reference) { const WindowData &data = getWindowData(reference); BorderBounds border = borderBounds(data.type); Graphics::MacWindow *win = findWindow(reference); + if (!win) return Common::Point(0, 0); return Common::Point(win->getDimensions().left + border.leftOffset, win->getDimensions().top + border.topOffset); } @@ -976,9 +986,9 @@ void Gui::selectDraggable(ObjID child, WindowReference origin, Common::Point cli } void Gui::handleDragRelease(Common::Point pos, bool shiftPressed, bool isDoubleClick) { - WindowReference destinationWindow = findWindowAtPoint(pos); - if (destinationWindow == kNoWindow) return; if (_draggedObj.id != 0) { + WindowReference destinationWindow = findWindowAtPoint(pos); + if (destinationWindow == kNoWindow) return; if (_draggedObj.hasMoved) { ObjID destObject = getWindowData(destinationWindow).objRef; pos -= (_draggedObj.startPos - _draggedObj.mouseOffset); @@ -1027,9 +1037,11 @@ void Gui::handleMenuAction(MenuAction action) { break; case MacVenture::kMenuActionOpen: debug("MacVenture Menu Action: Open"); + loadGame(0); break; case MacVenture::kMenuActionSave: debug("MacVenture Menu Action: Save"); + saveInto(0); break; case MacVenture::kMenuActionSaveAs: debug("MacVenture Menu Action: Save As"); @@ -1139,8 +1151,8 @@ bool Gui::tryCloseWindow(WindowReference winID) { Common::Point Gui::getObjMeasures(ObjID obj) { ensureAssetLoaded(obj); - int w = MAX(0, (int)_assets[obj]->getWidth()); - int h = MAX(0, (int)_assets[obj]->getHeight()); + int w = _assets[obj]->getWidth(); + int h = _assets[obj]->getHeight(); return Common::Point(w, h); } @@ -1296,7 +1308,7 @@ void Gui::processCursorTick() { void Gui::handleSingleClick(Common::Point pos) { debug("Single Click"); - // HACK + // HACK THERE HAS TO BE A MORE ELEGANT WAY if (_dialog) return; handleDragRelease(pos, false, false); } |