1#ifndef YAZE_APP_EDITOR_DUNGEON_INTERACTION_TILE_OBJECT_HANDLER_H
2#define YAZE_APP_EDITOR_DUNGEON_INTERACTION_TILE_OBJECT_HANDLER_H
38 bool HandleClick(
int canvas_x,
int canvas_y)
override;
39 void HandleDrag(ImVec2 current_pos, ImVec2 delta)
override;
46 void InitDrag(
const ImVec2& start_pos);
57 bool mouse_left_released,
bool shift_down,
58 bool toggle_down,
bool alt_down,
59 bool draw_box =
true);
66 void MoveObjects(
int room_id,
const std::vector<size_t>& indices,
int delta_x,
67 int delta_y,
bool notify_mutation =
true);
74 const std::vector<size_t>& indices,
75 int delta_x,
int delta_y,
76 bool notify_mutation =
true);
91 void SendToFront(
int room_id,
const std::vector<size_t>& indices);
92 void SendToBack(
int room_id,
const std::vector<size_t>& indices);
93 void MoveForward(
int room_id,
const std::vector<size_t>& indices);
94 void MoveBackward(
int room_id,
const std::vector<size_t>& indices);
99 void ResizeObjects(
int room_id,
const std::vector<size_t>& indices,
int delta);
117 void UpdateObjectsId(
int room_id,
const std::vector<size_t>& indices, int16_t new_id);
119 void UpdateObjectsSize(
int room_id,
const std::vector<size_t>& indices, uint8_t new_size);
121 void UpdateObjectsLayer(
int room_id,
const std::vector<size_t>& indices,
int new_layer);
Abstract base class for entity interaction handlers.
void SetContext(InteractionContext *ctx)
Set the interaction context.
Handles functional mutations and queries for tile objects.
zelda3::RoomObject preview_object_
void DrawGhostPreview() override
Draw ghost preview during placement.
std::vector< zelda3::RoomObject > clipboard_
bool was_placement_blocked() const
True if the most recent PlaceObjectAt was blocked.
void HandleMarqueeSelection(const ImVec2 &mouse_pos, bool mouse_left_down, bool mouse_left_released, bool shift_down, bool toggle_down, bool alt_down, bool draw_box=true)
void BeginPlacement() override
Begin placement mode.
bool HandleMouseWheel(float delta) override
std::unique_ptr< gfx::BackgroundBuffer > ghost_preview_buffer_
void ClearClipboard()
Clear the clipboard.
bool HasClipboardData() const
Check if clipboard has data.
void UpdateObjectsSize(int room_id, const std::vector< size_t > &indices, uint8_t new_size)
void SendToFront(int room_id, const std::vector< size_t > &indices)
Reorder objects.
void RenderGhostPreviewBitmap()
std::vector< size_t > DuplicateObjects(int room_id, const std::vector< size_t > &indices, int delta_x, int delta_y, bool notify_mutation=true)
Clone a set of objects and move them by a tile delta.
void clear_placement_blocked()
void DeleteAllObjects(int room_id)
Delete all objects in a room.
void MoveBackward(int room_id, const std::vector< size_t > &indices)
ImVec2 ApplyDragModifiers(const ImVec2 &delta) const
void HandleRelease() override
Handle mouse release.
void CopyObjectsToClipboard(int room_id, const std::vector< size_t > &indices)
Copy objects to internal clipboard.
bool drag_has_duplicated_
void HandleDrag(ImVec2 current_pos, ImVec2 delta) override
Handle mouse drag.
void UpdateObjectsLayer(int room_id, const std::vector< size_t > &indices, int new_layer)
std::vector< size_t > PasteFromClipboardAt(int room_id, int target_x, int target_y)
Paste objects from clipboard at target location. Use first clipboard item as origin.
void DrawSelectionHighlight() override
Draw selection highlight for selected entities.
bool IsPlacementActive() const override
Check if placement mode is active.
bool PlaceObjectAt(int room_id, const zelda3::RoomObject &object, int x, int y)
Place a new object. Returns false if blocked by ROM limits.
void SendToBack(int room_id, const std::vector< size_t > &indices)
std::vector< size_t > PasteFromClipboard(int room_id, int offset_x, int offset_y)
Paste objects from clipboard with offset.
bool HandleClick(int canvas_x, int canvas_y) override
Handle mouse click at canvas position.
bool object_placement_mode_
void SetPreviewObject(const zelda3::RoomObject &object)
Set object for placement.
PlacementBlockReason placement_block_reason() const
void BeginMarqueeSelection(const ImVec2 &start_pos)
void MoveForward(int room_id, const std::vector< size_t > &indices)
void MoveObjects(int room_id, const std::vector< size_t > &indices, int delta_x, int delta_y, bool notify_mutation=true)
Move a set of objects by a tile delta.
void CancelPlacement() override
Cancel current placement.
PlacementBlockReason placement_block_reason_
void DeleteObjects(int room_id, std::vector< size_t > indices)
Delete objects by indices.
bool drag_mutation_started_
TileObjectHandler(InteractionContext *ctx)
void UpdateObjectsId(int room_id, const std::vector< size_t > &indices, int16_t new_id)
zelda3::Room * GetRoom(int room_id)
std::pair< int, int > CalculateObjectBounds(const zelda3::RoomObject &object)
void NotifyChange(zelda3::Room *room)
void ResizeObjects(int room_id, const std::vector< size_t > &indices, int delta)
Resize objects by a delta.
std::optional< size_t > GetEntityAtPosition(int canvas_x, int canvas_y) const override
Get entity at canvas position.
void InitDrag(const ImVec2 &start_pos)
Editors are the view controllers for the application.
Shared context for all interaction handlers.