Handles object selection, placement, and interaction within the dungeon canvas. More...
#include <dungeon_object_interaction.h>
Private Member Functions | |
| std::pair< int, int > | CalculateObjectBounds (const zelda3::RoomObject &object) |
| void | HandleLeftClick (const ImVec2 &canvas_mouse_pos) |
| void | UpdateCollisionPainting (const ImVec2 &canvas_mouse_pos) |
| void | UpdateWaterFillPainting (const ImVec2 &canvas_mouse_pos) |
| void | HandleObjectSelectionStart (const ImVec2 &canvas_mouse_pos) |
| void | HandleEmptySpaceClick (const ImVec2 &canvas_mouse_pos) |
| void | HandleMouseRelease () |
Private Attributes | |
| gui::Canvas * | canvas_ |
| zelda3::DungeonEditorSystem * | editor_system_ = nullptr |
| std::array< zelda3::Room, dungeon_coords::kRoomCount > * | rooms_ = nullptr |
| int | current_room_id_ = 0 |
| InteractionContext | interaction_context_ |
| InteractionCoordinator | entity_coordinator_ |
| InteractionModeManager | mode_manager_ |
| zelda3::RoomObject | preview_object_ {0, 0, 0, 0, 0} |
| gfx::PaletteGroup | current_palette_group_ |
| ObjectSelection | selection_ |
| std::function< void(const zelda3::RoomObject &) | object_placed_callback_ ) |
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 43 of file dungeon_object_interaction.h.
|
inlineexplicit |
Definition at line 45 of file dungeon_object_interaction.h.
References yaze::editor::InteractionContext::canvas, entity_coordinator_, interaction_context_, yaze::editor::InteractionContext::selection, selection_, and yaze::editor::InteractionCoordinator::SetContext().

|
inline |
Set the unified interaction context.
This is the preferred method for configuring the interaction handler. It propagates context to all sub-handlers.
Definition at line 62 of file dungeon_object_interaction.h.
References yaze::editor::InteractionContext::canvas, canvas_, entity_coordinator_, interaction_context_, yaze::editor::InteractionContext::selection, selection_, and yaze::editor::InteractionCoordinator::SetContext().

|
inline |
Get the interaction coordinator for entity handling.
Use this for advanced entity operations (doors, sprites, items).
Definition at line 74 of file dungeon_object_interaction.h.
References entity_coordinator_.
Referenced by yaze::editor::ObjectEditorPanel::Draw().
|
inline |
Definition at line 75 of file dungeon_object_interaction.h.
References entity_coordinator_.
|
inline |
Definition at line 81 of file dungeon_object_interaction.h.
References interaction_context_, and yaze::editor::InteractionContext::last_mutation_domain.
|
inline |
Definition at line 84 of file dungeon_object_interaction.h.
References interaction_context_, and yaze::editor::InteractionContext::last_invalidation_domain.
|
inline |
Definition at line 89 of file dungeon_object_interaction.h.
References entity_coordinator_, interaction_context_, yaze::editor::InteractionContext::rom, and yaze::editor::InteractionCoordinator::SetContext().
Referenced by yaze::editor::DungeonCanvasViewer::DungeonCanvasViewer(), yaze::editor::DungeonCanvasViewer::SetContext(), and yaze::editor::DungeonCanvasViewer::SetRom().

| void yaze::editor::DungeonObjectInteraction::HandleCanvasMouseInput | ( | ) |
Definition at line 23 of file dungeon_object_interaction.cc.
References CancelPlacement(), canvas_, yaze::editor::DraggingObjects, entity_coordinator_, yaze::editor::InteractionModeManager::GetMode(), yaze::editor::InteractionCoordinator::HandleDrag(), HandleLayerKeyboardShortcuts(), HandleLeftClick(), HandleMouseRelease(), yaze::editor::InteractionCoordinator::HandleMouseWheel(), yaze::editor::InteractionCoordinator::HasEntitySelection(), yaze::gui::Canvas::IsMouseHovering(), yaze::editor::InteractionCoordinator::IsPlacementActive(), yaze::editor::ObjectSelection::IsRectangleSelectionActive(), mode_manager_, yaze::editor::PaintCollision, yaze::editor::PaintWaterFill, selection_, UpdateCollisionPainting(), UpdateWaterFillPainting(), and yaze::gui::Canvas::zero_point().
| void yaze::editor::DungeonObjectInteraction::CheckForObjectSelection | ( | ) |
Definition at line 281 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::PlaceObjectAtPosition | ( | int | room_x, |
| int | room_y ) |
Definition at line 438 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::DrawSelectionHighlights | ( | ) |
Definition at line 297 of file dungeon_object_interaction.cc.
References yaze::zelda3::DimensionService::Get(), yaze::zelda3::DimensionService::GetDimensions(), yaze::zelda3::GetObjectName(), yaze::zelda3::GetObjectSubtype(), ICON_MD_DRAG_INDICATOR, ICON_MD_MOUSE, and ICON_MD_TOUCH_APP.

| void yaze::editor::DungeonObjectInteraction::DrawHoverHighlight | ( | const std::vector< zelda3::RoomObject > & | objects | ) |
Definition at line 371 of file dungeon_object_interaction.cc.
References yaze::zelda3::DimensionService::Get(), and yaze::zelda3::DimensionService::GetSelectionBoundsPixels().

| void yaze::editor::DungeonObjectInteraction::DrawGhostPreview | ( | ) |
Definition at line 564 of file dungeon_object_interaction.cc.
| std::pair< int, int > yaze::editor::DungeonObjectInteraction::RoomToCanvasCoordinates | ( | int | room_x, |
| int | room_y ) const |
Definition at line 449 of file dungeon_object_interaction.cc.
| std::pair< int, int > yaze::editor::DungeonObjectInteraction::CanvasToRoomCoordinates | ( | int | canvas_x, |
| int | canvas_y ) const |
Definition at line 455 of file dungeon_object_interaction.cc.
Referenced by UpdateCollisionPainting().
| bool yaze::editor::DungeonObjectInteraction::IsWithinCanvasBounds | ( | int | canvas_x, |
| int | canvas_y, | ||
| int | margin = 32 ) const |
Definition at line 461 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::SetCurrentRoom | ( | std::array< zelda3::Room, dungeon_coords::kRoomCount > * | rooms, |
| int | room_id ) |
Definition at line 473 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::SetPreviewObject | ( | const zelda3::RoomObject & | object, |
| bool | loaded ) |
Definition at line 483 of file dungeon_object_interaction.cc.
Referenced by yaze::editor::DungeonCanvasViewer::ClearPreviewObject(), and yaze::editor::DungeonCanvasViewer::SetPreviewObject().
|
inline |
Definition at line 114 of file dungeon_object_interaction.h.
References yaze::editor::InteractionContext::current_palette_group, current_palette_group_, entity_coordinator_, interaction_context_, and yaze::editor::InteractionCoordinator::SetContext().
Referenced by yaze::editor::DungeonCanvasViewer::SetPreviewObject().

|
inline |
Definition at line 121 of file dungeon_object_interaction.h.
References mode_manager_.
Referenced by yaze::editor::CustomCollisionPanel::Draw(), yaze::editor::WaterFillPanel::Draw(), and yaze::editor::DungeonWorkbenchPanel::DrawInspectorShelfRoom().
|
inline |
Definition at line 122 of file dungeon_object_interaction.h.
References mode_manager_.
|
inline |
Definition at line 125 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::GetMode(), mode_manager_, and yaze::editor::PlaceObject.
Referenced by yaze::editor::ObjectEditorPanel::Draw(), and yaze::editor::ObjectEditorPanel::HandleKeyboardShortcuts().

| void yaze::editor::DungeonObjectInteraction::CancelPlacement | ( | ) |
Definition at line 715 of file dungeon_object_interaction.cc.
Referenced by yaze::editor::ObjectEditorPanel::CancelPlacement(), and HandleCanvasMouseInput().
| void yaze::editor::DungeonObjectInteraction::SetDoorPlacementMode | ( | bool | enabled, |
| zelda3::DoorType | type = zelda3::DoorType::NormalDoor ) |
Definition at line 656 of file dungeon_object_interaction.cc.
Referenced by yaze::editor::ObjectEditorPanel::DrawDoorSection().
|
inline |
Definition at line 133 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::GetMode(), mode_manager_, and yaze::editor::PlaceDoor.

|
inline |
Definition at line 136 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::GetModeState(), mode_manager_, and yaze::editor::ModeState::preview_door_type.

|
inline |
Definition at line 139 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::GetModeState(), mode_manager_, yaze::zelda3::NormalDoor, and yaze::editor::ModeState::preview_door_type.

|
inline |
Definition at line 143 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::CancelCurrentMode(), yaze::editor::InteractionModeManager::GetMode(), mode_manager_, and yaze::editor::PlaceDoor.

| void yaze::editor::DungeonObjectInteraction::SetSpritePlacementMode | ( | bool | enabled, |
| uint8_t | sprite_id = 0 ) |
Definition at line 673 of file dungeon_object_interaction.cc.
Referenced by yaze::editor::SpriteEditorPanel::DrawPlacementControls(), and yaze::editor::SpriteEditorPanel::DrawSpriteSelector().
|
inline |
Definition at line 151 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::GetMode(), mode_manager_, and yaze::editor::PlaceSprite.

|
inline |
Definition at line 154 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::GetModeState(), mode_manager_, and yaze::editor::ModeState::preview_sprite_id.

|
inline |
Definition at line 157 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::GetModeState(), mode_manager_, and yaze::editor::ModeState::preview_sprite_id.

|
inline |
Definition at line 160 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::CancelCurrentMode(), yaze::editor::InteractionModeManager::GetMode(), mode_manager_, and yaze::editor::PlaceSprite.

| void yaze::editor::DungeonObjectInteraction::SetItemPlacementMode | ( | bool | enabled, |
| uint8_t | item_id = 0 ) |
Definition at line 690 of file dungeon_object_interaction.cc.
Referenced by yaze::editor::ItemEditorPanel::DrawItemSelector(), and yaze::editor::ItemEditorPanel::DrawPlacementControls().
|
inline |
Definition at line 168 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::GetMode(), mode_manager_, and yaze::editor::PlaceItem.

|
inline |
Definition at line 171 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::GetModeState(), mode_manager_, and yaze::editor::ModeState::preview_item_id.

|
inline |
Definition at line 174 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::GetModeState(), mode_manager_, and yaze::editor::ModeState::preview_item_id.

|
inline |
Definition at line 177 of file dungeon_object_interaction.h.
References yaze::editor::InteractionModeManager::CancelCurrentMode(), yaze::editor::InteractionModeManager::GetMode(), mode_manager_, and yaze::editor::PlaceItem.

|
inline |
Definition at line 184 of file dungeon_object_interaction.h.
References yaze::editor::ObjectSelection::GetSelectedIndices(), and selection_.
Referenced by yaze::editor::ObjectEditorPanel::CopySelectedObjects(), yaze::editor::ObjectEditorPanel::CycleObjectSelection(), yaze::editor::ObjectEditorPanel::DeleteSelectedObjects(), yaze::editor::DungeonCanvasViewer::DrawDungeonCanvas(), yaze::editor::ObjectEditorPanel::DrawSelectedObjectInfo(), yaze::editor::ObjectEditorPanel::DuplicateSelectedObjects(), yaze::editor::ObjectEditorPanel::NudgeSelectedObjects(), and yaze::editor::ObjectEditorPanel::PerformDelete().

|
inline |
Definition at line 187 of file dungeon_object_interaction.h.
References yaze::editor::ObjectSelection::Add, yaze::editor::ObjectSelection::ClearSelection(), selection_, and yaze::editor::ObjectSelection::SelectObject().
Referenced by yaze::editor::ObjectEditorPanel::PasteObjects(), and yaze::editor::ObjectEditorPanel::SelectAllObjects().

|
inline |
Definition at line 193 of file dungeon_object_interaction.h.
References yaze::editor::ObjectSelection::HasSelection(), yaze::editor::ObjectSelection::IsRectangleSelectionActive(), and selection_.

| void yaze::editor::DungeonObjectInteraction::ClearSelection | ( | ) |
Definition at line 513 of file dungeon_object_interaction.cc.
Referenced by yaze::editor::ObjectEditorPanel::DeselectAllObjects().
|
inline |
Definition at line 197 of file dungeon_object_interaction.h.
References yaze::editor::ObjectSelection::IsObjectSelected(), and selection_.

|
inline |
Definition at line 200 of file dungeon_object_interaction.h.
References yaze::editor::ObjectSelection::GetSelectionCount(), and selection_.
Referenced by yaze::editor::ObjectEditorPanel::OnSelectionChanged().

|
inline |
Definition at line 203 of file dungeon_object_interaction.h.
References selection_, and yaze::editor::ObjectSelection::SetSelectionChangedCallback().
Referenced by yaze::editor::ObjectEditorPanel::SetupSelectionCallbacks().

| void yaze::editor::DungeonObjectInteraction::HandleScrollWheelResize | ( | ) |
Definition at line 568 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::HandleDeleteSelected | ( | ) |
Definition at line 521 of file dungeon_object_interaction.cc.
Referenced by yaze::editor::DungeonCanvasViewer::DeleteSelectedObjects().
| void yaze::editor::DungeonObjectInteraction::HandleDeleteAllObjects | ( | ) |
Definition at line 533 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::HandleCopySelected | ( | ) |
Definition at line 538 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::HandlePasteObjects | ( | ) |
Definition at line 543 of file dungeon_object_interaction.cc.
|
inline |
Definition at line 216 of file dungeon_object_interaction.h.
References entity_coordinator_, yaze::editor::TileObjectHandler::HasClipboardData(), and yaze::editor::InteractionCoordinator::tile_handler().

| bool yaze::editor::DungeonObjectInteraction::SetObjectId | ( | size_t | index, |
| int16_t | id ) |
Definition at line 573 of file dungeon_object_interaction.cc.
| bool yaze::editor::DungeonObjectInteraction::SetObjectSize | ( | size_t | index, |
| uint8_t | size ) |
Definition at line 578 of file dungeon_object_interaction.cc.
| bool yaze::editor::DungeonObjectInteraction::SetObjectLayer | ( | size_t | index, |
| zelda3::RoomObject::LayerType | layer ) |
Definition at line 583 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::SendSelectedToLayer | ( | int | target_layer | ) |
Definition at line 594 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::SendSelectedToFront | ( | ) |
Definition at line 599 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::SendSelectedToBack | ( | ) |
Definition at line 603 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::BringSelectedForward | ( | ) |
Definition at line 607 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::SendSelectedBackward | ( | ) |
Definition at line 611 of file dungeon_object_interaction.cc.
|
inline |
Definition at line 238 of file dungeon_object_interaction.h.
References selection_, and yaze::editor::ObjectSelection::SetLayerFilter().

|
inline |
Definition at line 239 of file dungeon_object_interaction.h.
References yaze::editor::ObjectSelection::GetLayerFilter(), and selection_.

|
inline |
Definition at line 240 of file dungeon_object_interaction.h.
References yaze::editor::ObjectSelection::IsLayerFilterActive(), and selection_.

|
inline |
Definition at line 241 of file dungeon_object_interaction.h.
References yaze::editor::ObjectSelection::IsMaskModeActive(), and selection_.

|
inline |
Definition at line 242 of file dungeon_object_interaction.h.
References yaze::editor::ObjectSelection::GetLayerFilterName(), and selection_.

|
inline |
Definition at line 243 of file dungeon_object_interaction.h.
References selection_, and yaze::editor::ObjectSelection::SetLayersMerged().

|
inline |
Definition at line 244 of file dungeon_object_interaction.h.
References yaze::editor::ObjectSelection::AreLayersMerged(), and selection_.

| void yaze::editor::DungeonObjectInteraction::HandleLayerKeyboardShortcuts | ( | ) |
Definition at line 615 of file dungeon_object_interaction.cc.
Referenced by HandleCanvasMouseInput().
|
inline |
Definition at line 250 of file dungeon_object_interaction.h.
References object_placed_callback_.
|
inline |
Definition at line 254 of file dungeon_object_interaction.h.
References entity_coordinator_, interaction_context_, yaze::editor::InteractionContext::on_invalidate_cache, and yaze::editor::InteractionCoordinator::SetContext().

|
inline |
Definition at line 258 of file dungeon_object_interaction.h.
References entity_coordinator_, interaction_context_, yaze::editor::InteractionContext::on_mutation, and yaze::editor::InteractionCoordinator::SetContext().

|
inline |
Definition at line 262 of file dungeon_object_interaction.h.
References editor_system_.
Referenced by yaze::editor::DungeonCanvasViewer::SetEditorSystem().
| void yaze::editor::DungeonObjectInteraction::SelectEntity | ( | EntityType | type, |
| size_t | index ) |
Definition at line 707 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::ClearEntitySelection | ( | ) |
Definition at line 711 of file dungeon_object_interaction.cc.
Referenced by yaze::editor::DungeonCanvasViewer::DrawDungeonCanvas().
|
inline |
Definition at line 269 of file dungeon_object_interaction.h.
References entity_coordinator_, and yaze::editor::InteractionCoordinator::HasEntitySelection().
Referenced by HandleLeftClick().

|
inline |
Definition at line 272 of file dungeon_object_interaction.h.
References entity_coordinator_, and yaze::editor::InteractionCoordinator::GetSelectedEntity().

| void yaze::editor::DungeonObjectInteraction::DrawEntitySelectionHighlights | ( | ) |
Definition at line 722 of file dungeon_object_interaction.cc.
| void yaze::editor::DungeonObjectInteraction::DrawDoorSnapIndicators | ( | ) |
Definition at line 727 of file dungeon_object_interaction.cc.
|
inline |
Definition at line 282 of file dungeon_object_interaction.h.
References entity_coordinator_, interaction_context_, yaze::editor::InteractionContext::on_entity_changed, and yaze::editor::InteractionCoordinator::SetContext().

|
private |
Definition at line 588 of file dungeon_object_interaction.cc.
References yaze::zelda3::DimensionService::Get(), and yaze::zelda3::DimensionService::GetPixelDimensions().

|
private |
Definition at line 90 of file dungeon_object_interaction.cc.
References entity_coordinator_, yaze::editor::InteractionCoordinator::HandleClick(), HandleEmptySpaceClick(), HandleObjectSelectionStart(), HasEntitySelection(), yaze::editor::ObjectSelection::HasSelection(), and selection_.
Referenced by HandleCanvasMouseInput().
|
private |
Definition at line 107 of file dungeon_object_interaction.cc.
References CanvasToRoomCoordinates(), current_room_id_, yaze::editor::paint_util::ForEachPointInSquareBrush(), yaze::editor::paint_util::ForEachPointOnLine(), yaze::editor::InteractionModeManager::GetModeState(), interaction_context_, yaze::editor::ModeState::is_painting, yaze::editor::kCustomCollision, mode_manager_, yaze::editor::InteractionContext::NotifyInvalidateCache(), yaze::editor::InteractionContext::NotifyMutation(), and rooms_.
Referenced by HandleCanvasMouseInput().
|
private |
Definition at line 162 of file dungeon_object_interaction.cc.
Referenced by HandleCanvasMouseInput().
|
private |
Definition at line 223 of file dungeon_object_interaction.cc.
Referenced by HandleLeftClick().
|
private |
Definition at line 231 of file dungeon_object_interaction.cc.
Referenced by HandleLeftClick().
|
private |
Definition at line 249 of file dungeon_object_interaction.cc.
Referenced by HandleCanvasMouseInput().
|
private |
Definition at line 288 of file dungeon_object_interaction.h.
Referenced by HandleCanvasMouseInput(), and SetContext().
|
private |
Definition at line 289 of file dungeon_object_interaction.h.
Referenced by SetEditorSystem().
|
private |
Definition at line 290 of file dungeon_object_interaction.h.
Referenced by UpdateCollisionPainting().
|
private |
Definition at line 291 of file dungeon_object_interaction.h.
Referenced by UpdateCollisionPainting().
|
private |
Definition at line 294 of file dungeon_object_interaction.h.
Referenced by DungeonObjectInteraction(), last_invalidation_domain(), last_mutation_domain(), SetCacheInvalidationCallback(), SetContext(), SetCurrentPaletteGroup(), SetEntityChangedCallback(), SetMutationCallback(), SetRom(), and UpdateCollisionPainting().
|
private |
Definition at line 295 of file dungeon_object_interaction.h.
Referenced by DungeonObjectInteraction(), entity_coordinator(), entity_coordinator(), GetSelectedEntity(), HandleCanvasMouseInput(), HandleLeftClick(), HasClipboardData(), HasEntitySelection(), SetCacheInvalidationCallback(), SetContext(), SetCurrentPaletteGroup(), SetEntityChangedCallback(), SetMutationCallback(), and SetRom().
|
private |
Definition at line 298 of file dungeon_object_interaction.h.
Referenced by CancelDoorPlacement(), CancelItemPlacement(), CancelSpritePlacement(), GetPreviewDoorType(), GetPreviewItemId(), GetPreviewSpriteId(), HandleCanvasMouseInput(), IsDoorPlacementActive(), IsItemPlacementActive(), IsObjectLoaded(), IsSpritePlacementActive(), mode_manager(), mode_manager(), SetPreviewDoorType(), SetPreviewItemId(), SetPreviewSpriteId(), and UpdateCollisionPainting().
|
private |
Definition at line 312 of file dungeon_object_interaction.h.
|
private |
Definition at line 315 of file dungeon_object_interaction.h.
Referenced by SetCurrentPaletteGroup().
|
private |
Definition at line 318 of file dungeon_object_interaction.h.
Referenced by AreLayersMerged(), DungeonObjectInteraction(), GetLayerFilter(), GetLayerFilterName(), GetSelectedObjectIndices(), GetSelectionCount(), HandleCanvasMouseInput(), HandleLeftClick(), IsLayerFilterActive(), IsMaskModeActive(), IsObjectSelectActive(), IsObjectSelected(), SetContext(), SetLayerFilter(), SetLayersMerged(), SetSelectedObjects(), and SetSelectionChangeCallback().
|
private |
Definition at line 321 of file dungeon_object_interaction.h.
Referenced by SetObjectPlacedCallback().