diff --git a/Makefile b/Makefile index aa570da3c..d8f43c6b7 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ EE_ASM_DIR = asm/ MAPFILE = opl.map EE_LDFLAGS += -Wl,-Map,$(MAPFILE) -EE_LIBS = -L$(PS2SDK)/ports/lib -L$(GSKIT)/lib -L./lib -lgskit -ldmakit -lgskit_toolkit -lpoweroff -lfileXio -lpatches -ljpeg -lpng -lz -ldebug -lm -lmc -lfreetype -lvux -lcdvd -lnetman -lps2ips -laudsrv -lc +EE_LIBS = -L$(PS2SDK)/ports/lib -L$(GSKIT)/lib -L./lib -lgskit -ldmakit -lgskit_toolkit -lpoweroff -lfileXio -lpatches -ljpeg -lpng -lz -ldebug -lm -lmc -lfreetype -lvux -lcdvd -lnetman -lps2ips -laudsrv EE_INCS += -I$(PS2SDK)/ports/include -I$(GSKIT)/include -I$(GSKIT)/ee/dma/include -I$(GSKIT)/ee/gs/include -I$(GSKIT)/ee/toolkit/include -Imodules/iopcore/common -Imodules/network/common -Imodules/hdd/common -Iinclude BIN2C = $(PS2SDK)/bin/bin2c diff --git a/include/config.h b/include/config.h index 9f8e07bfd..78f55be65 100644 --- a/include/config.h +++ b/include/config.h @@ -59,6 +59,7 @@ enum CONFIG_INDEX { #define CONFIG_OPL_UI_TEXTCOLOR "ui_text_color" #define CONFIG_OPL_SEL_TEXTCOLOR "sel_text_color" #define CONFIG_OPL_USE_INFOSCREEN "use_info_screen" +#define CONFIG_OPL_ENABLE_NOTIFICATIONS "enable_notifications" #define CONFIG_OPL_ENABLE_COVERART "enable_coverart" #define CONFIG_OPL_WIDESCREEN "wide_screen" #define CONFIG_OPL_VMODE "vmode" @@ -158,4 +159,7 @@ void configGetVMC(config_set_t *configSet, char *vmc, int length, int slot); void configSetVMC(config_set_t *configSet, const char *vmc, int slot); void configRemoveVMC(config_set_t *configSet, int slot); +char *configGetDir(void); +void configPrepareNotifications(char *prefix); + #endif diff --git a/include/dialogs.h b/include/dialogs.h index 4952804d1..c4c772e53 100644 --- a/include/dialogs.h +++ b/include/dialogs.h @@ -23,6 +23,7 @@ enum UI_ITEMS { UICFG_YOFF, UICFG_OVERSCAN, UICFG_INFOPAGE, + UICFG_NOTIFICATIONS, CFG_DEBUG, CFG_PS2LOGO, @@ -47,7 +48,7 @@ enum UI_ITEMS { ABOUT_BUILD_DETAILS, CFG_PARENLOCK_PASSWORD, - + CFG_SFX, CFG_BOOT_SND, CFG_SFX_VOLUME, diff --git a/include/lang.h b/include/lang.h index 9d12f2756..38a7449cf 100644 --- a/include/lang.h +++ b/include/lang.h @@ -267,6 +267,8 @@ enum _STR_IDS { _STR_BOOT_SND_VOLUME, _STR_CFM_VMODE_CHG, _STR_CACHE_HDD_GAME_LIST, + _STR_ENABLE_NOTIFICATIONS, + _STR_NOTIFICATIONS, LANG_STR_COUNT }; @@ -283,15 +285,16 @@ typedef struct char *name; } language_t; -int lngAddLanguages(char *path, const char *separator); +int lngAddLanguages(char *path, const char *separator, int mode); void lngInit(void); char *lngGetValue(void); void lngEnd(void); // Indices are shifted in GUI, as we add the internal english language at 0 -void lngSetGuiValue(int langGuiId); +int lngSetGuiValue(int langID); int lngGetGuiValue(void); int lngFindGuiID(const char *lang); char **lngGetGuiList(void); +char *lngGetFilePath(int langID); #endif diff --git a/include/opl.h b/include/opl.h index 83c4e5e71..c31752ad4 100644 --- a/include/opl.h +++ b/include/opl.h @@ -74,7 +74,7 @@ int loadConfig(int types); int saveConfig(int types, int showUI); void applyConfig(int themeID, int langID); void menuDeferredUpdate(void *data); -void moduleUpdateMenu(int mode, int themeChanged); +void moduleUpdateMenu(int mode, int themeChanged, int langChanged); void handleHdlSrv(); void deinit(int exception, int modeSelected); @@ -119,6 +119,7 @@ int gAPPStartMode; int gAutosort; int gAutoRefresh; int gUseInfoScreen; +int gEnableNotifications; int gEnableArt; int gWideScreen; int gVMode; // 0 - Auto, 1 - PAL, 2 - NTSC @@ -136,6 +137,8 @@ int gBootSndVolume; int gFadeDelay; int toggleSfx; +int showCfgPopup; + #ifdef IGS #define IGS_VERSION "0.1" #endif diff --git a/include/sound.h b/include/sound.h index 05ed6bf97..ed457c084 100644 --- a/include/sound.h +++ b/include/sound.h @@ -16,6 +16,4 @@ int sfxInit(int bootSnd); void sfxVolume(void); void sfxPlay(int id); -int thmSfxEnabled; - #endif diff --git a/include/themes.h b/include/themes.h index 4805d2106..cac5e910c 100644 --- a/include/themes.h +++ b/include/themes.h @@ -136,5 +136,6 @@ int thmSetGuiValue(int themeID, int reload); int thmGetGuiValue(void); int thmFindGuiID(const char *theme); const char **thmGetGuiList(void); +char *thmGetFilePath(int themeID); #endif diff --git a/include/util.h b/include/util.h index 55023d759..966d18fea 100644 --- a/include/util.h +++ b/include/util.h @@ -3,6 +3,7 @@ #include +int getmcID(void); int getFileSize(int fd); int openFile(char *path, int mode); void *readFile(char *path, int align, int *size); diff --git a/src/config.c b/src/config.c index 1562e7296..325b19008 100644 --- a/src/config.c +++ b/src/config.c @@ -152,6 +152,27 @@ static struct config_value_t *getConfigItemForName(config_set_t *configSet, cons return val; } +static char cfgDevice[8]; + +char *configGetDir(void) +{ + char *path = cfgDevice; + return path; +} + +void configPrepareNotifications(char *prefix) +{ + int mcID; + + snprintf(cfgDevice, sizeof(cfgDevice), prefix); + if (!strncmp(cfgDevice, "mc?", 3)) { + mcID = getmcID(); + cfgDevice[2] = mcID; + } + + showCfgPopup = 1; +} + void configInit(char *prefix) { char path[256]; @@ -166,6 +187,8 @@ void configInit(char *prefix) snprintf(path, sizeof(path), "%s/%s", prefix, configFilenames[i]); configAlloc(1 << i, &configFiles[i], path); } + + configPrepareNotifications(prefix); } void configSetMove(char *prefix) diff --git a/src/dia.c b/src/dia.c index 36e1ef9b8..5e1939eec 100644 --- a/src/dia.c +++ b/src/dia.c @@ -13,9 +13,7 @@ #include "include/fntsys.h" #include "include/themes.h" #include "include/util.h" - #include "include/sound.h" -#include // UI spacing of the dialogues (pixels between consecutive items) #define UI_SPACING_H 10 diff --git a/src/dialogs.c b/src/dialogs.c index f6291ef3f..0d7678fc5 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -365,6 +365,11 @@ struct UIItem diaUIConfig[] = { {UI_LABEL, 0, 1, 1, -1, -40, 0, {.label = {NULL, _STR_USE_INFO_SCREEN}}}, {UI_SPACER}, {UI_BOOL, UICFG_INFOPAGE, 1, 1, -1, 0, 0, {.intvalue = {0, 0}}}, + {UI_BREAK}, + + {UI_LABEL, 0, 1, 1, -1, -40, 0, {.label = {NULL, _STR_ENABLE_NOTIFICATIONS}}}, + {UI_SPACER}, + {UI_BOOL, UICFG_NOTIFICATIONS, 1, 1, -1, 0, 0, {.intvalue = {0, 0}}}, {UI_SPLITTER}, {UI_LABEL, 0, 1, 1, -1, -30, 0, {.label = {NULL, _STR_TXTCOLOR}}}, diff --git a/src/ethsupport.c b/src/ethsupport.c index ecfb92257..eaa4a85d4 100644 --- a/src/ethsupport.c +++ b/src/ethsupport.c @@ -259,7 +259,7 @@ static void ethInitSMB(void) thmAddElements(path, "\\", ethGameList.mode); sprintf(path, "%sLNG", ethPrefix); - lngAddLanguages(path, "\\"); + lngAddLanguages(path, "\\", ethGameList.mode); sbCreateFolders(ethPrefix, 1); } else if (gPCShareName[0] || !(gNetworkStartup >= ERROR_ETH_SMB_OPENSHARE)) { diff --git a/src/gui.c b/src/gui.c index 16442d9a9..317e74536 100644 --- a/src/gui.c +++ b/src/gui.c @@ -20,9 +20,7 @@ #include "include/compatupd.h" #include "include/pggsm.h" #include "include/cheatman.h" - #include "include/sound.h" -#include #ifdef PADEMU #include @@ -50,6 +48,12 @@ static ee_sema_t gQueueSema; static int screenWidth; static int screenHeight; +static int popupSfxPlayed; +static int popupTimer; + +static int showThmPopup; +static int showLngPopup; + // forward decl. static void guiShow(); @@ -234,6 +238,92 @@ void guiShowAbout() toggleSfx = 0; } +static void guiBootNotifications(void) +{ + if (gEnableNotifications) { + int themeID = thmGetGuiValue(); + if (themeID != 0) + showThmPopup = 1; + + int langID = lngGetGuiValue(); + if (langID != 0) + showLngPopup = 1; + + if (showThmPopup || showLngPopup || showCfgPopup) { + popupSfxPlayed = 0; + popupTimer -= 30; + } + } +} + +static void guiResetNotifications(void) +{ + popupSfxPlayed = 1; + popupTimer = 0; + showThmPopup = 0; + showLngPopup = 0; +} + +static void guiShowNotifications(void) +{ + int x; + int y = 10; + int yadd = 35; + char notification[32]; + char *col_pos; + + if (showThmPopup || showLngPopup || showCfgPopup) + popupTimer++; + + if (!popupSfxPlayed && popupTimer >= 20) { + sfxPlay(SFX_MESSAGE); + popupSfxPlayed = 1; + } + + if (showCfgPopup && popupTimer >= 20) { + char *path = configGetDir(); + snprintf(notification, sizeof(notification), _l(_STR_NOTIFICATIONS), "CFG", path); + if ((col_pos = strchr(notification, ':')) != NULL) + *(col_pos + 1) = '\0'; + + x = screenWidth - rmUnScaleX(fntCalcDimensions(gTheme->fonts[0], notification)) - 10; + + rmDrawRect(x, y, screenWidth - x, MENU_ITEM_HEIGHT + 10, gColDarker); + fntRenderString(gTheme->fonts[0], x + 5, y + 5, ALIGN_NONE, 0, 0, notification, gTheme->textColor); + } + y += yadd; + + if (showThmPopup && popupTimer >= 20) { + char *path = thmGetFilePath(thmGetGuiValue()); + snprintf(notification, sizeof(notification), _l(_STR_NOTIFICATIONS), "THM", path); + if ((col_pos = strchr(notification, ':')) != NULL) + *(col_pos + 1) = '\0'; + + x = screenWidth - rmUnScaleX(fntCalcDimensions(gTheme->fonts[0], notification)) - 10; + + rmDrawRect(x, y, screenWidth - x, MENU_ITEM_HEIGHT + 10, gColDarker); + fntRenderString(gTheme->fonts[0], x + 5, y + 5, ALIGN_NONE, 0, 0, notification, gTheme->textColor); + } + y += yadd; + + if (showLngPopup && popupTimer >= 20) { + char *path = lngGetFilePath(lngGetGuiValue()); + snprintf(notification, sizeof(notification), _l(_STR_NOTIFICATIONS), "LNG", path); + if ((col_pos = strchr(notification, ':')) != NULL) + *(col_pos + 1) = '\0'; + + x = screenWidth - rmUnScaleX(fntCalcDimensions(gTheme->fonts[0], notification)) - 10; + + rmDrawRect(x, y, screenWidth - x, MENU_ITEM_HEIGHT + 10, gColDarker); + fntRenderString(gTheme->fonts[0], x + 5, y + 5, ALIGN_NONE, 0, 0, notification, gTheme->textColor); + } + + if (popupTimer >= CLOCKS_PER_SEC / 2000) { + guiResetNotifications(); + showCfgPopup = 0; + } +} + static int guiNetCompatUpdRefresh(int modified) { int result; @@ -502,6 +592,8 @@ static int guiUIUpdater(int modified) void guiShowUIConfig(void) { curTheme = -1; + showCfgPopup = 0; + guiResetNotifications(); // configure the enumerations const char *scrollSpeeds[] = {_l(_STR_SLOW), _l(_STR_MEDIUM), _l(_STR_FAST), NULL}; @@ -519,6 +611,8 @@ void guiShowUIConfig(void) , "HDTV 1920x1080i @60Hz 16bit (HIRES)" , NULL}; int previousVMode; + int previousTheme = thmGetGuiValue(); + int previousLang = lngGetGuiValue(); reselect_video_mode: previousVMode = gVMode; @@ -532,6 +626,7 @@ void guiShowUIConfig(void) diaSetInt(diaUIConfig, UICFG_AUTOSORT, gAutosort); diaSetInt(diaUIConfig, UICFG_AUTOREFRESH, gAutoRefresh); diaSetInt(diaUIConfig, UICFG_INFOPAGE, gUseInfoScreen); + diaSetInt(diaUIConfig, UICFG_NOTIFICATIONS, gEnableNotifications); diaSetInt(diaUIConfig, UICFG_COVERART, gEnableArt); diaSetInt(diaUIConfig, UICFG_WIDESCREEN, gWideScreen); diaSetInt(diaUIConfig, UICFG_VMODE, gVMode); @@ -555,6 +650,7 @@ void guiShowUIConfig(void) diaGetInt(diaUIConfig, UICFG_AUTOSORT, &gAutosort); diaGetInt(diaUIConfig, UICFG_AUTOREFRESH, &gAutoRefresh); diaGetInt(diaUIConfig, UICFG_INFOPAGE, &gUseInfoScreen); + diaGetInt(diaUIConfig, UICFG_NOTIFICATIONS, &gEnableNotifications); diaGetInt(diaUIConfig, UICFG_COVERART, &gEnableArt); diaGetInt(diaUIConfig, UICFG_WIDESCREEN, &gWideScreen); diaGetInt(diaUIConfig, UICFG_VMODE, &gVMode); @@ -566,6 +662,16 @@ void guiShowUIConfig(void) //wait 70ms for confirm sound to finish playing before clearing buffer guiDelay(0070); sfxInit(0); + + if (previousTheme != themeID && themeID != 0) { + showThmPopup = 1; + popupSfxPlayed = 0; + } + + if (previousLang != langID && langID != 0) { + showLngPopup = 1; + popupSfxPlayed = 0; + } } if (previousVMode != gVMode) { @@ -1104,14 +1210,14 @@ void guiShowParentalLockConfig(void) void guiShowAudioConfig(void) { - int ret; + int ret; diaSetInt(diaAudioConfig, CFG_SFX, gEnableSFX); diaSetInt(diaAudioConfig, CFG_BOOT_SND, gEnableBootSND); diaSetInt(diaAudioConfig, CFG_SFX_VOLUME, gSFXVolume); diaSetInt(diaAudioConfig, CFG_BOOT_SND_VOLUME, gBootSndVolume); - ret = diaExecuteDialog(diaAudioConfig, -1, 1, &guiUpdater); + ret = diaExecuteDialog(diaAudioConfig, -1, 1, NULL); if (ret) { diaGetInt(diaAudioConfig, CFG_SFX, &gEnableSFX); diaGetInt(diaAudioConfig, CFG_BOOT_SND, &gEnableBootSND); @@ -2106,8 +2212,8 @@ void guiIntroLoop(void) { int endIntro = 0; - if (gEnableSFX && gEnableBootSND) - toggleSfx = -1; + if (gEnableSFX && gEnableBootSND) + toggleSfx = -1; while (!endIntro) { guiStartFrame(); @@ -2139,6 +2245,9 @@ void guiIntroLoop(void) void guiMainLoop(void) { + guiResetNotifications(); + guiBootNotifications(); + while (!gTerminate) { guiStartFrame(); @@ -2151,6 +2260,9 @@ void guiMainLoop(void) // Render overlaying gui thingies :) guiDrawOverlays(); + if (gEnableNotifications) + guiShowNotifications(); + // handle deferred operations guiHandleDeferredOps(); diff --git a/src/hddsupport.c b/src/hddsupport.c index 36ed712b0..41bdc33eb 100644 --- a/src/hddsupport.c +++ b/src/hddsupport.c @@ -34,15 +34,15 @@ static int hddUpdateGameListCache(hdl_games_list_t *cache, hdl_games_list_t *gam static void hddInitModules(void) { - hddLoadModules(); // update Themes char path[256]; sprintf(path, "%sTHM", hddPrefix); thmAddElements(path, "/", hddGameList.mode); + sprintf(path, "%sLNG", hddPrefix); - lngAddLanguages(path, "/"); + lngAddLanguages(path, "/", hddGameList.mode); sbCreateFolders(hddPrefix, 0); } diff --git a/src/lang.c b/src/lang.c index e988deda0..f84bd38c5 100644 --- a/src/lang.c +++ b/src/lang.c @@ -18,7 +18,7 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Network Config", "Advanced options", "", - "Settings saved...", + "Settings saved to %s", "Error writing settings!", "Exit", "Settings", @@ -275,6 +275,8 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Boot Sound Volume", "Confirm video mode change?", "Cache Game List (HDD)", + "Enable Notifications", + "%s Loaded From %s", }; static int guiLangID = 0; @@ -291,7 +293,7 @@ char *_l(unsigned int id) return lang_strs[id]; } -static void lngFreeFromFile(void) +static void lngFreeFromFile(char **lang_strs) { if (guiLangID == 0) return; @@ -331,10 +333,12 @@ static int lngLoadFromFile(char *path, char *name) file_buffer_t *fileBuffer = openFileBuffer(path, O_RDONLY, 1, 1024); if (fileBuffer) { // file exists, try to read it and load the custom lang - lang_strs = (char **)malloc(LANG_STR_COUNT * sizeof(char **)); + char **curL = lang_strs; + char **newL = (char **)malloc(LANG_STR_COUNT * sizeof(char **)); + memset(newL, 0, sizeof(char **)); int strId = 0; - while (strId < LANG_STR_COUNT && readFileBuffer(fileBuffer, &lang_strs[strId])) { + while (strId < LANG_STR_COUNT && readFileBuffer(fileBuffer, &newL[strId])) { strId++; } closeFileBuffer(fileBuffer); @@ -347,7 +351,7 @@ static int lngLoadFromFile(char *path, char *name) // if necessary complete lang with default internal while (strId < LANG_STR_COUNT) { LOG("LANG Default entry added: %s\n", internalEnglish[strId]); - lang_strs[strId] = internalEnglish[strId]; + newL[strId] = internalEnglish[strId]; strId++; } @@ -357,6 +361,9 @@ static int lngLoadFromFile(char *path, char *name) lngLoadFont(dir, name); + lang_strs = newL; + lngFreeFromFile(curL); + return 1; } return 0; @@ -418,7 +425,7 @@ static void lngRebuildLangNames(void) guiLangNames[nLanguages + 1] = NULL; } -int lngAddLanguages(char *path, const char *separator) +int lngAddLanguages(char *path, const char *separator, int mode) { int result; @@ -428,7 +435,8 @@ int lngAddLanguages(char *path, const char *separator) const char *temp; if (configGetStr(configGetByType(CONFIG_OPL), "language_text", &temp)) { - lngSetGuiValue(lngFindGuiID(temp)); + if (lngSetGuiValue(lngFindGuiID(temp))) + moduleUpdateMenu(mode, 0, 1); } return result; @@ -438,12 +446,12 @@ void lngInit(void) { fntInit(); - lngAddLanguages(gBaseMCDir, "/"); + lngAddLanguages(gBaseMCDir, "/", -1); } void lngEnd(void) { - lngFreeFromFile(); + lngFreeFromFile(lang_strs); int i = 0; for (; i < nLanguages; i++) { @@ -456,23 +464,22 @@ void lngEnd(void) fntEnd(); } -void lngSetGuiValue(int langID) +int lngSetGuiValue(int langID) { - if (guiLangID != langID) { - - lngFreeFromFile(); - - if (langID != 0) { - language_t *currLang = &languages[langID - 1]; - if (lngLoadFromFile(currLang->filePath, currLang->name)) { - guiLangID = langID; - return; + if (langID != -1) { + if (guiLangID != langID) { + if (langID != 0) { + language_t *currLang = &languages[langID - 1]; + if (lngLoadFromFile(currLang->filePath, currLang->name)) { + guiLangID = langID; + return 1; + } } + lang_strs = internalEnglish; + guiLangID = 0; } - - lang_strs = internalEnglish; - guiLangID = 0; } + return 0; } int lngGetGuiValue(void) @@ -496,3 +503,11 @@ char **lngGetGuiList(void) { return guiLangNames; } + +char *lngGetFilePath(int langID) +{ + language_t *currLang = &languages[langID - 1]; + char *path = currLang->filePath; + + return path; +} diff --git a/src/menusys.c b/src/menusys.c index 9a2a48ded..fc301e05f 100644 --- a/src/menusys.c +++ b/src/menusys.c @@ -15,10 +15,8 @@ #include "include/gui.h" #include "include/system.h" #include "include/ioman.h" -#include - #include "include/sound.h" -#include +#include enum MENU_IDs { MENU_SETTINGS = 0, @@ -689,7 +687,7 @@ void menuHandleInputMenu() // execute the item via looking at the id of it int id = mainMenuCurrent->item.id; - sfxPlay(SFX_CURSOR); + sfxPlay(SFX_CONFIRM); if (id == MENU_SETTINGS) { if (menuCheckParentalLock() == 0) diff --git a/src/opl.c b/src/opl.c index f1523cca0..75271e1a9 100644 --- a/src/opl.c +++ b/src/opl.c @@ -117,7 +117,7 @@ static char errorMessage[256]; static opl_io_module_t list_support[MODE_COUNT]; -void moduleUpdateMenu(int mode, int themeChanged) +void moduleUpdateMenu(int mode, int themeChanged, int langChanged) { if (mode == -1) return; @@ -127,6 +127,9 @@ void moduleUpdateMenu(int mode, int themeChanged) if (!mod->support) return; + if (langChanged) + guiUpdateScreenScale(); + // refresh Hints menuRemoveHints(&mod->menuItem); @@ -167,7 +170,7 @@ static void itemExecSelect(struct menu_item *curMenu) } } else { support->itemInit(); - moduleUpdateMenu(support->mode, 0); + moduleUpdateMenu(support->mode, 0, 0); // Manual refreshing can only be done if either auto refresh is disabled or auto refresh is disabled for the item. if (!gAutoRefresh || (support->updateDelay == MENU_UPD_DELAY_NOUPDATE)) ioPutRequest(IO_MENU_UPDATE_DEFFERED, &support->mode); @@ -180,7 +183,7 @@ static void itemExecCancel(struct menu_item *curMenu) { if (!curMenu->current) { return; - } + } if (!gEnableWrite) return; @@ -296,7 +299,7 @@ static void initMenuForListSupport(int mode) mod->menuItem.hints = NULL; - moduleUpdateMenu(mode, 0); + moduleUpdateMenu(mode, 0, 0); struct gui_update_t *mc = guiOpCreate(GUI_OP_ADD_MENU); mc->menu.menu = &mod->menuItem; @@ -333,7 +336,7 @@ static void initSupport(item_list_t *itemList, int startMode, int mode, int forc if (((force_reinit) && (startMode && mod->support->enabled)) || (startMode == START_MODE_AUTO && !mod->support->enabled)) { mod->support->itemInit(); - moduleUpdateMenu(mode, 0); + moduleUpdateMenu(mode, 0, 0); ioPutRequest(IO_MENU_UPDATE_DEFFERED, &mod->support->mode); // can't use mode as the variable will die at end of execution } @@ -685,8 +688,11 @@ static int tryAlternateDevice(int types) // At this point, the user has no loadable config files on any supported device, so try to find a device to save on. // We don't want to get users into alternate mode for their very first launch of OPL (i.e no config file at all, but still want to save on MC) // Check for a memory card inserted. - if (sysCheckMC() >= 0) + if (sysCheckMC() >= 0) { + configPrepareNotifications(gBaseMCDir); + showCfgPopup = 0; return 0; + } // No memory cards? Try a USB device... value = fileXioDopen("mass0:"); if (value >= 0) { @@ -702,6 +708,7 @@ static int tryAlternateDevice(int types) configInit("pfs0:"); } } + showCfgPopup = 0; return 0; } @@ -726,6 +733,7 @@ static void _loadConfig() configGetColor(configOPL, CONFIG_OPL_UI_TEXTCOLOR, gDefaultUITextColor); configGetColor(configOPL, CONFIG_OPL_SEL_TEXTCOLOR, gDefaultSelTextColor); configGetInt(configOPL, CONFIG_OPL_USE_INFOSCREEN, &gUseInfoScreen); + configGetInt(configOPL, CONFIG_OPL_ENABLE_NOTIFICATIONS, &gEnableNotifications); configGetInt(configOPL, CONFIG_OPL_ENABLE_COVERART, &gEnableArt); configGetInt(configOPL, CONFIG_OPL_WIDESCREEN, &gWideScreen); configGetInt(configOPL, CONFIG_OPL_VMODE, &gVMode); @@ -888,6 +896,7 @@ static void _saveConfig() configSetColor(configOPL, CONFIG_OPL_UI_TEXTCOLOR, gDefaultUITextColor); configSetColor(configOPL, CONFIG_OPL_SEL_TEXTCOLOR, gDefaultSelTextColor); configSetInt(configOPL, CONFIG_OPL_USE_INFOSCREEN, gUseInfoScreen); + configSetInt(configOPL, CONFIG_OPL_ENABLE_NOTIFICATIONS, gEnableNotifications); configSetInt(configOPL, CONFIG_OPL_ENABLE_COVERART, gEnableArt); configSetInt(configOPL, CONFIG_OPL_WIDESCREEN, gWideScreen); configSetInt(configOPL, CONFIG_OPL_VMODE, gVMode); @@ -968,8 +977,7 @@ void applyConfig(int themeID, int langID) // theme must be set after color, and lng after theme changed = thmSetGuiValue(themeID, changed); - if (langID != -1) - lngSetGuiValue(langID); + int langChanged = lngSetGuiValue(langID); guiUpdateScreenScale(); @@ -977,10 +985,10 @@ void applyConfig(int themeID, int langID) menuReinitMainMenu(); - moduleUpdateMenu(USB_MODE, changed); - moduleUpdateMenu(ETH_MODE, changed); - moduleUpdateMenu(HDD_MODE, changed); - moduleUpdateMenu(APP_MODE, changed); + moduleUpdateMenu(USB_MODE, changed, langChanged); + moduleUpdateMenu(ETH_MODE, changed, langChanged); + moduleUpdateMenu(HDD_MODE, changed, langChanged); + moduleUpdateMenu(APP_MODE, changed, langChanged); #ifdef __DEBUG debugApplyConfig(); @@ -999,14 +1007,22 @@ int loadConfig(int types) int saveConfig(int types, int showUI) { + char notification[32]; + char *col_pos; lscstatus = types; lscret = 0; guiHandleDeferedIO(&lscstatus, _l(_STR_SAVING_SETTINGS), IO_CUSTOM_SIMPLEACTION, &_saveConfig); if (showUI) { - if (lscret) - guiMsgBox(_l(_STR_SETTINGS_SAVED), 0, NULL); + if (lscret) { + char *path = configGetDir(); + snprintf(notification, sizeof(notification), _l(_STR_SETTINGS_SAVED), path); + if ((col_pos = strchr(notification, ':')) != NULL) + *(col_pos + 1) = '\0'; + + guiMsgBox(notification, 0, NULL); + } else guiMsgBox(_l(_STR_ERROR_SAVING_SETTINGS), 0, NULL); } @@ -1281,14 +1297,14 @@ static int loadHdldSvr(void) toggleSfx = 1; } - //deint audio lib while hdl server is running + // deint audio lib while hdl server is running audsrv_quit(); // block all io ops, wait for the ones still running to finish ioBlockOps(1); guiExecDeferredOps(); - //Deinitialize all support without shutting down the HDD unit. + // Deinitialize all support without shutting down the HDD unit. deinitAllSupport(NO_EXCEPTION, IO_MODE_SELECTED_ALL); clearErrorMessage(); /* At this point, an error might have been displayed (since background tasks were completed). Clear it, otherwise it will get displayed after the server is closed. */ @@ -1475,6 +1491,7 @@ static void setDefaults(void) gUSBPrefix[0] = '\0'; gETHPrefix[0] = '\0'; gUseInfoScreen = 0; + gEnableNotifications = 0; gEnableArt = 0; gWideScreen = 0; gEnableSFX = 0; @@ -1534,7 +1551,7 @@ static void init(void) startPads(); - //Compatibility update handler + // compatibility update handler ioRegisterHandler(IO_COMPAT_UPDATE_DEFFERED, &compatDeferredUpdate); // handler for deffered menu updates @@ -1579,7 +1596,7 @@ static void deferredAudioInit(void) else LOG("sfxInit: failed to initialize - %d.\n", ret); - //boot sound + // boot sound if (gEnableBootSND) { sfxPlay(SFX_BOOT); } diff --git a/src/sound.c b/src/sound.c index b3e03e143..29436bdad 100644 --- a/src/sound.c +++ b/src/sound.c @@ -26,8 +26,6 @@ extern unsigned int size_message_adp; extern unsigned char transition_adp[]; extern unsigned int size_transition_adp; -extern char sound_path[256]; - struct sfxEffect { const char *name; void *buffer; @@ -120,14 +118,14 @@ static int sfxLoad(struct sfxEffect *sfxData, audsrv_adpcm_t *sfx) ret = audsrv_load_adpcm(sfx, sfxData->buffer, sfxData->size); if (sfxData->builtin == 0) { - free(sfxData->buffer); - sfxData->buffer = NULL; //Mark the buffer as freed. + free(sfxData->buffer); + sfxData->buffer = NULL; //Mark the buffer as freed. } return ret; } -static int getFadeDelay(void) +static int getFadeDelay(char *sound_path) { FILE* bootSnd; char boot_path[256]; @@ -135,7 +133,7 @@ static int getFadeDelay(void) int logoFadeTime = 1400; //fade time from sound call to fade to main in milliseconds int byteRate = 176400 / 1000; //sample rate * channels * bits per sample /8 (/1000 to get in milliseconds) - sprintf(boot_path, "%s/%s", sound_path, sfx_files[SFX_BOOT].name); + snprintf(boot_path, sizeof(boot_path), "%s/%s", sound_path, sfx_files[SFX_BOOT].name); bootSnd = fopen(boot_path, "rb"); if (bootSnd == NULL) { @@ -169,31 +167,46 @@ void sfxVolume(void) //Returns number of audio files successfully loaded, < 0 if an unrecoverable error occurred. int sfxInit(int bootSnd) { + char sound_path[256]; char full_path[256]; - int ret, i, loaded; + int ret, loaded; + int thmSfxEnabled = 0; + int i = 1; audsrv_adpcm_init(); sfxInitDefaults(); sfxVolume(); + + //Check default theme is not current theme + int themeID = thmGetGuiValue(); + if (themeID != 0) { + //Get theme path for sfx + char *thmPath = thmGetFilePath(themeID); + snprintf(sound_path, sizeof(sound_path), "%ssound", thmPath); + + //Check for custom sfx folder + int fd = fileXioDopen(sound_path); + if (fd >= 0) + thmSfxEnabled = 1; + + fileXioDclose(fd); + } + //boot sound only needs to be read/loaded at init if (bootSnd) { - ret = getFadeDelay(); - if (ret != 0) { - gFadeDelay = 1200; - } i = 0; - } - else { - i = 1; + ret = getFadeDelay(sound_path); + if (ret != 0) + gFadeDelay = 1200; } loaded = 0; for (; i < SFX_COUNT; i++) { - if (thmSfxEnabled < 0) + if (thmSfxEnabled) { - sprintf(full_path, "%s/%s", sound_path, sfx_files[i].name); + snprintf(full_path, sizeof(full_path), "%s/%s", sound_path, sfx_files[i].name); ret = sfxRead(full_path, &sfx_files[i]); if (ret != 0) { @@ -221,4 +234,3 @@ void sfxPlay(int id) audsrv_ch_play_adpcm(id, &sfx[id]); } } - diff --git a/src/system.c b/src/system.c index 6fca77e9c..cdac8656a 100644 --- a/src/system.c +++ b/src/system.c @@ -21,7 +21,6 @@ #include "include/renderman.h" #include "include/extern_irx.h" #include "../ee_core/include/modules.h" -#include #include "include/pggsm.h" #include "include/cheatman.h" diff --git a/src/themes.c b/src/themes.c index a91ca1bae..55043e2c5 100644 --- a/src/themes.c +++ b/src/themes.c @@ -8,9 +8,7 @@ #include "include/fntsys.h" #include "include/lang.h" #include "include/pad.h" - #include "include/sound.h" -#include #define MENU_POS_V 50 #define HINT_HEIGHT 32 @@ -29,8 +27,6 @@ static int nThemes = 0; static theme_file_t themes[THM_MAX_FILES]; static const char **guiThemesNames = NULL; -char sound_path[256]; - enum ELEM_ATTRIBUTE_TYPE { ELEM_TYPE_ATTRIBUTE_TEXT = 0, ELEM_TYPE_STATIC_TEXT, @@ -1099,21 +1095,10 @@ static void thmLoad(const char *themePath) //No theme specified. Prepare and load the default theme. themeConfig = configAlloc(0, NULL, NULL); configReadBuffer(themeConfig, &conf_theme_OPL_cfg, size_conf_theme_OPL_cfg); - thmSfxEnabled = 0; } else { snprintf(path, sizeof(path), "%sconf_theme.cfg", themePath); themeConfig = configAlloc(0, NULL, path); configRead(themeConfig); // try to load the theme config file. If it does not exist, defaults will be used. - - //Get theme path for sfx, to use later - snprintf(sound_path, sizeof(sound_path), "%ssound", themePath); - //Check for custom sfx folder - int fd = fileXioDopen(sound_path); - if (fd < 0) - thmSfxEnabled = 0; - else - thmSfxEnabled = -1; - fileXioDclose(fd); } int intValue; @@ -1198,7 +1183,7 @@ static void thmRebuildGuiNames(void) if (guiThemesNames) free(guiThemesNames); - // build the languages name list + // build the themes name list guiThemesNames = (const char **)malloc((nThemes + 2) * sizeof(char **)); // add default internal @@ -1224,7 +1209,7 @@ int thmAddElements(char *path, const char *separator, int mode) if (configGetStr(configGetByType(CONFIG_OPL), "theme", &temp)) { LOG("THEMES Trying to set again theme: %s\n", temp); if (thmSetGuiValue(thmFindGuiID(temp), 0)) - moduleUpdateMenu(mode, 1); + moduleUpdateMenu(mode, 1, 0); } return result; @@ -1312,6 +1297,14 @@ const char **thmGetGuiList(void) return guiThemesNames; } +char *thmGetFilePath(int themeID) +{ + theme_file_t *currTheme = &themes[themeID - 1]; + char *path = currTheme->filePath; + + return path; +} + void thmEnd(void) { thmFree(gTheme); diff --git a/src/usbsupport.c b/src/usbsupport.c index 271974e00..4fa0c6445 100644 --- a/src/usbsupport.c +++ b/src/usbsupport.c @@ -156,7 +156,7 @@ static int usbNeedsUpdate(void) // update Languages if (!LanguagesLoaded) { sprintf(path, "%sLNG", usbPrefix); - if (lngAddLanguages(path, "/") > 0) + if (lngAddLanguages(path, "/", usbGameList.mode) > 0) LanguagesLoaded = 1; } diff --git a/src/util.c b/src/util.c index a2aaeb99a..116ca225d 100644 --- a/src/util.c +++ b/src/util.c @@ -24,6 +24,11 @@ static int mcID = -1; void guiWarning(const char *text, int count); +int getmcID(void) +{ + return mcID; +} + int getFileSize(int fd) { int size = fileXioLseek(fd, 0, SEEK_END);