From b3a6eafe8b44943e82683abd8aed160bada559fa Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 11 Nov 2023 19:00:58 -0500 Subject: [PATCH] Add `GfxGroupEditor` --- src/CMakeLists.txt | 1 + src/app/editor/modules/gfx_group_editor.cc | 109 +++++++++++++++++++++ src/app/editor/modules/gfx_group_editor.h | 53 ++++++++++ 3 files changed, 163 insertions(+) create mode 100644 src/app/editor/modules/gfx_group_editor.cc create mode 100644 src/app/editor/modules/gfx_group_editor.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06148197..5f695980 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,6 +18,7 @@ set( app/editor/screen_editor.cc app/editor/sprite_editor.cc app/editor/modules/tile16_editor.cc + app/editor/modules/gfx_group_editor.cc ) set( diff --git a/src/app/editor/modules/gfx_group_editor.cc b/src/app/editor/modules/gfx_group_editor.cc new file mode 100644 index 00000000..c0702111 --- /dev/null +++ b/src/app/editor/modules/gfx_group_editor.cc @@ -0,0 +1,109 @@ +#include "gfx_group_editor.h" + +#include + +#include + +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "app/core/editor.h" +#include "app/core/pipeline.h" +#include "app/editor/palette_editor.h" +#include "app/gfx/bitmap.h" +#include "app/gfx/snes_palette.h" +#include "app/gfx/snes_tile.h" +#include "app/gui/canvas.h" +#include "app/gui/icons.h" +#include "app/gui/input.h" +#include "app/gui/widgets.h" +#include "app/rom.h" +#include "app/zelda3/overworld.h" + +namespace yaze { +namespace app { +namespace editor { + +using ImGui::SameLine; + +absl::Status GfxGroupEditor::Update() { + if (ImGui::BeginTabBar("GfxGroupEditor")) { + // Main tab + if (ImGui::BeginTabItem("Main")) { + gui::InputHexByte("Selected Blockset", &selected_blockset_); + + ImGui::Text("Values"); + + if (ImGui::BeginTable("##BlocksetTable", 2, ImGuiTableFlags_Borders, + ImVec2(0, 0))) { + ImGui::TableSetupColumn("Inputs", ImGuiTableColumnFlags_WidthStretch, + ImGui::GetContentRegionAvail().x); + ImGui::TableSetupColumn("Sheets", ImGuiTableColumnFlags_WidthFixed, + 256); + ImGui::TableHeadersRow(); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + { + ImGui::BeginGroup(); + for (int i = 0; i < 8; i++) { + ImGui::SetNextItemWidth(100.f); + gui::InputHexByte(("##blockset0" + std::to_string(i)).c_str(), + &rom()->main_blockset_ids[selected_blockset_][i]); + if (i != 3 && i != 7) { + SameLine(); + } + } + ImGui::EndGroup(); + } + ImGui::TableNextColumn(); + { + ImGui::BeginGroup(); + for (int i = 0; i < 8; i++) { + auto sheet_id = rom()->main_blockset_ids[selected_blockset_][i]; + core::BitmapCanvasPipeline(blockset_canvas_, + graphics_bin_[sheet_id], 256, + 0x10 * 0x04, 0x20, true, false, 0); + } + ImGui::EndGroup(); + } + ImGui::EndTable(); + } + + ImGui::EndTabItem(); + } + + // Rooms tab + if (ImGui::BeginTabItem("Rooms")) { + ImGui::EndTabItem(); + } + + // Sprites tab + if (ImGui::BeginTabItem("Sprites")) { + ImGui::EndTabItem(); + } + + // Palettes tab + if (ImGui::BeginTabItem("Palettes")) { + ImGui::EndTabItem(); + } + + ImGui::EndTabBar(); + } + + ImGui::Separator(); + ImGui::Text("Palette: "); + ImGui::InputInt("##PreviewPaletteID", &preview_palette_id_); + + return absl::OkStatus(); +} + +void GfxGroupEditor::InitBlockset(gfx::Bitmap tile16_blockset, + gfx::BitmapTable graphics_bin, + gfx::SNESPalette palette) { + tile16_blockset_bmp_ = tile16_blockset; + graphics_bin_ = graphics_bin; + palette_ = palette; +} + +} // namespace editor +} // namespace app +} // namespace yaze diff --git a/src/app/editor/modules/gfx_group_editor.h b/src/app/editor/modules/gfx_group_editor.h new file mode 100644 index 00000000..2757700b --- /dev/null +++ b/src/app/editor/modules/gfx_group_editor.h @@ -0,0 +1,53 @@ +#ifndef YAZE_APP_EDITOR_GFX_GROUP_EDITOR_H +#define YAZE_APP_EDITOR_GFX_GROUP_EDITOR_H + +#include + +#include + +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "app/core/editor.h" +#include "app/core/pipeline.h" +#include "app/editor/palette_editor.h" +#include "app/gfx/bitmap.h" +#include "app/gfx/snes_palette.h" +#include "app/gfx/snes_tile.h" +#include "app/gui/canvas.h" +#include "app/gui/icons.h" +#include "app/gui/widgets.h" +#include "app/rom.h" +#include "app/zelda3/overworld.h" + +namespace yaze { +namespace app { +namespace editor { + +class GfxGroupEditor : public SharedROM { + public: + absl::Status Update(); + + void InitBlockset(gfx::Bitmap tile16_blockset, gfx::BitmapTable graphics_bin, + gfx::SNESPalette palette); + + private: + int preview_palette_id_; + uint8_t selected_blockset_ = 0; + + gui::Canvas blockset_canvas_; + + gfx::SNESPalette palette_; + gfx::Bitmap tile16_blockset_bmp_; + gfx::BitmapTable graphics_bin_; + + std::vector tile16_individual_data_; + std::vector tile16_individual_; + + gui::widgets::BitmapViewer gfx_group_viewer_; + zelda3::Overworld overworld_; +}; + +} // namespace editor +} // namespace app +} // namespace yaze +#endif // YAZE_APP_EDITOR_GFX_GROUP_EDITOR_H \ No newline at end of file