3#include "absl/strings/str_format.h"
8#include "imgui/imgui.h"
12namespace palette_utility {
16 bool clicked = ImGui::SmallButton(
19 if (ImGui::IsItemHovered()) {
20 ImGui::SetTooltip(
"Jump to palette editor:\n%s - Palette %d",
21 group_name.c_str(), palette_index);
24 if (clicked && editor) {
32 const std::string& group_name,
int palette_index,
38 bool changed = ImGui::ColorEdit4(label, &col.x,
39 ImGuiColorEditFlags_NoInputs |
40 ImGuiColorEditFlags_NoLabel);
48 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
54 ImGui::PopStyleColor();
56 if (ImGui::IsItemHovered()) {
57 ImGui::BeginTooltip();
58 ImGui::Text(
"Jump to Palette Editor");
59 ImGui::TextDisabled(
"%s - Palette %d, Color %d",
60 group_name.c_str(), palette_index, color_index);
70 const std::string& group_name,
75 bool changed = ImGui::InputInt(label, palette_id);
78 if (*palette_id < 0) *palette_id = 0;
79 if (*palette_id > 255) *palette_id = 255;
92 auto rgb = color.
rgb();
94 ImGui::Text(
"RGB: (%d, %d, %d)",
95 static_cast<int>(rgb.x),
96 static_cast<int>(rgb.y),
97 static_cast<int>(rgb.z));
98 ImGui::Text(
"SNES: $%04X", color.
snes());
99 ImGui::Text(
"Hex: #%02X%02X%02X",
100 static_cast<int>(rgb.x),
101 static_cast<int>(rgb.y),
102 static_cast<int>(rgb.z));
108 ImGui::TextDisabled(
"(ROM not loaded)");
113 if (!group || palette_index >= group->size()) {
114 ImGui::TextDisabled(
"(Palette not found)");
118 auto palette = group->palette(palette_index);
121 int preview_size = std::min(8,
static_cast<int>(palette.size()));
122 for (
int i = 0; i < preview_size; i++) {
123 if (i > 0) ImGui::SameLine();
127 ImGui::ColorButton(
"##preview", col,
128 ImGuiColorEditFlags_NoAlpha |
129 ImGuiColorEditFlags_NoPicker |
130 ImGuiColorEditFlags_NoTooltip,
133 if (ImGui::IsItemHovered()) {
134 ImGui::BeginTooltip();
135 ImGui::Text(
"Color %d", i);
The Rom class is used to load, save, and modify Rom data.
auto mutable_palette_group()
Allows the user to view and edit in game palettes.
void JumpToPalette(const std::string &group_name, int palette_index)
Jump to a specific palette by group and index.
constexpr ImVec4 rgb() const
Get RGB values (WARNING: stored as 0-255 in ImVec4)
constexpr uint16_t snes() const
Get SNES 15-bit color.
#define ICON_MD_OPEN_IN_NEW
bool DrawPaletteJumpButton(const char *label, const std::string &group_name, int palette_index, PaletteEditor *editor)
Draw a palette selector button that opens palette editor.
bool DrawPaletteIdSelector(const char *label, int *palette_id, const std::string &group_name, PaletteEditor *editor)
Draw a compact palette ID selector with preview.
bool DrawInlineColorEdit(const char *label, gfx::SnesColor *color, const std::string &group_name, int palette_index, int color_index, PaletteEditor *editor)
Draw inline color edit with jump to palette.
void DrawPalettePreview(const std::string &group_name, int palette_index, Rom *rom)
Draw a small palette preview (8 colors in a row)
void DrawColorInfoTooltip(const gfx::SnesColor &color)
Draw color info tooltip on hover.
ImVec4 ConvertSnesColorToImVec4(const gfx::SnesColor &color)
Convert SnesColor to standard ImVec4 for display.
gfx::SnesColor ConvertImVec4ToSnesColor(const ImVec4 &color)
Convert standard ImVec4 to SnesColor.
Main namespace for the application.