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;
39 Text(
"No ROM loaded. Please open a Zelda 3 ROM.");
40 return absl::OkStatus();
47 if (ImGui::IsItemHovered()) {
48 ImGui::SetTooltip(
"Show full 16-color palettes instead of 8");
53 if (BeginTable(
"##PalettesetLayout", 2,
54 ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable)) {
55 TableSetupColumn(
"Palettesets", ImGuiTableColumnFlags_WidthFixed, 200);
56 TableSetupColumn(
"Editor", ImGuiTableColumnFlags_WidthStretch);
69 return absl::OkStatus();
73 if (BeginChild(
"##PalettesetListChild", ImVec2(0, 400))) {
74 for (uint8_t idx = 0; idx < 72; idx++) {
77 std::string label = absl::StrFormat(
"0x%02X", idx);
81 std::string display_name = label;
88 if (Selectable(display_name.c_str(), is_selected)) {
104 std::string paletteset_label =
106 Text(
"%s", paletteset_label.c_str());
120 SetNextItemWidth(80.f);
123 Text(
"Index: %d", paletteset_ids[0]);
125 auto* dungeon_palette =
128 if (dungeon_palette) {
136 const char* sprite_labels[] = {
"Sprite Aux 1",
"Sprite Aux 2",
145 for (
int slot = 0; slot < 3; slot++) {
149 Text(
"%s %s", sprite_icons[slot], sprite_labels[slot]);
150 SetNextItemWidth(80.f);
153 Text(
"Index: %d", paletteset_ids[slot + 1]);
155 auto* sprite_palette =
157 if (sprite_palette) {
179 if (palette.
empty()) {
180 Text(
"(Empty palette)");
185 colors_to_show = std::min(colors_to_show, palette.
size());
187 for (
size_t color_idx = 0; color_idx < colors_to_show; color_idx++) {
188 PushID(
static_cast<int>(color_idx));
190 if ((color_idx % 8) != 0) {
191 SameLine(0.0f, GetStyle().ItemSpacing.y);
194 ImGuiColorEditFlags flags = ImGuiColorEditFlags_NoAlpha |
195 ImGuiColorEditFlags_NoTooltip;
197 flags |= ImGuiColorEditFlags_NoPicker;
201 palette[color_idx], flags)) {
205 if (ImGui::IsItemHovered()) {
206 auto& color = palette[color_idx];
207 ImGui::SetTooltip(
"Color %zu\nRGB: %d, %d, %d\nSNES: $%04X",
208 color_idx, color.rom_color().red, color.rom_color().green, color.rom_color().blue,
217 Text(
"(+%zu more)", palette.
size() - 8);
project::ResourceLabelManager * resource_label()
void DrawPalettesetEditor()
zelda3::GameData * game_data() const
uint8_t selected_paletteset_
void DrawPaletteGrid(gfx::SnesPalette &palette, bool editable=false)
void DrawPalettePreview(gfx::SnesPalette &palette, const char *label)
void DrawPalettesetList()
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