yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
gfx_group_editor.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_GFX_GROUP_EDITOR_H
2#define YAZE_APP_EDITOR_GFX_GROUP_EDITOR_H
3
4#include <array>
5#include <functional>
6#include <map>
7#include <memory>
8#include <optional>
9#include <string>
10
11#include "absl/status/status.h"
17#include "rom/rom.h"
18#include "zelda3/game_data.h"
20
21namespace yaze {
22namespace editor {
23
40 public:
42 absl::Status Update();
43
44 void DrawBlocksetViewer(bool sheet_only = false);
45 void DrawRoomsetViewer();
46 void DrawSpritesetViewer(bool sheet_only = false);
48
49 void SetSelectedBlockset(uint8_t blockset) {
50 Ws().selected_blockset = blockset;
51 }
52 void SetSelectedRoomset(uint8_t roomset) { Ws().selected_roomset = roomset; }
53 void SetSelectedSpriteset(uint8_t spriteset) {
54 Ws().selected_spriteset = spriteset;
55 }
56 void SetRom(Rom* rom);
57 void SetUndoManager(UndoManager* undo) { undo_ = undo; }
59 std::function<absl::StatusOr<zelda3::MainGroupUsageReport>(int, int)>;
61 main_usage_ = std::move(callback);
62 }
63 // Shared main table edit on the host editor's undo stack. Zero is a real
64 // sheet here, unlike zero in a room override (which means inherit).
65 absl::Status EditMainGraphicsSheet(int group, int slot, int sheet);
66 // Roomset entries 0-3 override background slots 3-6. Sheet zero inherits.
67 absl::Status EditRoomsetGraphicsSheet(int group, int entry, int sheet);
69 std::function<absl::StatusOr<zelda3::RoomsetUsageReport>(int)>;
71 roomset_usage_ = std::move(callback);
72 }
74 Rom* rom() const { return rom_; }
75 void SetGameData(zelda3::GameData* data);
77
79
81 void SetHostSurfaceHint(std::string hint) {
82 host_surface_hint_ = std::move(hint);
83 }
84
85 const GfxGroupWorkspaceState& workspace_state() const { return Ws(); }
86
87 private:
89 enum class GroupKind { kMain, kRoomset };
90 absl::Status EditGraphicsSheet(GroupKind kind, int group, int slot,
91 int sheet);
93 void DrawRoomsetUsage();
94 void DrawMainUsage();
95 void DrawSheetPicker();
96 void ResetSheetPicker();
98 Rom* rom = nullptr;
100 uint64_t generation = 0;
101 };
102 std::shared_ptr<AssignmentSession> assignment_session_ =
103 std::make_shared<AssignmentSession>();
104 UndoManager* undo_ = nullptr;
113 bool show_sheet_picker_ = false;
114 std::string assignment_error_;
115 std::map<int, gfx::Bitmap> picker_previews_;
117 gfx::Bitmap& preview);
118
120 const GfxGroupWorkspaceState& Ws() const {
121 return workspace_ ? *workspace_ : fallback_;
122 }
123
126
127 // Individual canvases for each sheet slot to avoid ID conflicts
128 std::array<gui::Canvas, 8> blockset_canvases_;
129 std::array<gui::Canvas, 4> roomset_canvases_;
130 std::array<gui::Canvas, 4> spriteset_canvases_;
131
132 std::array<gfx::Bitmap, 8> blockset_previews_;
133 std::array<gfx::Bitmap, 4> roomset_previews_;
134 std::array<gfx::Bitmap, 4> spriteset_previews_;
135
136 Rom* rom_ = nullptr;
138
139 // "Used by" for the selected spriteset. Area and room data are read
140 // from the ROM buffer on first use and on Refresh.
141 void DrawSpritesetUsage(int id);
142 std::optional<std::map<int, zelda3::OverworldAreaGfxInfo>> usage_areas_;
143 std::optional<std::map<int, zelda3::RoomGfxInfo>> usage_rooms_;
144 const Rom* usage_rom_ = nullptr;
147};
148
149} // namespace editor
150} // namespace yaze
151#endif // YAZE_APP_EDITOR_GFX_GROUP_EDITOR_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:49
Manage graphics group configurations in a Rom.
const GfxGroupWorkspaceState & Ws() const
std::array< gfx::Bitmap, 4 > roomset_previews_
void SetSelectedSpriteset(uint8_t spriteset)
std::function< absl::StatusOr< zelda3::RoomsetUsageReport >(int)> RoomsetUsageCallback
void SetSelectedRoomset(uint8_t roomset)
RoomsetUsageCallback roomset_usage_
absl::Status EditRoomsetGraphicsSheet(int group, int entry, int sheet)
std::array< gui::Canvas, 8 > blockset_canvases_
absl::Status EditGraphicsSheet(GroupKind kind, int group, int slot, int sheet)
zelda3::GameData * game_data() const
std::shared_ptr< AssignmentSession > assignment_session_
void DrawAssignmentControls(GroupKind kind)
std::function< absl::StatusOr< zelda3::MainGroupUsageReport >(int, int)> MainUsageCallback
std::optional< std::map< int, zelda3::OverworldAreaGfxInfo > > usage_areas_
GfxGroupWorkspaceState * workspace_
std::array< gui::Canvas, 4 > roomset_canvases_
void SetRoomsetUsageCallback(RoomsetUsageCallback callback)
void SetMainUsageCallback(MainUsageCallback callback)
std::array< gfx::Bitmap, 4 > spriteset_previews_
absl::Status EditMainGraphicsSheet(int group, int slot, int sheet)
std::map< int, gfx::Bitmap > picker_previews_
GfxGroupWorkspaceState & Ws()
gfx::SnesPalette * current_palette_
std::optional< std::map< int, zelda3::RoomGfxInfo > > usage_rooms_
void SetSelectedBlockset(uint8_t blockset)
GfxGroupWorkspaceState fallback_
void DrawSpritesetViewer(bool sheet_only=false)
std::array< gfx::Bitmap, 8 > blockset_previews_
void SetWorkspaceState(GfxGroupWorkspaceState *state)
void SetUndoManager(UndoManager *undo)
std::array< gui::Canvas, 4 > spriteset_canvases_
void SetHostSurfaceHint(std::string hint)
const GfxGroupWorkspaceState & workspace_state() const
void DrawBlocksetViewer(bool sheet_only=false)
void SetGameData(zelda3::GameData *data)
gfx::Bitmap * PrepareSheetPreview(int sheet_id, gfx::SheetRole role, gfx::Bitmap &preview)
Manages undo/redo stacks for a single editor.
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:70
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Which graphics sheets exist, which tables use them, and which 16x16 blocks are free.
Per-ROM-session UI state shared by all GfxGroupEditor surfaces.