Skip to content

Commit

Permalink
lng update (#2)
Browse files Browse the repository at this point in the history
* add support for reading language files from all devices

* lng: fix building lng list across multiple devices at the same time

* lng: load language font files from same location as currently loaded .lng file
  • Loading branch information
KrahJohlito authored and Tupakaveli committed Aug 25, 2019
1 parent 1d3c470 commit 4dbe3ec
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/lang.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,12 @@ static int lngLoadFont(const char *dir, const char *name)
{
char path[256];

snprintf(path, sizeof(path), "%s/font_%s.ttf", dir, name);
snprintf(path, sizeof(path), "%sfont_%s.ttf", dir, name);
LOG("LANG Custom TTF font path: %s\n", path);
if (fntLoadDefault(path) == 0)
return 0;

snprintf(path, sizeof(path), "%s/font_%s.otf", dir, name);
snprintf(path, sizeof(path), "%sfont_%s.otf", dir, name);
LOG("LANG Custom OTF font path: %s\n", path);
if (fntLoadDefault(path) == 0)
return 0;
Expand All @@ -326,7 +326,8 @@ static int lngLoadFont(const char *dir, const char *name)

static int lngLoadFromFile(char *path, char *name)
{
int HddStartMode;
char dir[128];

file_buffer_t *fileBuffer = openFileBuffer(path, O_RDONLY, 1, 1024);
if (fileBuffer) {
// file exists, try to read it and load the custom lang
Expand All @@ -350,14 +351,11 @@ static int lngLoadFromFile(char *path, char *name)
strId++;
}

if (lngLoadFont(gBaseMCDir, name) != 0) {
if (lngLoadFont("mass0:LNG", name) != 0) {
if (configGetInt(configGetByType(CONFIG_OPL), CONFIG_OPL_HDD_MODE, &HddStartMode) && (HddStartMode == START_MODE_AUTO)) {
hddLoadModules();
lngLoadFont("pfs0:LNG", name);
}
}
}
int len = strlen(path) - strlen(name) - 9; //-4 for extension, -5 for prefix
strncpy(dir, path, len);
dir[len] = '\0';

lngLoadFont(dir, name);

return 1;
}
Expand All @@ -374,7 +372,7 @@ static int lngReadEntry(int index, const char *path, const char *separator, cons
if (!FIO_S_ISDIR(mode)) {
if (strstr(name, ".lng") || strstr(name, ".LNG")) {

language_t *currLang = &languages[index];
language_t *currLang = &languages[nLanguages + index];

// filepath for this language file
int length = strlen(path) + 1 + strlen(name) + 1;
Expand Down

0 comments on commit 4dbe3ec

Please sign in to comment.