13using ImGui::BeginTable;
16using ImGui::Selectable;
17using ImGui::Separator;
18using ImGui::TableHeadersRow;
19using ImGui::TableNextColumn;
20using ImGui::TableNextRow;
21using ImGui::TableSetupColumn;
30 if (ImGui::BeginTabBar(
"##SpriteEditorTabs")) {
31 if (ImGui::BeginTabItem(
"Vanilla")) {
35 if (ImGui::BeginTabItem(
"Custom")) {
46 if (ImGui::BeginTable(
"##SpriteCanvasTable", 3, ImGuiTableFlags_Resizable,
48 TableSetupColumn(
"Sprites List", ImGuiTableColumnFlags_WidthFixed, 256);
49 TableSetupColumn(
"Canvas", ImGuiTableColumnFlags_WidthStretch,
50 ImGui::GetContentRegionAvail().x);
51 TableSetupColumn(
"Tile Selector", ImGuiTableColumnFlags_WidthFixed, 256);
59 static int next_tab_id = 0;
80 if (ImGui::BeginTabItem(
82 ImGuiTabItemFlags_None)) {
105 static bool flip_x =
false;
106 static bool flip_y =
false;
107 if (ImGui::BeginChild(
gui::GetID(
"##SpriteCanvas"),
108 ImGui::GetContentRegionAvail(),
true)) {
116 if (ImGui::BeginTable(
"##OAMTable", 7, ImGuiTableFlags_Resizable,
118 TableSetupColumn(
"X", ImGuiTableColumnFlags_WidthStretch);
119 TableSetupColumn(
"Y", ImGuiTableColumnFlags_WidthStretch);
120 TableSetupColumn(
"Tile", ImGuiTableColumnFlags_WidthStretch);
121 TableSetupColumn(
"Palette", ImGuiTableColumnFlags_WidthStretch);
122 TableSetupColumn(
"Priority", ImGuiTableColumnFlags_WidthStretch);
123 TableSetupColumn(
"Flip X", ImGuiTableColumnFlags_WidthStretch);
124 TableSetupColumn(
"Flip Y", ImGuiTableColumnFlags_WidthStretch);
144 if (ImGui::Checkbox(
"##XFlip", &flip_x)) {
149 if (ImGui::Checkbox(
"##YFlip", &flip_y)) {
165 if (ImGui::BeginChild(
gui::GetID(
"sheet_label"),
166 ImVec2(ImGui::GetContentRegionAvail().x, 0),
true,
167 ImGuiWindowFlags_NoDecoration)) {
168 for (
int i = 0; i < 8; i++) {
169 std::string sheet_label = absl::StrFormat(
"Sheet %d", i);
171 if (i % 2 == 0) ImGui::SameLine();
177 for (
int i = 0; i < 8; i++) {
188 if (ImGui::BeginChild(
gui::GetID(
"##SpritesList"),
189 ImVec2(ImGui::GetContentRegionAvail().x, 0),
true,
190 ImGuiWindowFlags_NoDecoration)) {
192 for (
const auto each_sprite_name : zelda3::kSpriteDefaultNames) {
193 rom()->resource_label()->SelectableLabelWithNameEdit(
195 zelda3::kSpriteDefaultNames[i].data());
196 if (ImGui::IsItemClicked()) {
209 if (ImGui::Button(
"Add Frame")) {
212 if (ImGui::Button(
"Remove Frame")) {
218 if (BeginTable(
"##CustomSpritesTable", 3,
219 ImGuiTableFlags_Resizable | ImGuiTableFlags_Borders |
220 ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable,
222 TableSetupColumn(
"Metadata", ImGuiTableColumnFlags_WidthFixed, 256);
223 TableSetupColumn(
"Canvas", ImGuiTableColumnFlags_WidthFixed, 256);
224 TableSetupColumn(
"TIlesheets", ImGuiTableColumnFlags_WidthFixed, 256);
245 if (ImGui::Button(
"Open ZSprite")) {
248 if (!file_path.empty()) {
258 Selectable(
"%s", custom_sprite.sprName.c_str());
259 if (ImGui::IsItemClicked()) {
270 Text(
"Sprite ID: %s", custom_sprite.property_sprid.Text.c_str());
271 Text(
"Sprite Name: %s", custom_sprite.property_sprname.Text.c_str());
272 Text(
"Sprite Palette: %s", custom_sprite.property_palette.Text.c_str());
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath.
gui::Canvas sprite_canvas_
void DrawSpritesList()
Draws the sprites list.
void DrawAnimationFrames()
Draws the animation frames manager.
gui::Canvas graphics_sheet_canvas_
void DrawCustomSpritesMetadata()
void DrawVanillaSpriteEditor()
void DrawSpriteCanvas()
Draws the sprite canvas.
ImVector< int > active_sprites_
std::vector< zsprite::ZSprite > custom_sprites_
void DrawCurrentSheets()
Draws the current sheets.
absl::Status Update() override
Updates the sprite editor.
uint8_t current_sheets_[8]
bool DrawTileSelector(int size)
void DrawBackground(ImVec2 canvas_size=ImVec2(0, 0), bool drag=false)
void DrawGrid(float grid_step=64.0f, int tile_id_offset=8)
void DrawBitmap(const Bitmap &bitmap, int border_offset=0, bool ready=true)
void DrawContextMenu(gfx::Bitmap *bitmap=nullptr)
std::string UppercaseHexByte(uint8_t byte, bool leading)
constexpr ImGuiTabBarFlags kSpriteTabBarFlags
bool InputHexByte(const char *label, uint8_t *data, float input_width, bool no_step)
ImGuiID GetID(const std::string &id)
bool InputHexWord(const char *label, uint16_t *data, float input_width, bool no_step)
absl::Status Load(const std::string &filename)