refactor de l'editor
This commit is contained in:
@@ -728,7 +728,7 @@ static auto cmdEdit(const std::vector<std::string>& args) -> std::string { // N
|
||||
return "usage: edit [on|off|revert|show|hide|mapbg|mapconn] [...]";
|
||||
}
|
||||
|
||||
// SET <property> <value> — modifica propiedad del enemigo seleccionado o de la habitación
|
||||
// SET <property> <value> — modifica propiedad de la entidad seleccionada o de la habitación
|
||||
static auto cmdSet(const std::vector<std::string>& args) -> std::string {
|
||||
if ((MapEditor::get() == nullptr) || !MapEditor::get()->isActive()) { return "Editor not active"; }
|
||||
if (args.empty()) { return "usage: set <property> <value>"; }
|
||||
@@ -740,18 +740,12 @@ static auto cmdSet(const std::vector<std::string>& args) -> std::string {
|
||||
|
||||
if (args.size() < 2) { return "usage: set <property> <value>"; }
|
||||
|
||||
// Si hay enemigo seleccionado, aplicar a enemigo
|
||||
if (MapEditor::get()->hasSelectedEnemy()) {
|
||||
return MapEditor::get()->setEnemyProperty(args[0], args[1]);
|
||||
switch (MapEditor::get()->getSelectionType()) {
|
||||
case EntityType::ENEMY: return MapEditor::get()->setEnemyProperty(args[0], args[1]);
|
||||
case EntityType::ITEM: return MapEditor::get()->setItemProperty(args[0], args[1]);
|
||||
case EntityType::PLATFORM: return MapEditor::get()->setPlatformProperty(args[0], args[1]);
|
||||
default: return MapEditor::get()->setRoomProperty(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]);
|
||||
}
|
||||
|
||||
// ENEMY [ADD|DELETE|DUPLICATE]
|
||||
@@ -785,6 +779,22 @@ static auto cmdItem(const std::vector<std::string>& args) -> std::string {
|
||||
}
|
||||
return "usage: item <add|delete|duplicate>";
|
||||
}
|
||||
|
||||
// PLATFORM [ADD|DELETE|DUPLICATE]
|
||||
static auto cmdPlatform(const std::vector<std::string>& args) -> std::string {
|
||||
if ((MapEditor::get() == nullptr) || !MapEditor::get()->isActive()) { return "Editor not active"; }
|
||||
if (args.empty()) { return "usage: platform <add|delete|duplicate>"; }
|
||||
if (args[0] == "ADD") { return MapEditor::get()->addPlatform(); }
|
||||
if (args[0] == "DELETE") {
|
||||
if (!MapEditor::get()->hasSelectedPlatform()) { return "No platform selected"; }
|
||||
return MapEditor::get()->deletePlatform();
|
||||
}
|
||||
if (args[0] == "DUPLICATE") {
|
||||
if (!MapEditor::get()->hasSelectedPlatform()) { return "No platform selected"; }
|
||||
return MapEditor::get()->duplicatePlatform();
|
||||
}
|
||||
return "usage: platform <add|delete|duplicate>";
|
||||
}
|
||||
#endif
|
||||
|
||||
// SHOW [INFO|NOTIFICATION|CHEEVO]
|
||||
@@ -933,6 +943,7 @@ void CommandRegistry::registerHandlers() { // NOLINT(readability-function-cogni
|
||||
handlers_["cmd_set"] = cmdSet;
|
||||
handlers_["cmd_enemy"] = cmdEnemy;
|
||||
handlers_["cmd_item"] = cmdItem;
|
||||
handlers_["cmd_platform"] = cmdPlatform;
|
||||
#endif
|
||||
// HELP se registra en load() como lambda que captura this
|
||||
|
||||
|
||||
Reference in New Issue
Block a user