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;
40 Text(tr(
"No ROM loaded. Please open a Zelda 3 ROM."));
41 return absl::OkStatus();
48 if (ImGui::IsItemHovered()) {
49 ImGui::SetTooltip(tr(
"Show full 16-color palettes instead of 8"));
54 if (BeginTable(
"##PalettesetLayout", 2,
55 ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable)) {
56 TableSetupColumn(
"Palettesets", ImGuiTableColumnFlags_WidthFixed, 200);
57 TableSetupColumn(
"Editor", ImGuiTableColumnFlags_WidthStretch);
70 return absl::OkStatus();
74 if (BeginChild(
"##PalettesetListChild", ImVec2(0, 400))) {
75 for (uint8_t idx = 0; idx < 72; idx++) {
78 std::string label = absl::StrFormat(
"0x%02X", idx);
82 std::string display_name = label;
89 if (Selectable(display_name.c_str(), is_selected)) {
105 std::string paletteset_label =
107 Text(
"%s", paletteset_label.c_str());
121 SetNextItemWidth(80.f);
124 Text(tr(
"Index: %d"), paletteset_ids[0]);
126 auto* dungeon_palette =
129 if (dungeon_palette) {
137 const char* sprite_labels[] = {
"Sprite Aux 1",
"Sprite Aux 2",
146 for (
int slot = 0; slot < 3; slot++) {
150 Text(
"%s %s", sprite_icons[slot], sprite_labels[slot]);
151 SetNextItemWidth(80.f);
154 Text(tr(
"Index: %d"), paletteset_ids[slot + 1]);
156 auto* sprite_palette =
158 if (sprite_palette) {
180 if (palette.
empty()) {
181 Text(tr(
"(Empty palette)"));
186 colors_to_show = std::min(colors_to_show, palette.
size());
188 for (
size_t color_idx = 0; color_idx < colors_to_show; color_idx++) {
189 PushID(
static_cast<int>(color_idx));
191 if ((color_idx % 8) != 0) {
192 SameLine(0.0f, GetStyle().ItemSpacing.y);
195 ImGuiColorEditFlags flags =
196 ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoTooltip;
198 flags |= ImGuiColorEditFlags_NoPicker;
202 palette[color_idx], flags)) {
206 if (ImGui::IsItemHovered()) {
207 auto& color = palette[color_idx];
208 ImGui::SetTooltip(tr(
"Color %zu\nRGB: %d, %d, %d\nSNES: $%04X"),
209 color_idx, color.rom_color().red,
210 color.rom_color().green, color.rom_color().blue,
219 Text(tr(
"(+%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