From 2dc38a8354750e1168d991f9f98c976bf70c9e79 Mon Sep 17 00:00:00 2001 From: giantpune Date: Wed, 20 May 2009 08:31:47 +0000 Subject: [PATCH] auto add / if missing from path ends. add stuff to create stat/favorite file. add option to use 12rh clock.(not tested but i'll know in 12 hours if it works) --- source/cfg.c | 118 ++++++++++++++++++++++++++++++++++++- source/cfg.h | 16 ++++- source/language.c | 10 ++++ source/language.h | 2 + source/main.cpp | 2 +- source/menu.cpp | 147 +++++++++++++++++++++++++++++++++++++++++----- 6 files changed, 275 insertions(+), 20 deletions(-) diff --git a/source/cfg.c b/source/cfg.c index 1784181a..2ae6b479 100644 --- a/source/cfg.c +++ b/source/cfg.c @@ -44,6 +44,7 @@ struct CFG CFG; struct THEME THEME; u8 ocarinaChoice = 0; u8 videoChoice = 0; +u8 faveChoice = no; u8 languageChoice = 0; u8 viChoice = 0; u8 iosChoice = 0; @@ -52,6 +53,8 @@ u8 xflip = 0; u8 qboot = 0; u8 wsprompt = 0; u8 keyset = 0; +u8 favorite = 0; +u8 count = 0; #define TITLE_MAX 65 @@ -67,8 +70,11 @@ int num_title = 0; //number of titles struct ID_Title *cfg_title = NULL; #define MAX_SAVED_GAMES 1000 +#define MAX_SAVED_GAME_NUM 1000 int num_saved_games = 0; +int num_saved_game_num = 0; struct Game_CFG cfg_game[MAX_SAVED_GAMES]; +struct Game_NUM cfg_game_num[MAX_SAVED_GAME_NUM]; /* For Mapping */ @@ -987,6 +993,26 @@ void cfg_set_game_opt(struct Game_CFG *game, u8 *id) game->parentalcontrol = parentalcontrolChoice; } +struct Game_NUM* cfg_get_game_num(u8 *id) +{ + struct Game_NUM *game = CFG_get_game_num(id); + if (game) return game; + if (num_saved_game_num >= MAX_SAVED_GAME_NUM) return NULL; + game = &cfg_game_num[num_saved_game_num]; + num_saved_game_num++; + return game; +} + +// current options to game +void cfg_set_game_num(struct Game_NUM *game, u8 *id) +{ + strncpy((char*)game->id, (char*)id, 6); + game->id[6] = 0; + game->favorite = favorite; + game->count = count; +} + + bool cfg_save_global()// save global settings { struct stat st; @@ -1103,12 +1129,57 @@ void game_set(char *name, char *val) if (np) p = np + 1; else p = NULL; } } +void game_set_num(char *name, char *val) +{ + u8 id[8]; + struct Game_NUM *game; + if (strncmp(name, "game:", 5) != 0) return; + trimcopy((char*)id, name+5, sizeof(id)); + game = cfg_get_game_num(id); + + cfg_set_game_num(game, id); + + + // parse val + // first split options by ; + char opt[100], *p, *np; + p = val; + + while(p) { + np = strchr(p, ';'); + if (np) trim_n_copy(opt, p, np-p, sizeof(opt)); + else trimcopy(opt, p, sizeof(opt)); + + char opt_name[100], opt_val[100]; + if (trimsplit(opt, opt_name, opt_val, ':', sizeof(opt_name))){ + + short opt_c; + if (strcmp("favorite", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->favorite = opt_c; + } + } + if (strcmp("count", opt_name) == 0) { + if (sscanf(opt_val, "%hd", &opt_c) == 1) { + game->count = opt_c; + } + } + } + + if (np) p = np + 1; else p = NULL; + } +} bool cfg_load_games() { return cfg_parsefile("SD:/config/GXGameSettings.cfg", &game_set); } +bool cfg_load_game_num() +{ + return cfg_parsefile("SD:/config/GXGameCount.cfg", &game_set_num); +} + bool cfg_save_games()// save per game setings { FILE *f; @@ -1140,6 +1211,30 @@ bool cfg_save_games()// save per game setings return true; } +bool cfg_save_game_num() +{ + FILE *f; + int i; + mkdir("SD:/config/", 0777); + f = fopen("SD:/config/GXGameCount.cfg", "wb"); + if (!f) { + printf("Error saving %s\n", "GXGameCount.cfg"); + sleep(1); + return false; + } + fprintf(f, "# USB Loader settings file\n"); + fprintf(f, "# note: this file is automatically generated\n"); + fprintf(f, "# Num Games: %d\n", num_saved_game_num); + for (i=0; i7){cosa=1;}datag++;if (sina==3){wiiBtn.SetAlignment(ALIGN_LEFT,ALIGN_BOTTOM);wiiBtnImg.SetAngle(0);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),((datag*2)-130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==2){wiiBtn.SetAlignment(ALIGN_RIGHT,ALIGN_TOP);wiiBtnImg.SetAngle(270);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((-2*(datag)+130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((2*(datag)-120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==1){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(180);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(2*(datag)-120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==0){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(90);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((2*(datag)-130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((-2*(datag)+120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}} + if ((datagB<1)&&(Settings.cios==1)&&(Settings.video == ntsc)&&(Settings.hddinfo == hr12)&&(Settings.qboot==1)&&(Settings.wsprompt==0)&&(Settings.language==ger)&&(Settings.tooltips==0)){dataed=1;dataef=1;}if (dataef==1){if (cosa>7){cosa=1;}datag++;if (sina==3){wiiBtn.SetAlignment(ALIGN_LEFT,ALIGN_BOTTOM);wiiBtnImg.SetAngle(0);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),((datag*2)-130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==2){wiiBtn.SetAlignment(ALIGN_RIGHT,ALIGN_TOP);wiiBtnImg.SetAngle(270);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((-2*(datag)+130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((2*(datag)-120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==1){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(180);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(2*(datag)-120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==0){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(90);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((2*(datag)-130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((-2*(datag)+120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}} /* #ifdef HW_RVL @@ -3252,6 +3254,31 @@ static int MenuDiscList() { wiilight(0); + //////////save game play count//////////////// + extern u8 favorite; + extern u8 count; + struct Game_NUM* game_num = CFG_get_game_num(header->id); + + if (game_num) + { + favorite = game_num->favorite; + count = game_num->count;//count+=1; + + }count+=1; + + if(isSdInserted() == 1) { + if (CFG_save_game_num(header->id)) + { + //WindowPrompt(LANGUAGE.SuccessfullySaved, 0, LANGUAGE.ok, 0,0,0); + } + else + { + WindowPrompt(LANGUAGE.SaveFailed, 0, LANGUAGE.ok, 0,0,0); + } + } else { + WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtosave, LANGUAGE.ok, 0,0,0); + } + ////////////end save play count////////////// struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); @@ -3338,6 +3365,7 @@ static int MenuDiscList() bool returnHere = true;// prompt to start game while (returnHere) { + returnHere = false; wiilight(1); choice = GameWindowPrompt(); @@ -3347,6 +3375,32 @@ static int MenuDiscList() { wiilight(0); + //////////save game play count//////////////// + extern u8 favorite; + extern u8 count; + struct Game_NUM* game_num = CFG_get_game_num(header->id); + + if (game_num) + { + favorite = game_num->favorite; + count = game_num->count;//count+=1; + + }count+=1; + + + if(isSdInserted() == 1) { + if (CFG_save_game_num(header->id)) + { + //WindowPrompt(LANGUAGE.SuccessfullySaved, 0, LANGUAGE.ok, 0,0,0); + } + else + { + WindowPrompt(LANGUAGE.SaveFailed, 0, LANGUAGE.ok, 0,0,0); + } + } else { + WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtosave, LANGUAGE.ok, 0,0,0); + } + ////////////end save play count////////////// struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); @@ -4024,7 +4078,7 @@ static int MenuSettings() Settings.vpatch = 0; if(Settings.sinfo > 3) Settings.sinfo = 0; - if(Settings.hddinfo > 1) + if(Settings.hddinfo > 2) Settings.hddinfo = 0; //CLOCK if(Settings.rumble > 1) Settings.rumble = 0; //RUMBLE @@ -4068,8 +4122,9 @@ static int MenuSettings() else if (Settings.sinfo == Both) sprintf (options2.value[4],"%s",LANGUAGE.Both); else if (Settings.sinfo == Neither) sprintf (options2.value[4],"%s",LANGUAGE.Neither); - if (Settings.hddinfo == HDDInfo) sprintf (options2.value[5],"%s",LANGUAGE.OFF); - else if (Settings.hddinfo == Clock) sprintf (options2.value[5],"%s",LANGUAGE.ON); + if (Settings.hddinfo == hr12) sprintf (options2.value[5],"12 %s",LANGUAGE.hour); + else if (Settings.hddinfo == hr24) sprintf (options2.value[5],"24 %s",LANGUAGE.hour); + else if (Settings.hddinfo == Off) sprintf (options2.value[5],"%s",LANGUAGE.OFF); if (Settings.rumble == RumbleOn) sprintf (options2.value[6],"%s",LANGUAGE.ON); else if (Settings.rumble == RumbleOff) sprintf (options2.value[6],"%s",LANGUAGE.OFF); @@ -4266,7 +4321,11 @@ static int MenuSettings() w.Append(&backBtn); w.Append(&lockBtn); if ( result == 1 ) - { strncpy(CFG.covers_path, entered, sizeof(CFG.covers_path)); + { + int len = (strlen(entered)-1); + if(entered[len] !='/') + strncat (entered, "/", 1); + strncpy(CFG.covers_path, entered, sizeof(CFG.covers_path)); WindowPrompt(LANGUAGE.CoverpathChanged,0,LANGUAGE.ok,0,0,0); if(isSdInserted() == 1) { cfg_save_global(); @@ -4302,6 +4361,9 @@ static int MenuSettings() w.Append(&lockBtn); if ( result == 1 ) { + int len = (strlen(entered)-1); + if(entered[len] !='/') + strncat (entered, "/", 1); strncpy(CFG.disc_path, entered, sizeof(CFG.disc_path)); WindowPrompt(LANGUAGE.DiscpathChanged,0,LANGUAGE.ok,0,0,0); if(isSdInserted() == 1) { @@ -4338,6 +4400,9 @@ static int MenuSettings() w.Append(&lockBtn); if ( result == 1 ) { + int len = (strlen(entered)-1); + if(entered[len] !='/') + strncat (entered, "/", 1); strncpy(CFG.theme_path, entered, sizeof(CFG.theme_path)); WindowPrompt(LANGUAGE.ThemepathChanged,0,LANGUAGE.ok,0,0,0); if(isSdInserted() == 1) { @@ -4472,7 +4537,11 @@ static int MenuSettings() w.Append(&backBtn); w.Append(&lockBtn); if ( result == 1 ) - { strncpy(CFG.titlestxt_path, entered, sizeof(CFG.titlestxt_path)); + { + int len = (strlen(entered)-1); + if(entered[len] !='/') + strncat (entered, "/", 1); + strncpy(CFG.titlestxt_path, entered, sizeof(CFG.titlestxt_path)); WindowPrompt(LANGUAGE.TitlestxtpathChanged,0,LANGUAGE.ok,0,0,0); if(isSdInserted() == 1) { cfg_save_global(); @@ -4699,12 +4768,13 @@ int GameSettings(struct discHdr * header) strncat(gameName, "...", 3); } - customOptionList options3(5); + customOptionList options3(6); sprintf(options3.name[0],"%s", LANGUAGE.VideoMode); sprintf(options3.name[1],"%s", LANGUAGE.VIDTVPatch); sprintf(options3.name[2],"%s", LANGUAGE.Language); sprintf(options3.name[3], "Ocarina"); sprintf(options3.name[4], "IOS"); + sprintf(options3.name[5],"%s", LANGUAGE.addToFavorite); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, vol); @@ -4762,7 +4832,7 @@ int GameSettings(struct discHdr * header) cancelBtn.SetTrigger(&trigA); cancelBtn.SetTrigger(&trigB); cancelBtn.SetEffectGrow(); - + GuiText deleteBtnTxt(LANGUAGE.Uninstall, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); deleteBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); GuiImage deleteBtnImg(&btnOutline); @@ -4795,6 +4865,19 @@ int GameSettings(struct discHdr * header) mainWindow->Append(&optionBrowser3); ResumeGui(); + //extern u8 favorite; + extern u8 count; + struct Game_NUM* game_num = CFG_get_game_num(header->id); + + if (game_num) + { + faveChoice = game_num->favorite; + count = game_num->count;//count+=1; + + } + else { + faveChoice = no;} + struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); @@ -4851,6 +4934,10 @@ int GameSettings(struct discHdr * header) if (iosChoice == i249) sprintf (options3.value[4],"249"); else if (iosChoice == i222) sprintf (options3.value[4],"222"); + + if (faveChoice == yes) sprintf (options3.value[5],"%s",LANGUAGE.Yes); + else if (faveChoice == no) sprintf (options3.value[5],"%s",LANGUAGE.No); + if(shutdown == 1) Sys_Shutdown(); @@ -4876,12 +4963,41 @@ int GameSettings(struct discHdr * header) case 4: iosChoice = (iosChoice + 1) % 2; break; + case 5: + faveChoice = (faveChoice + 1) % 2; + break; } if(saveBtn.GetState() == STATE_CLICKED) - { - if(isSdInserted() == 1) { - if (CFG_save_game_opt(header->id)) + { + + if(isSdInserted() == 1) { + //////////save game play count//////////////// + extern u8 favorite; + extern u8 count; + struct Game_NUM* game_num = CFG_get_game_num(header->id); + + if (game_num) + { + favorite = game_num->favorite; + count = game_num->count;//count+=1; + + }favorite = faveChoice; + + if(isSdInserted() == 1) { + if (CFG_save_game_num(header->id)) + { + //WindowPrompt(LANGUAGE.SuccessfullySaved, 0, LANGUAGE.ok, 0,0,0); + } + else + { + WindowPrompt(LANGUAGE.SaveFailed, 0, LANGUAGE.ok, 0,0,0); + } + } else { + WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtosave, LANGUAGE.ok, 0,0,0); + } + ////////////end save play count////////////// + if (CFG_save_game_opt(header->id)) { WindowPrompt(LANGUAGE.SuccessfullySaved, 0, LANGUAGE.ok, 0,0,0); } @@ -5141,10 +5257,9 @@ int MenuOGG() scrollon = 1; } - GuiCustomOptionBrowser optionBrowser4(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, scrollon, 85); + GuiCustomOptionBrowser optionBrowser4(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, scrollon, 55); optionBrowser4.SetPosition(0, 90); optionBrowser4.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - optionBrowser4.SetCol2Position(30); int songPlaying=0;