Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
authornemo
Sun, 24 May 2009 02:41:34 +0000
changeset 2098 c977d7f2aa09
parent 2097 30bc47dcd43e
child 2099 e70e7ce4fb0f
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
QTfrontend/SquareLabel.cpp
QTfrontend/gameuiconfig.cpp
QTfrontend/gameuiconfig.h
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/itemNum.cpp
QTfrontend/pages.cpp
QTfrontend/pages.h
--- a/QTfrontend/SquareLabel.cpp	Sat May 23 21:24:43 2009 +0000
+++ b/QTfrontend/SquareLabel.cpp	Sun May 24 02:41:34 2009 +0000
@@ -19,11 +19,12 @@
 #include <QPaintEvent>
 #include <QPainter>
 #include "SquareLabel.h"
+#include "hwform.h"
 
 SquareLabel::SquareLabel(QWidget * parent) :
 	QWidget(parent)
 {
-    setAttribute(Qt::WA_PaintOnScreen, true);
+    if(frontendEffects) setAttribute(Qt::WA_PaintOnScreen, true);
 }
 
 void SquareLabel::paintEvent(QPaintEvent * event)
--- a/QTfrontend/gameuiconfig.cpp	Sat May 23 21:24:43 2009 +0000
+++ b/QTfrontend/gameuiconfig.cpp	Sun May 24 02:41:34 2009 +0000
@@ -45,6 +45,7 @@
 	Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr);
 
 	Form->ui.pageOptions->CBReduceQuality->setChecked(value("video/reducequality", false).toBool());
+	Form->ui.pageOptions->CBFrontendEffects->setChecked(value("video/frontendeffects", true).toBool());
 	Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool());
 	Form->ui.pageOptions->CBEnableMusic->setChecked(value("audio/music", true).toBool());
 	Form->ui.pageOptions->volumeBox->setValue(value("audio/volume", 100).toUInt());
@@ -92,6 +93,8 @@
 
 	setValue("video/reducequality", isReducedQuality());
 
+	setValue("video/frontendeffects", isFrontendEffects());
+
 	bool ffscr=isFrontendFullscreen();
 	setValue("video/frontendfullscreen", ffscr);
 	emit frontendFullscreen(ffscr);
@@ -140,6 +143,10 @@
 {
   return Form->ui.pageOptions->CBReduceQuality->isChecked();
 }
+bool GameUIConfig::isFrontendEffects() const
+{
+  return Form->ui.pageOptions->CBFrontendEffects->isChecked();
+}
 
 bool GameUIConfig::isFrontendFullscreen() const
 {
--- a/QTfrontend/gameuiconfig.h	Sat May 23 21:24:43 2009 +0000
+++ b/QTfrontend/gameuiconfig.h	Sun May 24 02:41:34 2009 +0000
@@ -45,6 +45,7 @@
 	quint8 bitDepth();
 	QString netNick();
 	bool isReducedQuality() const;
+	bool isFrontendEffects() const;
 	bool isFrontendFullscreen() const;
 	void resizeToConfigValues();
 
--- a/QTfrontend/hwform.cpp	Sat May 23 21:24:43 2009 +0000
+++ b/QTfrontend/hwform.cpp	Sun May 24 02:41:34 2009 +0000
@@ -55,9 +55,16 @@
 #include "ammoSchemeModel.h"
 #include "bgwidget.h"
 
+// I started handing this down to each place it touches, but it was getting ridiculous
+// and this one flag does not warrant a static class
+bool frontendEffects = true;
+
 HWForm::HWForm(QWidget *parent)
   : QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0)
 {
+    QSettings settings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat);
+    frontendEffects = settings.value("video/frontendeffects", true).toBool();
+
 	ui.setupUi(this);
 
 	CustomizePalettes();
@@ -167,11 +174,14 @@
 	ui.pageScheme->setModel(ammoSchemeModel);
 	ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel);
 
-	wBackground = new BGWidget(this);
-	wBackground->setFixedSize(this->width(), this->height());
-	wBackground->lower();
-	wBackground->init();
-	wBackground->startAnimation();
+    wBackground = NULL;
+    if (config->isFrontendEffects()) {
+       wBackground = new BGWidget(this);
+       wBackground->setFixedSize(this->width(), this->height());
+       wBackground->lower();
+       wBackground->init();
+       wBackground->startAnimation();
+    }
 
 	PagesStack.push(ID_PAGE_MAIN);
 	GoBack();
@@ -912,6 +922,8 @@
 {
 	int w = event->size().width();
 	int h = event->size().height();
-	wBackground->setFixedSize(w, h);
-	wBackground->move(0, 0);
+    if (wBackground) {
+        wBackground->setFixedSize(w, h);
+        wBackground->move(0, 0);
+    }
 }
--- a/QTfrontend/hwform.h	Sat May 23 21:24:43 2009 +0000
+++ b/QTfrontend/hwform.h	Sun May 24 02:41:34 2009 +0000
@@ -38,6 +38,8 @@
 class QCloseEvent;
 class AmmoSchemeModel;
 
+extern bool frontendEffects;
+
 class HWForm : public QMainWindow
 {
 	Q_OBJECT
--- a/QTfrontend/itemNum.cpp	Sat May 23 21:24:43 2009 +0000
+++ b/QTfrontend/itemNum.cpp	Sun May 24 02:41:34 2009 +0000
@@ -17,6 +17,7 @@
  */
  
 #include "itemNum.h"
+#include "hwform.h"
 
 #include <QMouseEvent>
 #include <QPainter>
@@ -25,7 +26,7 @@
   QFrame(parent), m_im(im), infinityState(false), nonInteractive(false), minItems(min), maxItems(max),
   numItems(min+2 >= max ? min : min+2)
 {
-    setAttribute(Qt::WA_PaintOnScreen, true);
+    if(frontendEffects) setAttribute(Qt::WA_PaintOnScreen, true);
 }
 
 ItemNum::~ItemNum()
--- a/QTfrontend/pages.cpp	Sat May 23 21:24:43 2009 +0000
+++ b/QTfrontend/pages.cpp	Sun May 24 02:41:34 2009 +0000
@@ -60,11 +60,12 @@
 #include "hats.h"
 #include "misc.h"
 #include "togglebutton.h"
+#include "hwform.h"
 
 PageMain::PageMain(QWidget* parent) : 
   AbstractPage(parent)
 {
-    setAttribute(Qt::WA_NoSystemBackground, true);
+    if(frontendEffects) setAttribute(Qt::WA_NoSystemBackground, true);
 	QGridLayout * pageLayout = new QGridLayout(this);
 	//pageLayout->setColumnStretch(0, 1);
 	//pageLayout->setColumnStretch(1, 2);
@@ -407,6 +408,10 @@
 		CBReduceQuality->setText(QCheckBox::tr("Reduce Quality"));
 		GBAlayout->addWidget(CBReduceQuality);
 
+		CBFrontendEffects = new QCheckBox(AGGroupBox);
+		CBFrontendEffects->setText(QCheckBox::tr("Frontend Effects (Requires Restart)"));
+		GBAlayout->addWidget(CBFrontendEffects);
+
 		CBFullscreen = new QCheckBox(AGGroupBox);
 		CBFullscreen->setText(QCheckBox::tr("Fullscreen"));
 		GBAlayout->addWidget(CBFullscreen);
--- a/QTfrontend/pages.h	Sat May 23 21:24:43 2009 +0000
+++ b/QTfrontend/pages.h	Sun May 24 02:41:34 2009 +0000
@@ -227,6 +227,7 @@
 	QSpinBox * volumeBox;
 	QLineEdit *editNetNick;
 	QCheckBox *CBReduceQuality;
+	QCheckBox *CBFrontendEffects;
 };
 
 class PageNet : public AbstractPage