QTfrontend/gameuiconfig.cpp
changeset 7235 baa69bd025d9
parent 7153 f0d055645ab2
child 7238 313b2ecc4441
--- a/QTfrontend/gameuiconfig.cpp	Mon Jun 11 17:56:10 2012 +0400
+++ b/QTfrontend/gameuiconfig.cpp	Mon Jun 11 18:15:30 2012 +0400
@@ -26,6 +26,7 @@
 #include "gameuiconfig.h"
 #include "hwform.h"
 #include "pageoptions.h"
+#include "pagevideos.h"
 #include "pagenetserver.h"
 #include "hwconsts.h"
 #include "fpsedit.h"
@@ -42,6 +43,7 @@
     resizeToConfigValues();
 
     reloadValues();
+    reloadVideosValues();
 }
 
 void GameUIConfig::reloadValues(void)
@@ -110,6 +112,29 @@
     else if (depth > 16) depth = 32;
 }
 
+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->CBUseGameRes->setChecked(useGameRes);
+    Form->ui.pageVideos->CBRecordAudio->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;
@@ -182,6 +207,22 @@
 #ifdef SPARKLE_ENABLED
     setValue("misc/autoUpdate", isAutoUpdateEnabled());
 #endif
+
+    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->CBUseGameRes->isChecked());
+    setValue("videorec/audio", recordAudio());
+
     Form->gameSettings->sync();
 }
 
@@ -380,3 +421,37 @@
 {
     return Form->ui.pageOptions->volumeBox->value() * 128 / 100;
 }
+
+QString GameUIConfig::AVFormat()
+{
+    return Form->ui.pageVideos->getFormat();
+}
+
+QString GameUIConfig::videoCodec()
+{
+    return Form->ui.pageVideos->getVideoCodec();
+}
+
+QString GameUIConfig::audioCodec()
+{
+    return Form->ui.pageVideos->getAudioCodec();
+}
+
+QRect GameUIConfig::rec_Resolution()
+{
+    if (Form->ui.pageVideos->CBUseGameRes->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());
+}
+
+int GameUIConfig::rec_Framerate()
+{
+    return Form->ui.pageVideos->framerateBox->value();
+}
+
+bool GameUIConfig::recordAudio()
+{
+    return Form->ui.pageVideos->CBRecordAudio->isChecked();
+}