Skip to content

Commit

Permalink
Seperate entry notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
KrahJohlito committed Aug 17, 2021
1 parent f624611 commit d6818cb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 19 deletions.
4 changes: 3 additions & 1 deletion include/lang.h
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion lng/lang_English.lng
Expand Up @@ -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.
Expand Down
39 changes: 23 additions & 16 deletions src/gui.c
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/lang.c
Expand Up @@ -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.",
Expand Down

0 comments on commit d6818cb

Please sign in to comment.