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 = "Connected";
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.
110 bool is_painting = false;
112
116 void Clear() {
117 preview_door_type.reset();
118 preview_sprite_id.reset();
119 preview_item_id.reset();
122 drag_start = ImVec2(0, 0);
123 drag_current = ImVec2(0, 0);
124 duplicate_on_drag = false;
125 drag_mutation_started = false;
126 drag_has_duplicated = false;
129 rect_start_x = 0;
130 rect_start_y = 0;
131 rect_end_x = 0;
132 rect_end_y = 0;
133 entity_drag_start = ImVec2(0, 0);
134 entity_drag_current = ImVec2(0, 0);
139 is_painting = false;
141 }
142
153
158 drag_start = ImVec2(0, 0);
159 drag_current = ImVec2(0, 0);
160 duplicate_on_drag = false;
161 drag_mutation_started = false;
162 drag_has_duplicated = false;
165 entity_drag_start = ImVec2(0, 0);
166 entity_drag_current = ImVec2(0, 0);
167 }
168
173 rect_start_x = 0;
174 rect_start_y = 0;
175 rect_end_x = 0;
176 rect_end_y = 0;
177 }
178};
179
200 public:
205
210
217 void SetMode(InteractionMode mode);
218
224 void CancelCurrentMode();
225
235
240
248
255
262
269
276
283
292
297
301 const ModeState& GetModeState() const { return mode_state_; }
302
306 const char* GetModeName() const;
307
308 private:
312};
313
314} // namespace editor
315} // namespace yaze
316
317#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.