Get translation loading mostly working
This commit is contained in:
parent
93d99d6cb5
commit
e9a72bc967
2
Makefile
2
Makefile
|
@ -519,7 +519,7 @@ SUBTITLE_LANGUAGES = english \
|
|||
SUBTITLE_SOURCES = $(SUBTITLE_LANGUAGES:%=build/src/audio/subtitles_%.c)
|
||||
SUBTITLE_OBJECTS = $(SUBTITLE_LANGUAGES:%=build/src/audio/subtitles_%.o)
|
||||
|
||||
build/src/audio/subtitles.h build/src/audio/subtitles.c build/subtitles.ld: tools/level_scripts/subtitle_generate.py
|
||||
build/src/audio/subtitles.h build/src/audio/subtitles.c build/subtitles.ld $(SUBTITLE_SOURCES): tools/level_scripts/subtitle_generate.py
|
||||
python3 tools/level_scripts/subtitle_generate.py $(SUBTITLE_LANGUAGES)
|
||||
|
||||
####################
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
|
||||
#include "../build/src/audio/subtitles.h"
|
||||
|
||||
char* gLoadedLanugageBlock = NULL;
|
||||
char** gCurrentTranslations = NULL;
|
||||
int gCurrentLoadedLanguage = 0;
|
||||
|
||||
void translationsLoad(int language) {
|
||||
if (NUM_SUBTITLE_LANGUAGES == 0) {
|
||||
|
@ -24,18 +26,23 @@ void translationsLoad(int language) {
|
|||
struct SubtitleBlock* block = &SubtitleLanguageBlocks[language];
|
||||
|
||||
int blockSize = (int)block->romEnd - (int)block->romStart;
|
||||
char* blockStart = malloc(blockSize);
|
||||
romCopy(block->romStart, blockStart, blockSize);
|
||||
gLoadedLanugageBlock = malloc(blockSize);
|
||||
romCopy(block->romStart, gLoadedLanugageBlock, blockSize);
|
||||
|
||||
gCurrentTranslations = CALC_RAM_POINTER(block->values, blockStart);
|
||||
gCurrentTranslations = CALC_RAM_POINTER(block->values, gLoadedLanugageBlock);
|
||||
gCurrentLoadedLanguage = language;
|
||||
|
||||
for (int i = 0; i < NUM_SUBTITLE_MESSAGES; ++i) {
|
||||
gCurrentTranslations[i] = CALC_RAM_POINTER(gCurrentTranslations[i], blockStart);
|
||||
gCurrentTranslations[i] = CALC_RAM_POINTER(gCurrentTranslations[i], gLoadedLanugageBlock);
|
||||
}
|
||||
}
|
||||
|
||||
void translationsReload(int language) {
|
||||
free(gCurrentTranslations);
|
||||
if (language == gCurrentLoadedLanguage) {
|
||||
return;
|
||||
}
|
||||
|
||||
free(gLoadedLanugageBlock);
|
||||
translationsLoad(language);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,11 +109,25 @@ def make_SubtitleKey_headerlines(keys):
|
|||
def make_subtitle_for_language(lang_lines, lang_name):
|
||||
lines = []
|
||||
|
||||
idx = 1
|
||||
|
||||
lines.append("\n")
|
||||
|
||||
for value in lang_lines:
|
||||
lines.append(f'char __translation_{lang_name}_{idx}[] = "{value}";\n')
|
||||
idx = idx + 1
|
||||
|
||||
lines.append("\n")
|
||||
lines.append(f"char* gSubtitle{lang_name}[508] = {'{'}\n")
|
||||
|
||||
# SubtitleKeyNone
|
||||
lines.append(' "",\n')
|
||||
|
||||
idx = 1
|
||||
|
||||
for value in lang_lines:
|
||||
lines.append(f' "{value}",\n')
|
||||
lines.append(f' __translation_{lang_name}_{idx},\n')
|
||||
idx = idx + 1
|
||||
|
||||
lines.append("};\n")
|
||||
|
||||
|
@ -178,6 +192,7 @@ def process_all_closecaption_files(dir, language_names):
|
|||
language_list = []
|
||||
language_with_values_list = []
|
||||
SubtitleKey_generated = False
|
||||
key_order = {}
|
||||
|
||||
for langauge_name in language_names:
|
||||
filename = f"closecaption_{langauge_name}.txt"
|
||||
|
|
Loading…
Reference in a new issue