# HG changeset patch # User unc0rr # Date 1236866072 0 # Node ID 75489216b5b03a57578995cfb5d77796b0787e26 # Parent 40e59e9f82ce80ed6276f4e60e5ac11d70305e9c Continue work on new schemes diff -r 40e59e9f82ce -r 75489216b5b0 QTfrontend/ammoSchemeModel.cpp --- a/QTfrontend/ammoSchemeModel.cpp Wed Mar 11 14:32:28 2009 +0000 +++ b/QTfrontend/ammoSchemeModel.cpp Thu Mar 12 13:54:32 2009 +0000 @@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include #include #include "ammoSchemeModel.h" @@ -23,12 +24,15 @@ QAbstractTableModel(parent) { defaultScheme - << "Default" - << "45" - << "0" - << "0" - << "0" - << "0" + << "Default" // name + << "0" // fortsmode + << "0" // team divide + << "0" // solid land + << "0" // border + << "45" // turn time + << "100" // init health + << "15" // sudden death + << "5" // case probability ; schemes.append(defaultScheme); @@ -68,10 +72,11 @@ if (!index.isValid() || index.row() < 0 || index.row() >= schemes.size() || index.column() >= defaultScheme.size() - || role != Qt::DisplayRole) + || role != Qt::EditRole) return false; schemes[index.row()][index.column()] = value.toString(); + emit dataChanged(index, index); return true; } diff -r 40e59e9f82ce -r 75489216b5b0 QTfrontend/gamecfgwidget.cpp --- a/QTfrontend/gamecfgwidget.cpp Wed Mar 11 14:32:28 2009 +0000 +++ b/QTfrontend/gamecfgwidget.cpp Thu Mar 12 13:54:32 2009 +0000 @@ -24,6 +24,7 @@ #include #include #include +#include #include "gamecfgwidget.h" #include "igbox.h" @@ -48,68 +49,17 @@ QTableView * tv = new QTableView(this); tv->setModel(new AmmoSchemeModel); GBoxOptionsLayout->addWidget(tv, 0, 0, 1, 2); + + QPushButton * goToSchemePage = new QPushButton(GBoxOptions); + goToSchemePage->setText(tr("Edit schemes")); + GBoxOptionsLayout->addWidget(goToSchemePage, 1, 0, 1, 2); + connect(goToSchemePage, SIGNAL(clicked()), this, SIGNAL(goToSchemes())); - CB_mode_Forts = new QCheckBox(GBoxOptions); - CB_mode_Forts->setText(QCheckBox::tr("Forts mode")); - GBoxOptionsLayout->addWidget(CB_mode_Forts, 9, 0, 1, 2); - - CB_teamsDivide = new QCheckBox(GBoxOptions); - CB_teamsDivide->setText(QCheckBox::tr("Divide teams")); - GBoxOptionsLayout->addWidget(CB_teamsDivide, 1, 0, 1, 2); - - CB_solid = new QCheckBox(GBoxOptions); - CB_solid->setText(QCheckBox::tr("Solid land")); - GBoxOptionsLayout->addWidget(CB_solid, 2, 0, 1, 2); - - CB_border = new QCheckBox(GBoxOptions); - CB_border->setText(QCheckBox::tr("Add Border")); - GBoxOptionsLayout->addWidget(CB_border, 3, 0, 1, 2); - - L_TurnTime = new QLabel(QLabel::tr("Turn time"), GBoxOptions); - L_InitHealth = new QLabel(QLabel::tr("Initial health"), GBoxOptions); - L_SuddenDeath = new QLabel(QLabel::tr("Turns before SD"), GBoxOptions); - L_CaseProb = new QLabel(QLabel::tr("Crate drops"), GBoxOptions); - GBoxOptionsLayout->addWidget(L_TurnTime, 4, 0); - GBoxOptionsLayout->addWidget(L_InitHealth, 5, 0); - GBoxOptionsLayout->addWidget(L_SuddenDeath, 6, 0); - GBoxOptionsLayout->addWidget(L_CaseProb, 7, 0); GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Weapons"), GBoxOptions), 8, 0); - SB_TurnTime = new QSpinBox(GBoxOptions); - SB_TurnTime->setRange(1, 99); - SB_TurnTime->setValue(45); - SB_TurnTime->setSingleStep(15); - - SB_InitHealth = new QSpinBox(GBoxOptions); - SB_InitHealth->setRange(50, 200); - SB_InitHealth->setValue(100); - SB_InitHealth->setSingleStep(25); - - SB_SuddenDeath = new QSpinBox(GBoxOptions); - SB_SuddenDeath->setRange(0, 50); - SB_SuddenDeath->setValue(15); - SB_SuddenDeath->setSingleStep(3); - - SB_CaseProb = new FreqSpinBox(GBoxOptions); - SB_CaseProb->setRange(0, 9); - SB_CaseProb->setValue(5); - - GBoxOptionsLayout->addWidget(SB_TurnTime, 4, 1); - GBoxOptionsLayout->addWidget(SB_InitHealth, 5, 1); - GBoxOptionsLayout->addWidget(SB_SuddenDeath, 6, 1); - GBoxOptionsLayout->addWidget(SB_CaseProb, 7, 1); - WeaponsName = new QComboBox(GBoxOptions); GBoxOptionsLayout->addWidget(WeaponsName, 8, 1); - connect(SB_InitHealth, SIGNAL(valueChanged(int)), this, SLOT(initHealthChanged(int))); - connect(SB_TurnTime, SIGNAL(valueChanged(int)), this, SLOT(turnTimeChanged(int))); - connect(SB_SuddenDeath, SIGNAL(valueChanged(int)), this, SLOT(suddenDeathTurnsChanged(int))); - connect(SB_CaseProb, SIGNAL(valueChanged(int)), this, SLOT(caseProbabilityChanged(int))); - connect(CB_mode_Forts, SIGNAL(toggled(bool)), this, SLOT(fortsModeChanged(bool))); - connect(CB_teamsDivide, SIGNAL(toggled(bool)), this, SLOT(teamsDivideChanged(bool))); - connect(CB_solid, SIGNAL(toggled(bool)), this, SLOT(solidChanged(bool))); - connect(CB_border, SIGNAL(toggled(bool)), this, SLOT(borderChanged(bool))); connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int))); connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &))); @@ -122,21 +72,21 @@ { quint32 result = 0; - if (CB_mode_Forts->isChecked()) +/* if (CB_mode_Forts->isChecked()) result |= 0x01; if (CB_teamsDivide->isChecked()) result |= 0x10; if (CB_solid->isChecked()) result |= 0x04; if (CB_border->isChecked()) - result |= 0x08; + result |= 0x08;*/ return result; } quint32 GameCFGWidget::getInitHealth() const { - return SB_InitHealth->value(); +// return SB_InitHealth->value(); } QStringList GameCFGWidget::getFullConfig() const @@ -144,9 +94,9 @@ QStringList sl; sl.append("eseed " + pMapContainer->getCurrentSeed()); sl.append(QString("e$gmflags %1").arg(getGameFlags())); - sl.append(QString("e$turntime %1").arg(SB_TurnTime->value() * 1000)); - sl.append(QString("e$sd_turns %1").arg(SB_SuddenDeath->value())); - sl.append(QString("e$casefreq %1").arg(SB_CaseProb->value())); +// sl.append(QString("e$turntime %1").arg(SB_TurnTime->value() * 1000)); +// sl.append(QString("e$sd_turns %1").arg(SB_SuddenDeath->value())); +// sl.append(QString("e$casefreq %1").arg(SB_CaseProb->value())); sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter())); QString currentMap = pMapContainer->getCurrentMap(); @@ -175,17 +125,9 @@ { ammoChanged(WeaponsName->currentIndex()); - borderChanged(CB_border->isChecked()); - caseProbabilityChanged(SB_CaseProb->value()); - fortsModeChanged(CB_mode_Forts->isChecked()); - initHealthChanged(SB_InitHealth->value()); seedChanged(pMapContainer->getCurrentSeed()); - solidChanged(CB_solid->isChecked()); - suddenDeathTurnsChanged(SB_SuddenDeath->value()); - teamsDivideChanged(CB_teamsDivide->isChecked()); templateFilterChanged(pMapContainer->getTemplateFilter()); themeChanged(pMapContainer->getCurrentTheme()); - turnTimeChanged(SB_TurnTime->value()); // map must be the last QString map = pMapContainer->getCurrentMap(); @@ -211,35 +153,35 @@ return; } if (param == "HEALTH") { - SB_InitHealth->setValue(value.toUInt()); +// SB_InitHealth->setValue(value.toUInt()); return; } if (param == "TURNTIME") { - SB_TurnTime->setValue(value.toUInt()); +// SB_TurnTime->setValue(value.toUInt()); return; } if (param == "SD_TURNS") { - SB_SuddenDeath->setValue(value.toUInt()); +// SB_SuddenDeath->setValue(value.toUInt()); return; } if (param == "CASEFACTOR") { - SB_CaseProb->setValue(value.toUInt()); +// SB_CaseProb->setValue(value.toUInt()); return; } if (param == "FORTSMODE") { - CB_mode_Forts->setChecked(value.toUInt() != 0); +// CB_mode_Forts->setChecked(value.toUInt() != 0); return; } if (param == "DIVIDETEAMS") { - CB_teamsDivide->setChecked(value.toUInt() != 0); +// CB_teamsDivide->setChecked(value.toUInt() != 0); return; } if (param == "SOLIDLAND") { - CB_solid->setChecked(value.toUInt() != 0); +// CB_solid->setChecked(value.toUInt() != 0); return; } if (param == "BORDER") { - CB_border->setChecked(value.toUInt() != 0); +// CB_border->setChecked(value.toUInt() != 0); return; } if (param == "TEMPLATE") { @@ -266,26 +208,6 @@ ); } -void GameCFGWidget::borderChanged(bool value) -{ - emit paramChanged("BORDER", QStringList(value ? "1" : "0")); -} - -void GameCFGWidget::caseProbabilityChanged(int value) -{ - emit paramChanged("CASEFACTOR", QStringList(QString::number(value))); -} - -void GameCFGWidget::fortsModeChanged(bool value) -{ - emit paramChanged("FORTSMODE", QStringList(value ? "1" : "0")); -} - -void GameCFGWidget::initHealthChanged(int value) -{ - emit paramChanged("HEALTH", QStringList(QString::number(value))); -} - void GameCFGWidget::mapChanged(const QString & value) { emit paramChanged("MAP", QStringList(value)); @@ -301,27 +223,7 @@ emit paramChanged("SEED", QStringList(value)); } -void GameCFGWidget::solidChanged(bool value) -{ - emit paramChanged("SOLIDLAND", QStringList(value ? "1" : "0")); -} - -void GameCFGWidget::suddenDeathTurnsChanged(int value) -{ - emit paramChanged("SD_TURNS", QStringList(QString::number(value))); -} - -void GameCFGWidget::teamsDivideChanged(bool value) -{ - emit paramChanged("DIVIDETEAMS", QStringList(value ? "1" : "0")); -} - void GameCFGWidget::themeChanged(const QString & value) { emit paramChanged("THEME", QStringList(value)); } - -void GameCFGWidget::turnTimeChanged(int value) -{ - emit paramChanged("TURNTIME", QStringList(QString::number(value))); -} diff -r 40e59e9f82ce -r 75489216b5b0 QTfrontend/gamecfgwidget.h --- a/QTfrontend/gamecfgwidget.h Wed Mar 11 14:32:28 2009 +0000 +++ b/QTfrontend/gamecfgwidget.h Thu Mar 12 13:54:32 2009 +0000 @@ -29,28 +29,6 @@ class QCheckBox; class QVBoxLayout; 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 { @@ -70,36 +48,17 @@ signals: void paramChanged(const QString & param, const QStringList & value); + void goToSchemes(); private slots: void ammoChanged(int index); - void borderChanged(bool); - void caseProbabilityChanged(int); - void fortsModeChanged(bool); - void initHealthChanged(int); void mapChanged(const QString &); void templateFilterChanged(int); void seedChanged(const QString &); - void solidChanged(bool); - void suddenDeathTurnsChanged(int); - void teamsDivideChanged(bool); void themeChanged(const QString &); - void turnTimeChanged(int); private: - QCheckBox * CB_mode_Forts; - QCheckBox * CB_teamsDivide; - QCheckBox * CB_solid; - QCheckBox * CB_border; QGridLayout mainLayout; - QSpinBox * SB_TurnTime; - QSpinBox * SB_InitHealth; - QSpinBox * SB_SuddenDeath; - FreqSpinBox * SB_CaseProb; - QLabel * L_TurnTime; - QLabel * L_InitHealth; - QLabel * L_SuddenDeath; - QLabel * L_CaseProb; QString curNetAmmoName; QString curNetAmmo; diff -r 40e59e9f82ce -r 75489216b5b0 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Wed Mar 11 14:32:28 2009 +0000 +++ b/QTfrontend/hwform.cpp Thu Mar 12 13:54:32 2009 +0000 @@ -32,6 +32,7 @@ #include #include #include +#include #include "hwform.h" #include "game.h" @@ -49,6 +50,7 @@ #include "chatwidget.h" #include "playrecordpage.h" #include "input_ip.h" +#include "ammoSchemeModel.h" HWForm::HWForm(QWidget *parent) : QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0) @@ -67,24 +69,25 @@ connect(config, SIGNAL(frontendFullscreen(bool)), this, SLOT(onFrontendFullscreen(bool))); onFrontendFullscreen(config->isFrontendFullscreen()); - connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); - connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); - connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNet())); - connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), this, SLOT(GoToInfo())); + connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); + connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); + connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNet())); + connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), this, SLOT(GoToInfo())); connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); - connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); - connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); + connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); + connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); connect(ui.pageEditTeam->signalMapper, SIGNAL(mapped(const int &)), this, SLOT(RandomName(const int &))); connect(ui.pageEditTeam->randTeamButton, SIGNAL(clicked()), this, SLOT(RandomNames())); - connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); + connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool))); connect(ui.pageMultiplayer->teamsSelect, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); + connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToSchemes()), this, SLOT(GoToSchemes())); connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo())); @@ -113,6 +116,7 @@ connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), ui.pageNetGame->BtnGo, SLOT(setEnabled(bool))); connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); + connect(ui.pageNetGame->pGameCFG, SIGNAL(goToSchemes()), this, SLOT(GoToSchemes())); connect(ui.pageRoomsList->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); @@ -141,6 +145,10 @@ connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), this, SLOT(GoBack())); // executed third + + AmmoSchemeModel * ammoSchemeModel = new AmmoSchemeModel(this); + ui.pageScheme->mapper->setModel(ammoSchemeModel); + PagesStack.push(ID_PAGE_MAIN); GoBack(); } @@ -276,6 +284,11 @@ GoToPage(ID_PAGE_NETSERVER); } +void HWForm::GoToSchemes() +{ + GoToPage(ID_PAGE_SCHEME); +} + void HWForm::OnPageShown(quint8 id, quint8 lastid) { if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) { diff -r 40e59e9f82ce -r 75489216b5b0 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Wed Mar 11 14:32:28 2009 +0000 +++ b/QTfrontend/hwform.h Thu Mar 12 13:54:32 2009 +0000 @@ -56,6 +56,7 @@ void GoToSelectWeapon(); void GoToSelectNewWeapon(); void GoToNetServer(); + void GoToSchemes(); void GoToPage(quint8 id); void GoBack(); void btnExitPressed(); diff -r 40e59e9f82ce -r 75489216b5b0 QTfrontend/misc.h --- a/QTfrontend/misc.h Wed Mar 11 14:32:28 2009 +0000 +++ b/QTfrontend/misc.h Thu Mar 12 13:54:32 2009 +0000 @@ -22,6 +22,7 @@ #include #include #include +#include class Hash : public QObject { @@ -32,4 +33,26 @@ static QString md5(QByteArray buf); }; +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); + } + } +}; + + #endif // _MISC_H diff -r 40e59e9f82ce -r 75489216b5b0 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Wed Mar 11 14:32:28 2009 +0000 +++ b/QTfrontend/pages.cpp Thu Mar 12 13:54:32 2009 +0000 @@ -38,6 +38,8 @@ #include #include #include +#include + #include "pages.h" #include "sdlkeys.h" @@ -56,6 +58,7 @@ #include "selectWeapon.h" #include "igbox.h" #include "hats.h" +#include "misc.h" PageMain::PageMain(QWidget* parent) : AbstractPage(parent) @@ -848,4 +851,58 @@ 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); + + CB_teamsDivide = new QCheckBox(this); + CB_teamsDivide->setText(QCheckBox::tr("Divide teams")); + pageLayout->addWidget(CB_teamsDivide, 1, 0, 1, 2); + + CB_solid = new QCheckBox(this); + CB_solid->setText(QCheckBox::tr("Solid land")); + pageLayout->addWidget(CB_solid, 2, 0, 1, 2); + + CB_border = new QCheckBox(this); + CB_border->setText(QCheckBox::tr("Add Border")); + pageLayout->addWidget(CB_border, 3, 0, 1, 2); + + SB_TurnTime = new QSpinBox(this); + SB_TurnTime->setRange(1, 99); + SB_TurnTime->setValue(45); + SB_TurnTime->setSingleStep(15); + + SB_InitHealth = new QSpinBox(this); + SB_InitHealth->setRange(50, 200); + SB_InitHealth->setValue(100); + SB_InitHealth->setSingleStep(25); + + SB_SuddenDeath = new QSpinBox(this); + SB_SuddenDeath->setRange(0, 50); + SB_SuddenDeath->setValue(15); + SB_SuddenDeath->setSingleStep(3); + + SB_CaseProb = new FreqSpinBox(this); + SB_CaseProb->setRange(0, 9); + SB_CaseProb->setValue(5); + + LE_name = new QLineEdit(this); + + pageLayout->addWidget(SB_TurnTime, 4, 1); + pageLayout->addWidget(SB_InitHealth, 5, 1); + pageLayout->addWidget(SB_SuddenDeath, 6, 1); + pageLayout->addWidget(SB_CaseProb, 7, 1); + pageLayout->addWidget(LE_name, 8, 1); + + mapper = new QDataWidgetMapper(this); + 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(SB_TurnTime, 5); + mapper->addMapping(SB_InitHealth, 6); + mapper->addMapping(SB_SuddenDeath, 7); + mapper->addMapping(SB_CaseProb, 8); } diff -r 40e59e9f82ce -r 75489216b5b0 QTfrontend/pages.h --- a/QTfrontend/pages.h Wed Mar 11 14:32:28 2009 +0000 +++ b/QTfrontend/pages.h Thu Mar 12 13:54:32 2009 +0000 @@ -43,6 +43,7 @@ class QTextBrowser; class QTableWidget; class QAction; +class QDataWidgetMapper; class GameCFGWidget; class TeamSelWidget; @@ -53,9 +54,12 @@ class HWChatWidget; class SelWeaponWidget; class IconedGroupBox; +class FreqSpinBox; class AbstractPage : public QWidget { + Q_OBJECT + public: protected: @@ -401,6 +405,19 @@ public: PageScheme(QWidget* parent = 0); + + QDataWidgetMapper * mapper; + +private: + QCheckBox * CB_mode_Forts; + QCheckBox * CB_teamsDivide; + QCheckBox * CB_solid; + QCheckBox * CB_border; + QSpinBox * SB_TurnTime; + QSpinBox * SB_InitHealth; + QSpinBox * SB_SuddenDeath; + FreqSpinBox * SB_CaseProb; + QLineEdit * LE_name; }; #endif // PAGES_H