diff --git a/src/app/core/pipeline.cc b/src/app/core/pipeline.cc index 1a44a894..bb134f33 100644 --- a/src/app/core/pipeline.cc +++ b/src/app/core/pipeline.cc @@ -19,6 +19,37 @@ namespace yaze { namespace app { namespace core { +void GraphicsBinCanvasPipeline(int width, int height, int tile_size, + int num_sheets_to_load, int canvas_id, + bool is_loaded, gfx::BitmapTable& graphics_bin) { + gui::Canvas canvas; + + if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)canvas_id); + ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true, + ImGuiWindowFlags_AlwaysVerticalScrollbar)) { + canvas.DrawBackground(ImVec2(width + 1, num_sheets_to_load * height + 1)); + canvas.DrawContextMenu(); + if (is_loaded) { + for (const auto& [key, value] : graphics_bin) { + int offset = height * (key + 1); + int top_left_y = canvas.GetZeroPoint().y + 2; + if (key >= 1) { + top_left_y = canvas.GetZeroPoint().y + height * key; + } + canvas.GetDrawList()->AddImage( + (void*)value.texture(), + ImVec2(canvas.GetZeroPoint().x + 2, top_left_y), + ImVec2(canvas.GetZeroPoint().x + 0x100, + canvas.GetZeroPoint().y + offset)); + } + } + canvas.DrawTileSelector(tile_size); + canvas.DrawGrid(tile_size); + canvas.DrawOverlay(); + } + ImGui::EndChild(); +} + void ButtonPipe(absl::string_view button_text, std::function callback) { if (ImGui::Button(button_text.data())) { callback(); diff --git a/src/app/core/pipeline.h b/src/app/core/pipeline.h index 156aa0be..c602f70f 100644 --- a/src/app/core/pipeline.h +++ b/src/app/core/pipeline.h @@ -19,6 +19,10 @@ namespace yaze { namespace app { namespace core { +void GraphicsBinCanvasPipeline(int width, int height, int tile_size, + int num_sheets_to_load, int canvas_id, + bool is_loaded, gfx::BitmapTable& graphics_bin); + void ButtonPipe(absl::string_view button_text, std::function callback); void BitmapCanvasPipeline(int width, int height, int tile_size, int canvas_id, diff --git a/src/app/editor/graphics_editor.cc b/src/app/editor/graphics_editor.cc index bb705e74..6abfdc2c 100644 --- a/src/app/editor/graphics_editor.cc +++ b/src/app/editor/graphics_editor.cc @@ -252,30 +252,8 @@ absl::Status GraphicsEditor::DrawMemoryEditor() { } absl::Status GraphicsEditor::DrawGraphicsBin() { - if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)3); - ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true, - ImGuiWindowFlags_AlwaysVerticalScrollbar)) { - super_donkey_canvas_.DrawBackground( - ImVec2(0x100 + 1, num_sheets_to_load_ * 0x40 + 1)); - super_donkey_canvas_.DrawContextMenu(); - if (super_donkey_) { - for (const auto& [key, value] : graphics_bin_) { - int offset = 0x40 * (key + 1); - int top_left_y = super_donkey_canvas_.GetZeroPoint().y + 2; - if (key >= 1) { - top_left_y = super_donkey_canvas_.GetZeroPoint().y + 0x40 * key; - } - super_donkey_canvas_.GetDrawList()->AddImage( - (void*)value.texture(), - ImVec2(super_donkey_canvas_.GetZeroPoint().x + 2, top_left_y), - ImVec2(super_donkey_canvas_.GetZeroPoint().x + 0x100, - super_donkey_canvas_.GetZeroPoint().y + offset)); - } - } - super_donkey_canvas_.DrawGrid(16.0f); - super_donkey_canvas_.DrawOverlay(); - } - ImGui::EndChild(); + core::GraphicsBinCanvasPipeline(0x100, 0x40, 0x20, num_sheets_to_load_, 3, + super_donkey_, graphics_bin_); return absl::OkStatus(); } diff --git a/src/app/editor/graphics_editor.h b/src/app/editor/graphics_editor.h index fb501175..c6ddb791 100644 --- a/src/app/editor/graphics_editor.h +++ b/src/app/editor/graphics_editor.h @@ -20,17 +20,16 @@ namespace yaze { namespace app { namespace editor { - // "99973","A3D80", +// "99973","A3D80", - // +// const std::string kSuperDonkeyTiles[] = { - "97C05", "98219", "9871E", "98C00", "99084", "995AF", - "99DE0", "9A27E", "9A741", "9AC31", "9B07E", "9B55C", "9B963", - "9BB99", "9C009", "9C4B4", "9C92B", "9CDD6", "9D2C2", "9E037", - "9E527", "9EA56", "9EF65", "9FCD1", "A0193", "A059E", "A0B17", - "A0FB6", "A14A5", "A1988", "A1E66", "A232B", "A27F0", "A2B6E", - "A302C", "A3453", "A38CA", "A42BB", "A470C", "A4BA9", + "97C05", "98219", "9871E", "98C00", "99084", "995AF", "99DE0", "9A27E", + "9A741", "9AC31", "9B07E", "9B55C", "9B963", "9BB99", "9C009", "9C4B4", + "9C92B", "9CDD6", "9D2C2", "9E037", "9E527", "9EA56", "9EF65", "9FCD1", + "A0193", "A059E", "A0B17", "A0FB6", "A14A5", "A1988", "A1E66", "A232B", + "A27F0", "A2B6E", "A302C", "A3453", "A38CA", "A42BB", "A470C", "A4BA9", "A5089", "A5385", "A5742", "A5BCC", "A6017", "A6361", "A66F8"}; const std::string kSuperDonkeySprites[] = { @@ -125,6 +124,8 @@ class GraphicsEditor { gui::Canvas super_donkey_canvas_; gfx::BitmapTable graphics_bin_; + gfx::BitmapTable clipboard_graphics_bin_; + gfx::SNESPalette palette_; gfx::SNESPalette col_file_palette_;