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

Coordinates interaction mode switching and dispatches to handlers. More...

#include <interaction_coordinator.h>

Collaboration diagram for yaze::editor::InteractionCoordinator:

Public Types

enum class  Mode { Select , PlaceDoor , PlaceSprite , PlaceItem }
 Available interaction modes. More...
 

Public Member Functions

void SetContext (InteractionContext *ctx)
 Set the shared interaction context.
 
Mode GetCurrentMode () const
 Get current interaction mode.
 
void SetMode (Mode mode)
 Set interaction mode.
 
void CancelCurrentMode ()
 Cancel current mode and return to select mode.
 
bool IsPlacementActive () const
 Check if any placement mode is active.
 
DoorInteractionHandlerdoor_handler ()
 
const DoorInteractionHandlerdoor_handler () const
 
SpriteInteractionHandlersprite_handler ()
 
const SpriteInteractionHandlersprite_handler () const
 
ItemInteractionHandleritem_handler ()
 
const ItemInteractionHandleritem_handler () const
 
bool HandleClick (int canvas_x, int canvas_y)
 Handle click at canvas position.
 
void HandleDrag (ImVec2 current_pos, ImVec2 delta)
 Handle drag operation.
 
void HandleRelease ()
 Handle mouse release.
 
void DrawGhostPreviews ()
 Draw ghost previews for active placement mode.
 
void DrawSelectionHighlights ()
 Draw selection highlights for all entity types.
 
bool TrySelectEntityAtCursor (int canvas_x, int canvas_y)
 Try to select entity at cursor position.
 
bool HasEntitySelection () const
 Check if any entity is selected.
 
void ClearAllEntitySelections ()
 Clear all entity selections.
 
void DeleteSelectedEntity ()
 Delete currently selected entity.
 
Mode GetSelectedEntityType () const
 Get the type of currently selected entity.
 

Private Member Functions

BaseEntityHandlerGetActiveHandler ()
 Get active handler based on current mode.
 

Private Attributes

Mode current_mode_ = Mode::Select
 
InteractionContextctx_ = nullptr
 
DoorInteractionHandler door_handler_
 
SpriteInteractionHandler sprite_handler_
 
ItemInteractionHandler item_handler_
 

Detailed Description

Coordinates interaction mode switching and dispatches to handlers.

The coordinator manages the current interaction mode and ensures only one handler is active at a time. It provides a unified interface for the DungeonObjectInteraction facade to delegate to.

Definition at line 19 of file interaction_coordinator.h.

Member Enumeration Documentation

◆ Mode

Available interaction modes.

Enumerator
Select 
PlaceDoor 
PlaceSprite 
PlaceItem 

Definition at line 24 of file interaction_coordinator.h.

Member Function Documentation

◆ SetContext()

◆ GetCurrentMode()

Mode yaze::editor::InteractionCoordinator::GetCurrentMode ( ) const
inline

Get current interaction mode.

Definition at line 41 of file interaction_coordinator.h.

References current_mode_.

◆ SetMode()

void yaze::editor::InteractionCoordinator::SetMode ( Mode mode)

◆ CancelCurrentMode()

void yaze::editor::InteractionCoordinator::CancelCurrentMode ( )

◆ IsPlacementActive()

bool yaze::editor::InteractionCoordinator::IsPlacementActive ( ) const

◆ door_handler() [1/2]

DoorInteractionHandler & yaze::editor::InteractionCoordinator::door_handler ( )
inline

Definition at line 64 of file interaction_coordinator.h.

References door_handler_.

◆ door_handler() [2/2]

const DoorInteractionHandler & yaze::editor::InteractionCoordinator::door_handler ( ) const
inline

Definition at line 65 of file interaction_coordinator.h.

References door_handler_.

◆ sprite_handler() [1/2]

SpriteInteractionHandler & yaze::editor::InteractionCoordinator::sprite_handler ( )
inline

Definition at line 67 of file interaction_coordinator.h.

References sprite_handler_.

◆ sprite_handler() [2/2]

const SpriteInteractionHandler & yaze::editor::InteractionCoordinator::sprite_handler ( ) const
inline

Definition at line 68 of file interaction_coordinator.h.

References sprite_handler_.

◆ item_handler() [1/2]

ItemInteractionHandler & yaze::editor::InteractionCoordinator::item_handler ( )
inline

Definition at line 72 of file interaction_coordinator.h.

References item_handler_.

◆ item_handler() [2/2]

const ItemInteractionHandler & yaze::editor::InteractionCoordinator::item_handler ( ) const
inline

Definition at line 73 of file interaction_coordinator.h.

References item_handler_.

◆ HandleClick()

◆ HandleDrag()

◆ HandleRelease()

void yaze::editor::InteractionCoordinator::HandleRelease ( )

◆ DrawGhostPreviews()

◆ DrawSelectionHighlights()

◆ TrySelectEntityAtCursor()

bool yaze::editor::InteractionCoordinator::TrySelectEntityAtCursor ( int canvas_x,
int canvas_y )

Try to select entity at cursor position.

Checks all entity types (doors, sprites, items) and selects if found.

Returns
true if entity was selected

Definition at line 115 of file interaction_coordinator.cc.

References ClearAllEntitySelections(), door_handler_, yaze::editor::DoorInteractionHandler::HandleClick(), yaze::editor::ItemInteractionHandler::HandleClick(), yaze::editor::SpriteInteractionHandler::HandleClick(), item_handler_, and sprite_handler_.

Referenced by HandleClick().

Here is the call graph for this function:

◆ HasEntitySelection()

bool yaze::editor::InteractionCoordinator::HasEntitySelection ( ) const

◆ ClearAllEntitySelections()

void yaze::editor::InteractionCoordinator::ClearAllEntitySelections ( )

◆ DeleteSelectedEntity()

◆ GetSelectedEntityType()

InteractionCoordinator::Mode yaze::editor::InteractionCoordinator::GetSelectedEntityType ( ) const

Get the type of currently selected entity.

Returns
Selected entity type, or Mode::Select if no entity selected

Definition at line 156 of file interaction_coordinator.cc.

References door_handler_, yaze::editor::DoorInteractionHandler::HasSelection(), yaze::editor::ItemInteractionHandler::HasSelection(), yaze::editor::SpriteInteractionHandler::HasSelection(), item_handler_, PlaceDoor, PlaceItem, PlaceSprite, Select, and sprite_handler_.

Here is the call graph for this function:

◆ GetActiveHandler()

BaseEntityHandler * yaze::editor::InteractionCoordinator::GetActiveHandler ( )
private

Get active handler based on current mode.

Returns
Pointer to active handler, or nullptr if in Select mode

Definition at line 170 of file interaction_coordinator.cc.

References current_mode_, door_handler_, item_handler_, PlaceDoor, PlaceItem, PlaceSprite, Select, and sprite_handler_.

Member Data Documentation

◆ current_mode_

Mode yaze::editor::InteractionCoordinator::current_mode_ = Mode::Select
private

◆ ctx_

InteractionContext* yaze::editor::InteractionCoordinator::ctx_ = nullptr
private

Definition at line 142 of file interaction_coordinator.h.

Referenced by SetContext().

◆ door_handler_

◆ sprite_handler_

◆ item_handler_


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