yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
room_graphics_content.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_WORKSPACE_ROOM_GRAPHICS_CONTENT_H_
2#define YAZE_APP_EDITOR_DUNGEON_WORKSPACE_ROOM_GRAPHICS_CONTENT_H_
3
4#include <array>
5#include <cstdint>
6#include <functional>
7#include <map>
8#include <string>
9
13#include "app/gfx/core/bitmap.h"
17#include "app/gui/core/icons.h"
19#include "imgui/imgui.h"
20#include "zelda3/dungeon/room.h"
22
23namespace yaze {
24namespace editor {
25
26class DungeonEditorV2;
27
38 public:
39 // Default constructor for ContentRegistry self-registration
41 : room_gfx_canvas_("##RoomGfxCanvasPanel", ImVec2(256 + 1, 256 + 1)) {}
42
43 // Legacy constructor for direct instantiation
44 RoomGraphicsContent(int* current_room_id, DungeonRoomStore* rooms,
45 gfx::IRenderer* renderer = nullptr)
46 : current_room_id_(current_room_id),
47 rooms_(rooms),
48 renderer_(renderer),
49 room_gfx_canvas_("##RoomGfxCanvasPanel", ImVec2(256 + 1, 256 + 1)) {}
50
51 ~RoomGraphicsContent() override;
52
59 palette_dirty_ = true;
60 }
61
62 using AssignmentCallback = std::function<absl::Status(int, int, int)>;
64 assignment_callback_ = std::move(callback);
65 }
67 std::function<absl::StatusOr<zelda3::RoomsetUsageReport>(int)>;
69 usage_callback_ = std::move(callback);
70 }
71 // Workspace content can outlive its session during terminal teardown.
73
74 // ==========================================================================
75 // WindowContent Identity
76 // ==========================================================================
77
78 std::string GetId() const override { return "dungeon.room_graphics"; }
79 std::string GetDisplayName() const override { return "Room Graphics"; }
80 std::string GetIcon() const override { return ICON_MD_IMAGE; }
81 std::string GetEditorCategory() const override { return "Dungeon"; }
82 int GetPriority() const override { return 50; }
83 std::string GetWorkflowGroup() const override { return "Editors"; }
84 float GetPreferredWidth() const override { return 440.0f; }
85
86 // ==========================================================================
87 // WindowContent Drawing
88 // ==========================================================================
89
90 void Draw(bool* p_open) override;
91
92 private:
94
96 uint8_t block_id = 0;
97 size_t source_offset = 0;
98 int width = 0;
99 int height = 0;
102 bool bitmap_active = false;
103 bool has_surface = false;
104 bool has_texture = false;
105 };
106
107 void RefreshSheetPreviews(const zelda3::Room& room);
108 void DrawAssignmentControls(const zelda3::Room& room);
109 void DrawAssignmentPicker(const zelda3::Room& room);
110 void DrawSharedUsage(int roomset);
111 void ClearPickerPreviews();
112
113 int* current_room_id_ = nullptr;
117 std::array<gfx::Bitmap, 16> sheet_previews_;
118 std::array<SheetPreviewMetadata, 16> sheet_preview_metadata_{};
119 std::array<uint8_t, 16> preview_block_ids_{};
123 bool show_source_trace_ = false;
124 bool runtime_detached_ = false;
129 bool show_picker_ = false;
130 std::string assignment_error_;
133 std::map<int, gfx::Bitmap> picker_previews_;
136
137 // Palette tracking for proper sheet coloring
139 bool palette_dirty_ = true;
140};
141
142} // namespace editor
143} // namespace yaze
144
145#endif // YAZE_APP_EDITOR_DUNGEON_WORKSPACE_ROOM_GRAPHICS_CONTENT_H_
WindowContent for displaying room graphics blocks.
float GetPreferredWidth() const override
Get preferred width for this panel (optional)
std::array< uint8_t, 16 > preview_block_ids_
void RefreshSheetPreviews(const zelda3::Room &room)
std::string GetEditorCategory() const override
Editor category this panel belongs to.
std::string GetIcon() const override
Material Design icon for this panel.
void SetAssignmentCallback(AssignmentCallback callback)
std::string GetId() const override
Unique identifier for this panel.
std::map< int, gfx::Bitmap > picker_previews_
void SetUsageCallback(UsageCallback callback)
void DrawAssignmentControls(const zelda3::Room &room)
void DrawAssignmentPicker(const zelda3::Room &room)
void Draw(bool *p_open) override
Draw the panel content.
std::function< absl::StatusOr< zelda3::RoomsetUsageReport >(int)> UsageCallback
gui::AdaptiveSheetScaleMode sheet_scale_mode_
int GetPriority() const override
Get display priority for menu ordering.
RoomGraphicsContent(int *current_room_id, DungeonRoomStore *rooms, gfx::IRenderer *renderer=nullptr)
std::function< absl::Status(int, int, int)> AssignmentCallback
void SetCurrentPaletteGroup(const gfx::PaletteGroup &group)
Set the current palette group for graphics rendering.
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
std::array< gfx::Bitmap, 16 > sheet_previews_
std::string GetWorkflowGroup() const override
Optional workflow group for hack-centric actions.
std::array< SheetPreviewMetadata, 16 > sheet_preview_metadata_
Base interface for all logical window content components.
Defines an abstract interface for all rendering operations.
Definition irenderer.h:60
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:64
Which graphics sheets exist, which tables use them, and which 16x16 blocks are free.
#define ICON_MD_IMAGE
Definition icons.h:982
Represents a group of palettes.