3#include "absl/strings/str_format.h"
8#include "imgui/imgui.h"
13namespace palette_utility {
17 bool clicked = ImGui::SmallButton(
20 if (ImGui::IsItemHovered()) {
21 ImGui::SetTooltip(
"Jump to palette editor:\n%s - Palette %d",
22 group_name.c_str(), palette_index);
25 if (clicked && editor) {
33 const std::string& group_name,
int palette_index,
39 bool changed = ImGui::ColorEdit4(
41 ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
51 ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
59 if (ImGui::IsItemHovered()) {
60 ImGui::BeginTooltip();
61 ImGui::Text(
"Jump to Palette Editor");
62 ImGui::TextDisabled(
"%s - Palette %d, Color %d", group_name.c_str(),
63 palette_index, color_index);
73 const std::string& group_name,
78 bool changed = ImGui::InputInt(label, palette_id);
83 if (*palette_id > 255)
97 auto rgb = color.
rgb();
99 ImGui::Text(
"RGB: (%d, %d, %d)",
static_cast<int>(rgb.x),
100 static_cast<int>(rgb.y),
static_cast<int>(rgb.z));
101 ImGui::Text(
"SNES: $%04X", color.
snes());
102 ImGui::Text(
"Hex: #%02X%02X%02X",
static_cast<int>(rgb.x),
103 static_cast<int>(rgb.y),
static_cast<int>(rgb.z));
109 ImGui::TextDisabled(
"(GameData not loaded)");
114 if (!group || palette_index >= group->size()) {
115 ImGui::TextDisabled(
"(Palette not found)");
119 auto palette = group->palette(palette_index);
122 int preview_size = std::min(8,
static_cast<int>(palette.size()));
123 for (
int i = 0; i < preview_size; i++) {
129 ImGui::ColorButton(
"##preview", col,
130 ImGuiColorEditFlags_NoAlpha |
131 ImGuiColorEditFlags_NoPicker |
132 ImGuiColorEditFlags_NoTooltip,
135 if (ImGui::IsItemHovered()) {
136 ImGui::BeginTooltip();
137 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.
RAII guard for ImGui style colors.
#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