4#include "absl/strings/str_cat.h"
5#include "absl/strings/str_format.h"
10#include "imgui/imgui.h"
15using ImGui::BeginChild;
16using ImGui::BeginGroup;
17using ImGui::BeginTable;
21using ImGui::GetContentRegionAvail;
26using ImGui::Selectable;
27using ImGui::Separator;
28using ImGui::SetNextItemWidth;
29using ImGui::TableHeadersRow;
30using ImGui::TableNextColumn;
31using ImGui::TableNextRow;
32using ImGui::TableSetupColumn;
35using gfx::kPaletteGroupNames;
44 Text(tr(
"No ROM loaded. Please open a Zelda 3 ROM."));
45 return absl::OkStatus();
52 if (ImGui::IsItemHovered()) {
53 ImGui::SetTooltip(tr(
"Show full 16-color palettes instead of 8"));
58 if (BeginTable(
"##PalettesetLayout", 2,
59 ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable)) {
60 TableSetupColumn(
"Palettesets", ImGuiTableColumnFlags_WidthFixed, 200);
61 TableSetupColumn(
"Editor", ImGuiTableColumnFlags_WidthStretch);
74 return absl::OkStatus();
78 if (BeginChild(
"##PalettesetListChild", ImVec2(0, 400))) {
79 for (uint8_t idx = 0; idx < 72; idx++) {
82 std::string label = absl::StrFormat(
"0x%02X", idx);
86 std::string display_name = label;
93 if (Selectable(display_name.c_str(), is_selected)) {
109 std::string paletteset_label =
111 Text(
"%s", paletteset_label.c_str());
125 SetNextItemWidth(80.f);
128 Text(tr(
"Index: %d"), paletteset_ids[0]);
130 auto* dungeon_palette =
133 if (dungeon_palette) {
141 const char* sprite_labels[] = {
"Sprite Aux 1",
"Sprite Aux 2",
150 for (
int slot = 0; slot < 3; slot++) {
154 Text(
"%s %s", sprite_icons[slot], sprite_labels[slot]);
155 SetNextItemWidth(80.f);
158 Text(tr(
"Index: %d"), paletteset_ids[slot + 1]);
160 auto* sprite_palette =
162 if (sprite_palette) {
184 if (palette.
empty()) {
185 Text(tr(
"(Empty palette)"));
190 colors_to_show = std::min(colors_to_show, palette.
size());
192 for (
size_t color_idx = 0; color_idx < colors_to_show; color_idx++) {
193 PushID(
static_cast<int>(color_idx));
195 if ((color_idx % 8) != 0) {
196 SameLine(0.0f, GetStyle().ItemSpacing.y);
199 ImGuiColorEditFlags flags =
200 ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoTooltip;
202 flags |= ImGuiColorEditFlags_NoPicker;
206 palette[color_idx], flags)) {
210 if (ImGui::IsItemHovered()) {
211 auto& color = palette[color_idx];
212 ImGui::SetTooltip(tr(
"Color %zu\nRGB: %d, %d, %d\nSNES: $%04X"),
213 color_idx, color.rom_color().red,
214 color.rom_color().green, color.rom_color().blue,
223 Text(tr(
"(+%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