mirror of https://github.com/sm64pc/sm64pc.git
Added dynamic language support and fixed platform errors
This commit is contained in:
parent
73e97f841d
commit
098a7e9313
|
@ -75,14 +75,7 @@ static const u8 optsCameraStr[][32] = {
|
|||
// This is only for testing
|
||||
|
||||
static const u8 optsGameStr[][32] = {
|
||||
"TEXT_OPT_LANGUAGE",
|
||||
"TEXT_OPT_LANG_SPANISH",
|
||||
"TEXT_OPT_LANG_ENGLISH"
|
||||
};
|
||||
|
||||
static const u8 *languageChoices[] = {
|
||||
optsGameStr[1],
|
||||
optsGameStr[2],
|
||||
"TEXT_OPT_LANGUAGE"
|
||||
};
|
||||
|
||||
static const u8 optsVideoStr[][32] = {
|
||||
|
@ -276,7 +269,7 @@ static struct Option optsVideo[] = {
|
|||
};
|
||||
|
||||
static struct Option optsGame[] = {
|
||||
DEF_OPT_CHOICE( optsGameStr[0], &configLanguage, languageChoices ),
|
||||
DEF_OPT_CHOICE( optsGameStr[0], &configLanguage, NULL ),
|
||||
};
|
||||
|
||||
static struct Option optsAudio[] = {
|
||||
|
@ -376,6 +369,7 @@ static void optmenu_draw_text(s16 x, s16 y, const u8 *str, u8 col) {
|
|||
|
||||
static void optmenu_draw_opt(const struct Option *opt, s16 x, s16 y, u8 sel) {
|
||||
u8 buf[32] = { 0 };
|
||||
u8* choice;
|
||||
|
||||
if (opt->type == OPT_SUBMENU || opt->type == OPT_BUTTON)
|
||||
y -= 6;
|
||||
|
@ -388,7 +382,8 @@ static void optmenu_draw_opt(const struct Option *opt, s16 x, s16 y, u8 sel) {
|
|||
break;
|
||||
|
||||
case OPT_CHOICE:
|
||||
optmenu_draw_text(x, y-13, get_key_string(opt->choices[*opt->uval]), sel);
|
||||
choice = strcmp(opt->label, optsGameStr[0]) != 0 ? get_key_string(opt->choices[*opt->uval]) : getTranslatedText(languages[*opt->uval]->name);
|
||||
optmenu_draw_text(x, y-13, choice, sel);
|
||||
break;
|
||||
|
||||
case OPT_SCROLL:
|
||||
|
@ -424,12 +419,8 @@ static void optmenu_opt_change(struct Option *opt, s32 val) {
|
|||
break;
|
||||
|
||||
case OPT_CHOICE:
|
||||
*opt->uval = wrap_add(*opt->uval, val, 0, opt->numChoices - 1);
|
||||
static const char * languages[] = {
|
||||
"Spanish",
|
||||
"English"
|
||||
};
|
||||
set_language(get_language_by_name(languages[configLanguage]));
|
||||
*opt->uval = wrap_add(*opt->uval, val, 0, strcmp(opt->label, optsGameStr[0]) == 0 ? languagesAmount - 1: opt->numChoices - 1);
|
||||
set_language(languages[configLanguage]);
|
||||
break;
|
||||
|
||||
case OPT_SCROLL:
|
||||
|
|
|
@ -124,6 +124,7 @@ static const struct ConfigOption options[] = {
|
|||
{.name = "stick_deadzone", .type = CONFIG_TYPE_UINT, .uintValue = &configStickDeadzone},
|
||||
{.name = "rumble_strength", .type = CONFIG_TYPE_UINT, .uintValue = &configRumbleStrength},
|
||||
{.name = "precache", .type = CONFIG_TYPE_BOOL, .boolValue = &configPrecacheRes},
|
||||
{.name = "language", .type = CONFIG_TYPE_UINT, .boolValue = &configLanguage},
|
||||
#ifdef BETTERCAMERA
|
||||
{.name = "bettercam_enable", .type = CONFIG_TYPE_BOOL, .boolValue = &configEnableCamera},
|
||||
{.name = "bettercam_analog", .type = CONFIG_TYPE_BOOL, .boolValue = &configCameraAnalog},
|
||||
|
|
|
@ -168,13 +168,13 @@ void alloc_languages(char* exePath, char* gamedir){
|
|||
languages = realloc(languages, sizeof(struct LanguageEntry*) * 30);
|
||||
|
||||
char *lastSlash = NULL;
|
||||
char *parent = NULL;
|
||||
char *parent = malloc(FILENAME_MAX * sizeof(char*));
|
||||
#ifndef WIN32
|
||||
lastSlash = strrchr(exePath, '/');
|
||||
#else
|
||||
lastSlash = strrchr(exePath, '\\');
|
||||
#endif
|
||||
parent = strndup(exePath, strlen(exePath) - strlen(lastSlash));
|
||||
strncpy(parent, exePath, strlen(exePath) - strlen(lastSlash));
|
||||
|
||||
char * languagesDir = malloc(FILENAME_MAX * sizeof(char*));
|
||||
strcpy(languagesDir, parent);
|
||||
|
@ -196,9 +196,12 @@ void alloc_languages(char* exePath, char* gamedir){
|
|||
|
||||
char * jsonTxt = read_file(file);
|
||||
load_language(jsonTxt, languagesAmount - 1);
|
||||
free(file);
|
||||
}
|
||||
}
|
||||
|
||||
free(languagesDir);
|
||||
|
||||
languages = realloc(languages, sizeof(struct LanguageEntry*) * (languagesAmount));
|
||||
}
|
||||
|
||||
|
@ -264,11 +267,7 @@ void alloc_dialog_pool(char* exePath, char* gamedir){
|
|||
}
|
||||
|
||||
alloc_languages(exePath, gamedir);
|
||||
static const char * languages[] = {
|
||||
"Spanish",
|
||||
"English"
|
||||
};
|
||||
set_language(get_language_by_name(languages[configLanguage]));
|
||||
set_language(languages[configLanguage]);
|
||||
}
|
||||
|
||||
void dealloc_dialog_pool(void){
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"manifest": {
|
||||
"langName": "Spanish",
|
||||
"langName": "Español",
|
||||
"langLogo": "none"
|
||||
},
|
||||
"dialogs": [
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"manifest": {
|
||||
"langName": "Spanish",
|
||||
"langName": "Espa{00241}ol",
|
||||
"langLogo": "none"
|
||||
},
|
||||
"dialogs": [
|
||||
|
|
Loading…
Reference in New Issue