diff --git a/desmume/src/frontend/posix/gtk/config_opts.h b/desmume/src/frontend/posix/gtk/config_opts.h index 6d2ac136f..9042fbede 100644 --- a/desmume/src/frontend/posix/gtk/config_opts.h +++ b/desmume/src/frontend/posix/gtk/config_opts.h @@ -62,6 +62,8 @@ OPT(textureSmoothing, bool, false, Config, 3DTextureSmoothing) OPT(textureUpscale, int, 1, Config, 3DTextureUpscaling) OPT(highColorInterpolation, bool, true, Config, HighResolutionColorInterpolation) OPT(multisampling, bool, false, Config, OpenGLMultisampling) +OPT(command_line_overriding_firmware_language, bool, false, Config, CommandLineOverridingFirmwareLanguage) +OPT(firmware_language, int, 1, Config, FirmwareLanguage) /* Audio */ OPT(audio_enabled, bool, true, Audio, Enabled) diff --git a/desmume/src/frontend/posix/gtk/main.cpp b/desmume/src/frontend/posix/gtk/main.cpp index 9c81bb5ba..a272ab77e 100644 --- a/desmume/src/frontend/posix/gtk/main.cpp +++ b/desmume/src/frontend/posix/gtk/main.cpp @@ -139,6 +139,7 @@ static void LoadSaveStateInfo(); static void Printscreen(); static void Reset(); static void SetAudioVolume(); +static void SetFirmwareLanguage(); static void Edit_Controls(); static void Edit_Joystick_Controls(); static void MenuSave(GtkMenuItem *item, gpointer slot); @@ -360,6 +361,7 @@ static const char *ui_description = " " " " " " +" " " " " " " " @@ -439,6 +441,7 @@ static const GtkActionEntry action_entries[] = { { "cheatlist", NULL, "_List", NULL, NULL, CheatList }, { "ConfigSaveMenu", NULL, "_Saves" }, { "setaudiovolume", NULL, "Set audio _volume", NULL, NULL, SetAudioVolume }, + { "setfirmwarelanguage", NULL, "Set firmware _language", NULL, NULL, SetFirmwareLanguage }, { "editctrls", NULL, "_Edit controls",NULL, NULL, Edit_Controls }, { "editjoyctrls", NULL, "Edit _Joystick controls",NULL, NULL, Edit_Joystick_Controls }, @@ -1909,7 +1912,7 @@ static gint Key_Release(GtkWidget *w, GdkEventKey *e, gpointer data) /////////////////////////////// SET AUDIO VOLUME ////////////////////////////////////// -static void CallbackSetAudioVolume(GtkWidget* hscale, gpointer data) +static void CallbackSetAudioVolume(GtkWidget *hscale, gpointer data) { SNDSDLSetAudioVolume(gtk_range_get_value(GTK_RANGE(hscale))); config.audio_volume = SNDSDLGetAudioVolume(); @@ -1923,7 +1926,7 @@ static void SetAudioVolume() dialog = gtk_dialog_new_with_buttons("Set audio volume", GTK_WINDOW(pWindow), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); hscale = gtk_hscale_new_with_range(0, SDL_MIX_MAXVOLUME, 1); gtk_range_set_value(GTK_RANGE(hscale), SNDSDLGetAudioVolume()); - g_signal_connect(G_OBJECT(hscale), "value-changed", G_CALLBACK(CallbackSetAudioVolume), NULL); + g_signal_connect(G_OBJECT(hscale), "value-changed", G_CALLBACK(CallbackSetAudioVolume), NULL); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hscale, TRUE, FALSE, 0); gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); switch(gtk_dialog_run(GTK_DIALOG(dialog))) @@ -1939,6 +1942,51 @@ static void SetAudioVolume() gtk_widget_destroy(dialog); } +/////////////////////////////// SET FIRMWARE LANGUAGE ////////////////////////////////////// + +static void CallbackSetFirmwareLanguage(GtkWidget *check_button, gpointer data) +{ + gtk_widget_set_sensitive(GTK_WIDGET(data), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button))); +} + +static void SetFirmwareLanguage() +{ + GtkWidget *dialog = NULL; + GtkWidget *combo_box_text = NULL; + GtkWidget *check_button = NULL; + const char *languages[6] = {"Japanese", "English", "French", "German", "Italian", "Spanish"}; + gchar *text = NULL; + dialog = gtk_dialog_new_with_buttons("Set firmware language", GTK_WINDOW(pWindow), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); + combo_box_text = gtk_combo_box_text_new(); + for(int index = 0; index < 6; index++) + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo_box_text), languages[index]); + gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box_text), config.firmware_language); + gtk_widget_set_sensitive(combo_box_text, config.command_line_overriding_firmware_language); + check_button = gtk_check_button_new_with_mnemonic("_Enable command line overriding"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button), config.command_line_overriding_firmware_language); + g_signal_connect(G_OBJECT(check_button), "toggled", G_CALLBACK(CallbackSetFirmwareLanguage), combo_box_text); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), check_button, TRUE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), combo_box_text, TRUE, FALSE, 0); + gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); + switch(gtk_dialog_run(GTK_DIALOG(dialog))) + { + case GTK_RESPONSE_OK: + text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo_box_text)); + for(int index = 0; index < 6; index++) + if(strcmp(text, languages[index]) == 0) + { + CommonSettings.fwConfig.language = index; + config.firmware_language = index; + } + config.command_line_overriding_firmware_language = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check_button)); + break; + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_NONE: + break; + } + gtk_widget_destroy(dialog); +} + /////////////////////////////// CONTROLS EDIT ////////////////////////////////////// static void AcceptNewInputKey(GtkWidget *w, GdkEventKey *e, struct modify_key_ctx *ctx) @@ -3058,6 +3106,11 @@ common_gtk_main( class configured_features *my_config) CommonSettings.fwConfig.language = my_config->firmware_language; } + /* if the command line overriding is enabled + then use the language set on the GUI */ + if(config.command_line_overriding_firmware_language) + CommonSettings.fwConfig.language = config.firmware_language; + //------------------addons---------- my_config->process_addonCommands();