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::RoomObject> preview_object;
79 std::optional<zelda3::DoorType> preview_door_type;
80 std::optional<uint8_t> preview_sprite_id;
81 std::optional<uint8_t> preview_item_id;
82
83 // Door placement specifics
86
87 // Drag state
88 ImVec2 drag_start = ImVec2(0, 0);
89 ImVec2 drag_current = ImVec2(0, 0);
90 bool duplicate_on_drag = false;
92 bool drag_has_duplicated = false;
95
96 // Rectangle selection bounds (canvas coordinates)
97 int rect_start_x = 0;
98 int rect_start_y = 0;
99 int rect_end_x = 0;
100 int rect_end_y = 0;
101
102 // Entity drag state
103 ImVec2 entity_drag_start = ImVec2(0, 0);
104 ImVec2 entity_drag_current = ImVec2(0, 0);
105
106 // Paint state (collision + water fill)
107 int paint_brush_radius = 0; // 0 = 1x1, 1 = 3x3, etc.
111 bool is_painting = false;
113
117 void Clear() {
118 preview_object.reset();
119 preview_door_type.reset();
120 preview_sprite_id.reset();
121 preview_item_id.reset();
124 drag_start = ImVec2(0, 0);
125 drag_current = ImVec2(0, 0);
126 duplicate_on_drag = false;
127 drag_mutation_started = false;
128 drag_has_duplicated = false;
131 rect_start_x = 0;
132 rect_start_y = 0;
133 rect_end_x = 0;
134 rect_end_y = 0;
135 entity_drag_start = ImVec2(0, 0);
136 entity_drag_current = ImVec2(0, 0);
141 is_painting = false;
143 }
144
156
161 drag_start = ImVec2(0, 0);
162 drag_current = ImVec2(0, 0);
163 duplicate_on_drag = false;
164 drag_mutation_started = false;
165 drag_has_duplicated = false;
168 entity_drag_start = ImVec2(0, 0);
169 entity_drag_current = ImVec2(0, 0);
170 }
171
176 rect_start_x = 0;
177 rect_start_y = 0;
178 rect_end_x = 0;
179 rect_end_y = 0;
180 }
181};
182
203 public:
208
213
220 void SetMode(InteractionMode mode);
221
227 void CancelCurrentMode();
228
238
243
251
258
265
272
279
286
295
300
304 const ModeState& GetModeState() const { return mode_state_; }
305
309 const char* GetModeName() const;
310
311 private:
315};
316
317} // namespace editor
318} // namespace yaze
319
320#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
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.