Skip to content

Commit

Permalink
ui: show boxart cover when starting a game
Browse files Browse the repository at this point in the history
  • Loading branch information
flyinghead committed Dec 14, 2024
1 parent 20517cf commit 8257784
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
27 changes: 21 additions & 6 deletions core/ui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> 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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion core/ui/gui_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 8257784

Please sign in to comment.