mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-04 18:45:05 +01:00
made another useless function...
click the "Games:..." text to save a game list in the update path. normal txt or csv format for spreadsheets is supported.
This commit is contained in:
parent
f33eebc265
commit
12b45408e4
File diff suppressed because one or more lines are too long
@ -375,12 +375,19 @@ int MenuDiscList() {
|
||||
GuiText usedSpaceTxt(spaceinfo, 18, (GXColor) {THEME.info_r, THEME.info_g, THEME.info_b, 255});
|
||||
usedSpaceTxt.SetAlignment(THEME.hddInfoAlign, ALIGN_TOP);
|
||||
usedSpaceTxt.SetPosition(THEME.hddInfo_x, THEME.hddInfo_y);
|
||||
|
||||
char GamesCnt[15];
|
||||
|
||||
char GamesCnt[15];
|
||||
sprintf(GamesCnt,"%s: %i",tr("Games"), gameCnt);
|
||||
GuiText gamecntTxt(GamesCnt, 18, (GXColor) {THEME.info_r, THEME.info_g, THEME.info_b, 255});
|
||||
gamecntTxt.SetAlignment(THEME.gameCntAlign, ALIGN_TOP);
|
||||
gamecntTxt.SetPosition(THEME.gameCnt_x,THEME.gameCnt_y);
|
||||
|
||||
GuiButton gamecntBtn(100,18);
|
||||
gamecntBtn.SetAlignment(THEME.gameCntAlign, ALIGN_TOP);
|
||||
gamecntBtn.SetPosition(THEME.gameCnt_x,THEME.gameCnt_y);
|
||||
gamecntBtn.SetLabel(&gamecntTxt);
|
||||
gamecntBtn.SetEffectGrow();
|
||||
gamecntBtn.SetTrigger(&trigA);
|
||||
|
||||
|
||||
|
||||
GuiTooltip installBtnTT(tr("Install a game"));
|
||||
if (Settings.wsprompt == yes)
|
||||
@ -652,7 +659,7 @@ int MenuDiscList() {
|
||||
w.Append(&usedSpaceTxt);
|
||||
}
|
||||
if (THEME.showGameCnt == -1 || THEME.showGameCnt == 1) { //force show game cnt info
|
||||
w.Append(&gamecntTxt);
|
||||
w.Append(&gamecntBtn);
|
||||
}
|
||||
w.Append(&sdcardBtn);
|
||||
w.Append(&poweroffBtn);
|
||||
@ -788,6 +795,32 @@ int MenuDiscList() {
|
||||
}
|
||||
}
|
||||
|
||||
} else if (gamecntBtn.GetState() == STATE_CLICKED) {
|
||||
|
||||
char linebuf[150];
|
||||
snprintf(linebuf, sizeof(linebuf), tr("Save Game List to %sGameList ?"), Settings.update_path);
|
||||
|
||||
choice = WindowPrompt(0,linebuf, "txt","csv",tr("Back"));
|
||||
|
||||
if (choice==1)
|
||||
{
|
||||
if (save_gamelist(0))
|
||||
WindowPrompt(0,tr("Saved"), tr("OK"));
|
||||
else
|
||||
WindowPrompt(tr("Error"),tr("Could not save."), tr("OK"));
|
||||
|
||||
}
|
||||
else if (choice==2)
|
||||
{
|
||||
if (save_gamelist(1))
|
||||
WindowPrompt(0,tr("Saved"), tr("OK"));
|
||||
else
|
||||
WindowPrompt(tr("Error"),tr("Could not save."), tr("OK"));
|
||||
|
||||
}
|
||||
|
||||
gamecntBtn.ResetState();
|
||||
|
||||
} else if (homeBtn.GetState() == STATE_CLICKED) {
|
||||
s32 thetimeofbg = bgMusic->GetPlayTime();
|
||||
bgMusic->Stop();
|
||||
|
@ -978,6 +978,82 @@ int showGameInfo(char *ID) {
|
||||
}
|
||||
}
|
||||
|
||||
bool save_gamelist(int txt) { // save gamelist
|
||||
mainWindow->SetState(STATE_DISABLED);
|
||||
char tmp[200];
|
||||
sprintf(tmp, "%s", Settings.update_path);
|
||||
struct stat st;
|
||||
if (stat(tmp, &st) != 0) {
|
||||
mkdir(tmp, 0777);
|
||||
}
|
||||
FILE *f;
|
||||
sprintf(tmp, "%sGameList.txt", Settings.update_path);
|
||||
if (txt==1)
|
||||
sprintf(tmp, "%sGameList.csv", Settings.update_path);
|
||||
f = fopen(tmp, "w");
|
||||
if (!f) {
|
||||
sleep(1);
|
||||
mainWindow->SetState(STATE_DEFAULT);
|
||||
return false;
|
||||
}
|
||||
//make sure that all games are added to the gamelist
|
||||
__Menu_GetEntries(1);
|
||||
|
||||
f32 size = 0.0;
|
||||
f32 freespace, used;
|
||||
unsigned int i;
|
||||
|
||||
WBFS_DiskSpace(&used, &freespace);
|
||||
|
||||
fprintf(f, "# USB Loader Has Saved this file\n");
|
||||
fprintf(f, "# This file was created based on your list of games and language settings.\n");
|
||||
fclose(f);
|
||||
/* Closing and reopening because of a write issue we are having right now */
|
||||
f = fopen(tmp, "w");
|
||||
|
||||
if (txt==0)
|
||||
{
|
||||
fprintf(f, "# USB Loader Has Saved this file\n");
|
||||
fprintf(f, "# This file was created based on your list of games and language settings.\n\n");
|
||||
|
||||
fprintf(f, "%.2fGB %s %.2fGB %s\n\n",freespace,tr("of"),(freespace+used),tr("free"));
|
||||
fprintf(f, "ID Size(GB) Name\n");
|
||||
|
||||
for (i = 0; i < gameCnt ; i++) {
|
||||
struct discHdr* header = &gameList[i];
|
||||
WBFS_GameSize(header->id, &size);
|
||||
if (i<500) {
|
||||
fprintf(f, "%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2], header->id[3], header->id[4], header->id[5]);
|
||||
fprintf(f, " [%.2f] ", size);
|
||||
fprintf(f, " %s",get_title(header));
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
fprintf(f, "ID,Size(GB),Name\n");
|
||||
|
||||
for (i = 0; i < gameCnt ; i++) {
|
||||
struct discHdr* header = &gameList[i];
|
||||
WBFS_GameSize(header->id, &size);
|
||||
if (i<500) {
|
||||
fprintf(f, "%c%c%c%c%c%c,", header->id[0], header->id[1], header->id[2], header->id[3], header->id[4], header->id[5]);
|
||||
fprintf(f, "%.2f,", size);
|
||||
fprintf(f, "\"%s\"",get_title(header));
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
__Menu_GetEntries();
|
||||
mainWindow->SetState(STATE_DEFAULT);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool save_XML_URL() { // save xml url as as txt file for people without wifi
|
||||
char tmp[200];
|
||||
sprintf(tmp, "%s", Settings.update_path);
|
||||
@ -1013,7 +1089,7 @@ bool save_XML_URL() { // save xml url as as txt file for people without wifi
|
||||
fprintf(f, "# USB Loader Has Saved this file\n");
|
||||
fprintf(f, "# This URL was created based on your list of games and language settings.\n");
|
||||
fclose(f);
|
||||
/* Closing and reopening because of a write issue we are having right now */
|
||||
// Closing and reopening because of a write issue we are having right now
|
||||
f = fopen(tmp, "w");
|
||||
fprintf(f, "# USB Loader Has Saved this file\n");
|
||||
fprintf(f, "# This URL was created based on your list of games and language settings.\n");
|
||||
@ -1026,3 +1102,5 @@ bool save_XML_URL() { // save xml url as as txt file for people without wifi
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -10,4 +10,5 @@
|
||||
|
||||
int showGameInfo(char *ID);
|
||||
bool save_XML_URL();
|
||||
bool save_gamelist(int txt);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user