mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-17 16:59:17 +01:00
added favorites to per game settings, sorting for gamelist based on alphabetical, favorites, and play count. still has some bugs so don't make issues out of them.
This commit is contained in:
parent
4a0c038708
commit
2062ef871d
11
source/cfg.c
11
source/cfg.c
@ -50,6 +50,7 @@ u8 viChoice = 0;
|
||||
u8 iosChoice = 0;
|
||||
u8 parentalcontrolChoice = 0;
|
||||
u8 xflip = 0;
|
||||
u8 sort = 0;
|
||||
u8 qboot = 0;
|
||||
u8 wsprompt = 0;
|
||||
u8 keyset = 0;
|
||||
@ -757,6 +758,13 @@ void global_cfg_set(char *name, char *val)
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (strcmp(name, "sort") == 0) {
|
||||
int i;
|
||||
if (sscanf(val, "%d", &i) == 1) {
|
||||
Settings.sort = i;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
else if (strcmp(name, "keyset") == 0) {
|
||||
int i;
|
||||
@ -1030,6 +1038,7 @@ bool cfg_save_global()// save global settings
|
||||
fprintf(f, "volume = %d\n ", Settings.volume);
|
||||
fprintf(f, "tooltips = %d\n ", Settings.tooltips);
|
||||
fprintf(f, "password = %s\n ", Settings.unlockCode);
|
||||
fprintf(f, "sort = %d\n ", Settings.sort);
|
||||
fprintf(f, "cios = %d\n ", Settings.cios);
|
||||
fprintf(f, "keyset = %d\n ", Settings.keyset);
|
||||
fprintf(f, "xflip = %d\n ", Settings.xflip);
|
||||
@ -1268,7 +1277,7 @@ struct Game_NUM* CFG_get_game_num(u8 *id)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<num_saved_game_num; i++) {
|
||||
if (memcmp(id, cfg_game_num[i].id, 2) == 0) {
|
||||
if (memcmp(id, cfg_game_num[i].id, 6) == 0) {
|
||||
return &cfg_game_num[i];
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ struct THEME
|
||||
extern struct CFG CFG;
|
||||
extern struct THEME THEME;
|
||||
extern u8 ocarinaChoice;
|
||||
extern u8 fave;
|
||||
extern u8 sort;
|
||||
extern u8 playcnt;
|
||||
extern u8 videoChoice;
|
||||
extern u8 languageChoice;
|
||||
@ -154,6 +154,7 @@ extern u8 faveChoice;
|
||||
extern u8 parentalcontrolChoice;
|
||||
extern u8 xflip;
|
||||
extern u8 qboot;
|
||||
extern u8 sort;
|
||||
extern u8 wsprompt;
|
||||
extern u8 keyset;
|
||||
|
||||
@ -236,6 +237,11 @@ enum {
|
||||
hr24,
|
||||
Off,
|
||||
};
|
||||
enum {
|
||||
all,
|
||||
fave,
|
||||
pcount,
|
||||
};
|
||||
|
||||
enum {
|
||||
RumbleOff,
|
||||
@ -300,6 +306,7 @@ struct SSettings {
|
||||
int wsprompt;
|
||||
int keyset;
|
||||
int unicodefix;
|
||||
int sort;
|
||||
};
|
||||
|
||||
void CFG_LoadGlobal(void);
|
||||
|
@ -31,6 +31,7 @@ void lang_default()
|
||||
{
|
||||
snprintf(LANGUAGE.ok, sizeof(LANGUAGE.ok), "OK");
|
||||
snprintf(LANGUAGE.addToFavorite, sizeof(LANGUAGE.addToFavorite), "Favorite");
|
||||
snprintf(LANGUAGE.all, sizeof(LANGUAGE.all), "Alphabetical");
|
||||
snprintf(LANGUAGE.AppLanguage, sizeof(LANGUAGE.AppLanguage), "App Language");
|
||||
snprintf(LANGUAGE.t3Covers, sizeof(LANGUAGE.t3Covers), "3D Covers");
|
||||
snprintf(LANGUAGE.Areyousure, sizeof(LANGUAGE.Areyousure), "Are you sure?");
|
||||
@ -61,6 +62,7 @@ snprintf(LANGUAGE.CoverDownload, sizeof(LANGUAGE.CoverDownload), "Cover Download
|
||||
snprintf(LANGUAGE.CoverPath, sizeof(LANGUAGE.CoverPath), "Cover Path");
|
||||
snprintf(LANGUAGE.CoverpathChanged, sizeof(LANGUAGE.CoverpathChanged), "Coverpath Changed");
|
||||
snprintf(LANGUAGE.Coverpathchange, sizeof(LANGUAGE.Coverpathchange), "Coverpath change");
|
||||
snprintf(LANGUAGE.count, sizeof(LANGUAGE.count), "Play Count");
|
||||
snprintf(LANGUAGE.Credits, sizeof(LANGUAGE.Credits), "Credits");
|
||||
snprintf(LANGUAGE.DiscImages, sizeof(LANGUAGE.DiscImages), "Disc Images");
|
||||
snprintf(LANGUAGE.DiscimagePath, sizeof(LANGUAGE.DiscimagePath), "Discimage Path");
|
||||
@ -93,6 +95,7 @@ snprintf(LANGUAGE.Failedtoboot, sizeof(LANGUAGE.Failedtoboot), "Failed to boot:"
|
||||
snprintf(LANGUAGE.FailedtomountfrontSDcard, sizeof(LANGUAGE.FailedtomountfrontSDcard), "Failed to mount front SD-card");
|
||||
snprintf(LANGUAGE.FailedtosetUSB, sizeof(LANGUAGE.FailedtosetUSB), "Failed to set USB:");
|
||||
snprintf(LANGUAGE.Failedformating, sizeof(LANGUAGE.Failedformating), "Failed formating");
|
||||
snprintf(LANGUAGE.fave, sizeof(LANGUAGE.fave), "Favorites");
|
||||
snprintf(LANGUAGE.filesnotfoundontheserver, sizeof(LANGUAGE.filesnotfoundontheserver), "files not found on the server!");
|
||||
snprintf(LANGUAGE.Filenotfound, sizeof(LANGUAGE.Filenotfound), "File not found.");
|
||||
snprintf(LANGUAGE.filesleft, sizeof(LANGUAGE.filesleft), "file(s) left");
|
||||
@ -117,6 +120,7 @@ snprintf(LANGUAGE.Language, sizeof(LANGUAGE.Language), "Game Language");
|
||||
snprintf(LANGUAGE.Left, sizeof(LANGUAGE.Left), "Left");
|
||||
snprintf(LANGUAGE.LikeSysMenu, sizeof(LANGUAGE.LikeSysMenu), "Like SysMenu");
|
||||
snprintf(LANGUAGE.LoadingincIOS, sizeof(LANGUAGE.LoadingincIOS), "Loading in cIOS249");
|
||||
snprintf(LANGUAGE.ListSort, sizeof(LANGUAGE.ListSort), "Sort Game List");
|
||||
snprintf(LANGUAGE.Loadingstandardlanguage, sizeof(LANGUAGE.Loadingstandardlanguage), "Loading standard language.");
|
||||
snprintf(LANGUAGE.Loadingstandardmusic, sizeof(LANGUAGE.Loadingstandardmusic), "Loading standard music.");
|
||||
snprintf(LANGUAGE.Lock, sizeof(LANGUAGE.Lock), "Lock");
|
||||
@ -232,6 +236,10 @@ void language_set(char *name, char *val)
|
||||
strcopy(LANGUAGE.addToFavorite, val, sizeof(LANGUAGE.addToFavorite));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "all") == 0) {
|
||||
strcopy(LANGUAGE.all, val, sizeof(LANGUAGE.all));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "Specialthanksto") == 0) {
|
||||
strcopy(LANGUAGE.Specialthanksto, val, sizeof(LANGUAGE.Specialthanksto));
|
||||
return;
|
||||
@ -340,6 +348,10 @@ void language_set(char *name, char *val)
|
||||
strcopy(LANGUAGE.CouldnotinitializeDIPmodule, val, sizeof(LANGUAGE.CouldnotinitializeDIPmodule));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "count") == 0) {
|
||||
strcopy(LANGUAGE.count, val, sizeof(LANGUAGE.count));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "CoverDownload") == 0) {
|
||||
strcopy(LANGUAGE.CoverDownload, val, sizeof(LANGUAGE.CoverDownload));
|
||||
return;
|
||||
@ -424,6 +436,10 @@ void language_set(char *name, char *val)
|
||||
strcopy(LANGUAGE.ExitUSBISOLoader, val, sizeof(LANGUAGE.ExitUSBISOLoader));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "fave") == 0) {
|
||||
strcopy(LANGUAGE.fave, val, sizeof(LANGUAGE.fave));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "InitializingNetwork") == 0) {
|
||||
strcopy(LANGUAGE.InitializingNetwork, val, sizeof(LANGUAGE.InitializingNetwork));
|
||||
return;
|
||||
@ -589,6 +605,10 @@ void language_set(char *name, char *val)
|
||||
strcopy(LANGUAGE.LikeSysMenu, val, sizeof(LANGUAGE.LikeSysMenu));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "ListSort") == 0) {
|
||||
strcopy(LANGUAGE.ListSort, val, sizeof(LANGUAGE.ListSort));
|
||||
return;
|
||||
}
|
||||
if (strcmp(name, "LoadingincIOS") == 0) {
|
||||
strcopy(LANGUAGE.LoadingincIOS, val, sizeof(LANGUAGE.LoadingincIOS));
|
||||
return;
|
||||
|
@ -14,6 +14,7 @@ struct LANGUAGE
|
||||
|
||||
char t3Covers[50];
|
||||
char addToFavorite[20];
|
||||
char all[10];
|
||||
char AppLanguage[50];
|
||||
char Areyousure[50];
|
||||
char AutoPatch[20];
|
||||
@ -43,6 +44,7 @@ struct LANGUAGE
|
||||
char CoverPath[50];
|
||||
char CoverpathChanged[50];
|
||||
char Coverpathchange[50];
|
||||
char count[20];
|
||||
char Credits[30];
|
||||
char DiscImages[50];
|
||||
char DiscimagePath[50];
|
||||
@ -74,6 +76,7 @@ struct LANGUAGE
|
||||
char FailedtomountfrontSDcard[80];
|
||||
char FailedtosetUSB[50];
|
||||
char Failedformating[50];
|
||||
char fave[15];
|
||||
char Filenotfound[50];
|
||||
char filesnotfoundontheserver[80];
|
||||
char filesleft[50];
|
||||
@ -100,6 +103,7 @@ struct LANGUAGE
|
||||
char Langchange[50];
|
||||
char Left[50];
|
||||
char LikeSysMenu[50];
|
||||
char ListSort[20];
|
||||
char LoadingincIOS[50];
|
||||
char Loadingstandardlanguage[80];
|
||||
char Loadingstandardmusic[80];
|
||||
|
101
source/menu.cpp
101
source/menu.cpp
@ -2253,12 +2253,44 @@ InitGUIThreads()
|
||||
* EntryCmp
|
||||
***************************************************************************/
|
||||
s32 __Menu_EntryCmp(const void *a, const void *b)
|
||||
|
||||
{
|
||||
|
||||
struct discHdr *hdr1 = (struct discHdr *)a;
|
||||
|
||||
struct discHdr *hdr2 = (struct discHdr *)b;
|
||||
|
||||
|
||||
|
||||
/* Compare strings */
|
||||
|
||||
return stricmp(get_title(hdr1), get_title(hdr2));
|
||||
|
||||
}
|
||||
|
||||
s32 __Menu_EntryCmpCount(const void *a, const void *b)
|
||||
{
|
||||
s32 ret;
|
||||
|
||||
struct discHdr *hdr1 = (struct discHdr *)a;
|
||||
|
||||
struct discHdr *hdr2 = (struct discHdr *)b;
|
||||
|
||||
/* Compare Play Count */
|
||||
u8 count1 = 0;
|
||||
u8 count2 = 0;
|
||||
struct Game_NUM* game_num1 = CFG_get_game_num(hdr1->id);
|
||||
struct Game_NUM* game_num2 = CFG_get_game_num(hdr2->id);
|
||||
|
||||
|
||||
|
||||
if (game_num1) count1 = game_num1->count;
|
||||
if (game_num2) count2 = game_num2->count;
|
||||
|
||||
ret = (s32) (count2-count1);
|
||||
if (ret == 0) return stricmp(get_title(hdr1), get_title(hdr2));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -2266,7 +2298,7 @@ s32 __Menu_EntryCmp(const void *a, const void *b)
|
||||
***************************************************************************/
|
||||
|
||||
s32 __Menu_GetEntries(void)
|
||||
{
|
||||
{
|
||||
struct discHdr *buffer = NULL;
|
||||
struct discHdr *buffer2 = NULL;
|
||||
struct discHdr *header = NULL;
|
||||
@ -2294,15 +2326,23 @@ s32 __Menu_GetEntries(void)
|
||||
ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr));
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
if (CFG.parentalcontrol && !CFG.godmode)
|
||||
{
|
||||
|
||||
/////////////show favorites only///////////////////////
|
||||
if (Settings.sort==fave){
|
||||
u32 cnt2 = 0;
|
||||
|
||||
for (u32 i = 0; i < cnt; i++)
|
||||
{
|
||||
header = &buffer[i];
|
||||
if (get_block(header) < CFG.parentalcontrol)
|
||||
header = &buffer[i];
|
||||
u8 favorite = 0;
|
||||
struct Game_NUM* game_num = CFG_get_game_num(header->id);
|
||||
if (game_num)
|
||||
{
|
||||
favorite = game_num->favorite;}
|
||||
if (favorite==1)
|
||||
|
||||
|
||||
//if (get_block(header) < CFG.parentalcontrol)
|
||||
{
|
||||
buffer2 = (discHdr *) realloc(buffer2, (cnt2+1) * sizeof(struct discHdr));
|
||||
if (!buffer2)
|
||||
@ -2319,10 +2359,43 @@ s32 __Menu_GetEntries(void)
|
||||
buffer = buffer2;
|
||||
buffer2 = NULL;
|
||||
cnt = cnt2;
|
||||
//if (cnt==0){Settings.sort=all;__Menu_GetEntries();}
|
||||
|
||||
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);
|
||||
}
|
||||
|
||||
else {
|
||||
if (CFG.parentalcontrol && !CFG.godmode)
|
||||
{
|
||||
u32 cnt2 = 0;
|
||||
|
||||
for (u32 i = 0; i < cnt; i++)
|
||||
{
|
||||
if (get_block(header) < CFG.parentalcontrol)
|
||||
{
|
||||
buffer2 = (discHdr *) realloc(buffer2, (cnt2+1) * sizeof(struct discHdr));
|
||||
if (!buffer2)
|
||||
{
|
||||
free(buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy((buffer2 + cnt2), (buffer + i), sizeof(struct discHdr));
|
||||
cnt2++;
|
||||
}
|
||||
}
|
||||
free(buffer);
|
||||
buffer = buffer2;
|
||||
buffer2 = NULL;
|
||||
cnt = cnt2;
|
||||
}if (Settings.sort==all){qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);}
|
||||
else //if (Settings.sort==pcount)
|
||||
{qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmpCount);}
|
||||
}
|
||||
|
||||
|
||||
/* Sort entries */
|
||||
qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);
|
||||
//qsort(buffer, cnt, sizeof(struct discHdr), __Menu_EntryCmp);
|
||||
|
||||
/* Free memory */
|
||||
if (gameList)
|
||||
@ -2702,6 +2775,8 @@ static int MenuDiscList()
|
||||
int menu = MENU_NONE, dataef=0;
|
||||
char imgPath[100];
|
||||
char buf[4];
|
||||
__Menu_GetEntries();
|
||||
if (gameCnt==0){Settings.sort=all;__Menu_GetEntries();}
|
||||
|
||||
f32 freespace, used, size = 0.0;
|
||||
u32 nolist;
|
||||
@ -3986,7 +4061,7 @@ static int MenuSettings()
|
||||
sprintf(options2.name[2], "%s",LANGUAGE.keyboard);
|
||||
sprintf(options2.name[3], "%s",LANGUAGE.Unicodefix);
|
||||
sprintf(options2.name[4], "%s",LANGUAGE.Backgroundmusic);
|
||||
sprintf(options2.name[5], " ");
|
||||
sprintf(options2.name[5], "%s",LANGUAGE.ListSort);
|
||||
sprintf(options2.name[6], " ");
|
||||
sprintf(options2.name[7], " ");
|
||||
sprintf(options2.name[8], "%s",LANGUAGE.MP3Menu);
|
||||
@ -4391,6 +4466,8 @@ static int MenuSettings()
|
||||
Settings.keyset = 0;
|
||||
if ( Settings.unicodefix > 2 )
|
||||
Settings.unicodefix = 0;
|
||||
if ( Settings.sort > 2 )
|
||||
Settings.sort = 0;
|
||||
|
||||
if (strlen(CFG.titlestxt_path) < (9 + 3)) {
|
||||
sprintf(cfgtext, "%s", CFG.titlestxt_path);
|
||||
@ -4432,7 +4509,9 @@ static int MenuSettings()
|
||||
sprintf(options2.value[4], "%s", cfgtext);
|
||||
}
|
||||
|
||||
sprintf(options2.value[5], " ");
|
||||
if (Settings.sort == all) sprintf (options2.value[5],"%s",LANGUAGE.all);
|
||||
else if (Settings.sort == fave) sprintf (options2.value[5],"%s",LANGUAGE.fave);
|
||||
else if (Settings.sort == pcount) sprintf (options2.value[5],"%s",LANGUAGE.count);
|
||||
sprintf(options2.value[6], " ");
|
||||
sprintf(options2.value[7], " ");
|
||||
sprintf(options2.value[8], "not working!");
|
||||
@ -4545,6 +4624,10 @@ static int MenuSettings()
|
||||
} else {
|
||||
WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtousethatoption, LANGUAGE.ok, 0,0,0);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
Settings.sort++;
|
||||
//__Menu_GetEntries();
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user