--- a/QTfrontend/ui/widget/gamecfgwidget.cpp Wed Jan 02 11:11:49 2013 +0100
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp Sun Jan 27 00:28:57 2013 +0100
@@ -24,7 +24,11 @@
#include <QLabel>
#include <QMessageBox>
#include <QTableView>
+#include <QScrollBar>
+#include <QTabWidget>
#include <QPushButton>
+#include <QDebug>
+#include <QList>
#include "gamecfgwidget.h"
#include "igbox.h"
@@ -33,6 +37,7 @@
#include "ammoSchemeModel.h"
#include "proto.h"
#include "GameStyleModel.h"
+#include "themeprompt.h"
GameCFGWidget::GameCFGWidget(QWidget* parent) :
QGroupBox(parent)
@@ -40,28 +45,75 @@
, seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}")
{
mainLayout.setMargin(0);
-// mainLayout.setSizeConstraint(QLayout::SetMinimumSize);
+ setMinimumHeight(310);
+ setMaximumHeight(447);
+ setMinimumWidth(470);
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+
+ // Easy containers for the map/game options in either stacked or tabbed mode
+
+ mapContainerFree = new QWidget();
+ mapContainerTabbed = new QWidget();
+ optionsContainerFree = new QWidget();
+ optionsContainerTabbed = new QWidget();
+ tabbed = false;
+
+ // Container for when in tabbed mode
- pMapContainer = new HWMapContainer(this);
- mainLayout.addWidget(pMapContainer, 0, 0);
+ tabs = new QTabWidget(this);
+ tabs->setFixedWidth(470);
+ tabs->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
+ tabs->addTab(mapContainerTabbed, tr("Map"));
+ tabs->addTab(optionsContainerTabbed, tr("Game options"));
+ tabs->setObjectName("gameCfgWidgetTabs");
+ mainLayout.addWidget(tabs, 1);
+ tabs->setVisible(false);
+
+ // Container for when in stacked mode
+
+ StackContainer = new QWidget();
+ StackContainer->setObjectName("gameStackContainer");
+ mainLayout.addWidget(StackContainer, 1);
+ QVBoxLayout * stackLayout = new QVBoxLayout(StackContainer);
- IconedGroupBox *GBoxOptions = new IconedGroupBox(this);
- GBoxOptions->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
- mainLayout.addWidget(GBoxOptions, 1, 0);
+ // Map options
+
+ pMapContainer = new HWMapContainer(mapContainerFree);
+ stackLayout->addWidget(mapContainerFree, 0, Qt::AlignHCenter);
+ pMapContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ pMapContainer->setFixedSize(width() - 14, 278);
+ mapContainerFree->setFixedSize(pMapContainer->width(), pMapContainer->height());
+
+ // Horizontal divider
+
+ QFrame * divider = new QFrame();
+ divider->setFrameShape(QFrame::HLine);
+ divider->setFrameShadow(QFrame::Plain);
+ stackLayout->addWidget(divider, 0, Qt::AlignBottom);
+ //stackLayout->setRowMinimumHeight(1, 10);
- QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions);
+ // Game options
+
+ optionsContainerTabbed->setContentsMargins(0, 0, 0, 0);
+ optionsContainerFree->setFixedSize(width() - 14, 140);
+ stackLayout->addWidget(optionsContainerFree, 0, Qt::AlignHCenter);
- GBoxOptions->setTitle(tr("Game Options"));
- GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), GBoxOptions), 1, 0);
+ OptionsInnerContainer = new QWidget(optionsContainerFree);
+ m_childWidgets << OptionsInnerContainer;
+ OptionsInnerContainer->setFixedSize(optionsContainerFree->width(), optionsContainerFree->height());
+ OptionsInnerContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ GBoxOptionsLayout = new QGridLayout(OptionsInnerContainer);
- Scripts = new QComboBox(GBoxOptions);
+ GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), this), 1, 0);
+
+ Scripts = new QComboBox(this);
GBoxOptionsLayout->addWidget(Scripts, 1, 1);
Scripts->setModel(DataManager::instance().gameStyleModel());
m_curScript = Scripts->currentText();
connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int)));
- QWidget *SchemeWidget = new QWidget(GBoxOptions);
+ QWidget *SchemeWidget = new QWidget(this);
GBoxOptionsLayout->addWidget(SchemeWidget, 2, 0, 1, 2);
QGridLayout *SchemeWidgetLayout = new QGridLayout(SchemeWidget);
@@ -76,7 +128,7 @@
QPixmap pmEdit(":/res/edit.png");
QPushButton * goToSchemePage = new QPushButton(SchemeWidget);
- goToSchemePage->setToolTip(tr("Edit schemes"));
+ goToSchemePage->setWhatsThis(tr("Edit schemes"));
goToSchemePage->setIconSize(pmEdit.size());
goToSchemePage->setIcon(pmEdit);
goToSchemePage->setMaximumWidth(pmEdit.width() + 6);
@@ -91,7 +143,7 @@
connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int)));
QPushButton * goToWeaponPage = new QPushButton(SchemeWidget);
- goToWeaponPage->setToolTip(tr("Edit weapons"));
+ goToWeaponPage->setWhatsThis(tr("Edit weapons"));
goToWeaponPage->setIconSize(pmEdit.size());
goToWeaponPage->setIcon(pmEdit);
goToWeaponPage->setMaximumWidth(pmEdit.width() + 6);
@@ -99,7 +151,7 @@
connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons()));
bindEntries = new QCheckBox(SchemeWidget);
- bindEntries->setToolTip(tr("When this option is enabled selecting a game scheme will auto-select a weapon"));
+ bindEntries->setWhatsThis(tr("Game scheme will auto-select a weapon"));
bindEntries->setChecked(true);
bindEntries->setMaximumWidth(42);
bindEntries->setStyleSheet( "QCheckBox::indicator:checked { image: url(\":/res/lock.png\"); }"
@@ -118,6 +170,42 @@
connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(updateModelViews()));
}
+void GameCFGWidget::setTabbed(bool tabbed)
+{
+ if (tabbed && !this->tabbed)
+ { // Make tabbed
+ tabs->setCurrentIndex(0);
+ StackContainer->setVisible(false);
+ tabs->setVisible(true);
+ pMapContainer->setParent(mapContainerTabbed);
+ OptionsInnerContainer->setParent(optionsContainerTabbed);
+ pMapContainer->setVisible(true);
+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
+ this->tabbed = true;
+ }
+ else if (!tabbed && this->tabbed)
+ { // Make stacked
+ pMapContainer->setParent(mapContainerFree);
+ OptionsInnerContainer->setParent(optionsContainerFree);
+ tabs->setVisible(false);
+ StackContainer->setVisible(true);
+ pMapContainer->setVisible(true);
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ this->tabbed = false;
+ }
+
+ // Restore scrollbar palettes, since Qt seems to forget them easily when switching parents
+ QList<QScrollBar *> allSBars = findChildren<QScrollBar *>();
+ QPalette pal = palette();
+ pal.setColor(QPalette::WindowText, QColor(0xff, 0xcc, 0x00));
+ pal.setColor(QPalette::Button, QColor(0x00, 0x35, 0x1d));
+ pal.setColor(QPalette::Base, QColor(0x00, 0x35, 0x1d));
+ pal.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00));
+
+ for (int i = 0; i < allSBars.size(); ++i)
+ allSBars.at(i)->setPalette(pal);
+}
+
void GameCFGWidget::jumpToSchemes()
{
emit goToSchemes(GameSchemes->currentIndex());
@@ -186,7 +274,7 @@
if (schemeData(24).toBool())
result |= 0x02000000; // tag team
if (schemeData(25).toBool())
- result |= 0x04000000; // bottom border
+ result |= 0x04000000; // bottom
return result;
}
@@ -235,6 +323,8 @@
bcfg << QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()).toUtf8();
bcfg << QString("e$mapgen %1").arg(mapgen).toUtf8();
+
+
switch (mapgen)
{
case MAPGEN_MAZE:
@@ -271,7 +361,7 @@
bool illegal = ammo.size() != cDefaultAmmoStore->size();
if (illegal)
{
- QMessageBox illegalMsg(this);
+ QMessageBox illegalMsg(parentWidget());
illegalMsg.setIcon(QMessageBox::Warning);
illegalMsg.setWindowTitle(QMessageBox::tr("Error"));
illegalMsg.setText(QMessageBox::tr("Cannot use the ammo '%1'!").arg(name));
@@ -325,10 +415,6 @@
if (param == "SEED")
{
pMapContainer->setSeed(value);
- if (!seedRegexp.exactMatch(value))
- {
- pMapContainer->seedEdit->setVisible(true);
- }
return;
}
if (param == "THEME")
@@ -377,8 +463,6 @@
if (param == "FULLMAPCONFIG")
{
QString seed = slValue[3];
- if (!seedRegexp.exactMatch(seed))
- pMapContainer->seedEdit->setVisible(true);
pMapContainer->setAllMapParameters(
slValue[0],
@@ -586,3 +670,19 @@
Scripts->setCurrentIndex(0);
}
}
+
+bool GameCFGWidget::isMaster()
+{
+ return m_master;
+}
+
+void GameCFGWidget::setMaster(bool master)
+{
+ if (master == m_master) return;
+ m_master = master;
+
+ pMapContainer->setMaster(master);
+
+ foreach (QWidget *widget, m_childWidgets)
+ widget->setEnabled(master);
+}