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 | |
| InteractionCoordinator () | |
| 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 |
| TileObjectHandler & | tile_handler () |
| const TileObjectHandler & | tile_handler () const |
| bool | HandleClick (int canvas_x, int canvas_y) |
| Handle click at canvas position. | |
| bool | HandleMouseWheel (float delta) |
| void | SelectEntity (EntityType type, size_t index) |
| void | ClearEntitySelection () |
| bool | HasEntitySelection () const |
| void | CancelPlacement () |
| std::optional< SelectedEntity > | GetEntityAtPosition (int canvas_x, int canvas_y) const |
| SelectedEntity | GetSelectedEntity () const |
| 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. | |
| void | DrawPostPlacementOverlays () |
| Draw post-placement success toasts for all handlers (unconditional) | |
| bool | TrySelectEntityAtCursor (int canvas_x, int canvas_y) |
| Try to select entity at cursor position. | |
| 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. | |
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 20 of file interaction_coordinator.h.
|
strong |
Available interaction modes.
| Enumerator | |
|---|---|
| Select | |
| PlaceDoor | |
| PlaceSprite | |
| PlaceItem | |
Definition at line 25 of file interaction_coordinator.h.
|
inline |
Definition at line 32 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(), sprite_handler_, and tile_handler_.
Referenced by yaze::editor::DungeonObjectInteraction::DungeonObjectInteraction(), yaze::editor::DungeonObjectInteraction::SetCacheInvalidationCallback(), yaze::editor::DungeonObjectInteraction::SetContext(), yaze::editor::DungeonObjectInteraction::SetCurrentPaletteGroup(), yaze::editor::DungeonObjectInteraction::SetEntityChangedCallback(), yaze::editor::DungeonObjectInteraction::SetMutationCallback(), and yaze::editor::DungeonObjectInteraction::SetRom().

|
inline |
Get current interaction mode.
Definition at line 46 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 17 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 40 of file interaction_coordinator.cc.
References yaze::editor::DoorInteractionHandler::CancelPlacement(), yaze::editor::ItemInteractionHandler::CancelPlacement(), yaze::editor::SpriteInteractionHandler::CancelPlacement(), yaze::editor::TileObjectHandler::CancelPlacement(), current_mode_, door_handler_, item_handler_, Select, sprite_handler_, and tile_handler_.
Referenced by SetMode().

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

|
inline |
Definition at line 69 of file interaction_coordinator.h.
References door_handler_.
|
inline |
Definition at line 70 of file interaction_coordinator.h.
References door_handler_.
|
inline |
Definition at line 72 of file interaction_coordinator.h.
References sprite_handler_.
|
inline |
Definition at line 73 of file interaction_coordinator.h.
References sprite_handler_.
|
inline |
Definition at line 77 of file interaction_coordinator.h.
References item_handler_.
|
inline |
Definition at line 78 of file interaction_coordinator.h.
References item_handler_.
|
inline |
Definition at line 80 of file interaction_coordinator.h.
References tile_handler_.
Referenced by yaze::editor::ObjectEditorPanel::Draw(), and yaze::editor::DungeonObjectInteraction::HasClipboardData().
|
inline |
Definition at line 81 of file interaction_coordinator.h.
References tile_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 57 of file interaction_coordinator.cc.
References ClearAllEntitySelections(), yaze::editor::ObjectSelection::ClearSelection(), ctx_, yaze::editor::Door, door_handler_, GetEntityAtPosition(), yaze::editor::DoorInteractionHandler::HandleClick(), yaze::editor::ItemInteractionHandler::HandleClick(), yaze::editor::SpriteInteractionHandler::HandleClick(), yaze::editor::TileObjectHandler::HandleClick(), yaze::editor::DoorInteractionHandler::IsPlacementActive(), yaze::editor::ItemInteractionHandler::IsPlacementActive(), yaze::editor::SpriteInteractionHandler::IsPlacementActive(), yaze::editor::TileObjectHandler::IsPlacementActive(), yaze::editor::Item, item_handler_, yaze::editor::Object, yaze::editor::InteractionContext::selection, yaze::editor::Sprite, sprite_handler_, and tile_handler_.
Referenced by yaze::editor::DungeonObjectInteraction::HandleLeftClick().
| bool yaze::editor::InteractionCoordinator::HandleMouseWheel | ( | float | delta | ) |
Definition at line 114 of file interaction_coordinator.cc.
References door_handler_, yaze::editor::BaseEntityHandler::HandleMouseWheel(), yaze::editor::TileObjectHandler::HandleMouseWheel(), yaze::editor::DoorInteractionHandler::IsPlacementActive(), yaze::editor::ItemInteractionHandler::IsPlacementActive(), yaze::editor::SpriteInteractionHandler::IsPlacementActive(), yaze::editor::TileObjectHandler::IsPlacementActive(), item_handler_, sprite_handler_, and tile_handler_.
Referenced by yaze::editor::DungeonObjectInteraction::HandleCanvasMouseInput().
| void yaze::editor::InteractionCoordinator::SelectEntity | ( | EntityType | type, |
| size_t | index ) |
Definition at line 123 of file interaction_coordinator.cc.
References ClearAllEntitySelections(), yaze::editor::ObjectSelection::ClearSelection(), ctx_, yaze::editor::Door, door_handler_, yaze::editor::Item, item_handler_, yaze::editor::None, yaze::editor::Object, yaze::editor::DoorInteractionHandler::SelectDoor(), yaze::editor::InteractionContext::selection, yaze::editor::ItemInteractionHandler::SelectItem(), yaze::editor::SpriteInteractionHandler::SelectSprite(), yaze::editor::Sprite, and sprite_handler_.
| void yaze::editor::InteractionCoordinator::ClearEntitySelection | ( | ) |
Definition at line 148 of file interaction_coordinator.cc.
References ClearAllEntitySelections(), ctx_, HasEntitySelection(), and yaze::editor::InteractionContext::NotifyEntityChanged().

| bool yaze::editor::InteractionCoordinator::HasEntitySelection | ( | ) | const |
Definition at line 271 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_.
Referenced by ClearEntitySelection(), yaze::editor::DungeonObjectInteraction::HandleCanvasMouseInput(), and yaze::editor::DungeonObjectInteraction::HasEntitySelection().

| void yaze::editor::InteractionCoordinator::CancelPlacement | ( | ) |
Definition at line 156 of file interaction_coordinator.cc.
References yaze::editor::DoorInteractionHandler::CancelPlacement(), yaze::editor::ItemInteractionHandler::CancelPlacement(), yaze::editor::SpriteInteractionHandler::CancelPlacement(), yaze::editor::TileObjectHandler::CancelPlacement(), door_handler_, item_handler_, sprite_handler_, and tile_handler_.

| std::optional< SelectedEntity > yaze::editor::InteractionCoordinator::GetEntityAtPosition | ( | int | canvas_x, |
| int | canvas_y ) const |
Definition at line 163 of file interaction_coordinator.cc.
References yaze::editor::Door, door_handler_, yaze::editor::DoorInteractionHandler::GetEntityAtPosition(), yaze::editor::ItemInteractionHandler::GetEntityAtPosition(), yaze::editor::SpriteInteractionHandler::GetEntityAtPosition(), yaze::editor::TileObjectHandler::GetEntityAtPosition(), yaze::editor::Item, item_handler_, yaze::editor::Object, yaze::editor::Sprite, sprite_handler_, and tile_handler_.
Referenced by HandleClick().

| SelectedEntity yaze::editor::InteractionCoordinator::GetSelectedEntity | ( | ) | const |
Definition at line 176 of file interaction_coordinator.cc.
References yaze::editor::Door, door_handler_, yaze::editor::DoorInteractionHandler::GetSelectedIndex(), yaze::editor::ItemInteractionHandler::GetSelectedIndex(), yaze::editor::SpriteInteractionHandler::GetSelectedIndex(), yaze::editor::Item, item_handler_, yaze::editor::None, yaze::editor::Sprite, and sprite_handler_.
Referenced by yaze::editor::DungeonObjectInteraction::GetSelectedEntity().

| void yaze::editor::InteractionCoordinator::HandleDrag | ( | ImVec2 | current_pos, |
| ImVec2 | delta ) |
Handle drag operation.
Definition at line 189 of file interaction_coordinator.cc.
References ctx_, door_handler_, yaze::editor::DoorInteractionHandler::HandleDrag(), yaze::editor::ItemInteractionHandler::HandleDrag(), yaze::editor::SpriteInteractionHandler::HandleDrag(), yaze::editor::TileObjectHandler::HandleDrag(), yaze::editor::DoorInteractionHandler::HasSelection(), yaze::editor::ItemInteractionHandler::HasSelection(), yaze::editor::SpriteInteractionHandler::HasSelection(), yaze::editor::ObjectSelection::HasSelection(), yaze::editor::TileObjectHandler::IsPlacementActive(), item_handler_, yaze::editor::InteractionContext::selection, sprite_handler_, and tile_handler_.
Referenced by yaze::editor::DungeonObjectInteraction::HandleCanvasMouseInput().
| void yaze::editor::InteractionCoordinator::HandleRelease | ( | ) |
Handle mouse release.
Definition at line 207 of file interaction_coordinator.cc.
References door_handler_, yaze::editor::DoorInteractionHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::SpriteInteractionHandler::HandleRelease(), yaze::editor::TileObjectHandler::HandleRelease(), item_handler_, sprite_handler_, and tile_handler_.

| void yaze::editor::InteractionCoordinator::DrawGhostPreviews | ( | ) |
Draw ghost previews for active placement mode.
Definition at line 214 of file interaction_coordinator.cc.
References door_handler_, yaze::editor::DoorInteractionHandler::DrawGhostPreview(), yaze::editor::ItemInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), yaze::editor::TileObjectHandler::DrawGhostPreview(), yaze::editor::DoorInteractionHandler::IsPlacementActive(), yaze::editor::ItemInteractionHandler::IsPlacementActive(), yaze::editor::SpriteInteractionHandler::IsPlacementActive(), yaze::editor::TileObjectHandler::IsPlacementActive(), item_handler_, sprite_handler_, and tile_handler_.
| void yaze::editor::InteractionCoordinator::DrawSelectionHighlights | ( | ) |
Draw selection highlights for all entity types.
Definition at line 230 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_.
| void yaze::editor::InteractionCoordinator::DrawPostPlacementOverlays | ( | ) |
Draw post-placement success toasts for all handlers (unconditional)
Called every frame so toasts remain visible even after the user exits placement mode immediately after a successful placement.
Definition at line 242 of file interaction_coordinator.cc.
References door_handler_, yaze::editor::BaseEntityHandler::DrawPostPlacementToast(), item_handler_, sprite_handler_, and tile_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 251 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_.

| void yaze::editor::InteractionCoordinator::ClearAllEntitySelections | ( | ) |
Clear all entity selections.
Definition at line 276 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 ClearEntitySelection(), HandleClick(), SelectEntity(), and TrySelectEntityAtCursor().

| void yaze::editor::InteractionCoordinator::DeleteSelectedEntity | ( | ) |
Delete currently selected entity.
Definition at line 282 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 292 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 306 of file interaction_coordinator.cc.
References current_mode_, door_handler_, item_handler_, PlaceDoor, PlaceItem, PlaceSprite, Select, and sprite_handler_.
|
private |
Definition at line 165 of file interaction_coordinator.h.
Referenced by CancelCurrentMode(), GetActiveHandler(), GetCurrentMode(), and SetMode().
|
private |
Definition at line 166 of file interaction_coordinator.h.
Referenced by ClearEntitySelection(), HandleClick(), HandleDrag(), SelectEntity(), and SetContext().
|
private |
Definition at line 168 of file interaction_coordinator.h.
Referenced by CancelCurrentMode(), CancelPlacement(), ClearAllEntitySelections(), DeleteSelectedEntity(), door_handler(), door_handler(), DrawGhostPreviews(), DrawPostPlacementOverlays(), DrawSelectionHighlights(), GetActiveHandler(), GetEntityAtPosition(), GetSelectedEntity(), GetSelectedEntityType(), HandleClick(), HandleDrag(), HandleMouseWheel(), HandleRelease(), HasEntitySelection(), IsPlacementActive(), SelectEntity(), SetContext(), SetMode(), and TrySelectEntityAtCursor().
|
private |
Definition at line 169 of file interaction_coordinator.h.
Referenced by CancelCurrentMode(), CancelPlacement(), ClearAllEntitySelections(), DeleteSelectedEntity(), DrawGhostPreviews(), DrawPostPlacementOverlays(), DrawSelectionHighlights(), GetActiveHandler(), GetEntityAtPosition(), GetSelectedEntity(), GetSelectedEntityType(), HandleClick(), HandleDrag(), HandleMouseWheel(), HandleRelease(), HasEntitySelection(), IsPlacementActive(), SelectEntity(), SetContext(), SetMode(), sprite_handler(), sprite_handler(), and TrySelectEntityAtCursor().
|
private |
Definition at line 170 of file interaction_coordinator.h.
Referenced by CancelCurrentMode(), CancelPlacement(), ClearAllEntitySelections(), DeleteSelectedEntity(), DrawGhostPreviews(), DrawPostPlacementOverlays(), DrawSelectionHighlights(), GetActiveHandler(), GetEntityAtPosition(), GetSelectedEntity(), GetSelectedEntityType(), HandleClick(), HandleDrag(), HandleMouseWheel(), HandleRelease(), HasEntitySelection(), IsPlacementActive(), item_handler(), item_handler(), SelectEntity(), SetContext(), SetMode(), and TrySelectEntityAtCursor().
|
private |
Definition at line 171 of file interaction_coordinator.h.
Referenced by CancelCurrentMode(), CancelPlacement(), DrawGhostPreviews(), DrawPostPlacementOverlays(), GetEntityAtPosition(), HandleClick(), HandleDrag(), HandleMouseWheel(), HandleRelease(), IsPlacementActive(), SetContext(), tile_handler(), and tile_handler().