Skip to content

Commit 4dbe3ec

Browse files
KrahJohlitoTupakaveli
authored andcommitted
lng update (#2)
* 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
1 parent 1d3c470 commit 4dbe3ec

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/lang.c

+10-12
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,12 @@ static int lngLoadFont(const char *dir, const char *name)
309309
{
310310
char path[256];
311311

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

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

327327
static int lngLoadFromFile(char *path, char *name)
328328
{
329-
int HddStartMode;
329+
char dir[128];
330+
330331
file_buffer_t *fileBuffer = openFileBuffer(path, O_RDONLY, 1, 1024);
331332
if (fileBuffer) {
332333
// file exists, try to read it and load the custom lang
@@ -350,14 +351,11 @@ static int lngLoadFromFile(char *path, char *name)
350351
strId++;
351352
}
352353

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

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

377-
language_t *currLang = &languages[index];
375+
language_t *currLang = &languages[nLanguages + index];
378376

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

0 commit comments

Comments
 (0)