From ea6d8f9636b9c68d1ab5837b328c0de964477d07 Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 14 Jan 2024 11:15:48 -0500 Subject: [PATCH] SpriteEditor skeleton --- src/app/editor/sprite_editor.cc | 60 ++++++++++++++++++++++++++++++++- src/app/editor/sprite_editor.h | 16 +++++++-- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/src/app/editor/sprite_editor.cc b/src/app/editor/sprite_editor.cc index ba3d2a53..94f778b9 100644 --- a/src/app/editor/sprite_editor.cc +++ b/src/app/editor/sprite_editor.cc @@ -4,7 +4,65 @@ namespace yaze { namespace app { namespace editor { -absl::Status SpriteEditor::Update() { return absl::OkStatus(); } +using ImGui::Button; +using ImGui::Separator; +using ImGui::TableHeadersRow; +using ImGui::TableNextColumn; +using ImGui::TableNextRow; +using ImGui::TableSetupColumn; +using ImGui::Text; + +absl::Status SpriteEditor::Update() { + if (rom()->isLoaded() && !sheets_loaded_) { + // Load the values for current_sheets_ array + + sheets_loaded_ = true; + } + + // if (ImGui::BeginTable({"Canvas", "Graphics"}, 2, nullptr, ImVec2(0, 0))) { + // TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch, + // ImGui::GetContentRegionAvail().x); + // TableSetupColumn("Tile Selector", ImGuiTableColumnFlags_WidthFixed, 256); + // TableHeadersRow(); + // TableNextRow(); + // TableNextColumn(); + // DrawSpriteCanvas(); + + // TableNextColumn(); + // if (sheets_loaded_) { + // DrawCurrentSheets(); + // } + + // ImGui::EndTable(); + // } + + return absl::OkStatus(); +} + +void SpriteEditor::DrawEditorTable() {} + +void SpriteEditor::DrawSpriteCanvas() {} + +void SpriteEditor::DrawCurrentSheets() { + static gui::Canvas graphics_sheet_canvas; + for (int i = 0; i < 8; i++) { + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); + if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)7); + ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true, + ImGuiWindowFlags_AlwaysVerticalScrollbar | + ImGuiWindowFlags_AlwaysHorizontalScrollbar)) { + graphics_sheet_canvas.DrawBackground(ImVec2(0x200 * 8, 0x200 * 8)); + ImGui::PopStyleVar(2); + graphics_sheet_canvas.DrawContextMenu(); + graphics_sheet_canvas.DrawBitmap( + *rom()->bitmap_manager()[current_sheets_[i]], 2, 2); + graphics_sheet_canvas.DrawGrid(64.0f); + graphics_sheet_canvas.DrawOverlay(); + } + ImGui::EndChild(); + } +} } // namespace editor } // namespace app diff --git a/src/app/editor/sprite_editor.h b/src/app/editor/sprite_editor.h index 4bee1ae2..ae5cb0c0 100644 --- a/src/app/editor/sprite_editor.h +++ b/src/app/editor/sprite_editor.h @@ -2,14 +2,24 @@ #define YAZE_APP_EDITOR_SPRITE_EDITOR_H #include "absl/status/status.h" +#include "app/gui/canvas.h" +#include "app/rom.h" namespace yaze { namespace app { namespace editor { -class SpriteEditor { - public: - absl::Status Update(); +class SpriteEditor : public SharedROM { + public: + absl::Status Update(); + + private: + void DrawEditorTable(); + void DrawSpriteCanvas(); + void DrawCurrentSheets(); + + uint8_t current_sheets_[8]; + bool sheets_loaded_ = false; }; } // namespace editor