From 7e02aeb63f8aee8c568223118673cdd53976452d Mon Sep 17 00:00:00 2001
From: dimok321 <15055714+dimok789@users.noreply.github.com>
Date: Sat, 9 May 2009 22:37:14 +0000
Subject: [PATCH] *Moved everything from config.txt to global_settings.cfg
*Added cover/discimage/theme path edit through global settings *Changed if no
password is set, you are always godmode (even after reloading GUI). If you
have password set: the unlock is only till you leave.
---
gui.pnproj | 2 +-
source/cfg.c | 28 +++++++----
source/cfg.h | 2 +-
source/menu.cpp | 124 ++++++++++++++++++++++++++++++++++++++++++++----
4 files changed, 136 insertions(+), 20 deletions(-)
diff --git a/gui.pnproj b/gui.pnproj
index bc39748f..b229d3be 100644
--- a/gui.pnproj
+++ b/gui.pnproj
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/source/cfg.c b/source/cfg.c
index e8542b7c..6a43fd6d 100644
--- a/source/cfg.c
+++ b/source/cfg.c
@@ -195,7 +195,7 @@ void CFG_Default(int widescreen) // -1 = non forced Mode
snprintf(CFG.theme_path, sizeof(CFG.theme_path), "SD:/theme/");
}
- snprintf(CFG.covers_path, sizeof(CFG.covers_path), "SD:/images/"); //default image path
+ snprintf(CFG.covers_path, sizeof(CFG.covers_path), "SD:/images/"); //default image path
snprintf(CFG.disc_path, sizeof(CFG.disc_path), "SD:/images/disc/");//default path for disc images
snprintf(CFG.unlockCode, sizeof(CFG.unlockCode), "ab121b"); // default passwore
@@ -204,7 +204,7 @@ void CFG_Default(int widescreen) // -1 = non forced Mode
CFG.godmode = 0;
CFG.xflip = 0;
CFG.wsprompt = 0;
-
+
//all alignments are left top here
THEME.selection_x = 200;
THEME.selection_y = 40;
@@ -416,7 +416,7 @@ void cfg_set(char *name, char *val)
cfg_map("home", "reboot", &CFG.home, CFG_HOME_REBOOT);
cfg_int("simple", &CFG.simple, 3);
*/
-
+
// if these are defined in txt file, use them. otherwise use defaults
if (!CFG.widescreen &&(strcmp(name, "theme_path") == 0)) {// if in 4:3
@@ -591,7 +591,7 @@ void theme_set(char *name, char *val)
THEME.info_b = z;
}
}
-
+
else if (strcmp(cfg_name, "gametext_color") == 0) {
short x,y,z;
if (sscanf(val, "%hd,%hd, %hd", &x, &y, &z) == 3) {
@@ -607,7 +607,7 @@ void theme_set(char *name, char *val)
THEME.pagesize = x;
}
}
-
+
cfg_bool("show_id", &THEME.showID);
cfg_bool("show_tooltip", &THEME.showToolTip);
cfg_bool("show_hddinfo", &THEME.showHDD);
@@ -909,7 +909,19 @@ bool cfg_save_global()// save global settings
fprintf(f, "cios = %d\n ", Settings.cios);
fprintf(f, "xflip = %d\n ", Settings.xflip);
fprintf(f, "qboot = %d\n ", Settings.qboot);
- fprintf(f, "wsprompt = %d\n ", Settings.wsprompt);
+ fprintf(f, "parentalcontrol = %d\n ", CFG.parentalcontrol);
+ fprintf(f, "cover_path = %s\n ", CFG.covers_path);
+ if(CFG.widescreen) {
+ fprintf(f, "wtheme_path = %s\n ", CFG.theme_path);
+ } else {
+ fprintf(f, "theme_path = %s\n ", CFG.theme_path);
+ }
+ fprintf(f, "disc_path = %s\n ", CFG.disc_path);
+ if(!strcmp("", Settings.unlockCode)) {
+ fprintf(f, "godmode = %d\n ", CFG.godmode);
+ } else {
+ fprintf(f, "godmode = %d\n ", 0);
+ }
fclose(f);
return true;
}
@@ -972,7 +984,7 @@ void game_set(char *name, char *val)
game->parentalcontrol = opt_c;
}
}
-
+
}
// next opt
if (np) p = np + 1; else p = NULL;
@@ -1082,7 +1094,7 @@ void CFG_Load(int argc, char **argv)
CFG_Default(-1); // set defaults non forced
- snprintf(pathname, sizeof(pathname), "SD:/config/config.txt");
+ snprintf(pathname, sizeof(pathname), "SD:/config/global_settings.cfg");
cfg_parsefile(pathname, &widescreen_set); //first set widescreen
cfg_parsefile(pathname, &cfg_set); //then set config and layout options
diff --git a/source/cfg.h b/source/cfg.h
index 1b497ba0..34c3f84f 100644
--- a/source/cfg.h
+++ b/source/cfg.h
@@ -62,7 +62,7 @@ struct CFG
short parentalcontrol;
short maxcharacters;
short godmode;
- short xflip;
+ short xflip;
short wsprompt;
char unlockCode[20];
char covers_path[100];
diff --git a/source/menu.cpp b/source/menu.cpp
index c6d5bd51..7ff85bb3 100644
--- a/source/menu.cpp
+++ b/source/menu.cpp
@@ -3233,7 +3233,11 @@ static int MenuSettings()
GuiTrigger trigL;
trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT, PAD_BUTTON_LEFT);
GuiTrigger trigR;
- trigL.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
+ trigR.SetButtonOnlyTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
+ GuiTrigger trigMinus;
+ trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
+ GuiTrigger trigPlus;
+ trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
GuiText titleTxt("Settings", 28, (GXColor){0, 0, 0, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@@ -3271,6 +3275,7 @@ static int MenuSettings()
page1Btn.SetSoundClick(&btnClick);
page1Btn.SetTrigger(&trigA);
page1Btn.SetTrigger(&trigL);
+ page1Btn.SetTrigger(&trigMinus);
GuiTooltip page1BtnTT("Go to Page 1");
if (Settings.wsprompt == yes)
@@ -3289,6 +3294,7 @@ static int MenuSettings()
page2Btn.SetSoundClick(&btnClick);
page2Btn.SetTrigger(&trigA);
page2Btn.SetTrigger(&trigR);
+ page2Btn.SetTrigger(&trigPlus);
GuiTooltip page2BtnTT("Go to Page 2");
if (Settings.wsprompt == yes)
@@ -3381,10 +3387,10 @@ static int MenuSettings()
sprintf(options2.name[2], "Flip X");
sprintf(options2.name[3], "Quick Boot");
sprintf(options2.name[4], "Prompts & Buttons");
- sprintf(options2.name[5], " ");
- sprintf(options2.name[6], " ");
- sprintf(options2.name[7], " ");
- sprintf(options2.name[8], " ");
+ sprintf(options2.name[5], "Parentalcontrol");
+ sprintf(options2.name[6], "Cover Path");
+ sprintf(options2.name[7], "Discimage Path");
+ sprintf(options2.name[8], "Theme Path");
}
while(menu == MENU_NONE)
@@ -3508,6 +3514,8 @@ static int MenuSettings()
Settings.qboot = 0;
if ( Settings.wsprompt > 1 )
Settings.wsprompt = 0;
+ if (CFG.parentalcontrol > 3 )
+ CFG.parentalcontrol = 0;
if ( CFG.godmode != 1) sprintf(options2.value[0], "********");
@@ -3526,11 +3534,20 @@ static int MenuSettings()
if (Settings.wsprompt == no) sprintf (options2.value[4],"Normal");
else if (Settings.wsprompt == yes) sprintf (options2.value[4],"Widescreen Fix");
- sprintf (options2.value[5]," ");
- sprintf (options2.value[6]," ");
- sprintf (options2.value[7]," ");
- sprintf (options2.value[8]," ");
+ if (CFG.godmode != 1) sprintf(options2.value[5], "********");
+ else if(CFG.parentalcontrol == 0) sprintf(options2.value[5], "0");
+ else if(CFG.parentalcontrol == 1) sprintf(options2.value[5], "1");
+ else if(CFG.parentalcontrol == 2) sprintf(options2.value[5], "2");
+ else if(CFG.parentalcontrol == 3) sprintf(options2.value[5], "3");
+ if (CFG.godmode != 1) sprintf(options2.value[6], "********");
+ else sprintf(options2.value[6], CFG.covers_path);
+
+ if (CFG.godmode != 1) sprintf(options2.value[7], "********");
+ else sprintf(options2.value[7], CFG.disc_path);
+
+ if (CFG.godmode != 1) sprintf(options2.value[8], "********");
+ else sprintf(options2.value[8], CFG.theme_path);
ret = optionBrowser2.GetClickedOption();
@@ -3548,9 +3565,9 @@ static int MenuSettings()
char entered[20] = "";
strncpy(entered, Settings.unlockCode, sizeof(entered));
int result = OnScreenKeyboard(entered, 20);
+ mainWindow->Append(&optionBrowser2);
mainWindow->Append(&page1Btn);
mainWindow->Append(&page2Btn);
- mainWindow->Append(&optionBrowser2);
w.Append(&backBtn);
w.Append(&lockBtn);
if ( result == 1 )
@@ -3577,6 +3594,93 @@ static int MenuSettings()
case 4:
Settings.wsprompt++;
break;
+ case 5:
+ CFG.parentalcontrol++;
+ break;
+ case 6:
+ if ( CFG.godmode == 1)
+ {
+ mainWindow->Remove(&optionBrowser2);
+ mainWindow->Remove(&page1Btn);
+ mainWindow->Remove(&page2Btn);
+ w.Remove(&backBtn);
+ w.Remove(&lockBtn);
+ char entered[20] = "";
+ strncpy(entered, CFG.covers_path, sizeof(entered));
+ int result = OnScreenKeyboard(entered, 20);
+ mainWindow->Append(&optionBrowser2);
+ mainWindow->Append(&page1Btn);
+ mainWindow->Append(&page2Btn);
+ w.Append(&backBtn);
+ w.Append(&lockBtn);
+ if ( result == 1 )
+ {
+ strncpy(CFG.covers_path, entered, sizeof(CFG.covers_path));
+ WindowPrompt("Coverpath Changed",0,"OK",0,0,0);
+ cfg_save_global();
+ }
+ }
+ else
+ {
+ WindowPrompt("Coverpath change","Console should be unlocked to modify it.","OK",0,0,0);
+ }
+ break;
+ case 7:
+ if ( CFG.godmode == 1)
+ {
+ mainWindow->Remove(&optionBrowser2);
+ mainWindow->Remove(&page1Btn);
+ mainWindow->Remove(&page2Btn);
+ w.Remove(&backBtn);
+ w.Remove(&lockBtn);
+ char entered[20] = "";
+ strncpy(entered, CFG.disc_path, sizeof(entered));
+ int result = OnScreenKeyboard(entered, 20);
+ mainWindow->Append(&optionBrowser2);
+ mainWindow->Append(&page1Btn);
+ mainWindow->Append(&page2Btn);
+ w.Append(&backBtn);
+ w.Append(&lockBtn);
+ if ( result == 1 )
+ {
+ strncpy(CFG.disc_path, entered, sizeof(CFG.disc_path));
+ WindowPrompt("Discpath Changed",0,"OK",0,0,0);
+ cfg_save_global();
+ }
+ }
+ else
+ {
+ WindowPrompt("Discpath change","Console should be unlocked to modify it.","OK",0,0,0);
+ }
+ break;
+ case 8:
+ if ( CFG.godmode == 1)
+ {
+ mainWindow->Remove(&optionBrowser2);
+ mainWindow->Remove(&page1Btn);
+ mainWindow->Remove(&page2Btn);
+ w.Remove(&backBtn);
+ w.Remove(&lockBtn);
+ char entered[20] = "";
+ strncpy(entered, CFG.theme_path, sizeof(entered));
+ int result = OnScreenKeyboard(entered, 20);
+ mainWindow->Append(&optionBrowser2);
+ mainWindow->Append(&page1Btn);
+ mainWindow->Append(&page2Btn);
+ w.Append(&backBtn);
+ w.Append(&lockBtn);
+ if ( result == 1 )
+ {
+ strncpy(CFG.theme_path, entered, sizeof(CFG.theme_path));
+ WindowPrompt("Themepath Changed",0,"OK",0,0,0);
+ cfg_save_global();
+ }
+ }
+ else
+ {
+ WindowPrompt("Themepath change","Console should be unlocked to modify it.","OK",0,0,0);
+ }
+ break;
}
}