TINSEL: Add debug commands to add all clues, as well as listing them.

At the same time, name the NOTEBOOK_CLUE attribute appropriately
This commit is contained in:
Einar Johan Trøan Sømåen 2022-05-26 23:04:38 +02:00
parent 38dd15c183
commit fdfede64ca
No known key found for this signature in database
GPG Key ID: 0DFF2FB496CF9F93
6 changed files with 41 additions and 3 deletions

View File

@ -64,7 +64,9 @@ int strToInt(const char *s) {
Console::Console() : GUI::Debugger() {
if (TinselVersion == 3) {
registerCmd("add_clue", WRAP_METHOD(Console, cmd_add_clue));
registerCmd("add_all_clues", WRAP_METHOD(Console, cmd_add_all_clues));
registerCmd("cross_clue", WRAP_METHOD(Console, cmd_cross_clue));
registerCmd("list_clues", WRAP_METHOD(Console, cmd_list_clues));
}
registerCmd("item", WRAP_METHOD(Console, cmd_item));
registerCmd("scene", WRAP_METHOD(Console, cmd_scene));
@ -177,6 +179,14 @@ bool Console::cmd_add_clue(int argc, const char **argv) {
return false;
}
bool Console::cmd_add_all_clues(int argc, const char **argv) {
auto clues = _vm->_dialogs->GetAllNotebookClues();
for (auto clue : clues) {
_vm->_notebook->AddClue(clue);
}
return false;
}
bool Console::cmd_cross_clue(int argc, const char **argv) {
if (argc < 2) {
debugPrintf("%s clue_id\n", argv[0]);
@ -188,4 +198,12 @@ bool Console::cmd_cross_clue(int argc, const char **argv) {
return false;
}
bool Console::cmd_list_clues(int argc, const char **argv) {
auto clues = _vm->_dialogs->GetAllNotebookClues();
for (auto clue : clues) {
debugPrintf("%d\n", clue);
}
return true;
}
} // End of namespace Tinsel

View File

@ -35,7 +35,9 @@ public:
private:
bool cmd_add_clue(int argc, const char **argv);
bool cmd_add_all_clues(int argc, const char **argv);
bool cmd_cross_clue(int argc, const char **argv);
bool cmd_list_clues(int argc, const char **argv);
bool cmd_item(int argc, const char **argv);
bool cmd_scene(int argc, const char **argv);
bool cmd_music(int argc, const char **argv);

View File

@ -1268,7 +1268,7 @@ void Dialogs::InventoryIconCursor(bool bNewItem) {
if (TinselVersion == 3) {
auto invObj = GetInvObject(_heldItem);
if (invObj->hasAttribute(InvObjAttr::V3ATTR_X200)) {
if (invObj->hasAttribute(InvObjAttr::NOTEBOOK_CLUE)) {
_heldFilm = _vm->_systemReel->Get((SysReel)objIndex);
} else {
_heldFilm = _invFilms[objIndex];
@ -1720,7 +1720,7 @@ void Dialogs::HoldItem(int item, bool bKeepFilm) {
else if (invObj->hasAttribute(InvObjAttr::DEFINV2))
AddToInventory(INV_2, _heldItem);
else {
if ((TinselVersion < 3) || (!(invObj->hasAttribute(InvObjAttr::V3ATTR_X200)) && !(invObj->hasAttribute(InvObjAttr::V3ATTR_X400)))) {
if ((TinselVersion < 3) || (!(invObj->hasAttribute(InvObjAttr::NOTEBOOK_CLUE)) && !(invObj->hasAttribute(InvObjAttr::V3ATTR_X400)))) {
// Hook for definable default inventory
AddToInventory(INV_1, _heldItem);
}
@ -5217,6 +5217,18 @@ void Dialogs::syncInvInfo(Common::Serializer &s) {
}
}
// Let the debugger know all the available clues.
Common::Array<int> Dialogs::GetAllNotebookClues() const {
Common::Array<int> clues;
for (int i = 0; i < _invObjects->numObjects(); i++) {
auto obj = _invObjects->GetObjectByIndex(i);
if (obj->hasAttribute(InvObjAttr::NOTEBOOK_CLUE)) {
clues.push_back(obj->getId());
}
}
return clues;
}
/**************************************************************************/
/************************ Initialisation stuff ****************************/
/**************************************************************************/

View File

@ -295,6 +295,7 @@ public:
int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
// Noir
Common::Array<int> GetAllNotebookClues() const;
void idec_invMain(SCNHANDLE text, int MaxContents);
bool InventoryActive();

View File

@ -40,7 +40,7 @@ enum class InvObjAttr {
// Noir only
V3ATTR_X80 = 0x80,
V3ATTR_X200 = 0x200,
NOTEBOOK_CLUE = 0x200,
V3ATTR_X400 = 0x400,
NOTEBOOK_TITLE = 0x800, // is a notebook title
V3ATTR_X1000 = 0x1000,

View File

@ -117,6 +117,11 @@ int Notebook::AddTitle(const InventoryObjectT3 &invObject) {
}
void Notebook::AddClue(const InventoryObjectT3 &invObject) {
if (invObject.getUnknown() == 0) {
// This affects two clues, that should get special treatment.
warning("TODO: Handle clues with no parent page");
return;
}
// Add title if missing, otherwise just get the page it's on.
auto titleObject = _vm->_dialogs->GetInvObjectT3(invObject.getUnknown());
int pageIndex = AddTitle(*titleObject);