Custom spinbox for bonus boxes factor
authorunc0rr
Sat, 31 Jan 2009 15:44:07 +0000
changeset 1783 169ebeefd7ab
parent 1782 e7589e37a6d6
child 1784 dfe9bafb4590
Custom spinbox for bonus boxes factor
QTfrontend/gamecfgwidget.cpp
QTfrontend/gamecfgwidget.h
--- a/QTfrontend/gamecfgwidget.cpp	Sat Jan 31 15:39:53 2009 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Sat Jan 31 15:44:07 2009 +0000
@@ -80,7 +80,7 @@
 	SB_SuddenDeath->setValue(15);
 	SB_SuddenDeath->setSingleStep(3);
 	
-	SB_CaseProb = new QSpinBox(GBoxOptions);
+	SB_CaseProb = new FreqSpinBox(GBoxOptions);
 	SB_CaseProb->setRange(0, 9);
 	SB_CaseProb->setValue(5);
 
--- a/QTfrontend/gamecfgwidget.h	Sat Jan 31 15:39:53 2009 +0000
+++ b/QTfrontend/gamecfgwidget.h	Sat Jan 31 15:44:07 2009 +0000
@@ -22,13 +22,35 @@
 #include <QWidget>
 #include <QStringList>
 #include <QGroupBox>
+#include <QSpinBox>
 
 #include "mapContainer.h"
 
 class QCheckBox;
 class QVBoxLayout;
-class QSpinBox;
 class QLabel;
+class FreqSpinBox;
+
+class FreqSpinBox : public QSpinBox
+{
+	Q_OBJECT
+
+public:
+	FreqSpinBox(QWidget* parent) : QSpinBox(parent)
+	{
+
+	}
+
+	QString textFromValue ( int value ) const
+	{
+		switch (value)
+		{
+			case 0 : return tr("Never");
+			case 1 : return tr("Every turn");
+			default : return tr("Each %1 turn").arg(value);
+		}
+	}
+};
 
 class GameCFGWidget : public QGroupBox
 {
@@ -86,7 +108,7 @@
 	QSpinBox * SB_TurnTime;
 	QSpinBox * SB_InitHealth;
 	QSpinBox * SB_SuddenDeath;
-	QSpinBox * SB_CaseProb;
+	FreqSpinBox * SB_CaseProb;
 	QLabel * L_TurnTime;
 	QLabel * L_InitHealth;
 	QLabel * L_SuddenDeath;