treballant en sistema de portes i claus
This commit is contained in:
@@ -11,24 +11,24 @@
|
||||
#include <iostream> // Para cout
|
||||
#include <set> // Para set
|
||||
|
||||
#include "core/input/mouse.hpp" // Para Mouse
|
||||
#include "core/rendering/render_info.hpp" // Para RenderInfo
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource::Cache
|
||||
#include "core/resources/resource_list.hpp" // Para Resource::List
|
||||
#include "core/resources/resource_types.hpp" // Para RoomResource
|
||||
#include "game/editor/editor_statusbar.hpp" // Para EditorStatusBar
|
||||
#include "game/editor/room_saver.hpp" // Para RoomSaver
|
||||
#include "game/entities/player.hpp" // Para Player
|
||||
#include "game/game_control.hpp" // Para GameControl
|
||||
#include "game/gameplay/enemy_manager.hpp" // Para EnemyManager
|
||||
#include "game/gameplay/item_manager.hpp" // Para ItemManager
|
||||
#include "game/gameplay/platform_manager.hpp" // Para PlatformManager
|
||||
#include "game/gameplay/room.hpp" // Para Room
|
||||
#include "game/options.hpp" // Para Options
|
||||
#include "game/ui/console.hpp" // Para Console
|
||||
#include "utils/defines.hpp" // Para Tile::SIZE, PlayArea
|
||||
#include "core/input/mouse.hpp" // Para Mouse
|
||||
#include "core/rendering/render_info.hpp" // Para RenderInfo
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource::Cache
|
||||
#include "core/resources/resource_list.hpp" // Para Resource::List
|
||||
#include "core/resources/resource_types.hpp" // Para RoomResource
|
||||
#include "game/editor/editor_statusbar.hpp" // Para EditorStatusBar
|
||||
#include "game/editor/room_saver.hpp" // Para RoomSaver
|
||||
#include "game/entities/player.hpp" // Para Player
|
||||
#include "game/game_control.hpp" // Para GameControl
|
||||
#include "game/gameplay/enemy_manager.hpp" // Para EnemyManager
|
||||
#include "game/gameplay/item_manager.hpp" // Para ItemManager
|
||||
#include "game/gameplay/platform_manager.hpp" // Para PlatformManager
|
||||
#include "game/gameplay/room.hpp" // Para Room
|
||||
#include "game/options.hpp" // Para Options
|
||||
#include "game/ui/console.hpp" // Para Console
|
||||
#include "utils/defines.hpp" // Para Tile::SIZE, PlayArea
|
||||
#include "utils/utils.hpp"
|
||||
|
||||
// Singleton
|
||||
@@ -912,19 +912,27 @@ auto MapEditor::pointInRect(float px, float py, const SDL_FRect& rect) -> bool {
|
||||
|
||||
auto MapEditor::entityCount(EntityType type) const -> int {
|
||||
switch (type) {
|
||||
case EntityType::ENEMY: return room_->getEnemyManager()->getCount();
|
||||
case EntityType::ITEM: return room_->getItemManager()->getCount();
|
||||
case EntityType::PLATFORM: return room_->getPlatformManager()->getCount();
|
||||
default: return 0;
|
||||
case EntityType::ENEMY:
|
||||
return room_->getEnemyManager()->getCount();
|
||||
case EntityType::ITEM:
|
||||
return room_->getItemManager()->getCount();
|
||||
case EntityType::PLATFORM:
|
||||
return room_->getPlatformManager()->getCount();
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
auto MapEditor::entityRect(EntityType type, int index) -> SDL_FRect {
|
||||
switch (type) {
|
||||
case EntityType::ENEMY: return room_->getEnemyManager()->getEnemy(index)->getRect();
|
||||
case EntityType::ITEM: return room_->getItemManager()->getItem(index)->getCollider();
|
||||
case EntityType::PLATFORM: return room_->getPlatformManager()->getPlatform(index)->getRect();
|
||||
default: return {};
|
||||
case EntityType::ENEMY:
|
||||
return room_->getEnemyManager()->getEnemy(index)->getRect();
|
||||
case EntityType::ITEM:
|
||||
return room_->getItemManager()->getItem(index)->getCollider();
|
||||
case EntityType::PLATFORM:
|
||||
return room_->getPlatformManager()->getPlatform(index)->getRect();
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -938,37 +946,49 @@ auto MapEditor::entityBoundaries(EntityType type, int index) const -> BoundaryDa
|
||||
const auto& e = room_data_.enemies[index];
|
||||
return {e.x1, e.y1, e.x2, e.y2};
|
||||
}
|
||||
default: return {};
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
auto MapEditor::entityPosition(EntityType type, int index) const -> std::pair<float, float> {
|
||||
switch (type) {
|
||||
case EntityType::ENEMY: return {room_data_.enemies[index].x, room_data_.enemies[index].y};
|
||||
case EntityType::ITEM: return {room_data_.items[index].x, room_data_.items[index].y};
|
||||
case EntityType::ENEMY:
|
||||
return {room_data_.enemies[index].x, room_data_.enemies[index].y};
|
||||
case EntityType::ITEM:
|
||||
return {room_data_.items[index].x, room_data_.items[index].y};
|
||||
case EntityType::PLATFORM: {
|
||||
const auto& path = room_data_.platforms[index].path;
|
||||
return path.empty() ? std::pair{0.0F, 0.0F} : std::pair{path[0].x, path[0].y};
|
||||
}
|
||||
default: return {0.0F, 0.0F};
|
||||
default:
|
||||
return {0.0F, 0.0F};
|
||||
}
|
||||
}
|
||||
|
||||
auto MapEditor::entityDataCount(EntityType type) const -> int {
|
||||
switch (type) {
|
||||
case EntityType::ENEMY: return static_cast<int>(room_data_.enemies.size());
|
||||
case EntityType::ITEM: return static_cast<int>(room_data_.items.size());
|
||||
case EntityType::PLATFORM: return static_cast<int>(room_data_.platforms.size());
|
||||
default: return 0;
|
||||
case EntityType::ENEMY:
|
||||
return static_cast<int>(room_data_.enemies.size());
|
||||
case EntityType::ITEM:
|
||||
return static_cast<int>(room_data_.items.size());
|
||||
case EntityType::PLATFORM:
|
||||
return static_cast<int>(room_data_.platforms.size());
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
auto MapEditor::entityLabel(EntityType type) -> const char* {
|
||||
switch (type) {
|
||||
case EntityType::ENEMY: return "enemy";
|
||||
case EntityType::ITEM: return "item";
|
||||
case EntityType::PLATFORM: return "platform";
|
||||
default: return "none";
|
||||
case EntityType::ENEMY:
|
||||
return "enemy";
|
||||
case EntityType::ITEM:
|
||||
return "item";
|
||||
case EntityType::PLATFORM:
|
||||
return "platform";
|
||||
default:
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1226,10 +1246,14 @@ void MapEditor::updateStatusBarInfo() { // NOLINT(readability-function-cognitiv
|
||||
// Devuelve las propiedades válidas de SET según la selección actual
|
||||
auto MapEditor::getSetCompletions() const -> std::vector<std::string> {
|
||||
switch (selection_.type) {
|
||||
case EntityType::ENEMY: return {"ANIMATION", "VX", "VY", "FLIP", "MIRROR"};
|
||||
case EntityType::ITEM: return {"TILE", "COUNTER"};
|
||||
case EntityType::PLATFORM: return {"ANIMATION", "SPEED", "LOOP", "EASING"};
|
||||
default: return {"ITEMCOLOR1", "ITEMCOLOR2", "CONVEYOR", "TILESET", "UP", "DOWN", "LEFT", "RIGHT"};
|
||||
case EntityType::ENEMY:
|
||||
return {"ANIMATION", "VX", "VY", "FLIP", "MIRROR"};
|
||||
case EntityType::ITEM:
|
||||
return {"TILE", "COUNTER"};
|
||||
case EntityType::PLATFORM:
|
||||
return {"ANIMATION", "SPEED", "LOOP", "EASING"};
|
||||
default:
|
||||
return {"ITEMCOLOR1", "ITEMCOLOR2", "CONVEYOR", "TILESET", "UP", "DOWN", "LEFT", "RIGHT"};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1935,8 +1959,7 @@ auto MapEditor::addPlatform() -> std::string {
|
||||
constexpr float ROUTE_HALF = 2.0F * Tile::SIZE;
|
||||
new_platform.path = {
|
||||
{CENTER_X - ROUTE_HALF, CENTER_Y, 0.0F},
|
||||
{CENTER_X + ROUTE_HALF, CENTER_Y, 0.0F}
|
||||
};
|
||||
{CENTER_X + ROUTE_HALF, CENTER_Y, 0.0F}};
|
||||
|
||||
room_data_.platforms.push_back(new_platform);
|
||||
room_->getPlatformManager()->addPlatform(std::make_shared<MovingPlatform>(new_platform));
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string> // Para string
|
||||
|
||||
#include "external/fkyaml_node.hpp" // Para fkyaml::node
|
||||
#include "game/editor/mini_map.hpp" // Para MiniMap
|
||||
#include "game/editor/tile_picker.hpp" // Para TilePicker
|
||||
#include "external/fkyaml_node.hpp" // Para fkyaml::node
|
||||
#include "game/editor/mini_map.hpp" // Para MiniMap
|
||||
#include "game/editor/tile_picker.hpp" // Para TilePicker
|
||||
#include "game/entities/enemy.hpp" // Para Enemy::Data
|
||||
#include "game/entities/item.hpp" // Para Item::Data
|
||||
#include "game/entities/moving_platform.hpp" // Para MovingPlatform::Data
|
||||
@@ -21,13 +21,19 @@
|
||||
class EditorStatusBar;
|
||||
|
||||
// Tipo de entidad editable en el editor
|
||||
enum class EntityType { NONE, ENEMY, ITEM, PLATFORM };
|
||||
enum class EntityType { NONE,
|
||||
ENEMY,
|
||||
ITEM,
|
||||
PLATFORM };
|
||||
|
||||
// Seleccion unificada: una sola entidad seleccionada a la vez
|
||||
struct Selection {
|
||||
EntityType type{EntityType::NONE};
|
||||
int index{-1};
|
||||
void clear() { type = EntityType::NONE; index = -1; }
|
||||
void clear() {
|
||||
type = EntityType::NONE;
|
||||
index = -1;
|
||||
}
|
||||
[[nodiscard]] auto isNone() const -> bool { return type == EntityType::NONE; }
|
||||
[[nodiscard]] auto is(EntityType t) const -> bool { return type == t && index >= 0; }
|
||||
};
|
||||
@@ -140,7 +146,9 @@ class MapEditor {
|
||||
static auto pointInRect(float px, float py, const SDL_FRect& rect) -> bool;
|
||||
|
||||
// Entity helpers: acceso abstracto a datos de entidad por tipo
|
||||
struct BoundaryData { int x1, y1, x2, y2; };
|
||||
struct BoundaryData {
|
||||
int x1, y1, x2, y2;
|
||||
};
|
||||
auto entityCount(EntityType type) const -> int;
|
||||
auto entityRect(EntityType type, int index) -> SDL_FRect;
|
||||
static auto entityHasBoundaries(EntityType type) -> bool;
|
||||
@@ -152,7 +160,7 @@ class MapEditor {
|
||||
// Estado del editor
|
||||
bool active_{false};
|
||||
DragState drag_;
|
||||
Selection selection_; // Entidad seleccionada (unificada: enemy, item o platform)
|
||||
Selection selection_; // Entidad seleccionada (unificada: enemy, item o platform)
|
||||
static constexpr int NO_BRUSH = -2; // Sin brush activo
|
||||
static constexpr int ERASER_BRUSH = -1; // Brush borrador (pinta tile vacío = -1)
|
||||
int brush_tile_{NO_BRUSH}; // Tile activo para pintar
|
||||
|
||||
Reference in New Issue
Block a user