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 "app/rom.h"
11#include "imgui/imgui.h"
12
13namespace yaze {
14namespace gui {
15
17 public:
19
20 void Initialize(Rom *rom);
21
22 // Embedded drawing function, like the old PaletteEditorWidget
23 void Draw();
24
25 // Modal dialogs from the more feature-rich PaletteWidget
27 const std::string &title = "Palette Editor");
29 void ShowColorAnalysis(const gfx::Bitmap &bitmap,
30 const std::string &title = "Color Analysis");
31
32 bool ApplyROMPalette(gfx::Bitmap *bitmap, int group_index, int palette_index);
34 void SavePaletteBackup(const gfx::SnesPalette &palette);
36
37 // Callback when palette is modified
38 void SetOnPaletteChanged(std::function<void(int palette_id)> callback) {
39 on_palette_changed_ = callback;
40 }
41
42 // Get/Set current editing palette
45
46 bool IsROMLoaded() const { return rom_ != nullptr; }
49
50 private:
51 void DrawPaletteGrid(gfx::SnesPalette &palette, int cols = 15);
52 void DrawColorEditControls(gfx::SnesColor &color, int color_index);
53 void DrawPaletteAnalysis(const gfx::SnesPalette &palette);
54 void LoadROMPalettes();
55
56 // For embedded view
58 void DrawColorPicker();
59
60 Rom *rom_ = nullptr;
61 std::vector<gfx::SnesPalette> rom_palette_groups_;
62 std::vector<std::string> palette_group_names_;
64
66 int current_palette_index_ = 0; // used by ROM palette selector
69 bool show_rom_manager_ = false;
70
71 // State for embedded editor
74 ImVec4 editing_color_{0, 0, 0, 1};
75
76 // Callback for palette changes
77 std::function<void(int palette_id)> on_palette_changed_;
78
79 // Color editing state
81 ImVec4 temp_color_ = ImVec4(0, 0, 0, 1);
82};
83
84} // namespace gui
85} // namespace yaze
86
87#endif // YAZE_APP_GUI_WIDGETS_PALETTE_EDITOR_WIDGET_H
88
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:74
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:66
SNES Color container.
Definition snes_color.h:109
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 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)
Main namespace for the application.
Definition controller.cc:20