From cf280190a846d8804fe1cb2858386ef4abc7f4ff Mon Sep 17 00:00:00 2001 From: KrahJohlito <42090647+KrahJohlito@users.noreply.github.com> Date: Sat, 21 Sep 2019 22:39:34 +0930 Subject: [PATCH 1/5] Small code clean ups, lang fix... add notifications (optional) (#10) * sfx: code clean up * lng: fix font not being rendered if loading translations at boot from a device other than MC, and if lang is changed by manually initalising a device * gui: add notifications --- Makefile | 2 +- include/config.h | 4 ++ include/dialogs.h | 3 +- include/lang.h | 7 ++- include/opl.h | 5 +- include/sound.h | 2 - include/themes.h | 1 + include/util.h | 1 + src/config.c | 23 +++++++++ src/dia.c | 2 - src/dialogs.c | 5 ++ src/ethsupport.c | 2 +- src/gui.c | 124 +++++++++++++++++++++++++++++++++++++++++++--- src/hddsupport.c | 4 +- src/lang.c | 59 ++++++++++++++-------- src/menusys.c | 6 +-- src/opl.c | 53 +++++++++++++------- src/sound.c | 46 ++++++++++------- src/system.c | 1 - src/themes.c | 27 ++++------ src/usbsupport.c | 2 +- src/util.c | 5 ++ 22 files changed, 286 insertions(+), 98 deletions(-) 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); From b90529e490695afd25e531fdc18ad12b647eac24 Mon Sep 17 00:00:00 2001 From: Tupakaveli Date: Sat, 21 Sep 2019 23:44:34 +0930 Subject: [PATCH 2/5] Try to standardise English language strings --- src/lang.c | 198 ++++++++++++++++++++++++++--------------------------- 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/src/lang.c b/src/lang.c index f84bd38c5..32945045b 100644 --- a/src/lang.c +++ b/src/lang.c @@ -16,7 +16,7 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Save Changes", "Back", "Network Config", - "Advanced options", + "Advanced Options", "", "Settings saved to %s", "Error writing settings!", @@ -32,17 +32,17 @@ static char *internalEnglish[LANG_STR_COUNT] = { "The system will be powered off.", "Exit to Browser?", "Cancel updating?", - "%d: HardDisk Drive not detected", - "%d: HardDisk Drive not formatted", - "%d: Network startup error", - "%d: No network adaptor detected", - "%d: Cannot connect to SMB server", - "%d: Cannot log into SMB server", - "%d: Cannot open SMB share", - "%d: Cannot list SMB shares", - "%d: Cannot list games", - "%d: DHCP server unavailable", - "%d: No network connection", + "%d: HardDisk Drive not detected.", + "%d: HardDisk Drive not formatted.", + "%d: Network startup error.", + "%d: No network adaptor detected.", + "%d: Cannot connect to SMB server.", + "%d: Cannot log into SMB server.", + "%d: Cannot open SMB share.", + "%d: Cannot list SMB shares.", + "%d: Cannot list games.", + "%d: DHCP server unavailable.", + "%d: No network connection.", "On", "Off", "OK", @@ -52,47 +52,47 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Cross", "Games List", "Game Settings", - "Remove all settings", - "Removed all keys for the game", + "Remove All Settings", + "Removed all keys for the game.", "Scrolling", "Slow", "Medium", "Fast", - "Default menu", - "Load from disc", - "Please wait", - "Error while loading the Game ID", - "Automatic sorting", - "Error loading the language file", + "Default Menu", + "Load From Disc", + "Please wait.", + "Error while loading the Game ID.", + "Automatic Sorting", + "Error loading the language file.", "Disable Debug Colors", "No controller detected, waiting...", "Enable Cover Art", - "Wide screen", + "Widescreen", "Power Off", - "Loading config", - "Saving config", - "Start device", + "Loading config...", + "Saving config...", + "Start Device", "Refresh", - "USB device start mode", - "HDD device start mode", - "ETH device start mode", - "Applications start mode", + "USB Device Start Mode", + "HDD Device Start Mode", + "ETH Device Start Mode", + "Applications Start Mode", "Auto", "Manual", "Start HDL Server", - "HDL Server Starting...", - "HDL Server Running...", + "HDL Server starting...", + "HDL Server running...", "Failed to start HDL Server.", - "HDL Server Unloading...", - "IGR path", - "Background color", - "Text color", + "HDL Server unloading...", + "IGR Path", + "Background Color", + "Text Color", "- PS2 -", "- SMB Server -", - "IP address type", + "IP Address Type", "Static", "DHCP", - "IP address", + "IP Address", "Address", "Mask", "Gateway", @@ -102,7 +102,7 @@ static char *internalEnglish[LANG_STR_COUNT] = { "User", "Password", "", - "Address type", + "Address Type", "IP", "NetBIOS", "Accept", @@ -111,12 +111,12 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Delete", "Run", "Display Settings", - "Enable write operations", - "Check USB game fragmentation", - "Remember last played game", - "Select button", - "Error, the game is fragmented", - "Error, could not run the item", + "Enable Write Operations", + "Check USB Game Fragmentation", + "Remember Last Played Game", + "Select Button", + "Error, the game is fragmented.", + "Error, could not run the item.", "Test", "Leave empty for GUEST auth.", "Accurate Reads", @@ -127,40 +127,40 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Disable IGR", "Unused", "Unused", - "Changing the size will reformat the VMC", + "Changing the size will reformat the VMC.", "Create", "Start", "Modify", "Abort", "Reset", - "Use generic", + "Use Generic", "Configure VMC", "Name", "Size", "Status", "Progress", - "VMC file exist", - "Invalid VMC file, size is incorrect", - "VMC file need to be created", + "VMC file exists.", + "Invalid VMC file, size is incorrect.", + "VMC file needs to be created.", "Error accessing VMC %s. Continue with the Memory Card in slot %d?", - "Automatic refresh", + "Automatic Refresh", "About", "Coders", "Quality Assurance", - "USB prefix path", - "Boots custom ELF after an IGR", - "Value in minute(s), 0 to disable spin down", - "Automatic HDD spin down", - "Video mode", - "Dialog color", - "Selected color", - "Display info page", + "USB Prefix Path", + "Boots custom ELF after an IGR.", + "Value in minute(s), 0 to disable spin down.", + "Automatic HDD Spin Down", + "Video Mode", + "Dialog Color", + "Selected Color", + "Display Info Page", "Info", "Custom ELF", - "Color selection", + "Color Selection", "Reconnect", - "Leave empty to list shares", - "ETH prefix path", + "Leave empty to list shares.", + "ETH Prefix Path", "Backspace", "Space", "Enter", @@ -179,36 +179,36 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Mode 7", "Mode 8", "Configure GSM", - "Ethernet link mode", - "100Mbit full-duplex", - "100Mbit half-duplex", - "10Mbit full-duplex", - "10Mbit half-duplex", + "Ethernet Link Mode", + "100Mbit Full-duplex", + "100Mbit Half-duplex", + "10Mbit Full-duplex", + "10Mbit Half-duplex", "GSM Settings", "Enable GSM", - "Toggles GSM ON or OFF", + "Toggles GSM on/off.", "VMODE", - "Forced Custom Display Mode", + "Forced custom display mode.", "H-POS", - "Horizontal Adjustment", + "Horizontal adjustment.", "V-POS", - "Vertical Adjustment", + "Vertical adjustment.", "Overscan", - "Overscan Adjustment", + "Overscan adjustment.", "FMV Skip", "Skips Full Motion Videos", "Cheat Settings", "Enable PS2RD Cheat Engine", - "Lets PS2RD Cheat Engine patch your game", + "Lets PS2RD Cheat Engine patch your game.", "PS2RD Cheat Engine Mode", - "Auto-select or Select game cheats", - "Auto-select cheats", - "Select game cheats", - "Error: failed to load Cheat File", - "No cheats found", - "Download defaults", + "Auto select or select game cheats.", + "Auto Select Cheats", + "Select Game Cheats", + "Error: failed to load cheat file.", + "No cheats found.", + "Download Defaults", "Network Update", - "Re-download existing records?", + "Redownload existing records?", "Update failed.", "Failed to connect to update server.", "Update completed.", @@ -217,47 +217,47 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Customized Settings", "Downloaded Defaults", "Auto start in %i s...", - "Auto start", - "Value in second(s), 0 to disable auto start", + "Auto Start", + "Value in second(s), 0 to disable auto start.", "PS2 Logo", - "(Only displayed for a valid disc logo which matches the console's region)", + "Only displayed for a valid disc logo which matches the console's region.", "Configure PADEMU", "Pad Emulator Settings", - "Enable PadEmulator", - "Turns on/off PadEmulator for selected game.", - "Pad Emulator mode", + "Enable Pad Emulator", + "Turns on/off Pad Emulator for selected game.", + "Pad Emulator Mode", "Select Pad Emulator mode.", "DualShock3/4 USB", "DualShock3/4 BT", - "Settings for port:", + "Settings For Port:", "Select Pad Emulator port for settings.", - "Enable emulation", + "Enable Emulation", "Turns on/off Pad Emulator for selected port.", - "Enable vibration", + "Enable Vibration", "Turns on/off vibration for Pad Emulator selected port.", - "Usb bluetooth adapter mac address:", - "DS Controller paired to mac address:", + "USB Bluetooth Adapter MAC Address:", + "DS Controller Paired To MAC Address:", "Pair", "Pair DS Controller", - "Pair DS Controller with bluetooth adapter mac address.", - "Not connected", - "Bluetooth adapter information", - "Shows more information and supported features", + "Pair DS controller with Bluetooth adapter MAC address.", + "Not Connected", + "Bluetooth Adapter Information", + "Shows more information and supported features.", "HCI Version:", "LMP Version:", "Manufacturer ID:", - "Support features:", + "Supported Features:", "Yes", "No", "Bluetooth adapter should be fully compatible with DS3/DS4 controllers.", "Bluetooth adapter may not work correctly with DS3/DS4 controllers.", - "Enable Multitap emulation", + "Enable Multitap Emulation", "Turns on/off Multitap emulation for selected game.", - "Multitap emulator on port", + "Multitap Emulator On Port:", "Select port for Multitap emulation.", - "Disable workaround for fake ds3", - "Some fake ds3s need workaround, this option will disable it.", - "Emulate FIELD flipping", + "Disable Fake DS3 Workaround", + "Some fake DS3s need workaround, this option will disable it.", + "Emulate FIELD Flipping", "Fix for games that glitch under progressive video modes.", "Parental Lock Settings", "Parental Lock Password", From 4a94b75eed7518d819564cc6722254245ebf1f6c Mon Sep 17 00:00:00 2001 From: KrahJohlito <42090647+KrahJohlito@users.noreply.github.com> Date: Sun, 22 Sep 2019 13:36:14 +0930 Subject: [PATCH 3/5] Reduce notifications code (#12) * sfx: code clean up * lng: fix font not being rendered if loading translations at boot from a device other than MC, and if lang is changed by manually initalising a device * gui: add notifications * gui: reduce notifications code --- src/gui.c | 56 ++++++++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/src/gui.c b/src/gui.c index 317e74536..9fb1c4ff4 100644 --- a/src/gui.c +++ b/src/gui.c @@ -264,13 +264,26 @@ static void guiResetNotifications(void) showLngPopup = 0; } -static void guiShowNotifications(void) +static void guiRenderNotifications(char *type, char *path, int y) { + char notification[32]; + char *col_pos; int x; + + snprintf(notification, sizeof(notification), _l(_STR_NOTIFICATIONS), type, 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); +} + +static void guiShowNotifications(void) +{ int y = 10; int yadd = 35; - char notification[32]; - char *col_pos; if (showThmPopup || showLngPopup || showCfgPopup) popupTimer++; @@ -280,43 +293,18 @@ static void guiShowNotifications(void) 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; + if (showCfgPopup && popupTimer >= 20) + guiRenderNotifications("CFG", configGetDir(), y); - 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; + if (showThmPopup && popupTimer >= 20) + guiRenderNotifications("THM", thmGetFilePath(thmGetGuiValue()), y); - 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 (showLngPopup && popupTimer >= 20) + guiRenderNotifications("LNG", lngGetFilePath(lngGetGuiValue()), y); if (popupTimer >= CLOCKS_PER_SEC / 2000) { guiResetNotifications(); From 2e8e860b131b19c97f8a656f0866f50df8e3c328 Mon Sep 17 00:00:00 2001 From: Tupakaveli Date: Sun, 22 Sep 2019 15:59:10 +0930 Subject: [PATCH 4/5] Update English language template --- lng/lang_English.lng | 210 ++++++++++++++++++++++--------------------- src/lang.c | 6 +- 2 files changed, 109 insertions(+), 107 deletions(-) diff --git a/lng/lang_English.lng b/lng/lang_English.lng index cd8778e73..507cbebdc 100644 --- a/lng/lang_English.lng +++ b/lng/lang_English.lng @@ -9,7 +9,7 @@ # # # Once the translation is complete, you can submit it to the development team. # # # -# To use your custom language with OPL, simply copy your file into your mc?:/OPL folder. # +# To use your custom language with OPL, simply copy your file into your mc?:/OPL or LNG folder. # # (File must start with the "lang_" prefix and have the ".lng" extension) # # # # Finally, don't put too many comments in your file, it will waste space and increases loading # @@ -25,9 +25,9 @@ Open PS2 Loader %s Save Changes Back Network Config -Advanced options +Advanced Options -Settings saved... +Settings saved to %s Error writing settings! Exit Settings @@ -41,17 +41,17 @@ Language The system will be powered off. Exit to Browser? Cancel updating? -%d: HardDisk Drive not detected -%d: HardDisk Drive not formatted -%d: Network startup error -%d: No network adaptor detected -%d: Cannot connect to SMB server -%d: Cannot log into SMB server -%d: Cannot open SMB share -%d: Cannot list SMB shares -%d: Cannot list games -%d: DHCP server unavailable -%d: No network connection +%d: HardDisk Drive not detected. +%d: HardDisk Drive not formatted. +%d: Network startup error. +%d: No network adaptor detected. +%d: Cannot connect to SMB server. +%d: Cannot log into SMB server. +%d: Cannot open SMB share. +%d: Cannot list SMB shares. +%d: Cannot list games. +%d: DHCP server unavailable. +%d: No network connection. On Off OK @@ -61,47 +61,47 @@ Circle Cross Games List Game Settings -Remove all settings -Removed all keys for the game +Remove All Settings +Removed all keys for the game. Scrolling Slow Medium Fast -Default menu -Load from disc -Please wait -Error while loading the Game ID -Automatic sorting -Error loading the language file +Default Menu +Load From Disc +Please wait. +Error while loading the Game ID. +Automatic Sorting +Error loading the language file. Disable Debug Colors No controller detected, waiting... Enable Cover Art -Wide screen +Widescreen Power Off -Loading config -Saving config -Start device +Loading config... +Saving config... +Start Device Refresh -USB device start mode -HDD device start mode -ETH device start mode -Applications start mode +USB Device Start Mode +HDD Device Start Mode +ETH Device Start Mode +Applications Start Mode Auto Manual Start HDL Server -HDL Server Starting... -HDL Server Running... +HDL Server starting... +HDL Server running... Failed to start HDL Server. -HDL Server Unloading... -IGR path -Background color -Text color +HDL Server unloading... +IGR Path +Background Color +Text Color - PS2 - - SMB Server - -IP address type +IP Address Type Static DHCP -IP address +IP Address Address Mask Gateway @@ -111,7 +111,7 @@ Share User Password -Address type +Address Type IP NetBIOS Accept @@ -120,12 +120,12 @@ Rename Delete Run Display Settings -Enable write operations -Check USB game fragmentation -Remember last played game -Select button -Error, the game is fragmented -Error, could not run the item +Enable Write Operations +Check USB Game Fragmentation +Remember Last Played Game +Select Button +Error, the game is fragmented. +Error, could not run the item. Test Leave empty for GUEST auth. Accurate Reads @@ -136,40 +136,40 @@ Emulate DVD-DL Disable IGR Unused Unused -Changing the size will reformat the VMC +Changing the size will reformat the VMC. Create Start Modify Abort Reset -Use generic +Use Generic Configure VMC Name Size Status Progress -VMC file exist -Invalid VMC file, size is incorrect -VMC file need to be created +VMC file exists. +Invalid VMC file, size is incorrect. +VMC file needs to be created. Error accessing VMC %s. Continue with the Memory Card in slot %d? -Automatic refresh +Automatic Refresh About Coders Quality Assurance -USB prefix path -Boots custom ELF after an IGR -Value in minute(s), 0 to disable spin down -Automatic HDD spin down -Video mode -Dialog color -Selected color -Display info page +USB Prefix Path +Boots custom ELF after an IGR. +Value in minute(s), 0 to disable spin down. +Automatic HDD Spin Down +Video Mode +Dialog Color +Selected Color +Display Info Page Info Custom ELF -Color selection +Color Selection Reconnect -Leave empty to list shares -ETH prefix path +Leave empty to list shares. +ETH Prefix Path Backspace Space Enter @@ -188,85 +188,85 @@ Mode 6 Mode 7 Mode 8 Configure GSM -Ethernet link mode -100Mbit full-duplex -100Mbit half-duplex -10Mbit full-duplex -10Mbit half-duplex +Ethernet Link Mode +100Mbit Full-duplex +100Mbit Half-duplex +10Mbit Full-duplex +10Mbit Half-duplex GSM Settings Enable GSM -Toggles GSM ON or OFF +Toggles GSM on/off. VMODE -Forced Custom Display Mode +Forced custom display mode. H-POS -Horizontal Adjustment +Horizontal adjustment. V-POS -Vertical Adjustment +Vertical adjustment. Overscan -Overscan Adjustment +Overscan adjustment. FMV Skip -Skips Full Motion Videos +Skips full motion videos. Cheat Settings Enable PS2RD Cheat Engine -Lets PS2RD Cheat Engine patch your game +Lets PS2RD Cheat Engine patch your game. PS2RD Cheat Engine Mode -Auto-select or Select game cheats -Auto-select cheats -Select game cheats -Error: failed to load Cheat File -No cheats found -Download defaults +Auto select or select game cheats. +Auto Select Cheats +Select Game Cheats +Error: failed to load cheat file. +No cheats found. +Download Defaults Network Update -Re-download existing records? +Redownload existing records? Update failed. Failed to connect to update server. Update completed. Update cancelled. Download settings from the network? Customized Settings -Downloaded Defaults +Downloaded defaults. Auto start in %i s... -Auto start -Value in second(s), 0 to disable auto start +Auto Start +Value in second(s), 0 to disable auto start. PS2 Logo -(Only displayed for a valid disc logo which matches the console's region) +Only displayed for a valid disc logo which matches the console's region. Configure PADEMU Pad Emulator Settings -Enable PadEmulator -Turns on/off PadEmulator for selected game. -Pad Emulator mode +Enable Pad Emulator +Turns on/off Pad Emulator for selected game. +Pad Emulator Mode Select Pad Emulator mode. DualShock3/4 USB DualShock3/4 BT -Settings for port: +Settings For Port: Select Pad Emulator port for settings. -Enable emulation +Enable Emulation Turns on/off Pad Emulator for selected port. -Enable vibration +Enable Vibration Turns on/off vibration for Pad Emulator selected port. -Usb bluetooth adapter mac address: -DS Controller paired to mac address: +USB Bluetooth Adapter MAC Address: +DS Controller Paired To MAC Address: Pair Pair DS Controller -Pair DS Controller with bluetooth adapter mac address. -Not connected -Bluetooth adapter information -Shows more information and supported features +Pair DS controller with Bluetooth adapter MAC address. +Not Connected +Bluetooth Adapter Information +Shows more information and supported features. HCI Version: LMP Version: Manufacturer ID: -Support features: +Supported Features: Yes No Bluetooth adapter should be fully compatible with DS3/DS4 controllers. Bluetooth adapter may not work correctly with DS3/DS4 controllers. -Enable Multitap emulation +Enable Multitap Emulation Turns on/off Multitap emulation for selected game. -Multitap emulator on port +Multitap Emulator On Port: Select port for Multitap emulation. -Disable workaround for fake ds3 -Some fake ds3s need workaround, this option will disable it. -Emulate FIELD flipping +Disable Fake DS3 Workaround +Some fake DS3s need workaround, this option will disable it. +Emulate FIELD Flipping Fix for games that glitch under progressive video modes. Parental Lock Settings Parental Lock Password @@ -283,4 +283,6 @@ Enable Boot Sound Sound Effects Volume Boot Sound Volume Confirm video mode change? -Cache Game List (HDD) \ No newline at end of file +Cache Game List (HDD) +Enable Notifications +%s loaded from %s \ No newline at end of file diff --git a/src/lang.c b/src/lang.c index 32945045b..388c9d073 100644 --- a/src/lang.c +++ b/src/lang.c @@ -196,7 +196,7 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Overscan", "Overscan adjustment.", "FMV Skip", - "Skips Full Motion Videos", + "Skips full motion videos.", "Cheat Settings", "Enable PS2RD Cheat Engine", "Lets PS2RD Cheat Engine patch your game.", @@ -215,7 +215,7 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Update cancelled.", "Download settings from the network?", "Customized Settings", - "Downloaded Defaults", + "Downloaded defaults.", "Auto start in %i s...", "Auto Start", "Value in second(s), 0 to disable auto start.", @@ -276,7 +276,7 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Confirm video mode change?", "Cache Game List (HDD)", "Enable Notifications", - "%s Loaded From %s", + "%s loaded from %s", }; static int guiLangID = 0; From a67b8ecbf513cee55e88a1bfdad24dbc699d47ef Mon Sep 17 00:00:00 2001 From: KrahJohlito <42090647+KrahJohlito@users.noreply.github.com> Date: Sun, 22 Sep 2019 21:58:24 +0930 Subject: [PATCH 5/5] notifications: show upon manual device init, if thm or lang changed (#13) * sfx: code clean up * lng: fix font not being rendered if loading translations at boot from a device other than MC, and if lang is changed by manually initalising a device * gui: add notifications * gui: reduce notifications code * notifications: show upon manual device init, if thm or lang changed --- include/opl.h | 3 +++ src/gui.c | 22 ++-------------------- src/opl.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/include/opl.h b/include/opl.h index c31752ad4..6c31b0376 100644 --- a/include/opl.h +++ b/include/opl.h @@ -138,6 +138,9 @@ int gFadeDelay; int toggleSfx; int showCfgPopup; +int showThmPopup; +int showLngPopup; +int popupSfxPlayed; #ifdef IGS #define IGS_VERSION "0.1" diff --git a/src/gui.c b/src/gui.c index 9fb1c4ff4..a57739979 100644 --- a/src/gui.c +++ b/src/gui.c @@ -48,12 +48,8 @@ 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(); @@ -241,12 +237,10 @@ void guiShowAbout() static void guiBootNotifications(void) { if (gEnableNotifications) { - int themeID = thmGetGuiValue(); - if (themeID != 0) + if (thmGetGuiValue() != 0) showThmPopup = 1; - int langID = lngGetGuiValue(); - if (langID != 0) + if (lngGetGuiValue() != 0) showLngPopup = 1; if (showThmPopup || showLngPopup || showCfgPopup) { @@ -599,8 +593,6 @@ void guiShowUIConfig(void) , "HDTV 1920x1080i @60Hz 16bit (HIRES)" , NULL}; int previousVMode; - int previousTheme = thmGetGuiValue(); - int previousLang = lngGetGuiValue(); reselect_video_mode: previousVMode = gVMode; @@ -650,16 +642,6 @@ 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) { diff --git a/src/opl.c b/src/opl.c index 75271e1a9..a438bbff4 100644 --- a/src/opl.c +++ b/src/opl.c @@ -127,8 +127,13 @@ void moduleUpdateMenu(int mode, int themeChanged, int langChanged) if (!mod->support) return; - if (langChanged) + if (langChanged) { guiUpdateScreenScale(); + if (lngGetGuiValue() != 0) { + showLngPopup = 1; + popupSfxPlayed = 0; + } + } // refresh Hints menuRemoveHints(&mod->menuItem); @@ -153,8 +158,13 @@ void moduleUpdateMenu(int mode, int themeChanged, int langChanged) } // refresh Cache - if (themeChanged) + if (themeChanged) { submenuRebuildCache(mod->subMenu); + if (thmGetGuiValue() != 0) { + showThmPopup = 1; + popupSfxPlayed = 0; + } + } } static void itemExecSelect(struct menu_item *curMenu)