forked from jaildesigner-jailgames/jaildoctors_dilemma
reestructurat els comandos de consola
This commit is contained in:
@@ -117,16 +117,6 @@ categories:
|
|||||||
PLAYER SKIN: [DEFAULT, ABAD, BATMAN, CHIP, CONGO, JEANNINE, MUMMY, UPV_STUDENT]
|
PLAYER SKIN: [DEFAULT, ABAD, BATMAN, CHIP, CONGO, JEANNINE, MUMMY, UPV_STUDENT]
|
||||||
PLAYER COLOR: [DEFAULT]
|
PLAYER COLOR: [DEFAULT]
|
||||||
|
|
||||||
- keyword: SET
|
|
||||||
handler: cmd_set
|
|
||||||
description: "Set debug options"
|
|
||||||
usage: "SET INITIAL [ROOM|POS|SCENE] | SET ITEMS <0-200>"
|
|
||||||
debug_only: true
|
|
||||||
completions:
|
|
||||||
SET: [INITIAL, ITEMS]
|
|
||||||
SET INITIAL: [ROOM, POS, SCENE]
|
|
||||||
SET INITIAL SCENE: [LOGO, LOADING, TITLE, CREDITS, GAME, ENDING, ENDING2]
|
|
||||||
|
|
||||||
- keyword: RESTART
|
- keyword: RESTART
|
||||||
handler: cmd_restart
|
handler: cmd_restart
|
||||||
description: Restart from the beginning
|
description: Restart from the beginning
|
||||||
@@ -193,10 +183,18 @@ categories:
|
|||||||
commands:
|
commands:
|
||||||
- keyword: DEBUG
|
- keyword: DEBUG
|
||||||
handler: cmd_debug
|
handler: cmd_debug
|
||||||
description: "Toggle debug overlay (F12)"
|
description: "Debug mode and start options (F12)"
|
||||||
usage: "DEBUG [ON|OFF]"
|
usage: "DEBUG [MODE [ON|OFF]|START [HERE|ROOM|POS|SCENE <name>]]"
|
||||||
completions:
|
completions:
|
||||||
DEBUG: [ON, OFF]
|
DEBUG: [MODE, START]
|
||||||
|
DEBUG MODE: [ON, OFF]
|
||||||
|
DEBUG START: [HERE, ROOM, POS, SCENE]
|
||||||
|
DEBUG START SCENE: [LOGO, LOADING, TITLE, CREDITS, GAME, ENDING, ENDING2]
|
||||||
|
|
||||||
|
- keyword: ITEMS
|
||||||
|
handler: cmd_items
|
||||||
|
description: "Set item count (GAME only)"
|
||||||
|
usage: "ITEMS <0-200>"
|
||||||
|
|
||||||
- keyword: ROOM
|
- keyword: ROOM
|
||||||
handler: cmd_room
|
handler: cmd_room
|
||||||
|
|||||||
@@ -457,24 +457,86 @@ static auto cmd_sound(const std::vector<std::string>& args) -> std::string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// DEBUG [ON|OFF]
|
// DEBUG [MODE [ON|OFF]|START [HERE|ROOM|POS|SCENE <name>]]
|
||||||
static auto cmd_debug(const std::vector<std::string>& args) -> std::string {
|
static auto cmd_debug(const std::vector<std::string>& args) -> std::string {
|
||||||
if (SceneManager::current != SceneManager::Scene::GAME) { return "Only available in GAME scene"; }
|
// --- START subcommands (START SCENE works from any scene) ---
|
||||||
if (!GameControl::toggle_debug_mode) { return "Game not initialized"; }
|
if (!args.empty() && args[0] == "START") {
|
||||||
const bool ENABLED = Debug::get()->isEnabled();
|
// START SCENE [<name>] — works from any scene
|
||||||
if (!args.empty() && args[0] == "ON") {
|
if (args.size() >= 2 && args[1] == "SCENE") {
|
||||||
if (ENABLED) { return "Debug mode already ON"; }
|
SceneManager::Scene target = SceneManager::current;
|
||||||
GameControl::toggle_debug_mode();
|
std::string name = "current";
|
||||||
return "Debug mode ON";
|
if (args.size() >= 3) {
|
||||||
|
if (args[2] == "GAME") {
|
||||||
|
target = SceneManager::Scene::GAME;
|
||||||
|
name = "game";
|
||||||
|
} else if (args[2] == "LOGO") {
|
||||||
|
target = SceneManager::Scene::LOGO;
|
||||||
|
name = "logo";
|
||||||
|
} else if (args[2] == "LOADING") {
|
||||||
|
target = SceneManager::Scene::LOADING_SCREEN;
|
||||||
|
name = "loading";
|
||||||
|
} else if (args[2] == "TITLE") {
|
||||||
|
target = SceneManager::Scene::TITLE;
|
||||||
|
name = "title";
|
||||||
|
} else if (args[2] == "CREDITS") {
|
||||||
|
target = SceneManager::Scene::CREDITS;
|
||||||
|
name = "credits";
|
||||||
|
} else if (args[2] == "ENDING") {
|
||||||
|
target = SceneManager::Scene::ENDING;
|
||||||
|
name = "ending";
|
||||||
|
} else if (args[2] == "ENDING2") {
|
||||||
|
target = SceneManager::Scene::ENDING2;
|
||||||
|
name = "ending2";
|
||||||
|
} else {
|
||||||
|
std::string scene_lower = args[2];
|
||||||
|
std::ranges::transform(scene_lower, scene_lower.begin(), ::tolower);
|
||||||
|
return "Unknown scene: " + scene_lower;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Debug::get()->setInitialScene(target);
|
||||||
|
Debug::get()->saveToFile();
|
||||||
|
return "Initial scene set to: " + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// START HERE|ROOM|POS — requires GAME scene
|
||||||
|
if (SceneManager::current != SceneManager::Scene::GAME) { return "Only available in GAME scene"; }
|
||||||
|
if (!GameControl::set_initial_room || !GameControl::set_initial_pos) { return "Game not initialized"; }
|
||||||
|
|
||||||
|
const bool DO_ROOM = args.size() == 1 || args[1] == "HERE" || args[1] == "ROOM";
|
||||||
|
const bool DO_POS = args.size() == 1 || args[1] == "HERE" || args[1] == "POS";
|
||||||
|
|
||||||
|
if (!DO_ROOM && !DO_POS) { return "usage: debug start [here|room|pos|scene <name>]"; }
|
||||||
|
|
||||||
|
std::string result;
|
||||||
|
if (DO_ROOM) { result = GameControl::set_initial_room(); }
|
||||||
|
if (DO_POS) {
|
||||||
|
if (!result.empty()) { result += ", "; }
|
||||||
|
result += GameControl::set_initial_pos();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
if (!args.empty() && args[0] == "OFF") {
|
|
||||||
if (!ENABLED) { return "Debug mode already OFF"; }
|
// --- MODE [ON|OFF] toggle (requires GAME scene) ---
|
||||||
|
if (!args.empty() && args[0] == "MODE") {
|
||||||
|
if (SceneManager::current != SceneManager::Scene::GAME) { return "Only available in GAME scene"; }
|
||||||
|
if (!GameControl::toggle_debug_mode) { return "Game not initialized"; }
|
||||||
|
const bool ENABLED = Debug::get()->isEnabled();
|
||||||
|
if (args.size() >= 2 && args[1] == "ON") {
|
||||||
|
if (ENABLED) { return "Debug mode already ON"; }
|
||||||
|
GameControl::toggle_debug_mode();
|
||||||
|
return "Debug mode ON";
|
||||||
|
}
|
||||||
|
if (args.size() >= 2 && args[1] == "OFF") {
|
||||||
|
if (!ENABLED) { return "Debug mode already OFF"; }
|
||||||
|
GameControl::toggle_debug_mode();
|
||||||
|
return "Debug mode OFF";
|
||||||
|
}
|
||||||
|
if (args.size() >= 2) { return "usage: debug mode [on|off]"; }
|
||||||
GameControl::toggle_debug_mode();
|
GameControl::toggle_debug_mode();
|
||||||
return "Debug mode OFF";
|
return std::string("Debug mode ") + (Debug::get()->isEnabled() ? "ON" : "OFF");
|
||||||
}
|
}
|
||||||
if (!args.empty()) { return "usage: debug [on|off]"; }
|
|
||||||
GameControl::toggle_debug_mode();
|
return "usage: debug [mode [on|off]|start [here|room|pos|scene <name>]]";
|
||||||
return std::string("Debug mode ") + (Debug::get()->isEnabled() ? "ON" : "OFF");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ROOM <num>|NEXT|PREV
|
// ROOM <num>|NEXT|PREV
|
||||||
@@ -503,6 +565,20 @@ static auto cmd_room(const std::vector<std::string>& args) -> std::string {
|
|||||||
return std::string("Room not found: ") + buf;
|
return std::string("Room not found: ") + buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ITEMS <0-200>
|
||||||
|
static auto cmd_items(const std::vector<std::string>& args) -> std::string {
|
||||||
|
if (SceneManager::current != SceneManager::Scene::GAME) { return "Only available in GAME scene"; }
|
||||||
|
if (args.empty()) { return "usage: items <0-200>"; }
|
||||||
|
int count = 0;
|
||||||
|
try {
|
||||||
|
count = std::stoi(args[0]);
|
||||||
|
} catch (...) { return "usage: items <0-200>"; }
|
||||||
|
if (count < 0 || count > 200) { return "Items must be between 0 and 200"; }
|
||||||
|
if (!GameControl::set_items) { return "Game not initialized"; }
|
||||||
|
GameControl::set_items(count);
|
||||||
|
return "Items: " + std::to_string(count);
|
||||||
|
}
|
||||||
|
|
||||||
// SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART]
|
// SCENE [LOGO|LOADING|TITLE|CREDITS|GAME|ENDING|ENDING2|RESTART]
|
||||||
static auto cmd_scene(const std::vector<std::string>& args) -> std::string {
|
static auto cmd_scene(const std::vector<std::string>& args) -> std::string {
|
||||||
if (Options::kiosk.enabled) { return "Not allowed in kiosk mode"; }
|
if (Options::kiosk.enabled) { return "Not allowed in kiosk mode"; }
|
||||||
@@ -660,81 +736,6 @@ static auto cmd_player(const std::vector<std::string>& args) -> std::string {
|
|||||||
return "usage: player skin <name> | player color <0-15>|default";
|
return "usage: player skin <name> | player color <0-15>|default";
|
||||||
}
|
}
|
||||||
|
|
||||||
// SET INITIAL / SET ITEMS
|
|
||||||
static auto cmd_set(const std::vector<std::string>& args) -> std::string {
|
|
||||||
#ifdef _DEBUG
|
|
||||||
// SET INITIAL SCENE [<nombre>]
|
|
||||||
if (args.size() >= 2 && args[0] == "INITIAL" && args[1] == "SCENE") {
|
|
||||||
SceneManager::Scene target = SceneManager::current;
|
|
||||||
std::string name = "current";
|
|
||||||
if (args.size() >= 3) {
|
|
||||||
if (args[2] == "GAME") {
|
|
||||||
target = SceneManager::Scene::GAME;
|
|
||||||
name = "game";
|
|
||||||
} else if (args[2] == "LOGO") {
|
|
||||||
target = SceneManager::Scene::LOGO;
|
|
||||||
name = "logo";
|
|
||||||
} else if (args[2] == "LOADING") {
|
|
||||||
target = SceneManager::Scene::LOADING_SCREEN;
|
|
||||||
name = "loading";
|
|
||||||
} else if (args[2] == "TITLE") {
|
|
||||||
target = SceneManager::Scene::TITLE;
|
|
||||||
name = "title";
|
|
||||||
} else if (args[2] == "CREDITS") {
|
|
||||||
target = SceneManager::Scene::CREDITS;
|
|
||||||
name = "credits";
|
|
||||||
} else if (args[2] == "ENDING") {
|
|
||||||
target = SceneManager::Scene::ENDING;
|
|
||||||
name = "ending";
|
|
||||||
} else if (args[2] == "ENDING2") {
|
|
||||||
target = SceneManager::Scene::ENDING2;
|
|
||||||
name = "ending2";
|
|
||||||
} else {
|
|
||||||
std::string scene_lower = args[2];
|
|
||||||
std::ranges::transform(scene_lower, scene_lower.begin(), ::tolower);
|
|
||||||
return "Unknown scene: " + scene_lower;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Debug::get()->setInitialScene(target);
|
|
||||||
Debug::get()->saveToFile();
|
|
||||||
return "Initial scene set to: " + name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SceneManager::current != SceneManager::Scene::GAME) { return "Only available in GAME scene"; }
|
|
||||||
|
|
||||||
// SET ITEMS <0-200>
|
|
||||||
if (!args.empty() && args[0] == "ITEMS") {
|
|
||||||
if (args.size() < 2) { return "usage: set items <0-200>"; }
|
|
||||||
int count = 0;
|
|
||||||
try {
|
|
||||||
count = std::stoi(args[1]);
|
|
||||||
} catch (...) { return "usage: set items <0-200>"; }
|
|
||||||
if (count < 0 || count > 200) { return "Items must be between 0 and 200"; }
|
|
||||||
if (!GameControl::set_items) { return "Game not initialized"; }
|
|
||||||
GameControl::set_items(count);
|
|
||||||
return "Items: " + std::to_string(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.empty() || args[0] != "INITIAL") { return "usage: set initial [room|pos|scene] | set items <0-200>"; }
|
|
||||||
|
|
||||||
const bool DO_ROOM = args.size() == 1 || (args.size() >= 2 && args[1] == "ROOM");
|
|
||||||
const bool DO_POS = args.size() == 1 || (args.size() >= 2 && args[1] == "POS");
|
|
||||||
|
|
||||||
if (!DO_ROOM && !DO_POS) { return "usage: set initial [room|pos|scene]"; }
|
|
||||||
if (!GameControl::set_initial_room || !GameControl::set_initial_pos) { return "Game not initialized"; }
|
|
||||||
|
|
||||||
std::string result;
|
|
||||||
if (DO_ROOM) { result = GameControl::set_initial_room(); }
|
|
||||||
if (DO_POS) {
|
|
||||||
if (!result.empty()) { result += ", "; }
|
|
||||||
result += GameControl::set_initial_pos();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
#else
|
|
||||||
return "Debug only command";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// RESTART
|
// RESTART
|
||||||
static auto cmd_restart(const std::vector<std::string>&) -> std::string {
|
static auto cmd_restart(const std::vector<std::string>&) -> std::string {
|
||||||
SceneManager::current = SceneManager::Scene::LOGO;
|
SceneManager::current = SceneManager::Scene::LOGO;
|
||||||
@@ -798,7 +799,6 @@ void CommandRegistry::registerHandlers() {
|
|||||||
handlers_["cmd_hide"] = cmd_hide;
|
handlers_["cmd_hide"] = cmd_hide;
|
||||||
handlers_["cmd_cheat"] = cmd_cheat;
|
handlers_["cmd_cheat"] = cmd_cheat;
|
||||||
handlers_["cmd_player"] = cmd_player;
|
handlers_["cmd_player"] = cmd_player;
|
||||||
handlers_["cmd_set"] = cmd_set;
|
|
||||||
handlers_["cmd_restart"] = cmd_restart;
|
handlers_["cmd_restart"] = cmd_restart;
|
||||||
handlers_["cmd_kiosk"] = cmd_kiosk;
|
handlers_["cmd_kiosk"] = cmd_kiosk;
|
||||||
handlers_["cmd_exit"] = cmd_exit;
|
handlers_["cmd_exit"] = cmd_exit;
|
||||||
@@ -806,6 +806,7 @@ void CommandRegistry::registerHandlers() {
|
|||||||
handlers_["cmd_size"] = cmd_size;
|
handlers_["cmd_size"] = cmd_size;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
handlers_["cmd_debug"] = cmd_debug;
|
handlers_["cmd_debug"] = cmd_debug;
|
||||||
|
handlers_["cmd_items"] = cmd_items;
|
||||||
handlers_["cmd_room"] = cmd_room;
|
handlers_["cmd_room"] = cmd_room;
|
||||||
handlers_["cmd_scene"] = cmd_scene;
|
handlers_["cmd_scene"] = cmd_scene;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user