Centralized palette management system. More...
#include <palette_manager.h>

Classes | |
| struct | SaveTransactionSnapshot |
| struct | SessionState |
Public Types | |
| using | ChangeCallback = std::function<void(const PaletteChangeEvent&)> |
Public Member Functions | |
| PaletteManager (const PaletteManager &)=delete | |
| PaletteManager & | operator= (const PaletteManager &)=delete |
| PaletteManager (PaletteManager &&)=delete | |
| PaletteManager & | operator= (PaletteManager &&)=delete |
| void | Initialize (zelda3::GameData *game_data) |
| Initialize the palette manager with GameData. | |
| void | Initialize (Rom *rom) |
| Legacy initialization with ROM (deprecated, use GameData version) | |
| bool | IsInitialized () const |
| Check if manager is initialized. | |
| void | ActivateSession (zelda3::GameData *game_data) |
| Select the palette state for a ROM session without resnapshotting it. | |
| uint64_t | ColorRevision (const zelda3::GameData *game_data) const |
| bool | IsSessionActive (const zelda3::GameData *game_data) const |
| Check whether this exact GameData is the active palette session. | |
| bool | IsManaging (const zelda3::GameData *game_data) const |
| Check whether the manager is bound to this exact GameData and ROM. | |
| void | ReleaseSession (const zelda3::GameData *game_data) |
| Forget all palette tracking for a closing or reloaded ROM session. | |
| void | ResetForTesting () |
| Reset all state for test isolation. | |
| SnesColor | GetColor (const std::string &group_name, int palette_index, int color_index) const |
| Get a color from a palette. | |
| absl::Status | SetColor (const std::string &group_name, int palette_index, int color_index, const SnesColor &new_color) |
| Set a color in a palette (records change for undo) | |
| absl::Status | ApplyExternalChanges (const zelda3::GameData *owner, const std::vector< PaletteColorChange > &changes, const std::function< absl::Status()> &participant) |
| absl::Status | ResetColor (const std::string &group_name, int palette_index, int color_index) |
| Reset a single color to its original ROM value. | |
| absl::Status | ResetPalette (const std::string &group_name, int palette_index) |
| Reset an entire palette to original ROM values. | |
| absl::Status | BeginColorEdit (const std::string &group_name, int palette_index, int color_index, uint64_t caller_id=0) |
| void | CommitColorEdit (uint64_t caller_id=0) |
| void | CancelColorEdit (uint64_t caller_id=0) |
| bool | HasColorEdit (uint64_t caller_id=0) const |
| bool | HasUnsavedChanges () const |
| Check if there are ANY unsaved changes. | |
| bool | HasUnsavedChanges (const zelda3::GameData *game_data) const |
| Check a specific ROM session without changing the active binding. | |
| std::vector< std::string > | GetModifiedGroups () const |
| Get list of modified palette group names. | |
| bool | IsGroupModified (const std::string &group_name) const |
| Check if a specific palette group has modifications. | |
| bool | IsPaletteModified (const std::string &group_name, int palette_index) const |
| Check if a specific palette is modified. | |
| bool | IsColorModified (const std::string &group_name, int palette_index, int color_index) const |
| Check if a specific color is modified. | |
| size_t | GetModifiedColorCount () const |
| Get count of modified colors across all groups. | |
| size_t | GetModifiedColorCount (const zelda3::GameData *game_data) const |
| Count modified colors for a specific ROM session. | |
| absl::StatusOr< std::vector< std::pair< uint32_t, uint32_t > > > | GetModifiedColorWriteRanges () const |
| Get exact, coalesced half-open ROM ranges for modified colors. Invalid or unbound addresses return an error, never an empty success. | |
| absl::StatusOr< std::vector< std::pair< uint32_t, uint32_t > > > | GetModifiedColorWriteRanges (const zelda3::GameData *game_data) const |
| Get modified-color ranges for a session without activating it. | |
| absl::StatusOr< std::vector< std::pair< uint32_t, uint32_t > > > | GetModifiedGroupColorWriteRanges (const std::string &group_name) const |
| Get exact, coalesced half-open ROM ranges for one modified group. Resolution errors leave the pending changes intact. | |
| absl::Status | SaveGroup (const std::string &group_name) |
| Save a specific palette group to ROM. | |
| absl::Status | SaveAllToRom () |
| Save ALL modified palettes to ROM. | |
| absl::Status | BeginSaveTransaction () |
| void | RollbackSaveTransaction () |
| void | CommitSaveTransaction () |
| void | DiscardGroup (const std::string &group_name) |
| Discard changes for a specific group. | |
| void | DiscardAllChanges () |
| Discard ALL unsaved changes. | |
| absl::Status | ApplyPreviewChanges () |
| Apply preview changes to other editors without saving to ROM. | |
| void | Undo () |
| Undo the most recent change. | |
| void | Redo () |
| Redo the most recently undone change. | |
| bool | CanUndo () const |
| Check if the complete undo entry matches current colors. Conflicting history is retained, but unavailable until values match again. | |
| bool | CanRedo () const |
| Check if the complete redo entry matches current colors. Conflicting history is retained, but unavailable until values match again. | |
| size_t | GetUndoStackSize () const |
| Get size of undo stack. | |
| size_t | GetRedoStackSize () const |
| Get size of redo stack. | |
| void | ClearHistory () |
| Clear undo/redo history. | |
| int | RegisterChangeListener (ChangeCallback callback) |
| Register a callback for palette change events. | |
| void | UnregisterChangeListener (int callback_id) |
| Unregister a change listener. | |
| void | BeginBatch () |
| Begin a batch operation (groups multiple changes into one undo step) | |
| void | EndBatch () |
| End a batch operation. | |
| bool | InBatch () const |
| Check if currently in a batch operation. | |
| SnesColor | GetOriginalColor (const std::string &group_name, int palette_index, int color_index) const |
Static Public Member Functions | |
| static PaletteManager & | Get () |
| Get the singleton instance. | |
Private Member Functions | |
| PaletteManager ()=default | |
| ~PaletteManager ()=default | |
| PaletteGroup * | GetMutableGroup (const std::string &group_name) |
| Helper: Get mutable palette group. | |
| const PaletteGroup * | GetGroup (const std::string &group_name) const |
| Helper: Get const palette group. | |
| void | RecordChanges (std::vector< PaletteColorChange > changes) |
| Helper: Record one undo step (a gesture or an entire batch). | |
| bool | CanReplayHistory (const std::vector< PaletteColorChange > &changes, bool redo) const |
| void | RecordChange (const PaletteColorChange &change) |
| Helper: Record a single-color undo step. | |
| void | NotifyListeners (const PaletteChangeEvent &event) |
| Helper: Notify all listeners of an event. | |
| void | MarkModified (const std::string &group_name, int palette_index, int color_index) |
| Helper: Mark a color as modified. | |
| void | ClearModifiedFlags (const std::string &group_name) |
| Helper: Clear modified flags for a group. | |
| SessionState * | CurrentState () |
| const SessionState * | CurrentState () const |
| const SessionState * | FindState (const zelda3::GameData *game_data) const |
| absl::StatusOr< uint32_t > | ResolveColorAddress (const zelda3::GameData *game_data, const std::string &group_name, int palette_index, int color_index) const |
Private Attributes | |
| zelda3::GameData * | game_data_ = nullptr |
| GameData instance (not owned) - preferred. | |
| Rom * | rom_ = nullptr |
| ROM instance (not owned) - legacy, used when game_data_ is null. | |
| std::unordered_map< const zelda3::GameData *, SessionState > | session_states_ |
| Per-GameData state. RomSession owns the keys and releases them on teardown. | |
| SessionState | unbound_state_ |
| State used only before a GameData session is selected (legacy/tests). | |
| std::unordered_map< int, ChangeCallback > | change_listeners_ |
| Change listeners. | |
| int | next_callback_id_ = 1 |
Static Private Attributes | |
| static constexpr size_t | kMaxUndoHistory = 500 |
Centralized palette management system.
Singleton coordinator for ALL palette editing operations. Provides:
Thread-safety: This class is NOT thread-safe. All operations must be called from the main UI thread.
Definition at line 76 of file palette_manager.h.
| using yaze::gfx::PaletteManager::ChangeCallback = std::function<void(const PaletteChangeEvent&)> |
Definition at line 78 of file palette_manager.h.
|
delete |
|
delete |
|
privatedefault |
|
privatedefault |
|
inlinestatic |
Get the singleton instance.
Definition at line 81 of file palette_manager.h.
Referenced by yaze::gui::PaletteEditorWidget::ApplyDungeonRenderColorEdit(), yaze::editor::PaletteReorderControl::Begin(), yaze::editor::DungeonEditorV2::BeginSaveTransaction(), yaze::editor::PaletteEditor::BeginSaveTransaction(), yaze::editor::PaletteGroupPanel::CanRedo(), yaze::editor::PaletteEditor::CanRedo(), yaze::editor::PaletteGroupPanel::CanUndo(), yaze::editor::PaletteEditor::CanUndo(), yaze::editor::PaletteGroupPanel::ClearHistory(), yaze::editor::DungeonEditorV2::CollectWriteRanges(), yaze::editor::DungeonEditorV2::CommitSaveTransaction(), yaze::editor::PaletteEditor::CommitSaveTransaction(), yaze::editor::DungeonEditorV2::ConfigureStagedGraphicsPreview(), yaze::editor::CreateProjectGraphicsImportAction(), yaze::editor::PaletteGroupPanel::DiscardChanges(), yaze::editor::EditorManager::DiscardPendingRomBackupRestore(), yaze::editor::UsagePreviewView::Draw(), yaze::editor::PaletteEditor::DrawCategorizedPaletteList(), yaze::editor::PaletteGroupPanel::DrawColorPicker(), yaze::editor::PaletteEditor::DrawControlPanel(), yaze::gui::PaletteEditorWidget::DrawDungeonRenderColorPicker(), yaze::editor::ImageImportView::DrawPaletteImport(), yaze::editor::UsagePreviewView::DrawSourcePreview(), yaze::editor::PaletteGroupPanel::DrawToolbar(), yaze::editor::EditorManager::EnsureGameDataLoaded(), yaze::editor::ExecutePalettePixelPlan(), yaze::editor::PaletteGroupPanel::GetOriginalColor(), yaze::editor::DungeonEditorV2::HandleArenaPaletteChanged(), yaze::editor::EditorManager::HandleSessionClosed(), yaze::editor::EditorManager::HandleSessionCreated(), yaze::editor::EditorManager::HandleSessionSwitched(), yaze::editor::PaletteGroupPanel::HasUnsavedChanges(), yaze::editor::PaletteGroupPanel::ImportFromClipboard(), yaze::editor::PaletteGroupPanel::ImportFromJson(), yaze::editor::PaletteGroupPanel::IsColorModified(), yaze::editor::PaletteGroupPanel::IsManagedSession(), yaze::editor::PaletteGroupPanel::IsPaletteModified(), yaze::editor::SessionCoordinator::IsSessionModified(), yaze::editor::DungeonEditorV2::Load(), yaze::editor::OverworldEditor::Load(), yaze::editor::PaletteEditor::Load(), yaze::editor::EditorManager::LoadAssets(), yaze::editor::EditorManager::PendingPaletteColorCountForSession(), yaze::editor::PaletteGroupPanel::Redo(), yaze::editor::PaletteEditor::Redo(), yaze::editor::RefreshGraphicsPreviewPalettes(), yaze::editor::SpriteEditor::RefreshSpritePreviewGraphics(), yaze::editor::EditorManager::ReplaceActiveSessionRom(), yaze::editor::PaletteGroupPanel::ResetColor(), yaze::editor::PaletteGroupPanel::ResetPalette(), yaze::editor::DungeonEditorV2::RollbackSaveTransaction(), yaze::editor::PaletteEditor::RollbackSaveTransaction(), yaze::editor::DungeonEditorV2::Save(), yaze::editor::PaletteEditor::Save(), yaze::editor::EditorManager::SaveRomInternal(), yaze::editor::DungeonEditorV2::SaveRoomImpl(), yaze::editor::PaletteGroupPanel::SaveToRom(), yaze::editor::EditorManager::SessionHasPendingRomWork(), yaze::editor::PaletteGroupPanel::SetColor(), yaze::editor::UsagePreviewView::SharedUsesHash(), yaze::editor::PaletteReorderControl::SourceChanged(), yaze::editor::PaletteGroupPanel::Undo(), yaze::editor::PaletteEditor::Undo(), and yaze::editor::RomSession::~RomSession().
|
delete |
|
delete |
| void yaze::gfx::PaletteManager::Initialize | ( | zelda3::GameData * | game_data | ) |
Initialize the palette manager with GameData.
| game_data | Pointer to GameData instance (must outlive PaletteManager) |
Definition at line 86 of file palette_manager.cc.
References ActivateSession(), CurrentState(), game_data_, yaze::gfx::PaletteGroupMap::get_group(), and yaze::zelda3::GameData::palette_groups.
Referenced by yaze::editor::EditorManager::EnsureGameDataLoaded(), yaze::editor::DungeonEditorV2::Load(), yaze::editor::PaletteEditor::Load(), and yaze::editor::EditorManager::LoadAssets().

| void yaze::gfx::PaletteManager::Initialize | ( | Rom * | rom | ) |
Legacy initialization with ROM (deprecated, use GameData version)
| rom | Pointer to ROM instance (must outlive PaletteManager) |
Definition at line 148 of file palette_manager.cc.
References game_data_, rom_, and unbound_state_.
| bool yaze::gfx::PaletteManager::IsInitialized | ( | ) | const |
Check if manager is initialized.
Definition at line 64 of file palette_manager.cc.
References FindState(), game_data_, yaze::zelda3::GameData::rom(), and rom_.
Referenced by ApplyExternalChanges(), ApplyPreviewChanges(), BeginColorEdit(), BeginSaveTransaction(), DiscardAllChanges(), DiscardGroup(), GetGroup(), GetMutableGroup(), IsManaging(), ResetPalette(), SaveAllToRom(), SaveGroup(), and SetColor().

| void yaze::gfx::PaletteManager::ActivateSession | ( | zelda3::GameData * | game_data | ) |
Select the palette state for a ROM session without resnapshotting it.
Session activation may happen before GameData assets are loaded. Initialize() creates the original-palette snapshot once those assets are available.
Definition at line 78 of file palette_manager.cc.
References game_data_, yaze::zelda3::GameData::rom(), rom_, and session_states_.
Referenced by yaze::editor::EditorManager::HandleSessionClosed(), yaze::editor::EditorManager::HandleSessionCreated(), yaze::editor::EditorManager::HandleSessionSwitched(), Initialize(), and yaze::editor::EditorManager::ReplaceActiveSessionRom().

| uint64_t yaze::gfx::PaletteManager::ColorRevision | ( | const zelda3::GameData * | game_data | ) | const |
Definition at line 72 of file palette_manager.cc.
References FindState().
Referenced by yaze::editor::PaletteReorderControl::Begin(), yaze::editor::DungeonEditorV2::ConfigureStagedGraphicsPreview(), yaze::editor::UsagePreviewView::Draw(), yaze::editor::UsagePreviewView::DrawSourcePreview(), yaze::editor::SpriteEditor::RefreshSpritePreviewGraphics(), and yaze::editor::PaletteReorderControl::SourceChanged().

| bool yaze::gfx::PaletteManager::IsSessionActive | ( | const zelda3::GameData * | game_data | ) | const |
Check whether this exact GameData is the active palette session.
Unlike IsManaging(), this may be true before lazy-loaded palette assets have been initialized.
Definition at line 128 of file palette_manager.cc.
References game_data_, yaze::zelda3::GameData::rom(), and rom_.
Referenced by IsManaging().

| bool yaze::gfx::PaletteManager::IsManaging | ( | const zelda3::GameData * | game_data | ) | const |
Check whether the manager is bound to this exact GameData and ROM.
Definition at line 133 of file palette_manager.cc.
References IsInitialized(), and IsSessionActive().
Referenced by ApplyExternalChanges(), yaze::editor::CreateProjectGraphicsImportAction(), and yaze::editor::PaletteGroupPanel::IsManagedSession().

| void yaze::gfx::PaletteManager::ReleaseSession | ( | const zelda3::GameData * | game_data | ) |
Forget all palette tracking for a closing or reloaded ROM session.
Definition at line 137 of file palette_manager.cc.
References game_data_, rom_, and session_states_.
Referenced by yaze::editor::EditorManager::LoadAssets(), yaze::editor::EditorManager::ReplaceActiveSessionRom(), and yaze::editor::RomSession::~RomSession().
| void yaze::gfx::PaletteManager::ResetForTesting | ( | ) |
Reset all state for test isolation.
Definition at line 159 of file palette_manager.cc.
References change_listeners_, game_data_, next_callback_id_, rom_, session_states_, and unbound_state_.
| SnesColor yaze::gfx::PaletteManager::GetColor | ( | const std::string & | group_name, |
| int | palette_index, | ||
| int | color_index ) const |
Get a color from a palette.
| group_name | Palette group name |
| palette_index | Palette index within group |
| color_index | Color index within palette |
Definition at line 170 of file palette_manager.cc.
References GetGroup().
Referenced by yaze::gui::PaletteEditorWidget::DrawDungeonRenderColorPicker().

| absl::Status yaze::gfx::PaletteManager::SetColor | ( | const std::string & | group_name, |
| int | palette_index, | ||
| int | color_index, | ||
| const SnesColor & | new_color ) |
Set a color in a palette (records change for undo)
| group_name | Palette group name |
| palette_index | Palette index within group |
| color_index | Color index within palette |
| new_color | The new color value |
Definition at line 185 of file palette_manager.cc.
References CommitColorEdit(), CurrentState(), GetMutableGroup(), InBatch(), IsInitialized(), yaze::gfx::PaletteChangeEvent::kColorChanged, MarkModified(), NotifyListeners(), RecordChange(), and yaze::gfx::SnesColor::snes().
Referenced by ResetColor(), and yaze::editor::PaletteGroupPanel::SetColor().
| absl::Status yaze::gfx::PaletteManager::ApplyExternalChanges | ( | const zelda3::GameData * | owner, |
| const std::vector< PaletteColorChange > & | changes, | ||
| const std::function< absl::Status()> & | participant ) |
Definition at line 244 of file palette_manager.cc.
References CurrentState(), GetMutableGroup(), IsInitialized(), IsManaging(), yaze::gfx::PaletteChangeEvent::kColorChanged, MarkModified(), and NotifyListeners().
Referenced by yaze::editor::ExecutePalettePixelPlan().
| absl::Status yaze::gfx::PaletteManager::ResetColor | ( | const std::string & | group_name, |
| int | palette_index, | ||
| int | color_index ) |
Reset a single color to its original ROM value.
Definition at line 303 of file palette_manager.cc.
References GetOriginalColor(), and SetColor().
Referenced by yaze::editor::PaletteGroupPanel::ResetColor().

| absl::Status yaze::gfx::PaletteManager::ResetPalette | ( | const std::string & | group_name, |
| int | palette_index ) |
Reset an entire palette to original ROM values.
Definition at line 309 of file palette_manager.cc.
References CommitColorEdit(), CurrentState(), GetMutableGroup(), IsInitialized(), yaze::gfx::PaletteChangeEvent::kPaletteReset, and NotifyListeners().
Referenced by yaze::editor::PaletteGroupPanel::ResetPalette().
| absl::Status yaze::gfx::PaletteManager::BeginColorEdit | ( | const std::string & | group_name, |
| int | palette_index, | ||
| int | color_index, | ||
| uint64_t | caller_id = 0 ) |
Definition at line 356 of file palette_manager.cc.
References yaze::gfx::PaletteManager::SessionState::color_edit, yaze::gfx::PaletteManager::SessionState::color_edit_caller, CommitColorEdit(), CurrentState(), GetGroup(), InBatch(), and IsInitialized().
| void yaze::gfx::PaletteManager::CommitColorEdit | ( | uint64_t | caller_id = 0 | ) |
Definition at line 377 of file palette_manager.cc.
References CurrentState(), HasColorEdit(), and RecordChange().
Referenced by BeginBatch(), BeginColorEdit(), BeginSaveTransaction(), ClearHistory(), yaze::editor::EditorManager::HandleSessionSwitched(), Redo(), ResetPalette(), SaveGroup(), SetColor(), and Undo().

| void yaze::gfx::PaletteManager::CancelColorEdit | ( | uint64_t | caller_id = 0 | ) |
Definition at line 389 of file palette_manager.cc.
References CurrentState(), GetMutableGroup(), HasColorEdit(), yaze::gfx::PaletteChangeEvent::kColorChanged, MarkModified(), and NotifyListeners().
Referenced by DiscardGroup().
| bool yaze::gfx::PaletteManager::HasColorEdit | ( | uint64_t | caller_id = 0 | ) | const |
Definition at line 410 of file palette_manager.cc.
References CurrentState().
Referenced by CancelColorEdit(), CommitColorEdit(), and DiscardGroup().

| bool yaze::gfx::PaletteManager::HasUnsavedChanges | ( | ) | const |
Check if there are ANY unsaved changes.
Definition at line 418 of file palette_manager.cc.
References CurrentState(), and yaze::gfx::PaletteManager::SessionState::modified_palettes.
Referenced by yaze::editor::EditorManager::SessionHasPendingRomWork().

| bool yaze::gfx::PaletteManager::HasUnsavedChanges | ( | const zelda3::GameData * | game_data | ) | const |
Check a specific ROM session without changing the active binding.
Definition at line 422 of file palette_manager.cc.
References FindState().

| std::vector< std::string > yaze::gfx::PaletteManager::GetModifiedGroups | ( | ) | const |
Get list of modified palette group names.
Definition at line 428 of file palette_manager.cc.
References CurrentState(), and yaze::gfx::PaletteManager::SessionState::modified_palettes.
Referenced by ApplyPreviewChanges(), DiscardAllChanges(), and SaveAllToRom().

| bool yaze::gfx::PaletteManager::IsGroupModified | ( | const std::string & | group_name | ) | const |
Check if a specific palette group has modifications.
Definition at line 436 of file palette_manager.cc.
References CurrentState(), and yaze::gfx::PaletteManager::SessionState::modified_palettes.
Referenced by yaze::editor::PaletteGroupPanel::DrawToolbar(), and yaze::editor::PaletteGroupPanel::HasUnsavedChanges().

| bool yaze::gfx::PaletteManager::IsPaletteModified | ( | const std::string & | group_name, |
| int | palette_index ) const |
Check if a specific palette is modified.
Definition at line 441 of file palette_manager.cc.
References CurrentState(), and yaze::gfx::PaletteManager::SessionState::modified_palettes.
Referenced by yaze::editor::PaletteGroupPanel::IsPaletteModified().

| bool yaze::gfx::PaletteManager::IsColorModified | ( | const std::string & | group_name, |
| int | palette_index, | ||
| int | color_index ) const |
Check if a specific color is modified.
Definition at line 450 of file palette_manager.cc.
References CurrentState(), and yaze::gfx::PaletteManager::SessionState::modified_colors.
Referenced by yaze::editor::PaletteGroupPanel::IsColorModified().

| size_t yaze::gfx::PaletteManager::GetModifiedColorCount | ( | ) | const |
Get count of modified colors across all groups.
Definition at line 465 of file palette_manager.cc.
References game_data_, and GetModifiedColorCount().
Referenced by GetModifiedColorCount(), GetModifiedColorWriteRanges(), and yaze::editor::EditorManager::PendingPaletteColorCountForSession().

| size_t yaze::gfx::PaletteManager::GetModifiedColorCount | ( | const zelda3::GameData * | game_data | ) | const |
Count modified colors for a specific ROM session.
Definition at line 469 of file palette_manager.cc.
References FindState().

| absl::StatusOr< std::vector< std::pair< uint32_t, uint32_t > > > yaze::gfx::PaletteManager::GetModifiedColorWriteRanges | ( | ) | const |
Get exact, coalesced half-open ROM ranges for modified colors. Invalid or unbound addresses return an error, never an empty success.
Definition at line 532 of file palette_manager.cc.
References game_data_, and GetModifiedColorWriteRanges().
Referenced by GetModifiedColorWriteRanges(), SaveAllToRom(), and yaze::editor::anonymous_namespace{dungeon_editor_v2_persistence.cc}::ValidatePaletteManifestConflicts().

| absl::StatusOr< std::vector< std::pair< uint32_t, uint32_t > > > yaze::gfx::PaletteManager::GetModifiedColorWriteRanges | ( | const zelda3::GameData * | game_data | ) | const |
Get modified-color ranges for a session without activating it.
Definition at line 537 of file palette_manager.cc.
References ASSIGN_OR_RETURN, FindState(), GetModifiedColorCount(), and ResolveColorAddress().

| absl::StatusOr< std::vector< std::pair< uint32_t, uint32_t > > > yaze::gfx::PaletteManager::GetModifiedGroupColorWriteRanges | ( | const std::string & | group_name | ) | const |
Get exact, coalesced half-open ROM ranges for one modified group. Resolution errors leave the pending changes intact.
The active palette session is used. Callers must verify session ownership before using these ranges to authorize a save.
Definition at line 561 of file palette_manager.cc.
References ASSIGN_OR_RETURN, CurrentState(), game_data_, and ResolveColorAddress().

| absl::Status yaze::gfx::PaletteManager::SaveGroup | ( | const std::string & | group_name | ) |
Save a specific palette group to ROM.
Definition at line 583 of file palette_manager.cc.
References ASSIGN_OR_RETURN, ClearModifiedFlags(), CommitColorEdit(), CurrentState(), game_data_, yaze::gfx::Arena::Get(), GetMutableGroup(), IsInitialized(), yaze::gfx::PaletteChangeEvent::kGroupSaved, yaze::gfx::PaletteManager::SessionState::modified_colors, yaze::gfx::PaletteManager::SessionState::modified_palettes, NotifyListeners(), yaze::gfx::Arena::NotifyPaletteModified(), yaze::gfx::PaletteManager::SessionState::original_palettes, ResolveColorAddress(), RETURN_IF_ERROR, yaze::zelda3::GameData::rom(), rom_, yaze::Rom::set_dirty(), and yaze::Rom::WriteShort().
Referenced by SaveAllToRom().
| absl::Status yaze::gfx::PaletteManager::SaveAllToRom | ( | ) |
Save ALL modified palettes to ROM.
Definition at line 657 of file palette_manager.cc.
References GetModifiedColorWriteRanges(), GetModifiedGroups(), IsInitialized(), yaze::gfx::PaletteChangeEvent::kAllSaved, NotifyListeners(), RETURN_IF_ERROR, and SaveGroup().
| absl::Status yaze::gfx::PaletteManager::BeginSaveTransaction | ( | ) |
Definition at line 678 of file palette_manager.cc.
References CommitColorEdit(), CurrentState(), IsInitialized(), and yaze::gfx::PaletteManager::SaveTransactionSnapshot::original_palettes.

| void yaze::gfx::PaletteManager::RollbackSaveTransaction | ( | ) |
Definition at line 695 of file palette_manager.cc.
References CurrentState().
Referenced by yaze::editor::DungeonEditorV2::RollbackSaveTransaction(), and yaze::editor::PaletteEditor::RollbackSaveTransaction().

| void yaze::gfx::PaletteManager::CommitSaveTransaction | ( | ) |
Definition at line 709 of file palette_manager.cc.
References CurrentState(), and yaze::gfx::PaletteManager::SessionState::save_transaction_snapshot.
Referenced by yaze::editor::DungeonEditorV2::CommitSaveTransaction(), and yaze::editor::PaletteEditor::CommitSaveTransaction().

| void yaze::gfx::PaletteManager::DiscardGroup | ( | const std::string & | group_name | ) |
Discard changes for a specific group.
Definition at line 738 of file palette_manager.cc.
References CancelColorEdit(), ClearModifiedFlags(), CurrentState(), GetMutableGroup(), HasColorEdit(), IsInitialized(), yaze::gfx::PaletteChangeEvent::kGroupDiscarded, yaze::gfx::PaletteManager::SessionState::modified_palettes, NotifyListeners(), and yaze::gfx::PaletteManager::SessionState::original_palettes.
Referenced by DiscardAllChanges(), and yaze::editor::PaletteGroupPanel::DiscardChanges().
| void yaze::gfx::PaletteManager::DiscardAllChanges | ( | ) |
Discard ALL unsaved changes.
Definition at line 776 of file palette_manager.cc.
References ClearHistory(), DiscardGroup(), GetModifiedGroups(), IsInitialized(), yaze::gfx::PaletteChangeEvent::kAllDiscarded, and NotifyListeners().
| absl::Status yaze::gfx::PaletteManager::ApplyPreviewChanges | ( | ) |
Apply preview changes to other editors without saving to ROM.
This triggers bitmap propagation notification so other editors can refresh their visuals with the modified palettes. Use this for "live preview" functionality before committing to ROM.
Definition at line 713 of file palette_manager.cc.
References yaze::gfx::PaletteManager::SessionState::color_revision, CurrentState(), yaze::gfx::Arena::Get(), GetModifiedGroups(), IsInitialized(), yaze::gfx::PaletteChangeEvent::kAllSaved, NotifyListeners(), and yaze::gfx::Arena::NotifyPaletteModified().
| void yaze::gfx::PaletteManager::Undo | ( | ) |
Undo the most recent change.
Definition at line 796 of file palette_manager.cc.
References CanUndo(), CommitColorEdit(), CurrentState(), game_data_, GetMutableGroup(), yaze::gfx::PaletteChangeEvent::kColorChanged, MarkModified(), NotifyListeners(), and rom_.
Referenced by yaze::editor::PaletteGroupPanel::Undo(), and yaze::editor::PaletteEditor::Undo().
| void yaze::gfx::PaletteManager::Redo | ( | ) |
Redo the most recently undone change.
Definition at line 834 of file palette_manager.cc.
References CanRedo(), CommitColorEdit(), CurrentState(), game_data_, GetMutableGroup(), yaze::gfx::PaletteChangeEvent::kColorChanged, MarkModified(), NotifyListeners(), and rom_.
Referenced by yaze::editor::PaletteGroupPanel::Redo(), and yaze::editor::PaletteEditor::Redo().
| bool yaze::gfx::PaletteManager::CanUndo | ( | ) | const |
Check if the complete undo entry matches current colors. Conflicting history is retained, but unavailable until values match again.
Definition at line 875 of file palette_manager.cc.
References CanReplayHistory(), and CurrentState().
Referenced by yaze::editor::PaletteGroupPanel::CanUndo(), yaze::editor::PaletteGroupPanel::DrawToolbar(), and Undo().

| bool yaze::gfx::PaletteManager::CanRedo | ( | ) | const |
Check if the complete redo entry matches current colors. Conflicting history is retained, but unavailable until values match again.
Definition at line 887 of file palette_manager.cc.
References CanReplayHistory(), and CurrentState().
Referenced by yaze::editor::PaletteGroupPanel::CanRedo(), yaze::editor::PaletteGroupPanel::DrawToolbar(), and Redo().

| size_t yaze::gfx::PaletteManager::GetUndoStackSize | ( | ) | const |
Get size of undo stack.
Definition at line 922 of file palette_manager.cc.
References CurrentState(), and yaze::gfx::PaletteManager::SessionState::undo_stack.

| size_t yaze::gfx::PaletteManager::GetRedoStackSize | ( | ) | const |
Get size of redo stack.
Definition at line 926 of file palette_manager.cc.
References CurrentState(), and yaze::gfx::PaletteManager::SessionState::redo_stack.

| void yaze::gfx::PaletteManager::ClearHistory | ( | ) |
Clear undo/redo history.
Definition at line 869 of file palette_manager.cc.
References CommitColorEdit(), CurrentState(), yaze::gfx::PaletteManager::SessionState::redo_stack, and yaze::gfx::PaletteManager::SessionState::undo_stack.
Referenced by yaze::editor::PaletteGroupPanel::ClearHistory(), and DiscardAllChanges().

| int yaze::gfx::PaletteManager::RegisterChangeListener | ( | ChangeCallback | callback | ) |
Register a callback for palette change events.
Definition at line 932 of file palette_manager.cc.
References change_listeners_, and next_callback_id_.
| void yaze::gfx::PaletteManager::UnregisterChangeListener | ( | int | callback_id | ) |
Unregister a change listener.
Definition at line 938 of file palette_manager.cc.
References change_listeners_.
| void yaze::gfx::PaletteManager::BeginBatch | ( | ) |
Begin a batch operation (groups multiple changes into one undo step)
Definition at line 944 of file palette_manager.cc.
References yaze::gfx::PaletteManager::SessionState::batch_changes, yaze::gfx::PaletteManager::SessionState::batch_depth, CommitColorEdit(), and CurrentState().

| void yaze::gfx::PaletteManager::EndBatch | ( | ) |
End a batch operation.
Definition at line 952 of file palette_manager.cc.
References yaze::gfx::PaletteManager::SessionState::batch_depth, yaze::gfx::PaletteColorChange::color_index, CurrentState(), game_data_, yaze::gfx::PaletteColorChange::group_name, yaze::gfx::PaletteChangeEvent::kColorChanged, NotifyListeners(), yaze::gfx::PaletteColorChange::palette_index, RecordChanges(), and rom_.

| bool yaze::gfx::PaletteManager::InBatch | ( | ) | const |
Check if currently in a batch operation.
Definition at line 1001 of file palette_manager.cc.
References yaze::gfx::PaletteManager::SessionState::batch_depth, and CurrentState().
Referenced by BeginColorEdit(), and SetColor().

| SnesColor yaze::gfx::PaletteManager::GetOriginalColor | ( | const std::string & | group_name, |
| int | palette_index, | ||
| int | color_index ) const |
Definition at line 1037 of file palette_manager.cc.
References CurrentState().
Referenced by yaze::editor::PaletteGroupPanel::GetOriginalColor(), and ResetColor().

|
private |
Helper: Get mutable palette group.
Definition at line 1007 of file palette_manager.cc.
References game_data_, yaze::gfx::PaletteGroupMap::get_group(), IsInitialized(), and yaze::zelda3::GameData::palette_groups.
Referenced by ApplyExternalChanges(), CancelColorEdit(), DiscardGroup(), Redo(), ResetPalette(), SaveGroup(), SetColor(), and Undo().

|
private |
Helper: Get const palette group.
Definition at line 1021 of file palette_manager.cc.
References game_data_, IsInitialized(), and yaze::zelda3::GameData::palette_groups.
Referenced by BeginColorEdit(), CanReplayHistory(), GetColor(), and MarkModified().

|
private |
Helper: Record one undo step (a gesture or an entire batch).
Definition at line 1059 of file palette_manager.cc.
References CurrentState(), kMaxUndoHistory, yaze::gfx::PaletteManager::SessionState::redo_stack, and yaze::gfx::PaletteManager::SessionState::undo_stack.
Referenced by EndBatch(), and RecordChange().

|
private |
Definition at line 896 of file palette_manager.cc.
References GetGroup().
Referenced by CanRedo(), and CanUndo().

|
private |
Helper: Record a single-color undo step.
Definition at line 1055 of file palette_manager.cc.
References RecordChanges().
Referenced by CommitColorEdit(), and SetColor().

|
private |
Helper: Notify all listeners of an event.
Definition at line 1074 of file palette_manager.cc.
References change_listeners_, yaze::gfx::PaletteManager::SessionState::color_revision, CurrentState(), game_data_, yaze::gfx::Arena::Get(), yaze::gfx::PaletteChangeEvent::group_name, yaze::gfx::PaletteChangeEvent::kColorChanged, yaze::gfx::PaletteChangeEvent::kGroupDiscarded, yaze::gfx::PaletteChangeEvent::kPaletteReset, yaze::gfx::Arena::NotifyPaletteModified(), yaze::gfx::PaletteChangeEvent::palette_index, rom_, and yaze::gfx::PaletteChangeEvent::type.
Referenced by ApplyExternalChanges(), ApplyPreviewChanges(), CancelColorEdit(), DiscardAllChanges(), DiscardGroup(), EndBatch(), Redo(), ResetPalette(), SaveAllToRom(), SaveGroup(), SetColor(), and Undo().

|
private |
Helper: Mark a color as modified.
Definition at line 1093 of file palette_manager.cc.
References CurrentState(), and GetGroup().
Referenced by ApplyExternalChanges(), CancelColorEdit(), Redo(), SetColor(), and Undo().

|
private |
Helper: Clear modified flags for a group.
Definition at line 1143 of file palette_manager.cc.
References CurrentState(), yaze::gfx::PaletteManager::SessionState::modified_colors, and yaze::gfx::PaletteManager::SessionState::modified_palettes.
Referenced by DiscardGroup(), and SaveGroup().

|
private |
Definition at line 40 of file palette_manager.cc.
References game_data_, session_states_, and unbound_state_.
Referenced by ApplyExternalChanges(), ApplyPreviewChanges(), BeginBatch(), BeginColorEdit(), BeginSaveTransaction(), CancelColorEdit(), CanRedo(), CanUndo(), ClearHistory(), ClearModifiedFlags(), CommitColorEdit(), CommitSaveTransaction(), DiscardGroup(), EndBatch(), GetModifiedGroupColorWriteRanges(), GetModifiedGroups(), GetOriginalColor(), GetRedoStackSize(), GetUndoStackSize(), HasColorEdit(), HasUnsavedChanges(), InBatch(), Initialize(), IsColorModified(), IsGroupModified(), IsPaletteModified(), MarkModified(), NotifyListeners(), RecordChanges(), Redo(), ResetPalette(), RollbackSaveTransaction(), SaveGroup(), SetColor(), and Undo().
|
private |
Definition at line 47 of file palette_manager.cc.
References game_data_, session_states_, and unbound_state_.
|
private |
Definition at line 55 of file palette_manager.cc.
References session_states_.
Referenced by ColorRevision(), GetModifiedColorCount(), GetModifiedColorWriteRanges(), HasUnsavedChanges(), and IsInitialized().
|
private |
Definition at line 485 of file palette_manager.cc.
References ASSIGN_OR_RETURN, yaze::gfx::PaletteGroupMap::get_group(), yaze::gfx::GetPaletteAddress(), yaze::gfx::palette_group_internal::OverworldPaletteLayout::Legacy(), yaze::zelda3::GameData::palette_groups, yaze::gfx::PaletteGroup::palette_ref(), yaze::zelda3::GameData::rom(), yaze::gfx::SnesPalette::size(), yaze::gfx::PaletteGroup::size(), and yaze::Rom::vector().
Referenced by GetModifiedColorWriteRanges(), GetModifiedGroupColorWriteRanges(), and SaveGroup().
|
private |
GameData instance (not owned) - preferred.
Definition at line 448 of file palette_manager.h.
Referenced by ActivateSession(), CurrentState(), CurrentState(), EndBatch(), GetGroup(), GetModifiedColorCount(), GetModifiedColorWriteRanges(), GetModifiedGroupColorWriteRanges(), GetMutableGroup(), Initialize(), Initialize(), IsInitialized(), IsSessionActive(), NotifyListeners(), Redo(), ReleaseSession(), ResetForTesting(), SaveGroup(), and Undo().
|
private |
ROM instance (not owned) - legacy, used when game_data_ is null.
Definition at line 451 of file palette_manager.h.
Referenced by ActivateSession(), EndBatch(), Initialize(), IsInitialized(), IsSessionActive(), NotifyListeners(), Redo(), ReleaseSession(), ResetForTesting(), SaveGroup(), and Undo().
|
private |
Per-GameData state. RomSession owns the keys and releases them on teardown.
Definition at line 454 of file palette_manager.h.
Referenced by ActivateSession(), CurrentState(), CurrentState(), FindState(), ReleaseSession(), and ResetForTesting().
|
private |
State used only before a GameData session is selected (legacy/tests).
Definition at line 457 of file palette_manager.h.
Referenced by CurrentState(), CurrentState(), Initialize(), and ResetForTesting().
|
staticconstexprprivate |
Definition at line 459 of file palette_manager.h.
Referenced by RecordChanges().
|
private |
Change listeners.
Definition at line 462 of file palette_manager.h.
Referenced by NotifyListeners(), RegisterChangeListener(), ResetForTesting(), and UnregisterChangeListener().
|
private |
Definition at line 463 of file palette_manager.h.
Referenced by RegisterChangeListener(), and ResetForTesting().