WiiSaveBanner: fall back to $userdir/Load/WiiBanners

Unlike custom banners which work as an override, this mechanism works as
a fallback. The use case is if you have games you don't really play but
want to keep around for testing purposes without filling up your NAND
with lots of saves. For ease of use, the directory structure is the same
but only title/$title_hi/$title_lo/data/banner.bin files are
relevant.
This commit is contained in:
Tillmann Karras
2025-06-15 11:13:18 +01:00
parent a5e85caf0a
commit fe6fd2279c
7 changed files with 30 additions and 9 deletions

View File

@ -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"

View File

@ -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;
}
}

View File

@ -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,

View File

@ -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;

View File

@ -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);

View File

@ -3,12 +3,14 @@
#include "DiscIO/WiiSaveBanner.h"
#include <fmt/format.h>
#include <iterator>
#include <string>
#include <vector>
#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 = {};

View File

@ -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; }