yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
interaction_mode.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_INTERACTION_INTERACTION_MODE_H_
2#define YAZE_APP_EDITOR_DUNGEON_INTERACTION_INTERACTION_MODE_H_
3
4#include <optional>
5
6#include "imgui/imgui.h"
9
10namespace yaze {
11namespace editor {
12
29enum class InteractionMode {
30 Select, // Normal selection mode (no placement active)
31 PlaceObject, // Placing a room tile object
32 PlaceDoor, // Placing a door entity
33 PlaceSprite, // Placing a sprite entity
34 PlaceItem, // Placing a pot item entity
35 DraggingObjects, // Dragging selected tile objects
36 DraggingEntity, // Dragging selected door/sprite/item
37 RectangleSelect, // Drawing rectangle selection box
38 PaintCollision, // Painting custom collision tiles
39 PaintWaterFill, // Painting water fill zones (Oracle of Secrets)
40};
41
48struct ModeState {
49 // Placement preview data
50 std::optional<zelda3::RoomObject> preview_object;
51 std::optional<zelda3::DoorType> preview_door_type;
52 std::optional<uint8_t> preview_sprite_id;
53 std::optional<uint8_t> preview_item_id;
54
55 // Door placement specifics
58
59 // Drag state
60 ImVec2 drag_start = ImVec2(0, 0);
61 ImVec2 drag_current = ImVec2(0, 0);
62 bool duplicate_on_drag = false;
64 bool drag_has_duplicated = false;
67
68 // Rectangle selection bounds (canvas coordinates)
69 int rect_start_x = 0;
70 int rect_start_y = 0;
71 int rect_end_x = 0;
72 int rect_end_y = 0;
73
74 // Entity drag state
75 ImVec2 entity_drag_start = ImVec2(0, 0);
76 ImVec2 entity_drag_current = ImVec2(0, 0);
77
78 // Paint state (collision + water fill)
79 int paint_brush_radius = 0; // 0 = 1x1, 1 = 3x3, etc.
83 bool is_painting = false;
85
89 void Clear() {
90 preview_object.reset();
91 preview_door_type.reset();
92 preview_sprite_id.reset();
93 preview_item_id.reset();
96 drag_start = ImVec2(0, 0);
97 drag_current = ImVec2(0, 0);
98 duplicate_on_drag = false;
100 drag_has_duplicated = false;
103 rect_start_x = 0;
104 rect_start_y = 0;
105 rect_end_x = 0;
106 rect_end_y = 0;
107 entity_drag_start = ImVec2(0, 0);
108 entity_drag_current = ImVec2(0, 0);
113 is_painting = false;
115 }
116
128
133 drag_start = ImVec2(0, 0);
134 drag_current = ImVec2(0, 0);
135 duplicate_on_drag = false;
136 drag_mutation_started = false;
137 drag_has_duplicated = false;
140 entity_drag_start = ImVec2(0, 0);
141 entity_drag_current = ImVec2(0, 0);
142 }
143
148 rect_start_x = 0;
149 rect_start_y = 0;
150 rect_end_x = 0;
151 rect_end_y = 0;
152 }
153};
154
175 public:
180
185
192 void SetMode(InteractionMode mode);
193
199 void CancelCurrentMode();
200
210
215
223
230
237
244
251
258
267
272
276 const ModeState& GetModeState() const { return mode_state_; }
277
281 const char* GetModeName() const;
282
283 private:
287};
288
289} // namespace editor
290} // namespace yaze
291
292#endif // YAZE_APP_EDITOR_DUNGEON_INTERACTION_INTERACTION_MODE_H_
Manages interaction mode state and transitions.
bool IsRectangleSelecting() const
Check if rectangle selection is in progress.
bool IsDoorPlacementActive() const
Check if door placement mode is active.
void CancelCurrentMode()
Cancel current mode and return to Select.
void SetMode(InteractionMode mode)
Set interaction mode.
InteractionMode GetMode() const
Get current interaction mode.
ModeState & GetModeState()
Get mutable reference to mode state.
const ModeState & GetModeState() const
Get const reference to mode state.
const char * GetModeName() const
Get mode name for debugging/UI.
bool IsSpritePlacementActive() const
Check if sprite placement mode is active.
bool IsItemPlacementActive() const
Check if item placement mode is active.
bool IsSelectMode() const
Check if in normal selection mode.
bool IsDragging() const
Check if any dragging operation is in progress.
InteractionMode GetPreviousMode() const
Get previous mode (for undo/escape handling)
bool IsEntityPlacementActive() const
Check if entity (non-object) placement is active.
bool IsPlacementActive() const
Check if any placement mode is active.
bool IsObjectPlacementActive() const
Check if object placement mode is active.
InteractionMode
Unified interaction mode for the dungeon editor.
DoorDirection
Door direction on room walls.
Definition door_types.h:18
@ North
Top wall (horizontal door, 4x3 tiles)
Mode-specific state data.
std::optional< zelda3::DoorType > preview_door_type
void Clear()
Clear all mode state.
zelda3::DoorDirection detected_door_direction
std::optional< uint8_t > preview_item_id
std::optional< uint8_t > preview_sprite_id
std::optional< zelda3::RoomObject > preview_object
void ClearPlacementData()
Clear only placement preview data.
void ClearRectangleData()
Clear only rectangle selection state.
void ClearDragData()
Clear only drag-related state.