Coordinates interaction mode switching and dispatches to handlers. More...
#include <interaction_coordinator.h>

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. | |
| DoorInteractionHandler & | door_handler () |
| const DoorInteractionHandler & | door_handler () const |
| SpriteInteractionHandler & | sprite_handler () |
| const SpriteInteractionHandler & | sprite_handler () const |
| ItemInteractionHandler & | item_handler () |
| const ItemInteractionHandler & | item_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 | |
| BaseEntityHandler * | GetActiveHandler () |
| Get active handler based on current mode. | |
Private Attributes | |
| Mode | current_mode_ = Mode::Select |
| InteractionContext * | ctx_ = nullptr |
| DoorInteractionHandler | door_handler_ |
| SpriteInteractionHandler | sprite_handler_ |
| ItemInteractionHandler | item_handler_ |
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.
|
strong |
Available interaction modes.
| Enumerator | |
|---|---|
| Select | |
| PlaceDoor | |
| PlaceSprite | |
| PlaceItem | |
Definition at line 24 of file interaction_coordinator.h.
| void yaze::editor::InteractionCoordinator::SetContext | ( | InteractionContext * | ctx | ) |
Set the shared interaction context.
This propagates the context to all handlers.
Definition at line 9 of file interaction_coordinator.cc.
References ctx_, door_handler_, item_handler_, yaze::editor::BaseEntityHandler::SetContext(), and sprite_handler_.
Referenced by yaze::editor::DungeonObjectInteraction::DungeonObjectInteraction(), yaze::editor::DungeonObjectInteraction::SetCacheInvalidationCallback(), yaze::editor::DungeonObjectInteraction::SetContext(), yaze::editor::DungeonObjectInteraction::SetCurrentPaletteGroup(), yaze::editor::DungeonObjectInteraction::SetCurrentRoom(), yaze::editor::DungeonObjectInteraction::SetEntityChangedCallback(), yaze::editor::DungeonObjectInteraction::SetMutationCallback(), and yaze::editor::DungeonObjectInteraction::SetRom().

|
inline |
Get current interaction mode.
Definition at line 41 of file interaction_coordinator.h.
References current_mode_.
| void yaze::editor::InteractionCoordinator::SetMode | ( | Mode | mode | ) |
Set interaction mode.
Cancels any active placement in the previous mode.
Definition at line 16 of file interaction_coordinator.cc.
References yaze::editor::DoorInteractionHandler::BeginPlacement(), yaze::editor::ItemInteractionHandler::BeginPlacement(), yaze::editor::SpriteInteractionHandler::BeginPlacement(), CancelCurrentMode(), current_mode_, door_handler_, item_handler_, PlaceDoor, PlaceItem, PlaceSprite, Select, and sprite_handler_.

| void yaze::editor::InteractionCoordinator::CancelCurrentMode | ( | ) |
Cancel current mode and return to select mode.
Definition at line 39 of file interaction_coordinator.cc.
References yaze::editor::DoorInteractionHandler::CancelPlacement(), yaze::editor::ItemInteractionHandler::CancelPlacement(), yaze::editor::SpriteInteractionHandler::CancelPlacement(), current_mode_, door_handler_, item_handler_, Select, and sprite_handler_.
Referenced by SetMode().

| bool yaze::editor::InteractionCoordinator::IsPlacementActive | ( | ) | const |
Check if any placement mode is active.
Definition at line 48 of file interaction_coordinator.cc.
References door_handler_, yaze::editor::DoorInteractionHandler::IsPlacementActive(), yaze::editor::ItemInteractionHandler::IsPlacementActive(), yaze::editor::SpriteInteractionHandler::IsPlacementActive(), item_handler_, and sprite_handler_.

|
inline |
Definition at line 64 of file interaction_coordinator.h.
References door_handler_.
|
inline |
Definition at line 65 of file interaction_coordinator.h.
References door_handler_.
|
inline |
Definition at line 67 of file interaction_coordinator.h.
References sprite_handler_.
|
inline |
Definition at line 68 of file interaction_coordinator.h.
References sprite_handler_.
|
inline |
Definition at line 72 of file interaction_coordinator.h.
References item_handler_.
|
inline |
Definition at line 73 of file interaction_coordinator.h.
References item_handler_.
| bool yaze::editor::InteractionCoordinator::HandleClick | ( | int | canvas_x, |
| int | canvas_y ) |
Handle click at canvas position.
Dispatches to appropriate handler based on current mode.
Definition at line 54 of file interaction_coordinator.cc.
References door_handler_, yaze::editor::DoorInteractionHandler::HandleClick(), yaze::editor::ItemInteractionHandler::HandleClick(), yaze::editor::SpriteInteractionHandler::HandleClick(), yaze::editor::DoorInteractionHandler::IsPlacementActive(), yaze::editor::ItemInteractionHandler::IsPlacementActive(), yaze::editor::SpriteInteractionHandler::IsPlacementActive(), item_handler_, sprite_handler_, and TrySelectEntityAtCursor().
| void yaze::editor::InteractionCoordinator::HandleDrag | ( | ImVec2 | current_pos, |
| ImVec2 | delta ) |
Handle drag operation.
Definition at line 70 of file interaction_coordinator.cc.
References door_handler_, yaze::editor::DoorInteractionHandler::HandleDrag(), yaze::editor::ItemInteractionHandler::HandleDrag(), yaze::editor::SpriteInteractionHandler::HandleDrag(), yaze::editor::DoorInteractionHandler::HasSelection(), yaze::editor::ItemInteractionHandler::HasSelection(), yaze::editor::SpriteInteractionHandler::HasSelection(), item_handler_, and sprite_handler_.
| void yaze::editor::InteractionCoordinator::HandleRelease | ( | ) |
Handle mouse release.
Definition at line 83 of file interaction_coordinator.cc.
References door_handler_, yaze::editor::DoorInteractionHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::SpriteInteractionHandler::HandleRelease(), item_handler_, and sprite_handler_.

| void yaze::editor::InteractionCoordinator::DrawGhostPreviews | ( | ) |
Draw ghost previews for active placement mode.
Definition at line 90 of file interaction_coordinator.cc.
References door_handler_, yaze::editor::DoorInteractionHandler::DrawGhostPreview(), yaze::editor::ItemInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), yaze::editor::DoorInteractionHandler::IsPlacementActive(), yaze::editor::ItemInteractionHandler::IsPlacementActive(), yaze::editor::SpriteInteractionHandler::IsPlacementActive(), item_handler_, and sprite_handler_.
| void yaze::editor::InteractionCoordinator::DrawSelectionHighlights | ( | ) |
Draw selection highlights for all entity types.
Definition at line 103 of file interaction_coordinator.cc.
References door_handler_, yaze::editor::DoorInteractionHandler::DrawSelectionHighlight(), yaze::editor::ItemInteractionHandler::DrawSelectionHighlight(), yaze::editor::SpriteInteractionHandler::DrawSelectionHighlight(), yaze::editor::DoorInteractionHandler::DrawSnapIndicators(), yaze::editor::DoorInteractionHandler::HasSelection(), yaze::editor::DoorInteractionHandler::IsPlacementActive(), item_handler_, and sprite_handler_.
| 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.
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().

| bool yaze::editor::InteractionCoordinator::HasEntitySelection | ( | ) | const |
Check if any entity is selected.
Definition at line 135 of file interaction_coordinator.cc.
References door_handler_, yaze::editor::DoorInteractionHandler::HasSelection(), yaze::editor::ItemInteractionHandler::HasSelection(), yaze::editor::SpriteInteractionHandler::HasSelection(), item_handler_, and sprite_handler_.

| void yaze::editor::InteractionCoordinator::ClearAllEntitySelections | ( | ) |
Clear all entity selections.
Definition at line 140 of file interaction_coordinator.cc.
References yaze::editor::DoorInteractionHandler::ClearSelection(), yaze::editor::ItemInteractionHandler::ClearSelection(), yaze::editor::SpriteInteractionHandler::ClearSelection(), door_handler_, item_handler_, and sprite_handler_.
Referenced by TrySelectEntityAtCursor().

| void yaze::editor::InteractionCoordinator::DeleteSelectedEntity | ( | ) |
Delete currently selected entity.
Definition at line 146 of file interaction_coordinator.cc.
References yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), door_handler_, yaze::editor::DoorInteractionHandler::HasSelection(), yaze::editor::ItemInteractionHandler::HasSelection(), yaze::editor::SpriteInteractionHandler::HasSelection(), item_handler_, and sprite_handler_.
| InteractionCoordinator::Mode yaze::editor::InteractionCoordinator::GetSelectedEntityType | ( | ) | const |
Get the type of currently selected entity.
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_.

|
private |
Get active handler based on current mode.
Definition at line 170 of file interaction_coordinator.cc.
References current_mode_, door_handler_, item_handler_, PlaceDoor, PlaceItem, PlaceSprite, Select, and sprite_handler_.
|
private |
Definition at line 141 of file interaction_coordinator.h.
Referenced by CancelCurrentMode(), GetActiveHandler(), GetCurrentMode(), and SetMode().
|
private |
Definition at line 142 of file interaction_coordinator.h.
Referenced by SetContext().
|
private |
Definition at line 144 of file interaction_coordinator.h.
Referenced by CancelCurrentMode(), ClearAllEntitySelections(), DeleteSelectedEntity(), door_handler(), door_handler(), DrawGhostPreviews(), DrawSelectionHighlights(), GetActiveHandler(), GetSelectedEntityType(), HandleClick(), HandleDrag(), HandleRelease(), HasEntitySelection(), IsPlacementActive(), SetContext(), SetMode(), and TrySelectEntityAtCursor().
|
private |
Definition at line 145 of file interaction_coordinator.h.
Referenced by CancelCurrentMode(), ClearAllEntitySelections(), DeleteSelectedEntity(), DrawGhostPreviews(), DrawSelectionHighlights(), GetActiveHandler(), GetSelectedEntityType(), HandleClick(), HandleDrag(), HandleRelease(), HasEntitySelection(), IsPlacementActive(), SetContext(), SetMode(), sprite_handler(), sprite_handler(), and TrySelectEntityAtCursor().
|
private |
Definition at line 146 of file interaction_coordinator.h.
Referenced by CancelCurrentMode(), ClearAllEntitySelections(), DeleteSelectedEntity(), DrawGhostPreviews(), DrawSelectionHighlights(), GetActiveHandler(), GetSelectedEntityType(), HandleClick(), HandleDrag(), HandleRelease(), HasEntitySelection(), IsPlacementActive(), item_handler(), item_handler(), SetContext(), SetMode(), and TrySelectEntityAtCursor().