yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::DoorInteractionHandler Class Reference

Handles door placement and interaction in the dungeon editor. More...

#include <door_interaction_handler.h>

Inheritance diagram for yaze::editor::DoorInteractionHandler:
Collaboration diagram for yaze::editor::DoorInteractionHandler:

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.
 
InteractionContextcontext () 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::RoomGetCurrentRoom () const
 Get current room (convenience method)
 
- Protected Attributes inherited from yaze::editor::BaseEntityHandler
InteractionContextctx_ = nullptr
 

Detailed Description

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.

Member Function Documentation

◆ BeginPlacement()

void yaze::editor::DoorInteractionHandler::BeginPlacement ( )
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().

Here is the call graph for this function:

◆ CancelPlacement()

void yaze::editor::DoorInteractionHandler::CancelPlacement ( )
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().

◆ IsPlacementActive()

bool yaze::editor::DoorInteractionHandler::IsPlacementActive ( ) const
inlineoverridevirtual

◆ HandleClick()

bool yaze::editor::DoorInteractionHandler::HandleClick ( int canvas_x,
int canvas_y )
overridevirtual

Handle mouse click at canvas position.

Parameters
canvas_xUnscaled X position relative to canvas origin
canvas_yUnscaled Y position relative to canvas origin
Returns
true if click was handled by this handler

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().

◆ HandleDrag()

void yaze::editor::DoorInteractionHandler::HandleDrag ( ImVec2 current_pos,
ImVec2 delta )
overridevirtual

Handle mouse drag.

Parameters
current_posCurrent mouse position (screen coords)
deltaMouse 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().

◆ HandleRelease()

◆ DrawGhostPreview()

◆ DrawSelectionHighlight()

◆ GetEntityAtPosition()

std::optional< size_t > yaze::editor::DoorInteractionHandler::GetEntityAtPosition ( int canvas_x,
int canvas_y ) const
overridevirtual

Get entity at canvas position.

Parameters
canvas_xUnscaled X position relative to canvas origin
canvas_yUnscaled Y position relative to canvas origin
Returns
Entity index if found, nullopt otherwise

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().

Here is the call graph for this function:

◆ SetDoorType()

void yaze::editor::DoorInteractionHandler::SetDoorType ( zelda3::DoorType type)
inline

Set door type for placement.

Definition at line 45 of file door_interaction_handler.h.

References preview_door_type_.

◆ GetDoorType()

zelda3::DoorType yaze::editor::DoorInteractionHandler::GetDoorType ( ) const
inline

Get current door type for placement.

Definition at line 50 of file door_interaction_handler.h.

References preview_door_type_.

◆ DrawSnapIndicators()

◆ SelectDoor()

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().

Here is the call graph for this function:

◆ ClearSelection()

void yaze::editor::DoorInteractionHandler::ClearSelection ( )

◆ HasSelection()

◆ GetSelectedIndex()

std::optional< size_t > yaze::editor::DoorInteractionHandler::GetSelectedIndex ( ) const
inline

Get selected door index.

Definition at line 77 of file door_interaction_handler.h.

References selected_door_index_.

◆ DeleteSelected()

◆ PlaceDoorAtSnappedPosition()

◆ UpdateSnappedPosition()

bool yaze::editor::DoorInteractionHandler::UpdateSnappedPosition ( int canvas_x,
int canvas_y )
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().

Here is the call graph for this function:

Member Data Documentation

◆ door_placement_mode_

bool yaze::editor::DoorInteractionHandler::door_placement_mode_ = false
private

◆ preview_door_type_

zelda3::DoorType yaze::editor::DoorInteractionHandler::preview_door_type_ = zelda3::DoorType::NormalDoor
private

◆ detected_door_direction_

zelda3::DoorDirection yaze::editor::DoorInteractionHandler::detected_door_direction_ = zelda3::DoorDirection::North
private

◆ snapped_door_position_

uint8_t yaze::editor::DoorInteractionHandler::snapped_door_position_ = 0
private

◆ selected_door_index_

std::optional<size_t> yaze::editor::DoorInteractionHandler::selected_door_index_
private

◆ is_dragging_

bool yaze::editor::DoorInteractionHandler::is_dragging_ = false
private

◆ drag_start_pos_

ImVec2 yaze::editor::DoorInteractionHandler::drag_start_pos_
private

Definition at line 94 of file door_interaction_handler.h.

Referenced by HandleClick().

◆ drag_current_pos_

ImVec2 yaze::editor::DoorInteractionHandler::drag_current_pos_
private

The documentation for this class was generated from the following files: