QTfrontend/gameuiconfig.cpp
branchui-scaling
changeset 15283 c4fd2813b127
parent 13389 24b531dcebe7
parent 14961 575dbd7b5f43
child 15663 d92eeb468dad
equal deleted inserted replaced
13390:0135e64c6c66 15283:c4fd2813b127
   103     Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
   103     Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
   104     bool ffscr=value("frontend/fullscreen", false).toBool();
   104     bool ffscr=value("frontend/fullscreen", false).toBool();
   105     Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr);
   105     Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr);
   106 
   106 
   107     Form->ui.pageOptions->SLQuality->setValue(value("video/quality", 5).toUInt());
   107     Form->ui.pageOptions->SLQuality->setValue(value("video/quality", 5).toUInt());
       
   108     Form->ui.pageOptions->SLZoom->setValue(value("video/zoom", 100).toUInt());
   108     Form->ui.pageOptions->CBStereoMode->setCurrentIndex(value("video/stereo", 0).toUInt());
   109     Form->ui.pageOptions->CBStereoMode->setCurrentIndex(value("video/stereo", 0).toUInt());
   109     Form->ui.pageOptions->CBFrontendEffects->setChecked(value("frontend/effects", true).toBool());
   110     Form->ui.pageOptions->CBFrontendEffects->setChecked(value("frontend/effects", true).toBool());
   110     Form->ui.pageOptions->CBSound->setChecked(value("audio/sound", true).toBool());
   111     Form->ui.pageOptions->CBSound->setChecked(value("audio/sound", true).toBool());
   111     Form->ui.pageOptions->CBFrontendSound->setChecked(value("frontend/sound", true).toBool());
   112     Form->ui.pageOptions->CBFrontendSound->setChecked(value("frontend/sound", true).toBool());
   112     Form->ui.pageOptions->CBMusic->setChecked(value("audio/music", true).toBool());
   113     Form->ui.pageOptions->CBMusic->setChecked(value("audio/music", true).toBool());
   113     Form->ui.pageOptions->CBFrontendMusic->setChecked(value("frontend/music", true).toBool());
   114     Form->ui.pageOptions->CBFrontendMusic->setChecked(value("frontend/music", true).toBool());
       
   115     Form->ui.pageOptions->CBDampenAudio->setChecked(value("audio/dampen", true).toBool());
   114     Form->ui.pageOptions->SLVolume->setValue(value("audio/volume", 100).toUInt());
   116     Form->ui.pageOptions->SLVolume->setValue(value("audio/volume", 100).toUInt());
   115 
   117 
   116     QString netNick = value("net/nick", tr("Guest")+QString("%1").arg(rand())).toString();
   118     QString netNick = value("net/nick", getRandomNick()).toString();
   117     Form->ui.pageOptions->editNetNick->setText(netNick);
   119     Form->ui.pageOptions->editNetNick->setText(netNick);
   118     bool savePwd = value("net/savepassword",true).toBool();
   120     bool savePwd = value("net/savepassword",true).toBool();
   119     Form->ui.pageOptions->CBSavePassword->setChecked(savePwd);
   121     Form->ui.pageOptions->CBSavePassword->setChecked(savePwd);
   120 
   122 
   121     Form->ui.pageOptions->editNetPassword->installEventFilter(this);
   123     Form->ui.pageOptions->editNetPassword->installEventFilter(this);
   239 }
   241 }
   240 
   242 
   241 void GameUIConfig::SaveOptions()
   243 void GameUIConfig::SaveOptions()
   242 {
   244 {
   243     setValue("video/fullscreenResolution", Form->ui.pageOptions->CBResolution->currentText());
   245     setValue("video/fullscreenResolution", Form->ui.pageOptions->CBResolution->currentText());
   244     setValue("video/windowedWidth", Form->ui.pageOptions->windowWidthEdit->text());
   246     setValue("video/windowedWidth", Form->ui.pageOptions->windowWidthEdit->value());
   245     setValue("video/windowedHeight", Form->ui.pageOptions->windowHeightEdit->text());
   247     setValue("video/windowedHeight", Form->ui.pageOptions->windowHeightEdit->value());
   246     setValue("video/fullscreen", vid_Fullscreen());
   248     setValue("video/fullscreen", vid_Fullscreen());
   247 
   249 
   248     setValue("video/quality", Form->ui.pageOptions->SLQuality->value());
   250     setValue("video/quality", Form->ui.pageOptions->SLQuality->value());
       
   251     setValue("video/zoom", Form->ui.pageOptions->SLZoom->value());
   249     setValue("video/stereo", stereoMode());
   252     setValue("video/stereo", stereoMode());
   250 
   253 
   251     setValue("frontend/effects", isFrontendEffects());
   254     setValue("frontend/effects", isFrontendEffects());
   252 
   255 
   253     setValue("misc/weaponTooltips", Form->ui.pageOptions->WeaponTooltip->isChecked());
   256     setValue("misc/weaponTooltips", Form->ui.pageOptions->WeaponTooltip->isChecked());
   268     setValue("audio/sound", isSoundEnabled());
   271     setValue("audio/sound", isSoundEnabled());
   269     setValue("frontend/sound", isFrontendSoundEnabled());
   272     setValue("frontend/sound", isFrontendSoundEnabled());
   270     setValue("audio/music", isMusicEnabled());
   273     setValue("audio/music", isMusicEnabled());
   271     setValue("frontend/music", isFrontendMusicEnabled());
   274     setValue("frontend/music", isFrontendMusicEnabled());
   272     setValue("audio/volume", Form->ui.pageOptions->SLVolume->value());
   275     setValue("audio/volume", Form->ui.pageOptions->SLVolume->value());
       
   276     setValue("audio/dampen", isAudioDampenEnabled());
   273 
   277 
   274     setValue("net/nick", netNick());
   278     setValue("net/nick", netNick());
   275     if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) {
   279     if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) {
   276         setPasswordHash(netPasswordHash());
   280         setPasswordHash(netPasswordHash());
   277     }
   281     }
   363     if (wh.size() == 2)
   367     if (wh.size() == 2)
   364     {
   368     {
   365         full.setWidth(wh[0].toInt());
   369         full.setWidth(wh[0].toInt());
   366         full.setHeight(wh[1].toInt());
   370         full.setHeight(wh[1].toInt());
   367     }
   371     }
   368     windowed.setWidth(Form->ui.pageOptions->windowWidthEdit->text().toInt());
   372     windowed.setWidth(Form->ui.pageOptions->windowWidthEdit->value());
   369     windowed.setHeight(Form->ui.pageOptions->windowHeightEdit->text().toInt());
   373     windowed.setHeight(Form->ui.pageOptions->windowHeightEdit->value());
   370     return std::make_pair(full, windowed);
   374     return std::make_pair(full, windowed);
   371 }
   375 }
   372 
   376 
   373 QRect GameUIConfig::vid_Resolution()
   377 QRect GameUIConfig::vid_Resolution()
   374 {
   378 {
   441 bool GameUIConfig::isFrontendFullscreen() const
   445 bool GameUIConfig::isFrontendFullscreen() const
   442 {
   446 {
   443     return Form->ui.pageOptions->CBFrontendFullscreen->isChecked();
   447     return Form->ui.pageOptions->CBFrontendFullscreen->isChecked();
   444 }
   448 }
   445 
   449 
       
   450 quint16 GameUIConfig::zoom()
       
   451 {
       
   452     return Form->ui.pageOptions->SLZoom->value();
       
   453 }
       
   454 
       
   455 bool GameUIConfig::isHolidaySillinessEnabled() const
       
   456 {
       
   457     return value("misc/holidaySilliness", true).toBool();
       
   458 }
       
   459 
       
   460 int GameUIConfig::quickGameExperience() const
       
   461 {
       
   462     return value("misc/quickGameExperience", 0).toInt();
       
   463 }
       
   464 
       
   465 void GameUIConfig::setQuickGameExperience(int exp)
       
   466 {
       
   467     setValue("misc/quickGameExperience", exp);
       
   468 }
       
   469 
   446 bool GameUIConfig::isSoundEnabled()
   470 bool GameUIConfig::isSoundEnabled()
   447 {
   471 {
   448     return Form->ui.pageOptions->CBSound->isChecked();
   472     return Form->ui.pageOptions->CBSound->isChecked();
   449 }
   473 }
   450 bool GameUIConfig::isFrontendSoundEnabled()
   474 bool GameUIConfig::isFrontendSoundEnabled()
   457     return Form->ui.pageOptions->CBMusic->isChecked();
   481     return Form->ui.pageOptions->CBMusic->isChecked();
   458 }
   482 }
   459 bool GameUIConfig::isFrontendMusicEnabled()
   483 bool GameUIConfig::isFrontendMusicEnabled()
   460 {
   484 {
   461     return Form->ui.pageOptions->CBFrontendMusic->isChecked();
   485     return Form->ui.pageOptions->CBFrontendMusic->isChecked();
       
   486 }
       
   487 bool GameUIConfig::isAudioDampenEnabled()
       
   488 {
       
   489     return Form->ui.pageOptions->CBDampenAudio->isChecked();
   462 }
   490 }
   463 
   491 
   464 bool GameUIConfig::isShowFPSEnabled()
   492 bool GameUIConfig::isShowFPSEnabled()
   465 {
   493 {
   466     return Form->ui.pageOptions->CBShowFPS->isChecked();
   494     return Form->ui.pageOptions->CBShowFPS->isChecked();
   499 }
   527 }
   500 
   528 
   501 void GameUIConfig::updNetNick()
   529 void GameUIConfig::updNetNick()
   502 {
   530 {
   503     Form->ui.pageOptions->editNetNick->setText(value("net/nick", "").toString());
   531     Form->ui.pageOptions->editNetNick->setText(value("net/nick", "").toString());
       
   532 }
       
   533 
       
   534 QString GameUIConfig::getRandomNick()
       
   535 {
       
   536     // Generate random nick name or pick old one if one was already generated.
       
   537     QString nick;
       
   538     if (cachedRandomNick.isNull())
       
   539         // "Guest" + number between 1 and 99999
       
   540         cachedRandomNick = tr("Guest") + QString("%1").arg(rand() % 99999 + 1);
       
   541     return cachedRandomNick;
   504 }
   542 }
   505 
   543 
   506 QByteArray GameUIConfig::netPasswordHash()
   544 QByteArray GameUIConfig::netPasswordHash()
   507 {
   545 {
   508     return QCryptographicHash::hash(Form->ui.pageOptions->editNetPassword->text().toUtf8(), QCryptographicHash::Md5).toHex();
   546     return QCryptographicHash::hash(Form->ui.pageOptions->editNetPassword->text().toUtf8(), QCryptographicHash::Md5).toHex();