mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-15 00:27:31 +00:00
STARK: Move debug related functions to the debug console
This commit is contained in:
parent
6018a0e5d4
commit
553b282a6d
@ -29,6 +29,8 @@
|
||||
#include "engines/stark/resources/knowledge.h"
|
||||
#include "engines/stark/resources/root.h"
|
||||
#include "engines/stark/resources/script.h"
|
||||
#include "engines/stark/resources/knowledgeset.h"
|
||||
#include "engines/stark/resources/item.h"
|
||||
#include "engines/stark/services/archiveloader.h"
|
||||
#include "engines/stark/services/dialogplayer.h"
|
||||
#include "engines/stark/services/global.h"
|
||||
@ -468,17 +470,29 @@ bool Console::Cmd_DumpLocation(int argc, const char **argv) {
|
||||
}
|
||||
|
||||
bool Console::Cmd_ListInventory(int argc, const char **argv) {
|
||||
if (StarkGlobal->getInventory()) {
|
||||
StarkGlobal->printInventory(argc != 2);
|
||||
} else {
|
||||
Resources::KnowledgeSet *inventory = StarkGlobal->getInventory();
|
||||
|
||||
if (!inventory) {
|
||||
debugPrintf("The inventory has not been loaded\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool printAll = argc != 2;
|
||||
Common::Array<Resources::Item*> inventoryItems = inventory->listChildren<Resources::Item>(Resources::Item::kItemInventory);
|
||||
Common::Array<Resources::Item*>::iterator it = inventoryItems.begin();
|
||||
for (int i = 0; it != inventoryItems.end(); ++it, i++) {
|
||||
if (printAll || (*it)->isEnabled()) {
|
||||
debugPrintf("Item %d: %s\n", i, (*it)->getName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Console::Cmd_EnableInventoryItem(int argc, const char **argv) {
|
||||
if (!StarkGlobal->getInventory()) {
|
||||
Resources::KnowledgeSet *inventory = StarkGlobal->getInventory();
|
||||
|
||||
if (!inventory) {
|
||||
debugPrintf("The inventory has not been loaded\n");
|
||||
return true;
|
||||
}
|
||||
@ -490,7 +504,13 @@ bool Console::Cmd_EnableInventoryItem(int argc, const char **argv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
StarkGlobal->enableInventoryItem(atoi(argv[1]));
|
||||
uint num = atoi(argv[1]);
|
||||
Common::Array<Resources::Item*> inventoryItems = inventory->listChildren<Resources::Item>(Resources::Item::kItemInventory);
|
||||
if (num < inventoryItems.size()) {
|
||||
inventoryItems[num]->setEnabled(true);
|
||||
} else {
|
||||
debugPrintf("Invalid index %d, only %d indices available\n", num, inventoryItems.size());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -54,27 +54,6 @@ void Global::setCurrentChapter(int32 value) {
|
||||
chapter->setIntegerValue(value);
|
||||
}
|
||||
|
||||
void Global::printInventory(bool printAll) {
|
||||
// Assume that this function is only called by the debug console
|
||||
Common::Array<Resources::Item*> inventoryItems = _inventory->listChildren<Resources::Item>(Resources::Item::kItemInventory);
|
||||
Common::Array<Resources::Item*>::iterator it = inventoryItems.begin();
|
||||
for (int i = 0; it != inventoryItems.end(); ++it, i++) {
|
||||
if (printAll || (*it)->isEnabled()) {
|
||||
g_engine->getDebugger()->debugPrintf("Item %d: %s\n", i, (*it)->getName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Global::enableInventoryItem(int32 num) {
|
||||
Common::Array<Resources::Item*> inventoryItems = _inventory->listChildren<Resources::Item>(Resources::Item::kItemInventory);
|
||||
if (num >= 0 && num <= inventoryItems.size()) {
|
||||
inventoryItems[num]->setEnabled(true);
|
||||
} else {
|
||||
// Assume that only being called by the debug console will cause the checking failed
|
||||
g_engine->getDebugger()->debugPrintf("Invalid index %d, only %d indices available\n", num, inventoryItems.size());
|
||||
}
|
||||
}
|
||||
|
||||
Common::String Global::getCharacterName(int32 id) {
|
||||
Resources::KnowledgeSet *characters = _level->findChildWithSubtype<Resources::KnowledgeSet>(Resources::KnowledgeSet::kPersons);
|
||||
Resources::Knowledge *character = characters->findChildWithIndex<Resources::Knowledge>(id);
|
||||
|
@ -100,8 +100,6 @@ public:
|
||||
int32 getCurrentChapter();
|
||||
|
||||
/** Temporary HACK to allow us to query the inventory */
|
||||
void printInventory(bool printAll);
|
||||
void enableInventoryItem(int32 num);
|
||||
bool hasInventoryItem(const Common::String &itemName) const;
|
||||
|
||||
/** Change the current chapter */
|
||||
|
@ -61,12 +61,10 @@ public:
|
||||
/** Build a save file name for the specified target and slot */
|
||||
static Common::String formatSaveName(const char *target, int slot);
|
||||
|
||||
// Engine API
|
||||
GUI::Debugger *getDebugger() override { return (GUI::Debugger *)_console; }
|
||||
|
||||
protected:
|
||||
// Engine APIs
|
||||
Common::Error run() override;
|
||||
GUI::Debugger *getDebugger() override { return (GUI::Debugger *)_console; }
|
||||
bool hasFeature(EngineFeature f) const override;
|
||||
bool canLoadGameStateCurrently() override;
|
||||
bool canSaveGameStateCurrently() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user