yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::gfx::PaletteManager Class Reference

Centralized palette management system. More...

#include <palette_manager.h>

Collaboration diagram for yaze::gfx::PaletteManager:

Classes

struct  SaveTransactionSnapshot
 
struct  SessionState
 

Public Types

using ChangeCallback = std::function<void(const PaletteChangeEvent&)>
 

Public Member Functions

 PaletteManager (const PaletteManager &)=delete
 
PaletteManageroperator= (const PaletteManager &)=delete
 
 PaletteManager (PaletteManager &&)=delete
 
PaletteManageroperator= (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.
 
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 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.
 
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.
 
std::vector< std::pair< uint32_t, uint32_t > > GetModifiedColorWriteRanges () const
 Get exact, coalesced half-open ROM ranges for modified colors.
 
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::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 undo is available.
 
bool CanRedo () const
 Check if redo is available.
 
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.
 

Static Public Member Functions

static PaletteManagerGet ()
 Get the singleton instance.
 

Private Member Functions

 PaletteManager ()=default
 
 ~PaletteManager ()=default
 
PaletteGroupGetMutableGroup (const std::string &group_name)
 Helper: Get mutable palette group.
 
const PaletteGroupGetGroup (const std::string &group_name) const
 Helper: Get const palette group.
 
SnesColor GetOriginalColor (const std::string &group_name, int palette_index, int color_index) const
 Helper: Get original color from snapshot.
 
void RecordChange (const PaletteColorChange &change)
 Helper: Record a change for undo.
 
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.
 
SessionStateCurrentState ()
 
const SessionStateCurrentState () const
 
const SessionStateFindState (const zelda3::GameData *game_data) const
 

Private Attributes

zelda3::GameDatagame_data_ = nullptr
 GameData instance (not owned) - preferred.
 
Romrom_ = nullptr
 ROM instance (not owned) - legacy, used when game_data_ is null.
 
std::unordered_map< const zelda3::GameData *, SessionStatesession_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, ChangeCallbackchange_listeners_
 Change listeners.
 
int next_callback_id_ = 1
 

Static Private Attributes

static constexpr size_t kMaxUndoHistory = 500
 

Detailed Description

Centralized palette management system.

Singleton coordinator for ALL palette editing operations. Provides:

  • Global dirty tracking across all palette groups
  • Transaction-based editing with automatic ROM synchronization
  • Unified undo/redo stack shared across all editors
  • Batch operations (save all, discard all)
  • Change notifications via observer pattern
  • Conflict resolution when multiple editors modify same palette

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.

Member Typedef Documentation

◆ ChangeCallback

Definition at line 78 of file palette_manager.h.

Constructor & Destructor Documentation

◆ PaletteManager() [1/3]

yaze::gfx::PaletteManager::PaletteManager ( const PaletteManager & )
delete

◆ PaletteManager() [2/3]

yaze::gfx::PaletteManager::PaletteManager ( PaletteManager && )
delete

◆ PaletteManager() [3/3]

yaze::gfx::PaletteManager::PaletteManager ( )
privatedefault

◆ ~PaletteManager()

yaze::gfx::PaletteManager::~PaletteManager ( )
privatedefault

Member Function Documentation

◆ Get()

static PaletteManager & yaze::gfx::PaletteManager::Get ( )
inlinestatic

Get the singleton instance.

Definition at line 81 of file palette_manager.h.

Referenced by yaze::gui::PaletteEditorWidget::ApplyDungeonRenderColorEdit(), yaze::editor::DungeonEditorV2::BeginSaveTransaction(), yaze::editor::PaletteGroupPanel::CanRedo(), yaze::editor::PaletteGroupPanel::CanUndo(), yaze::editor::PaletteGroupPanel::ClearHistory(), yaze::editor::DungeonEditorV2::CollectWriteRanges(), yaze::editor::DungeonEditorV2::CommitSaveTransaction(), yaze::editor::PaletteGroupPanel::DiscardChanges(), yaze::editor::EditorManager::DiscardPendingRomBackupRestore(), yaze::editor::PaletteEditor::DrawCategorizedPaletteList(), yaze::editor::PaletteEditor::DrawControlPanel(), yaze::gui::PaletteEditorWidget::DrawDungeonRenderColorPicker(), yaze::editor::PaletteGroupPanel::DrawToolbar(), yaze::editor::EditorManager::EnsureGameDataLoaded(), yaze::editor::PaletteGroupPanel::GetOriginalColor(), 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::PaletteEditor::Load(), yaze::editor::EditorManager::LoadAssets(), yaze::editor::EditorManager::PendingPaletteColorCountForSession(), yaze::editor::PaletteGroupPanel::Redo(), yaze::editor::PaletteEditor::Redo(), yaze::editor::EditorManager::ReplaceActiveSessionRom(), yaze::editor::PaletteGroupPanel::ResetColor(), yaze::editor::PaletteGroupPanel::ResetPalette(), yaze::editor::DungeonEditorV2::RollbackSaveTransaction(), yaze::editor::DungeonEditorV2::Save(), yaze::editor::PaletteEditor::Save(), yaze::editor::DungeonEditorV2::SaveRoom(), yaze::editor::PaletteGroupPanel::SaveToRom(), yaze::editor::EditorManager::SessionHasPendingRomWork(), yaze::editor::PaletteGroupPanel::SetColor(), yaze::editor::PaletteGroupPanel::Undo(), yaze::editor::PaletteEditor::Undo(), and yaze::editor::RomSession::~RomSession().

◆ operator=() [1/2]

PaletteManager & yaze::gfx::PaletteManager::operator= ( const PaletteManager & )
delete

◆ operator=() [2/2]

PaletteManager & yaze::gfx::PaletteManager::operator= ( PaletteManager && )
delete

◆ Initialize() [1/2]

void yaze::gfx::PaletteManager::Initialize ( zelda3::GameData * game_data)

Initialize the palette manager with GameData.

Parameters
game_dataPointer to GameData instance (must outlive PaletteManager)

Definition at line 56 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().

Here is the call graph for this function:

◆ Initialize() [2/2]

void yaze::gfx::PaletteManager::Initialize ( Rom * rom)

Legacy initialization with ROM (deprecated, use GameData version)

Parameters
romPointer to ROM instance (must outlive PaletteManager)

Definition at line 118 of file palette_manager.cc.

References game_data_, rom_, and unbound_state_.

◆ IsInitialized()

bool yaze::gfx::PaletteManager::IsInitialized ( ) const

Check if manager is initialized.

Definition at line 40 of file palette_manager.cc.

References FindState(), game_data_, yaze::zelda3::GameData::rom(), and rom_.

Referenced by ApplyPreviewChanges(), BeginSaveTransaction(), DiscardAllChanges(), DiscardGroup(), GetGroup(), GetMutableGroup(), IsManaging(), ResetPalette(), SaveAllToRom(), SaveGroup(), and SetColor().

Here is the call graph for this function:

◆ ActivateSession()

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 48 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().

Here is the call graph for this function:

◆ IsSessionActive()

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 98 of file palette_manager.cc.

References game_data_, yaze::zelda3::GameData::rom(), and rom_.

Referenced by IsManaging().

Here is the call graph for this function:

◆ 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 103 of file palette_manager.cc.

References IsInitialized(), and IsSessionActive().

Referenced by yaze::editor::PaletteGroupPanel::IsManagedSession().

Here is the call graph for this function:

◆ ReleaseSession()

void yaze::gfx::PaletteManager::ReleaseSession ( const zelda3::GameData * game_data)

Forget all palette tracking for a closing or reloaded ROM session.

Definition at line 107 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().

◆ ResetForTesting()

void yaze::gfx::PaletteManager::ResetForTesting ( )

Reset all state for test isolation.

Definition at line 129 of file palette_manager.cc.

References change_listeners_, game_data_, next_callback_id_, rom_, session_states_, and unbound_state_.

◆ GetColor()

SnesColor yaze::gfx::PaletteManager::GetColor ( const std::string & group_name,
int palette_index,
int color_index ) const

Get a color from a palette.

Parameters
group_namePalette group name
palette_indexPalette index within group
color_indexColor index within palette
Returns
The color, or default SnesColor if invalid indices

Definition at line 140 of file palette_manager.cc.

References GetGroup().

Referenced by yaze::gui::PaletteEditorWidget::DrawDungeonRenderColorPicker(), and yaze::editor::PaletteGroupPanel::GetOriginalColor().

Here is the call graph for this function:

◆ SetColor()

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)

Parameters
group_namePalette group name
palette_indexPalette index within group
color_indexColor index within palette
new_colorThe new color value
Returns
Status of the operation

Definition at line 155 of file palette_manager.cc.

References yaze::gfx::PaletteManager::SessionState::batch_changes, CurrentState(), GetMutableGroup(), InBatch(), IsInitialized(), yaze::gfx::PaletteChangeEvent::kColorChanged, MarkModified(), NotifyListeners(), and RecordChange().

Referenced by ResetColor(), and yaze::editor::PaletteGroupPanel::SetColor().

◆ ResetColor()

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 218 of file palette_manager.cc.

References GetOriginalColor(), and SetColor().

Referenced by yaze::editor::PaletteGroupPanel::ResetColor().

Here is the call graph for this function:

◆ ResetPalette()

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 224 of file palette_manager.cc.

References CurrentState(), GetMutableGroup(), IsInitialized(), yaze::gfx::PaletteChangeEvent::kPaletteReset, and NotifyListeners().

Referenced by yaze::editor::PaletteGroupPanel::ResetPalette().

Here is the call graph for this function:

◆ HasUnsavedChanges() [1/2]

bool yaze::gfx::PaletteManager::HasUnsavedChanges ( ) const

Check if there are ANY unsaved changes.

Definition at line 272 of file palette_manager.cc.

References CurrentState(), and yaze::gfx::PaletteManager::SessionState::modified_palettes.

Referenced by yaze::editor::PaletteEditor::DrawControlPanel(), and yaze::editor::EditorManager::SessionHasPendingRomWork().

Here is the call graph for this function:

◆ HasUnsavedChanges() [2/2]

bool yaze::gfx::PaletteManager::HasUnsavedChanges ( const zelda3::GameData * game_data) const

Check a specific ROM session without changing the active binding.

Definition at line 276 of file palette_manager.cc.

References FindState().

Here is the call graph for this function:

◆ GetModifiedGroups()

std::vector< std::string > yaze::gfx::PaletteManager::GetModifiedGroups ( ) const

Get list of modified palette group names.

Definition at line 282 of file palette_manager.cc.

References CurrentState(), and yaze::gfx::PaletteManager::SessionState::modified_palettes.

Referenced by ApplyPreviewChanges(), DiscardAllChanges(), and SaveAllToRom().

Here is the call graph for this function:

◆ IsGroupModified()

bool yaze::gfx::PaletteManager::IsGroupModified ( const std::string & group_name) const

Check if a specific palette group has modifications.

Definition at line 290 of file palette_manager.cc.

References CurrentState(), and yaze::gfx::PaletteManager::SessionState::modified_palettes.

Referenced by yaze::editor::PaletteEditor::DrawCategorizedPaletteList(), yaze::editor::PaletteGroupPanel::DrawToolbar(), and yaze::editor::PaletteGroupPanel::HasUnsavedChanges().

Here is the call graph for this function:

◆ IsPaletteModified()

bool yaze::gfx::PaletteManager::IsPaletteModified ( const std::string & group_name,
int palette_index ) const

Check if a specific palette is modified.

Definition at line 295 of file palette_manager.cc.

References CurrentState(), and yaze::gfx::PaletteManager::SessionState::modified_palettes.

Referenced by yaze::editor::PaletteGroupPanel::IsPaletteModified().

Here is the call graph for this function:

◆ IsColorModified()

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 304 of file palette_manager.cc.

References CurrentState(), and yaze::gfx::PaletteManager::SessionState::modified_colors.

Referenced by yaze::editor::PaletteGroupPanel::IsColorModified().

Here is the call graph for this function:

◆ GetModifiedColorCount() [1/2]

size_t yaze::gfx::PaletteManager::GetModifiedColorCount ( ) const

Get count of modified colors across all groups.

Definition at line 319 of file palette_manager.cc.

References game_data_, and GetModifiedColorCount().

Referenced by yaze::editor::PaletteEditor::DrawControlPanel(), GetModifiedColorCount(), GetModifiedColorWriteRanges(), and yaze::editor::EditorManager::PendingPaletteColorCountForSession().

Here is the call graph for this function:

◆ GetModifiedColorCount() [2/2]

size_t yaze::gfx::PaletteManager::GetModifiedColorCount ( const zelda3::GameData * game_data) const

Count modified colors for a specific ROM session.

Definition at line 323 of file palette_manager.cc.

References FindState().

Here is the call graph for this function:

◆ GetModifiedColorWriteRanges() [1/2]

std::vector< std::pair< uint32_t, uint32_t > > yaze::gfx::PaletteManager::GetModifiedColorWriteRanges ( ) const

Get exact, coalesced half-open ROM ranges for modified colors.

Definition at line 340 of file palette_manager.cc.

References game_data_, and GetModifiedColorWriteRanges().

Referenced by GetModifiedColorWriteRanges().

Here is the call graph for this function:

◆ GetModifiedColorWriteRanges() [2/2]

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 345 of file palette_manager.cc.

References FindState(), GetModifiedColorCount(), and yaze::gfx::GetPaletteAddress().

Here is the call graph for this function:

◆ SaveGroup()

◆ SaveAllToRom()

absl::Status yaze::gfx::PaletteManager::SaveAllToRom ( )

Save ALL modified palettes to ROM.

Definition at line 448 of file palette_manager.cc.

References GetModifiedGroups(), IsInitialized(), yaze::gfx::PaletteChangeEvent::kAllSaved, NotifyListeners(), RETURN_IF_ERROR, and SaveGroup().

Referenced by yaze::editor::PaletteEditor::DrawControlPanel().

Here is the call graph for this function:

◆ BeginSaveTransaction()

absl::Status yaze::gfx::PaletteManager::BeginSaveTransaction ( )

Definition at line 465 of file palette_manager.cc.

References CurrentState(), IsInitialized(), and yaze::gfx::PaletteManager::SaveTransactionSnapshot::original_palettes.

Here is the call graph for this function:

◆ RollbackSaveTransaction()

void yaze::gfx::PaletteManager::RollbackSaveTransaction ( )

Definition at line 481 of file palette_manager.cc.

References CurrentState().

Referenced by yaze::editor::DungeonEditorV2::RollbackSaveTransaction().

Here is the call graph for this function:

◆ CommitSaveTransaction()

void yaze::gfx::PaletteManager::CommitSaveTransaction ( )

Definition at line 495 of file palette_manager.cc.

References CurrentState(), and yaze::gfx::PaletteManager::SessionState::save_transaction_snapshot.

Referenced by yaze::editor::DungeonEditorV2::CommitSaveTransaction().

Here is the call graph for this function:

◆ DiscardGroup()

◆ DiscardAllChanges()

void yaze::gfx::PaletteManager::DiscardAllChanges ( )

◆ ApplyPreviewChanges()

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.

Returns
Status of the operation

Definition at line 499 of file palette_manager.cc.

References yaze::gfx::Arena::Get(), GetModifiedGroups(), IsInitialized(), yaze::gfx::PaletteChangeEvent::kAllSaved, NotifyListeners(), and yaze::gfx::Arena::NotifyPaletteModified().

Referenced by yaze::editor::PaletteEditor::DrawControlPanel().

◆ Undo()

◆ Redo()

◆ CanUndo()

bool yaze::gfx::PaletteManager::CanUndo ( ) const

Check if undo is available.

Definition at line 639 of file palette_manager.cc.

References CurrentState(), and yaze::gfx::PaletteManager::SessionState::undo_stack.

Referenced by yaze::editor::PaletteGroupPanel::CanUndo(), yaze::editor::PaletteGroupPanel::DrawToolbar(), and Undo().

Here is the call graph for this function:

◆ CanRedo()

bool yaze::gfx::PaletteManager::CanRedo ( ) const

Check if redo is available.

Definition at line 643 of file palette_manager.cc.

References CurrentState(), and yaze::gfx::PaletteManager::SessionState::redo_stack.

Referenced by yaze::editor::PaletteGroupPanel::CanRedo(), yaze::editor::PaletteGroupPanel::DrawToolbar(), and Redo().

Here is the call graph for this function:

◆ GetUndoStackSize()

size_t yaze::gfx::PaletteManager::GetUndoStackSize ( ) const

Get size of undo stack.

Definition at line 647 of file palette_manager.cc.

References CurrentState(), and yaze::gfx::PaletteManager::SessionState::undo_stack.

Here is the call graph for this function:

◆ GetRedoStackSize()

size_t yaze::gfx::PaletteManager::GetRedoStackSize ( ) const

Get size of redo stack.

Definition at line 651 of file palette_manager.cc.

References CurrentState(), and yaze::gfx::PaletteManager::SessionState::redo_stack.

Here is the call graph for this function:

◆ ClearHistory()

void yaze::gfx::PaletteManager::ClearHistory ( )

Clear undo/redo history.

Definition at line 634 of file palette_manager.cc.

References CurrentState(), yaze::gfx::PaletteManager::SessionState::redo_stack, and yaze::gfx::PaletteManager::SessionState::undo_stack.

Referenced by yaze::editor::PaletteGroupPanel::ClearHistory(), and DiscardAllChanges().

Here is the call graph for this function:

◆ RegisterChangeListener()

int yaze::gfx::PaletteManager::RegisterChangeListener ( ChangeCallback callback)

Register a callback for palette change events.

Returns
Unique ID for this callback (use to unregister)

Definition at line 657 of file palette_manager.cc.

References change_listeners_, and next_callback_id_.

◆ UnregisterChangeListener()

void yaze::gfx::PaletteManager::UnregisterChangeListener ( int callback_id)

Unregister a change listener.

Definition at line 663 of file palette_manager.cc.

References change_listeners_.

◆ BeginBatch()

void yaze::gfx::PaletteManager::BeginBatch ( )

Begin a batch operation (groups multiple changes into one undo step)

Note
Must be paired with EndBatch()

Definition at line 669 of file palette_manager.cc.

References yaze::gfx::PaletteManager::SessionState::batch_changes, yaze::gfx::PaletteManager::SessionState::batch_depth, and CurrentState().

Here is the call graph for this function:

◆ EndBatch()

◆ InBatch()

bool yaze::gfx::PaletteManager::InBatch ( ) const

Check if currently in a batch operation.

Definition at line 700 of file palette_manager.cc.

References yaze::gfx::PaletteManager::SessionState::batch_depth, and CurrentState().

Referenced by SetColor().

Here is the call graph for this function:

◆ GetMutableGroup()

PaletteGroup * yaze::gfx::PaletteManager::GetMutableGroup ( const std::string & group_name)
private

Helper: Get mutable palette group.

Definition at line 706 of file palette_manager.cc.

References game_data_, yaze::gfx::PaletteGroupMap::get_group(), IsInitialized(), and yaze::zelda3::GameData::palette_groups.

Referenced by DiscardGroup(), Redo(), ResetPalette(), SaveGroup(), SetColor(), and Undo().

Here is the call graph for this function:

◆ GetGroup()

const PaletteGroup * yaze::gfx::PaletteManager::GetGroup ( const std::string & group_name) const
private

Helper: Get const palette group.

Definition at line 720 of file palette_manager.cc.

References game_data_, IsInitialized(), and yaze::zelda3::GameData::palette_groups.

Referenced by GetColor(), and MarkModified().

Here is the call graph for this function:

◆ GetOriginalColor()

SnesColor yaze::gfx::PaletteManager::GetOriginalColor ( const std::string & group_name,
int palette_index,
int color_index ) const
private

Helper: Get original color from snapshot.

Definition at line 736 of file palette_manager.cc.

References CurrentState().

Referenced by ResetColor().

Here is the call graph for this function:

◆ RecordChange()

void yaze::gfx::PaletteManager::RecordChange ( const PaletteColorChange & change)
private

Helper: Record a change for undo.

Definition at line 754 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 SetColor().

Here is the call graph for this function:

◆ NotifyListeners()

void yaze::gfx::PaletteManager::NotifyListeners ( const PaletteChangeEvent & event)
private

Helper: Notify all listeners of an event.

Definition at line 766 of file palette_manager.cc.

References change_listeners_.

Referenced by ApplyPreviewChanges(), DiscardAllChanges(), DiscardGroup(), EndBatch(), Redo(), ResetPalette(), SaveAllToRom(), SaveGroup(), SetColor(), and Undo().

◆ MarkModified()

void yaze::gfx::PaletteManager::MarkModified ( const std::string & group_name,
int palette_index,
int color_index )
private

Helper: Mark a color as modified.

Definition at line 772 of file palette_manager.cc.

References CurrentState(), and GetGroup().

Referenced by Redo(), SetColor(), and Undo().

Here is the call graph for this function:

◆ ClearModifiedFlags()

void yaze::gfx::PaletteManager::ClearModifiedFlags ( const std::string & group_name)
private

Helper: Clear modified flags for a group.

Definition at line 822 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().

Here is the call graph for this function:

◆ CurrentState() [1/2]

◆ CurrentState() [2/2]

const PaletteManager::SessionState * yaze::gfx::PaletteManager::CurrentState ( ) const
private

Definition at line 23 of file palette_manager.cc.

References game_data_, session_states_, and unbound_state_.

◆ FindState()

const PaletteManager::SessionState * yaze::gfx::PaletteManager::FindState ( const zelda3::GameData * game_data) const
private

Member Data Documentation

◆ game_data_

zelda3::GameData* yaze::gfx::PaletteManager::game_data_ = nullptr
private

◆ rom_

Rom* yaze::gfx::PaletteManager::rom_ = nullptr
private

ROM instance (not owned) - legacy, used when game_data_ is null.

Definition at line 399 of file palette_manager.h.

Referenced by ActivateSession(), Initialize(), IsInitialized(), IsSessionActive(), ReleaseSession(), ResetForTesting(), and SaveGroup().

◆ session_states_

std::unordered_map<const zelda3::GameData*, SessionState> yaze::gfx::PaletteManager::session_states_
private

Per-GameData state. RomSession owns the keys and releases them on teardown.

Definition at line 402 of file palette_manager.h.

Referenced by ActivateSession(), CurrentState(), CurrentState(), FindState(), ReleaseSession(), and ResetForTesting().

◆ unbound_state_

SessionState yaze::gfx::PaletteManager::unbound_state_
private

State used only before a GameData session is selected (legacy/tests).

Definition at line 405 of file palette_manager.h.

Referenced by CurrentState(), CurrentState(), Initialize(), and ResetForTesting().

◆ kMaxUndoHistory

constexpr size_t yaze::gfx::PaletteManager::kMaxUndoHistory = 500
staticconstexprprivate

Definition at line 407 of file palette_manager.h.

Referenced by RecordChange().

◆ change_listeners_

std::unordered_map<int, ChangeCallback> yaze::gfx::PaletteManager::change_listeners_
private

Change listeners.

Definition at line 410 of file palette_manager.h.

Referenced by NotifyListeners(), RegisterChangeListener(), ResetForTesting(), and UnregisterChangeListener().

◆ next_callback_id_

int yaze::gfx::PaletteManager::next_callback_id_ = 1
private

Definition at line 411 of file palette_manager.h.

Referenced by RegisterChangeListener(), and ResetForTesting().


The documentation for this class was generated from the following files: