aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBastien Bouclet2018-06-17 14:44:31 +0200
committerBastien Bouclet2018-06-29 13:31:54 +0200
commit2e8d08c1d0d626b1dd9c69c951de07aec7fd4bb4 (patch)
tree9cef8c38650cd5605ac40cde4173e562ab890ebe /engines
parent0ca52f62a4b475081f77eb933934c8f3448f33e2 (diff)
downloadscummvm-rg350-2e8d08c1d0d626b1dd9c69c951de07aec7fd4bb4.tar.gz
scummvm-rg350-2e8d08c1d0d626b1dd9c69c951de07aec7fd4bb4.tar.bz2
scummvm-rg350-2e8d08c1d0d626b1dd9c69c951de07aec7fd4bb4.zip
MOHAWK: RIVEN: Add a save button to the main menu
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/riven_card.cpp46
-rw-r--r--engines/mohawk/riven_card.h2
-rw-r--r--engines/mohawk/riven_stack.cpp32
-rw-r--r--engines/mohawk/riven_stack.h11
-rw-r--r--engines/mohawk/riven_stacks/aspit.cpp43
-rw-r--r--engines/mohawk/riven_stacks/aspit.h7
6 files changed, 130 insertions, 11 deletions
diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp
index 031a88163b..d2f8d4f42d 100644
--- a/engines/mohawk/riven_card.cpp
+++ b/engines/mohawk/riven_card.cpp
@@ -25,6 +25,7 @@
#include "mohawk/cursors.h"
#include "mohawk/riven_graphics.h"
#include "mohawk/riven_stack.h"
+#include "mohawk/riven_stacks/aspit.h"
#include "mohawk/riven_video.h"
#include "mohawk/resource.h"
@@ -81,6 +82,7 @@ void RivenCard::applyPatches(uint16 id) {
}
applyPropertiesPatch22118(globalId);
+ applyPropertiesPatchE2E(globalId);
}
void RivenCard::applyPropertiesPatch8EB7(uint32 globalId) {
@@ -390,6 +392,50 @@ void RivenCard::applyPropertiesPatch22118(uint32 globalId) {
}
}
+void RivenCard::applyPropertiesPatchE2E(uint32 globalId) {
+ // The main menu in the Myst 25th anniversary version is patched to include new items:
+ // - Save game
+ if (globalId == 0xE2E) {
+ uint16 patchData[] = {
+ 24, // blstId
+ 0xFFFF, // name
+ 485, // left
+ 311, // top
+ 602, // right
+ 326, // bottom
+ 0, // u0
+ kRivenMainCursor, // cursor
+ 4, // index
+ 0xFFFF, // transition offset
+ 0, // flags
+ 2, // script count
+
+ kMouseDownScript, // script type
+ 1, // command count
+ kRivenCommandRunExternal, // command type
+ 2, // argument count
+ RivenStacks::ASpit::kExternalSaveGame, // external command name id
+ 0, // external argument count
+
+ kMouseInsideScript, // script type
+ 1, // command count
+ kRivenCommandChangeCursor, // command type
+ 1, // argument count
+ kRivenOpenHandCursor // cursor
+ };
+
+ // Script data is expected to be in big endian
+ for (uint i = 0; i < ARRAYSIZE(patchData); i++) {
+ patchData[i] = TO_BE_16(patchData[i]);
+ }
+
+ // Add the new hotspot to the existing ones
+ Common::MemoryReadStream patchStream((const byte *)(patchData), ARRAYSIZE(patchData) * sizeof(uint16));
+ RivenHotspot *newHotspot = new RivenHotspot(_vm, &patchStream);
+ _hotspots.push_back(newHotspot);
+ }
+}
+
void RivenCard::enter(bool unkMovies) {
setCurrentCardVariable();
diff --git a/engines/mohawk/riven_card.h b/engines/mohawk/riven_card.h
index 2b6a8d41bf..f285ba1a1b 100644
--- a/engines/mohawk/riven_card.h
+++ b/engines/mohawk/riven_card.h
@@ -192,6 +192,8 @@ private:
Common::Array<MLSTRecord> _movieList;
Common::Array<HotspotEnableRecord> _hotspotEnableList;
Common::Array<WaterEffectRecord> _waterEffectList;
+
+ void applyPropertiesPatchE2E(uint32 globalId);
};
struct MLSTRecord {
diff --git a/engines/mohawk/riven_stack.cpp b/engines/mohawk/riven_stack.cpp
index 7d3d1057a3..2a9fb7fbad 100644
--- a/engines/mohawk/riven_stack.cpp
+++ b/engines/mohawk/riven_stack.cpp
@@ -101,6 +101,28 @@ int16 RivenStack::getIdFromName(RivenNameResource nameResource, const Common::St
}
}
+void RivenStack::registerName(RivenNameResource nameResource, uint16 nameId, const Common::String &name) {
+ switch (nameResource) {
+ case kVariableNames:
+ _varNames.registerName(nameId, name);
+ break;
+ case kExternalCommandNames:
+ _externalCommandNames.registerName(nameId, name);
+ break;
+ case kStackNames:
+ _stackNames.registerName(nameId, name);
+ break;
+ case kCardNames:
+ _cardNames.registerName(nameId, name);
+ break;
+ case kHotspotNames:
+ _hotspotNames.registerName(nameId, name);
+ break;
+ default:
+ error("Unknown name resource %d", nameResource);
+ }
+}
+
void RivenStack::loadCardIdMap() {
Common::SeekableReadStream *rmapStream = _vm->getResource(ID_RMAP, 1);
@@ -509,6 +531,16 @@ int16 RivenNameList::getNameId(const Common::String &name) const {
return -1;
}
+void RivenNameList::registerName(uint16 nameId, const Common::String &name) {
+ if (nameId >= _names.size()) {
+ _names.resize(nameId + 1);
+ }
+
+ _names[nameId] = name;
+
+ // We don't add the name to _index, getNameId does not work for names added this way
+}
+
namespace RivenStacks {
static const char *names[] = {
"<unknown>",
diff --git a/engines/mohawk/riven_stack.h b/engines/mohawk/riven_stack.h
index 2af63b2838..8ab18a5f6f 100644
--- a/engines/mohawk/riven_stack.h
+++ b/engines/mohawk/riven_stack.h
@@ -64,6 +64,14 @@ public:
*/
int16 getNameId(const Common::String &name) const;
+ /**
+ * Add a name id => name mapping
+ *
+ * The implementation of the method is currently limited and
+ * does not allow retrieving an id from the name.
+ */
+ void registerName(uint16 nameId, const Common::String &name);
+
private:
void loadResource(MohawkEngine_Riven *vm, uint16 id);
@@ -114,6 +122,9 @@ public:
*/
int16 getIdFromName(RivenNameResource nameResource, const Common::String &name) const;
+ /** Add a name id => name mapping in a name list */
+ void registerName(RivenNameResource nameResource, uint16 nameId, const Common::String &name);
+
/** Get the id of a card in the card from its global identifier */
uint16 getCardStackId(uint32 globalId) const;
diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp
index 1c6f330b64..893221244c 100644
--- a/engines/mohawk/riven_stacks/aspit.cpp
+++ b/engines/mohawk/riven_stacks/aspit.cpp
@@ -64,13 +64,16 @@ ASpit::ASpit(MohawkEngine_Riven *vm) :
REGISTER_COMMAND(ASpit, xaenablemenuintro);
REGISTER_COMMAND(ASpit, xademoquit);
REGISTER_COMMAND(ASpit, xaexittomain);
+
+ REGISTER_COMMAND(ASpit, xaSaveGame);
+ registerName(kExternalCommandNames, kExternalSaveGame, "xaSaveGame");
}
static const char *menuItems[] = {
"SETUP",
"START NEW GAME",
"START SAVED GAME",
- 0
+ "SAVE GAME"
};
void ASpit::xastartupbtnhide(const ArgumentArray &args) {
@@ -79,10 +82,6 @@ void ASpit::xastartupbtnhide(const ArgumentArray &args) {
warning("xastartupbtnhide");
- Graphics::Surface surface;
- surface.create(115, 200, _vm->_gfx->getBackScreen()->format);
- surface.fillRect(Common::Rect(0, 0, 115, 200), 0);
-
Common::File file;
const char *fontname = "FreeSans.ttf";
@@ -104,14 +103,31 @@ void ASpit::xastartupbtnhide(const ArgumentArray &args) {
font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
}
- int y = 70;
+ struct MenuItem {
+ uint16 blstId;
+ };
- for (const char **item = menuItems; *item; item++) {
- font->drawString(&surface, *item, 0, y, surface.w, 0xffffff);
- y += fontHeight * 2.5;
- }
+ MenuItem items[] = {
+ { 22 },
+ { 16 },
+ { 23 },
+ { 24 }
+ };
+
+ for (uint i = 0; i < ARRAYSIZE(items); i++) {
+ RivenHotspot *hotspot = _vm->getCard()->getHotspotByBlstId(items[i].blstId);
+ Common::Rect hotspotRect = hotspot->getRect();
+
+ Graphics::Surface surface;
+ surface.create(hotspotRect.width(), hotspotRect.height(), _vm->_gfx->getBackScreen()->format);
+
+ uint32 textColor = surface.format.RGBToColor(164, 164, 164);
- _vm->_gfx->copySurfaceToScreen(&surface, 485, 160);
+ font->drawString(&surface, menuItems[i], 0, 0, surface.w, textColor);
+
+ _vm->_gfx->copySurfaceToScreen(&surface, hotspotRect.left, hotspotRect.top);
+ surface.free();
+ }
}
void ASpit::xasetupcomplete(const ArgumentArray &args) {
@@ -324,6 +340,11 @@ void ASpit::xarestoregame(const ArgumentArray &args) {
_vm->runLoadDialog();
}
+void ASpit::xaSaveGame(const ArgumentArray &args) {
+ // Launch the load game dialog
+ _vm->runSaveDialog();
+}
+
void ASpit::xadisablemenureturn(const ArgumentArray &args) {
// This function would normally enable the Windows menu item for
// returning to the main menu. Ctrl+r will do this instead.
diff --git a/engines/mohawk/riven_stacks/aspit.h b/engines/mohawk/riven_stacks/aspit.h
index b2e5301dad..75b9fd3e64 100644
--- a/engines/mohawk/riven_stacks/aspit.h
+++ b/engines/mohawk/riven_stacks/aspit.h
@@ -35,6 +35,10 @@ class ASpit : public RivenStack {
public:
ASpit(MohawkEngine_Riven *vm);
+ enum PatchedExternalCommandNameId {
+ kExternalSaveGame = 20
+ };
+
// External commands - Main Menu
void xastartupbtnhide(const ArgumentArray &args);
void xasetupcomplete(const ArgumentArray &args);
@@ -59,6 +63,9 @@ public:
// External commands - DVD-specific
void xarestoregame(const ArgumentArray &args);
+ // External commands - ScummVM 25th anniversary specific
+ void xaSaveGame(const ArgumentArray &args);
+
// External commands - Demo-specific
void xadisablemenureturn(const ArgumentArray &args);
void xaenablemenureturn(const ArgumentArray &args);