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(
40 ImGuiColorEditFlags_NoInputs | 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", group_name.c_str(),
60 palette_index, color_index);
70 const std::string& group_name,
75 bool changed = ImGui::InputInt(label, palette_id);
80 if (*palette_id > 255)
94 auto rgb = color.
rgb();
96 ImGui::Text(
"RGB: (%d, %d, %d)",
static_cast<int>(rgb.x),
97 static_cast<int>(rgb.y),
static_cast<int>(rgb.z));
98 ImGui::Text(
"SNES: $%04X", color.
snes());
99 ImGui::Text(
"Hex: #%02X%02X%02X",
static_cast<int>(rgb.x),
100 static_cast<int>(rgb.y),
static_cast<int>(rgb.z));
106 ImGui::TextDisabled(
"(GameData not loaded)");
111 if (!group || palette_index >= group->size()) {
112 ImGui::TextDisabled(
"(Palette not found)");
116 auto palette = group->palette(palette_index);
119 int preview_size = std::min(8,
static_cast<int>(palette.size()));
120 for (
int i = 0; i < preview_size; i++) {
126 ImGui::ColorButton(
"##preview", col,
127 ImGuiColorEditFlags_NoAlpha |
128 ImGuiColorEditFlags_NoPicker |
129 ImGuiColorEditFlags_NoTooltip,
132 if (ImGui::IsItemHovered()) {
133 ImGui::BeginTooltip();
134 ImGui::Text(
"Color %d", i);
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.
void DrawPalettePreview(const std::string &group_name, int palette_index, zelda3::GameData *game_data)
Draw a small palette preview (8 colors in a row)
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 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.
PaletteGroup * get_group(const std::string &group_name)
gfx::PaletteGroupMap palette_groups