Skip to content

Commit

Permalink
Small code clean ups, lang fix... add notifications (optional) (#10)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
KrahJohlito authored and Tupakaveli committed Sep 21, 2019
1 parent 0de42a1 commit 94f2ed3
Show file tree
Hide file tree
Showing 22 changed files with 286 additions and 98 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
3 changes: 2 additions & 1 deletion include/dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum UI_ITEMS {
UICFG_YOFF,
UICFG_OVERSCAN,
UICFG_INFOPAGE,
UICFG_NOTIFICATIONS,

CFG_DEBUG,
CFG_PS2LOGO,
Expand All @@ -47,7 +48,7 @@ enum UI_ITEMS {
ABOUT_BUILD_DETAILS,

CFG_PARENLOCK_PASSWORD,

CFG_SFX,
CFG_BOOT_SND,
CFG_SFX_VOLUME,
Expand Down
7 changes: 5 additions & 2 deletions include/lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -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
5 changes: 4 additions & 1 deletion include/opl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand All @@ -136,6 +137,8 @@ int gBootSndVolume;
int gFadeDelay;
int toggleSfx;

int showCfgPopup;

#ifdef IGS
#define IGS_VERSION "0.1"
#endif
Expand Down
2 changes: 0 additions & 2 deletions include/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ int sfxInit(int bootSnd);
void sfxVolume(void);
void sfxPlay(int id);

int thmSfxEnabled;

#endif
1 change: 1 addition & 0 deletions include/themes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <gsToolkit.h>

int getmcID(void);
int getFileSize(int fd);
int openFile(char *path, int mode);
void *readFile(char *path, int align, int *size);
Expand Down
23 changes: 23 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/dia.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
#include "include/fntsys.h"
#include "include/themes.h"
#include "include/util.h"

#include "include/sound.h"
#include <audsrv.h>

// UI spacing of the dialogues (pixels between consecutive items)
#define UI_SPACING_H 10
Expand Down
5 changes: 5 additions & 0 deletions src/dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}}},
Expand Down
2 changes: 1 addition & 1 deletion src/ethsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Loading

0 comments on commit 94f2ed3

Please sign in to comment.