Abstract base class for entity interaction handlers. More...
#include <base_entity_handler.h>


Public Member Functions | |
| virtual | ~BaseEntityHandler ()=default |
| void | SetContext (InteractionContext *ctx) |
| Set the interaction context. | |
| InteractionContext * | context () const |
| Get the interaction context. | |
| virtual void | BeginPlacement ()=0 |
| Begin placement mode. | |
| virtual void | CancelPlacement ()=0 |
| Cancel current placement. | |
| virtual bool | IsPlacementActive () const =0 |
| Check if placement mode is active. | |
| virtual bool | HandleClick (int canvas_x, int canvas_y)=0 |
| Handle mouse click at canvas position. | |
| virtual void | HandleDrag (ImVec2 current_pos, ImVec2 delta)=0 |
| Handle mouse drag. | |
| virtual void | HandleRelease ()=0 |
| Handle mouse release. | |
| virtual bool | HandleMouseWheel (float delta) |
| virtual void | DrawGhostPreview ()=0 |
| Draw ghost preview during placement. | |
| virtual void | DrawSelectionHighlight ()=0 |
| Draw selection highlight for selected entities. | |
| virtual std::optional< size_t > | GetEntityAtPosition (int canvas_x, int canvas_y) const =0 |
| Get entity at canvas position. | |
| void | DrawPostPlacementToast () |
Protected Member Functions | |
| void | TriggerSuccessToast () |
| void | DrawSuccessToastOverlay (const char *msg, ImU32 color) const |
| 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) | |
| DungeonCanvasTransform | GetCanvasTransform () const |
| std::optional< ImVec2 > | GetPointerScreenPosition () const |
| bool | HasValidContext () const |
| Check if context is valid. | |
| zelda3::Room * | GetCurrentRoom () const |
| Get current room (convenience method) | |
Protected Attributes | |
| InteractionContext * | ctx_ = nullptr |
| float | toast_expire_time_ = 0.0f |
Static Protected Attributes | |
| static constexpr float | kToastDuration = 1.5f |
Abstract base class for entity interaction handlers.
Each entity type (object, door, sprite, item) has its own handler that implements this interface. This provides consistent interaction patterns while allowing specialized behavior.
The InteractionCoordinator manages mode switching and dispatches calls to the appropriate handler.
Definition at line 28 of file base_entity_handler.h.
|
virtualdefault |
|
inline |
Set the interaction context.
Must be called before using any other methods. The context provides access to canvas, room data, and callbacks.
Definition at line 38 of file base_entity_handler.h.
References ctx_.
Referenced by yaze::editor::InteractionCoordinator::SetContext(), and yaze::editor::TileObjectHandler::TileObjectHandler().
|
inline |
Get the interaction context.
Definition at line 43 of file base_entity_handler.h.
References ctx_.
Referenced by yaze::editor::DungeonCanvasViewer::HandleRoomCanvasDropTargets().
|
pure virtual |
Begin placement mode.
Called when user selects an entity to place from the palette. Override to initialize placement state.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.
|
pure virtual |
Cancel current placement.
Called when user presses Escape or switches modes. Override to clean up placement state.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.
|
pure virtual |
Check if placement mode is active.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.
|
pure virtual |
Handle mouse click at canvas position.
| canvas_x | Unscaled X position relative to canvas origin |
| canvas_y | Unscaled Y position relative to canvas origin |
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.
|
pure virtual |
Handle mouse drag.
| current_pos | Current unscaled room-pixel position |
| delta | Mouse movement since last frame (screen pixels) |
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.
|
pure virtual |
Handle mouse release.
Called when left mouse button is released after a drag.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.
|
inlinevirtual |
Reimplemented in yaze::editor::TileObjectHandler.
Definition at line 97 of file base_entity_handler.h.
Referenced by yaze::editor::InteractionCoordinator::HandleMouseWheel().
|
pure virtual |
Draw ghost preview during placement.
Called every frame when placement mode is active. Shows preview of entity at cursor position.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.
|
pure virtual |
Draw selection highlight for selected entities.
Called every frame to show selection state.
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.
|
pure virtual |
Get entity at canvas position.
| canvas_x | Unscaled X position relative to canvas origin |
| canvas_y | Unscaled Y position relative to canvas origin |
Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.
|
inline |
Definition at line 135 of file base_entity_handler.h.
References DrawSuccessToastOverlay(), and yaze::editor::AgentUI::GetTheme().
Referenced by yaze::editor::InteractionCoordinator::DrawPostPlacementOverlays().

|
inlineprotected |
Definition at line 151 of file base_entity_handler.h.
References kToastDuration, and toast_expire_time_.
Referenced by yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::TileObjectHandler::PlaceObjectAt(), and yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition().
|
inlineprotected |
Definition at line 160 of file base_entity_handler.h.
References GetCanvasZeroPoint(), and toast_expire_time_.
Referenced by DrawPostPlacementToast().

|
inlineprotected |
Convert room tile coordinates to canvas pixel coordinates.
Definition at line 193 of file base_entity_handler.h.
References yaze::editor::dungeon_coords::RoomToCanvas().
Referenced by yaze::editor::DoorInteractionHandler::DrawGhostPreview(), and yaze::editor::TileObjectHandler::DrawGhostPreview().

|
inlineprotected |
Convert canvas pixel coordinates to room tile coordinates.
Definition at line 200 of file base_entity_handler.h.
References yaze::editor::dungeon_coords::CanvasToRoom().
Referenced by yaze::editor::TileObjectHandler::DrawGhostPreview(), and yaze::editor::TileObjectHandler::HandleClick().

|
inlineprotected |
Check if coordinates are within room bounds.
Definition at line 207 of file base_entity_handler.h.
References yaze::editor::dungeon_coords::IsWithinBounds().
Referenced by yaze::editor::TileObjectHandler::DrawGhostPreview(), yaze::editor::DoorInteractionHandler::GetEntityAtPosition(), yaze::editor::ItemInteractionHandler::GetEntityAtPosition(), yaze::editor::SpriteInteractionHandler::GetEntityAtPosition(), yaze::editor::TileObjectHandler::GetEntityAtPosition(), yaze::editor::DoorInteractionHandler::HandleClick(), yaze::editor::ItemInteractionHandler::HandleClick(), yaze::editor::SpriteInteractionHandler::HandleClick(), and yaze::editor::TileObjectHandler::HandleClick().

|
inlineprotected |
Get canvas zero point (for screen coordinate conversion)
Definition at line 214 of file base_entity_handler.h.
References yaze::editor::InteractionContext::canvas, ctx_, and yaze::gui::Canvas::zero_point().
Referenced by DrawSuccessToastOverlay().

|
inlineprotected |
Definition at line 220 of file base_entity_handler.h.
References yaze::editor::InteractionContext::canvas, ctx_, yaze::gui::Canvas::global_scale(), yaze::gui::Canvas::scrolling(), and yaze::gui::Canvas::zero_point().
Referenced by yaze::editor::DoorInteractionHandler::DrawGhostPreview(), yaze::editor::ItemInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), yaze::editor::TileObjectHandler::DrawGhostPreview(), yaze::editor::DoorInteractionHandler::DrawSelectionHighlight(), yaze::editor::ItemInteractionHandler::DrawSelectionHighlight(), yaze::editor::SpriteInteractionHandler::DrawSelectionHighlight(), yaze::editor::TileObjectHandler::DrawSmartGuides(), yaze::editor::DoorInteractionHandler::DrawSnapIndicators(), GetPointerScreenPosition(), and yaze::editor::DoorInteractionHandler::HandleOverlayClick().

|
inlineprotected |
Definition at line 229 of file base_entity_handler.h.
References yaze::editor::InteractionContext::canvas, ctx_, GetCanvasTransform(), yaze::gui::TouchInput::GetTouchPoint(), yaze::gui::Canvas::IsMouseHovering(), yaze::gui::TouchInput::IsTouchActive(), yaze::editor::dungeon_coords::IsWithinBounds(), yaze::gui::TouchInput::kMaxTouchPoints, and yaze::editor::DungeonCanvasTransform::ScreenToRoomPixelCoordinates().
Referenced by yaze::editor::DoorInteractionHandler::DrawGhostPreview(), yaze::editor::ItemInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), and yaze::editor::TileObjectHandler::DrawGhostPreview().
|
inlineprotected |
Check if context is valid.
Definition at line 268 of file base_entity_handler.h.
References ctx_, and yaze::editor::InteractionContext::IsValid().
Referenced by yaze::editor::DoorInteractionHandler::DeleteAll(), yaze::editor::ItemInteractionHandler::DeleteAll(), yaze::editor::SpriteInteractionHandler::DeleteAll(), yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::DoorInteractionHandler::DrawGhostPreview(), yaze::editor::ItemInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), yaze::editor::TileObjectHandler::DrawGhostPreview(), yaze::editor::DoorInteractionHandler::DrawSelectionHighlight(), yaze::editor::ItemInteractionHandler::DrawSelectionHighlight(), yaze::editor::SpriteInteractionHandler::DrawSelectionHighlight(), yaze::editor::TileObjectHandler::DrawSelectionHighlight(), yaze::editor::DoorInteractionHandler::DrawSnapIndicators(), yaze::editor::DoorInteractionHandler::GetEntityAtPosition(), yaze::editor::ItemInteractionHandler::GetEntityAtPosition(), yaze::editor::SpriteInteractionHandler::GetEntityAtPosition(), yaze::editor::TileObjectHandler::GetEntityAtPosition(), yaze::editor::DoorInteractionHandler::HandleClick(), yaze::editor::ItemInteractionHandler::HandleClick(), yaze::editor::SpriteInteractionHandler::HandleClick(), yaze::editor::TileObjectHandler::HandleClick(), yaze::editor::TileObjectHandler::HandleMouseWheel(), yaze::editor::DoorInteractionHandler::HandleOverlayClick(), yaze::editor::DoorInteractionHandler::MutateDoorType(), yaze::editor::ItemInteractionHandler::NudgeSelected(), yaze::editor::DoorInteractionHandler::NudgeSelected(), yaze::editor::SpriteInteractionHandler::NudgeSelected(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), and yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition().

|
inlineprotected |
Get current room (convenience method)
Definition at line 273 of file base_entity_handler.h.
References ctx_, and yaze::editor::InteractionContext::GetCurrentRoom().
Referenced by yaze::editor::DoorInteractionHandler::DeleteAll(), yaze::editor::ItemInteractionHandler::DeleteAll(), yaze::editor::SpriteInteractionHandler::DeleteAll(), yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::DoorInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), yaze::editor::DoorInteractionHandler::DrawSelectionHighlight(), yaze::editor::ItemInteractionHandler::DrawSelectionHighlight(), yaze::editor::SpriteInteractionHandler::DrawSelectionHighlight(), yaze::editor::TileObjectHandler::DrawSelectionHighlight(), yaze::editor::DoorInteractionHandler::DrawSnapIndicators(), yaze::editor::DoorInteractionHandler::GetPlacementGhostCapacityState(), yaze::editor::SpriteInteractionHandler::GetPlacementGhostCapacityState(), yaze::editor::DoorInteractionHandler::HandleOverlayClick(), yaze::editor::DoorInteractionHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::SpriteInteractionHandler::HandleRelease(), yaze::editor::DoorInteractionHandler::MutateDoorType(), yaze::editor::ItemInteractionHandler::NudgeSelected(), yaze::editor::DoorInteractionHandler::NudgeSelected(), yaze::editor::SpriteInteractionHandler::NudgeSelected(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), and yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition().

|
protected |
Definition at line 143 of file base_entity_handler.h.
Referenced by yaze::editor::TileObjectHandler::BeginMarqueeSelection(), yaze::editor::DoorInteractionHandler::BuildPairBadgeOverlay(), context(), yaze::editor::DoorInteractionHandler::DeleteAll(), yaze::editor::ItemInteractionHandler::DeleteAll(), yaze::editor::SpriteInteractionHandler::DeleteAll(), yaze::editor::TileObjectHandler::DeleteAllObjects(), yaze::editor::TileObjectHandler::DeleteObjects(), yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), yaze::editor::TileObjectHandler::DrawGhostPreview(), yaze::editor::DoorInteractionHandler::DrawSelectionHighlight(), yaze::editor::TileObjectHandler::DrawSelectionHighlight(), yaze::editor::TileObjectHandler::DrawSmartGuides(), yaze::editor::TileObjectHandler::DuplicateObjects(), GetCanvasTransform(), GetCanvasZeroPoint(), GetCurrentRoom(), yaze::editor::DoorInteractionHandler::GetEntityAtPosition(), yaze::editor::ItemInteractionHandler::GetEntityAtPosition(), yaze::editor::SpriteInteractionHandler::GetEntityAtPosition(), yaze::editor::TileObjectHandler::GetEntityAtPosition(), yaze::editor::TileObjectHandler::GetPlacementGhostCapacityState(), GetPointerScreenPosition(), yaze::editor::TileObjectHandler::GetRoom(), yaze::editor::TileObjectHandler::HandleClick(), yaze::editor::TileObjectHandler::HandleDrag(), yaze::editor::TileObjectHandler::HandleMarqueeSelection(), yaze::editor::TileObjectHandler::HandleMouseWheel(), yaze::editor::DoorInteractionHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::SpriteInteractionHandler::HandleRelease(), yaze::editor::TileObjectHandler::HandleRelease(), HasValidContext(), yaze::editor::TileObjectHandler::MoveBackward(), yaze::editor::TileObjectHandler::MoveForward(), yaze::editor::TileObjectHandler::MoveObjects(), yaze::editor::DoorInteractionHandler::MutateDoorType(), yaze::editor::DoorInteractionHandler::NavigateToPairBadge(), yaze::editor::TileObjectHandler::NotifyChange(), yaze::editor::ItemInteractionHandler::NudgeSelected(), yaze::editor::DoorInteractionHandler::NudgeSelected(), yaze::editor::SpriteInteractionHandler::NudgeSelected(), yaze::editor::TileObjectHandler::PasteFromClipboard(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), yaze::editor::TileObjectHandler::PlaceObjectAt(), yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition(), yaze::editor::TileObjectHandler::RenderGhostPreviewBitmap(), yaze::editor::TileObjectHandler::ResizeObjects(), yaze::editor::DoorInteractionHandler::SelectDoor(), yaze::editor::ItemInteractionHandler::SelectItem(), yaze::editor::SpriteInteractionHandler::SelectSprite(), yaze::editor::TileObjectHandler::SendToBack(), yaze::editor::TileObjectHandler::SendToFront(), SetContext(), yaze::editor::TileObjectHandler::UpdateObjectsId(), yaze::editor::TileObjectHandler::UpdateObjectsLayer(), and yaze::editor::TileObjectHandler::UpdateObjectsSize().
|
protected |
Definition at line 182 of file base_entity_handler.h.
Referenced by DrawSuccessToastOverlay(), and TriggerSuccessToast().
|
staticconstexprprotected |
Definition at line 184 of file base_entity_handler.h.
Referenced by TriggerSuccessToast().