1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Save & load language selection

This commit is contained in:
Ivan Savenko 2022-12-25 23:06:22 +02:00
parent b012cd9490
commit 4cd91ffbed
3 changed files with 13 additions and 2 deletions

View File

@ -17,7 +17,7 @@
"type" : "object", "type" : "object",
"default": {}, "default": {},
"additionalProperties" : false, "additionalProperties" : false,
"required" : [ "playerName", "showfps", "music", "sound", "encoding", "swipe", "saveRandomMaps", "saveFrequency", "notifications", "extraDump" ], "required" : [ "playerName", "showfps", "music", "sound", "encoding", "language", "swipe", "saveRandomMaps", "saveFrequency", "notifications", "extraDump" ],
"properties" : { "properties" : {
"playerName" : { "playerName" : {
"type":"string", "type":"string",
@ -51,6 +51,10 @@
"type":"string", "type":"string",
"default" : "Maps/Arrogance" "default" : "Maps/Arrogance"
}, },
"language" : {
"type":"string",
"default" : "english"
},
"lastSave" : { "lastSave" : {
"type":"string", "type":"string",
"default" : "NEWGAME" "default" : "NEWGAME"

View File

@ -51,6 +51,7 @@ MainWindow::MainWindow(QWidget * parent)
: QMainWindow(parent), ui(new Ui::MainWindow) : QMainWindow(parent), ui(new Ui::MainWindow)
{ {
load(); // load FS before UI load(); // load FS before UI
updateTranslation(); // load translation
ui->setupUi(this); ui->setupUi(this);

View File

@ -114,6 +114,11 @@ void CSettingsView::loadSettings()
if(encodingIndex < ui->comboBoxEncoding->count()) if(encodingIndex < ui->comboBoxEncoding->count())
ui->comboBoxEncoding->setCurrentIndex((int)encodingIndex); ui->comboBoxEncoding->setCurrentIndex((int)encodingIndex);
ui->comboBoxAutoSave->setCurrentIndex(settings["general"]["saveFrequency"].Integer() > 0 ? 1 : 0); ui->comboBoxAutoSave->setCurrentIndex(settings["general"]["saveFrequency"].Integer() > 0 ? 1 : 0);
std::string language = settings["general"]["language"].String();
size_t languageIndex = boost::range::find(languageTagList, language) - languageTagList;
if(languageIndex < ui->comboBoxLanguage->count())
ui->comboBoxLanguage->setCurrentIndex((int)languageIndex);
} }
void CSettingsView::fillValidResolutions(bool isExtraResolutionsModEnabled) void CSettingsView::fillValidResolutions(bool isExtraResolutionsModEnabled)
@ -319,7 +324,8 @@ void CSettingsView::on_comboBoxLanguage_currentIndexChanged(int index)
Settings node = settings.write["general"]["language"]; Settings node = settings.write["general"]["language"];
node->String() = languageTagList[index]; node->String() = languageTagList[index];
dynamic_cast<MainWindow*>(qApp->activeWindow())->updateTranslation(); if ( qApp->activeWindow() && dynamic_cast<MainWindow*>(qApp->activeWindow()) )
dynamic_cast<MainWindow*>(qApp->activeWindow())->updateTranslation();
} }
void CSettingsView::changeEvent(QEvent *event) void CSettingsView::changeEvent(QEvent *event)