yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_object_interaction.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_DUNGEON_OBJECT_INTERACTION_H
2#define YAZE_APP_EDITOR_DUNGEON_DUNGEON_OBJECT_INTERACTION_H
3
4#include <vector>
5#include <functional>
6
7#include "imgui/imgui.h"
8#include "app/gui/canvas.h"
11
12namespace yaze {
13namespace editor {
14
22 public:
23 explicit DungeonObjectInteraction(gui::Canvas* canvas) : canvas_(canvas) {}
24
25 // Main interaction handling
28 void PlaceObjectAtPosition(int room_x, int room_y);
29
30 // Selection rectangle (like OverworldEditor)
33 void DrawSelectionHighlights(); // Draw highlights for selected objects
34
35 // Drag and select box functionality
36 void DrawSelectBox();
37 void DrawDragPreview();
39 bool IsObjectInSelectBox(const zelda3::RoomObject& object) const;
40
41 // Coordinate conversion
42 std::pair<int, int> RoomToCanvasCoordinates(int room_x, int room_y) const;
43 std::pair<int, int> CanvasToRoomCoordinates(int canvas_x, int canvas_y) const;
44 bool IsWithinCanvasBounds(int canvas_x, int canvas_y, int margin = 32) const;
45
46 // State management
47 void SetCurrentRoom(std::array<zelda3::Room, 0x128>* rooms, int room_id);
48 void SetPreviewObject(const zelda3::RoomObject& object, bool loaded);
49
50 // Selection state
51 const std::vector<size_t>& GetSelectedObjectIndices() const { return selected_object_indices_; }
53 void ClearSelection();
54
55 // Context menu
56 void ShowContextMenu();
58 void HandleCopySelected();
59 void HandlePasteObjects();
60
61 // Callbacks
62 void SetObjectPlacedCallback(std::function<void(const zelda3::RoomObject&)> callback) {
63 object_placed_callback_ = callback;
64 }
65 void SetCacheInvalidationCallback(std::function<void()> callback) {
67 }
68
69 private:
71 std::array<zelda3::Room, 0x128>* rooms_ = nullptr;
73
74 // Preview object state
76 bool object_loaded_ = false;
77
78 // Drag and select infrastructure
79 bool is_dragging_ = false;
80 bool is_selecting_ = false;
85 std::vector<int> selected_objects_;
86
87 // Object selection rectangle (like OverworldEditor)
91 std::vector<size_t> selected_object_indices_;
92
93 // Callbacks
94 std::function<void(const zelda3::RoomObject&)> object_placed_callback_;
95 std::function<void()> cache_invalidation_callback_;
96
97 // Clipboard for copy/paste
98 std::vector<zelda3::RoomObject> clipboard_;
99 bool has_clipboard_data_ = false;
100};
101
102} // namespace editor
103} // namespace yaze
104
105#endif // YAZE_APP_EDITOR_DUNGEON_DUNGEON_OBJECT_INTERACTION_H
Handles object selection, placement, and interaction within the dungeon canvas.
std::array< zelda3::Room, 0x128 > * rooms_
bool IsWithinCanvasBounds(int canvas_x, int canvas_y, int margin=32) const
void SetCacheInvalidationCallback(std::function< void()> callback)
void SetCurrentRoom(std::array< zelda3::Room, 0x128 > *rooms, int room_id)
std::pair< int, int > RoomToCanvasCoordinates(int room_x, int room_y) const
bool IsObjectInSelectBox(const zelda3::RoomObject &object) const
void SetObjectPlacedCallback(std::function< void(const zelda3::RoomObject &)> callback)
std::vector< zelda3::RoomObject > clipboard_
std::function< void(const zelda3::RoomObject &)> object_placed_callback_
const std::vector< size_t > & GetSelectedObjectIndices() const
std::pair< int, int > CanvasToRoomCoordinates(int canvas_x, int canvas_y) const
void SetPreviewObject(const zelda3::RoomObject &object, bool loaded)
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:54
Main namespace for the application.