yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
palette_editor_widget.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GUI_WIDGETS_PALETTE_EDITOR_WIDGET_H
2#define YAZE_APP_GUI_WIDGETS_PALETTE_EDITOR_WIDGET_H
3
4#include <functional>
5#include <map>
6#include <optional>
7#include <vector>
8
9#include "absl/status/status.h"
10#include "app/gfx/core/bitmap.h"
12#include "imgui/imgui.h"
13#include "rom/rom.h"
14#include "zelda3/game_data.h"
15
16namespace yaze {
17namespace gui {
18
23
28
30 public:
32
33 void Initialize(zelda3::GameData* game_data);
34 void Initialize(Rom* rom); // Legacy, deprecated
35
36 // Embedded drawing function, like the old PaletteEditorWidget
37 void Draw();
38
39 // Modal dialogs from the more feature-rich PaletteWidget
41 const std::string& title = "Palette Editor");
43 void ShowColorAnalysis(const gfx::Bitmap& bitmap,
44 const std::string& title = "Color Analysis");
45
46 bool ApplyROMPalette(gfx::Bitmap* bitmap, int group_index, int palette_index);
48 void SavePaletteBackup(const gfx::SnesPalette& palette);
50
51 // Original palette-id-only callback retained for source compatibility.
52 void SetOnPaletteChanged(std::function<void(int)> callback) {
53 if (!callback) {
55 return;
56 }
57 on_palette_changed_ = [callback](DungeonPaletteChange change) {
58 callback(change.palette_id);
59 };
60 }
61
62 // Typed callback for dungeon rendering consumers that must distinguish
63 // shared HUD edits from palette-scoped dungeon-main edits.
65 std::function<void(DungeonPaletteChange)> callback) {
66 on_palette_changed_ = callback;
67 }
68
69 // Get/Set current editing palette
72 void SetDungeonRenderPaletteMode(bool enabled) {
74 }
75
76 // Apply one editable CGRAM slot from the dungeon render palette. Passing a
77 // color records the edit through PaletteManager; std::nullopt resets the
78 // slot to PaletteManager's original ROM snapshot. The palette-change
79 // callback is fired only after a successful managed edit.
80 absl::Status ApplyDungeonRenderColorEdit(int display_index,
81 std::optional<gfx::SnesColor> color);
82
83 bool IsROMLoaded() const { return rom_ != nullptr; }
86
87 private:
88 void DrawPaletteGrid(gfx::SnesPalette& palette, int cols = 15);
89 void DrawColorEditControls(gfx::SnesColor& color, int color_index);
90 void DrawPaletteAnalysis(const gfx::SnesPalette& palette);
91 void LoadROMPalettes();
92 float ComputeSwatchSize(int columns, float min_size, float max_size) const;
93
94 // For embedded view
96 void DrawColorPicker();
99
101 Rom* rom_ = nullptr; // Legacy, deprecated
102 std::vector<gfx::SnesPalette> rom_palette_groups_;
103 std::vector<std::string> palette_group_names_;
105
107 int current_palette_index_ = 0; // used by ROM palette selector
110 bool show_rom_manager_ = false;
111
112 // State for embedded editor
115 ImVec4 editing_color_{0, 0, 0, 1};
116
117 // Callback for palette changes
119
120 // Color editing state
122 ImVec4 temp_color_ = ImVec4(0, 0, 0, 1);
124};
125
126} // namespace gui
127} // namespace yaze
128
129#endif // YAZE_APP_GUI_WIDGETS_PALETTE_EDITOR_WIDGET_H
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:67
SNES Color container.
Definition snes_color.h:110
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
std::vector< gfx::SnesPalette > rom_palette_groups_
bool RestorePaletteBackup(gfx::SnesPalette &palette)
void ShowPaletteEditor(gfx::SnesPalette &palette, const std::string &title="Palette Editor")
void SetOnDungeonPaletteChanged(std::function< void(DungeonPaletteChange)> callback)
bool ApplyROMPalette(gfx::Bitmap *bitmap, int group_index, int palette_index)
const gfx::SnesPalette * GetSelectedROMPalette() const
void SetDungeonRenderPaletteMode(bool enabled)
void SavePaletteBackup(const gfx::SnesPalette &palette)
std::function< void(DungeonPaletteChange)> on_palette_changed_
void ShowColorAnalysis(const gfx::Bitmap &bitmap, const std::string &title="Color Analysis")
void Initialize(zelda3::GameData *game_data)
absl::Status ApplyDungeonRenderColorEdit(int display_index, std::optional< gfx::SnesColor > color)
void DrawColorEditControls(gfx::SnesColor &color, int color_index)
void DrawPaletteAnalysis(const gfx::SnesPalette &palette)
void SetOnPaletteChanged(std::function< void(int)> callback)
float ComputeSwatchSize(int columns, float min_size, float max_size) const
std::vector< std::string > palette_group_names_
void DrawPaletteGrid(gfx::SnesPalette &palette, int cols=15)
DungeonRenderPaletteSource source