yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
selection_properties_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_UI_SELECTION_PROPERTIES_PANEL_H_
2#define YAZE_APP_EDITOR_UI_SELECTION_PROPERTIES_PANEL_H_
3
4#include <functional>
5#include <string>
6#include <variant>
7#include <vector>
8
9#include "imgui/imgui.h"
10
11namespace yaze {
12
13class Rom;
14
15namespace zelda3 {
16struct DungeonObject;
17struct Sprite;
18struct Entrance;
19class OverworldMap;
20} // namespace zelda3
21
22namespace editor {
23
43
50 int id = -1; // Primary identifier
51 int secondary_id = -1; // Secondary identifier (e.g., room for objects)
52 void* data = nullptr; // Pointer to the actual data structure
53 std::string display_name; // Human-readable name for the selection
54 bool read_only = false; // Whether editing is allowed
55};
56
82 public:
83 using ChangeCallback = std::function<void(const SelectionContext&)>;
84
87
88 // Non-copyable
91
92 // ============================================================================
93 // Configuration
94 // ============================================================================
95
96 void SetRom(Rom* rom) { rom_ = rom; }
98 on_change_ = std::move(callback);
99 }
100
101 // ============================================================================
102 // Selection Management
103 // ============================================================================
104
108 void SetSelection(const SelectionContext& context);
109
113 void ClearSelection();
114
118 const SelectionContext& GetSelection() const { return selection_; }
119
124
125 // ============================================================================
126 // Rendering
127 // ============================================================================
128
134 void Draw();
135
136 private:
137 // Type-specific drawing methods
138 void DrawNoSelection();
151
152 // Helper methods
153 void DrawPropertyHeader(const char* icon, const char* title);
154 bool DrawPositionEditor(const char* label, int* x, int* y,
155 int min_val = 0, int max_val = 512);
156 bool DrawSizeEditor(const char* label, int* width, int* height);
157 bool DrawByteProperty(const char* label, uint8_t* value,
158 const char* tooltip = nullptr);
159 bool DrawWordProperty(const char* label, uint16_t* value,
160 const char* tooltip = nullptr);
161 bool DrawComboProperty(const char* label, int* current_item,
162 const char* const items[], int items_count);
163 bool DrawFlagsProperty(const char* label, uint8_t* flags,
164 const char* const flag_names[], int flag_count);
165 void DrawReadOnlyText(const char* label, const char* value);
166 void DrawReadOnlyHex(const char* label, uint32_t value, int digits = 4);
167
168 void NotifyChange();
169
170 // State
172 Rom* rom_ = nullptr;
174
175 // UI state
176 bool show_advanced_ = false;
177 bool show_raw_data_ = false;
178};
179
183const char* GetSelectionTypeName(SelectionType type);
184
185} // namespace editor
186} // namespace yaze
187
188#endif // YAZE_APP_EDITOR_UI_SELECTION_PROPERTIES_PANEL_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:24
Full-editing properties panel for selected entities.
bool DrawByteProperty(const char *label, uint8_t *value, const char *tooltip=nullptr)
bool DrawFlagsProperty(const char *label, uint8_t *flags, const char *const flag_names[], int flag_count)
bool DrawPositionEditor(const char *label, int *x, int *y, int min_val=0, int max_val=512)
const SelectionContext & GetSelection() const
Get the current selection context.
void DrawReadOnlyText(const char *label, const char *value)
SelectionPropertiesPanel(const SelectionPropertiesPanel &)=delete
bool DrawSizeEditor(const char *label, int *width, int *height)
std::function< void(const SelectionContext &)> ChangeCallback
SelectionPropertiesPanel & operator=(const SelectionPropertiesPanel &)=delete
bool DrawWordProperty(const char *label, uint16_t *value, const char *tooltip=nullptr)
bool HasSelection() const
Check if there's an active selection.
bool DrawComboProperty(const char *label, int *current_item, const char *const items[], int items_count)
void ClearSelection()
Clear the current selection.
void Draw()
Draw the properties panel content.
void DrawReadOnlyHex(const char *label, uint32_t value, int digits=4)
void DrawPropertyHeader(const char *icon, const char *title)
void SetSelection(const SelectionContext &context)
Set the current selection to display/edit.
const char * GetSelectionTypeName(SelectionType type)
Get a human-readable name for a selection type.
SelectionType
Types of entities that can be selected and edited.
Holds information about the current selection.