diff --git a/.gitignore b/.gitignore index 0caa3e08..15fbcb57 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,7 @@ sm64config.txt /assets/**/*.bin /sound/**/*.m64 /sound/**/*.aiff +!/textures/special/*.png !/levels/**/*custom*.png !/levels/**/*custom*/**/*.png !/actors/**/*custom*.png diff --git a/bin/segment2.c b/bin/segment2.c index 40b6abbc..a8034c61 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -982,10 +982,11 @@ const u8 *const main_font_lut[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, texture_font_char_us_comma, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, + // SPECIAL CHARS: Start ID - 112:0x70 + texture_font_char_accent_a, texture_font_char_accent_e, texture_font_char_accent_i, texture_font_char_accent_o, + texture_font_char_accent_u, texture_font_char_mayus_accent_a, texture_font_char_mayus_accent_e, texture_font_char_mayus_accent_i, + texture_font_char_mayus_accent_o, texture_font_char_mayus_accent_u, texture_font_char_enye, texture_font_char_mayus_enye, + texture_font_char_umlaut, texture_font_char_mayus_umlaut, texture_font_char_question, texture_font_char_exclamation, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @@ -1018,11 +1019,6 @@ const u8 *const main_font_lut[] = { texture_font_char_us_question, texture_font_char_us_double_quote_open, texture_font_char_us_double_quote_close, texture_font_char_us_tilde, 0x0, texture_font_char_us_coin, texture_font_char_us_star_filled, texture_font_char_us_multiply, texture_font_char_us_interpunct, texture_font_char_us_star_hollow, 0x0, 0x0, - - texture_font_char_mayus_accent_a, texture_font_char_mayus_accent_e, texture_font_char_mayus_accent_i, texture_font_char_mayus_accent_o, - texture_font_char_mayus_accent_u, texture_font_char_mayus_umlaut, texture_font_char_exclamation, texture_font_char_mayus_enye, - texture_font_char_accent_a, texture_font_char_accent_e, texture_font_char_accent_i, texture_font_char_accent_o, texture_font_char_accent_u, - texture_font_char_question, texture_font_char_umlaut, texture_font_char_enye, }; // credits font LUT 0x02008738-0x020087CB diff --git a/src/game/options_menu.c b/src/game/options_menu.c index de192faa..409c37df 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -429,7 +429,6 @@ static void optmenu_opt_change(struct Option *opt, s32 val) { "Spanish", "English" }; - printf("SWITCH LANGUAGE: %s\n", languages[configLanguage]); set_language(get_language_by_name(languages[configLanguage])); break; diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 5ecd728f..3a725c03 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -174,17 +174,18 @@ static void on_anim_frame(double time) { } #endif -void main_func(void) { +void main_func(char *argv[]) { static u64 pool[0x165000/8 / 4 * sizeof(void *)]; main_pool_init(pool, pool + sizeof(pool) / sizeof(pool[0])); gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT); const char *gamedir = gCLIOpts.GameDir[0] ? gCLIOpts.GameDir : FS_BASEDIR; - const char *userpath = gCLIOpts.SavePath[0] ? gCLIOpts.SavePath : sys_user_path(); + const char *userpath = gCLIOpts.SavePath[0] ? gCLIOpts.SavePath : sys_user_path(); fs_init(sys_ropaths, gamedir, userpath); - alloc_dialog_pool(); configfile_load(configfile_name()); + alloc_dialog_pool(argv[0], gamedir); + if (gCLIOpts.FullScreen == 1) configWindow.fullscreen = true; else if (gCLIOpts.FullScreen == 2) @@ -237,8 +238,7 @@ void main_func(void) { audio_init(); sound_init(); - thread5_game_loop(NULL); - + thread5_game_loop(NULL); inited = true; // precache data if needed @@ -267,6 +267,6 @@ void main_func(void) { int main(int argc, char *argv[]) { parse_cli_opts(argc, argv); - main_func(); + main_func(argv); return 0; } diff --git a/src/text/text-loader.c b/src/text/text-loader.c index cb3e453c..8ded53fe 100644 --- a/src/text/text-loader.c +++ b/src/text/text-loader.c @@ -8,6 +8,7 @@ #include #include #include "libs/cJSON.h" +#include "pc/configfile.h" #define PLACEHOLDER "You are not supposed\nto be here.\n\nKeep this as a secret\n\n- Render96 Team" @@ -163,31 +164,37 @@ void load_language(char* jsonTxt, s8 language){ cJSON_free(json); } -void alloc_languages(void){ +void alloc_languages(char* exePath, char* gamedir){ languages = realloc(languages, sizeof(struct LanguageEntry*) * 30); - char * languagesDir = "./res/texts/"; + char *lastSlash = NULL; + char *parent = NULL; + #ifndef WIN32 + lastSlash = strrchr(exePath, '/'); + #else + lastSlash = strrchr(exePath, '\\'); + #endif + parent = strndup(exePath, strlen(exePath) - strlen(lastSlash)); + + char * languagesDir = malloc(FILENAME_MAX * sizeof(char*)); + strcpy(languagesDir, parent); + strcat(languagesDir, "/"); + strcat(languagesDir, gamedir); + strcat(languagesDir, "/texts/"); + DIR *lf = opendir(languagesDir); struct dirent *de; while ((de = readdir(lf)) != NULL){ const char* extension = get_filename_ext(de->d_name); - char * file = malloc(99 * sizeof(char*)); - if(strcmp(extension, "json") == 0){ - strcpy(file, ""); - strcat(file, "./res/texts/"); + char * file = malloc(FILENAME_MAX * sizeof(char*)); + if(strcmp(extension, "json") == 0){ + + strcpy(file, languagesDir); strcat(file, de->d_name); - - #ifndef WIN32 - char * language_file = realpath(file, NULL); - #else - char * language_file = malloc(_MAX_PATH * sizeof(char)); - _fullpath(language_file, file, _MAX_PATH ); - #endif - languagesAmount++; - printf("Loading File: %s\n", language_file); + printf("Loading File: %s\n", file); - char * jsonTxt = read_file(language_file); + char * jsonTxt = read_file(file); load_language(jsonTxt, languagesAmount - 1); } } @@ -236,7 +243,7 @@ u8* get_key_string(char* id){ return tmp; } -void alloc_dialog_pool(void){ +void alloc_dialog_pool(char* exePath, char* gamedir){ languages = malloc(sizeof(struct LanguageEntry*)); languages[0] = malloc (sizeof (struct LanguageEntry)); @@ -256,8 +263,12 @@ void alloc_dialog_pool(void){ languages[0]->dialogs[i] = entry; } - alloc_languages(); - set_language(get_language_by_name("English")); + alloc_languages(exePath, gamedir); + static const char * languages[] = { + "Spanish", + "English" + }; + set_language(get_language_by_name(languages[configLanguage])); } void dealloc_dialog_pool(void){ diff --git a/src/text/text-loader.h b/src/text/text-loader.h index 7d9278ff..a1385d49 100644 --- a/src/text/text-loader.h +++ b/src/text/text-loader.h @@ -31,6 +31,6 @@ extern u8* get_key_string(char* id); extern struct LanguageEntry* get_language_by_name(char* name); extern struct LanguageEntry* get_language(); extern void set_language(struct LanguageEntry* new_language); -extern void alloc_dialog_pool(void); +extern void alloc_dialog_pool(char* exePath, char* gamedir); extern void dealloc_dialog_pool(void); #endif \ No newline at end of file diff --git a/src/text/txtconv.c b/src/text/txtconv.c index 3c6ec999..f641a60c 100644 --- a/src/text/txtconv.c +++ b/src/text/txtconv.c @@ -1,11 +1,11 @@ #include "txtconv.h" -struct Character charmap[348] = { +struct Character charmap[356] = { {"0", {0x0, NULL}}, {"1", {0x1, NULL}}, {"{65297}", {0x1, NULL}}, {"2", {0x2, NULL}}, {"{65298}", {0x2, NULL}}, {"3", {0x3, NULL}}, {"{65299}", {0x3, NULL}}, {"4", {0x4, NULL}}, {"{65300}", {0x4, NULL}}, {"5", {0x5, NULL}}, {"{65301}", {0x5, NULL}}, {"6", {0x6, NULL}}, {"{65302}", {0x6, NULL}}, {"7", {0x7, NULL}}, {"{65303}", {0x7, NULL}}, {"8", {0x8, NULL}}, {"{65304}", {0x8, NULL}}, {"9", {0x9, NULL}}, {"{65305}", {0x9, NULL}}, {"A", {0xa, NULL}}, {"{65313}", {0xa, NULL}}, {"B", {0xb, NULL}}, {"{65314}", {0xb, NULL}}, {"C", {0xc, NULL}}, {"{65315}", {0xc, NULL}}, {"D", {0xd, NULL}}, {"{65316}", {0xd, NULL}}, {"E", {0xe, NULL}}, {"{65317}", {0xe, NULL}}, {"F", {0xf, NULL}}, {"{65318}", {0xf, NULL}}, {"G", {0x10, NULL}}, {"{65319}", {0x10, NULL}}, {"H", {0x11, NULL}}, {"{65320}", {0x11, NULL}}, {"I", {0x12, NULL}}, {"{65321}", {0x12, NULL}}, - {"J", {0x13, NULL}}, {"{65322}", {0x13, NULL}}, {"K", {0x14, NULL}}, {"{65323}", {0x14, NULL}}, {"L", {0x15, NULL}}, {"{65324}", {0x15, NULL}}, {"M", {0x20, NULL}}, {"{65325}", {0x16, NULL}}, {"N", {0x17, NULL}}, + {"J", {0x13, NULL}}, {"{65322}", {0x13, NULL}}, {"K", {0x14, NULL}}, {"{65323}", {0x14, NULL}}, {"L", {0x15, NULL}}, {"{65324}", {0x15, NULL}}, {"M", {0x16, NULL}}, {"{65325}", {0x16, NULL}}, {"N", {0x17, NULL}}, {"{65326}", {0x17, NULL}}, {"O", {0x18, NULL}}, {"{65327}", {0x18, NULL}}, {"P", {0x19, NULL}}, {"{65328}", {0x19, NULL}}, {"Q", {0x1a, NULL}}, {"{65329}", {0x1a, NULL}}, {"R", {0x1b, NULL}}, {"{65330}", {0x1b, NULL}}, {"S", {0x1c, NULL}}, {"{65331}", {0x1c, NULL}}, {"T", {0x1d, NULL}}, {"{65332}", {0x1d, NULL}}, {"U", {0x1e, NULL}}, {"{65333}", {0x1e, NULL}}, {"V", {0x1f, NULL}}, {"{65334}", {0x1f, NULL}}, {"W", {0x20, NULL}}, {"{65335}", {0x20, NULL}}, {"X", {0x21, NULL}}, {"{65336}", {0x21, NULL}}, {"Y", {0x22, NULL}}, {"{65337}", {0x22, NULL}}, {"Z", {0x23, NULL}}, {"{65338}", {0x23, NULL}}, {"a", {0x24, NULL}}, {"b", {0x25, NULL}}, @@ -41,13 +41,27 @@ struct Character charmap[348] = { {"{00239}", {0xa2, NULL}}, {"{00223}", {0xec, NULL}}, {"{00199}", {0xed, NULL}}, {"{00231}", {0xee, NULL}}, {"{08222}", {0xf0, NULL}}, // SPECIAL CHARACTERS - {"{00161}", {0x95, NULL}}, {"{00237}", {0x95, NULL}}, {"{00225}", {0x95, NULL}}, {"{00243}", {0x95, NULL}}, {"{00201}", {0x95, NULL}}, {"{00233}", {0x95, NULL}}, - {"{00241}", {0x95, NULL}}, {"{00250}", {0x95, NULL}}, {"{00218}", {0x95, NULL}}, {"{00211}", {0x95, NULL}}, {"{00252}", {0x95, NULL}} + {"{00225}", {112, NULL}}, + {"{00233}", {113, NULL}}, + {"{00237}", {114, NULL}}, + {"{00243}", {115, NULL}}, + {"{00250}", {116, NULL}}, + {"{00193}", {117, NULL}}, + {"{00201}", {118, NULL}}, + {"{00205}", {119, NULL}}, + {"{00211}", {120, NULL}}, + {"{00218}", {121, NULL}}, + {"{00241}", {122, NULL}}, + {"{00209}", {123, NULL}}, + {"{00252}", {124, NULL}}, + {"{00220}", {125, NULL}}, + {"{00191}", {126, NULL}}, + {"{00161}", {127, NULL}} }; struct Character getCharacter(char* ch){ struct Character tmp = {NULL, {NULL, NULL}}; - for(s32 cmid = 0; cmid < 340; cmid++){ + for(s32 cmid = 0; cmid < sizeof(charmap) / sizeof(struct Character); cmid++){ if(charmap[cmid].txt != NULL){ if(strncmp(charmap[cmid].txt, ch, strlen(charmap[cmid].txt)) == 0) { tmp = charmap[cmid]; @@ -103,8 +117,8 @@ u8 * getTranslatedText(char * txt){ struct Character ctm = getCharacter(tmpSpecialChar); if(ctm.txt != NULL){ - shiftArr += 6; - cid += 6; + shiftArr += 5; + cid += 5; for(int cl = 0; cl < 2; cl++){ if(ctm.value[cl] != NULL){ tmp[cid - shiftArr + cl] = ctm.value[cl]; diff --git a/textures/special/accent_a.png b/textures/special/accent_a.png new file mode 100755 index 00000000..b21e0eb1 Binary files /dev/null and b/textures/special/accent_a.png differ diff --git a/textures/special/accent_e.png b/textures/special/accent_e.png new file mode 100755 index 00000000..45f1f435 Binary files /dev/null and b/textures/special/accent_e.png differ diff --git a/textures/special/accent_i.png b/textures/special/accent_i.png new file mode 100755 index 00000000..bb15a6e6 Binary files /dev/null and b/textures/special/accent_i.png differ diff --git a/textures/special/accent_o.png b/textures/special/accent_o.png new file mode 100755 index 00000000..edf2ac4c Binary files /dev/null and b/textures/special/accent_o.png differ diff --git a/textures/special/accent_u.png b/textures/special/accent_u.png new file mode 100755 index 00000000..c51ba80f Binary files /dev/null and b/textures/special/accent_u.png differ diff --git a/textures/special/enye.png b/textures/special/enye.png new file mode 100755 index 00000000..7ca617d0 Binary files /dev/null and b/textures/special/enye.png differ diff --git a/textures/special/exclamation.png b/textures/special/exclamation.png new file mode 100755 index 00000000..ce31cb1e Binary files /dev/null and b/textures/special/exclamation.png differ diff --git a/textures/special/mayus_accent_a.png b/textures/special/mayus_accent_a.png new file mode 100755 index 00000000..a5403319 Binary files /dev/null and b/textures/special/mayus_accent_a.png differ diff --git a/textures/special/mayus_accent_e.png b/textures/special/mayus_accent_e.png new file mode 100755 index 00000000..b969a976 Binary files /dev/null and b/textures/special/mayus_accent_e.png differ diff --git a/textures/special/mayus_accent_i.png b/textures/special/mayus_accent_i.png new file mode 100755 index 00000000..5a483c54 Binary files /dev/null and b/textures/special/mayus_accent_i.png differ diff --git a/textures/special/mayus_accent_o.png b/textures/special/mayus_accent_o.png new file mode 100755 index 00000000..cb44485e Binary files /dev/null and b/textures/special/mayus_accent_o.png differ diff --git a/textures/special/mayus_accent_u.png b/textures/special/mayus_accent_u.png new file mode 100755 index 00000000..23e6cd97 Binary files /dev/null and b/textures/special/mayus_accent_u.png differ diff --git a/textures/special/mayus_enye.png b/textures/special/mayus_enye.png new file mode 100755 index 00000000..d04178c5 Binary files /dev/null and b/textures/special/mayus_enye.png differ diff --git a/textures/special/mayus_umlaut.png b/textures/special/mayus_umlaut.png new file mode 100755 index 00000000..45cca581 Binary files /dev/null and b/textures/special/mayus_umlaut.png differ diff --git a/textures/special/question.png b/textures/special/question.png new file mode 100755 index 00000000..8fa95b4c Binary files /dev/null and b/textures/special/question.png differ diff --git a/textures/special/umlaut.png b/textures/special/umlaut.png new file mode 100755 index 00000000..4e62c1c5 Binary files /dev/null and b/textures/special/umlaut.png differ