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 <vector>
7
10#include "imgui/imgui.h"
11#include "rom/rom.h"
12#include "zelda3/game_data.h"
13
14namespace yaze {
15namespace gui {
16
18 public:
20
21 void Initialize(zelda3::GameData* game_data);
22 void Initialize(Rom* rom); // Legacy, deprecated
23
24 // Embedded drawing function, like the old PaletteEditorWidget
25 void Draw();
26
27 // Modal dialogs from the more feature-rich PaletteWidget
29 const std::string& title = "Palette Editor");
31 void ShowColorAnalysis(const gfx::Bitmap& bitmap,
32 const std::string& title = "Color Analysis");
33
34 bool ApplyROMPalette(gfx::Bitmap* bitmap, int group_index, int palette_index);
36 void SavePaletteBackup(const gfx::SnesPalette& palette);
38
39 // Callback when palette is modified
40 void SetOnPaletteChanged(std::function<void(int palette_id)> callback) {
41 on_palette_changed_ = callback;
42 }
43
44 // Get/Set current editing palette
47
48 bool IsROMLoaded() const { return rom_ != nullptr; }
51
52 private:
53 void DrawPaletteGrid(gfx::SnesPalette& palette, int cols = 15);
54 void DrawColorEditControls(gfx::SnesColor& color, int color_index);
55 void DrawPaletteAnalysis(const gfx::SnesPalette& palette);
56 void LoadROMPalettes();
57
58 // For embedded view
60 void DrawColorPicker();
61
63 Rom* rom_ = nullptr; // Legacy, deprecated
64 std::vector<gfx::SnesPalette> rom_palette_groups_;
65 std::vector<std::string> palette_group_names_;
67
69 int current_palette_index_ = 0; // used by ROM palette selector
72 bool show_rom_manager_ = false;
73
74 // State for embedded editor
77 ImVec4 editing_color_{0, 0, 0, 1};
78
79 // Callback for palette changes
80 std::function<void(int palette_id)> on_palette_changed_;
81
82 // Color editing state
84 ImVec4 temp_color_ = ImVec4(0, 0, 0, 1);
85};
86
87} // namespace gui
88} // namespace yaze
89
90#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:24
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_
std::function< void(int palette_id)> on_palette_changed_
bool RestorePaletteBackup(gfx::SnesPalette &palette)
void ShowPaletteEditor(gfx::SnesPalette &palette, const std::string &title="Palette Editor")
bool ApplyROMPalette(gfx::Bitmap *bitmap, int group_index, int palette_index)
const gfx::SnesPalette * GetSelectedROMPalette() const
void SavePaletteBackup(const gfx::SnesPalette &palette)
void ShowColorAnalysis(const gfx::Bitmap &bitmap, const std::string &title="Color Analysis")
void Initialize(zelda3::GameData *game_data)
void SetOnPaletteChanged(std::function< void(int palette_id)> callback)
void DrawColorEditControls(gfx::SnesColor &color, int color_index)
void DrawPaletteAnalysis(const gfx::SnesPalette &palette)
std::vector< std::string > palette_group_names_
void DrawPaletteGrid(gfx::SnesPalette &palette, int cols=15)