diff --git a/Source/Core/Common/CommonPaths.h b/Source/Core/Common/CommonPaths.h index 0f6b7adfb6..45d60aa435 100644 --- a/Source/Core/Common/CommonPaths.h +++ b/Source/Core/Common/CommonPaths.h @@ -89,6 +89,7 @@ #define GRAPHICSMOD_DIR "GraphicMods" #define WIISDSYNC_DIR "WiiSDSync" #define ASSEMBLY_DIR "SavedAssembly" +#define WIIBANNERS_DIR "WiiBanners" // This one is only used to remove it if it was present #define SHADERCACHE_LEGACY_DIR "ShaderCache" diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index 51a841ddec..c97218c37e 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -881,6 +881,7 @@ static void RebuildUserDirectories(unsigned int dir_index) s_user_paths[D_RESOURCEPACK_IDX] = s_user_paths[D_USER_IDX] + RESOURCEPACK_DIR DIR_SEP; s_user_paths[D_DYNAMICINPUT_IDX] = s_user_paths[D_LOAD_IDX] + DYNAMICINPUT_DIR DIR_SEP; s_user_paths[D_GRAPHICSMOD_IDX] = s_user_paths[D_LOAD_IDX] + GRAPHICSMOD_DIR DIR_SEP; + s_user_paths[D_BANNERS_WIIROOT_IDX] = s_user_paths[D_LOAD_IDX] + WIIBANNERS_DIR DIR_SEP; s_user_paths[D_WIISDCARDSYNCFOLDER_IDX] = s_user_paths[D_LOAD_IDX] + WIISDSYNC_DIR DIR_SEP; s_user_paths[F_DOLPHINCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + DOLPHIN_CONFIG; s_user_paths[F_GCPADCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + GCPAD_CONFIG; @@ -972,6 +973,7 @@ static void RebuildUserDirectories(unsigned int dir_index) s_user_paths[D_RIIVOLUTION_IDX] = s_user_paths[D_LOAD_IDX] + RIIVOLUTION_DIR DIR_SEP; s_user_paths[D_DYNAMICINPUT_IDX] = s_user_paths[D_LOAD_IDX] + DYNAMICINPUT_DIR DIR_SEP; s_user_paths[D_GRAPHICSMOD_IDX] = s_user_paths[D_LOAD_IDX] + GRAPHICSMOD_DIR DIR_SEP; + s_user_paths[D_BANNERS_WIIROOT_IDX] = s_user_paths[D_LOAD_IDX] + WIIBANNERS_DIR DIR_SEP; break; } } diff --git a/Source/Core/Common/FileUtil.h b/Source/Core/Common/FileUtil.h index a887ffd8f3..00d20b29b2 100644 --- a/Source/Core/Common/FileUtil.h +++ b/Source/Core/Common/FileUtil.h @@ -76,6 +76,7 @@ enum D_GPU_DRIVERS_HOOKS, D_GPU_DRIVERS_FILE_REDIRECT, D_ASM_ROOT_IDX, + D_BANNERS_WIIROOT_IDX, FIRST_FILE_USER_PATH_IDX, F_DOLPHINCONFIG_IDX = FIRST_FILE_USER_PATH_IDX, F_GCPADCONFIG_IDX, diff --git a/Source/Core/Common/NandPaths.cpp b/Source/Core/Common/NandPaths.cpp index db2c2f0cf3..aa44b91714 100644 --- a/Source/Core/Common/NandPaths.cpp +++ b/Source/Core/Common/NandPaths.cpp @@ -19,7 +19,19 @@ namespace Common { std::string RootUserPath(FromWhichRoot from) { - int idx = from == FromWhichRoot::Configured ? D_WIIROOT_IDX : D_SESSION_WIIROOT_IDX; + int idx{}; + switch (from) + { + case FromWhichRoot::Configured: + idx = D_WIIROOT_IDX; + break; + case FromWhichRoot::Session: + idx = D_SESSION_WIIROOT_IDX; + break; + case FromWhichRoot::Banners: + idx = D_BANNERS_WIIROOT_IDX; + break; + } std::string dir = File::GetUserPath(idx); dir.pop_back(); // remove trailing path separator return dir; diff --git a/Source/Core/Common/NandPaths.h b/Source/Core/Common/NandPaths.h index dd27b904b6..fa59e73da8 100644 --- a/Source/Core/Common/NandPaths.h +++ b/Source/Core/Common/NandPaths.h @@ -14,6 +14,7 @@ enum class FromWhichRoot { Configured, // not related to currently running game - use D_WIIROOT_IDX Session, // request from currently running game - use D_SESSION_WIIROOT_IDX + Banners, // fallback for Wii savegame banners - use D_BANNERS_WIIROOT_IDX }; std::string RootUserPath(FromWhichRoot from); diff --git a/Source/Core/DiscIO/WiiSaveBanner.cpp b/Source/Core/DiscIO/WiiSaveBanner.cpp index 7c2489ea93..203b033271 100644 --- a/Source/Core/DiscIO/WiiSaveBanner.cpp +++ b/Source/Core/DiscIO/WiiSaveBanner.cpp @@ -3,12 +3,14 @@ #include "DiscIO/WiiSaveBanner.h" +#include #include #include #include #include "Common/ColorUtil.h" #include "Common/CommonTypes.h" +#include "Common/FileUtil.h" #include "Common/IOFile.h" #include "Common/NandPaths.h" #include "Common/StringUtil.h" @@ -20,17 +22,20 @@ constexpr u32 ICON_HEIGHT = 48; constexpr u32 ICON_SIZE = ICON_WIDTH * ICON_HEIGHT * 2; WiiSaveBanner::WiiSaveBanner(u64 title_id) - : WiiSaveBanner(Common::GetTitleDataPath(title_id, Common::FromWhichRoot::Configured) + - "/banner.bin") -{ -} - -WiiSaveBanner::WiiSaveBanner(const std::string& path) : m_path(path) { constexpr u32 BANNER_SIZE = BANNER_WIDTH * BANNER_HEIGHT * 2; constexpr size_t MINIMUM_SIZE = sizeof(Header) + BANNER_SIZE + ICON_SIZE; - File::IOFile file(path, "rb"); + + m_path = Common::GetTitleDataPath(title_id, Common::FromWhichRoot::Configured) + "/banner.bin"; + File::IOFile file(m_path, "rb"); + + if (!file) + { + m_path = Common::GetTitleDataPath(title_id, Common::FromWhichRoot::Banners) + "/banner.bin"; + file = File::IOFile(m_path, "rb"); + } + if (!file.ReadArray(&m_header, 1)) { m_header = {}; diff --git a/Source/Core/DiscIO/WiiSaveBanner.h b/Source/Core/DiscIO/WiiSaveBanner.h index 2531a01f55..88276239ea 100644 --- a/Source/Core/DiscIO/WiiSaveBanner.h +++ b/Source/Core/DiscIO/WiiSaveBanner.h @@ -17,7 +17,6 @@ public: static constexpr u32 BANNER_HEIGHT = 64; explicit WiiSaveBanner(u64 title_id); - explicit WiiSaveBanner(const std::string& path); bool IsValid() const { return m_valid; } const std::string& GetPath() const { return m_path; }