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

Abstract base class for entity interaction handlers. More...

#include <base_entity_handler.h>

Inheritance diagram for yaze::editor::BaseEntityHandler:
Collaboration diagram for yaze::editor::BaseEntityHandler:

Public Member Functions

virtual ~BaseEntityHandler ()=default
 
void SetContext (InteractionContext *ctx)
 Set the interaction context.
 
InteractionContextcontext () 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)
 
float GetCanvasScale () const
 Get canvas global scale.
 
bool HasValidContext () const
 Check if context is valid.
 
zelda3::RoomGetCurrentRoom () const
 Get current room (convenience method)
 

Protected Attributes

InteractionContextctx_ = nullptr
 
float toast_expire_time_ = 0.0f
 

Static Protected Attributes

static constexpr float kToastDuration = 1.5f
 

Detailed Description

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 26 of file base_entity_handler.h.

Constructor & Destructor Documentation

◆ ~BaseEntityHandler()

virtual yaze::editor::BaseEntityHandler::~BaseEntityHandler ( )
virtualdefault

Member Function Documentation

◆ SetContext()

void yaze::editor::BaseEntityHandler::SetContext ( InteractionContext * ctx)
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 36 of file base_entity_handler.h.

References ctx_.

Referenced by yaze::editor::InteractionCoordinator::SetContext(), and yaze::editor::TileObjectHandler::TileObjectHandler().

◆ context()

InteractionContext * yaze::editor::BaseEntityHandler::context ( ) const
inline

Get the interaction context.

Definition at line 41 of file base_entity_handler.h.

References ctx_.

◆ BeginPlacement()

virtual void yaze::editor::BaseEntityHandler::BeginPlacement ( )
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.

◆ CancelPlacement()

virtual void yaze::editor::BaseEntityHandler::CancelPlacement ( )
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.

◆ IsPlacementActive()

virtual bool yaze::editor::BaseEntityHandler::IsPlacementActive ( ) const
pure virtual

◆ HandleClick()

virtual bool yaze::editor::BaseEntityHandler::HandleClick ( int canvas_x,
int canvas_y )
pure virtual

Handle mouse click at canvas position.

Parameters
canvas_xUnscaled X position relative to canvas origin
canvas_yUnscaled Y position relative to canvas origin
Returns
true if click was handled by this handler

Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.

◆ HandleDrag()

virtual void yaze::editor::BaseEntityHandler::HandleDrag ( ImVec2 current_pos,
ImVec2 delta )
pure virtual

Handle mouse drag.

Parameters
current_posCurrent mouse position (screen coords)
deltaMouse movement since last frame

Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.

◆ HandleRelease()

virtual void yaze::editor::BaseEntityHandler::HandleRelease ( )
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.

◆ HandleMouseWheel()

virtual bool yaze::editor::BaseEntityHandler::HandleMouseWheel ( float delta)
inlinevirtual

◆ DrawGhostPreview()

virtual void yaze::editor::BaseEntityHandler::DrawGhostPreview ( )
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.

◆ DrawSelectionHighlight()

virtual void yaze::editor::BaseEntityHandler::DrawSelectionHighlight ( )
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.

◆ GetEntityAtPosition()

virtual std::optional< size_t > yaze::editor::BaseEntityHandler::GetEntityAtPosition ( int canvas_x,
int canvas_y ) const
pure virtual

Get entity at canvas position.

Parameters
canvas_xUnscaled X position relative to canvas origin
canvas_yUnscaled Y position relative to canvas origin
Returns
Entity index if found, nullopt otherwise

Implemented in yaze::editor::DoorInteractionHandler, yaze::editor::ItemInteractionHandler, yaze::editor::SpriteInteractionHandler, and yaze::editor::TileObjectHandler.

◆ DrawPostPlacementToast()

void yaze::editor::BaseEntityHandler::DrawPostPlacementToast ( )
inline

Definition at line 133 of file base_entity_handler.h.

References DrawSuccessToastOverlay(), and yaze::editor::AgentUI::GetTheme().

Referenced by yaze::editor::InteractionCoordinator::DrawPostPlacementOverlays().

Here is the call graph for this function:

◆ TriggerSuccessToast()

◆ DrawSuccessToastOverlay()

void yaze::editor::BaseEntityHandler::DrawSuccessToastOverlay ( const char * msg,
ImU32 color ) const
inlineprotected

Definition at line 157 of file base_entity_handler.h.

References GetCanvasZeroPoint(), and toast_expire_time_.

Referenced by DrawPostPlacementToast().

Here is the call graph for this function:

◆ RoomToCanvas()

std::pair< int, int > yaze::editor::BaseEntityHandler::RoomToCanvas ( int room_x,
int room_y ) const
inlineprotected

Convert room tile coordinates to canvas pixel coordinates.

Definition at line 191 of file base_entity_handler.h.

References yaze::editor::dungeon_coords::RoomToCanvas().

Referenced by yaze::editor::DoorInteractionHandler::DrawGhostPreview(), and yaze::editor::TileObjectHandler::DrawGhostPreview().

Here is the call graph for this function:

◆ CanvasToRoom()

std::pair< int, int > yaze::editor::BaseEntityHandler::CanvasToRoom ( int canvas_x,
int canvas_y ) const
inlineprotected

Convert canvas pixel coordinates to room tile coordinates.

Definition at line 198 of file base_entity_handler.h.

References yaze::editor::dungeon_coords::CanvasToRoom().

Referenced by yaze::editor::TileObjectHandler::DrawGhostPreview(), and yaze::editor::TileObjectHandler::HandleClick().

Here is the call graph for this function:

◆ IsWithinBounds()

bool yaze::editor::BaseEntityHandler::IsWithinBounds ( int canvas_x,
int canvas_y ) const
inlineprotected

Check if coordinates are within room bounds.

Definition at line 205 of file base_entity_handler.h.

References yaze::editor::dungeon_coords::IsWithinBounds().

Referenced by yaze::editor::TileObjectHandler::DrawGhostPreview(), and yaze::editor::TileObjectHandler::HandleClick().

Here is the call graph for this function:

◆ GetCanvasZeroPoint()

◆ GetCanvasScale()

◆ HasValidContext()

bool yaze::editor::BaseEntityHandler::HasValidContext ( ) const
inlineprotected

Check if context is valid.

Definition at line 229 of file base_entity_handler.h.

References ctx_, and yaze::editor::InteractionContext::IsValid().

Referenced by 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::DoorInteractionHandler::HandleClick(), yaze::editor::ItemInteractionHandler::HandleClick(), yaze::editor::SpriteInteractionHandler::HandleClick(), yaze::editor::TileObjectHandler::HandleClick(), yaze::editor::TileObjectHandler::HandleMouseWheel(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), and yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition().

Here is the call graph for this function:

◆ GetCurrentRoom()

Member Data Documentation

◆ ctx_

InteractionContext* yaze::editor::BaseEntityHandler::ctx_ = nullptr
protected

Definition at line 140 of file base_entity_handler.h.

Referenced by yaze::editor::TileObjectHandler::BeginMarqueeSelection(), context(), yaze::editor::TileObjectHandler::DeleteAllObjects(), yaze::editor::TileObjectHandler::DeleteObjects(), 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::TileObjectHandler::DrawSelectionHighlight(), yaze::editor::TileObjectHandler::DuplicateObjects(), GetCanvasScale(), GetCanvasZeroPoint(), GetCurrentRoom(), yaze::editor::DoorInteractionHandler::GetEntityAtPosition(), yaze::editor::ItemInteractionHandler::GetEntityAtPosition(), yaze::editor::SpriteInteractionHandler::GetEntityAtPosition(), yaze::editor::TileObjectHandler::GetEntityAtPosition(), 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::TileObjectHandler::NotifyChange(), 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().

◆ toast_expire_time_

float yaze::editor::BaseEntityHandler::toast_expire_time_ = 0.0f
protected

Definition at line 180 of file base_entity_handler.h.

Referenced by DrawSuccessToastOverlay(), and TriggerSuccessToast().

◆ kToastDuration

constexpr float yaze::editor::BaseEntityHandler::kToastDuration = 1.5f
staticconstexprprotected

Definition at line 182 of file base_entity_handler.h.

Referenced by TriggerSuccessToast().


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