yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
door_interaction_handler.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_INTERACTION_DOOR_INTERACTION_HANDLER_H_
2#define YAZE_APP_EDITOR_DUNGEON_INTERACTION_DOOR_INTERACTION_HANDLER_H_
3
4#include <string>
5
10
11namespace yaze {
12namespace editor {
13
21 public:
23 kNone = 0,
27 };
28 enum class GhostCapacityState {
29 kNormal = 0,
32 };
33
34 // ========================================================================
35 // BaseEntityHandler interface
36 // ========================================================================
37
38 void BeginPlacement() override;
39 void CancelPlacement() override;
40 bool IsPlacementActive() const override { return door_placement_mode_; }
41
42 bool HandleClick(int canvas_x, int canvas_y) override;
43 void HandleDrag(ImVec2 current_pos, ImVec2 delta) override;
44 void HandleRelease() override;
45 bool HandleOverlayClick(int canvas_x, int canvas_y);
46
47 void DrawGhostPreview() override;
48 void DrawSelectionHighlight() override;
49
50 std::optional<size_t> GetEntityAtPosition(int canvas_x,
51 int canvas_y) const override;
52
53 // ========================================================================
54 // Door-specific methods
55 // ========================================================================
56
61
66
72 void DrawSnapIndicators();
73
77 void SelectDoor(size_t index);
78
82 void ClearSelection();
83
87 bool HasSelection() const { return selected_door_index_.has_value(); }
88
92 std::optional<size_t> GetSelectedIndex() const {
94 }
95
99 void DeleteSelected();
100 void DeleteAll();
101 bool NudgeSelected(int delta_x, int delta_y);
102
112 bool MutateDoorType(size_t index, zelda3::DoorType new_type);
113
125
126 private:
128 std::string label;
131 ImU32 color = 0;
133 std::optional<size_t> target_door_index;
136 };
137
138 // Placement state
144
145 // Selection state
146 std::optional<size_t> selected_door_index_;
147 bool is_dragging_ = false;
150
154 void PlaceDoorAtSnappedPosition(int canvas_x, int canvas_y);
155
159 bool UpdateSnappedPosition(int canvas_x, int canvas_y);
160
161 std::optional<PairBadgeOverlay> BuildPairBadgeOverlay(
162 const zelda3::Room::Door& door, ImVec2 door_pos, ImVec2 door_size,
163 float scale) const;
164 void NavigateToPairBadge(const PairBadgeOverlay& badge) const;
165};
166
167} // namespace editor
168} // namespace yaze
169
170#endif // YAZE_APP_EDITOR_DUNGEON_INTERACTION_DOOR_INTERACTION_HANDLER_H_
Abstract base class for entity interaction handlers.
Handles door placement and interaction in the dungeon editor.
bool HandleOverlayClick(int canvas_x, int canvas_y)
bool NudgeSelected(int delta_x, int delta_y)
void DrawSelectionHighlight() override
Draw selection highlight for selected entities.
void DrawSnapIndicators()
Draw snap position indicators during door drag.
void SelectDoor(size_t index)
Select door at index.
void DrawGhostPreview() override
Draw ghost preview during placement.
void NavigateToPairBadge(const PairBadgeOverlay &badge) const
zelda3::DoorType GetDoorType() const
Get current door type for placement.
void HandleDrag(ImVec2 current_pos, ImVec2 delta) override
Handle mouse drag.
void SetDoorType(zelda3::DoorType type)
Set door type for placement.
void CancelPlacement() override
Cancel current placement.
PlacementBlockReason placement_block_reason() const
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.
std::optional< size_t > GetSelectedIndex() const
Get selected door index.
GhostCapacityState GetPlacementGhostCapacityState() const
bool IsPlacementActive() const override
Check if placement mode is active.
bool UpdateSnappedPosition(int canvas_x, int canvas_y)
Update snapped position based on cursor.
void PlaceDoorAtSnappedPosition(int canvas_x, int canvas_y)
Place door at snapped position.
bool MutateDoorType(size_t index, zelda3::DoorType new_type)
Change the type of a door in place, re-encoding ROM bytes.
std::optional< size_t > GetEntityAtPosition(int canvas_x, int canvas_y) const override
Get entity at canvas position.
bool was_placement_blocked() const
True if the most recent PlaceDoorAtSnappedPosition was blocked.
bool HasSelection() const
Check if a door is selected.
std::optional< PairBadgeOverlay > BuildPairBadgeOverlay(const zelda3::Room::Door &door, ImVec2 door_pos, ImVec2 door_size, float scale) const
DoorType
Door types from ALTTP.
Definition door_types.h:33
@ NormalDoor
Normal door (upper layer)
DoorDirection
Door direction on room walls.
Definition door_types.h:18
@ North
Top wall (horizontal door, 4x3 tiles)
Represents a door in a dungeon room.
Definition room.h:276