3#include "absl/status/status.h"
4#include "absl/strings/str_cat.h"
11#include "imgui/imgui.h"
16using ImGui::BeginChild;
17using ImGui::BeginGroup;
18using ImGui::BeginTabBar;
19using ImGui::BeginTabItem;
20using ImGui::BeginTable;
23using ImGui::EndTabBar;
24using ImGui::EndTabItem;
26using ImGui::GetContentRegionAvail;
28using ImGui::IsItemClicked;
32using ImGui::Separator;
33using ImGui::SetNextItemWidth;
34using ImGui::TableHeadersRow;
35using ImGui::TableNextColumn;
36using ImGui::TableNextRow;
37using ImGui::TableSetupColumn;
40using gfx::kPaletteGroupNames;
44 if (BeginTabBar(
"GfxGroupEditor")) {
45 if (BeginTabItem(
"Main")) {
55 if (BeginTabItem(
"Rooms")) {
64 if (BeginTabItem(
"Sprites")) {
75 if (BeginTabItem(
"Palettes")) {
83 return absl::OkStatus();
87 if (BeginTable(
"##BlocksetTable", sheet_only ? 1 : 2,
88 ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable,
91 TableSetupColumn(
"Inputs", ImGuiTableColumnFlags_WidthStretch,
92 GetContentRegionAvail().x);
95 TableSetupColumn(
"Sheets", ImGuiTableColumnFlags_WidthFixed, 256);
102 for (
int i = 0; i < 8; i++) {
103 SetNextItemWidth(100.f);
113 for (
int i = 0; i < 8; i++) {
117 0x20,
true,
false, 22);
126 Text(
"Values - Overwrites 4 of main blockset");
127 if (BeginTable(
"##Roomstable", 3,
128 ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable,
130 TableSetupColumn(
"List", ImGuiTableColumnFlags_WidthFixed, 100);
131 TableSetupColumn(
"Inputs", ImGuiTableColumnFlags_WidthStretch,
132 GetContentRegionAvail().x);
133 TableSetupColumn(
"Sheets", ImGuiTableColumnFlags_WidthFixed, 256);
139 BeginChild(
"##RoomsetList");
140 for (
int i = 0; i < 0x51; i++) {
142 std::string roomset_label = absl::StrFormat(
"0x%02X", i);
144 false,
"roomset", roomset_label,
"Roomset " + roomset_label);
145 if (IsItemClicked()) {
156 for (
int i = 0; i < 4; i++) {
157 SetNextItemWidth(100.f);
166 for (
int i = 0; i < 4; i++) {
170 0x20,
true,
false, 23);
179 if (BeginTable(
"##SpritesTable", sheet_only ? 1 : 2,
180 ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable,
183 TableSetupColumn(
"Inputs", ImGuiTableColumnFlags_WidthStretch,
184 GetContentRegionAvail().x);
186 TableSetupColumn(
"Sheets", ImGuiTableColumnFlags_WidthFixed, 256);
193 for (
int i = 0; i < 4; i++) {
194 SetNextItemWidth(100.f);
204 for (
int i = 0; i < 4; i++) {
209 0x20,
true,
false, 24);
219 if (palette.
empty()) {
222 for (
size_t n = 0; n < palette.
size(); n++) {
224 if ((n % 8) != 0) SameLine(0.0f, GetStyle().ItemSpacing.y);
228 ImGuiColorEditFlags_NoAlpha |
229 ImGuiColorEditFlags_NoPicker |
230 ImGuiColorEditFlags_NoTooltip)) {
239 if (!
rom()->is_loaded()) {
250 uint8_t &dungeon_main_palette_val =
252 uint8_t &dungeon_spr_pal_1_val =
254 uint8_t &dungeon_spr_pal_2_val =
256 uint8_t &dungeon_spr_pal_3_val =
262 false, kPaletteGroupNames[PaletteCategory::kDungeons].data(),
263 std::to_string(dungeon_main_palette_val),
"Unnamed dungeon palette");
266 DrawPaletteFromPaletteGroup(palette);
273 DrawPaletteFromPaletteGroup(spr_aux_pal1);
276 false, kPaletteGroupNames[PaletteCategory::kSpritesAux1].data(),
277 std::to_string(dungeon_spr_pal_1_val),
"Dungeon Spr Pal 1");
284 DrawPaletteFromPaletteGroup(spr_aux_pal2);
287 false, kPaletteGroupNames[PaletteCategory::kSpritesAux2].data(),
288 std::to_string(dungeon_spr_pal_2_val),
"Dungeon Spr Pal 2");
295 DrawPaletteFromPaletteGroup(spr_aux_pal3);
298 false, kPaletteGroupNames[PaletteCategory::kSpritesAux3].data(),
299 std::to_string(dungeon_spr_pal_3_val),
"Dungeon Spr Pal 3");
auto mutable_palette_group()
std::array< std::array< uint8_t, 4 >, kNumSpritesets > spriteset_ids
ResourceLabelManager * resource_label()
std::array< std::array< uint8_t, 4 >, kNumPalettesets > paletteset_ids
std::array< std::array< uint8_t, 4 >, kNumRoomBlocksets > room_blockset_ids
std::array< std::array< uint8_t, 8 >, kNumMainBlocksets > main_blockset_ids
uint8_t selected_blockset_
uint8_t selected_spriteset_
gui::Canvas roomset_canvas_
uint8_t selected_paletteset_
uint8_t selected_roomset_
gui::Canvas spriteset_canvas_
void DrawSpritesetViewer(bool sheet_only=false)
gui::Canvas blockset_canvas_
void DrawBlocksetViewer(bool sheet_only=false)
auto mutable_gfx_sheets()
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
void DrawPaletteFromPaletteGroup(gfx::SnesPalette &palette)
Editors are the view controllers for the application.
void BitmapCanvasPipeline(gui::Canvas &canvas, gfx::Bitmap &bitmap, int width, int height, int tile_size, bool is_loaded, bool scrollbar, int canvas_id)
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)
Main namespace for the application.
void SelectableLabelWithNameEdit(bool selected, const std::string &type, const std::string &key, const std::string &defaultValue)