3#include "absl/strings/str_cat.h"
4#include "absl/strings/str_format.h"
9#include "imgui/imgui.h"
14using ImGui::BeginChild;
15using ImGui::BeginGroup;
16using ImGui::BeginTable;
20using ImGui::GetContentRegionAvail;
25using ImGui::Selectable;
26using ImGui::Separator;
27using ImGui::SetNextItemWidth;
28using ImGui::TableHeadersRow;
29using ImGui::TableNextColumn;
30using ImGui::TableNextRow;
31using ImGui::TableSetupColumn;
34using gfx::kPaletteGroupNames;
43 Text(
"No ROM loaded. Please open a Zelda 3 ROM.");
44 return absl::OkStatus();
51 if (ImGui::IsItemHovered()) {
52 ImGui::SetTooltip(
"Show full 16-color palettes instead of 8");
57 if (BeginTable(
"##PalettesetLayout", 2,
58 ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable)) {
59 TableSetupColumn(
"Palettesets", ImGuiTableColumnFlags_WidthFixed, 200);
60 TableSetupColumn(
"Editor", ImGuiTableColumnFlags_WidthStretch);
73 return absl::OkStatus();
77 if (BeginChild(
"##PalettesetListChild", ImVec2(0, 400))) {
78 for (uint8_t idx = 0; idx < 72; idx++) {
81 std::string label = absl::StrFormat(
"0x%02X", idx);
85 std::string display_name = label;
92 if (Selectable(display_name.c_str(), is_selected)) {
108 std::string paletteset_label =
110 Text(
"%s", paletteset_label.c_str());
124 SetNextItemWidth(80.f);
127 Text(
"Index: %d", paletteset_ids[0]);
129 auto* dungeon_palette =
132 if (dungeon_palette) {
140 const char* sprite_labels[] = {
"Sprite Aux 1",
"Sprite Aux 2",
149 for (
int slot = 0; slot < 3; slot++) {
153 Text(
"%s %s", sprite_icons[slot], sprite_labels[slot]);
154 SetNextItemWidth(80.f);
157 Text(
"Index: %d", paletteset_ids[slot + 1]);
159 auto* sprite_palette =
161 if (sprite_palette) {
183 if (palette.
empty()) {
184 Text(
"(Empty palette)");
189 colors_to_show = std::min(colors_to_show, palette.
size());
191 for (
size_t color_idx = 0; color_idx < colors_to_show; color_idx++) {
192 PushID(
static_cast<int>(color_idx));
194 if ((color_idx % 8) != 0) {
195 SameLine(0.0f, GetStyle().ItemSpacing.y);
198 ImGuiColorEditFlags flags =
199 ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoTooltip;
201 flags |= ImGuiColorEditFlags_NoPicker;
205 palette[color_idx], flags)) {
209 if (ImGui::IsItemHovered()) {
210 auto& color = palette[color_idx];
211 ImGui::SetTooltip(
"Color %zu\nRGB: %d, %d, %d\nSNES: $%04X", color_idx,
212 color.rom_color().red, color.rom_color().green,
213 color.rom_color().blue, color.snes());
221 Text(
"(+%zu more)", palette.
size() - 8);
project::ResourceLabelManager * resource_label()
zelda3::GameData * game_data() const
uint8_t selected_paletteset_
void DrawPaletteGrid(gfx::SnesPalette &palette, bool editable=false)
void DrawPalettesetEditor()
void DrawPalettesetList()
void Draw(bool *p_open) override
Draw the panel content.
void DrawPalettePreview(gfx::SnesPalette &palette, const char *label)
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
#define ICON_MD_LANDSCAPE
#define ICON_MD_SMART_TOY
IMGUI_API bool SnesColorButton(absl::string_view id, gfx::SnesColor &color, ImGuiColorEditFlags flags, const ImVec2 &size_arg)
bool InputHexByte(const char *label, uint8_t *data, float input_width, bool no_step)
PaletteGroup sprites_aux1
PaletteGroup sprites_aux2
PaletteGroup sprites_aux3
PaletteGroup dungeon_main
Represents a group of palettes.
auto mutable_palette(int i)
void SelectableLabelWithNameEdit(bool selected, const std::string &type, const std::string &key, const std::string &defaultValue)
std::array< std::array< uint8_t, 4 >, kNumPalettesets > paletteset_ids
gfx::PaletteGroupMap palette_groups