From 825778445a4a671044cda9def44b714adfd1a629 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sat, 14 Dec 2024 16:54:18 +0100 Subject: [PATCH] ui: show boxart cover when starting a game --- core/ui/gui.cpp | 27 +++++++++++++++++++++------ core/ui/gui_util.h | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/core/ui/gui.cpp b/core/ui/gui.cpp index 44bd8d994..f29ff70ba 100644 --- a/core/ui/gui.cpp +++ b/core/ui/gui.cpp @@ -3436,14 +3436,28 @@ static void gui_display_onboarding() select_file_popup(title, &systemdir_selected_callback); } +static void drawBoxartBackground() +{ + GameMedia game; + game.path = settings.content.path; + game.fileName = settings.content.fileName; + GameBoxart art = boxart.getBoxart(game); + ImguiFileTexture tex(art.boxartPath); + ImDrawList *dl = ImGui::GetBackgroundDrawList(); + tex.draw(dl, ImVec2(0, 0), ImVec2(settings.display.width, settings.display.height), 1.f); +} + static std::future networkStatus; static void gui_network_start() { + drawBoxartBackground(); centerNextWindow(); - ImGui::SetNextWindowSize(ScaledVec2(330, 180)); + ImGui::SetNextWindowSize(ScaledVec2(330, 0)); + ImGui::SetNextWindowBgAlpha(0.8f); + ImguiStyleVar _1(ImGuiStyleVar_WindowPadding, ScaledVec2(20, 20)); - ImGui::Begin("##network", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize); + ImGui::Begin("##network", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize); ImguiStyleVar _(ImGuiStyleVar_FramePadding, ScaledVec2(20, 10)); ImGui::AlignTextToFramePadding(); @@ -3471,7 +3485,6 @@ static void gui_network_start() float currentwidth = ImGui::GetContentRegionAvail().x; ImGui::SetCursorPosX((currentwidth - uiScaled(100.f)) / 2.f + ImGui::GetStyle().WindowPadding.x); - ImGui::SetCursorPosY(uiScaled(126.f)); if (ImGui::Button("Cancel", ScaledVec2(100.f, 0)) && NetworkHandshake::instance != nullptr) { NetworkHandshake::instance->stop(); @@ -3490,10 +3503,13 @@ static void gui_network_start() static void gui_display_loadscreen() { + drawBoxartBackground(); centerNextWindow(); - ImGui::SetNextWindowSize(ScaledVec2(330, 180)); + ImGui::SetNextWindowSize(ScaledVec2(330, 0)); + ImGui::SetNextWindowBgAlpha(0.8f); + ImguiStyleVar _(ImGuiStyleVar_WindowPadding, ScaledVec2(20, 20)); - if (ImGui::Begin("##loading", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize)) + if (ImGui::Begin("##loading", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize)) { ImguiStyleVar _(ImGuiStyleVar_FramePadding, ScaledVec2(20, 10)); ImGui::AlignTextToFramePadding(); @@ -3531,7 +3547,6 @@ static void gui_display_loadscreen() float currentwidth = ImGui::GetContentRegionAvail().x; ImGui::SetCursorPosX((currentwidth - uiScaled(100.f)) / 2.f + ImGui::GetStyle().WindowPadding.x); - ImGui::SetCursorPosY(uiScaled(126.f)); if (ImGui::Button("Cancel", ScaledVec2(100.f, 0))) gameLoader.cancel(); } diff --git a/core/ui/gui_util.h b/core/ui/gui_util.h index baadb4466..02520f77f 100644 --- a/core/ui/gui_util.h +++ b/core/ui/gui_util.h @@ -201,7 +201,7 @@ class ImguiTexture public: void draw(const ImVec2& size, const ImVec4& tint_col = ImVec4(1, 1, 1, 1), const ImVec4& border_col = ImVec4(0, 0, 0, 0)); - void draw(ImDrawList *drawList, const ImVec2& pos, const ImVec2& size, float alpha = 1.f); + void draw(ImDrawList *drawList, const ImVec2& pos, const ImVec2& size, float alpha); void draw(ImDrawList *drawList, const ImVec2& pos, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& color = ImVec4(1, 1, 1, 1)); bool button(const char* str_id, const ImVec2& image_size, const std::string& title = {}, const ImVec4& bg_col = ImVec4(0, 0, 0, 0),