yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::PaletteGroupCard Class Referenceabstract

Base class for palette group editing cards. More...

#include <palette_group_card.h>

Inherited by yaze::editor::DungeonMainPaletteCard, yaze::editor::EquipmentPaletteCard, yaze::editor::OverworldAnimatedPaletteCard, yaze::editor::OverworldMainPaletteCard, yaze::editor::SpritePaletteCard, yaze::editor::SpritesAux1PaletteCard, yaze::editor::SpritesAux2PaletteCard, and yaze::editor::SpritesAux3PaletteCard.

Collaboration diagram for yaze::editor::PaletteGroupCard:

Public Member Functions

 PaletteGroupCard (const std::string &group_name, const std::string &display_name, Rom *rom)
 Construct a new Palette Group Card.
 
virtual ~PaletteGroupCard ()=default
 
void Draw ()
 Draw the card's ImGui UI.
 
void Show ()
 
void Hide ()
 
bool IsVisible () const
 
bool * visibility_flag ()
 
absl::Status SaveToRom ()
 Save all modified palettes to ROM.
 
void DiscardChanges ()
 Discard all unsaved changes.
 
void ResetPalette (int palette_index)
 Reset a specific palette to original ROM values.
 
void ResetColor (int palette_index, int color_index)
 Reset a specific color to original ROM value.
 
void SetColor (int palette_index, int color_index, const gfx::SnesColor &new_color)
 Set a color value (records change for undo)
 
void Undo ()
 
void Redo ()
 
bool CanUndo () const
 
bool CanRedo () const
 
void ClearHistory ()
 
bool HasUnsavedChanges () const
 
bool IsPaletteModified (int palette_index) const
 
bool IsColorModified (int palette_index, int color_index) const
 
int GetSelectedPaletteIndex () const
 
void SetSelectedPaletteIndex (int index)
 
int GetSelectedColorIndex () const
 
void SetSelectedColorIndex (int index)
 
std::string ExportToJson () const
 
absl::Status ImportFromJson (const std::string &json)
 
std::string ExportToClipboard () const
 
absl::Status ImportFromClipboard ()
 

Protected Member Functions

virtual gfx::PaletteGroupGetPaletteGroup ()=0
 Get the palette group for this card.
 
virtual const gfx::PaletteGroupGetPaletteGroup () const =0
 
virtual const PaletteGroupMetadataGetMetadata () const =0
 Get metadata for this palette group.
 
virtual void DrawPaletteGrid ()=0
 Draw the palette grid specific to this palette type.
 
virtual int GetColorsPerRow () const =0
 Get the number of colors per row for grid layout.
 
virtual void DrawCustomToolbarButtons ()
 Draw additional toolbar buttons (called after standard buttons)
 
virtual void DrawCustomPanels ()
 Draw additional panels (called after main content)
 
void DrawToolbar ()
 Draw standard toolbar with save/discard/undo/redo.
 
void DrawPaletteSelector ()
 Draw palette selector dropdown.
 
void DrawColorPicker ()
 Draw color picker for selected color.
 
void DrawColorInfo ()
 Draw color info panel with RGB/SNES/Hex values.
 
void DrawMetadataInfo ()
 Draw palette metadata info panel.
 
void DrawBatchOperationsPopup ()
 Draw batch operations popup.
 
gfx::SnesPaletteGetMutablePalette (int index)
 Get mutable palette by index.
 
gfx::SnesColor GetOriginalColor (int palette_index, int color_index) const
 Get original color from ROM (for reset/comparison)
 
absl::Status WriteColorToRom (int palette_index, int color_index, const gfx::SnesColor &color)
 Write a single color to ROM.
 
void MarkModified (int palette_index, int color_index)
 Mark palette as modified.
 
void ClearModified (int palette_index)
 Clear modified flags for palette.
 

Protected Attributes

std::string group_name_
 
std::string display_name_
 
Romrom_
 
bool show_ = false
 
int selected_palette_ = 0
 
int selected_color_ = -1
 
gfx::SnesColor editing_color_
 
bool auto_save_enabled_ = false
 
bool show_snes_format_ = true
 
bool show_hex_format_ = true
 

Detailed Description

Base class for palette group editing cards.

Provides common functionality for all palette group editors:

  • ROM persistence with transaction-based writes
  • Undo/redo history management
  • Modified state tracking with visual indicators
  • Save/discard workflow
  • Common toolbar and color picker UI
  • EditorCardRegistry integration

Derived classes implement specific grid layouts and palette access.

Definition at line 67 of file palette_group_card.h.

Constructor & Destructor Documentation

◆ PaletteGroupCard()

yaze::editor::PaletteGroupCard::PaletteGroupCard ( const std::string &  group_name,
const std::string &  display_name,
Rom rom 
)

Construct a new Palette Group Card.

Parameters
group_nameInternal palette group name (e.g., "ow_main", "dungeon_main")
display_nameHuman-readable name for UI
romROM instance for reading/writing palettes

Definition at line 24 of file palette_group_card.cc.

◆ ~PaletteGroupCard()

virtual yaze::editor::PaletteGroupCard::~PaletteGroupCard ( )
virtualdefault

Member Function Documentation

◆ Draw()

◆ Show()

void yaze::editor::PaletteGroupCard::Show ( )
inline

Definition at line 90 of file palette_group_card.h.

References show_.

◆ Hide()

void yaze::editor::PaletteGroupCard::Hide ( )
inline

Definition at line 91 of file palette_group_card.h.

References show_.

◆ IsVisible()

bool yaze::editor::PaletteGroupCard::IsVisible ( ) const
inline

Definition at line 92 of file palette_group_card.h.

References show_.

◆ visibility_flag()

bool * yaze::editor::PaletteGroupCard::visibility_flag ( )
inline

Definition at line 93 of file palette_group_card.h.

References show_.

◆ SaveToRom()

absl::Status yaze::editor::PaletteGroupCard::SaveToRom ( )

Save all modified palettes to ROM.

Definition at line 407 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, and yaze::gfx::PaletteManager::SaveGroup().

Referenced by DrawToolbar().

Here is the call graph for this function:

◆ DiscardChanges()

void yaze::editor::PaletteGroupCard::DiscardChanges ( )

Discard all unsaved changes.

Definition at line 412 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::DiscardGroup(), yaze::gfx::PaletteManager::Get(), group_name_, and selected_color_.

Referenced by DrawBatchOperationsPopup(), and DrawToolbar().

Here is the call graph for this function:

◆ ResetPalette()

void yaze::editor::PaletteGroupCard::ResetPalette ( int  palette_index)

Reset a specific palette to original ROM values.

Definition at line 420 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, and yaze::gfx::PaletteManager::ResetPalette().

Referenced by DrawPaletteSelector().

Here is the call graph for this function:

◆ ResetColor()

void yaze::editor::PaletteGroupCard::ResetColor ( int  palette_index,
int  color_index 
)

Reset a specific color to original ROM value.

Definition at line 425 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, and yaze::gfx::PaletteManager::ResetColor().

Referenced by DrawColorPicker().

Here is the call graph for this function:

◆ SetColor()

void yaze::editor::PaletteGroupCard::SetColor ( int  palette_index,
int  color_index,
const gfx::SnesColor new_color 
)

Set a color value (records change for undo)

Todo:
Show error notification

Definition at line 391 of file palette_group_card.cc.

References auto_save_enabled_, yaze::gfx::PaletteManager::Get(), group_name_, yaze::gfx::PaletteManager::SetColor(), and WriteColorToRom().

Referenced by DrawColorPicker().

Here is the call graph for this function:

◆ Undo()

void yaze::editor::PaletteGroupCard::Undo ( )

Definition at line 433 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::Get(), and yaze::gfx::PaletteManager::Undo().

Referenced by DrawToolbar().

Here is the call graph for this function:

◆ Redo()

void yaze::editor::PaletteGroupCard::Redo ( )

Definition at line 438 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::Get(), and yaze::gfx::PaletteManager::Redo().

Referenced by DrawToolbar().

Here is the call graph for this function:

◆ CanUndo()

bool yaze::editor::PaletteGroupCard::CanUndo ( ) const

Definition at line 468 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::CanUndo(), and yaze::gfx::PaletteManager::Get().

Referenced by DrawToolbar().

Here is the call graph for this function:

◆ CanRedo()

bool yaze::editor::PaletteGroupCard::CanRedo ( ) const

Definition at line 473 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::CanRedo(), and yaze::gfx::PaletteManager::Get().

Referenced by DrawToolbar().

Here is the call graph for this function:

◆ ClearHistory()

void yaze::editor::PaletteGroupCard::ClearHistory ( )

Definition at line 443 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::ClearHistory(), and yaze::gfx::PaletteManager::Get().

Here is the call graph for this function:

◆ HasUnsavedChanges()

bool yaze::editor::PaletteGroupCard::HasUnsavedChanges ( ) const

Definition at line 463 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, and yaze::gfx::PaletteManager::IsGroupModified().

Here is the call graph for this function:

◆ IsPaletteModified()

bool yaze::editor::PaletteGroupCard::IsPaletteModified ( int  palette_index) const

Definition at line 450 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, and yaze::gfx::PaletteManager::IsPaletteModified().

Referenced by DrawPaletteSelector(), and DrawToolbar().

Here is the call graph for this function:

◆ IsColorModified()

◆ GetSelectedPaletteIndex()

int yaze::editor::PaletteGroupCard::GetSelectedPaletteIndex ( ) const
inline

Definition at line 136 of file palette_group_card.h.

References selected_palette_.

◆ SetSelectedPaletteIndex()

void yaze::editor::PaletteGroupCard::SetSelectedPaletteIndex ( int  index)
inline

Definition at line 137 of file palette_group_card.h.

References selected_palette_.

◆ GetSelectedColorIndex()

int yaze::editor::PaletteGroupCard::GetSelectedColorIndex ( ) const
inline

Definition at line 139 of file palette_group_card.h.

References selected_color_.

◆ SetSelectedColorIndex()

void yaze::editor::PaletteGroupCard::SetSelectedColorIndex ( int  index)
inline

Definition at line 140 of file palette_group_card.h.

References selected_color_.

◆ ExportToJson()

std::string yaze::editor::PaletteGroupCard::ExportToJson ( ) const
Todo:
Implement JSON export

Definition at line 505 of file palette_group_card.cc.

◆ ImportFromJson()

absl::Status yaze::editor::PaletteGroupCard::ImportFromJson ( const std::string &  json)
Todo:
Implement JSON import

Definition at line 510 of file palette_group_card.cc.

◆ ExportToClipboard()

std::string yaze::editor::PaletteGroupCard::ExportToClipboard ( ) const

Definition at line 515 of file palette_group_card.cc.

References GetPaletteGroup(), and selected_palette_.

Referenced by DrawBatchOperationsPopup(), and DrawToolbar().

Here is the call graph for this function:

◆ ImportFromClipboard()

absl::Status yaze::editor::PaletteGroupCard::ImportFromClipboard ( )
Todo:
Implement clipboard import

Definition at line 535 of file palette_group_card.cc.

Referenced by DrawBatchOperationsPopup(), and DrawToolbar().

◆ GetPaletteGroup() [1/2]

◆ GetPaletteGroup() [2/2]

◆ GetMetadata()

◆ DrawPaletteGrid()

◆ GetColorsPerRow()

◆ DrawCustomToolbarButtons()

virtual void yaze::editor::PaletteGroupCard::DrawCustomToolbarButtons ( )
inlineprotectedvirtual

Draw additional toolbar buttons (called after standard buttons)

Definition at line 179 of file palette_group_card.h.

Referenced by DrawToolbar().

◆ DrawCustomPanels()

virtual void yaze::editor::PaletteGroupCard::DrawCustomPanels ( )
inlineprotectedvirtual

Draw additional panels (called after main content)

Reimplemented in yaze::editor::SpritePaletteCard.

Definition at line 184 of file palette_group_card.h.

Referenced by Draw().

◆ DrawToolbar()

◆ DrawPaletteSelector()

void yaze::editor::PaletteGroupCard::DrawPaletteSelector ( )
protected

◆ DrawColorPicker()

◆ DrawColorInfo()

void yaze::editor::PaletteGroupCard::DrawColorInfo ( )
protected

Draw color info panel with RGB/SNES/Hex values.

Definition at line 267 of file palette_group_card.cc.

References editing_color_, yaze::gfx::SnesColor::rgb(), yaze::gui::SectionHeader(), selected_color_, show_hex_format_, show_snes_format_, and yaze::gfx::SnesColor::snes().

Referenced by Draw().

Here is the call graph for this function:

◆ DrawMetadataInfo()

void yaze::editor::PaletteGroupCard::DrawMetadataInfo ( )
protected

Draw palette metadata info panel.

Definition at line 302 of file palette_group_card.cc.

References GetMetadata(), yaze::gui::SectionHeader(), and selected_palette_.

Referenced by Draw().

Here is the call graph for this function:

◆ DrawBatchOperationsPopup()

void yaze::editor::PaletteGroupCard::DrawBatchOperationsPopup ( )
protected

Draw batch operations popup.

Definition at line 364 of file palette_group_card.cc.

References DiscardChanges(), ExportToClipboard(), ImportFromClipboard(), yaze::gui::SectionHeader(), and yaze::gui::ThemedButton().

Referenced by Draw().

◆ GetMutablePalette()

◆ GetOriginalColor()

gfx::SnesColor yaze::editor::PaletteGroupCard::GetOriginalColor ( int  palette_index,
int  color_index 
) const
protected

Get original color from ROM (for reset/comparison)

Definition at line 488 of file palette_group_card.cc.

References yaze::gfx::PaletteManager::Get(), yaze::gfx::PaletteManager::GetColor(), and group_name_.

Referenced by DrawColorPicker().

Here is the call graph for this function:

◆ WriteColorToRom()

absl::Status yaze::editor::PaletteGroupCard::WriteColorToRom ( int  palette_index,
int  color_index,
const gfx::SnesColor color 
)
protected

Write a single color to ROM.

Definition at line 495 of file palette_group_card.cc.

References yaze::gfx::GetPaletteAddress(), group_name_, rom_, and yaze::Rom::WriteColor().

Referenced by SetColor().

Here is the call graph for this function:

◆ MarkModified()

void yaze::editor::PaletteGroupCard::MarkModified ( int  palette_index,
int  color_index 
)
protected

Mark palette as modified.

◆ ClearModified()

void yaze::editor::PaletteGroupCard::ClearModified ( int  palette_index)
protected

Clear modified flags for palette.

Member Data Documentation

◆ group_name_

std::string yaze::editor::PaletteGroupCard::group_name_
protected

◆ display_name_

std::string yaze::editor::PaletteGroupCard::display_name_
protected

Definition at line 249 of file palette_group_card.h.

Referenced by Draw().

◆ rom_

◆ show_

bool yaze::editor::PaletteGroupCard::show_ = false
protected

Definition at line 251 of file palette_group_card.h.

Referenced by Draw(), Hide(), IsVisible(), Show(), and visibility_flag().

◆ selected_palette_

◆ selected_color_

◆ editing_color_

◆ auto_save_enabled_

bool yaze::editor::PaletteGroupCard::auto_save_enabled_ = false
protected

Definition at line 259 of file palette_group_card.h.

Referenced by SetColor().

◆ show_snes_format_

bool yaze::editor::PaletteGroupCard::show_snes_format_ = true
protected

Definition at line 260 of file palette_group_card.h.

Referenced by DrawColorInfo().

◆ show_hex_format_

bool yaze::editor::PaletteGroupCard::show_hex_format_ = true
protected

Definition at line 261 of file palette_group_card.h.

Referenced by DrawColorInfo().


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