Handles door placement and interaction in the dungeon editor. More...
#include <door_interaction_handler.h>


Public Member Functions | |
| void | BeginPlacement () override |
| Begin placement mode. | |
| void | CancelPlacement () override |
| Cancel current placement. | |
| bool | IsPlacementActive () const override |
| Check if placement mode is active. | |
| bool | HandleClick (int canvas_x, int canvas_y) override |
| Handle mouse click at canvas position. | |
| void | HandleDrag (ImVec2 current_pos, ImVec2 delta) override |
| Handle mouse drag. | |
| void | HandleRelease () override |
| Handle mouse release. | |
| void | DrawGhostPreview () override |
| Draw ghost preview during placement. | |
| void | DrawSelectionHighlight () override |
| Draw selection highlight for selected entities. | |
| std::optional< size_t > | GetEntityAtPosition (int canvas_x, int canvas_y) const override |
| Get entity at canvas position. | |
| void | SetDoorType (zelda3::DoorType type) |
| Set door type for placement. | |
| zelda3::DoorType | GetDoorType () const |
| Get current door type for placement. | |
| void | DrawSnapIndicators () |
| Draw snap position indicators during door drag. | |
| void | SelectDoor (size_t index) |
| Select door at index. | |
| void | ClearSelection () |
| Clear door selection. | |
| bool | HasSelection () const |
| Check if a door is selected. | |
| std::optional< size_t > | GetSelectedIndex () const |
| Get selected door index. | |
| void | DeleteSelected () |
| Delete selected door. | |
Public Member Functions inherited from yaze::editor::BaseEntityHandler | |
| virtual | ~BaseEntityHandler ()=default |
| void | SetContext (InteractionContext *ctx) |
| Set the interaction context. | |
| InteractionContext * | context () const |
| Get the interaction context. | |
Private Member Functions | |
| void | PlaceDoorAtSnappedPosition (int canvas_x, int canvas_y) |
| Place door at snapped position. | |
| bool | UpdateSnappedPosition (int canvas_x, int canvas_y) |
| Update snapped position based on cursor. | |
Private Attributes | |
| bool | door_placement_mode_ = false |
| zelda3::DoorType | preview_door_type_ = zelda3::DoorType::NormalDoor |
| zelda3::DoorDirection | detected_door_direction_ = zelda3::DoorDirection::North |
| uint8_t | snapped_door_position_ = 0 |
| std::optional< size_t > | selected_door_index_ |
| bool | is_dragging_ = false |
| ImVec2 | drag_start_pos_ |
| ImVec2 | drag_current_pos_ |
Additional Inherited Members | |
Protected Member Functions inherited from yaze::editor::BaseEntityHandler | |
| std::pair< int, int > | RoomToCanvas (int room_x, int room_y) const |
| Convert room tile coordinates to canvas pixel coordinates. | |
| std::pair< int, int > | CanvasToRoom (int canvas_x, int canvas_y) const |
| Convert canvas pixel coordinates to room tile coordinates. | |
| bool | IsWithinBounds (int canvas_x, int canvas_y) const |
| Check if coordinates are within room bounds. | |
| ImVec2 | GetCanvasZeroPoint () const |
| Get canvas zero point (for screen coordinate conversion) | |
| float | GetCanvasScale () const |
| Get canvas global scale. | |
| bool | HasValidContext () const |
| Check if context is valid. | |
| zelda3::Room * | GetCurrentRoom () const |
| Get current room (convenience method) | |
Protected Attributes inherited from yaze::editor::BaseEntityHandler | |
| InteractionContext * | ctx_ = nullptr |
Handles door placement and interaction in the dungeon editor.
Doors snap to valid wall positions and have automatic direction detection based on which wall the cursor is near.
Definition at line 18 of file door_interaction_handler.h.
|
overridevirtual |
Begin placement mode.
Called when user selects an entity to place from the palette. Override to initialize placement state.
Implements yaze::editor::BaseEntityHandler.
Definition at line 12 of file door_interaction_handler.cc.
References ClearSelection(), and door_placement_mode_.
Referenced by yaze::editor::InteractionCoordinator::SetMode().

|
overridevirtual |
Cancel current placement.
Called when user presses Escape or switches modes. Override to clean up placement state.
Implements yaze::editor::BaseEntityHandler.
Definition at line 17 of file door_interaction_handler.cc.
References detected_door_direction_, door_placement_mode_, yaze::zelda3::North, and snapped_door_position_.
Referenced by yaze::editor::InteractionCoordinator::CancelCurrentMode().
|
inlineoverridevirtual |
Check if placement mode is active.
Implements yaze::editor::BaseEntityHandler.
Definition at line 26 of file door_interaction_handler.h.
References door_placement_mode_.
Referenced by yaze::editor::InteractionCoordinator::DrawGhostPreviews(), yaze::editor::InteractionCoordinator::DrawSelectionHighlights(), yaze::editor::InteractionCoordinator::HandleClick(), and yaze::editor::InteractionCoordinator::IsPlacementActive().
|
overridevirtual |
Handle mouse click at canvas position.
| canvas_x | Unscaled X position relative to canvas origin |
| canvas_y | Unscaled Y position relative to canvas origin |
Implements yaze::editor::BaseEntityHandler.
Definition at line 23 of file door_interaction_handler.cc.
References ClearSelection(), door_placement_mode_, drag_current_pos_, drag_start_pos_, GetEntityAtPosition(), yaze::editor::BaseEntityHandler::HasValidContext(), is_dragging_, PlaceDoorAtSnappedPosition(), and SelectDoor().
Referenced by yaze::editor::InteractionCoordinator::HandleClick(), and yaze::editor::InteractionCoordinator::TrySelectEntityAtCursor().
|
overridevirtual |
Handle mouse drag.
| current_pos | Current mouse position (screen coords) |
| delta | Mouse movement since last frame |
Implements yaze::editor::BaseEntityHandler.
Definition at line 46 of file door_interaction_handler.cc.
References drag_current_pos_, is_dragging_, and selected_door_index_.
Referenced by yaze::editor::InteractionCoordinator::HandleDrag().
|
overridevirtual |
Handle mouse release.
Called when left mouse button is released after a drag.
Implements yaze::editor::BaseEntityHandler.
Definition at line 52 of file door_interaction_handler.cc.
References yaze::editor::BaseEntityHandler::ctx_, yaze::zelda3::DoorPositionManager::DetectWallFromPosition(), drag_current_pos_, yaze::editor::BaseEntityHandler::GetCurrentRoom(), is_dragging_, yaze::zelda3::DoorPositionManager::IsValidPosition(), yaze::editor::InteractionContext::NotifyInvalidateCache(), yaze::editor::InteractionContext::NotifyMutation(), selected_door_index_, and yaze::zelda3::DoorPositionManager::SnapToNearestPosition().
Referenced by yaze::editor::InteractionCoordinator::HandleRelease().
|
overridevirtual |
Draw ghost preview during placement.
Called every frame when placement mode is active. Shows preview of entity at cursor position.
Implements yaze::editor::BaseEntityHandler.
Definition at line 96 of file door_interaction_handler.cc.
References yaze::editor::InteractionContext::canvas, yaze::editor::BaseEntityHandler::ctx_, detected_door_direction_, door_placement_mode_, yaze::editor::BaseEntityHandler::GetCanvasScale(), yaze::zelda3::GetDoorDimensions(), yaze::zelda3::GetDoorDirectionName(), yaze::zelda3::GetDoorTypeName(), yaze::editor::AgentUI::GetTheme(), yaze::editor::BaseEntityHandler::HasValidContext(), yaze::zelda3::DoorPositionManager::PositionToTileCoords(), preview_door_type_, yaze::editor::BaseEntityHandler::RoomToCanvas(), snapped_door_position_, and UpdateSnappedPosition().
Referenced by yaze::editor::InteractionCoordinator::DrawGhostPreviews().
|
overridevirtual |
Draw selection highlight for selected entities.
Called every frame to show selection state.
Implements yaze::editor::BaseEntityHandler.
Definition at line 158 of file door_interaction_handler.cc.
References yaze::zelda3::DoorPositionManager::DetectWallSection(), drag_current_pos_, DrawSnapIndicators(), yaze::editor::BaseEntityHandler::GetCanvasScale(), yaze::editor::BaseEntityHandler::GetCanvasZeroPoint(), yaze::editor::BaseEntityHandler::GetCurrentRoom(), yaze::zelda3::GetDoorDimensions(), yaze::editor::BaseEntityHandler::HasValidContext(), is_dragging_, yaze::zelda3::DoorPositionManager::PositionToTileCoords(), selected_door_index_, and yaze::zelda3::DoorPositionManager::SnapToNearestPosition().
Referenced by yaze::editor::InteractionCoordinator::DrawSelectionHighlights().
|
overridevirtual |
Get entity at canvas position.
| canvas_x | Unscaled X position relative to canvas origin |
| canvas_y | Unscaled Y position relative to canvas origin |
Implements yaze::editor::BaseEntityHandler.
Definition at line 221 of file door_interaction_handler.cc.
References yaze::editor::BaseEntityHandler::ctx_, yaze::editor::BaseEntityHandler::GetCanvasScale(), yaze::editor::InteractionContext::GetCurrentRoomConst(), yaze::zelda3::GetDoorDimensions(), and yaze::editor::BaseEntityHandler::HasValidContext().
Referenced by HandleClick().

|
inline |
Set door type for placement.
Definition at line 45 of file door_interaction_handler.h.
References preview_door_type_.
|
inline |
Get current door type for placement.
Definition at line 50 of file door_interaction_handler.h.
References preview_door_type_.
| void yaze::editor::DoorInteractionHandler::DrawSnapIndicators | ( | ) |
Draw snap position indicators during door drag.
Shows valid snap positions along the detected wall.
Definition at line 335 of file door_interaction_handler.cc.
References yaze::zelda3::DoorPositionManager::DetectWallSection(), drag_current_pos_, yaze::editor::BaseEntityHandler::GetCanvasScale(), yaze::editor::BaseEntityHandler::GetCanvasZeroPoint(), yaze::zelda3::GetDoorDimensions(), yaze::zelda3::DoorPositionManager::GetSectionStartPosition(), yaze::editor::AgentUI::GetTheme(), yaze::editor::BaseEntityHandler::HasValidContext(), is_dragging_, yaze::zelda3::DoorPositionManager::PositionToTileCoords(), and yaze::zelda3::DoorPositionManager::SnapToNearestPosition().
Referenced by DrawSelectionHighlight(), and yaze::editor::InteractionCoordinator::DrawSelectionHighlights().
| void yaze::editor::DoorInteractionHandler::SelectDoor | ( | size_t | index | ) |
Select door at index.
Definition at line 254 of file door_interaction_handler.cc.
References yaze::editor::BaseEntityHandler::ctx_, yaze::editor::InteractionContext::NotifyEntityChanged(), and selected_door_index_.
Referenced by HandleClick().

| void yaze::editor::DoorInteractionHandler::ClearSelection | ( | ) |
Clear door selection.
Definition at line 259 of file door_interaction_handler.cc.
References is_dragging_, and selected_door_index_.
Referenced by BeginPlacement(), yaze::editor::InteractionCoordinator::ClearAllEntitySelections(), DeleteSelected(), and HandleClick().
|
inline |
Check if a door is selected.
Definition at line 72 of file door_interaction_handler.h.
References selected_door_index_.
Referenced by yaze::editor::InteractionCoordinator::DeleteSelectedEntity(), yaze::editor::InteractionCoordinator::DrawSelectionHighlights(), yaze::editor::InteractionCoordinator::GetSelectedEntityType(), yaze::editor::InteractionCoordinator::HandleDrag(), and yaze::editor::InteractionCoordinator::HasEntitySelection().
|
inline |
Get selected door index.
Definition at line 77 of file door_interaction_handler.h.
References selected_door_index_.
| void yaze::editor::DoorInteractionHandler::DeleteSelected | ( | ) |
Delete selected door.
Definition at line 264 of file door_interaction_handler.cc.
References ClearSelection(), yaze::editor::BaseEntityHandler::ctx_, yaze::editor::BaseEntityHandler::GetCurrentRoom(), yaze::editor::BaseEntityHandler::HasValidContext(), yaze::editor::InteractionContext::NotifyInvalidateCache(), yaze::editor::InteractionContext::NotifyMutation(), and selected_door_index_.
Referenced by yaze::editor::InteractionCoordinator::DeleteSelectedEntity().
|
private |
Place door at snapped position.
Definition at line 280 of file door_interaction_handler.cc.
References yaze::zelda3::Room::Door::byte1, yaze::zelda3::Room::Door::byte2, yaze::editor::BaseEntityHandler::ctx_, yaze::zelda3::DoorPositionManager::DetectWallFromPosition(), yaze::zelda3::Room::Door::direction, yaze::zelda3::Room::Door::EncodeBytes(), yaze::editor::BaseEntityHandler::GetCurrentRoom(), yaze::editor::BaseEntityHandler::HasValidContext(), yaze::zelda3::DoorPositionManager::IsValidPosition(), yaze::editor::InteractionContext::NotifyInvalidateCache(), yaze::editor::InteractionContext::NotifyMutation(), yaze::zelda3::Room::Door::position, preview_door_type_, yaze::zelda3::DoorPositionManager::SnapToNearestPosition(), and yaze::zelda3::Room::Door::type.
Referenced by HandleClick().
|
private |
Update snapped position based on cursor.
Definition at line 322 of file door_interaction_handler.cc.
References detected_door_direction_, yaze::zelda3::DoorPositionManager::DetectWallFromPosition(), snapped_door_position_, and yaze::zelda3::DoorPositionManager::SnapToNearestPosition().
Referenced by DrawGhostPreview().

|
private |
Definition at line 86 of file door_interaction_handler.h.
Referenced by BeginPlacement(), CancelPlacement(), DrawGhostPreview(), HandleClick(), and IsPlacementActive().
|
private |
Definition at line 87 of file door_interaction_handler.h.
Referenced by DrawGhostPreview(), GetDoorType(), PlaceDoorAtSnappedPosition(), and SetDoorType().
|
private |
Definition at line 88 of file door_interaction_handler.h.
Referenced by CancelPlacement(), DrawGhostPreview(), and UpdateSnappedPosition().
|
private |
Definition at line 89 of file door_interaction_handler.h.
Referenced by CancelPlacement(), DrawGhostPreview(), and UpdateSnappedPosition().
|
private |
Definition at line 92 of file door_interaction_handler.h.
Referenced by ClearSelection(), DeleteSelected(), DrawSelectionHighlight(), GetSelectedIndex(), HandleDrag(), HandleRelease(), HasSelection(), and SelectDoor().
|
private |
Definition at line 93 of file door_interaction_handler.h.
Referenced by ClearSelection(), DrawSelectionHighlight(), DrawSnapIndicators(), HandleClick(), HandleDrag(), and HandleRelease().
|
private |
Definition at line 94 of file door_interaction_handler.h.
Referenced by HandleClick().
|
private |
Definition at line 95 of file door_interaction_handler.h.
Referenced by DrawSelectionHighlight(), DrawSnapIndicators(), HandleClick(), HandleDrag(), and HandleRelease().