4#include "absl/strings/str_format.h"
9#include "imgui/imgui.h"
14namespace palette_utility {
18 bool clicked = ImGui::SmallButton(
21 if (ImGui::IsItemHovered()) {
22 ImGui::SetTooltip(tr(
"Jump to palette editor:\n%s - Palette %d"),
23 group_name.c_str(), palette_index);
26 if (clicked && editor) {
34 const std::string& group_name,
int palette_index,
40 bool changed = ImGui::ColorEdit4(
42 ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
52 ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
60 if (ImGui::IsItemHovered()) {
61 ImGui::BeginTooltip();
62 ImGui::Text(tr(
"Jump to Palette Editor"));
63 ImGui::TextDisabled(tr(
"%s - Palette %d, Color %d"), group_name.c_str(),
64 palette_index, color_index);
74 const std::string& group_name,
79 bool changed = ImGui::InputInt(label, palette_id);
84 if (*palette_id > 255)
98 auto rgb = color.
rgb();
100 ImGui::Text(tr(
"RGB: (%d, %d, %d)"),
static_cast<int>(rgb.x),
101 static_cast<int>(rgb.y),
static_cast<int>(rgb.z));
102 ImGui::Text(tr(
"SNES: $%04X"), color.
snes());
103 ImGui::Text(tr(
"Hex: #%02X%02X%02X"),
static_cast<int>(rgb.x),
104 static_cast<int>(rgb.y),
static_cast<int>(rgb.z));
110 ImGui::TextDisabled(tr(
"(GameData not loaded)"));
115 if (!group || palette_index >= group->size()) {
116 ImGui::TextDisabled(tr(
"(Palette not found)"));
120 auto palette = group->palette(palette_index);
123 int preview_size = std::min(8,
static_cast<int>(palette.size()));
124 for (
int i = 0; i < preview_size; i++) {
130 ImGui::ColorButton(
"##preview", col,
131 ImGuiColorEditFlags_NoAlpha |
132 ImGuiColorEditFlags_NoPicker |
133 ImGuiColorEditFlags_NoTooltip,
136 if (ImGui::IsItemHovered()) {
137 ImGui::BeginTooltip();
138 ImGui::Text(tr(
"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