treballant en editor de items i tile_picker

This commit is contained in:
2026-04-02 14:49:26 +02:00
parent acaf434e5c
commit 22d6ac2fbf
15 changed files with 540 additions and 45 deletions

View File

@@ -87,7 +87,7 @@ class Console {
// Estado de la entrada de texto
std::vector<std::string> msg_lines_; // Líneas de mensaje (1 o más)
std::string input_line_;
std::string prompt_{"> "}; // Prompt configurable
std::string prompt_{"> "}; // Prompt configurable
float cursor_timer_{0.0F};
bool cursor_visible_{true};

View File

@@ -23,8 +23,8 @@
#include "utils/utils.hpp" // Para toUpper, prettyName
#ifdef _DEBUG
#include "core/system/debug.hpp" // Para Debug
#include "game/editor/map_editor.hpp" // Para MapEditor
#include "core/system/debug.hpp" // Para Debug
#include "game/editor/map_editor.hpp" // Para MapEditor
#endif
// ── Helpers ──────────────────────────────────────────────────────────────────
@@ -708,6 +708,13 @@ static auto cmd_edit(const std::vector<std::string>& args) -> std::string {
// SET <property> <value> — modifica propiedad del enemigo seleccionado o de la habitación
static auto cmd_set(const std::vector<std::string>& args) -> std::string {
if (!MapEditor::get() || !MapEditor::get()->isActive()) { return "Editor not active"; }
if (args.empty()) { return "usage: set <property> <value>"; }
// SET TILE no necesita argumento (abre el tile picker visual)
if (args[0] == "TILE" && MapEditor::get()->hasSelectedItem()) {
return MapEditor::get()->setItemProperty("TILE", "");
}
if (args.size() < 2) { return "usage: set <property> <value>"; }
// Si hay enemigo seleccionado, aplicar a enemigo
@@ -715,6 +722,11 @@ static auto cmd_set(const std::vector<std::string>& args) -> std::string {
return MapEditor::get()->setEnemyProperty(args[0], args[1]);
}
// Si hay item seleccionado, aplicar a item
if (MapEditor::get()->hasSelectedItem()) {
return MapEditor::get()->setItemProperty(args[0], args[1]);
}
// Si no, aplicar a la habitación
return MapEditor::get()->setRoomProperty(args[0], args[1]);
}
@@ -734,6 +746,22 @@ static auto cmd_enemy(const std::vector<std::string>& args) -> std::string {
}
return "usage: enemy <add|delete|duplicate>";
}
// ITEM [ADD|DELETE|DUPLICATE]
static auto cmd_item(const std::vector<std::string>& args) -> std::string {
if (!MapEditor::get() || !MapEditor::get()->isActive()) { return "Editor not active"; }
if (args.empty()) { return "usage: item <add|delete|duplicate>"; }
if (args[0] == "ADD") { return MapEditor::get()->addItem(); }
if (args[0] == "DELETE") {
if (!MapEditor::get()->hasSelectedItem()) { return "No item selected"; }
return MapEditor::get()->deleteItem();
}
if (args[0] == "DUPLICATE") {
if (!MapEditor::get()->hasSelectedItem()) { return "No item selected"; }
return MapEditor::get()->duplicateItem();
}
return "usage: item <add|delete|duplicate>";
}
#endif
// SHOW [INFO|NOTIFICATION|CHEEVO]
@@ -937,6 +965,7 @@ void CommandRegistry::registerHandlers() {
handlers_["cmd_edit"] = cmd_edit;
handlers_["cmd_set"] = cmd_set;
handlers_["cmd_enemy"] = cmd_enemy;
handlers_["cmd_item"] = cmd_item;
#endif
// HELP se registra en load() como lambda que captura this
@@ -967,9 +996,7 @@ void CommandRegistry::registerHandlers() {
#ifdef _DEBUG
// Colores de la paleta (compartido por SET COLOR, BGCOLOR, BORDER, ITEMCOLOR1, ITEMCOLOR2)
auto color_provider = []() -> std::vector<std::string> {
return {"BLACK", "BRIGHT_BLACK", "BLUE", "BRIGHT_BLUE", "RED", "BRIGHT_RED",
"MAGENTA", "BRIGHT_MAGENTA", "GREEN", "BRIGHT_GREEN", "CYAN", "BRIGHT_CYAN",
"YELLOW", "BRIGHT_YELLOW", "WHITE", "BRIGHT_WHITE"};
return {"BLACK", "BRIGHT_BLACK", "BLUE", "BRIGHT_BLUE", "RED", "BRIGHT_RED", "MAGENTA", "BRIGHT_MAGENTA", "GREEN", "BRIGHT_GREEN", "CYAN", "BRIGHT_CYAN", "YELLOW", "BRIGHT_YELLOW", "WHITE", "BRIGHT_WHITE"};
};
dynamic_providers_["SET COLOR"] = color_provider;
dynamic_providers_["SET BGCOLOR"] = color_provider;