From bcf581dc826574ca754ce726ff62bffc99dbcb3b Mon Sep 17 00:00:00 2001 From: Elad <18193363+elad335@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:29:09 +0200 Subject: [PATCH] Fixup Emulator::GetBackgroundPicturePath() --- rpcs3/Emu/System.cpp | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 2815ad6982..79ffbce8ad 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -739,18 +739,23 @@ std::string Emulator::GetBackgroundPicturePath() const disc_dir.clear(); } + constexpr auto search_barrier = "barrier"; + std::initializer_list testees = { - m_sfo_dir + "/ICON0.PNG", m_sfo_dir + "/PIC0.PNG", m_sfo_dir + "/PIC1.PNG", m_sfo_dir + "/PIC2.PNG", m_sfo_dir + "/PIC3.PNG", - disc_dir.empty() ? (disc_dir + "/ICON0.PNG") : disc_dir, - disc_dir.empty() ? (disc_dir + "/PIC0.PNG") : disc_dir, - disc_dir.empty() ? (disc_dir + "/PIC1.PNG") : disc_dir, - disc_dir.empty() ? (disc_dir + "/PIC2.PNG") : disc_dir, - disc_dir.empty() ? (disc_dir + "/PIC3.PNG") : disc_dir, + search_barrier, + !disc_dir.empty() ? (disc_dir + "/PIC0.PNG") : disc_dir, + !disc_dir.empty() ? (disc_dir + "/PIC1.PNG") : disc_dir, + !disc_dir.empty() ? (disc_dir + "/PIC2.PNG") : disc_dir, + !disc_dir.empty() ? (disc_dir + "/PIC3.PNG") : disc_dir, + search_barrier, + m_sfo_dir + "/ICON0.PNG", + search_barrier, + !disc_dir.empty() ? (disc_dir + "/ICON0.PNG") : disc_dir, }; // Try to return the picture with the highest resultion @@ -764,7 +769,18 @@ std::string Emulator::GetBackgroundPicturePath() const fs::stat_t file_stat{}; - if (path.empty() || !fs::get_stat(path, file_stat)) + if (path == search_barrier) + { + if (index_of_largest_file != umax) + { + // Found a file in the preferred image group + break; + } + + continue; + } + + if (path.empty() || !fs::get_stat(path, file_stat) || file_stat.is_directory) { continue; }