QTfrontend/gamecfgwidget.cpp
changeset 1802 dd148e2506e2
parent 1797 fedd8649fdd9
child 1873 815a3ff1fe4b
equal deleted inserted replaced
1801:bc0c5c21376e 1802:dd148e2506e2
    66 	GBoxOptionsLayout->addWidget(L_TurnTime, 4, 0);
    66 	GBoxOptionsLayout->addWidget(L_TurnTime, 4, 0);
    67 	GBoxOptionsLayout->addWidget(L_InitHealth, 5, 0);
    67 	GBoxOptionsLayout->addWidget(L_InitHealth, 5, 0);
    68 	GBoxOptionsLayout->addWidget(L_SuddenDeath, 6, 0);
    68 	GBoxOptionsLayout->addWidget(L_SuddenDeath, 6, 0);
    69 	GBoxOptionsLayout->addWidget(L_CaseProb, 7, 0);
    69 	GBoxOptionsLayout->addWidget(L_CaseProb, 7, 0);
    70 	GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Weapons"), GBoxOptions), 8, 0);
    70 	GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Weapons"), GBoxOptions), 8, 0);
    71 	GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Generated Map Filter"), GBoxOptions), 9, 0);
       
    72 
    71 
    73 	SB_TurnTime = new QSpinBox(GBoxOptions);
    72 	SB_TurnTime = new QSpinBox(GBoxOptions);
    74 	SB_TurnTime->setRange(1, 99);
    73 	SB_TurnTime->setRange(1, 99);
    75 	SB_TurnTime->setValue(45);
    74 	SB_TurnTime->setValue(45);
    76 	SB_TurnTime->setSingleStep(15);
    75 	SB_TurnTime->setSingleStep(15);
    94 	GBoxOptionsLayout->addWidget(SB_SuddenDeath, 6, 1);
    93 	GBoxOptionsLayout->addWidget(SB_SuddenDeath, 6, 1);
    95 	GBoxOptionsLayout->addWidget(SB_CaseProb, 7, 1);
    94 	GBoxOptionsLayout->addWidget(SB_CaseProb, 7, 1);
    96 	
    95 	
    97 	WeaponsName = new QComboBox(GBoxOptions);
    96 	WeaponsName = new QComboBox(GBoxOptions);
    98 	GBoxOptionsLayout->addWidget(WeaponsName, 8, 1);
    97 	GBoxOptionsLayout->addWidget(WeaponsName, 8, 1);
    99 
       
   100 	CB_TemplateFilter = new QComboBox(GBoxOptions);
       
   101     CB_TemplateFilter->addItem(tr("All"), 0);
       
   102     CB_TemplateFilter->addItem(tr("Small"), 1);
       
   103     CB_TemplateFilter->addItem(tr("Medium"), 2);
       
   104     CB_TemplateFilter->addItem(tr("Large"), 3);
       
   105     CB_TemplateFilter->addItem(tr("Cavern"), 4);
       
   106     CB_TemplateFilter->addItem(tr("Wacky"), 5);
       
   107 	GBoxOptionsLayout->addWidget(CB_TemplateFilter, 9, 1);
       
   108 
    98 
   109 	connect(SB_InitHealth, SIGNAL(valueChanged(int)), this, SIGNAL(initHealthChanged(int)));
    99 	connect(SB_InitHealth, SIGNAL(valueChanged(int)), this, SIGNAL(initHealthChanged(int)));
   110 	connect(SB_TurnTime, SIGNAL(valueChanged(int)), this, SIGNAL(turnTimeChanged(int)));
   100 	connect(SB_TurnTime, SIGNAL(valueChanged(int)), this, SIGNAL(turnTimeChanged(int)));
   111 	connect(SB_SuddenDeath, SIGNAL(valueChanged(int)), this, SIGNAL(suddenDeathTurnsChanged(int)));
   101 	connect(SB_SuddenDeath, SIGNAL(valueChanged(int)), this, SIGNAL(suddenDeathTurnsChanged(int)));
   112 	connect(SB_CaseProb, SIGNAL(valueChanged(int)), this, SIGNAL(caseProbabilityChanged(int)));
   102 	connect(SB_CaseProb, SIGNAL(valueChanged(int)), this, SIGNAL(caseProbabilityChanged(int)));
   113 	connect(CB_mode_Forts, SIGNAL(toggled(bool)), this, SIGNAL(fortsModeChanged(bool)));
   103 	connect(CB_mode_Forts, SIGNAL(toggled(bool)), this, SIGNAL(fortsModeChanged(bool)));
   114 	connect(CB_teamsDivide, SIGNAL(toggled(bool)), this, SIGNAL(teamsDivideChanged(bool)));
   104 	connect(CB_teamsDivide, SIGNAL(toggled(bool)), this, SIGNAL(teamsDivideChanged(bool)));
   115 	connect(CB_solid, SIGNAL(toggled(bool)), this, SIGNAL(solidChanged(bool)));
   105 	connect(CB_solid, SIGNAL(toggled(bool)), this, SIGNAL(solidChanged(bool)));
   116 	connect(CB_border, SIGNAL(toggled(bool)), this, SIGNAL(borderChanged(bool)));
   106 	connect(CB_border, SIGNAL(toggled(bool)), this, SIGNAL(borderChanged(bool)));
   117 	connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int)));
   107 	connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int)));
   118 	connect(CB_TemplateFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(templateFilterChanged(int)));
       
   119 	connect(CB_TemplateFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(templateFilterChanged(int)));
       
   120 
   108 
   121 	connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SIGNAL(seedChanged(const QString &)));
   109 	connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SIGNAL(seedChanged(const QString &)));
   122 	connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SIGNAL(mapChanged(const QString &)));
   110 	connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SIGNAL(mapChanged(const QString &)));
   123 	connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SIGNAL(themeChanged(const QString &)));
   111 	connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SIGNAL(themeChanged(const QString &)));
   124 }
   112 }
   172 quint32 GameCFGWidget::getCaseProbability() const
   160 quint32 GameCFGWidget::getCaseProbability() const
   173 {
   161 {
   174 	return SB_CaseProb->value();
   162 	return SB_CaseProb->value();
   175 }
   163 }
   176 
   164 
   177 quint32 GameCFGWidget::getTemplateFilter() const
       
   178 {
       
   179 	return CB_TemplateFilter->itemData(CB_TemplateFilter->currentIndex()).toInt();
       
   180 }
       
   181 
       
   182 QStringList GameCFGWidget::getFullConfig() const
   165 QStringList GameCFGWidget::getFullConfig() const
   183 {
   166 {
   184 	QStringList sl;
   167 	QStringList sl;
   185 	sl.append("eseed " + getCurrentSeed());
   168 	sl.append("eseed " + getCurrentSeed());
   186 	sl.append(QString("e$gmflags %1").arg(getGameFlags()));
   169 	sl.append(QString("e$gmflags %1").arg(getGameFlags()));
   187 	sl.append(QString("e$turntime %1").arg(getTurnTime() * 1000));
   170 	sl.append(QString("e$turntime %1").arg(getTurnTime() * 1000));
   188 	sl.append(QString("e$sd_turns %1").arg(getSuddenDeathTurns()));
   171 	sl.append(QString("e$sd_turns %1").arg(getSuddenDeathTurns()));
   189 	sl.append(QString("e$casefreq %1").arg(getCaseProbability()));
   172 	sl.append(QString("e$casefreq %1").arg(getCaseProbability()));
   190 	sl.append(QString("e$template_filter %1").arg(getTemplateFilter()));
   173 	sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()));
   191 
   174 
   192 	QString currentMap = getCurrentMap();
   175 	QString currentMap = getCurrentMap();
   193 	if (currentMap.size() > 0)
   176 	if (currentMap.size() > 0)
   194 		sl.append("emap " + currentMap);
   177 		sl.append("emap " + currentMap);
   195 	sl.append("etheme " + getCurrentTheme());
   178 	sl.append("etheme " + getCurrentTheme());
   264 		WeaponsName->setItemData(pos, ammo);
   247 		WeaponsName->setItemData(pos, ammo);
   265 		WeaponsName->setCurrentIndex(pos);
   248 		WeaponsName->setCurrentIndex(pos);
   266 	}
   249 	}
   267 }
   250 }
   268 
   251 
   269 void GameCFGWidget::setTemplateFilter(int filter)
       
   270 {
       
   271 	CB_TemplateFilter->setCurrentIndex(filter);
       
   272 }
       
   273 
       
   274 void GameCFGWidget::templateFilterChanged(int filter)
       
   275 {
       
   276 	pMapContainer->setTemplateFilter(filter);
       
   277 	emit newTemplateFilter(filter);
       
   278 }
       
   279 
       
   280 void GameCFGWidget::ammoChanged(int index)
   252 void GameCFGWidget::ammoChanged(int index)
   281 {
   253 {
   282 	if (index >= 0)
   254 	if (index >= 0)
   283 		emit newWeaponScheme(WeaponsName->itemText(index), WeaponsName->itemData(index).toString());
   255 		emit newWeaponScheme(WeaponsName->itemText(index), WeaponsName->itemData(index).toString());
   284 }
   256 }