yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
object_editor_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_PANELS_OBJECT_EDITOR_PANEL_H_
2#define YAZE_APP_EDITOR_DUNGEON_PANELS_OBJECT_EDITOR_PANEL_H_
3
4#include <memory>
5#include <unordered_map>
6
9#include "app/editor/editor.h"
14#include "app/gui/core/icons.h"
16#include "rom/rom.h"
22#include "zelda3/game_data.h"
23
24namespace yaze {
25namespace editor {
26
48 public:
50 gfx::IRenderer* renderer, Rom* rom, DungeonCanvasViewer* canvas_viewer,
51 std::shared_ptr<zelda3::DungeonObjectEditor> object_editor = nullptr);
52
53 // ==========================================================================
54 // EditorPanel Identity
55 // ==========================================================================
56
57 std::string GetId() const override { return "dungeon.object_editor"; }
58 std::string GetDisplayName() const override { return "Object Editor"; }
59 std::string GetIcon() const override { return ICON_MD_CONSTRUCTION; }
60 std::string GetEditorCategory() const override { return "Dungeon"; }
61 int GetPriority() const override { return 60; }
62
63 // ==========================================================================
64 // EditorPanel Drawing
65 // ==========================================================================
66
67 void Draw(bool* p_open) override;
68 void OnOpen() override {}
69 void OnClose() override {}
70
71 // ==========================================================================
72 // Component Accessors
73 // ==========================================================================
74
79
80 // ==========================================================================
81 // Context Management
82 // ==========================================================================
83
84 void SetCurrentRoom(int room_id) {
85 current_room_id_ = room_id;
87 }
89 // Reset callback flag when viewer changes so we rewire to the new viewer
90 if (canvas_viewer_ != viewer) {
92 }
93 canvas_viewer_ = viewer;
95 }
96
102
103 void SetGameData(zelda3::GameData* game_data) {
104 object_selector_.SetGameData(game_data);
106 }
107
108 void SetRooms(std::array<zelda3::Room, 0x128>* rooms) {
110 }
111
115
116 // ==========================================================================
117 // Programmatic Controls (for agents/automation)
118 // ==========================================================================
119
120 void SelectObject(int obj_id);
121 void SetAgentOptimizedLayout(bool enabled);
123
124 // Object operations
125 void CycleObjectSelection(int direction);
126 void SelectAllObjects();
128 void CopySelectedObjects();
129 void PasteObjects();
130 void CancelPlacement(); // Cancel current object placement
131
132 // ==========================================================================
133 // Static Object Editor (double-click to open)
134 // ==========================================================================
135
136 void OpenStaticObjectEditor(int object_id);
140
141 private:
142 // Selection change handler
143 void OnSelectionChanged();
144
145 // Drawing methods
146 void DrawObjectSelector();
147 void DrawDoorSection();
148 void DrawEmulatorPreview();
151
152 // Keyboard shortcuts
154 void DeselectAllObjects();
155 void PerformDelete();
157 void NudgeSelectedObjects(int dx, int dy);
158 void ScrollToObject(size_t index);
159
160 // ==========================================================================
161 // Member Variables
162 // ==========================================================================
163
164 Rom* rom_ = nullptr;
167
168 // Components
171
172 // Object preview canvases (one per object type)
173 std::unordered_map<int, gui::Canvas> object_preview_canvases_;
174
175 // UI state
178 bool show_object_list_ = true;
180 bool show_grid_ = true;
181 bool show_object_ids_ = false;
184
185 // Selected object for placement
189 std::shared_ptr<zelda3::DungeonObjectEditor> object_editor_;
190
191 // Selection state cache (updated via callback)
194
195 // Static object editor state (opened via double-click)
199 gui::Canvas static_preview_canvas_{"##StaticObjectPreview", ImVec2(128, 128)};
201 std::unique_ptr<zelda3::ObjectParser> object_parser_;
204
205 // Door placement state
208};
209
210} // namespace editor
211} // namespace yaze
212
213#endif // YAZE_APP_EDITOR_DUNGEON_PANELS_OBJECT_EDITOR_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
Handles object selection, preview, and editing UI.
void set_rooms(std::array< zelda3::Room, 0x128 > *rooms)
void SetGameData(zelda3::GameData *game_data)
void SetCurrentPaletteGroup(const gfx::PaletteGroup &palette_group)
Base interface for all logical panel components.
Unified panel for dungeon object editing.
gui::DungeonObjectEmulatorPreview & emulator_preview()
int GetPriority() const override
Get display priority for menu ordering.
std::string GetIcon() const override
Material Design icon for this panel.
void SetCanvasViewer(DungeonCanvasViewer *viewer)
void OnClose() override
Called when panel is hidden.
std::string GetId() const override
Unique identifier for this panel.
void SetCurrentPaletteGroup(const gfx::PaletteGroup &group)
void SetGameData(zelda3::GameData *game_data)
ObjectEditorPanel(gfx::IRenderer *renderer, Rom *rom, DungeonCanvasViewer *canvas_viewer, std::shared_ptr< zelda3::DungeonObjectEditor > object_editor=nullptr)
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
std::unique_ptr< zelda3::ObjectParser > object_parser_
std::unordered_map< int, gui::Canvas > object_preview_canvases_
void OnOpen() override
Called when panel becomes visible.
gui::DungeonObjectEmulatorPreview emulator_preview_
void SetContext(EditorContext ctx)
gfx::BackgroundBuffer static_preview_buffer_
void SetRooms(std::array< zelda3::Room, 0x128 > *rooms)
void Draw(bool *p_open) override
Draw the panel content.
DungeonObjectSelector & object_selector()
std::shared_ptr< zelda3::DungeonObjectEditor > object_editor_
std::string GetEditorCategory() const override
Editor category this panel belongs to.
zelda3::ObjectDrawInfo static_editor_draw_info_
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:67
Defines an abstract interface for all rendering operations.
Definition irenderer.h:40
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:150
#define ICON_MD_CONSTRUCTION
Definition icons.h:458
DoorType
Door types from ALTTP.
Definition door_types.h:33
@ NormalDoor
Normal door (upper layer)
Lightweight view into the essential runtime context (Rom + GameData)
Definition editor.h:67
zelda3::GameData * game_data
Definition editor.h:69
Represents a group of palettes.
Draw routine information for object rendering.