Manages ROM and project persistence state. More...
#include <rom_lifecycle_manager.h>
Classes | |
| struct | Dependencies |
Public Types | |
| enum class | PotItemSaveDecision { kSaveWithPotItems , kSaveWithoutPotItems , kCancel } |
Public Member Functions | |
| RomLifecycleManager ()=default | |
| RomLifecycleManager (Dependencies deps) | |
| ~RomLifecycleManager ()=default | |
| void | Initialize (Dependencies deps) |
| void | UpdateCurrentRomHash (Rom *rom) |
| Recompute the hash of the current ROM. | |
| const std::string & | current_rom_hash () const |
| Get the cached ROM hash string. | |
| bool | IsRomHashMismatch () const |
| Check whether the ROM hash mismatches the project's expected hash. | |
| absl::Status | CheckRomWritePolicy (Rom *rom) |
| Enforce project write policy; may set pending_rom_write_confirm. | |
| absl::Status | CheckOracleRomSafetyPreSave (Rom *rom) |
| Run Oracle-specific ROM safety preflight before saving. | |
| bool | IsRomWriteConfirmPending () const |
| void | ConfirmRomWrite () |
| void | CancelRomWriteConfirm () |
| const std::vector< core::WriteConflict > & | pending_write_conflicts () const |
| bool | ShouldBypassWriteConflict () const |
| void | BypassWriteConflictOnce () |
| void | ClearPendingWriteConflicts () |
| void | SetPendingWriteConflicts (std::vector< core::WriteConflict > conflicts) |
| void | ConsumeWriteConflictBypass () |
| bool | HasPendingPotItemSaveConfirmation () const |
| int | pending_pot_item_unloaded_rooms () const |
| int | pending_pot_item_total_rooms () const |
| void | SetPotItemConfirmPending (int unloaded_rooms, int total_rooms) |
| Set pot-item confirmation pending (called by SaveRom when needed). | |
| PotItemSaveDecision | ResolvePotItemSaveConfirmation (PotItemSaveDecision decision) |
| bool | ShouldBypassPotItemConfirm () const |
| bool | ShouldSuppressPotItemSave () const |
| void | ClearPotItemBypass () |
| std::vector< RomFileManager::BackupEntry > | GetRomBackups (Rom *rom) const |
| absl::Status | PruneRomBackups (Rom *rom) |
| void | ApplyDefaultBackupPolicy (bool enabled, const std::string &folder, int retention_count, bool keep_daily, int keep_daily_days) |
| Apply default backup policy from user settings. | |
Private Attributes | |
| RomFileManager * | rom_file_manager_ = nullptr |
| SessionCoordinator * | session_coordinator_ = nullptr |
| ToastManager * | toast_manager_ = nullptr |
| PopupManager * | popup_manager_ = nullptr |
| project::YazeProject * | project_ = nullptr |
| std::string | current_rom_hash_ |
| bool | pending_rom_write_confirm_ = false |
| bool | bypass_rom_write_confirm_once_ = false |
| bool | pending_pot_item_save_confirm_ = false |
| int | pending_pot_item_unloaded_rooms_ = 0 |
| int | pending_pot_item_total_rooms_ = 0 |
| bool | bypass_pot_item_confirm_once_ = false |
| bool | suppress_pot_item_save_once_ = false |
| std::vector< core::WriteConflict > | pending_write_conflicts_ |
| bool | bypass_write_conflict_once_ = false |
Manages ROM and project persistence state.
Extracted from EditorManager to consolidate all ROM/project save/load state management, write-policy enforcement, backup management, and confirmation dialogs into a single component.
EditorManager delegates ROM operations to this class and receives results/errors back. The manager does NOT own the ROM or project objects - those live in the session hierarchy.
Definition at line 31 of file rom_lifecycle_manager.h.
|
strong |
| Enumerator | |
|---|---|
| kSaveWithPotItems | |
| kSaveWithoutPotItems | |
| kCancel | |
Definition at line 33 of file rom_lifecycle_manager.h.
|
default |
|
explicit |
Definition at line 38 of file rom_lifecycle_manager.cc.
|
default |
| void yaze::editor::RomLifecycleManager::Initialize | ( | Dependencies | deps | ) |
Late-initialize dependencies (for when deps aren't available at construction time, e.g. EditorManager's member initialization).
Definition at line 45 of file rom_lifecycle_manager.cc.
References yaze::editor::RomLifecycleManager::Dependencies::popup_manager, popup_manager_, yaze::editor::RomLifecycleManager::Dependencies::project, project_, yaze::editor::RomLifecycleManager::Dependencies::rom_file_manager, rom_file_manager_, yaze::editor::RomLifecycleManager::Dependencies::session_coordinator, session_coordinator_, yaze::editor::RomLifecycleManager::Dependencies::toast_manager, and toast_manager_.
Referenced by yaze::editor::EditorManager::InitializeSubsystems().
| void yaze::editor::RomLifecycleManager::UpdateCurrentRomHash | ( | Rom * | rom | ) |
Recompute the hash of the current ROM.
Definition at line 57 of file rom_lifecycle_manager.cc.
References yaze::util::ComputeRomHash(), current_rom_hash_, yaze::Rom::data(), yaze::Rom::is_loaded(), and yaze::Rom::size().
Referenced by yaze::editor::EditorManager::UpdateCurrentRomHash().

|
inline |
Get the cached ROM hash string.
Definition at line 63 of file rom_lifecycle_manager.h.
References current_rom_hash_.
Referenced by yaze::editor::EditorManager::GetCurrentRomHash().
| bool yaze::editor::RomLifecycleManager::IsRomHashMismatch | ( | ) | const |
Check whether the ROM hash mismatches the project's expected hash.
Definition at line 65 of file rom_lifecycle_manager.cc.
References current_rom_hash_, yaze::project::RomMetadata::expected_hash, project_, yaze::project::YazeProject::project_opened(), and yaze::project::YazeProject::rom_metadata.
Referenced by yaze::editor::EditorManager::IsRomHashMismatch().

| absl::Status yaze::editor::RomLifecycleManager::CheckRomWritePolicy | ( | Rom * | rom | ) |
Enforce project write policy; may set pending_rom_write_confirm.
Definition at line 77 of file rom_lifecycle_manager.cc.
References bypass_rom_write_confirm_once_, current_rom_hash_, yaze::project::RomMetadata::expected_hash, yaze::project::kAllow, yaze::project::kBlock, yaze::editor::kError, yaze::editor::PopupID::kRomWriteConfirm, yaze::editor::kWarning, pending_rom_write_confirm_, popup_manager_, project_, yaze::project::YazeProject::project_opened(), yaze::project::YazeProject::rom_metadata, yaze::editor::PopupManager::Show(), yaze::editor::ToastManager::Show(), toast_manager_, and yaze::project::RomMetadata::write_policy.
Referenced by yaze::editor::EditorManager::CheckRomWritePolicy().

| absl::Status yaze::editor::RomLifecycleManager::CheckOracleRomSafetyPreSave | ( | Rom * | rom | ) |
Run Oracle-specific ROM safety preflight before saving.
Definition at line 119 of file rom_lifecycle_manager.cc.
References yaze::project::YazeProject::hack_manifest, yaze::core::HackManifest::HasProjectRegistry(), yaze::Rom::is_loaded(), yaze::editor::kError, yaze::core::HackManifest::loaded(), yaze::zelda3::OracleRomSafetyPreflightOptions::max_collision_errors, project_, yaze::project::YazeProject::project_opened(), yaze::zelda3::OracleRomSafetyPreflightOptions::require_custom_collision_write_support, yaze::zelda3::OracleRomSafetyPreflightOptions::require_water_fill_reserved_region, yaze::zelda3::RunOracleRomSafetyPreflight(), yaze::editor::ToastManager::Show(), toast_manager_, yaze::zelda3::OracleRomSafetyPreflightOptions::validate_custom_collision_maps, and yaze::zelda3::OracleRomSafetyPreflightOptions::validate_water_fill_table.
Referenced by yaze::editor::EditorManager::CheckOracleRomSafetyPreSave().
|
inline |
Definition at line 78 of file rom_lifecycle_manager.h.
References pending_rom_write_confirm_.
Referenced by yaze::editor::EditorManager::IsRomWriteConfirmPending(), and yaze::editor::EditorManager::SaveRom().
| void yaze::editor::RomLifecycleManager::ConfirmRomWrite | ( | ) |
Definition at line 155 of file rom_lifecycle_manager.cc.
References bypass_rom_write_confirm_once_, and pending_rom_write_confirm_.
Referenced by yaze::editor::EditorManager::ConfirmRomWrite().
| void yaze::editor::RomLifecycleManager::CancelRomWriteConfirm | ( | ) |
Definition at line 160 of file rom_lifecycle_manager.cc.
References bypass_rom_write_confirm_once_, and pending_rom_write_confirm_.
Referenced by yaze::editor::EditorManager::CancelRomWriteConfirm(), and yaze::editor::EditorManager::SaveRom().
|
inline |
Definition at line 86 of file rom_lifecycle_manager.h.
References pending_write_conflicts_.
Referenced by yaze::editor::EditorManager::pending_write_conflicts(), and yaze::editor::EditorManager::SaveRom().
|
inline |
Definition at line 89 of file rom_lifecycle_manager.h.
References bypass_write_conflict_once_.
Referenced by yaze::editor::EditorManager::SaveRom().
|
inline |
Definition at line 90 of file rom_lifecycle_manager.h.
References bypass_write_conflict_once_.
Referenced by yaze::editor::EditorManager::BypassWriteConflictOnce().
|
inline |
Definition at line 91 of file rom_lifecycle_manager.h.
References pending_write_conflicts_.
Referenced by yaze::editor::EditorManager::ClearPendingWriteConflicts().
|
inline |
Definition at line 92 of file rom_lifecycle_manager.h.
References pending_write_conflicts_.
Referenced by yaze::editor::EditorManager::SaveRom().
|
inline |
Definition at line 95 of file rom_lifecycle_manager.h.
References bypass_write_conflict_once_, and pending_write_conflicts_.
Referenced by yaze::editor::EditorManager::SaveRom().
|
inline |
Definition at line 104 of file rom_lifecycle_manager.h.
References pending_pot_item_save_confirm_.
Referenced by yaze::editor::EditorManager::HasPendingPotItemSaveConfirmation(), and yaze::editor::EditorManager::SaveRom().
|
inline |
Definition at line 107 of file rom_lifecycle_manager.h.
References pending_pot_item_unloaded_rooms_.
Referenced by yaze::editor::EditorManager::pending_pot_item_unloaded_rooms(), and yaze::editor::EditorManager::SaveRom().
|
inline |
Definition at line 110 of file rom_lifecycle_manager.h.
References pending_pot_item_total_rooms_.
Referenced by yaze::editor::EditorManager::pending_pot_item_total_rooms().
| void yaze::editor::RomLifecycleManager::SetPotItemConfirmPending | ( | int | unloaded_rooms, |
| int | total_rooms ) |
Set pot-item confirmation pending (called by SaveRom when needed).
Definition at line 169 of file rom_lifecycle_manager.cc.
References pending_pot_item_save_confirm_, pending_pot_item_total_rooms_, and pending_pot_item_unloaded_rooms_.
Referenced by yaze::editor::EditorManager::SaveRom().
| RomLifecycleManager::PotItemSaveDecision yaze::editor::RomLifecycleManager::ResolvePotItemSaveConfirmation | ( | PotItemSaveDecision | decision | ) |
Resolve the pot item confirmation dialog. If decision is kSaveWithPotItems or kSaveWithoutPotItems, the caller should invoke SaveRom() again (with the appropriate bypass).
Definition at line 177 of file rom_lifecycle_manager.cc.
References bypass_pot_item_confirm_once_, kCancel, kSaveWithoutPotItems, pending_pot_item_save_confirm_, pending_pot_item_total_rooms_, pending_pot_item_unloaded_rooms_, and suppress_pot_item_save_once_.
Referenced by yaze::editor::EditorManager::ResolvePotItemSaveConfirmation().
|
inline |
Definition at line 123 of file rom_lifecycle_manager.h.
References bypass_pot_item_confirm_once_.
Referenced by yaze::editor::EditorManager::SaveRom().
|
inline |
Definition at line 126 of file rom_lifecycle_manager.h.
References suppress_pot_item_save_once_.
Referenced by yaze::editor::EditorManager::SaveRom().
|
inline |
Definition at line 129 of file rom_lifecycle_manager.h.
References bypass_pot_item_confirm_once_, and suppress_pot_item_save_once_.
Referenced by yaze::editor::EditorManager::SaveRom().
| std::vector< RomFileManager::BackupEntry > yaze::editor::RomLifecycleManager::GetRomBackups | ( | Rom * | rom | ) | const |
Definition at line 198 of file rom_lifecycle_manager.cc.
References yaze::Rom::filename(), yaze::editor::RomFileManager::ListBackups(), and rom_file_manager_.
Referenced by yaze::editor::EditorManager::GetRomBackups().

| absl::Status yaze::editor::RomLifecycleManager::PruneRomBackups | ( | Rom * | rom | ) |
Definition at line 206 of file rom_lifecycle_manager.cc.
References yaze::Rom::filename(), yaze::editor::RomFileManager::PruneBackups(), and rom_file_manager_.
Referenced by yaze::editor::EditorManager::PruneRomBackups().

| void yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy | ( | bool | enabled, |
| const std::string & | folder, | ||
| int | retention_count, | ||
| bool | keep_daily, | ||
| int | keep_daily_days ) |
Apply default backup policy from user settings.
Definition at line 216 of file rom_lifecycle_manager.cc.
References rom_file_manager_, yaze::editor::RomFileManager::SetBackupBeforeSave(), yaze::editor::RomFileManager::SetBackupFolder(), yaze::editor::RomFileManager::SetBackupKeepDaily(), yaze::editor::RomFileManager::SetBackupKeepDailyDays(), and yaze::editor::RomFileManager::SetBackupRetentionCount().
Referenced by yaze::editor::EditorManager::ApplyDefaultBackupPolicy(), and yaze::editor::EditorManager::SaveRom().
|
private |
Definition at line 148 of file rom_lifecycle_manager.h.
Referenced by ApplyDefaultBackupPolicy(), GetRomBackups(), Initialize(), and PruneRomBackups().
|
private |
Definition at line 149 of file rom_lifecycle_manager.h.
Referenced by Initialize().
|
private |
Definition at line 150 of file rom_lifecycle_manager.h.
Referenced by CheckOracleRomSafetyPreSave(), CheckRomWritePolicy(), and Initialize().
|
private |
Definition at line 151 of file rom_lifecycle_manager.h.
Referenced by CheckRomWritePolicy(), and Initialize().
|
private |
Definition at line 152 of file rom_lifecycle_manager.h.
Referenced by CheckOracleRomSafetyPreSave(), CheckRomWritePolicy(), Initialize(), and IsRomHashMismatch().
|
private |
Definition at line 155 of file rom_lifecycle_manager.h.
Referenced by CheckRomWritePolicy(), current_rom_hash(), IsRomHashMismatch(), and UpdateCurrentRomHash().
|
private |
Definition at line 158 of file rom_lifecycle_manager.h.
Referenced by CancelRomWriteConfirm(), CheckRomWritePolicy(), ConfirmRomWrite(), and IsRomWriteConfirmPending().
|
private |
Definition at line 159 of file rom_lifecycle_manager.h.
Referenced by CancelRomWriteConfirm(), CheckRomWritePolicy(), and ConfirmRomWrite().
|
private |
Definition at line 162 of file rom_lifecycle_manager.h.
Referenced by HasPendingPotItemSaveConfirmation(), ResolvePotItemSaveConfirmation(), and SetPotItemConfirmPending().
|
private |
Definition at line 163 of file rom_lifecycle_manager.h.
Referenced by pending_pot_item_unloaded_rooms(), ResolvePotItemSaveConfirmation(), and SetPotItemConfirmPending().
|
private |
Definition at line 164 of file rom_lifecycle_manager.h.
Referenced by pending_pot_item_total_rooms(), ResolvePotItemSaveConfirmation(), and SetPotItemConfirmPending().
|
private |
Definition at line 165 of file rom_lifecycle_manager.h.
Referenced by ClearPotItemBypass(), ResolvePotItemSaveConfirmation(), and ShouldBypassPotItemConfirm().
|
private |
Definition at line 166 of file rom_lifecycle_manager.h.
Referenced by ClearPotItemBypass(), ResolvePotItemSaveConfirmation(), and ShouldSuppressPotItemSave().
|
private |
Definition at line 169 of file rom_lifecycle_manager.h.
Referenced by ClearPendingWriteConflicts(), ConsumeWriteConflictBypass(), pending_write_conflicts(), and SetPendingWriteConflicts().
|
private |
Definition at line 170 of file rom_lifecycle_manager.h.
Referenced by BypassWriteConflictOnce(), ConsumeWriteConflictBypass(), and ShouldBypassWriteConflict().