- eliminades entrades deprecated en assets.yaml
- corregit autocompletat dinamic de set animation segons el tipo de entitat - refeta la animació de la porta
This commit is contained in:
@@ -5,11 +5,13 @@
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath> // Para std::round
|
||||
#include <cstdio> // Para std::remove (borrar fichero)
|
||||
#include <fstream> // Para ifstream, ofstream
|
||||
#include <iostream> // Para cout
|
||||
#include <set> // Para set
|
||||
#include <cmath> // Para std::round
|
||||
#include <cstdio> // Para std::remove (borrar fichero)
|
||||
#include <filesystem> // Para directory_iterator (getAnimationCompletions)
|
||||
#include <fstream> // Para ifstream, ofstream
|
||||
#include <iostream> // Para cout
|
||||
#include <set> // Para set
|
||||
#include <system_error> // Para std::error_code
|
||||
|
||||
#include "core/input/mouse.hpp" // Para Mouse
|
||||
#include "core/rendering/render_info.hpp" // Para RenderInfo
|
||||
@@ -1350,6 +1352,32 @@ auto MapEditor::getSetCompletions() const -> std::vector<std::string> {
|
||||
}
|
||||
}
|
||||
|
||||
// Devuelve la lista de animaciones disponibles para la entidad seleccionada,
|
||||
// escaneando la carpeta correspondiente en data/. Cada tipo de entidad solo
|
||||
// puede usar animaciones de su propio directorio. Para entidades sin animación
|
||||
// (Item, Room/none) devuelve lista vacía.
|
||||
auto MapEditor::getAnimationCompletions() const -> std::vector<std::string> {
|
||||
const char* folder = nullptr;
|
||||
switch (selection_.type) {
|
||||
case EntityType::ENEMY: folder = "data/enemies"; break;
|
||||
case EntityType::PLATFORM: folder = "data/platforms"; break;
|
||||
case EntityType::KEY: folder = "data/keys"; break;
|
||||
case EntityType::DOOR: folder = "data/doors"; break;
|
||||
default: return {};
|
||||
}
|
||||
std::vector<std::string> result;
|
||||
std::error_code ec;
|
||||
for (const auto& entry : std::filesystem::directory_iterator(folder, ec)) {
|
||||
if (ec) { break; }
|
||||
if (!entry.is_regular_file()) { continue; }
|
||||
const auto& path = entry.path();
|
||||
if (path.extension() != ".yaml") { continue; }
|
||||
result.push_back(toUpper(path.stem().string()));
|
||||
}
|
||||
std::sort(result.begin(), result.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
// Modifica una propiedad del enemigo seleccionado
|
||||
auto MapEditor::setEnemyProperty(const std::string& property, const std::string& value) -> std::string { // NOLINT(readability-function-cognitive-complexity)
|
||||
if (!active_) { return "Editor not active"; }
|
||||
|
||||
@@ -63,6 +63,7 @@ class MapEditor {
|
||||
auto duplicateEnemy() -> std::string;
|
||||
[[nodiscard]] auto hasSelectedEnemy() const -> bool { return selection_.is(EntityType::ENEMY); }
|
||||
[[nodiscard]] auto getSetCompletions() const -> std::vector<std::string>;
|
||||
[[nodiscard]] auto getAnimationCompletions() const -> std::vector<std::string>;
|
||||
|
||||
// Comandos para propiedades de la habitación
|
||||
auto setRoomProperty(const std::string& property, const std::string& value) -> std::string;
|
||||
|
||||
@@ -238,6 +238,20 @@ void Player::startJump() {
|
||||
|
||||
void Player::moveHorizontal(float delta_time) {
|
||||
const auto& tc = room_->getTileCollider();
|
||||
|
||||
// Early exit: si hay pared inmediata en la dirección de movimiento, parar
|
||||
// y poner vx_=0. Sin esto, el player choca, queda re-posicionado en el
|
||||
// mismo sitio pero conserva vx_ != 0, así que animate() reproduce walk
|
||||
// anim continuamente mientras empuja contra la pared.
|
||||
if (vx_ > 0.0F && tc.checkWallRight(x_, y_, WIDTH, HEIGHT) != Collision::NONE) {
|
||||
vx_ = 0.0F;
|
||||
return;
|
||||
}
|
||||
if (vx_ < 0.0F && tc.checkWallLeft(x_, y_, WIDTH, HEIGHT) != Collision::NONE) {
|
||||
vx_ = 0.0F;
|
||||
return;
|
||||
}
|
||||
|
||||
float new_x = x_ + (vx_ * delta_time);
|
||||
|
||||
// Comprobar ambos muros siempre (el tilemap extendido incluye paredes de rooms
|
||||
|
||||
@@ -1043,18 +1043,14 @@ void CommandRegistry::registerHandlers() { // NOLINT(readability-function-cogni
|
||||
dynamic_providers_["SET ITEMCOLOR1"] = color_provider;
|
||||
dynamic_providers_["SET ITEMCOLOR2"] = color_provider;
|
||||
|
||||
// SET ANIMATION: animaciones de enemigos (nombres sin extensión, UPPERCASE)
|
||||
// SET ANIMATION: animaciones disponibles para la entidad seleccionada en
|
||||
// el editor. La lista la calcula MapEditor escaneando data/<carpeta>/ del
|
||||
// tipo de entidad correspondiente.
|
||||
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));
|
||||
if (MapEditor::get() != nullptr && MapEditor::get()->isActive()) {
|
||||
return MapEditor::get()->getAnimationCompletions();
|
||||
}
|
||||
return result;
|
||||
return {};
|
||||
};
|
||||
|
||||
// SET TILESET: tilesets disponibles (nombres sin extensión, UPPERCASE)
|
||||
|
||||
Reference in New Issue
Block a user