33 : session_id_(session_id),
35 game_data_(game_data),
36 user_settings_(user_settings),
37 editor_registry_(editor_registry),
39 auto register_factory = [&](
EditorType type,
auto&& fallback) {
42 fallback = std::forward<decltype(fallback)>(
43 fallback)]()
mutable -> std::unique_ptr<Editor> {
54 [
this]() {
return std::make_unique<AssemblyEditor>(
rom_); });
56 return std::make_unique<DungeonEditorV2>(
rom_);
59 [
this]() {
return std::make_unique<GraphicsEditor>(
rom_); });
61 [
this]() {
return std::make_unique<MusicEditor>(
rom_); });
63 return std::make_unique<OverworldEditor>(
rom_);
66 [
this]() {
return std::make_unique<PaletteEditor>(
rom_); });
68 [
this]() {
return std::make_unique<ScreenEditor>(
rom_); });
70 [
this]() {
return std::make_unique<SpriteEditor>(
rom_); });
72 [
this]() {
return std::make_unique<MessageEditor>(
rom_); });
74 [
this]() {
return std::make_unique<MemoryEditor>(
rom_); });
76 []() {
return std::make_unique<SettingsPanel>(); });
78 []() {
return std::make_unique<PlanningEditor>(); });
86 panel->SetUserSettings(settings);
92 for (
auto& [type, editor] :
editors_) {
100 for (
auto& [type, editor] :
editors_) {
101 editor->SetDependencies(dependencies);
110 for (
auto& [type, editor] :
editors_) {
112 editor->PrepareForSessionTeardown();
126 return it->second.get();
145 auto editor = factory_it->second();
157 dungeon->SetRoomGraphicsOverworldProvider(
162 int slot) -> absl::StatusOr<zelda3::MainGroupUsageReport> {
164 return absl::FailedPreconditionError(
"No loaded graphics session");
167 std::map<int, uint8_t> explicit_main;
170 dungeon->rooms().ForEachLoaded([&](
int id,
const zelda3::Room& room) {
176 rooms, explicit_main,
180 [
this](
int group) -> absl::StatusOr<zelda3::RoomsetUsageReport> {
182 return absl::FailedPreconditionError(
"No loaded graphics session");
185 return dungeon->GetRoomGraphicsUsage(group);
190 if (
auto* graphics =
dynamic_cast<GraphicsEditor*
>(editor.get())) {
191 graphics->SetRoomUsageProvider([
this]() {
197 dungeon->VisitGraphicsUsageRooms([&](
int id,
zelda3::Room& room,
198 const std::string& provenance,
199 bool current,
int entrance_slot) {
201 &room, provenance, current, entrance_slot});
206 graphics->SetMainGraphicsUsageCallback(main_usage);
207 graphics->SetRoomsetGraphicsUsageCallback(roomset_usage);
210 overworld->SetMainGraphicsUsageCallback(main_usage);
211 overworld->SetRoomsetGraphicsUsageCallback(roomset_usage);
214 if (
auto* settings_panel =
static_cast<SettingsPanel*
>(editor.get())) {
219 Editor* editor_ptr = editor.get();
247 if (editor ==
nullptr) {
258 editor->OpenFolder(folder_path);
264 editor->ChangeActiveFile(path);
271 return editor->asar_wrapper();
278 static const std::map<std::string, core::AsarSymbol> kEmpty;
281 return editor->symbols();
289 return editor->LoadedRoomCount();
297 return editor->TotalRoomCount();
302std::vector<std::pair<uint32_t, uint32_t>>
306 return editor->CollectWriteRanges();
316 return diff.ok() && diff->any();
322 return editor->HasPendingGraphicsChanges();
330 return editor->HasPendingScreenChanges();
338 editor->InvalidateRomBackedState();
345 return editor->HasPendingProjectDraftChanges();
353 return editor->PrepareProjectSave();
355 return absl::OkStatus();
361 return &editor->overworld();
404 editors(&rom, &game_data, user_settings, session_id, editor_registry) {}
410 editors(&rom, &game_data, user_settings, session_id, editor_registry) {
421 auto path = std::filesystem::path(
rom.
filename()).lexically_normal();
422 path.make_preferred();
423 const std::string editing_source = preserve_editing_source &&
rom_baseline
434 std::make_unique<std::array<gfx::Bitmap, zelda3::kNumGfxSheets>>(
442 bitmap.set_data(std::vector<uint8_t>(pixels.begin(), pixels.end()));
453 if (arena.gfx_sheets_owner() == &
game_data) {
454 arena.BindGraphicsSheets(
nullptr,
nullptr);
458 arena.RetireBitmap(bitmap);
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Modern C++ wrapper for Asar 65816 assembler integration.
Text editor for modifying assembly code.
DungeonEditorV2 - Simplified dungeon editor using component delegation.
Manages editor types, categories, and lifecycle.
std::unique_ptr< Editor > CreateEditor(EditorType type, Rom *rom) const
Contains a complete set of editors for a single ROM instance.
bool session_teardown_prepared_
std::optional< EditorDependencies > dependencies_
MemoryEditor * GetMemoryEditor() const
void InvalidateScreenRomBackedState()
std::unordered_map< EditorType, std::unique_ptr< Editor > > editors_
DungeonEditorV2 * GetDungeonEditor() const
void OpenAssemblyFolder(const std::string &folder_path) const
MusicEditor * GetMusicEditor() const
ScreenEditor * GetScreenEditor() const
void SetGameData(zelda3::GameData *game_data)
bool HasPendingProjectDraftChanges() const
Editor * GetExistingEditor(EditorType type) const
bool ShouldTrackAsActiveEditor(EditorType type) const
core::AsarWrapper * GetAsarWrapper() const
absl::Status PrepareProjectSave()
void TrackActiveEditor(Editor *editor)
void ChangeActiveAssemblyFile(std::string_view path) const
void ApplyDependencies(const EditorDependencies &dependencies)
const std::map< std::string, core::AsarSymbol > & GetAssemblySymbols() const
void PrepareForSessionTeardown()
EditorSet(Rom *rom=nullptr, zelda3::GameData *game_data=nullptr, UserSettings *user_settings=nullptr, size_t session_id=0, EditorRegistry *editor_registry=nullptr)
Editor * EnsureEditorCreated(EditorType type) const
SpriteEditor * GetSpriteEditor() const
UserSettings * user_settings_
Editor * GetEditor(EditorType type) const
GraphicsEditor * GetGraphicsEditor() const
int LoadedDungeonRoomCount() const
Editor * FindEditor(EditorType type) const
PaletteEditor * GetPaletteEditor() const
bool HasPendingGraphicsChanges() const
bool HasPendingScreenChanges() const
std::unordered_map< EditorType, EditorFactory > editor_factories_
EditorRegistry * editor_registry_
void set_user_settings(UserSettings *settings)
zelda3::Overworld * GetOverworldData() const
MessageEditor * GetMessageEditor() const
int TotalDungeonRoomCount() const
SettingsPanel * GetSettingsPanel() const
std::vector< Editor * > active_editors_
zelda3::GameData * game_data_
OverworldEditor * GetOverworldEditor() const
AssemblyEditor * GetAssemblyEditor() const
std::vector< std::pair< uint32_t, uint32_t > > CollectDungeonWriteRanges() const
Interface for editor classes.
virtual void SetDependencies(const EditorDependencies &deps)
Allows the user to edit graphics sheets from the game or view prototype graphics.
A class for editing music data in a Rom.
Main UI class for editing overworld maps in A Link to the Past.
Allows the user to view and edit in game palettes.
The ScreenEditor class allows the user to edit a variety of screens in the game or create a custom me...
Manages the settings UI displayed in the right sidebar.
Allows the user to edit sprites.
Manages user preferences and settings persistence.
void BindGraphicsSheets(GraphicsSheets *sheets, const void *owner)
static PaletteManager & Get()
Get the singleton instance.
void ReleaseSession(const zelda3::GameData *game_data)
Forget all palette tracking for a closing or reloaded ROM session.
bool HasSheet(uint16_t sheet) const
True when the buffer holds all 4096 bytes of sheet.
absl::Span< const uint8_t > Sheet(uint16_t sheet) const
The sheet's 4096 pixels, or an empty span when it is not held.
uint8_t spriteset() const
uint8_t render_entrance_blockset() const
std::map< int, LiveRoomContext > LiveRoomContexts
Editors are the view controllers for the application.
RomIdentityHashes ComputeRomIdentityHashes(const uint8_t *data, size_t size)
absl::StatusOr< RoomsetUsageReport > DescribeRoomsetUsage(Rom &rom, GameData &game_data, int roomset, const std::map< int, RoomGfxInfo > &rooms, const Overworld *live_overworld)
absl::StatusOr< MainGroupUsageReport > DescribeMainGroupUsage(Rom &rom, GameData &game_data, int group, int slot, const std::map< int, RoomGfxInfo > &rooms, const std::map< int, uint8_t > &explicit_room_main, const Overworld *live_overworld)
absl::StatusOr< GfxGroupDiff > DiffGfxGroups(const Rom &rom, const GameData &data)
std::map< int, RoomGfxInfo > CollectRoomGfx(const Rom &rom)
Unified dependency container for all editor types.
Per-ROM-session UI state shared by all GfxGroupEditor surfaces.
std::unique_ptr< std::array< gfx::Bitmap, zelda3::kNumGfxSheets > > graphics_display_
core::FeatureFlags::Flags feature_flags
void ActivateGraphicsDisplay()
void CaptureRomIdentity(bool preserve_editing_source=false)
bool HasPendingGfxGroupChanges() const
std::optional< RomBaselineIdentity > rom_baseline
void ResetGraphicsDisplay()
zelda3::GameData game_data
void ReloadGraphicsDisplay()
std::string GetDisplayName() const
std::array< gfx::Bitmap, kNumGfxSheets > gfx_bitmaps
GraphicsSheetStore sheet_store