Handles object selection, placement, and interaction within the dungeon canvas. More...
#include <dungeon_object_interaction.h>
Public Member Functions | |
DungeonObjectInteraction (gui::Canvas *canvas) | |
void | HandleCanvasMouseInput () |
void | CheckForObjectSelection () |
void | PlaceObjectAtPosition (int room_x, int room_y) |
void | DrawObjectSelectRect () |
void | SelectObjectsInRect () |
void | DrawSelectionHighlights () |
void | DrawSelectBox () |
void | DrawDragPreview () |
void | UpdateSelectedObjects () |
bool | IsObjectInSelectBox (const zelda3::RoomObject &object) const |
std::pair< int, int > | RoomToCanvasCoordinates (int room_x, int room_y) const |
std::pair< int, int > | CanvasToRoomCoordinates (int canvas_x, int canvas_y) const |
bool | IsWithinCanvasBounds (int canvas_x, int canvas_y, int margin=32) const |
void | SetCurrentRoom (std::array< zelda3::Room, 0x128 > *rooms, int room_id) |
void | SetPreviewObject (const zelda3::RoomObject &object, bool loaded) |
const std::vector< size_t > & | GetSelectedObjectIndices () const |
bool | IsObjectSelectActive () const |
void | ClearSelection () |
void | ShowContextMenu () |
void | HandleDeleteSelected () |
void | HandleCopySelected () |
void | HandlePasteObjects () |
void | SetObjectPlacedCallback (std::function< void(const zelda3::RoomObject &)> callback) |
void | SetCacheInvalidationCallback (std::function< void()> callback) |
Private Attributes | |
gui::Canvas * | canvas_ |
std::array< zelda3::Room, 0x128 > * | rooms_ = nullptr |
int | current_room_id_ = 0 |
zelda3::RoomObject | preview_object_ {0, 0, 0, 0, 0} |
bool | object_loaded_ = false |
bool | is_dragging_ = false |
bool | is_selecting_ = false |
ImVec2 | drag_start_pos_ |
ImVec2 | drag_current_pos_ |
ImVec2 | select_start_pos_ |
ImVec2 | select_current_pos_ |
std::vector< int > | selected_objects_ |
bool | object_select_active_ = false |
ImVec2 | object_select_start_ |
ImVec2 | object_select_end_ |
std::vector< size_t > | selected_object_indices_ |
std::function< void(const zelda3::RoomObject &)> | object_placed_callback_ |
std::function< void()> | cache_invalidation_callback_ |
std::vector< zelda3::RoomObject > | clipboard_ |
bool | has_clipboard_data_ = false |
Handles object selection, placement, and interaction within the dungeon canvas.
This component manages mouse interactions for object selection (similar to OverworldEditor), object placement, drag operations, and multi-object selection.
Definition at line 21 of file dungeon_object_interaction.h.
|
inlineexplicit |
Definition at line 23 of file dungeon_object_interaction.h.
void yaze::editor::DungeonObjectInteraction::HandleCanvasMouseInput | ( | ) |
Definition at line 9 of file dungeon_object_interaction.cc.
References cache_invalidation_callback_, canvas_, yaze::gui::Canvas::canvas_size(), CanvasToRoomCoordinates(), current_room_id_, drag_current_pos_, drag_start_pos_, DrawDragPreview(), is_dragging_, is_selecting_, yaze::gui::Canvas::IsMouseHovering(), object_loaded_, PlaceObjectAtPosition(), rooms_, select_current_pos_, select_start_pos_, selected_object_indices_, selected_objects_, UpdateSelectedObjects(), and yaze::gui::Canvas::zero_point().
Referenced by yaze::editor::DungeonCanvasViewer::DrawDungeonCanvas().
void yaze::editor::DungeonObjectInteraction::CheckForObjectSelection | ( | ) |
Definition at line 103 of file dungeon_object_interaction.cc.
References DrawObjectSelectRect(), object_select_active_, and SelectObjectsInRect().
Referenced by yaze::editor::DungeonCanvasViewer::DrawDungeonCanvas().
void yaze::editor::DungeonObjectInteraction::PlaceObjectAtPosition | ( | int | room_x, |
int | room_y | ||
) |
Definition at line 238 of file dungeon_object_interaction.cc.
References cache_invalidation_callback_, current_room_id_, yaze::zelda3::RoomObject::id_, object_loaded_, object_placed_callback_, preview_object_, rooms_, and yaze::zelda3::RoomObject::x_.
Referenced by HandleCanvasMouseInput().
void yaze::editor::DungeonObjectInteraction::DrawObjectSelectRect | ( | ) |
Definition at line 113 of file dungeon_object_interaction.cc.
References canvas_, yaze::gui::Canvas::IsMouseHovering(), object_loaded_, object_select_active_, object_select_end_, object_select_start_, selected_object_indices_, SelectObjectsInRect(), and yaze::gui::Canvas::zero_point().
Referenced by CheckForObjectSelection().
void yaze::editor::DungeonObjectInteraction::SelectObjectsInRect | ( | ) |
Definition at line 158 of file dungeon_object_interaction.cc.
References CanvasToRoomCoordinates(), current_room_id_, object_select_end_, object_select_start_, rooms_, and selected_object_indices_.
Referenced by CheckForObjectSelection(), and DrawObjectSelectRect().
void yaze::editor::DungeonObjectInteraction::DrawSelectionHighlights | ( | ) |
Definition at line 183 of file dungeon_object_interaction.cc.
References canvas_, current_room_id_, rooms_, RoomToCanvasCoordinates(), selected_object_indices_, and yaze::gui::Canvas::zero_point().
Referenced by yaze::editor::DungeonCanvasViewer::DrawDungeonCanvas().
void yaze::editor::DungeonObjectInteraction::DrawSelectBox | ( | ) |
Definition at line 263 of file dungeon_object_interaction.cc.
References canvas_, is_selecting_, select_current_pos_, select_start_pos_, and yaze::gui::Canvas::zero_point().
Referenced by yaze::editor::DungeonCanvasViewer::DrawDungeonCanvas().
void yaze::editor::DungeonObjectInteraction::DrawDragPreview | ( | ) |
Definition at line 282 of file dungeon_object_interaction.cc.
References canvas_, current_room_id_, drag_current_pos_, drag_start_pos_, is_dragging_, rooms_, RoomToCanvasCoordinates(), selected_object_indices_, and yaze::gui::Canvas::zero_point().
Referenced by HandleCanvasMouseInput().
void yaze::editor::DungeonObjectInteraction::UpdateSelectedObjects | ( | ) |
Definition at line 319 of file dungeon_object_interaction.cc.
References current_room_id_, is_selecting_, IsObjectInSelectBox(), rooms_, and selected_objects_.
Referenced by HandleCanvasMouseInput().
bool yaze::editor::DungeonObjectInteraction::IsObjectInSelectBox | ( | const zelda3::RoomObject & | object | ) | const |
Definition at line 336 of file dungeon_object_interaction.cc.
References is_selecting_, RoomToCanvasCoordinates(), select_current_pos_, and select_start_pos_.
Referenced by UpdateSelectedObjects().
std::pair< int, int > yaze::editor::DungeonObjectInteraction::RoomToCanvasCoordinates | ( | int | room_x, |
int | room_y | ||
) | const |
Definition at line 354 of file dungeon_object_interaction.cc.
Referenced by DrawDragPreview(), DrawSelectionHighlights(), and IsObjectInSelectBox().
std::pair< int, int > yaze::editor::DungeonObjectInteraction::CanvasToRoomCoordinates | ( | int | canvas_x, |
int | canvas_y | ||
) | const |
Definition at line 359 of file dungeon_object_interaction.cc.
Referenced by HandleCanvasMouseInput(), HandlePasteObjects(), and SelectObjectsInRect().
bool yaze::editor::DungeonObjectInteraction::IsWithinCanvasBounds | ( | int | canvas_x, |
int | canvas_y, | ||
int | margin = 32 |
||
) | const |
Definition at line 364 of file dungeon_object_interaction.cc.
References canvas_, yaze::gui::Canvas::canvas_size(), and yaze::gui::Canvas::global_scale().
void yaze::editor::DungeonObjectInteraction::SetCurrentRoom | ( | std::array< zelda3::Room, 0x128 > * | rooms, |
int | room_id | ||
) |
Definition at line 375 of file dungeon_object_interaction.cc.
References current_room_id_, and rooms_.
Referenced by yaze::editor::DungeonCanvasViewer::DrawDungeonCanvas().
void yaze::editor::DungeonObjectInteraction::SetPreviewObject | ( | const zelda3::RoomObject & | object, |
bool | loaded | ||
) |
Definition at line 380 of file dungeon_object_interaction.cc.
References object_loaded_, and preview_object_.
Referenced by yaze::editor::DungeonCanvasViewer::ClearPreviewObject(), and yaze::editor::DungeonCanvasViewer::SetPreviewObject().
|
inline |
Definition at line 51 of file dungeon_object_interaction.h.
References selected_object_indices_.
Referenced by yaze::editor::ObjectEditorCard::DrawSelectedObjectInfo().
|
inline |
Definition at line 52 of file dungeon_object_interaction.h.
References object_select_active_.
void yaze::editor::DungeonObjectInteraction::ClearSelection | ( | ) |
Definition at line 385 of file dungeon_object_interaction.cc.
References is_dragging_, is_selecting_, object_select_active_, and selected_object_indices_.
Referenced by HandleDeleteSelected().
void yaze::editor::DungeonObjectInteraction::ShowContextMenu | ( | ) |
Definition at line 392 of file dungeon_object_interaction.cc.
References canvas_, HandleCopySelected(), HandleDeleteSelected(), HandlePasteObjects(), has_clipboard_data_, yaze::zelda3::RoomObject::id_, is_dragging_, yaze::gui::Canvas::IsMouseHovering(), object_loaded_, preview_object_, and selected_object_indices_.
Referenced by yaze::editor::DungeonCanvasViewer::DrawDungeonCanvas().
void yaze::editor::DungeonObjectInteraction::HandleDeleteSelected | ( | ) |
Definition at line 433 of file dungeon_object_interaction.cc.
References cache_invalidation_callback_, ClearSelection(), current_room_id_, rooms_, and selected_object_indices_.
Referenced by yaze::editor::DungeonCanvasViewer::DrawDungeonCanvas(), and ShowContextMenu().
void yaze::editor::DungeonObjectInteraction::HandleCopySelected | ( | ) |
Definition at line 457 of file dungeon_object_interaction.cc.
References clipboard_, current_room_id_, has_clipboard_data_, rooms_, and selected_object_indices_.
Referenced by ShowContextMenu().
void yaze::editor::DungeonObjectInteraction::HandlePasteObjects | ( | ) |
Definition at line 475 of file dungeon_object_interaction.cc.
References cache_invalidation_callback_, canvas_, CanvasToRoomCoordinates(), clipboard_, current_room_id_, has_clipboard_data_, rooms_, and yaze::gui::Canvas::zero_point().
Referenced by ShowContextMenu().
|
inline |
Definition at line 62 of file dungeon_object_interaction.h.
References object_placed_callback_.
|
inline |
Definition at line 65 of file dungeon_object_interaction.h.
References cache_invalidation_callback_.
|
private |
Definition at line 70 of file dungeon_object_interaction.h.
Referenced by DrawDragPreview(), DrawObjectSelectRect(), DrawSelectBox(), DrawSelectionHighlights(), HandleCanvasMouseInput(), HandlePasteObjects(), IsWithinCanvasBounds(), and ShowContextMenu().
|
private |
Definition at line 71 of file dungeon_object_interaction.h.
Referenced by DrawDragPreview(), DrawSelectionHighlights(), HandleCanvasMouseInput(), HandleCopySelected(), HandleDeleteSelected(), HandlePasteObjects(), PlaceObjectAtPosition(), SelectObjectsInRect(), SetCurrentRoom(), and UpdateSelectedObjects().
|
private |
Definition at line 72 of file dungeon_object_interaction.h.
Referenced by DrawDragPreview(), DrawSelectionHighlights(), HandleCanvasMouseInput(), HandleCopySelected(), HandleDeleteSelected(), HandlePasteObjects(), PlaceObjectAtPosition(), SelectObjectsInRect(), SetCurrentRoom(), and UpdateSelectedObjects().
|
private |
Definition at line 75 of file dungeon_object_interaction.h.
Referenced by PlaceObjectAtPosition(), SetPreviewObject(), and ShowContextMenu().
|
private |
Definition at line 76 of file dungeon_object_interaction.h.
Referenced by DrawObjectSelectRect(), HandleCanvasMouseInput(), PlaceObjectAtPosition(), SetPreviewObject(), and ShowContextMenu().
|
private |
Definition at line 79 of file dungeon_object_interaction.h.
Referenced by ClearSelection(), DrawDragPreview(), HandleCanvasMouseInput(), and ShowContextMenu().
|
private |
Definition at line 80 of file dungeon_object_interaction.h.
Referenced by ClearSelection(), DrawSelectBox(), HandleCanvasMouseInput(), IsObjectInSelectBox(), and UpdateSelectedObjects().
|
private |
Definition at line 81 of file dungeon_object_interaction.h.
Referenced by DrawDragPreview(), and HandleCanvasMouseInput().
|
private |
Definition at line 82 of file dungeon_object_interaction.h.
Referenced by DrawDragPreview(), and HandleCanvasMouseInput().
|
private |
Definition at line 83 of file dungeon_object_interaction.h.
Referenced by DrawSelectBox(), HandleCanvasMouseInput(), and IsObjectInSelectBox().
|
private |
Definition at line 84 of file dungeon_object_interaction.h.
Referenced by DrawSelectBox(), HandleCanvasMouseInput(), and IsObjectInSelectBox().
|
private |
Definition at line 85 of file dungeon_object_interaction.h.
Referenced by HandleCanvasMouseInput(), and UpdateSelectedObjects().
|
private |
Definition at line 88 of file dungeon_object_interaction.h.
Referenced by CheckForObjectSelection(), ClearSelection(), DrawObjectSelectRect(), and IsObjectSelectActive().
|
private |
Definition at line 89 of file dungeon_object_interaction.h.
Referenced by DrawObjectSelectRect(), and SelectObjectsInRect().
|
private |
Definition at line 90 of file dungeon_object_interaction.h.
Referenced by DrawObjectSelectRect(), and SelectObjectsInRect().
|
private |
Definition at line 91 of file dungeon_object_interaction.h.
Referenced by ClearSelection(), DrawDragPreview(), DrawObjectSelectRect(), DrawSelectionHighlights(), GetSelectedObjectIndices(), HandleCanvasMouseInput(), HandleCopySelected(), HandleDeleteSelected(), SelectObjectsInRect(), and ShowContextMenu().
|
private |
Definition at line 94 of file dungeon_object_interaction.h.
Referenced by PlaceObjectAtPosition(), and SetObjectPlacedCallback().
|
private |
Definition at line 95 of file dungeon_object_interaction.h.
Referenced by HandleCanvasMouseInput(), HandleDeleteSelected(), HandlePasteObjects(), PlaceObjectAtPosition(), and SetCacheInvalidationCallback().
|
private |
Definition at line 98 of file dungeon_object_interaction.h.
Referenced by HandleCopySelected(), and HandlePasteObjects().
|
private |
Definition at line 99 of file dungeon_object_interaction.h.
Referenced by HandleCopySelected(), HandlePasteObjects(), and ShowContextMenu().