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

Handles object selection, placement, and interaction within the dungeon canvas. More...

#include <dungeon_object_interaction.h>

Collaboration diagram for yaze::editor::DungeonObjectInteraction:

Public Member Functions

 DungeonObjectInteraction (gui::Canvas *canvas)
 
void HandleCanvasMouseInput ()
 
void CheckForObjectSelection ()
 
void PlaceObjectAtPosition (int room_x, int room_y)
 
void DrawObjectSelectRect ()
 
void SelectObjectsInRect ()
 
void DrawSelectionHighlights ()
 
void DrawSelectBox ()
 
void DrawDragPreview ()
 
void UpdateSelectedObjects ()
 
bool IsObjectInSelectBox (const zelda3::RoomObject &object) const
 
std::pair< int, int > RoomToCanvasCoordinates (int room_x, int room_y) const
 
std::pair< int, int > CanvasToRoomCoordinates (int canvas_x, int canvas_y) const
 
bool IsWithinCanvasBounds (int canvas_x, int canvas_y, int margin=32) const
 
void SetCurrentRoom (std::array< zelda3::Room, 0x128 > *rooms, int room_id)
 
void SetPreviewObject (const zelda3::RoomObject &object, bool loaded)
 
const std::vector< size_t > & GetSelectedObjectIndices () const
 
bool IsObjectSelectActive () const
 
void ClearSelection ()
 
void ShowContextMenu ()
 
void HandleDeleteSelected ()
 
void HandleCopySelected ()
 
void HandlePasteObjects ()
 
void SetObjectPlacedCallback (std::function< void(const zelda3::RoomObject &)> callback)
 
void SetCacheInvalidationCallback (std::function< void()> callback)
 

Private Attributes

gui::Canvascanvas_
 
std::array< zelda3::Room, 0x128 > * rooms_ = nullptr
 
int current_room_id_ = 0
 
zelda3::RoomObject preview_object_ {0, 0, 0, 0, 0}
 
bool object_loaded_ = false
 
bool is_dragging_ = false
 
bool is_selecting_ = false
 
ImVec2 drag_start_pos_
 
ImVec2 drag_current_pos_
 
ImVec2 select_start_pos_
 
ImVec2 select_current_pos_
 
std::vector< int > selected_objects_
 
bool object_select_active_ = false
 
ImVec2 object_select_start_
 
ImVec2 object_select_end_
 
std::vector< size_t > selected_object_indices_
 
std::function< void(const zelda3::RoomObject &)> object_placed_callback_
 
std::function< void()> cache_invalidation_callback_
 
std::vector< zelda3::RoomObjectclipboard_
 
bool has_clipboard_data_ = false
 

Detailed Description

Handles object selection, placement, and interaction within the dungeon canvas.

This component manages mouse interactions for object selection (similar to OverworldEditor), object placement, drag operations, and multi-object selection.

Definition at line 21 of file dungeon_object_interaction.h.

Constructor & Destructor Documentation

◆ DungeonObjectInteraction()

yaze::editor::DungeonObjectInteraction::DungeonObjectInteraction ( gui::Canvas canvas)
inlineexplicit

Definition at line 23 of file dungeon_object_interaction.h.

Member Function Documentation

◆ HandleCanvasMouseInput()

◆ CheckForObjectSelection()

void yaze::editor::DungeonObjectInteraction::CheckForObjectSelection ( )

Definition at line 103 of file dungeon_object_interaction.cc.

References DrawObjectSelectRect(), object_select_active_, and SelectObjectsInRect().

Referenced by yaze::editor::DungeonCanvasViewer::DrawDungeonCanvas().

Here is the call graph for this function:

◆ PlaceObjectAtPosition()

void yaze::editor::DungeonObjectInteraction::PlaceObjectAtPosition ( int  room_x,
int  room_y 
)

◆ DrawObjectSelectRect()

void yaze::editor::DungeonObjectInteraction::DrawObjectSelectRect ( )

◆ SelectObjectsInRect()

void yaze::editor::DungeonObjectInteraction::SelectObjectsInRect ( )

◆ DrawSelectionHighlights()

void yaze::editor::DungeonObjectInteraction::DrawSelectionHighlights ( )

◆ DrawSelectBox()

void yaze::editor::DungeonObjectInteraction::DrawSelectBox ( )

◆ DrawDragPreview()

void yaze::editor::DungeonObjectInteraction::DrawDragPreview ( )

◆ UpdateSelectedObjects()

void yaze::editor::DungeonObjectInteraction::UpdateSelectedObjects ( )

Definition at line 319 of file dungeon_object_interaction.cc.

References current_room_id_, is_selecting_, IsObjectInSelectBox(), rooms_, and selected_objects_.

Referenced by HandleCanvasMouseInput().

Here is the call graph for this function:

◆ IsObjectInSelectBox()

bool yaze::editor::DungeonObjectInteraction::IsObjectInSelectBox ( const zelda3::RoomObject object) const

Definition at line 336 of file dungeon_object_interaction.cc.

References is_selecting_, RoomToCanvasCoordinates(), select_current_pos_, and select_start_pos_.

Referenced by UpdateSelectedObjects().

Here is the call graph for this function:

◆ RoomToCanvasCoordinates()

std::pair< int, int > yaze::editor::DungeonObjectInteraction::RoomToCanvasCoordinates ( int  room_x,
int  room_y 
) const

◆ CanvasToRoomCoordinates()

std::pair< int, int > yaze::editor::DungeonObjectInteraction::CanvasToRoomCoordinates ( int  canvas_x,
int  canvas_y 
) const

◆ IsWithinCanvasBounds()

bool yaze::editor::DungeonObjectInteraction::IsWithinCanvasBounds ( int  canvas_x,
int  canvas_y,
int  margin = 32 
) const

Definition at line 364 of file dungeon_object_interaction.cc.

References canvas_, yaze::gui::Canvas::canvas_size(), and yaze::gui::Canvas::global_scale().

Here is the call graph for this function:

◆ SetCurrentRoom()

void yaze::editor::DungeonObjectInteraction::SetCurrentRoom ( std::array< zelda3::Room, 0x128 > *  rooms,
int  room_id 
)

◆ SetPreviewObject()

void yaze::editor::DungeonObjectInteraction::SetPreviewObject ( const zelda3::RoomObject object,
bool  loaded 
)

◆ GetSelectedObjectIndices()

const std::vector< size_t > & yaze::editor::DungeonObjectInteraction::GetSelectedObjectIndices ( ) const
inline

◆ IsObjectSelectActive()

bool yaze::editor::DungeonObjectInteraction::IsObjectSelectActive ( ) const
inline

Definition at line 52 of file dungeon_object_interaction.h.

References object_select_active_.

◆ ClearSelection()

void yaze::editor::DungeonObjectInteraction::ClearSelection ( )

◆ ShowContextMenu()

◆ HandleDeleteSelected()

void yaze::editor::DungeonObjectInteraction::HandleDeleteSelected ( )

◆ HandleCopySelected()

void yaze::editor::DungeonObjectInteraction::HandleCopySelected ( )

◆ HandlePasteObjects()

void yaze::editor::DungeonObjectInteraction::HandlePasteObjects ( )

◆ SetObjectPlacedCallback()

void yaze::editor::DungeonObjectInteraction::SetObjectPlacedCallback ( std::function< void(const zelda3::RoomObject &)>  callback)
inline

Definition at line 62 of file dungeon_object_interaction.h.

References object_placed_callback_.

◆ SetCacheInvalidationCallback()

void yaze::editor::DungeonObjectInteraction::SetCacheInvalidationCallback ( std::function< void()>  callback)
inline

Definition at line 65 of file dungeon_object_interaction.h.

References cache_invalidation_callback_.

Member Data Documentation

◆ canvas_

◆ rooms_

◆ current_room_id_

◆ preview_object_

zelda3::RoomObject yaze::editor::DungeonObjectInteraction::preview_object_ {0, 0, 0, 0, 0}
private

◆ object_loaded_

bool yaze::editor::DungeonObjectInteraction::object_loaded_ = false
private

◆ is_dragging_

bool yaze::editor::DungeonObjectInteraction::is_dragging_ = false
private

◆ is_selecting_

bool yaze::editor::DungeonObjectInteraction::is_selecting_ = false
private

◆ drag_start_pos_

ImVec2 yaze::editor::DungeonObjectInteraction::drag_start_pos_
private

Definition at line 81 of file dungeon_object_interaction.h.

Referenced by DrawDragPreview(), and HandleCanvasMouseInput().

◆ drag_current_pos_

ImVec2 yaze::editor::DungeonObjectInteraction::drag_current_pos_
private

Definition at line 82 of file dungeon_object_interaction.h.

Referenced by DrawDragPreview(), and HandleCanvasMouseInput().

◆ select_start_pos_

ImVec2 yaze::editor::DungeonObjectInteraction::select_start_pos_
private

◆ select_current_pos_

ImVec2 yaze::editor::DungeonObjectInteraction::select_current_pos_
private

◆ selected_objects_

std::vector<int> yaze::editor::DungeonObjectInteraction::selected_objects_
private

Definition at line 85 of file dungeon_object_interaction.h.

Referenced by HandleCanvasMouseInput(), and UpdateSelectedObjects().

◆ object_select_active_

bool yaze::editor::DungeonObjectInteraction::object_select_active_ = false
private

◆ object_select_start_

ImVec2 yaze::editor::DungeonObjectInteraction::object_select_start_
private

Definition at line 89 of file dungeon_object_interaction.h.

Referenced by DrawObjectSelectRect(), and SelectObjectsInRect().

◆ object_select_end_

ImVec2 yaze::editor::DungeonObjectInteraction::object_select_end_
private

Definition at line 90 of file dungeon_object_interaction.h.

Referenced by DrawObjectSelectRect(), and SelectObjectsInRect().

◆ selected_object_indices_

std::vector<size_t> yaze::editor::DungeonObjectInteraction::selected_object_indices_
private

◆ object_placed_callback_

std::function<void(const zelda3::RoomObject&)> yaze::editor::DungeonObjectInteraction::object_placed_callback_
private

Definition at line 94 of file dungeon_object_interaction.h.

Referenced by PlaceObjectAtPosition(), and SetObjectPlacedCallback().

◆ cache_invalidation_callback_

std::function<void()> yaze::editor::DungeonObjectInteraction::cache_invalidation_callback_
private

◆ clipboard_

std::vector<zelda3::RoomObject> yaze::editor::DungeonObjectInteraction::clipboard_
private

Definition at line 98 of file dungeon_object_interaction.h.

Referenced by HandleCopySelected(), and HandlePasteObjects().

◆ has_clipboard_data_

bool yaze::editor::DungeonObjectInteraction::has_clipboard_data_ = false
private

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