drag'n drop de enemics, boundaries i items
This commit is contained in:
@@ -18,12 +18,11 @@ class EditorStatusBar;
|
||||
|
||||
class MapEditor {
|
||||
public:
|
||||
static void init(); // [SINGLETON] Crea el objeto
|
||||
static void destroy(); // [SINGLETON] Destruye el objeto
|
||||
static auto get() -> MapEditor*; // [SINGLETON] Obtiene el objeto
|
||||
static void init(); // [SINGLETON] Crea el objeto
|
||||
static void destroy(); // [SINGLETON] Destruye el objeto
|
||||
static auto get() -> MapEditor*; // [SINGLETON] Obtiene el objeto
|
||||
|
||||
void enter(std::shared_ptr<Room> room, std::shared_ptr<Player> player,
|
||||
const std::string& room_path, std::shared_ptr<Scoreboard::Data> scoreboard_data);
|
||||
void enter(std::shared_ptr<Room> room, std::shared_ptr<Player> player, const std::string& room_path, std::shared_ptr<Scoreboard::Data> scoreboard_data);
|
||||
void exit();
|
||||
[[nodiscard]] auto isActive() const -> bool { return active_; }
|
||||
|
||||
@@ -38,26 +37,31 @@ class MapEditor {
|
||||
~MapEditor(); // Destructor
|
||||
|
||||
// Tipos para drag & drop
|
||||
enum class DragTarget { NONE, PLAYER, ENEMY_INITIAL, ENEMY_BOUND1, ENEMY_BOUND2, ITEM };
|
||||
enum class DragTarget { NONE,
|
||||
PLAYER,
|
||||
ENEMY_INITIAL,
|
||||
ENEMY_BOUND1,
|
||||
ENEMY_BOUND2,
|
||||
ITEM };
|
||||
|
||||
struct DragState {
|
||||
DragTarget target{DragTarget::NONE};
|
||||
int index{-1}; // Índice del enemigo o item en room_data_
|
||||
float offset_x{0.0F}; // Offset entre el cursor y el origen de la entidad al inicio del drag
|
||||
int index{-1}; // Índice del enemigo o item en room_data_
|
||||
float offset_x{0.0F}; // Offset entre el cursor y el origen de la entidad al inicio del drag
|
||||
float offset_y{0.0F};
|
||||
float snap_x{0.0F}; // Posición snapped actual (para preview)
|
||||
float snap_x{0.0F}; // Posición snapped actual (para preview)
|
||||
float snap_y{0.0F};
|
||||
};
|
||||
|
||||
// Métodos internos
|
||||
void updateMousePosition(); // Convierte coordenadas de ventana a coordenadas de juego y tile
|
||||
void renderEnemyBoundaries(); // Dibuja marcadores de boundaries y líneas de ruta
|
||||
void renderBoundaryMarker(float x, float y, Uint8 color); // Dibuja un marcador de boundary en una posición
|
||||
void renderSelectionHighlight(); // Dibuja highlight del elemento seleccionado/arrastrado
|
||||
void handleMouseDown(float game_x, float game_y); // Procesa click del ratón (hit test + inicio de drag)
|
||||
void handleMouseUp(); // Procesa soltar el ratón (commit del drag)
|
||||
void updateDrag(); // Actualiza la posición snapped durante el drag
|
||||
static auto snapToGrid(float value) -> float; // Alinea un valor a la cuadrícula de 8x8
|
||||
void updateMousePosition(); // Convierte coordenadas de ventana a coordenadas de juego y tile
|
||||
void renderEnemyBoundaries(); // Dibuja marcadores de boundaries y líneas de ruta
|
||||
void renderBoundaryMarker(float x, float y, Uint8 color); // Dibuja un marcador de boundary en una posición
|
||||
void renderSelectionHighlight(); // Dibuja highlight del elemento seleccionado/arrastrado
|
||||
void handleMouseDown(float game_x, float game_y); // Procesa click del ratón (hit test + inicio de drag)
|
||||
void handleMouseUp(); // Procesa soltar el ratón (commit del drag)
|
||||
void updateDrag(); // Actualiza la posición snapped durante el drag
|
||||
static auto snapToGrid(float value) -> float; // Alinea un valor a la cuadrícula de 8x8
|
||||
static auto pointInRect(float px, float py, const SDL_FRect& rect) -> bool; // Hit test punto en rectángulo
|
||||
|
||||
// Estado del editor
|
||||
|
||||
Reference in New Issue
Block a user