mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-27 13:44:15 +01:00
-added custom wii game directory support via the ini option
"wii_games_dir", if you want for example use usb:/games, then set this option to "%s:/games" etc, subdirs and stuff are supported (issue 165)
This commit is contained in:
parent
1680e303c7
commit
b2b2fe2ea1
@ -2,22 +2,7 @@
|
||||
#include "text.hpp"
|
||||
#include "memory/mem2.hpp"
|
||||
|
||||
int currentStr = 0;
|
||||
static char fmt_buffer[MAX_USES][MAX_MSG_SIZE];
|
||||
static char general_buffer[MAX_MSG_SIZE * 2];
|
||||
|
||||
// Simplified use of sprintf
|
||||
char *fmt(const char *format, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
currentStr = (currentStr + 1) % MAX_USES;
|
||||
vsnprintf(fmt_buffer[currentStr], MAX_MSG_SIZE - 1, format, va);
|
||||
fmt_buffer[currentStr][MAX_MSG_SIZE - 1] = '\0';
|
||||
va_end(va);
|
||||
return fmt_buffer[currentStr];
|
||||
}
|
||||
|
||||
string sfmt(const char *format, ...)
|
||||
{
|
||||
va_list va;
|
||||
@ -458,47 +443,3 @@ string rtrim(string s)
|
||||
s.erase(find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(), s.end());
|
||||
return s;
|
||||
}
|
||||
|
||||
void Asciify( wchar_t *str )
|
||||
{
|
||||
const wchar_t *ptr = str;
|
||||
wchar_t *ctr = str;
|
||||
|
||||
while(*ptr != '\0')
|
||||
{
|
||||
switch(*ptr)
|
||||
{
|
||||
case 0x14c:
|
||||
*ctr = 0x4f;
|
||||
break;
|
||||
}
|
||||
*ctr = *ptr;
|
||||
++ptr;
|
||||
++ctr;
|
||||
}
|
||||
*ctr = '\0';
|
||||
}
|
||||
|
||||
void Asciify2( char *str )
|
||||
{
|
||||
u8 i=0;
|
||||
for( i=0; i < strlen(str); ++i )
|
||||
{
|
||||
if( str[i] < 0x20 || str[i] > 0x7F )
|
||||
str[i] = '_';
|
||||
else {
|
||||
switch( str[i] )
|
||||
{
|
||||
case '*':
|
||||
case '\"':
|
||||
case '|':
|
||||
case '<':
|
||||
case '>':
|
||||
case '?':
|
||||
case ':':
|
||||
str[i] = '_';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "fmt.h"
|
||||
#include "FreeTypeGX.h"
|
||||
#include "video.hpp"
|
||||
#include "wstringEx/wstringEx.hpp"
|
||||
@ -56,12 +57,6 @@ private:
|
||||
|
||||
// Nothing to do with CText. Q&D helpers for string formating.
|
||||
|
||||
enum {
|
||||
MAX_MSG_SIZE = 1024,
|
||||
MAX_USES = 8,
|
||||
};
|
||||
|
||||
char *fmt(const char *format, ...);
|
||||
std::string sfmt(const char *format, ...);
|
||||
wstringEx wfmt(const wstringEx &format, ...);
|
||||
bool checkFmt(const wstringEx &ref, const wstringEx &format);
|
||||
@ -73,7 +68,5 @@ std::string upperCase(std::string text);
|
||||
std::string lowerCase(std::string text);
|
||||
std::string ltrim(std::string s);
|
||||
std::string rtrim(std::string s);
|
||||
void Asciify( wchar_t *str );
|
||||
void Asciify2( char *str );
|
||||
|
||||
#endif // !defined(__TEXT_HPP)
|
||||
|
@ -73,7 +73,7 @@ int SetupARGV(struct __argv * args)
|
||||
if(!args)
|
||||
return -1;
|
||||
|
||||
bzero(args, sizeof(struct __argv));
|
||||
memset(args, 0, sizeof(struct __argv));
|
||||
args->argvMagic = ARGV_MAGIC;
|
||||
|
||||
u32 argc = 0;
|
||||
|
@ -157,7 +157,7 @@ int frag_remap(FragList *ff, FragList *log, FragList *phy)
|
||||
int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
||||
{
|
||||
char fname[1024];
|
||||
bzero(fname, 1024);
|
||||
memset(fname, 0, sizeof(fname));
|
||||
u32 length = strlen(path);
|
||||
strcpy(fname, path);
|
||||
|
||||
@ -166,7 +166,7 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
||||
|
||||
if(fname[length-1] > '0' && fname[length-1] < '9')
|
||||
return 0;
|
||||
bool isWBFS = wbfs_part_fs != PART_FS_WBFS && strcasestr(strrchr(fname,'.'), ".wbfs") != 0;
|
||||
bool isWBFS = strrchr(fname,'.') != NULL && strcasecmp(strrchr(fname,'.'), ".wbfs") == 0;
|
||||
|
||||
struct stat st;
|
||||
FragList *fs = MEM1_lo_alloc(sizeof(FragList));
|
||||
@ -237,7 +237,6 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
||||
for (j = 0; j < fs->num; j++)
|
||||
fs->frag[j].sector += wbfs_part_lba;
|
||||
}
|
||||
|
||||
frag_concat(fa, fs);
|
||||
}
|
||||
|
||||
@ -246,17 +245,17 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
|
||||
goto out;
|
||||
|
||||
frag_init(frag_list, MAX_FRAG);
|
||||
if (isWBFS) // If this is a .wbfs file format, remap.
|
||||
if(isWBFS) // If this is a .wbfs file format, remap.
|
||||
{
|
||||
wbfs_disc_t *disc = WBFS_OpenDisc(id, path);
|
||||
if (!disc)
|
||||
if(!disc)
|
||||
{
|
||||
ret_val = -4;
|
||||
goto out;
|
||||
}
|
||||
frag_init(fw, MAX_FRAG);
|
||||
ret = wbfs_get_fragments(disc, &_frag_append, fw, hdd_sector_size);
|
||||
if (ret)
|
||||
if(ret)
|
||||
{
|
||||
ret_val = -5;
|
||||
goto out;
|
||||
|
@ -294,9 +294,9 @@ s32 GCDump::DumpGame()
|
||||
char *FSTNameOff = NULL;
|
||||
|
||||
char folder[MAX_FAT_PATH];
|
||||
bzero(folder, MAX_FAT_PATH);
|
||||
memset(folder, 0, MAX_FAT_PATH);
|
||||
char gamepath[MAX_FAT_PATH];
|
||||
bzero(gamepath, MAX_FAT_PATH);
|
||||
memset(gamepath, 0, MAX_FAT_PATH);
|
||||
|
||||
while(!gamedone)
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ bool reset = false;
|
||||
bool shutdown = false;
|
||||
volatile u8 ExitOption = 0;
|
||||
const char *NeekPath = NULL;
|
||||
char wii_games_dir[64];
|
||||
|
||||
void __Wpad_PowerCallback()
|
||||
{
|
||||
@ -37,9 +38,7 @@ void Open_Inputs(void)
|
||||
|
||||
/* Set POWER button callback */
|
||||
WPAD_SetPowerButtonCallback(__Wpad_PowerCallback);
|
||||
|
||||
WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);
|
||||
|
||||
WPAD_SetIdleTimeout(60 * 2); // idle after 2 minutes
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ extern bool useMainIOS;
|
||||
extern volatile bool NANDemuView;
|
||||
extern volatile bool networkInit;
|
||||
extern u8 currentPartition;
|
||||
extern char wii_games_dir[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -23,12 +23,13 @@
|
||||
#include "fileOps/fileOps.h"
|
||||
#include "gecko/gecko.hpp"
|
||||
#include "libwbfs/libwbfs.h"
|
||||
#include "loader/utils.h"
|
||||
#include "loader/sys.h"
|
||||
#include "gui/fmt.h"
|
||||
|
||||
#define MAX_FAT_PATH 1024
|
||||
#define TITLE_LEN 64
|
||||
|
||||
char wbfs_fs_drive[16];
|
||||
char wbfs_ext_dir[16] = "/wbfs";
|
||||
char invalid_path[] = "/\\:|<>?*\"'";
|
||||
|
||||
split_info_t split;
|
||||
@ -176,22 +177,22 @@ s32 WBFS_Ext_AddGame(progress_callback_t spinner, void *spinner_data)
|
||||
char *cleantitle;
|
||||
|
||||
char folder[MAX_FAT_PATH];
|
||||
bzero(folder, MAX_FAT_PATH);
|
||||
memset(folder, 0, MAX_FAT_PATH);
|
||||
|
||||
char gamepath[MAX_FAT_PATH];
|
||||
bzero(gamepath, MAX_FAT_PATH);
|
||||
memset(gamepath, 0, MAX_FAT_PATH);
|
||||
|
||||
Disc_ReadHeader(&header);
|
||||
asprintf(&cleantitle, header.title);
|
||||
for(cp = strpbrk(cleantitle, illegal); cp; cp = strpbrk(cp, illegal))
|
||||
*cp = '_';
|
||||
snprintf(folder, sizeof(folder), "%s%s", wbfs_fs_drive, wbfs_ext_dir);
|
||||
strncpy(folder, fmt(wii_games_dir, wbfs_fs_drive), sizeof(folder));
|
||||
fsop_MakeFolder(folder);
|
||||
snprintf(folder, sizeof(folder), "%s%s/%s [%s]", wbfs_fs_drive, wbfs_ext_dir, cleantitle, header.id);
|
||||
strncpy(folder, fmt("%s/%s [%s]", folder, cleantitle, header.id), sizeof(folder));
|
||||
fsop_MakeFolder(folder);
|
||||
free(cleantitle);
|
||||
|
||||
snprintf(gamepath, sizeof(gamepath), "%s/%s.wbfs", folder, header.id);
|
||||
strncpy(gamepath, fmt("%s/%s.wbfs", folder, header.id), sizeof(gamepath));
|
||||
u64 size = (u64)143432*2*0x8000ULL;
|
||||
u32 n_sector = size / 512;
|
||||
|
||||
|
@ -204,6 +204,12 @@ void CMenu::init()
|
||||
useMainIOS = m_cfg.getBool("GENERAL", "force_cios_load", false);
|
||||
if(prevCios != mainIOS || prevForceCIOS != useMainIOS)
|
||||
InternalSave.SaveIOS(mainIOS, useMainIOS);
|
||||
/* Our Wii game dir */
|
||||
memset(wii_games_dir, 0, 64);
|
||||
strncpy(wii_games_dir, m_cfg.getString("GENERAL", "wii_games_dir", GAMES_DIR).c_str(), 64);
|
||||
if(strncmp(wii_games_dir, "%s:/", 4) != 0)
|
||||
strcpy(wii_games_dir, GAMES_DIR);
|
||||
gprintf("Wii Games Directory: %s\n", wii_games_dir);
|
||||
/* Do our USB HDD Checks */
|
||||
bool onUSB = m_cfg.getBool("GENERAL", "data_on_usb", strncmp(drive, "usb", 3) == 0);
|
||||
drive = check; //reset the drive variable for the check
|
||||
|
Loading…
Reference in New Issue
Block a user