csettingsview_moc.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. /*
  2. * csettingsview_moc.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "csettingsview_moc.h"
  12. #include "ui_csettingsview_moc.h"
  13. #include "mainwindow_moc.h"
  14. #include "../modManager/cmodlistview_moc.h"
  15. #include "../helper.h"
  16. #include "../jsonutils.h"
  17. #include "../languages.h"
  18. #include <QFileInfo>
  19. #include <QGuiApplication>
  20. #include "../../lib/CConfigHandler.h"
  21. #ifndef VCMI_MOBILE
  22. #include <SDL2/SDL.h>
  23. #endif
  24. namespace
  25. {
  26. QString resolutionToString(const QSize & resolution)
  27. {
  28. return QString{"%1x%2"}.arg(resolution.width()).arg(resolution.height());
  29. }
  30. static constexpr std::array cursorTypesList =
  31. {
  32. "hardware",
  33. "software"
  34. };
  35. static constexpr std::array upscalingFilterTypes =
  36. {
  37. "nearest",
  38. "linear",
  39. "best"
  40. };
  41. }
  42. void CSettingsView::setDisplayList()
  43. {
  44. QStringList list;
  45. for (const auto screen : QGuiApplication::screens())
  46. list << QString{"%1 - %2"}.arg(screen->name(), resolutionToString(screen->size()));
  47. if(list.count() < 2)
  48. {
  49. ui->comboBoxDisplayIndex->hide();
  50. ui->labelDisplayIndex->hide();
  51. fillValidResolutionsForScreen(0);
  52. }
  53. else
  54. {
  55. int displayIndex = settings["video"]["displayIndex"].Integer();
  56. ui->comboBoxDisplayIndex->addItems(list);
  57. // calls fillValidResolutions() in slot
  58. ui->comboBoxDisplayIndex->setCurrentIndex(displayIndex);
  59. }
  60. }
  61. void CSettingsView::setCheckbuttonState(QToolButton * button, bool checked)
  62. {
  63. button->setChecked(checked);
  64. updateCheckbuttonText(button);
  65. }
  66. void CSettingsView::updateCheckbuttonText(QToolButton * button)
  67. {
  68. if (button->isChecked())
  69. button->setText(tr("On"));
  70. else
  71. button->setText(tr("Off"));
  72. }
  73. void CSettingsView::loadSettings()
  74. {
  75. #ifdef VCMI_MOBILE
  76. ui->comboBoxFullScreen->hide();
  77. ui->labelFullScreen->hide();
  78. #else
  79. ui->labelReservedArea->hide();
  80. ui->sliderReservedArea->hide();
  81. ui->labelRelativeCursorMode->hide();
  82. ui->buttonRelativeCursorMode->hide();
  83. ui->sliderRelativeCursorSpeed->hide();
  84. ui->labelRelativeCursorSpeed->hide();
  85. ui->buttonHapticFeedback->hide();
  86. ui->labelHapticFeedback->hide();
  87. if (settings["video"]["realFullscreen"].Bool())
  88. ui->comboBoxFullScreen->setCurrentIndex(2);
  89. else
  90. ui->comboBoxFullScreen->setCurrentIndex(settings["video"]["fullscreen"].Bool());
  91. #endif
  92. fillValidScalingRange();
  93. ui->spinBoxInterfaceScaling->setValue(settings["video"]["resolution"]["scaling"].Float());
  94. ui->spinBoxFramerateLimit->setValue(settings["video"]["targetfps"].Float());
  95. ui->spinBoxFramerateLimit->setDisabled(settings["video"]["vsync"].Bool());
  96. ui->sliderReservedArea->setValue(std::round(settings["video"]["reservedWidth"].Float() * 100));
  97. ui->comboBoxFriendlyAI->setCurrentText(QString::fromStdString(settings["server"]["friendlyAI"].String()));
  98. ui->comboBoxNeutralAI->setCurrentText(QString::fromStdString(settings["server"]["neutralAI"].String()));
  99. ui->comboBoxEnemyAI->setCurrentText(QString::fromStdString(settings["server"]["enemyAI"].String()));
  100. ui->comboBoxEnemyPlayerAI->setCurrentText(QString::fromStdString(settings["server"]["playerAI"].String()));
  101. ui->comboBoxAlliedPlayerAI->setCurrentText(QString::fromStdString(settings["server"]["alliedAI"].String()));
  102. ui->spinBoxNetworkPort->setValue(settings["server"]["localPort"].Integer());
  103. ui->lineEditRepositoryDefault->setText(QString::fromStdString(settings["launcher"]["defaultRepositoryURL"].String()));
  104. ui->lineEditRepositoryExtra->setText(QString::fromStdString(settings["launcher"]["extraRepositoryURL"].String()));
  105. ui->lineEditRepositoryDefault->setEnabled(settings["launcher"]["defaultRepositoryEnabled"].Bool());
  106. ui->lineEditRepositoryExtra->setEnabled(settings["launcher"]["extraRepositoryEnabled"].Bool());
  107. ui->spinBoxAutoSaveLimit->setValue(settings["general"]["autosaveCountLimit"].Integer());
  108. ui->lineEditAutoSavePrefix->setText(QString::fromStdString(settings["general"]["savePrefix"].String()));
  109. ui->lineEditAutoSavePrefix->setEnabled(settings["general"]["useSavePrefix"].Bool());
  110. Languages::fillLanguages(ui->comboBoxLanguage, false);
  111. fillValidRenderers();
  112. std::string upscalingFilter = settings["video"]["scalingMode"].String();
  113. int upscalingFilterIndex = vstd::find_pos(upscalingFilterTypes, upscalingFilter);
  114. ui->comboBoxUpscalingFilter->setCurrentIndex(upscalingFilterIndex);
  115. ui->sliderMusicVolume->setValue(settings["general"]["music"].Integer());
  116. ui->sliderSoundVolume->setValue(settings["general"]["sound"].Integer());
  117. ui->sliderRelativeCursorSpeed->setValue(settings["general"]["relativePointerSpeedMultiplier"].Integer());
  118. ui->sliderLongTouchDuration->setValue(settings["general"]["longTouchTimeMilliseconds"].Integer());
  119. ui->slideToleranceDistanceMouse->setValue(settings["input"]["mouseToleranceDistance"].Integer());
  120. ui->sliderToleranceDistanceTouch->setValue(settings["input"]["touchToleranceDistance"].Integer());
  121. ui->sliderToleranceDistanceController->setValue(settings["input"]["shortcutToleranceDistance"].Integer());
  122. ui->sliderControllerSticksSensitivity->setValue(settings["input"]["controllerAxisSpeed"].Integer());
  123. ui->sliderControllerSticksAcceleration->setValue(settings["input"]["controllerAxisScale"].Float() * 100);
  124. ui->lineEditGameLobbyHost->setText(QString::fromStdString(settings["lobby"]["hostname"].String()));
  125. ui->spinBoxNetworkPortLobby->setValue(settings["lobby"]["port"].Integer());
  126. loadToggleButtonSettings();
  127. }
  128. void CSettingsView::loadToggleButtonSettings()
  129. {
  130. setCheckbuttonState(ui->buttonShowIntro, settings["video"]["showIntro"].Bool());
  131. setCheckbuttonState(ui->buttonVSync, settings["video"]["vsync"].Bool());
  132. setCheckbuttonState(ui->buttonAutoCheck, settings["launcher"]["autoCheckRepositories"].Bool());
  133. setCheckbuttonState(ui->buttonRepositoryDefault, settings["launcher"]["defaultRepositoryEnabled"].Bool());
  134. setCheckbuttonState(ui->buttonRepositoryExtra, settings["launcher"]["extraRepositoryEnabled"].Bool());
  135. setCheckbuttonState(ui->buttonIgnoreSslErrors, settings["launcher"]["ignoreSslErrors"].Bool());
  136. setCheckbuttonState(ui->buttonAutoSave, settings["general"]["saveFrequency"].Integer() > 0);
  137. setCheckbuttonState(ui->buttonAutoSavePrefix, settings["general"]["useSavePrefix"].Bool());
  138. setCheckbuttonState(ui->buttonRelativeCursorMode, settings["general"]["userRelativePointer"].Bool());
  139. setCheckbuttonState(ui->buttonHapticFeedback, settings["general"]["hapticFeedback"].Bool());
  140. std::string cursorType = settings["video"]["cursor"].String();
  141. int cursorTypeIndex = vstd::find_pos(cursorTypesList, cursorType);
  142. setCheckbuttonState(ui->buttonCursorType, cursorTypeIndex);
  143. }
  144. void CSettingsView::fillValidResolutions()
  145. {
  146. fillValidResolutionsForScreen(ui->comboBoxDisplayIndex->isVisible() ? ui->comboBoxDisplayIndex->currentIndex() : 0);
  147. }
  148. QSize CSettingsView::getPreferredRenderingResolution()
  149. {
  150. #ifndef VCMI_MOBILE
  151. bool fullscreen = settings["video"]["fullscreen"].Bool();
  152. bool realFullscreen = settings["video"]["realFullscreen"].Bool();
  153. if (!fullscreen || realFullscreen)
  154. {
  155. int resX = settings["video"]["resolution"]["width"].Integer();
  156. int resY = settings["video"]["resolution"]["height"].Integer();
  157. return QSize(resX, resY);
  158. }
  159. #endif
  160. return QApplication::primaryScreen()->geometry().size() * QApplication::primaryScreen()->devicePixelRatio();
  161. }
  162. void CSettingsView::fillValidScalingRange()
  163. {
  164. //FIXME: this code is copy of ScreenHandler::getSupportedScalingRange
  165. // H3 resolution, any resolution smaller than that is not correctly supported
  166. static const QSize minResolution = {800, 600};
  167. // arbitrary limit on *downscaling*. Allow some downscaling, if requested by user. Should be generally limited to 100+ for all but few devices
  168. static const double minimalScaling = 50;
  169. QSize renderResolution = getPreferredRenderingResolution();
  170. double maximalScalingWidth = 100.0 * renderResolution.width() / minResolution.width();
  171. double maximalScalingHeight = 100.0 * renderResolution.height() / minResolution.height();
  172. double maximalScaling = std::min(maximalScalingWidth, maximalScalingHeight);
  173. ui->spinBoxInterfaceScaling->setRange(minimalScaling, maximalScaling);
  174. }
  175. #ifndef VCMI_MOBILE
  176. static QStringList getAvailableRenderingDrivers()
  177. {
  178. SDL_Init(SDL_INIT_VIDEO);
  179. QStringList result;
  180. result += QString(); // empty value for autoselection
  181. int driversCount = SDL_GetNumRenderDrivers();
  182. for(int it = 0; it < driversCount; it++)
  183. {
  184. SDL_RendererInfo info;
  185. if (SDL_GetRenderDriverInfo(it, &info) == 0)
  186. result += QString::fromLatin1(info.name);
  187. }
  188. SDL_Quit();
  189. return result;
  190. }
  191. static QVector<QSize> findAvailableResolutions(int displayIndex)
  192. {
  193. // Ugly workaround since we don't actually need SDL in Launcher
  194. // However Qt at the moment provides no way to query list of available resolutions
  195. QVector<QSize> result;
  196. SDL_Init(SDL_INIT_VIDEO);
  197. int modesCount = SDL_GetNumDisplayModes(displayIndex);
  198. for (int i =0; i < modesCount; ++i)
  199. {
  200. SDL_DisplayMode mode;
  201. if (SDL_GetDisplayMode(displayIndex, i, &mode) != 0)
  202. continue;
  203. QSize resolution(mode.w, mode.h);
  204. result.push_back(resolution);
  205. }
  206. boost::range::sort(result, [](const auto & left, const auto & right)
  207. {
  208. return left.height() * left.width() < right.height() * right.width();
  209. });
  210. result.erase(boost::unique(result).end(), result.end());
  211. SDL_Quit();
  212. return result;
  213. }
  214. void CSettingsView::fillValidResolutionsForScreen(int screenIndex)
  215. {
  216. QSignalBlocker guard(ui->comboBoxResolution); // avoid saving wrong resolution after adding first item from the list
  217. ui->comboBoxResolution->clear();
  218. bool fullscreen = settings["video"]["fullscreen"].Bool();
  219. bool realFullscreen = settings["video"]["realFullscreen"].Bool();
  220. if (!fullscreen || realFullscreen)
  221. {
  222. QVector<QSize> resolutions = findAvailableResolutions(screenIndex);
  223. for(const auto & entry : resolutions)
  224. ui->comboBoxResolution->addItem(resolutionToString(entry));
  225. }
  226. else
  227. {
  228. ui->comboBoxResolution->addItem(resolutionToString(getPreferredRenderingResolution()));
  229. }
  230. ui->comboBoxResolution->setEnabled(ui->comboBoxResolution->count() > 1);
  231. int resX = settings["video"]["resolution"]["width"].Integer();
  232. int resY = settings["video"]["resolution"]["height"].Integer();
  233. int resIndex = ui->comboBoxResolution->findText(resolutionToString({resX, resY}));
  234. ui->comboBoxResolution->setCurrentIndex(resIndex);
  235. // if selected resolution no longer exists, force update value to the largest (last) resolution
  236. if(resIndex == -1)
  237. ui->comboBoxResolution->setCurrentIndex(ui->comboBoxResolution->count() - 1);
  238. }
  239. void CSettingsView::fillValidRenderers()
  240. {
  241. QSignalBlocker guard(ui->comboBoxRendererType); // avoid saving wrong renderer after adding first item from the list
  242. ui->comboBoxRendererType->clear();
  243. auto driversList = getAvailableRenderingDrivers();
  244. ui->comboBoxRendererType->addItems(driversList);
  245. std::string rendererName = settings["video"]["driver"].String();
  246. int index = ui->comboBoxRendererType->findText(QString::fromStdString(rendererName));
  247. ui->comboBoxRendererType->setCurrentIndex(index);
  248. }
  249. #else
  250. void CSettingsView::fillValidResolutionsForScreen(int screenIndex)
  251. {
  252. // resolutions are not selectable on mobile platforms
  253. ui->comboBoxResolution->hide();
  254. ui->labelResolution->hide();
  255. }
  256. void CSettingsView::fillValidRenderers()
  257. {
  258. // untested on mobile platforms
  259. ui->comboBoxRendererType->hide();
  260. ui->labelRendererType->hide();
  261. }
  262. #endif
  263. CSettingsView::CSettingsView(QWidget * parent)
  264. : QWidget(parent), ui(new Ui::CSettingsView)
  265. {
  266. ui->setupUi(this);
  267. Helper::enableScrollBySwiping(ui->settingsScrollArea);
  268. loadSettings();
  269. }
  270. CSettingsView::~CSettingsView()
  271. {
  272. delete ui;
  273. }
  274. void CSettingsView::on_comboBoxResolution_currentTextChanged(const QString & arg1)
  275. {
  276. QStringList list = arg1.split("x");
  277. Settings node = settings.write["video"]["resolution"];
  278. node["width"].Float() = list[0].toInt();
  279. node["height"].Float() = list[1].toInt();
  280. fillValidResolutions();
  281. fillValidScalingRange();
  282. }
  283. void CSettingsView::on_comboBoxFullScreen_currentIndexChanged(int index)
  284. {
  285. Settings nodeFullscreen = settings.write["video"]["fullscreen"];
  286. Settings nodeRealFullscreen = settings.write["video"]["realFullscreen"];
  287. nodeFullscreen->Bool() = (index != 0);
  288. nodeRealFullscreen->Bool() = (index == 2);
  289. fillValidResolutions();
  290. fillValidScalingRange();
  291. }
  292. void CSettingsView::on_buttonAutoCheck_toggled(bool value)
  293. {
  294. Settings node = settings.write["launcher"]["autoCheckRepositories"];
  295. node->Bool() = value;
  296. updateCheckbuttonText(ui->buttonAutoCheck);
  297. }
  298. void CSettingsView::on_comboBoxDisplayIndex_currentIndexChanged(int index)
  299. {
  300. Settings node = settings.write["video"];
  301. node["displayIndex"].Float() = index;
  302. fillValidResolutionsForScreen(index);
  303. }
  304. void CSettingsView::on_comboBoxFriendlyAI_currentTextChanged(const QString & arg1)
  305. {
  306. Settings node = settings.write["server"]["friendlyAI"];
  307. node->String() = arg1.toUtf8().data();
  308. }
  309. void CSettingsView::on_comboBoxNeutralAI_currentTextChanged(const QString & arg1)
  310. {
  311. Settings node = settings.write["server"]["neutralAI"];
  312. node->String() = arg1.toUtf8().data();
  313. }
  314. void CSettingsView::on_comboBoxEnemyAI_currentTextChanged(const QString & arg1)
  315. {
  316. Settings node = settings.write["server"]["enemyAI"];
  317. node->String() = arg1.toUtf8().data();
  318. }
  319. void CSettingsView::on_spinBoxNetworkPort_valueChanged(int arg1)
  320. {
  321. Settings node = settings.write["server"]["port"];
  322. node->Float() = arg1;
  323. }
  324. void CSettingsView::on_buttonShowIntro_toggled(bool value)
  325. {
  326. Settings node = settings.write["video"]["showIntro"];
  327. node->Bool() = value;
  328. updateCheckbuttonText(ui->buttonShowIntro);
  329. }
  330. void CSettingsView::on_buttonAutoSave_toggled(bool value)
  331. {
  332. Settings node = settings.write["general"]["saveFrequency"];
  333. node->Integer() = value ? 1 : 0;
  334. updateCheckbuttonText(ui->buttonAutoSave);
  335. }
  336. void CSettingsView::on_comboBoxLanguage_currentIndexChanged(int index)
  337. {
  338. Settings node = settings.write["general"]["language"];
  339. QString selectedLanguage = ui->comboBoxLanguage->itemData(index).toString();
  340. node->String() = selectedLanguage.toStdString();
  341. if(auto * mainWindow = dynamic_cast<MainWindow *>(qApp->activeWindow()))
  342. mainWindow->updateTranslation();
  343. }
  344. void CSettingsView::changeEvent(QEvent *event)
  345. {
  346. if(event->type() == QEvent::LanguageChange)
  347. {
  348. ui->retranslateUi(this);
  349. Languages::fillLanguages(ui->comboBoxLanguage, false);
  350. loadTranslation();
  351. loadToggleButtonSettings();
  352. }
  353. QWidget::changeEvent(event);
  354. }
  355. void CSettingsView::showEvent(QShowEvent * event)
  356. {
  357. loadTranslation();
  358. QWidget::showEvent(event);
  359. }
  360. void CSettingsView::on_buttonCursorType_toggled(bool value)
  361. {
  362. Settings node = settings.write["video"]["cursor"];
  363. node->String() = cursorTypesList[value ? 1 : 0];
  364. updateCheckbuttonText(ui->buttonCursorType);
  365. }
  366. void CSettingsView::loadTranslation()
  367. {
  368. QString baseLanguage = Languages::getHeroesDataLanguage();
  369. auto * mainWindow = dynamic_cast<MainWindow *>(qApp->activeWindow());
  370. if (!mainWindow)
  371. return;
  372. QString languageName = QString::fromStdString(settings["general"]["language"].String());
  373. QString modName = mainWindow->getModView()->getTranslationModName(languageName);
  374. bool translationExists = !modName.isEmpty();
  375. bool translationNeeded = languageName != baseLanguage;
  376. bool showTranslation = translationNeeded && translationExists;
  377. ui->labelTranslation->setVisible(showTranslation);
  378. ui->labelTranslationStatus->setVisible(showTranslation);
  379. ui->pushButtonTranslation->setVisible(showTranslation);
  380. if (!translationExists || !translationNeeded)
  381. return;
  382. bool translationAvailable = mainWindow->getModView()->isModAvailable(modName);
  383. bool translationEnabled = mainWindow->getModView()->isModEnabled(modName);
  384. ui->pushButtonTranslation->setVisible(!translationEnabled);
  385. if (translationEnabled)
  386. {
  387. ui->labelTranslationStatus->setText(tr("Active"));
  388. }
  389. if (!translationEnabled && !translationAvailable)
  390. {
  391. ui->labelTranslationStatus->setText(tr("Disabled"));
  392. ui->pushButtonTranslation->setText(tr("Enable"));
  393. }
  394. if (translationAvailable)
  395. {
  396. ui->labelTranslationStatus->setText(tr("Not Installed"));
  397. ui->pushButtonTranslation->setText(tr("Install"));
  398. }
  399. }
  400. void CSettingsView::on_pushButtonTranslation_clicked()
  401. {
  402. auto * mainWindow = dynamic_cast<MainWindow *>(qApp->activeWindow());
  403. assert(mainWindow);
  404. if (!mainWindow)
  405. return;
  406. QString languageName = QString::fromStdString(settings["general"]["language"].String());
  407. QString modName = mainWindow->getModView()->getTranslationModName(languageName);
  408. assert(!modName.isEmpty());
  409. if (modName.isEmpty())
  410. return;
  411. if (mainWindow->getModView()->isModAvailable(modName))
  412. {
  413. mainWindow->switchToModsTab();
  414. mainWindow->getModView()->doInstallMod(modName);
  415. }
  416. else
  417. {
  418. mainWindow->getModView()->enableModByName(modName);
  419. }
  420. }
  421. void CSettingsView::on_buttonRepositoryDefault_toggled(bool value)
  422. {
  423. Settings node = settings.write["launcher"]["defaultRepositoryEnabled"];
  424. node->Bool() = value;
  425. ui->lineEditRepositoryDefault->setEnabled(value);
  426. updateCheckbuttonText(ui->buttonRepositoryDefault);
  427. }
  428. void CSettingsView::on_buttonRepositoryExtra_toggled(bool value)
  429. {
  430. Settings node = settings.write["launcher"]["extraRepositoryEnabled"];
  431. node->Bool() = value;
  432. ui->lineEditRepositoryExtra->setEnabled(value);
  433. updateCheckbuttonText(ui->buttonRepositoryExtra);
  434. }
  435. void CSettingsView::on_lineEditRepositoryExtra_textEdited(const QString &arg1)
  436. {
  437. Settings node = settings.write["launcher"]["extraRepositoryURL"];
  438. node->String() = arg1.toStdString();
  439. }
  440. void CSettingsView::on_spinBoxInterfaceScaling_valueChanged(int arg1)
  441. {
  442. Settings node = settings.write["video"]["resolution"]["scaling"];
  443. node->Float() = arg1;
  444. }
  445. void CSettingsView::on_refreshRepositoriesButton_clicked()
  446. {
  447. auto * mainWindow = dynamic_cast<MainWindow *>(qApp->activeWindow());
  448. assert(mainWindow);
  449. if (!mainWindow)
  450. return;
  451. mainWindow->getModView()->loadRepositories();
  452. }
  453. void CSettingsView::on_spinBoxFramerateLimit_valueChanged(int arg1)
  454. {
  455. Settings node = settings.write["video"]["targetfps"];
  456. node->Float() = arg1;
  457. }
  458. void CSettingsView::on_buttonVSync_toggled(bool value)
  459. {
  460. Settings node = settings.write["video"]["vsync"];
  461. node->Bool() = value;
  462. ui->spinBoxFramerateLimit->setDisabled(settings["video"]["vsync"].Bool());
  463. updateCheckbuttonText(ui->buttonVSync);
  464. }
  465. void CSettingsView::on_comboBoxEnemyPlayerAI_currentTextChanged(const QString &arg1)
  466. {
  467. Settings node = settings.write["server"]["playerAI"];
  468. node->String() = arg1.toUtf8().data();
  469. }
  470. void CSettingsView::on_comboBoxAlliedPlayerAI_currentTextChanged(const QString &arg1)
  471. {
  472. Settings node = settings.write["server"]["alliedAI"];
  473. node->String() = arg1.toUtf8().data();
  474. }
  475. void CSettingsView::on_buttonAutoSavePrefix_toggled(bool value)
  476. {
  477. Settings node = settings.write["general"]["useSavePrefix"];
  478. node->Bool() = value;
  479. ui->lineEditAutoSavePrefix->setEnabled(value);
  480. updateCheckbuttonText(ui->buttonAutoSavePrefix);
  481. }
  482. void CSettingsView::on_spinBoxAutoSaveLimit_valueChanged(int arg1)
  483. {
  484. Settings node = settings.write["general"]["autosaveCountLimit"];
  485. node->Float() = arg1;
  486. }
  487. void CSettingsView::on_lineEditAutoSavePrefix_textEdited(const QString & arg1)
  488. {
  489. Settings node = settings.write["general"]["savePrefix"];
  490. node->String() = arg1.toStdString();
  491. }
  492. void CSettingsView::on_sliderReservedArea_valueChanged(int arg1)
  493. {
  494. Settings node = settings.write["video"]["reservedWidth"];
  495. node->Float() = float(arg1) / 100; // percentage -> ratio
  496. }
  497. void CSettingsView::on_comboBoxRendererType_currentTextChanged(const QString &arg1)
  498. {
  499. Settings node = settings.write["video"]["driver"];
  500. node->String() = arg1.toStdString();
  501. }
  502. void CSettingsView::on_buttonIgnoreSslErrors_clicked(bool checked)
  503. {
  504. Settings node = settings.write["launcher"]["ignoreSslErrors"];
  505. node->Bool() = checked;
  506. updateCheckbuttonText(ui->buttonIgnoreSslErrors);
  507. }
  508. void CSettingsView::on_comboBoxUpscalingFilter_currentIndexChanged(int index)
  509. {
  510. Settings node = settings.write["video"]["scalingMode"];
  511. node->String() = upscalingFilterTypes[index];
  512. }
  513. void CSettingsView::on_sliderMusicVolume_valueChanged(int value)
  514. {
  515. Settings node = settings.write["general"]["music"];
  516. node->Integer() = value;
  517. }
  518. void CSettingsView::on_sliderSoundVolume_valueChanged(int value)
  519. {
  520. Settings node = settings.write["general"]["sound"];
  521. node->Integer() = value;
  522. }
  523. void CSettingsView::on_buttonRelativeCursorMode_toggled(bool value)
  524. {
  525. Settings node = settings.write["general"]["userRelativePointer"];
  526. node->Bool() = value;
  527. updateCheckbuttonText(ui->buttonRelativeCursorMode);
  528. }
  529. void CSettingsView::on_sliderRelativeCursorSpeed_valueChanged(int value)
  530. {
  531. Settings node = settings.write["general"]["relativePointerSpeedMultiplier"];
  532. node->Float() = value / 100.0;
  533. }
  534. void CSettingsView::on_buttonHapticFeedback_toggled(bool value)
  535. {
  536. Settings node = settings.write["general"]["hapticFeedback"];
  537. node->Bool() = value;
  538. updateCheckbuttonText(ui->buttonHapticFeedback);
  539. }
  540. void CSettingsView::on_sliderLongTouchDuration_valueChanged(int value)
  541. {
  542. Settings node = settings.write["general"]["longTouchTimeMilliseconds"];
  543. node->Integer() = value;
  544. }
  545. void CSettingsView::on_slideToleranceDistanceMouse_valueChanged(int value)
  546. {
  547. Settings node = settings.write["input"]["mouseToleranceDistance"];
  548. node->Integer() = value;
  549. }
  550. void CSettingsView::on_sliderToleranceDistanceTouch_valueChanged(int value)
  551. {
  552. Settings node = settings.write["input"]["touchToleranceDistance"];
  553. node->Integer() = value;
  554. }
  555. void CSettingsView::on_sliderToleranceDistanceController_valueChanged(int value)
  556. {
  557. Settings node = settings.write["input"]["shortcutToleranceDistance"];
  558. node->Integer() = value;
  559. }
  560. void CSettingsView::on_lineEditGameLobbyHost_textChanged(const QString & arg1)
  561. {
  562. Settings node = settings.write["lobby"]["hostname"];
  563. node->String() = arg1.toStdString();
  564. }
  565. void CSettingsView::on_spinBoxNetworkPortLobby_valueChanged(int arg1)
  566. {
  567. Settings node = settings.write["lobby"]["port"];
  568. node->Integer() = arg1;
  569. }
  570. void CSettingsView::on_sliderControllerSticksAcceleration_valueChanged(int value)
  571. {
  572. Settings node = settings.write["input"]["controllerAxisScale"];
  573. node->Integer() = value / 100.0;
  574. }
  575. void CSettingsView::on_sliderControllerSticksSensitivity_valueChanged(int value)
  576. {
  577. Settings node = settings.write["input"]["controllerAxisSpeed"];
  578. node->Integer() = value;
  579. }