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>

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.
 
DoorInteractionHandlerdoor_handler ()
 
const DoorInteractionHandlerdoor_handler () const
 
SpriteInteractionHandlersprite_handler ()
 
const SpriteInteractionHandlersprite_handler () const
 
ItemInteractionHandleritem_handler ()
 
const ItemInteractionHandleritem_handler () const
 
TileObjectHandlertile_handler ()
 
const TileObjectHandlertile_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< SelectedEntityGetEntityAtPosition (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

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_
 
TileObjectHandler tile_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 20 of file interaction_coordinator.h.

Member Enumeration Documentation

◆ Mode

Available interaction modes.

Enumerator
Select 
PlaceDoor 
PlaceSprite 
PlaceItem 

Definition at line 25 of file interaction_coordinator.h.

Constructor & Destructor Documentation

◆ InteractionCoordinator()

yaze::editor::InteractionCoordinator::InteractionCoordinator ( )
inline

Definition at line 32 of file interaction_coordinator.h.

Member Function Documentation

◆ SetContext()

◆ GetCurrentMode()

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

Get current interaction mode.

Definition at line 46 of file interaction_coordinator.h.

References current_mode_.

◆ SetMode()

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

◆ CancelCurrentMode()

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

◆ IsPlacementActive()

◆ door_handler() [1/2]

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

Definition at line 69 of file interaction_coordinator.h.

References door_handler_.

◆ door_handler() [2/2]

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

Definition at line 70 of file interaction_coordinator.h.

References door_handler_.

◆ sprite_handler() [1/2]

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

Definition at line 72 of file interaction_coordinator.h.

References sprite_handler_.

◆ sprite_handler() [2/2]

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

Definition at line 73 of file interaction_coordinator.h.

References sprite_handler_.

◆ item_handler() [1/2]

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

Definition at line 77 of file interaction_coordinator.h.

References item_handler_.

◆ item_handler() [2/2]

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

Definition at line 78 of file interaction_coordinator.h.

References item_handler_.

◆ tile_handler() [1/2]

TileObjectHandler & yaze::editor::InteractionCoordinator::tile_handler ( )
inline

◆ tile_handler() [2/2]

const TileObjectHandler & yaze::editor::InteractionCoordinator::tile_handler ( ) const
inline

Definition at line 81 of file interaction_coordinator.h.

References tile_handler_.

◆ HandleClick()

◆ HandleMouseWheel()

◆ SelectEntity()

◆ ClearEntitySelection()

void yaze::editor::InteractionCoordinator::ClearEntitySelection ( )

Definition at line 148 of file interaction_coordinator.cc.

References ClearAllEntitySelections(), ctx_, HasEntitySelection(), and yaze::editor::InteractionContext::NotifyEntityChanged().

Here is the call graph for this function:

◆ HasEntitySelection()

◆ CancelPlacement()

◆ GetEntityAtPosition()

◆ GetSelectedEntity()

◆ HandleDrag()

◆ HandleRelease()

◆ DrawGhostPreviews()

◆ DrawSelectionHighlights()

◆ DrawPostPlacementOverlays()

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_.

Here is the call graph for this function:

◆ 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 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_.

Here is the call graph for this function:

◆ 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 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_.

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 306 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

◆ door_handler_

◆ sprite_handler_

◆ item_handler_

◆ tile_handler_


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