QTfrontend/gameuiconfig.cpp
changeset 7687 c73fd8cfa7c0
parent 7672 686ba86ae0e3
child 7700 fc44e4e33d1c
equal deleted inserted replaced
7613:ce6ead3327b2 7687:c73fd8cfa7c0
    25 #include <QStandardItemModel>
    25 #include <QStandardItemModel>
    26 
    26 
    27 #include "gameuiconfig.h"
    27 #include "gameuiconfig.h"
    28 #include "hwform.h"
    28 #include "hwform.h"
    29 #include "pageoptions.h"
    29 #include "pageoptions.h"
       
    30 #include "pagevideos.h"
    30 #include "pagenetserver.h"
    31 #include "pagenetserver.h"
    31 #include "hwconsts.h"
    32 #include "hwconsts.h"
    32 #include "fpsedit.h"
    33 #include "fpsedit.h"
    33 #include "HWApplication.h"
    34 #include "HWApplication.h"
    34 #include "DataManager.h"
    35 #include "DataManager.h"
    42 
    43 
    43     //Form->resize(value("frontend/width", 640).toUInt(), value("frontend/height", 450).toUInt());
    44     //Form->resize(value("frontend/width", 640).toUInt(), value("frontend/height", 450).toUInt());
    44     resizeToConfigValues();
    45     resizeToConfigValues();
    45 
    46 
    46     reloadValues();
    47     reloadValues();
       
    48     reloadVideosValues();
    47 }
    49 }
    48 
    50 
    49 void GameUIConfig::reloadValues(void)
    51 void GameUIConfig::reloadValues(void)
    50 {
    52 {
    51     Form->ui.pageOptions->WeaponTooltip->setChecked(value("misc/weaponTooltips", true).toBool());
    53     Form->ui.pageOptions->WeaponTooltip->setChecked(value("misc/weaponTooltips", true).toBool());
    64     bool ffscr=value("frontend/fullscreen", false).toBool();
    66     bool ffscr=value("frontend/fullscreen", false).toBool();
    65     Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr);
    67     Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr);
    66 
    68 
    67     Form->ui.pageOptions->SLQuality->setValue(value("video/quality", 5).toUInt());
    69     Form->ui.pageOptions->SLQuality->setValue(value("video/quality", 5).toUInt());
    68     Form->ui.pageOptions->CBStereoMode->setCurrentIndex(value("video/stereo", 0).toUInt());
    70     Form->ui.pageOptions->CBStereoMode->setCurrentIndex(value("video/stereo", 0).toUInt());
    69     Form->ui.pageOptions->CBFrontendEffects->setChecked(frontendEffects);
    71     Form->ui.pageOptions->CBEnableFrontendSound->setChecked(value("frontend/effects", true).toBool());
    70     Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool());
    72     Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool());
    71     Form->ui.pageOptions->CBEnableFrontendSound->setChecked(value("frontend/sound", true).toBool());
    73     Form->ui.pageOptions->CBEnableFrontendSound->setChecked(value("frontend/sound", true).toBool());
    72     Form->ui.pageOptions->CBEnableMusic->setChecked(value("audio/music", true).toBool());
    74     Form->ui.pageOptions->CBEnableMusic->setChecked(value("audio/music", true).toBool());
    73     Form->ui.pageOptions->CBEnableFrontendMusic->setChecked(value("frontend/music", true).toBool());
    75     Form->ui.pageOptions->CBEnableFrontendMusic->setChecked(value("frontend/music", true).toBool());
    74     Form->ui.pageOptions->volumeBox->setValue(value("audio/volume", 100).toUInt());
    76     Form->ui.pageOptions->volumeBox->setValue(value("audio/volume", 100).toUInt());
   116         for(int i = model->rowCount() - 1; i >= 0; --i)
   118         for(int i = model->rowCount() - 1; i >= 0; --i)
   117             model->item(i)->setData(QColor(value(QString("colors/color%1").arg(i), model->item(i)->data().value<QColor>()).value<QColor>()));
   119             model->item(i)->setData(QColor(value(QString("colors/color%1").arg(i), model->item(i)->data().value<QColor>()).value<QColor>()));
   118     }
   120     }
   119 }
   121 }
   120 
   122 
       
   123 void GameUIConfig::reloadVideosValues(void)
       
   124 {
       
   125     Form->ui.pageVideos->framerateBox->setValue(value("videorec/fps",25).toUInt());
       
   126     Form->ui.pageVideos->bitrateBox->setValue(value("videorec/bitrate",400).toUInt());
       
   127     bool useGameRes = value("videorec/usegameres",true).toBool();
       
   128     if (useGameRes)
       
   129     {
       
   130         QRect res = vid_Resolution();
       
   131         Form->ui.pageVideos->widthEdit->setText(QString::number(res.width()));
       
   132         Form->ui.pageVideos->heightEdit->setText(QString::number(res.height()));
       
   133     }
       
   134     else
       
   135     {
       
   136         Form->ui.pageVideos->widthEdit->setText(value("videorec/width","800").toString());
       
   137         Form->ui.pageVideos->heightEdit->setText(value("videorec/height","600").toString());
       
   138     }
       
   139     Form->ui.pageVideos->checkUseGameRes->setChecked(useGameRes);
       
   140     Form->ui.pageVideos->checkRecordAudio->setChecked(value("videorec/audio",true).toBool());
       
   141     if (!Form->ui.pageVideos->tryCodecs(value("videorec/format","no").toString(),
       
   142                                         value("videorec/videocodec","no").toString(),
       
   143                                         value("videorec/audiocodec","no").toString()))
       
   144         Form->ui.pageVideos->setDefaultCodecs();
       
   145 }
       
   146 
   121 QStringList GameUIConfig::GetTeamsList()
   147 QStringList GameUIConfig::GetTeamsList()
   122 {
   148 {
   123     QDir teamdir;
   149     QDir teamdir;
   124     teamdir.cd(cfgdir->absolutePath() + "/Teams");
   150     teamdir.cd(cfgdir->absolutePath() + "/Teams");
   125     QStringList teamslist = teamdir.entryList(QStringList("*.hwt"),QDir::Files|QDir::Hidden);
   151     QStringList teamslist = teamdir.entryList(QStringList("*.hwt"),QDir::Files|QDir::Hidden);
   194     { // save colors
   220     { // save colors
   195         QStandardItemModel * model = DataManager::instance().colorsModel();
   221         QStandardItemModel * model = DataManager::instance().colorsModel();
   196         for(int i = model->rowCount() - 1; i >= 0; --i)
   222         for(int i = model->rowCount() - 1; i >= 0; --i)
   197             setValue(QString("colors/color%1").arg(i), model->item(i)->data());
   223             setValue(QString("colors/color%1").arg(i), model->item(i)->data());
   198     }
   224     }
       
   225 
       
   226     Form->gameSettings->sync();
       
   227 }
       
   228 
       
   229 void GameUIConfig::SaveVideosOptions()
       
   230 {
       
   231     QRect res = rec_Resolution();
       
   232     setValue("videorec/format", AVFormat());
       
   233     setValue("videorec/videocodec", videoCodec());
       
   234     setValue("videorec/audiocodec", audioCodec());
       
   235     setValue("videorec/fps", rec_Framerate());
       
   236     setValue("videorec/bitrate", rec_Bitrate());
       
   237     setValue("videorec/width", res.width());
       
   238     setValue("videorec/height", res.height());
       
   239     setValue("videorec/usegameres", Form->ui.pageVideos->checkUseGameRes->isChecked());
       
   240     setValue("videorec/audio", recordAudio());
   199 
   241 
   200     Form->gameSettings->sync();
   242     Form->gameSettings->sync();
   201 }
   243 }
   202 
   244 
   203 QString GameUIConfig::language()
   245 QString GameUIConfig::language()
   393 
   435 
   394 quint8 GameUIConfig::volume()
   436 quint8 GameUIConfig::volume()
   395 {
   437 {
   396     return Form->ui.pageOptions->volumeBox->value() * 128 / 100;
   438     return Form->ui.pageOptions->volumeBox->value() * 128 / 100;
   397 }
   439 }
       
   440 
       
   441 QString GameUIConfig::AVFormat()
       
   442 {
       
   443     return Form->ui.pageVideos->format();
       
   444 }
       
   445 
       
   446 QString GameUIConfig::videoCodec()
       
   447 {
       
   448     return Form->ui.pageVideos->videoCodec();
       
   449 }
       
   450 
       
   451 QString GameUIConfig::audioCodec()
       
   452 {
       
   453     return Form->ui.pageVideos->audioCodec();
       
   454 }
       
   455 
       
   456 QRect GameUIConfig::rec_Resolution()
       
   457 {
       
   458     if (Form->ui.pageVideos->checkUseGameRes->isChecked())
       
   459         return vid_Resolution();
       
   460     QRect res(0,0,0,0);
       
   461     res.setWidth(Form->ui.pageVideos->widthEdit->text().toUInt());
       
   462     res.setHeight(Form->ui.pageVideos->heightEdit->text().toUInt());
       
   463     return res;
       
   464 }
       
   465 
       
   466 int GameUIConfig::rec_Framerate()
       
   467 {
       
   468     return Form->ui.pageVideos->framerateBox->value();
       
   469 }
       
   470 
       
   471 int GameUIConfig::rec_Bitrate()
       
   472 {
       
   473     return Form->ui.pageVideos->bitrateBox->value();
       
   474 }
       
   475 
       
   476 bool GameUIConfig::recordAudio()
       
   477 {
       
   478     return Form->ui.pageVideos->checkRecordAudio->isChecked();
       
   479 }