--- a/QTfrontend/ammoSchemeModel.cpp Mon Mar 16 20:55:10 2009 +0000
+++ b/QTfrontend/ammoSchemeModel.cpp Wed Mar 18 15:48:43 2009 +0000
@@ -22,11 +22,33 @@
#include "ammoSchemeModel.h"
#include "hwconsts.h"
+QList<QVariant> defaultScheme = QList<QVariant>()
+ << QVariant("Default") // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(true) // add mines 8
+ << QVariant(100) // damage modfier 9
+ << QVariant(45) // turn time 10
+ << QVariant(100) // init health 11
+ << QVariant(15) // sudden death 12
+ << QVariant(5) // case prob 13
+ ;
+
AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
QAbstractTableModel(parent),
fileConfig(fileName, QSettings::IniFormat)
{
- spNames
+ QStringList predefSchemesNames;
+ predefSchemesNames
+ << "Default"
+ << "Pro mode";
+
+QStringList spNames = QStringList()
<< "name" // 0
<< "fortsmode" // 1
<< "divteams" // 2
@@ -43,32 +65,9 @@
<< "caseprobability" // 13
;
-
- QStringList predefSchemesNames;
- predefSchemesNames
- << tr("Default")
- << tr("Pro mode");
-
- defaultScheme
- << QVariant(tr("Default")) // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(true) // add mines 8
- << QVariant(100) // damage modfier 9
- << QVariant(45) // turn time 10
- << QVariant(100) // init health 11
- << QVariant(15) // sudden death 12
- << QVariant(5) // case prob 13
- ;
-
QList<QVariant> proMode;
proMode
- << QVariant(tr("Pro mode"))// name 0
+ << QVariant("Pro mode") // name 0
<< QVariant(false) // fortsmode 1
<< QVariant(false) // team divide 2
<< QVariant(false) // solid land 3
@@ -195,3 +194,57 @@
}
fileConfig.endArray();
}
+
+
+NetAmmoSchemeModel::NetAmmoSchemeModel(QObject * parent) :
+ QAbstractTableModel(parent)
+{
+ netScheme = defaultScheme;
+}
+
+QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ return QVariant();
+}
+
+int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return 1;
+}
+
+int NetAmmoSchemeModel::columnCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return defaultScheme.size();
+}
+
+QVariant NetAmmoSchemeModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || index.row() < 0
+ || index.row() > 1
+ || index.column() >= defaultScheme.size()
+ || (role != Qt::EditRole && role != Qt::DisplayRole)
+ )
+ return QVariant();
+
+ return netScheme[index.column()];
+}
+
+void NetAmmoSchemeModel::setNetSchemeConfig(QStringList & cfg)
+{
+ if(cfg.size() != netScheme.size())
+ {
+ qWarning("Incorrect scheme cfg size");
+ return;
+ }
+
+ for(int i = 0; i < cfg.size(); ++i)
+ netScheme[i] = QVariant(cfg[i]);
+
+ reset();
+}
--- a/QTfrontend/ammoSchemeModel.h Mon Mar 16 20:55:10 2009 +0000
+++ b/QTfrontend/ammoSchemeModel.h Wed Mar 18 15:48:43 2009 +0000
@@ -50,11 +50,28 @@
QList< QList<QVariant> > schemes;
private:
- QList<QVariant> defaultScheme;
-
QSettings fileConfig;
QStringList spNames;
};
+class NetAmmoSchemeModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ NetAmmoSchemeModel(QObject * parent);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex & parent) const;
+ int columnCount(const QModelIndex & parent) const;
+ QVariant data(const QModelIndex &index, int role) const;
+
+public slots:
+ void setNetSchemeConfig(QStringList & cfg);
+
+private:
+ QList<QVariant> netScheme;
+};
+
#endif // _AMMO_SCHEME_MODEL_INCLUDED
--- a/QTfrontend/hwform.cpp Mon Mar 16 20:55:10 2009 +0000
+++ b/QTfrontend/hwform.cpp Wed Mar 18 15:48:43 2009 +0000
@@ -832,9 +832,25 @@
void HWForm::NetGameSlave()
{
+ if (hwnet)
+ {
+ NetAmmoSchemeModel * netAmmo = new NetAmmoSchemeModel(hwnet);
+ connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), netAmmo, SLOT(setNetSchemeConfig(QStringList &)));
+ ui.pageNetGame->pGameCFG->GameSchemes->setModel(netAmmo);
+
+ ui.pageNetGame->pGameCFG->GameSchemes->view()->disconnect(hwnet);
+ connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)),
+ this, SLOT(selectFirstNetScheme()));
+ }
+
ui.pageNetGame->setMasterMode(false);
}
+void HWForm::selectFirstNetScheme()
+{
+ ui.pageNetGame->pGameCFG->GameSchemes->setCurrentIndex(0);
+}
+
void HWForm::NetLeftRoom()
{
if (ui.Pages->currentIndex() == ID_PAGE_NETGAME)
--- a/QTfrontend/hwform.h Mon Mar 16 20:55:10 2009 +0000
+++ b/QTfrontend/hwform.h Wed Mar 18 15:48:43 2009 +0000
@@ -93,6 +93,7 @@
void NetGameSlave();
void AsyncNetServerStart();
void NetLeftRoom();
+ void selectFirstNetScheme();
private:
void _NetConnect(const QString & hostName, quint16 port, const QString & nick);
--- a/QTfrontend/newnetclient.cpp Mon Mar 16 20:55:10 2009 +0000
+++ b/QTfrontend/newnetclient.cpp Wed Mar 18 15:48:43 2009 +0000
@@ -473,7 +473,10 @@
QStringList tmp = lst;
tmp.removeFirst();
tmp.removeFirst();
- emit paramChanged(lst[1], tmp);
+ if (lst[1] == "SCHEME")
+ emit netSchemeConfig(tmp);
+ else
+ emit paramChanged(lst[1], tmp);
return;
}
--- a/QTfrontend/newnetclient.h Mon Mar 16 20:55:10 2009 +0000
+++ b/QTfrontend/newnetclient.h Wed Mar 18 15:48:43 2009 +0000
@@ -101,6 +101,7 @@
void adminAccess(bool);
void roomMaster(bool);
+ void netSchemeConfig(QStringList &);
void paramChanged(const QString & param, const QStringList & value);
void configAsked();