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 void SetAgentCallbacks(std::function<void(const std::string&)> send_callback,
101 std::function<void()> focus_callback) {
102 send_to_agent_ = std::move(send_callback);
103 focus_agent_panel_ = std::move(focus_callback);
104 }
105
106 // ============================================================================
107 // Selection Management
108 // ============================================================================
109
113 void SetSelection(const SelectionContext& context);
114
118 void ClearSelection();
119
123 const SelectionContext& GetSelection() const { return selection_; }
124
129
130 // ============================================================================
131 // Rendering
132 // ============================================================================
133
139 void Draw();
140
141 private:
142 // Type-specific drawing methods
143 void DrawNoSelection();
157 void DrawAgentActions();
158 std::string BuildSelectionContext() const;
159 std::string BuildAgentPrompt(const char* intent) const;
160 void SendAgentPrompt(const char* intent);
161
162 // Helper methods
163 void DrawPropertyHeader(const char* icon, const char* title);
164 bool DrawPositionEditor(const char* label, int* x, int* y,
165 int min_val = 0, int max_val = 512);
166 bool DrawSizeEditor(const char* label, int* width, int* height);
167 bool DrawByteProperty(const char* label, uint8_t* value,
168 const char* tooltip = nullptr);
169 bool DrawWordProperty(const char* label, uint16_t* value,
170 const char* tooltip = nullptr);
171 bool DrawComboProperty(const char* label, int* current_item,
172 const char* const items[], int items_count);
173 bool DrawFlagsProperty(const char* label, uint8_t* flags,
174 const char* const flag_names[], int flag_count);
175 void DrawReadOnlyText(const char* label, const char* value);
176 void DrawReadOnlyHex(const char* label, uint32_t value, int digits = 4);
177
178 void NotifyChange();
179
180 // State
182 Rom* rom_ = nullptr;
184 std::function<void(const std::string&)> send_to_agent_;
185 std::function<void()> focus_agent_panel_;
186
187 // UI state
188 bool show_advanced_ = false;
189 bool show_raw_data_ = false;
190};
191
195const char* GetSelectionTypeName(SelectionType type);
196
197} // namespace editor
198} // namespace yaze
199
200#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:28
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)
std::string BuildAgentPrompt(const char *intent) const
void SetAgentCallbacks(std::function< void(const std::string &)> send_callback, std::function< void()> focus_callback)
bool DrawPositionEditor(const char *label, int *x, int *y, int min_val=0, int max_val=512)
std::function< void(const std::string &) send_to_agent_)
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.