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
42// Brief, user-facing tool mode display names. Single source of truth shared
43// between InteractionModeManager::GetModeName and DungeonToolset's tooltip
44// strings so the status bar, toolbar, and toolset stay in sync.
45namespace tool_mode_names {
46inline constexpr const char* kSelect = "Select";
47inline constexpr const char* kObjects = "Objects";
48inline constexpr const char* kSprites = "Sprites";
49inline constexpr const char* kItems = "Items";
50inline constexpr const char* kDoors = "Doors";
51inline constexpr const char* kChests = "Chests";
52inline constexpr const char* kEntrances = "Entrances";
53inline constexpr const char* kDragObjects = "Drag Objects";
54inline constexpr const char* kDragEntity = "Drag Entity";
55inline constexpr const char* kRectangle = "Rectangle";
56inline constexpr const char* kCollision = "Collision";
57inline constexpr const char* kWaterFill = "Water Fill";
58} // namespace tool_mode_names
59
60// Brief, user-facing workflow mode display names. Single source of truth
61// for the dungeon status bar, the global yaze status bar mode segment, and
62// any callsite that toggles between the integrated Workbench, the legacy
63// Standalone per-window flow, or the Connected canvas view.
64namespace workflow_mode_names {
65inline constexpr const char* kWorkbench = "Workbench";
66inline constexpr const char* kStandalone = "Standalone";
67inline constexpr const char* kConnected = "Overview";
68} // namespace workflow_mode_names
69
76struct ModeState {
77 // Placement preview data
78 std::optional<zelda3::DoorType> preview_door_type;
79 std::optional<uint8_t> preview_sprite_id;
80 std::optional<uint8_t> preview_item_id;
81
82 // Door placement specifics
85
86 // Drag state
87 ImVec2 drag_start = ImVec2(0, 0);
88 ImVec2 drag_current = ImVec2(0, 0);
89 bool duplicate_on_drag = false;
91 bool drag_has_duplicated = false;
94
95 // Rectangle selection bounds (canvas coordinates)
96 int rect_start_x = 0;
97 int rect_start_y = 0;
98 int rect_end_x = 0;
99 int rect_end_y = 0;
100
101 // Entity drag state
102 ImVec2 entity_drag_start = ImVec2(0, 0);
103 ImVec2 entity_drag_current = ImVec2(0, 0);
104
105 // Paint state (collision + water fill)
106 int paint_brush_radius = 0; // 0 = 1x1, 1 = 3x3, etc.
111 bool is_painting = false;
113
117 void Clear() {
118 preview_door_type.reset();
119 preview_sprite_id.reset();
120 preview_item_id.reset();
123 drag_start = ImVec2(0, 0);
124 drag_current = ImVec2(0, 0);
125 duplicate_on_drag = false;
126 drag_mutation_started = false;
127 drag_has_duplicated = false;
130 rect_start_x = 0;
131 rect_start_y = 0;
132 rect_end_x = 0;
133 rect_end_y = 0;
134 entity_drag_start = ImVec2(0, 0);
135 entity_drag_current = ImVec2(0, 0);
140 paint_collision_erase = false;
141 is_painting = false;
143 }
144
155
160 drag_start = ImVec2(0, 0);
161 drag_current = ImVec2(0, 0);
162 duplicate_on_drag = false;
163 drag_mutation_started = false;
164 drag_has_duplicated = false;
167 entity_drag_start = ImVec2(0, 0);
168 entity_drag_current = ImVec2(0, 0);
169 }
170
175 rect_start_x = 0;
176 rect_start_y = 0;
177 rect_end_x = 0;
178 rect_end_y = 0;
179 }
180};
181
202 public:
207
212
219 void SetMode(InteractionMode mode);
220
226 void CancelCurrentMode();
227
237
242
250
257
264
271
278
285
294
299
303 const ModeState& GetModeState() const { return mode_state_; }
304
308 const char* GetModeName() const;
309
310 private:
314};
315
316} // namespace editor
317} // namespace yaze
318
319#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.
constexpr const char * kObjects
constexpr const char * kRectangle
constexpr const char * kItems
constexpr const char * kEntrances
constexpr const char * kChests
constexpr const char * kSprites
constexpr const char * kSelect
constexpr const char * kDragEntity
constexpr const char * kWaterFill
constexpr const char * kDoors
constexpr const char * kCollision
constexpr const char * kDragObjects
constexpr const char * kConnected
constexpr const char * kStandalone
constexpr const char * kWorkbench
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
void ClearPlacementData()
Clear only placement preview data.
void ClearRectangleData()
Clear only rectangle selection state.
void ClearDragData()
Clear only drag-related state.