QTfrontend/gameuiconfig.cpp
changeset 7615 b39beffcf05e
parent 7565 00568d3054d0
child 7633 d4251e519062
--- a/QTfrontend/gameuiconfig.cpp	Mon Aug 27 16:52:50 2012 -0400
+++ b/QTfrontend/gameuiconfig.cpp	Tue Aug 28 20:30:57 2012 +0400
@@ -27,6 +27,7 @@
 #include "gameuiconfig.h"
 #include "hwform.h"
 #include "pageoptions.h"
+#include "pagevideos.h"
 #include "pagenetserver.h"
 #include "hwconsts.h"
 #include "fpsedit.h"
@@ -44,6 +45,7 @@
     resizeToConfigValues();
 
     reloadValues();
+    reloadVideosValues();
 }
 
 void GameUIConfig::reloadValues(void)
@@ -118,6 +120,29 @@
     }
 }
 
+void GameUIConfig::reloadVideosValues(void)
+{
+    Form->ui.pageVideos->framerateBox->setValue(value("videorec/fps",25).toUInt());
+    bool useGameRes = value("videorec/usegameres",true).toBool();
+    if (useGameRes)
+    {
+        QRect res = vid_Resolution();
+        Form->ui.pageVideos->widthEdit->setText(QString::number(res.width()));
+        Form->ui.pageVideos->heightEdit->setText(QString::number(res.height()));
+    }
+    else
+    {
+        Form->ui.pageVideos->widthEdit->setText(value("videorec/width","800").toString());
+        Form->ui.pageVideos->heightEdit->setText(value("videorec/height","600").toString());
+    }
+    Form->ui.pageVideos->checkUseGameRes->setChecked(useGameRes);
+    Form->ui.pageVideos->checkRecordAudio->setChecked(value("videorec/audio",true).toBool());
+    if (!Form->ui.pageVideos->tryCodecs(value("videorec/format","no").toString(),
+                                        value("videorec/videocodec","no").toString(),
+                                        value("videorec/audiocodec","no").toString()))
+        Form->ui.pageVideos->setDefaultCodecs();
+}
+
 QStringList GameUIConfig::GetTeamsList()
 {
     QDir teamdir;
@@ -200,6 +225,21 @@
     Form->gameSettings->sync();
 }
 
+void GameUIConfig::SaveVideosOptions()
+{
+    QRect res = rec_Resolution();
+    setValue("videorec/format", AVFormat());
+    setValue("videorec/videocodec", videoCodec());
+    setValue("videorec/audiocodec", audioCodec());
+    setValue("videorec/fps", rec_Framerate());
+    setValue("videorec/width", res.width());
+    setValue("videorec/height", res.height());
+    setValue("videorec/usegameres", Form->ui.pageVideos->checkUseGameRes->isChecked());
+    setValue("videorec/audio", recordAudio());
+
+    Form->gameSettings->sync();
+}
+
 QString GameUIConfig::language()
 {
     return Form->ui.pageOptions->CBLanguage->itemData(Form->ui.pageOptions->CBLanguage->currentIndex()).toString();
@@ -395,3 +435,38 @@
 {
     return Form->ui.pageOptions->volumeBox->value() * 128 / 100;
 }
+
+QString GameUIConfig::AVFormat()
+{
+    return Form->ui.pageVideos->format();
+}
+
+QString GameUIConfig::videoCodec()
+{
+    return Form->ui.pageVideos->videoCodec();
+}
+
+QString GameUIConfig::audioCodec()
+{
+    return Form->ui.pageVideos->audioCodec();
+}
+
+QRect GameUIConfig::rec_Resolution()
+{
+    if (Form->ui.pageVideos->checkUseGameRes->isChecked())
+        return vid_Resolution();
+    QRect res(0,0,0,0);
+    res.setWidth(Form->ui.pageVideos->widthEdit->text().toUInt());
+    res.setHeight(Form->ui.pageVideos->heightEdit->text().toUInt());
+    return res;
+}
+
+int GameUIConfig::rec_Framerate()
+{
+    return Form->ui.pageVideos->framerateBox->value();
+}
+
+bool GameUIConfig::recordAudio()
+{
+    return Form->ui.pageVideos->checkRecordAudio->isChecked();
+}