mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 14:51:40 +00:00
MOHAWK: Move the resource names to RivenStack
This commit is contained in:
parent
f752066a8e
commit
3c8decec0a
@ -44,6 +44,7 @@
|
||||
#include "mohawk/riven_card.h"
|
||||
#include "mohawk/riven_external.h"
|
||||
#include "mohawk/riven_sound.h"
|
||||
#include "mohawk/riven_stack.h"
|
||||
#endif
|
||||
|
||||
namespace Mohawk {
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "mohawk/riven_graphics.h"
|
||||
#include "mohawk/riven_saveload.h"
|
||||
#include "mohawk/riven_sound.h"
|
||||
#include "mohawk/riven_stack.h"
|
||||
#include "mohawk/dialogs.h"
|
||||
#include "mohawk/video.h"
|
||||
#include "mohawk/console.h"
|
||||
@ -305,9 +306,6 @@ void MohawkEngine_Riven::changeToStack(uint16 n) {
|
||||
if (_stack && _stack->getId() == n && !_mhk.empty())
|
||||
return;
|
||||
|
||||
delete _stack;
|
||||
_stack = new RivenStack(this, n);
|
||||
|
||||
// Stop any videos playing
|
||||
_video->stopVideos();
|
||||
_video->clearMLST();
|
||||
@ -338,15 +336,11 @@ void MohawkEngine_Riven::changeToStack(uint16 n) {
|
||||
if (_mhk.empty())
|
||||
error("Could not load stack %s", getStackName(n).c_str());
|
||||
|
||||
// Load stack specific names
|
||||
_varNames = RivenNameList(this, kVariableNames);
|
||||
_externalCommandNames = RivenNameList(this, kExternalCommandNames);
|
||||
_stackNames = RivenNameList(this, kStackNames);
|
||||
_cardNames = RivenNameList(this, kCardNames);
|
||||
_hotspotNames = RivenNameList(this, kHotspotNames);
|
||||
|
||||
// Stop any currently playing sounds
|
||||
_sound->stopAllSLST();
|
||||
|
||||
delete _stack;
|
||||
_stack = new RivenStack(this, n);
|
||||
}
|
||||
|
||||
// Riven uses some hacks to change stacks for linking books
|
||||
@ -828,7 +822,7 @@ void MohawkEngine_Riven::checkSunnerAlertClick() {
|
||||
}
|
||||
|
||||
void MohawkEngine_Riven::addZipVisitedCard(uint16 cardId, uint16 cardNameId) {
|
||||
Common::String cardName = getName(kCardNames, cardNameId);
|
||||
Common::String cardName = getCurStack()->getName(kCardNames, cardNameId);
|
||||
if (cardName.empty())
|
||||
return;
|
||||
ZipMode zip;
|
||||
@ -851,40 +845,6 @@ bool MohawkEngine_Riven::isZipVisitedCard(const Common::String &hotspotName) con
|
||||
return foundMatch;
|
||||
}
|
||||
|
||||
Common::String MohawkEngine_Riven::getName(uint16 nameResource, uint16 nameID) {
|
||||
switch (nameResource) {
|
||||
case kVariableNames:
|
||||
return _varNames.getName(nameID);
|
||||
case kExternalCommandNames:
|
||||
return _externalCommandNames.getName(nameID);
|
||||
case kStackNames:
|
||||
return _stackNames.getName(nameID);
|
||||
case kCardNames:
|
||||
return _cardNames.getName(nameID);
|
||||
case kHotspotNames:
|
||||
return _hotspotNames.getName(nameID);
|
||||
default:
|
||||
error("Unknown name resource %d", nameResource);
|
||||
}
|
||||
}
|
||||
|
||||
int16 MohawkEngine_Riven::getIdFromName(uint16 nameResource, const Common::String &name) {
|
||||
switch (nameResource) {
|
||||
case kVariableNames:
|
||||
return _varNames.getNameId(name);
|
||||
case kExternalCommandNames:
|
||||
return _externalCommandNames.getNameId(name);
|
||||
case kStackNames:
|
||||
return _stackNames.getNameId(name);
|
||||
case kCardNames:
|
||||
return _cardNames.getNameId(name);
|
||||
case kHotspotNames:
|
||||
return _hotspotNames.getNameId(name);
|
||||
default:
|
||||
error("Unknown name resource %d", nameResource);
|
||||
}
|
||||
}
|
||||
|
||||
bool ZipMode::operator== (const ZipMode &z) const {
|
||||
return z.name == name && z.id == id;
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include "mohawk/installer_archive.h"
|
||||
#include "mohawk/mohawk.h"
|
||||
#include "mohawk/riven_stack.h"
|
||||
#include "mohawk/riven_scripts.h"
|
||||
|
||||
#include "common/hashmap.h"
|
||||
@ -42,6 +41,7 @@ class RivenExternal;
|
||||
class RivenConsole;
|
||||
class RivenSaveLoad;
|
||||
class RivenOptionsDialog;
|
||||
class RivenStack;
|
||||
class RivenCard;
|
||||
class RivenHotspot;
|
||||
class RivenSoundManager;
|
||||
@ -62,15 +62,6 @@ enum {
|
||||
kStackLast = kStackAspit
|
||||
};
|
||||
|
||||
// NAME Resource ID's
|
||||
enum {
|
||||
kCardNames = 1,
|
||||
kHotspotNames = 2,
|
||||
kExternalCommandNames = 3,
|
||||
kVariableNames = 4,
|
||||
kStackNames = 5
|
||||
};
|
||||
|
||||
enum RivenTransitionSpeed {
|
||||
kRivenTransitionSpeedNone = 5000,
|
||||
kRivenTransitionSpeedFastest = 5001,
|
||||
@ -134,13 +125,6 @@ private:
|
||||
RivenStack *_stack;
|
||||
void handleEvents();
|
||||
|
||||
// Stack resource names
|
||||
RivenNameList _varNames;
|
||||
RivenNameList _externalCommandNames;
|
||||
RivenNameList _hotspotNames;
|
||||
RivenNameList _cardNames;
|
||||
RivenNameList _stackNames;
|
||||
|
||||
// Hotspot related functions and variables
|
||||
void checkInventoryClick();
|
||||
bool _showHotspots;
|
||||
@ -161,8 +145,6 @@ public:
|
||||
void changeToCard(uint16 dest);
|
||||
void changeToStack(uint16);
|
||||
void refreshCard();
|
||||
Common::String getName(uint16 nameResource, uint16 nameID);
|
||||
int16 getIdFromName(uint16 nameResource, const Common::String &name);
|
||||
Common::String getStackName(uint16 stack) const;
|
||||
RivenCard *getCurCard() const { return _card; }
|
||||
RivenStack *getCurStack() const { return _stack; }
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "mohawk/cursors.h"
|
||||
#include "mohawk/riven_graphics.h"
|
||||
#include "mohawk/riven_stack.h"
|
||||
|
||||
#include "mohawk/resource.h"
|
||||
#include "mohawk/riven.h"
|
||||
@ -261,7 +262,7 @@ Common::Array<RivenHotspot *> RivenCard::getHotspots() const {
|
||||
}
|
||||
|
||||
RivenHotspot *RivenCard::getHotspotByName(const Common::String &name) const {
|
||||
int16 nameId = _vm->getIdFromName(kHotspotNames, name);
|
||||
int16 nameId = _vm->getCurStack()->getIdFromName(kHotspotNames, name);
|
||||
|
||||
for (uint i = 0; i < _hotspots.size(); i++) {
|
||||
if (_hotspots[i]->getNameId() == nameId) {
|
||||
@ -509,7 +510,7 @@ Common::String RivenHotspot::getName() const {
|
||||
if (_nameResource < 0)
|
||||
return Common::String();
|
||||
|
||||
return _vm->getName(kHotspotNames, _nameResource);
|
||||
return _vm->getCurStack()->getName(kHotspotNames, _nameResource);
|
||||
}
|
||||
|
||||
uint16 RivenHotspot::getIndex() const {
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "mohawk/riven_external.h"
|
||||
#include "mohawk/riven_graphics.h"
|
||||
#include "mohawk/riven_sound.h"
|
||||
#include "mohawk/riven_stack.h"
|
||||
#include "mohawk/video.h"
|
||||
|
||||
#include "gui/message.h"
|
||||
@ -198,7 +199,7 @@ void RivenExternal::setupCommands() {
|
||||
}
|
||||
|
||||
void RivenExternal::runCommand(uint16 argc, uint16 *argv) {
|
||||
Common::String externalCommandName = _vm->getName(kExternalCommandNames, argv[0]);
|
||||
Common::String externalCommandName = _vm->getCurStack()->getName(kExternalCommandNames, argv[0]);
|
||||
|
||||
for (uint16 i = 0; i < _externalCommands.size(); i++)
|
||||
if (externalCommandName == _externalCommands[i]->desc) {
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "mohawk/riven_card.h"
|
||||
#include "mohawk/riven_graphics.h"
|
||||
#include "mohawk/riven_sound.h"
|
||||
#include "mohawk/riven_stack.h"
|
||||
|
||||
#include "common/system.h"
|
||||
#include "engines/util.h"
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "mohawk/riven.h"
|
||||
#include "mohawk/riven_card.h"
|
||||
#include "mohawk/riven_saveload.h"
|
||||
#include "mohawk/riven_stack.h"
|
||||
|
||||
#include "common/system.h"
|
||||
#include "graphics/thumbnail.h"
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "mohawk/riven_graphics.h"
|
||||
#include "mohawk/riven_scripts.h"
|
||||
#include "mohawk/riven_sound.h"
|
||||
#include "mohawk/riven_stack.h"
|
||||
#include "mohawk/video.h"
|
||||
|
||||
#include "common/memstream.h"
|
||||
@ -462,7 +463,7 @@ void RivenSimpleCommand::incrementVariable(uint16 op, uint16 argc, uint16 *argv)
|
||||
|
||||
// Command 27: go to stack (stack name, code high, code low)
|
||||
void RivenSimpleCommand::changeStack(uint16 op, uint16 argc, uint16 *argv) {
|
||||
Common::String stackName = _vm->getName(kStackNames, argv[0]);
|
||||
Common::String stackName = _vm->getCurStack()->getName(kStackNames, argv[0]);
|
||||
int8 index = -1;
|
||||
|
||||
for (byte i = 0; i < 8; i++)
|
||||
@ -629,10 +630,10 @@ void RivenSimpleCommand::dump(byte tabs) {
|
||||
printTabs(tabs);
|
||||
|
||||
if (_type == 7) { // Use the variable name
|
||||
Common::String varName = _vm->getName(kVariableNames, _arguments[0]);
|
||||
Common::String varName = _vm->getCurStack()->getName(kVariableNames, _arguments[0]);
|
||||
debugN("%s = %d;\n", varName.c_str(), _arguments[1]);
|
||||
} else if (_type == 17) { // Use the external command name
|
||||
Common::String externalCommandName = _vm->getName(kVariableNames, _arguments[0]);
|
||||
Common::String externalCommandName = _vm->getCurStack()->getName(kVariableNames, _arguments[0]);
|
||||
debugN("%s(", externalCommandName.c_str());
|
||||
uint16 varCount = _arguments[1];
|
||||
for (uint16 j = 0; j < varCount; j++) {
|
||||
@ -642,7 +643,7 @@ void RivenSimpleCommand::dump(byte tabs) {
|
||||
}
|
||||
debugN(");\n");
|
||||
} else if (_type == 24) { // Use the variable name
|
||||
Common::String varName = _vm->getName(kVariableNames, _arguments[0]);
|
||||
Common::String varName = _vm->getCurStack()->getName(kVariableNames, _arguments[0]);
|
||||
debugN("%s += %d;\n", varName.c_str(), _arguments[1]);
|
||||
} else {
|
||||
debugN("%s(", _opcodes[_type].desc);
|
||||
@ -704,7 +705,7 @@ RivenSwitchCommand *RivenSwitchCommand::createFromStream(MohawkEngine_Riven *vm,
|
||||
}
|
||||
|
||||
void RivenSwitchCommand::dump(byte tabs) {
|
||||
Common::String varName = _vm->getName(kVariableNames, _variableId);
|
||||
Common::String varName = _vm->getCurStack()->getName(kVariableNames, _variableId);
|
||||
printTabs(tabs); debugN("switch (%s) {\n", varName.c_str());
|
||||
for (uint16 j = 0; j < _branches.size(); j++) {
|
||||
printTabs(tabs + 1);
|
||||
|
@ -30,7 +30,7 @@ namespace Mohawk {
|
||||
RivenStack::RivenStack(MohawkEngine_Riven *vm, uint16 id) :
|
||||
_vm(vm),
|
||||
_id(id) {
|
||||
|
||||
loadResourceNames();
|
||||
}
|
||||
|
||||
RivenStack::~RivenStack() {
|
||||
@ -41,6 +41,48 @@ uint16 RivenStack::getId() const {
|
||||
return _id;
|
||||
}
|
||||
|
||||
void RivenStack::loadResourceNames() {
|
||||
_varNames = RivenNameList(_vm, kVariableNames);
|
||||
_externalCommandNames = RivenNameList(_vm, kExternalCommandNames);
|
||||
_stackNames = RivenNameList(_vm, kStackNames);
|
||||
_cardNames = RivenNameList(_vm, kCardNames);
|
||||
_hotspotNames = RivenNameList(_vm, kHotspotNames);
|
||||
}
|
||||
|
||||
Common::String RivenStack::getName(RivenNameResource nameResource, uint16 nameId) const {
|
||||
switch (nameResource) {
|
||||
case kVariableNames:
|
||||
return _varNames.getName(nameId);
|
||||
case kExternalCommandNames:
|
||||
return _externalCommandNames.getName(nameId);
|
||||
case kStackNames:
|
||||
return _stackNames.getName(nameId);
|
||||
case kCardNames:
|
||||
return _cardNames.getName(nameId);
|
||||
case kHotspotNames:
|
||||
return _hotspotNames.getName(nameId);
|
||||
default:
|
||||
error("Unknown name resource %d", nameResource);
|
||||
}
|
||||
}
|
||||
|
||||
int16 RivenStack::getIdFromName(RivenNameResource nameResource, const Common::String &name) const {
|
||||
switch (nameResource) {
|
||||
case kVariableNames:
|
||||
return _varNames.getNameId(name);
|
||||
case kExternalCommandNames:
|
||||
return _externalCommandNames.getNameId(name);
|
||||
case kStackNames:
|
||||
return _stackNames.getNameId(name);
|
||||
case kCardNames:
|
||||
return _cardNames.getNameId(name);
|
||||
case kHotspotNames:
|
||||
return _hotspotNames.getNameId(name);
|
||||
default:
|
||||
error("Unknown name resource %d", nameResource);
|
||||
}
|
||||
}
|
||||
|
||||
RivenNameList::RivenNameList() {
|
||||
|
||||
}
|
||||
|
@ -28,27 +28,14 @@
|
||||
namespace Mohawk {
|
||||
|
||||
class MohawkEngine_Riven;
|
||||
class RivenNameList;
|
||||
|
||||
/**
|
||||
* A game level
|
||||
*
|
||||
* The names Card and Stack are legacy from the HyperCard engine used in
|
||||
* the original mac version of Myst.
|
||||
*
|
||||
* Stacks contain behaviors that are specific to a game level.
|
||||
*/
|
||||
class RivenStack {
|
||||
public:
|
||||
RivenStack(MohawkEngine_Riven *vm, uint16 id);
|
||||
virtual ~RivenStack();
|
||||
|
||||
/** Get the id of the stack */
|
||||
uint16 getId() const;
|
||||
private:
|
||||
MohawkEngine_Riven *_vm;
|
||||
|
||||
uint16 _id;
|
||||
// NAME Resource ID's
|
||||
enum RivenNameResource {
|
||||
kCardNames = 1,
|
||||
kHotspotNames = 2,
|
||||
kExternalCommandNames = 3,
|
||||
kVariableNames = 4,
|
||||
kStackNames = 5
|
||||
};
|
||||
|
||||
/**
|
||||
@ -71,10 +58,50 @@ public:
|
||||
int16 getNameId(const Common::String &name) const;
|
||||
|
||||
private:
|
||||
void loadResource(MohawkEngine_Riven *vm, uint16 id);
|
||||
|
||||
Common::StringArray _names;
|
||||
Common::Array<uint16> _index;
|
||||
};
|
||||
|
||||
void loadResource(MohawkEngine_Riven *vm, uint16 id);
|
||||
/**
|
||||
* A game level
|
||||
*
|
||||
* The names Card and Stack are legacy from the HyperCard engine used in
|
||||
* the original mac version of Myst.
|
||||
*
|
||||
* Stacks contain behaviors and data that are specific to a game level.
|
||||
*/
|
||||
class RivenStack {
|
||||
public:
|
||||
RivenStack(MohawkEngine_Riven *vm, uint16 id);
|
||||
virtual ~RivenStack();
|
||||
|
||||
/** Get the id of the stack */
|
||||
uint16 getId() const;
|
||||
|
||||
/** Get the name of a resource using its id */
|
||||
Common::String getName(RivenNameResource nameResource, uint16 nameId) const;
|
||||
|
||||
/**
|
||||
* Get the id of a resource using its name
|
||||
*
|
||||
* The search is case insensitive.
|
||||
*/
|
||||
int16 getIdFromName(RivenNameResource nameResource, const Common::String &name) const;
|
||||
private:
|
||||
void loadResourceNames();
|
||||
|
||||
MohawkEngine_Riven *_vm;
|
||||
|
||||
uint16 _id;
|
||||
|
||||
// Stack resource names
|
||||
RivenNameList _varNames;
|
||||
RivenNameList _externalCommandNames;
|
||||
RivenNameList _hotspotNames;
|
||||
RivenNameList _cardNames;
|
||||
RivenNameList _stackNames;
|
||||
};
|
||||
|
||||
} // End of namespace Mohawk
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "common/str.h"
|
||||
|
||||
#include "mohawk/riven.h"
|
||||
#include "mohawk/riven_stack.h"
|
||||
|
||||
namespace Mohawk {
|
||||
|
||||
@ -268,7 +269,7 @@ static const char *variableNames[] = {
|
||||
};
|
||||
|
||||
uint32 &MohawkEngine_Riven::getStackVar(uint32 index) {
|
||||
Common::String name = getName(kVariableNames, index);
|
||||
Common::String name = getCurStack()->getName(kVariableNames, index);
|
||||
|
||||
if (!_vars.contains(name))
|
||||
error("Could not find variable '%s' (stack variable %d)", name.c_str(), index);
|
||||
|
Loading…
x
Reference in New Issue
Block a user