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

Protected Member Functions

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
 

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

References ctx_.

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

◆ context()

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

Get the interaction context.

Definition at line 39 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, and yaze::editor::SpriteInteractionHandler.

◆ 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, and yaze::editor::SpriteInteractionHandler.

◆ 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, and yaze::editor::SpriteInteractionHandler.

◆ 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, and yaze::editor::SpriteInteractionHandler.

◆ 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, and yaze::editor::SpriteInteractionHandler.

◆ 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, and yaze::editor::SpriteInteractionHandler.

◆ 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, and yaze::editor::SpriteInteractionHandler.

◆ 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, and yaze::editor::SpriteInteractionHandler.

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

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

Referenced by yaze::editor::DoorInteractionHandler::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 144 of file base_entity_handler.h.

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

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

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

Here is the call graph for this function:

◆ GetCanvasZeroPoint()

ImVec2 yaze::editor::BaseEntityHandler::GetCanvasZeroPoint ( ) const
inlineprotected

◆ GetCanvasScale()

◆ HasValidContext()

◆ GetCurrentRoom()

Member Data Documentation

◆ ctx_


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