From c6fdedb008978282e5c2c6f1f18fbe8d06d5c8d3 Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Sat, 23 May 2009 22:23:24 +0000 Subject: [PATCH] *Added wiilight settings to turn on/off and install only (issue 211) *Added DefaultSettings Button and a DefaultGameSettings Button. *Fixed OGG Menu to not codedump on path change and auto add '/' if not entered like on paths *Some small fixes --- source/cfg.c | 8 ++ source/cfg.h | 34 ++--- source/language.c | 20 +++ source/language.h | 4 + source/libwiigui/gui_button.cpp | 26 ---- source/libwiigui/gui_customoptionbrowser.cpp | 1 - source/libwiigui/gui_gamebrowser.h | 31 ----- source/main.cpp | 6 +- source/main.h | 3 +- source/menu.cpp | 133 ++++++++++--------- 10 files changed, 123 insertions(+), 143 deletions(-) diff --git a/source/cfg.c b/source/cfg.c index d25b6fa3..992b0c25 100644 --- a/source/cfg.c +++ b/source/cfg.c @@ -862,6 +862,13 @@ void global_cfg_set(char *name, char *val) } return; } + else if (strcmp(name, "wiilight") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.wiilight = i; + } + return; + } } // split line to part1 delimiter part2 @@ -1071,6 +1078,7 @@ bool cfg_save_global()// save global settings fprintf(f, "godmode = %d\n ", 0); } fprintf(f, "ogg_path = %s\n ", CFG.ogg_path); + fprintf(f, "wiilight = %d\n ", Settings.wiilight); fclose(f); return true; } diff --git a/source/cfg.h b/source/cfg.h index 60a61846..3ef38f44 100644 --- a/source/cfg.h +++ b/source/cfg.h @@ -278,35 +278,29 @@ enum { dvorak, euro, }; -/* -enum { - ParentalControlOff, - ParentalControlLevel1, - ParentalControlLevel2, - ParentalControlLevel3 -};*/ struct SSettings { - int video; - int language; + int video; + int language; int ocarina; int vpatch; int ios; - int sinfo; - int hddinfo; - int rumble; - int xflip; - int volume; + int sinfo; + int hddinfo; + int rumble; + int xflip; + int volume; int tooltips; char unlockCode[20]; - int parentalcontrol; + int parentalcontrol; int cios; - int qboot; - int wsprompt; - int keyset; + int qboot; + int wsprompt; + int keyset; int unicodefix; - int sort; - int fave; + int sort; + int fave; + int wiilight; }; void CFG_LoadGlobal(void); diff --git a/source/language.c b/source/language.c index 3e3a0f42..f9df1f15 100644 --- a/source/language.c +++ b/source/language.c @@ -77,6 +77,8 @@ snprintf(LANGUAGE.Doyouwanttoretryfor30secs, sizeof(LANGUAGE.Doyouwanttoretryfor snprintf(LANGUAGE.Downloadingfile, sizeof(LANGUAGE.Downloadingfile), "Downloading file:"); snprintf(LANGUAGE.DownloadBoxartimage, sizeof(LANGUAGE.DownloadBoxartimage), "Download Boxart image?"); snprintf(LANGUAGE.Downloadfinished, sizeof(LANGUAGE.Downloadfinished), "Download finished"); +snprintf(LANGUAGE.Defaultgamesettings, sizeof(LANGUAGE.Defaultgamesettings), "Default Gamesettings"); +snprintf(LANGUAGE.Defaultsettings, sizeof(LANGUAGE.Defaultsettings), "Default Settings"); snprintf(LANGUAGE.Error, sizeof(LANGUAGE.Error), "Error !"); snprintf(LANGUAGE.hour, sizeof(LANGUAGE.hour), "Hour"); snprintf(LANGUAGE.Homemenu, sizeof(LANGUAGE.Homemenu), "HOME Menu"); @@ -150,6 +152,7 @@ snprintf(LANGUAGE.of, sizeof(LANGUAGE.of), "of"); snprintf(LANGUAGE.OFF, sizeof(LANGUAGE.OFF), "OFF"); snprintf(LANGUAGE.OfficialSite, sizeof(LANGUAGE.OfficialSite), "Official Site"); snprintf(LANGUAGE.ON, sizeof(LANGUAGE.ON), "ON"); +snprintf(LANGUAGE.OnlyInstall, sizeof(LANGUAGE.OnlyInstall), "Only for Install"); snprintf(LANGUAGE.Parentalcontrol, sizeof(LANGUAGE.Parentalcontrol), "Parental control"); snprintf(LANGUAGE.Partition, sizeof(LANGUAGE.Partition), "Partition"); snprintf(LANGUAGE.Password, sizeof(LANGUAGE.Password), "Password"); @@ -208,6 +211,7 @@ snprintf(LANGUAGE.Waiting, sizeof(LANGUAGE.Waiting), "Waiting..."); snprintf(LANGUAGE.WaitingforUSBDevice, sizeof(LANGUAGE.WaitingforUSBDevice), "Waiting for USB Device"); snprintf(LANGUAGE.WidescreenFix, sizeof(LANGUAGE.WidescreenFix), "Widescreen Fix"); snprintf(LANGUAGE.WiiMenu, sizeof(LANGUAGE.WiiMenu), "Wii Menu"); +snprintf(LANGUAGE.Wiilight, sizeof(LANGUAGE.Wiilight), "Wiilight"); snprintf(LANGUAGE.WrongPassword, sizeof(LANGUAGE.WrongPassword), "Wrong Password"); snprintf(LANGUAGE.Yes, sizeof(LANGUAGE.Yes), "Yes"); snprintf(LANGUAGE.YoudonthavecIOS, sizeof(LANGUAGE.YoudonthavecIOS), "You don't have cIOS222"); @@ -427,6 +431,14 @@ void language_set(char *name, char *val) strcopy(LANGUAGE.Downloadfinished, val, sizeof(LANGUAGE.Downloadfinished)); return; } + if (strcmp(name, "Defaultgamesettings") == 0) { + strcopy(LANGUAGE.Defaultgamesettings, val, sizeof(LANGUAGE.Defaultgamesettings)); + return; + } + if (strcmp(name, "Defaultsettings") == 0) { + strcopy(LANGUAGE.Defaultsettings, val, sizeof(LANGUAGE.Defaultsettings)); + return; + } if (strcmp(name, "Error") == 0) { strcopy(LANGUAGE.Error, val, sizeof(LANGUAGE.Error)); return; @@ -728,6 +740,10 @@ void language_set(char *name, char *val) strcopy(LANGUAGE.OfficialSite, val, sizeof(LANGUAGE.OfficialSite)); return; } + if (strcmp(name, "OnlyInstall") == 0) { + strcopy(LANGUAGE.OnlyInstall, val, sizeof(LANGUAGE.OnlyInstall)); + return; + } if (strcmp(name, "ON") == 0) { strcopy(LANGUAGE.ON, val, sizeof(LANGUAGE.ON)); return; @@ -956,6 +972,10 @@ void language_set(char *name, char *val) strcopy(LANGUAGE.WiiMenu, val, sizeof(LANGUAGE.WiiMenu)); return; } + if (strcmp(name, "Wiilight") == 0) { + strcopy(LANGUAGE.Wiilight, val, sizeof(LANGUAGE.Wiilight)); + return; + } if (strcmp(name, "WrongPassword") == 0) { strcopy(LANGUAGE.WrongPassword, val, sizeof(LANGUAGE.WrongPassword)); return; diff --git a/source/language.h b/source/language.h index 9c46674a..748180fb 100644 --- a/source/language.h +++ b/source/language.h @@ -59,6 +59,8 @@ struct LANGUAGE char Downloadingfile[50]; char DownloadBoxartimage[50]; char Downloadfinished[50]; + char Defaultgamesettings[50]; + char Defaultsettings[40]; char Error[30]; char BOOTERROR[50]; char ErrorreadingDisc[50]; @@ -135,6 +137,7 @@ struct LANGUAGE char OfficialSite[50]; char ok[30]; char ON[30]; + char OnlyInstall[50]; char Parentalcontrol[50]; char Partition[50]; char Password[50]; @@ -192,6 +195,7 @@ struct LANGUAGE char WaitingforUSBDevice[80]; char WidescreenFix[50]; char WiiMenu[50]; + char Wiilight[20]; char WrongPassword[50]; char Yes[20]; char YoudonthavecIOS[70]; diff --git a/source/libwiigui/gui_button.cpp b/source/libwiigui/gui_button.cpp index 320dd683..66a4f8b8 100644 --- a/source/libwiigui/gui_button.cpp +++ b/source/libwiigui/gui_button.cpp @@ -141,27 +141,6 @@ void GuiButton::SetSoundClick(GuiSound * snd) soundClick = snd; } -//No delay for now -/* -void GuiButton::SetToolTip(GuiImage* img, GuiText * txt, int x, int y) -{ - LOCK(this); - if(img) - { - - toolTip = img; - img->SetParent(this); - img->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); - img->SetPosition(x,y); - if(txt) - { - toolTipTxt = txt; - txt->SetParent(img); - } - - } -} -*/ void GuiButton::SetToolTip(GuiElement* tt, int x, int y, int h_align, int v_align) { LOCK(this); @@ -249,11 +228,6 @@ void GuiButton::Update(GuiTrigger * t) else if(parentElement && parentElement->GetState() == STATE_DISABLED) return; -// if(state != STATE_SELECTED && toolTip) { -// time2 = 0; -// } - - #ifdef HW_RVL // cursor if(t->wpad.ir.valid) diff --git a/source/libwiigui/gui_customoptionbrowser.cpp b/source/libwiigui/gui_customoptionbrowser.cpp index ecf7e693..e9f8a30c 100644 --- a/source/libwiigui/gui_customoptionbrowser.cpp +++ b/source/libwiigui/gui_customoptionbrowser.cpp @@ -206,7 +206,6 @@ void GuiCustomOptionBrowser::SetFocus(int f) optionBtn[i]->ResetState(); if(f == 1) - optionBtn[selectedItem]->ResetState(); optionBtn[selectedItem]->SetState(STATE_SELECTED); } diff --git a/source/libwiigui/gui_gamebrowser.h b/source/libwiigui/gui_gamebrowser.h index b71b76f3..a5741aaf 100644 --- a/source/libwiigui/gui_gamebrowser.h +++ b/source/libwiigui/gui_gamebrowser.h @@ -3,31 +3,6 @@ #include "gui.h" #include "../disc.h" -/* -class GameBrowserList { - public: - GameBrowserList(int size) { - name = new char * [size]; - - for (int i = 0; i < size; i++) - { - name[i] = new char[50]; - } - length = size; - }; - ~GameBrowserList(){ - for (int i = 0; i < length; i++) - { - delete [] name[i]; - } - delete [] name; - }; - - public: - int length; - char ** name; -}; -*/ class GuiGameBrowser : public GuiElement { @@ -69,22 +44,16 @@ class GuiGameBrowser : public GuiElement GuiImage * scrollbarImg; GuiImage * arrowDownImg; GuiImage * arrowDownOverImg; - GuiImage * ttarrowUpImg; - GuiImage * ttarrowDownImg; GuiImage * arrowUpImg; GuiImage * arrowUpOverImg; GuiImage * scrollbarBoxImg; GuiImage * scrollbarBoxOverImg; - GuiText * ttarrowDownTxt; - GuiText * ttarrowUpTxt; - GuiImageData * bgGames; GuiImageData * bgGamesEntry; GuiImageData * scrollbar; GuiImageData * arrowDown; GuiImageData * arrowDownOver; - GuiImageData * ttarrow; GuiImageData * arrowUp; GuiImageData * arrowUpOver; GuiImageData * scrollbarBox; diff --git a/source/main.cpp b/source/main.cpp index bd4ce032..49ab08aa 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -31,7 +31,8 @@ #include "video2.h" #include "wpad.h" #include "cfg.h" -#include "language.h" +#include "language.h" +#include "fat.h" /* Constants */ @@ -99,6 +100,7 @@ DefaultSettings() Settings.xflip = no; Settings.qboot = no; Settings.unicodefix = 0; + Settings.wiilight = 1; CFG_LoadGlobal(); } @@ -134,6 +136,8 @@ main(int argc, char *argv[]) printf("ERROR: cIOS could not be loaded!"); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } + + fatInit(1, true); SDCard_Init(); diff --git a/source/main.h b/source/main.h index 7af49813..14755619 100644 --- a/source/main.h +++ b/source/main.h @@ -12,7 +12,8 @@ extern struct SSettings Settings; -void ExitApp(); +void ExitApp(); +void DefaultSettings(); extern int ExitRequested; extern FreeTypeGX *fontSystem; extern bool netcheck; diff --git a/source/menu.cpp b/source/menu.cpp index e579b9a9..a3fa8e24 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -100,8 +100,9 @@ extern u8 reset; static vu32 *_wiilight_reg = (u32*)0xCD0000C0; void wiilight(int enable){ // Toggle wiilight (thanks Bool for wiilight source) u32 val = (*_wiilight_reg&~0x20); - if(enable) val |= 0x20; - *_wiilight_reg=val;} + if(enable && Settings.wiilight) val |= 0x20; + *_wiilight_reg=val; +} //Prototypes int WindowPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, const char *btn3Label, const char *btn4Label); @@ -2636,6 +2637,7 @@ static int MenuInstall() sprintf(gametxt, "%s : %.2fGB", name, gamesize); + wiilight(1); choice = WindowPrompt(LANGUAGE.Continueinstallgame,gametxt,LANGUAGE.ok,LANGUAGE.Cancel,0,0); if(choice == 1) { @@ -2647,6 +2649,7 @@ static int MenuInstall() sprintf(errortxt, "%s: %.2fGB, %s: %.2fGB",LANGUAGE.GameSize, gamesize, LANGUAGE.FreeSpace, freespace); choice = WindowPrompt(LANGUAGE.Notenoughfreespace,errortxt,LANGUAGE.ok, LANGUAGE.Return,0,0); if (choice == 1) { + wiilight(1); ret = ProgressWindow(gametxt, name); if (ret != 0) { WindowPrompt (LANGUAGE.Installerror,0,LANGUAGE.Back,0,0,0); @@ -2654,11 +2657,10 @@ static int MenuInstall() break; } else { + wiilight(1); __Menu_GetEntries(); //get the entries again - wiilight(1); WindowPrompt (LANGUAGE.Successfullyinstalled,name,LANGUAGE.ok,0,0,0); menu = MENU_DISCLIST; - wiilight(0); break; } } else { @@ -2675,25 +2677,28 @@ static int MenuInstall() break; } else { __Menu_GetEntries(); //get the entries again - wiilight(1); WindowPrompt (LANGUAGE.Successfullyinstalled,name,LANGUAGE.ok,0,0,0); menu = MENU_DISCLIST; - wiilight(0); break; } } } else { menu = MENU_DISCLIST; - wiilight(0); break; } - if (shutdown == 1) + if (shutdown == 1) { + wiilight(0); Sys_Shutdown(); - if(reset == 1) + } + if(reset == 1) { + wiilight(0); Sys_Reboot(); + } } + //Turn off the WiiLight + wiilight(0); HaltGui(); @@ -3189,7 +3194,7 @@ static int MenuDiscList() } else { WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtodownloadimages, LANGUAGE.ok, 0,0,0); } - DownloadBtn.ResetState(); + DownloadBtn.ResetState(); gameBrowser.SetFocus(1); }//end download @@ -3486,7 +3491,7 @@ static int MenuDiscList() { returnHere = false; - wiilight(1); + if(Settings.wiilight != 2) wiilight(1); choice = GameWindowPrompt(); header = &gameList[gameSelected]; //reset header @@ -4108,10 +4113,10 @@ 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.Wiilight); sprintf(options2.name[6], " "); - sprintf(options2.name[7], " "); - sprintf(options2.name[8], "%s",LANGUAGE.MP3Menu); + sprintf(options2.name[7], "%s",LANGUAGE.MP3Menu); + sprintf(options2.name[8], "%s",LANGUAGE.Defaultsettings); } while(menu == MENU_NONE) @@ -4513,8 +4518,8 @@ static int MenuSettings() Settings.keyset = 0; if ( Settings.unicodefix > 2 ) Settings.unicodefix = 0; - //if ( Settings.sort > 2 ) - // Settings.sort = 0; + if ( Settings.wiilight > 2 ) + Settings.wiilight = 0; if (strlen(CFG.titlestxt_path) < (9 + 3)) { sprintf(cfgtext, "%s", CFG.titlestxt_path); @@ -4556,10 +4561,13 @@ static int MenuSettings() sprintf(options2.value[4], "%s", cfgtext); } - sprintf(options2.value[5], " "); + if (Settings.wiilight == 0) sprintf (options2.value[5],"%s",LANGUAGE.OFF); + else if (Settings.wiilight == 1) sprintf (options2.value[5],"%s",LANGUAGE.ON); + else if (Settings.wiilight == 2) sprintf (options2.value[5],"%s",LANGUAGE.OnlyInstall); + sprintf(options2.value[6], " "); - sprintf(options2.value[7], " "); - sprintf(options2.value[8], "not working!"); + sprintf(options2.value[7], "not working!"); + sprintf(options2.value[8], " "); ret = optionBrowser2.GetClickedOption(); @@ -4662,14 +4670,30 @@ static int MenuSettings() WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtousethatoption, LANGUAGE.ok, 0,0,0); } break; - case 8: - if(isSdInserted() == 1) { + case 5: + Settings.wiilight++; + break; + case 7: + if(isSdInserted()) { menu = MENU_MP3; pageToDisplay = 0; } else { WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtousethatoption, LANGUAGE.ok, 0,0,0); } break; + case 8: + int choice = WindowPrompt(LANGUAGE.Areyousure, 0, LANGUAGE.Yes, LANGUAGE.Cancel, 0, 0); + if(choice == 1) { + if(isSdInserted()) { + remove("SD:/config/GXGlobal.cfg"); + } + lang_default(); + CFG_Load(); + DefaultSettings(); + menu = MENU_SETTINGS; + pageToDisplay = 0; + } + break; } } @@ -4820,13 +4844,14 @@ int GameSettings(struct discHdr * header) strncat(gameName, "...", 3); } - customOptionList options3(6); + customOptionList options3(7); 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],"Parental Control");//sprintf(options3.name[5],"%s", LANGUAGE.addToFavorite); + sprintf(options3.name[6],"%s", LANGUAGE.Defaultgamesettings); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, vol); @@ -4921,19 +4946,6 @@ int GameSettings(struct discHdr * header) mainWindow->Append(&optionBrowser3); ResumeGui(); - //extern u8 favorite; - /*extern u16 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); @@ -5004,6 +5016,8 @@ int GameSettings(struct discHdr * header) if(reset == 1) Sys_Reboot(); + sprintf(options3.value[6]," "); + ret = optionBrowser3.GetClickedOption(); switch (ret) @@ -5026,38 +5040,28 @@ int GameSettings(struct discHdr * header) case 5: parentalcontrolChoice = (parentalcontrolChoice + 1) % 4; break; + case 6: + int choice = WindowPrompt(LANGUAGE.Areyousure,0,LANGUAGE.Yes,LANGUAGE.Cancel,0,0); + if(choice == 1) { + videoChoice = discdefault; + viChoice = off; + languageChoice = ConsoleLangDefault; + ocarinaChoice = off; + if(Settings.cios == ios222) { + iosChoice = i222; + } else { + iosChoice = i249; + } + parentalcontrolChoice = 0; + } + break; } if(saveBtn.GetState() == STATE_CLICKED) { 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)) + if (CFG_save_game_opt(header->id)) { WindowPrompt(LANGUAGE.SuccessfullySaved, 0, LANGUAGE.ok, 0,0,0); } @@ -5428,14 +5432,17 @@ int MenuOGG() w.Append(&prevBtn); w.Append(&stopBtn); if ( result == 1 ) { + int len = (strlen(entered)-1); + if(entered[len] !='/') + strncat (entered, "/", 1); strncpy(CFG.oggload_path, entered, sizeof(CFG.oggload_path)); WindowPrompt(LANGUAGE.Backgroundmusicpath,0,LANGUAGE.ok,0,0,0); - if(isSdInserted() == 1) { - cfg_save_global(); + if(isSdInserted()) { if(!strcmp("", CFG.oggload_path)) { sprintf(CFG.ogg_path, "notset"); bgMusic->Play(); } + //cfg_save_global(); menu = MENU_OGG; break; } else {