Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI: Add an option to set the GUI language to the game language #1402

Merged
merged 1 commit into from
Dec 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions base/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ static Common::Error runGame(const Plugin *plugin, OSystem &system, const Common
warning(_("Engine does not support debug level '%s'"), token.c_str());
}

#ifdef USE_TRANSLATION
Common::String previousLanguage = TransMan.getCurrentLanguage();
if (ConfMan.hasKey("gui_use_game_language")
&& ConfMan.getBool("gui_use_game_language")
&& ConfMan.hasKey("language")) {
TransMan.setLanguage(ConfMan.get("language"));
}
#endif

// Initialize any game-specific keymaps
engine->initKeymap();

Expand All @@ -278,6 +287,10 @@ static Common::Error runGame(const Plugin *plugin, OSystem &system, const Common
// Reset the file/directory mappings
SearchMan.clear();

#ifdef USE_TRANSLATION
TransMan.setLanguage(previousLanguage);
#endif

// Return result (== 0 means no error)
return result;
}
Expand Down
15 changes: 15 additions & 0 deletions gui/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,7 @@ GlobalOptionsDialog::GlobalOptionsDialog(LauncherDialog *launcher)
_autosavePeriodPopUp = 0;
_guiLanguagePopUpDesc = 0;
_guiLanguagePopUp = 0;
_guiLanguageUseGameLanguageCheckbox = nullptr;
#ifdef USE_UPDATES
_updatesPopUpDesc = 0;
_updatesPopUp = 0;
Expand Down Expand Up @@ -1690,6 +1691,17 @@ void GlobalOptionsDialog::build() {
_guiLanguagePopUp->setSelectedTag(Common::kTranslationBuiltinId);
#endif // USE_DETECTLANG

_guiLanguageUseGameLanguageCheckbox = new CheckboxWidget(tab, "GlobalOptions_Misc.GuiLanguageUseGameLanguage",
_("Switch the GUI language to the game language"),
_("When starting a game, change the GUI language to the game language."
"That way, if a game uses the ScummVM save and load dialogs, they are"
"in the same language as the game.")
);

if (ConfMan.hasKey("gui_use_game_language")) {
_guiLanguageUseGameLanguageCheckbox->setState(ConfMan.getBool("gui_use_game_language", _domain));
}

#endif // USE_TRANSLATION

#ifdef USE_UPDATES
Expand Down Expand Up @@ -1960,6 +1972,9 @@ void GlobalOptionsDialog::apply() {
newCharset = TransMan.getCurrentCharset();
isRebuildNeeded = true;
}

bool guiUseGameLanguage = _guiLanguageUseGameLanguageCheckbox->getState();
ConfMan.setBool("gui_use_game_language", guiUseGameLanguage, _domain);
#endif

GUI::ThemeEngine::GraphicsMode gfxMode = (GUI::ThemeEngine::GraphicsMode)_rendererPopUp->getSelectedTag();
Expand Down
1 change: 1 addition & 0 deletions gui/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ class GlobalOptionsDialog : public OptionsDialog {
PopUpWidget *_autosavePeriodPopUp;
StaticTextWidget *_guiLanguagePopUpDesc;
PopUpWidget *_guiLanguagePopUp;
CheckboxWidget *_guiLanguageUseGameLanguageCheckbox;

#ifdef USE_UPDATES
StaticTextWidget *_updatesPopUpDesc;
Expand Down
10 changes: 10 additions & 0 deletions gui/themes/default.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,11 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"/>"
"</layout>"
"<layout type='horizontal' padding='0,0,0,0' spacing='10' center='true'>"
"<widget name='GuiLanguageUseGameLanguage' "
"type='Checkbox' "
"/>"
"</layout>"
"<layout type='horizontal' padding='0,0,0,0' spacing='10' center='true'>"
"<widget name='UpdatesPopupDesc' "
"type='OptionsLabel' "
"/>"
Expand Down Expand Up @@ -2739,6 +2744,11 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"/>"
"</layout>"
"<layout type='horizontal' padding='0,0,0,0' spacing='6' center='true'>"
"<widget name='GuiLanguageUseGameLanguage' "
"type='Checkbox' "
"/>"
"</layout>"
"<layout type='horizontal' padding='0,0,0,0' spacing='6' center='true'>"
"<widget name='UpdatesPopupDesc' "
"width='80' "
"height='Globals.Line.Height' "
Expand Down
Binary file modified gui/themes/scummclassic.zip
Binary file not shown.
5 changes: 5 additions & 0 deletions gui/themes/scummclassic/classic_layout.stx
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,11 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'>
<widget name = 'GuiLanguageUseGameLanguage'
type = 'Checkbox'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'>
<widget name = 'UpdatesPopupDesc'
type = 'OptionsLabel'
Expand Down
5 changes: 5 additions & 0 deletions gui/themes/scummclassic/classic_layout_lowres.stx
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,11 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'>
<widget name = 'GuiLanguageUseGameLanguage'
type = 'Checkbox'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'>
<widget name = 'UpdatesPopupDesc'
width = '80'
Expand Down
Binary file modified gui/themes/scummmodern.zip
Binary file not shown.
5 changes: 5 additions & 0 deletions gui/themes/scummmodern/scummmodern_layout.stx
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,11 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'>
<widget name = 'GuiLanguageUseGameLanguage'
type = 'Checkbox'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'>
<widget name = 'UpdatesPopupDesc'
type = 'OptionsLabel'
Expand Down
7 changes: 6 additions & 1 deletion gui/themes/scummmodern/scummmodern_layout_lowres.stx
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,12 @@
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'>
<widget name = 'GuiLanguageUseGameLanguage'
type = 'Checkbox'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'>
<widget name = 'UpdatesPopupDesc'
width = '80'
height = 'Globals.Line.Height'
Expand Down