MOHAWK: RIVEN: Add a console to quickly test all the cards

Goes through all the cards clicking on hotspots at random.
This commit is contained in:
Bastien Bouclet 2019-02-02 13:30:44 +01:00
parent f72f71a6cc
commit 04edc22635
6 changed files with 93 additions and 15 deletions

View File

@ -374,23 +374,24 @@ bool MystConsole::Cmd_QuickTest(int argc, const char **argv) {
#ifdef ENABLE_RIVEN
RivenConsole::RivenConsole(MohawkEngine_Riven *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("changeCard", WRAP_METHOD(RivenConsole, Cmd_ChangeCard));
registerCmd("curCard", WRAP_METHOD(RivenConsole, Cmd_CurCard));
registerCmd("dumpCard", WRAP_METHOD(RivenConsole, Cmd_DumpCard));
registerCmd("var", WRAP_METHOD(RivenConsole, Cmd_Var));
registerCmd("playSound", WRAP_METHOD(RivenConsole, Cmd_PlaySound));
registerCmd("changeCard", WRAP_METHOD(RivenConsole, Cmd_ChangeCard));
registerCmd("curCard", WRAP_METHOD(RivenConsole, Cmd_CurCard));
registerCmd("dumpCard", WRAP_METHOD(RivenConsole, Cmd_DumpCard));
registerCmd("var", WRAP_METHOD(RivenConsole, Cmd_Var));
registerCmd("playSound", WRAP_METHOD(RivenConsole, Cmd_PlaySound));
registerCmd("playSLST", WRAP_METHOD(RivenConsole, Cmd_PlaySLST));
registerCmd("stopSound", WRAP_METHOD(RivenConsole, Cmd_StopSound));
registerCmd("curStack", WRAP_METHOD(RivenConsole, Cmd_CurStack));
registerCmd("dumpStack", WRAP_METHOD(RivenConsole, Cmd_DumpStack));
registerCmd("changeStack", WRAP_METHOD(RivenConsole, Cmd_ChangeStack));
registerCmd("hotspots", WRAP_METHOD(RivenConsole, Cmd_Hotspots));
registerCmd("zipMode", WRAP_METHOD(RivenConsole, Cmd_ZipMode));
registerCmd("stopSound", WRAP_METHOD(RivenConsole, Cmd_StopSound));
registerCmd("curStack", WRAP_METHOD(RivenConsole, Cmd_CurStack));
registerCmd("dumpStack", WRAP_METHOD(RivenConsole, Cmd_DumpStack));
registerCmd("changeStack", WRAP_METHOD(RivenConsole, Cmd_ChangeStack));
registerCmd("hotspots", WRAP_METHOD(RivenConsole, Cmd_Hotspots));
registerCmd("zipMode", WRAP_METHOD(RivenConsole, Cmd_ZipMode));
registerCmd("dumpScript", WRAP_METHOD(RivenConsole, Cmd_DumpScript));
registerCmd("listZipCards", WRAP_METHOD(RivenConsole, Cmd_ListZipCards));
registerCmd("getRMAP", WRAP_METHOD(RivenConsole, Cmd_GetRMAP));
registerCmd("getRMAP", WRAP_METHOD(RivenConsole, Cmd_GetRMAP));
registerCmd("combos", WRAP_METHOD(RivenConsole, Cmd_Combos));
registerCmd("sliderState", WRAP_METHOD(RivenConsole, Cmd_SliderState));
registerCmd("quickTest", WRAP_METHOD(RivenConsole, Cmd_QuickTest));
registerVar("show_hotspots", &_vm->_showHotspots);
}
@ -687,6 +688,65 @@ bool RivenConsole::Cmd_SliderState(int argc, const char **argv) {
return true;
}
bool RivenConsole::Cmd_QuickTest(int argc, const char **argv) {
_vm->pauseEngine(false);
// Go through all the stacks, all the cards and click random stuff
for (uint16 stackId = kStackFirst; stackId <= kStackLast; stackId++) {
debug("Loading stack %s", RivenStacks::getName(stackId));
_vm->changeToStack(stackId);
Common::Array<uint16> cardIds = _vm->getResourceIDList(ID_CARD);
for (uint16 i = 0; i < cardIds.size(); i++) {
if (_vm->shouldQuit()) break;
uint16 cardId = cardIds[i];
if (stackId == kStackTspit && cardId == 366) continue; // Cut card with invalid links
if (stackId == kStackTspit && cardId == 412) continue; // Cut card with invalid links
if (stackId == kStackTspit && cardId == 486) continue; // Cut card with invalid links
if (stackId == kStackBspit && cardId == 465) continue; // Cut card with invalid links
if (stackId == kStackJspit && cardId == 737) continue; // Cut card with invalid links
debug("Loading card %d", cardId);
RivenScriptPtr script = _vm->_scriptMan->createScriptFromData(1,
kRivenCommandChangeCard, 1, cardId);
_vm->_scriptMan->runScript(script, true);
_vm->_gfx->setTransitionMode(kRivenTransitionModeDisabled);
while (_vm->_scriptMan->hasQueuedScripts()) {
_vm->doFrame();
}
// Click on a random hotspot
Common::Array<RivenHotspot *> hotspots = _vm->getCard()->getHotspots();
if (!hotspots.empty() && _vm->getStack()->getId() != kStackAspit) {
uint hotspotIndex = _vm->_rnd->getRandomNumberRng(0, hotspots.size() - 1);
RivenHotspot *hotspot = hotspots[hotspotIndex];
if (hotspot->isEnabled()) {
Common::Rect hotspotRect = hotspot->getRect();
Common::Point hotspotPoint((hotspotRect.left + hotspotRect.right) / 2, (hotspotRect.top + hotspotRect.bottom) / 2);
_vm->getStack()->onMouseDown(hotspotPoint);
_vm->getStack()->onMouseUp(hotspotPoint);
}
while (_vm->_scriptMan->hasQueuedScripts()) {
_vm->doFrame();
}
}
if (_vm->getStack()->getId() != stackId) {
// Clicking may have linked us to another age
_vm->changeToStack(stackId);
}
}
}
_vm->pauseEngine(true);
return true;
}
#endif // ENABLE_RIVEN
LivingBooksConsole::LivingBooksConsole(MohawkEngine_LivingBooks *vm) : GUI::Debugger(), _vm(vm) {

View File

@ -89,6 +89,7 @@ private:
bool Cmd_GetRMAP(int argc, const char **argv);
bool Cmd_Combos(int argc, const char **argv);
bool Cmd_SliderState(int argc, const char **argv);
bool Cmd_QuickTest(int argc, const char **argv);
};
#endif

View File

@ -636,6 +636,17 @@ Common::SeekableReadStream *MohawkEngine_Riven::getExtrasResource(uint32 tag, ui
return _extrasFile->getResource(tag, id);
}
Common::Array<uint16> MohawkEngine_Riven::getResourceIDList(uint32 type) const {
Common::Array<uint16> ids;
for (uint i = 0; i < _mhk.size(); i++) {
ids.push_back(_mhk[i]->getResourceIDList(type));
}
return ids;
}
void MohawkEngine_Riven::delay(uint32 ms) {
uint32 startTime = _system->getMillis();

View File

@ -153,6 +153,7 @@ public:
uint32 &getStackVar(uint32 index);
// Miscellaneous
Common::Array<uint16> getResourceIDList(uint32 type) const;
Common::SeekableReadStream *getExtrasResource(uint32 tag, uint16 id);
bool _activatedPLST;
bool _activatedSLST;

View File

@ -30,7 +30,6 @@
#include "common/str-array.h"
#include "mohawk/riven_graphics.h"
#include "mohawk/riven_stack.h"
namespace Mohawk {

View File

@ -157,7 +157,13 @@ void GSpit::xgpincontrols(const ArgumentArray &args) {
}
// Now check to see if this section of the island exists
uint32 islandIndex = _vm->_vars["glkbtns"] - 1;
uint32 islandIndex = _vm->_vars["glkbtns"];
if (islandIndex == 0) {
// No island selected. Probably we jumped to the card.
warning("xgpincontrols called without an island selected.");
return;
}
uint16 imagePos = mousePos.x + mousePos.y;
static const uint16 islandImages[5][11] = {
@ -172,7 +178,7 @@ void GSpit::xgpincontrols(const ArgumentArray &args) {
uint32 imageCount = _vm->_vars["gimagemax"];
uint32 image = 0;
for (; image < imageCount; image++)
if (islandImages[islandIndex][image] == imagePos)
if (islandImages[islandIndex - 1][image] == imagePos)
break;
// If we past it, we don't have a valid map coordinate