yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
interaction_coordinator.cc
Go to the documentation of this file.
1// Related header
3
4// Third-party library headers
5#include "imgui/imgui.h"
6
7namespace yaze::editor {
8
15
17 // Cancel current mode first
19
20 current_mode_ = mode;
21
22 // Activate the new mode
23 switch (mode) {
24 case Mode::PlaceDoor:
26 break;
29 break;
30 case Mode::PlaceItem:
32 break;
33 case Mode::Select:
34 // Nothing to activate
35 break;
36 }
37}
38
47
53
54bool InteractionCoordinator::HandleClick(int canvas_x, int canvas_y) {
55 // Check placement modes first
57 return door_handler_.HandleClick(canvas_x, canvas_y);
58 }
60 return sprite_handler_.HandleClick(canvas_x, canvas_y);
61 }
63 return item_handler_.HandleClick(canvas_x, canvas_y);
64 }
65
66 // In select mode, try to select entity
67 return TrySelectEntityAtCursor(canvas_x, canvas_y);
68}
69
70void InteractionCoordinator::HandleDrag(ImVec2 current_pos, ImVec2 delta) {
71 // Forward drag to handlers that have active selections
73 door_handler_.HandleDrag(current_pos, delta);
74 }
76 sprite_handler_.HandleDrag(current_pos, delta);
77 }
79 item_handler_.HandleDrag(current_pos, delta);
80 }
81}
82
89
102
104 // Draw selection highlights for all entity types
108
109 // Draw snap indicators for door placement
112 }
113}
114
116 int canvas_y) {
117 // Clear all selections first
119
120 // Try to select in priority order: doors, sprites, items
121 // (matches original DungeonObjectInteraction behavior)
122 if (door_handler_.HandleClick(canvas_x, canvas_y)) {
123 return true;
124 }
125 if (sprite_handler_.HandleClick(canvas_x, canvas_y)) {
126 return true;
127 }
128 if (item_handler_.HandleClick(canvas_x, canvas_y)) {
129 return true;
130 }
131
132 return false;
133}
134
139
145
155
169
171 switch (current_mode_) {
172 case Mode::PlaceDoor:
173 return &door_handler_;
175 return &sprite_handler_;
176 case Mode::PlaceItem:
177 return &item_handler_;
178 case Mode::Select:
179 default:
180 return nullptr;
181 }
182}
183
184} // namespace yaze::editor
Abstract base class for entity interaction handlers.
void SetContext(InteractionContext *ctx)
Set the interaction context.
void DrawSelectionHighlight() override
Draw selection highlight for selected entities.
void DrawSnapIndicators()
Draw snap position indicators during door drag.
void DrawGhostPreview() override
Draw ghost preview during placement.
void HandleDrag(ImVec2 current_pos, ImVec2 delta) override
Handle mouse drag.
void CancelPlacement() override
Cancel current placement.
void BeginPlacement() override
Begin placement mode.
void HandleRelease() override
Handle mouse release.
bool HandleClick(int canvas_x, int canvas_y) override
Handle mouse click at canvas position.
bool IsPlacementActive() const override
Check if placement mode is active.
bool HasSelection() const
Check if a door is selected.
bool TrySelectEntityAtCursor(int canvas_x, int canvas_y)
Try to select entity at cursor position.
Mode GetSelectedEntityType() const
Get the type of currently selected entity.
void CancelCurrentMode()
Cancel current mode and return to select mode.
void SetContext(InteractionContext *ctx)
Set the shared interaction context.
BaseEntityHandler * GetActiveHandler()
Get active handler based on current mode.
void DeleteSelectedEntity()
Delete currently selected entity.
bool IsPlacementActive() const
Check if any placement mode is active.
bool HandleClick(int canvas_x, int canvas_y)
Handle click at canvas position.
void DrawSelectionHighlights()
Draw selection highlights for all entity types.
void SetMode(Mode mode)
Set interaction mode.
void ClearAllEntitySelections()
Clear all entity selections.
void DrawGhostPreviews()
Draw ghost previews for active placement mode.
bool HasEntitySelection() const
Check if any entity is selected.
void HandleDrag(ImVec2 current_pos, ImVec2 delta)
Handle drag operation.
void DrawSelectionHighlight() override
Draw selection highlight for selected entities.
bool HandleClick(int canvas_x, int canvas_y) override
Handle mouse click at canvas position.
bool IsPlacementActive() const override
Check if placement mode is active.
void DrawGhostPreview() override
Draw ghost preview during placement.
void BeginPlacement() override
Begin placement mode.
void HandleDrag(ImVec2 current_pos, ImVec2 delta) override
Handle mouse drag.
bool HasSelection() const
Check if an item is selected.
void HandleRelease() override
Handle mouse release.
void CancelPlacement() override
Cancel current placement.
bool IsPlacementActive() const override
Check if placement mode is active.
void CancelPlacement() override
Cancel current placement.
void HandleRelease() override
Handle mouse release.
bool HasSelection() const
Check if a sprite is selected.
void DrawGhostPreview() override
Draw ghost preview during placement.
void DrawSelectionHighlight() override
Draw selection highlight for selected entities.
void HandleDrag(ImVec2 current_pos, ImVec2 delta) override
Handle mouse drag.
bool HandleClick(int canvas_x, int canvas_y) override
Handle mouse click at canvas position.
void BeginPlacement() override
Begin placement mode.
Editors are the view controllers for the application.
Definition agent_chat.cc:23
Shared context for all interaction handlers.