editar propietats del enemic

This commit is contained in:
2026-04-02 12:45:29 +02:00
parent 3a5b16346b
commit 273d9304dc
8 changed files with 280 additions and 82 deletions

View File

@@ -14,6 +14,7 @@
#include "core/rendering/render_info.hpp" // Para RenderInfo
#include "core/rendering/screen.hpp" // Para Screen
#include "core/resources/resource_helper.hpp" // Para Resource::Helper
#include "core/resources/resource_list.hpp" // Para Resource::List
#include "external/fkyaml_node.hpp" // Para fkyaml::node
#include "game/game_control.hpp" // Para GameControl
#include "game/options.hpp" // Para Options
@@ -703,6 +704,14 @@ static auto cmd_edit(const std::vector<std::string>& args) -> std::string {
}
return "usage: edit [on|off|revert]";
}
// SET <property> <value> — modifica propiedad del enemigo seleccionado en el editor
static auto cmd_set(const std::vector<std::string>& args) -> std::string {
if (!MapEditor::get() || !MapEditor::get()->isActive()) { return "Editor not active"; }
if (!MapEditor::get()->hasSelectedEnemy()) { return "No enemy selected"; }
if (args.size() < 2) { return "usage: set <animation|color|vx|vy|flip> <value>"; }
return MapEditor::get()->setEnemyProperty(args[0], args[1]);
}
#endif
// SHOW [INFO|NOTIFICATION|CHEEVO]
@@ -904,6 +913,7 @@ void CommandRegistry::registerHandlers() {
handlers_["cmd_room"] = cmd_room;
handlers_["cmd_scene"] = cmd_scene;
handlers_["cmd_edit"] = cmd_edit;
handlers_["cmd_set"] = cmd_set;
#endif
// HELP se registra en load() como lambda que captura this
@@ -930,6 +940,29 @@ void CommandRegistry::registerHandlers() {
}
return result;
};
#ifdef _DEBUG
// SET COLOR: colores de la paleta (UPPERCASE, sin .yaml)
dynamic_providers_["SET COLOR"] = []() -> 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"};
};
// SET ANIMATION: animaciones de enemigos (nombres sin extensión, UPPERCASE)
dynamic_providers_["SET ANIMATION"] = []() -> std::vector<std::string> {
std::vector<std::string> result;
auto list = Resource::List::get()->getListByType(Resource::List::Type::ANIMATION);
for (const auto& path : list) {
if (path.find("enemies") == std::string::npos) { continue; }
std::string name = getFileName(path);
auto dot = name.rfind('.');
if (dot != std::string::npos) { name = name.substr(0, dot); }
result.push_back(toUpper(name));
}
return result;
};
#endif
}
void CommandRegistry::load(const std::string& yaml_path) {