Skip to content
Permalink
Browse files
Seperate entry notifications
  • Loading branch information
KrahJohlito committed Aug 17, 2021
1 parent f624611 commit d6818cbb48009a7b66a7a2f3963c3b97bb4eb890
Showing with 32 additions and 19 deletions.
  1. +3 −1 include/lang.h
  2. +3 −1 lng/lang_English.lng
  3. +23 −16 src/gui.c
  4. +3 −1 src/lang.c
@@ -259,7 +259,9 @@ enum _STR_IDS {
_STR_CFM_VMODE_CHG,
_STR_CACHE_HDD_GAME_LIST,
_STR_ENABLE_NOTIFICATIONS,
_STR_NOTIFICATIONS,
_STR_CFG_NOTIFICATION,
_STR_THM_NOTIFICATION,
_STR_LNG_NOTIFICATION,
_STR_OPTIONS,
_STR_GAME_SETTINGS_SAVED,
_STR_GAME_SETTINGS_REMOVED,
@@ -276,7 +276,9 @@ Boot Sound Volume
Confirm video mode change?
Cache Game List (HDD)
Notifications
%s loaded from %s
Config loaded from %s
Theme loaded from %s
Language loaded from %s
Options
Game settings saved.
%s settings removed.
@@ -249,49 +249,56 @@ static void guiResetNotifications(void)
popupTimer = 0;
}

static void guiRenderNotifications(char *type, char *path, int y)
static void guiRenderNotifications(char *string, int y)
{
char notification[128];
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;
x = screenWidth - rmUnScaleX(fntCalcDimensions(gTheme->fonts[0], string)) - 10;

rmDrawRect(x - 10, y, screenWidth - x, MENU_ITEM_HEIGHT + 10, gColDarker);
fntRenderString(gTheme->fonts[0], x - 5, y + 5, ALIGN_NONE, 0, 0, notification, gTheme->textColor);
fntRenderString(gTheme->fonts[0], x - 5, y + 5, ALIGN_NONE, 0, 0, string, gTheme->textColor);
}

static void guiShowNotifications(void)
{
char notification[128];
char *col_pos;
int y = 10;
int yadd = 35;
clock_t currentTime;

currentTime = clock();
if (showThmPopup || showLngPopup || showCfgPopup) {
if (!popupTimer) {
popupTimer = clock() + 5000 * (CLOCKS_PER_SEC / 1000);
sfxPlay(SFX_MESSAGE);
}

if (showCfgPopup) {
guiRenderNotifications("CFG", configGetDir(), y);
snprintf(notification, sizeof(notification), _l(_STR_CFG_NOTIFICATION), configGetDir());
if ((col_pos = strchr(notification, ':')) != NULL)
*(col_pos + 1) = '\0';

guiRenderNotifications(notification, y);
y += yadd;
}

if (showThmPopup) {
guiRenderNotifications("THM", thmGetFilePath(thmGetGuiValue()), y);
snprintf(notification, sizeof(notification), _l(_STR_THM_NOTIFICATION), thmGetFilePath(thmGetGuiValue()));
if ((col_pos = strchr(notification, ':')) != NULL)
*(col_pos + 1) = '\0';

guiRenderNotifications(notification, y);
y += yadd;
}

if (showLngPopup)
guiRenderNotifications("LNG", lngGetFilePath(lngGetGuiValue()), y);
if (showLngPopup) {
snprintf(notification, sizeof(notification), _l(_STR_LNG_NOTIFICATION), lngGetFilePath(lngGetGuiValue()));
if ((col_pos = strchr(notification, ':')) != NULL)
*(col_pos + 1) = '\0';

guiRenderNotifications(notification, y);
}

if (currentTime >= popupTimer) {
if (clock() >= popupTimer) {
guiResetNotifications();
showCfgPopup = 0;
}
@@ -263,7 +263,9 @@ static char *internalEnglish[LANG_STR_COUNT] = {
"Confirm video mode change?",
"Cache Game List (HDD)",
"Notifications",
"%s loaded from %s",
"Config loaded from %s",
"Theme loaded from %s",
"Language loaded from %s",
"Options",
"Game settings saved.",
"%s settings removed.",

0 comments on commit d6818cb

Please sign in to comment.