Add GraphicsBinCanvasPipeline

This commit is contained in:
Justin Scofield
2023-08-02 19:12:57 -04:00
parent b3458b56db
commit e88b2a6d2f
4 changed files with 46 additions and 32 deletions

View File

@@ -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<void()> callback) {
if (ImGui::Button(button_text.data())) {
callback();