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};
39
46struct ModeState {
47 // Placement preview data
48 std::optional<zelda3::RoomObject> preview_object;
49 std::optional<zelda3::DoorType> preview_door_type;
50 std::optional<uint8_t> preview_sprite_id;
51 std::optional<uint8_t> preview_item_id;
52
53 // Door placement specifics
56
57 // Drag state
58 ImVec2 drag_start = ImVec2(0, 0);
59 ImVec2 drag_current = ImVec2(0, 0);
60
61 // Rectangle selection bounds (canvas coordinates)
62 int rect_start_x = 0;
63 int rect_start_y = 0;
64 int rect_end_x = 0;
65 int rect_end_y = 0;
66
67 // Entity drag state
68 ImVec2 entity_drag_start = ImVec2(0, 0);
69 ImVec2 entity_drag_current = ImVec2(0, 0);
70
74 void Clear() {
75 preview_object.reset();
76 preview_door_type.reset();
77 preview_sprite_id.reset();
78 preview_item_id.reset();
81 drag_start = ImVec2(0, 0);
82 drag_current = ImVec2(0, 0);
83 rect_start_x = 0;
84 rect_start_y = 0;
85 rect_end_x = 0;
86 rect_end_y = 0;
87 entity_drag_start = ImVec2(0, 0);
88 entity_drag_current = ImVec2(0, 0);
89 }
90
102
107 drag_start = ImVec2(0, 0);
108 drag_current = ImVec2(0, 0);
109 entity_drag_start = ImVec2(0, 0);
110 entity_drag_current = ImVec2(0, 0);
111 }
112
117 rect_start_x = 0;
118 rect_start_y = 0;
119 rect_end_x = 0;
120 rect_end_y = 0;
121 }
122};
123
144 public:
149
154
161 void SetMode(InteractionMode mode);
162
168 void CancelCurrentMode();
169
179
184
192
199
206
213
220
227
236
241
245 const ModeState& GetModeState() const { return mode_state_; }
246
250 const char* GetModeName() const;
251
252 private:
256};
257
258} // namespace editor
259} // namespace yaze
260
261#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.