New schemes page look by TheXception
authorunc0rr
Thu, 02 Apr 2009 20:37:03 +0000
changeset 1932 f586d75c8b6a
parent 1931 ffe420e9e61a
child 1933 7b8b0a9032d3
New schemes page look by TheXception
QTfrontend/CMakeLists.txt
QTfrontend/hedgewars.qrc
QTfrontend/pages.cpp
QTfrontend/pages.h
QTfrontend/res/PlaySound.png
QTfrontend/res/ammopic.png
QTfrontend/res/btnBorder.png
QTfrontend/res/btnDisabled.png
QTfrontend/res/btnForts.png
QTfrontend/res/btnInvurnable.png
QTfrontend/res/btnLaserSight.png
QTfrontend/res/btnLowGravity.png
QTfrontend/res/btnMines.png
QTfrontend/res/btnOverlay.png
QTfrontend/res/btnSolid.png
QTfrontend/res/btnTeamsDivide.png
QTfrontend/res/dice.png
QTfrontend/res/hh25x25.png
QTfrontend/res/hh_small.png
QTfrontend/res/iconBox.png
QTfrontend/res/iconDamage.png
QTfrontend/res/iconHealth.png
QTfrontend/res/iconSuddenDeath.png
QTfrontend/res/iconTime.png
QTfrontend/res/icons.png
QTfrontend/res/infinity.png
QTfrontend/res/lightbulb_off.png
QTfrontend/togglebutton.cpp
QTfrontend/togglebutton.h
--- a/QTfrontend/CMakeLists.txt	Thu Apr 02 18:50:08 2009 +0000
+++ b/QTfrontend/CMakeLists.txt	Thu Apr 02 20:37:03 2009 +0000
@@ -86,6 +86,7 @@
 	statsPage.cpp
 	misc.cpp
 	ammoSchemeModel.cpp
+	togglebutton.cpp
 	)
 
 if(MINGW)
@@ -135,6 +136,7 @@
 	statsPage.h
 	misc.h
 	ammoSchemeModel.h
+	togglebutton.h
 	)
 
 set(hwfr_hdrs
--- a/QTfrontend/hedgewars.qrc	Thu Apr 02 18:50:08 2009 +0000
+++ b/QTfrontend/hedgewars.qrc	Thu Apr 02 20:37:03 2009 +0000
@@ -44,6 +44,19 @@
     <file>res/spin_down.png</file>
     <file>res/PlaySound.png</file>
     <file>res/hh_small.png</file>
-    <file>res/dice.png</file>
+    <file>res/btnDisabled.png</file>
+    <file>res/btnForts.png</file>
+    <file>res/btnBorder.png</file>
+    <file>res/btnInvurnable.png</file>
+    <file>res/btnLaserSight.png</file>
+    <file>res/btnLowGravity.png</file>
+    <file>res/btnMines.png</file>
+    <file>res/btnTeamsDivide.png</file>
+    <file>res/btnSolid.png</file>
+    <file>res/iconBox.png</file>
+    <file>res/iconHealth.png</file>
+    <file>res/iconSuddenDeath.png</file>
+    <file>res/iconDamage.png</file>
+    <file>res/iconTime.png</file>
 </qresource>
 </RCC>
--- a/QTfrontend/pages.cpp	Thu Apr 02 18:50:08 2009 +0000
+++ b/QTfrontend/pages.cpp	Thu Apr 02 20:37:03 2009 +0000
@@ -59,6 +59,7 @@
 #include "igbox.h"
 #include "hats.h"
 #include "misc.h"
+#include "togglebutton.h"
 
 PageMain::PageMain(QWidget* parent) : 
   AbstractPage(parent)
@@ -467,7 +468,7 @@
 	pageLayout->addWidget(BtnNetSvrStart, 4, 2);
 
 	BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true);
-
+	
 	ConnGroupBox = new QGroupBox(this);
 	ConnGroupBox->setTitle(QGroupBox::tr("Net game"));
 	pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3);
@@ -858,71 +859,144 @@
 	AbstractPage(parent)
 {
 	QGridLayout * pageLayout = new QGridLayout(this);
-
-	CB_mode_Forts = new QCheckBox(this);
-	CB_mode_Forts->setText(QCheckBox::tr("Forts mode"));
-	pageLayout->addWidget(CB_mode_Forts, 0, 0, 1, 2);
+	QGroupBox * gb = new QGroupBox(QGroupBox::tr("Scheme options"), this);
+	
+	QGridLayout * gl = new QGridLayout();
+	gb->setLayout(gl);
 
-	CB_teamsDivide = new QCheckBox(this);
-	CB_teamsDivide->setText(QCheckBox::tr("Divide teams"));
-	pageLayout->addWidget(CB_teamsDivide, 1, 0, 1, 2);
+	pageLayout->addWidget(gb, 1,0,13,4);
+	
+	QGroupBox * gbGameModes = new QGroupBox(QGroupBox::tr("Game Modifiers"), gb);
+	QGroupBox * gbBasicSettings = new QGroupBox(QGroupBox::tr("Basic Settings"), gb);
+	
+	gl->addWidget(gbGameModes,0,0,1,1);
+	gl->addWidget(gbBasicSettings,0,1,1,1);
+	
+	QGridLayout * glGMLayout = new QGridLayout(gbGameModes);
+	QGridLayout * glBSLayout = new QGridLayout(gbBasicSettings);
+	gbGameModes->setLayout(glGMLayout);
+	gbBasicSettings->setLayout(glBSLayout);
+	// Left
+	
+	TBW_mode_Forts = new ToggleButtonWidget(gbGameModes, ":/res/btnForts.png");
+	TBW_mode_Forts->setText(ToggleButtonWidget::tr("Fort Mode"));
+	glGMLayout->addWidget(TBW_mode_Forts,0,0,1,1);
 
-	CB_solid = new QCheckBox(this);
-	CB_solid->setText(QCheckBox::tr("Solid land"));
-	pageLayout->addWidget(CB_solid, 2, 0, 1, 2);
+	TBW_teamsDivide = new ToggleButtonWidget(gbGameModes, ":/res/btnTeamsDivide.png");
+	TBW_teamsDivide->setText(ToggleButtonWidget::tr("Divide Teams"));
+	glGMLayout->addWidget(TBW_teamsDivide,0,1,1,1);
+	//pageLayout->addWidget(TBW_teamsDivide, 1, 0, 1, 2);
 
-	CB_border = new QCheckBox(this);
-	CB_border->setText(QCheckBox::tr("Add Border"));
-	pageLayout->addWidget(CB_border, 3, 0, 1, 2);
+	TBW_solid = new ToggleButtonWidget(gbGameModes, ":/res/btnSolid.png");
+	TBW_solid->setText(ToggleButtonWidget::tr("Solid Land"));
+	glGMLayout->addWidget(TBW_solid,0,2,1,1);
+	//pageLayout->addWidget(TBW_solid, 2, 0, 1, 2);
 
-	CB_lowGravity = new QCheckBox(this);
-	CB_lowGravity->setText(QCheckBox::tr("Low Gravity"));
-	pageLayout->addWidget(CB_lowGravity, 4, 0, 1, 2);
+	TBW_border = new ToggleButtonWidget(gbGameModes, ":/res/btnBorder.png");
+	TBW_border->setText(ToggleButtonWidget::tr("Add Border"));
+	glGMLayout->addWidget(TBW_border,0,3,1,1);
+	//pageLayout->addWidget(TBW_border, 3, 0, 1, 2);
 
-	CB_laserSight = new QCheckBox(this);
-	CB_laserSight->setText(QCheckBox::tr("Laser Sight"));
-	pageLayout->addWidget(CB_laserSight, 5, 0, 1, 2);
+	TBW_lowGravity = new ToggleButtonWidget(gbGameModes, ":/res/btnLowGravity.png");
+	TBW_lowGravity->setText(ToggleButtonWidget::tr("Low Gravity"));
+	glGMLayout->addWidget(TBW_lowGravity,1,0,1,1);
+	//pageLayout->addWidget(TBW_lowGravity, 4, 0, 1, 2);
+
+	TBW_laserSight = new ToggleButtonWidget(gbGameModes, ":/res/btnLaserSight.png");
+	TBW_laserSight->setText(ToggleButtonWidget::tr("Laser Sight"));
+	glGMLayout->addWidget(TBW_laserSight,1,1,1,1);
+	//pageLayout->addWidget(TBW_laserSight, 5, 0, 1, 2);
 
-	CB_invulnerable = new QCheckBox(this);
-	CB_invulnerable->setText(QCheckBox::tr("Invulnerable"));
-	pageLayout->addWidget(CB_invulnerable, 6, 0, 1, 2);
+	TBW_invulnerable = new ToggleButtonWidget(gbGameModes, ":/res/btnInvurnable.png");
+	TBW_invulnerable->setText(ToggleButtonWidget::tr("Invulnerable"));
+	glGMLayout->addWidget(TBW_invulnerable,1,2,1,1);
+	//pageLayout->addWidget(TBW_invulnerable, 6, 0, 1, 2);
+
+	TBW_mines = new ToggleButtonWidget(gbGameModes, ":/res/btnMines.png");
+	TBW_mines->setText(ToggleButtonWidget::tr("Add Mines"));
+	glGMLayout->addWidget(TBW_mines,1,3,1,1);
+	//pageLayout->addWidget(TBW_mines, 7, 0, 1, 2);
 
-	CB_mines = new QCheckBox(this);
-	CB_mines->setText(QCheckBox::tr("Add Mines"));
-	pageLayout->addWidget(CB_mines, 7, 0, 1, 2);
-
-	SB_DamageModifier = new QSpinBox(this);
+	// Right
+	QLabel * l;
+	
+	l = new QLabel(gbBasicSettings);
+	l->setText(QLabel::tr("Damage Modifier"));
+	glBSLayout->addWidget(l,0,0,1,1);
+	l = new QLabel(gbBasicSettings);
+	l->setFixedSize(32,32);
+	l->setPixmap(QPixmap(":/res/iconDamage.png"));
+	glBSLayout->addWidget(l,0,2,1,1);
+	
+	SB_DamageModifier = new QSpinBox(gbBasicSettings);
 	SB_DamageModifier->setRange(10, 300);
 	SB_DamageModifier->setValue(100);
 	SB_DamageModifier->setSingleStep(25);
+	glBSLayout->addWidget(SB_DamageModifier,0,1,1,1);
+
+	l = new QLabel(gbBasicSettings);
+	l->setText(QLabel::tr("Turn Time"));
+	glBSLayout->addWidget(l,1,0,1,1);
+	l = new QLabel(gbBasicSettings);
+	l->setFixedSize(32,32);
+	l->setPixmap(QPixmap(":/res/iconTime.png"));
+	glBSLayout->addWidget(l,1,2,1,1);
 	
-	SB_TurnTime = new QSpinBox(this);
+	SB_TurnTime = new QSpinBox(gbBasicSettings);
 	SB_TurnTime->setRange(1, 99);
 	SB_TurnTime->setValue(45);
 	SB_TurnTime->setSingleStep(15);
+	glBSLayout->addWidget(SB_TurnTime,1,1,1,1);
 	
-	SB_InitHealth = new QSpinBox(this);
+	l = new QLabel(gbBasicSettings);
+	l->setText(QLabel::tr("Initial Health"));
+	glBSLayout->addWidget(l,2,0,1,1);
+	l = new QLabel(gbBasicSettings);
+	l->setFixedSize(32,32);
+	l->setPixmap(QPixmap(":/res/iconHealth.png"));
+	glBSLayout->addWidget(l,2,2,1,1);
+	
+	SB_InitHealth = new QSpinBox(gbBasicSettings);
 	SB_InitHealth->setRange(50, 200);
 	SB_InitHealth->setValue(100);
 	SB_InitHealth->setSingleStep(25);
+	glBSLayout->addWidget(SB_InitHealth,2,1,1,1);
 	
-	SB_SuddenDeath = new QSpinBox(this);
+	l = new QLabel(gbBasicSettings);
+	l->setText(QLabel::tr("Sudden Death Timeout"));
+	glBSLayout->addWidget(l,3,0,1,1);
+	l = new QLabel(gbBasicSettings);
+	l->setFixedSize(32,32);
+	l->setPixmap(QPixmap(":/res/iconSuddenDeath.png"));
+	glBSLayout->addWidget(l,3,2,1,1);
+
+	SB_SuddenDeath = new QSpinBox(gbBasicSettings);
 	SB_SuddenDeath->setRange(0, 50);
 	SB_SuddenDeath->setValue(15);
 	SB_SuddenDeath->setSingleStep(3);
+	glBSLayout->addWidget(SB_SuddenDeath,3,1,1,1);
 	
-	SB_CaseProb = new FreqSpinBox(this);
+	l = new QLabel(gbBasicSettings);
+	l->setText(QLabel::tr("Case Probability"));
+	glBSLayout->addWidget(l,4,0,1,1);
+	l = new QLabel(gbBasicSettings);
+	l->setFixedSize(32,32);
+	l->setPixmap(QPixmap(":/res/iconBox.png"));
+	glBSLayout->addWidget(l,4,2,1,1);
+
+	SB_CaseProb = new FreqSpinBox(gbBasicSettings);
 	SB_CaseProb->setRange(0, 9);
 	SB_CaseProb->setValue(5);
+	glBSLayout->addWidget(SB_CaseProb,4,1,1,1);
+
+
+	l = new QLabel(gbBasicSettings);
+	l->setText(QLabel::tr("Scheme Name:"));
 
 	LE_name = new QLineEdit(this);
-
-	pageLayout->addWidget(SB_DamageModifier, 8, 1);
-	pageLayout->addWidget(SB_TurnTime, 9, 1);
-	pageLayout->addWidget(SB_InitHealth, 10, 1);
-	pageLayout->addWidget(SB_SuddenDeath, 11, 1);
-	pageLayout->addWidget(SB_CaseProb, 12, 1);
-	pageLayout->addWidget(LE_name, 13, 1);
+	
+	gl->addWidget(LE_name,14,1,1,1);
+	gl->addWidget(l,14,0,1,1);
 
 	mapper = new QDataWidgetMapper(this);
 
@@ -944,14 +1018,14 @@
 	selectScheme->setModel(model);
 	
 	mapper->addMapping(LE_name, 0);
-	mapper->addMapping(CB_mode_Forts, 1);
-	mapper->addMapping(CB_teamsDivide, 2);
-	mapper->addMapping(CB_solid, 3);
-	mapper->addMapping(CB_border, 4);
-	mapper->addMapping(CB_lowGravity, 5);
-	mapper->addMapping(CB_laserSight, 6);
-	mapper->addMapping(CB_invulnerable, 7);
-	mapper->addMapping(CB_mines, 8);
+	mapper->addMapping(TBW_mode_Forts->button(), 1);
+	mapper->addMapping(TBW_teamsDivide->button(), 2);
+	mapper->addMapping(TBW_solid->button(), 3);
+	mapper->addMapping(TBW_border->button(), 4);
+	mapper->addMapping(TBW_lowGravity->button(), 5);
+	mapper->addMapping(TBW_laserSight->button(), 6);
+	mapper->addMapping(TBW_invulnerable->button(), 7);
+	mapper->addMapping(TBW_mines->button(), 8);
 	mapper->addMapping(SB_DamageModifier, 9);
 	mapper->addMapping(SB_TurnTime, 10);
 	mapper->addMapping(SB_InitHealth, 11);
--- a/QTfrontend/pages.h	Thu Apr 02 18:50:08 2009 +0000
+++ b/QTfrontend/pages.h	Thu Apr 02 20:37:03 2009 +0000
@@ -27,6 +27,7 @@
 
 #include "binds.h"
 #include "mapContainer.h"
+#include "togglebutton.h"
 
 class QPushButton;
 class QGroupBox;
@@ -416,14 +417,14 @@
 
 private:
 	QDataWidgetMapper * mapper;
-	QCheckBox * CB_mode_Forts;
-	QCheckBox * CB_teamsDivide;
-	QCheckBox * CB_solid;
-	QCheckBox * CB_border;
-	QCheckBox * CB_lowGravity;
-	QCheckBox * CB_laserSight;
-	QCheckBox * CB_invulnerable;
-	QCheckBox * CB_mines;
+	ToggleButtonWidget * TBW_mode_Forts;
+	ToggleButtonWidget * TBW_teamsDivide;
+	ToggleButtonWidget * TBW_solid;
+	ToggleButtonWidget * TBW_border;
+	ToggleButtonWidget * TBW_lowGravity;
+	ToggleButtonWidget * TBW_laserSight;
+	ToggleButtonWidget * TBW_invulnerable;
+	ToggleButtonWidget * TBW_mines;
 
 	QSpinBox * SB_DamageModifier;
 	QSpinBox * SB_TurnTime;
Binary file QTfrontend/res/PlaySound.png has changed
Binary file QTfrontend/res/ammopic.png has changed
Binary file QTfrontend/res/btnBorder.png has changed
Binary file QTfrontend/res/btnDisabled.png has changed
Binary file QTfrontend/res/btnForts.png has changed
Binary file QTfrontend/res/btnInvurnable.png has changed
Binary file QTfrontend/res/btnLaserSight.png has changed
Binary file QTfrontend/res/btnLowGravity.png has changed
Binary file QTfrontend/res/btnMines.png has changed
Binary file QTfrontend/res/btnOverlay.png has changed
Binary file QTfrontend/res/btnSolid.png has changed
Binary file QTfrontend/res/btnTeamsDivide.png has changed
Binary file QTfrontend/res/dice.png has changed
Binary file QTfrontend/res/hh25x25.png has changed
Binary file QTfrontend/res/hh_small.png has changed
Binary file QTfrontend/res/iconBox.png has changed
Binary file QTfrontend/res/iconDamage.png has changed
Binary file QTfrontend/res/iconHealth.png has changed
Binary file QTfrontend/res/iconSuddenDeath.png has changed
Binary file QTfrontend/res/iconTime.png has changed
Binary file QTfrontend/res/icons.png has changed
Binary file QTfrontend/res/infinity.png has changed
Binary file QTfrontend/res/lightbulb_off.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/togglebutton.cpp	Thu Apr 02 20:37:03 2009 +0000
@@ -0,0 +1,76 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2009 Kristian Lehmann <email@thexception.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "togglebutton.h"
+
+ToggleButtonWidget::ToggleButtonWidget(QWidget * parent, QString img)
+{
+	QVBoxLayout * l = new QVBoxLayout(this);
+	setLayout(l);
+
+	pbMain = new QPushButton(this);
+	pbMain->setCheckable(true);
+	
+	QPixmap pm(":/res/btnDisabled.png");
+	QPainter * painter = new QPainter();
+
+	pmChecked.load(img);
+	pmDisabled.load(img);
+
+	l->addWidget(pbMain);
+
+	painter->begin(&pmDisabled);
+	painter->drawPixmap(pmDisabled.rect(), pm);
+	painter->end();
+
+	pbMain->setIconSize(pmDisabled.size());
+	pbMain->setIcon(pmDisabled);
+
+	connect(pbMain, SIGNAL(toggled(bool)), this, SLOT(eventToggled(bool)));
+
+	lbMain = new QLabel(this);
+	lbMain->setFixedHeight(32);
+
+	l->addWidget(lbMain);
+}
+
+ToggleButtonWidget::~ToggleButtonWidget()
+{
+	delete pbMain;
+	delete lbMain;
+}
+
+bool ToggleButtonWidget::isChecked()
+{
+	return pbMain->isChecked();
+}
+
+void ToggleButtonWidget::setChecked(bool checked)
+{
+	pbMain->setChecked(checked);
+}
+
+void ToggleButtonWidget::setText(QString s)
+{
+	lbMain->setText(s);
+}
+
+void ToggleButtonWidget::eventToggled(bool checked)
+{
+	if (checked) pbMain->setIcon(pmChecked); else pbMain->setIcon(pmDisabled);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/togglebutton.h	Thu Apr 02 20:37:03 2009 +0000
@@ -0,0 +1,50 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2009 Kristian Lehmann <email@thexception.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef TOGGLEBUTTONWIDGET_H
+#define TOGGLEBUTTONWIDGET_H
+
+#include <QWidget>
+#include <QPainter>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QLabel>
+
+class ToggleButtonWidget : public QWidget
+{
+	Q_OBJECT
+public:
+	ToggleButtonWidget(QWidget * parent, QString img);
+	~ToggleButtonWidget();
+	bool isChecked();
+	void setChecked(bool checked);
+	void setText(QString s);
+	QPushButton * button()
+	{
+		return pbMain;
+	}
+private:
+	QLabel * lbMain;
+	QPushButton * pbMain;
+	QPixmap pmChecked;
+	QPixmap pmDisabled;
+private slots:
+	void eventToggled(bool checked);
+};
+
+#endif // TOGGLEBUTTONWIDGET_H