# HG changeset patch
# User unc0rr
# Date 1237233356 0
# Node ID e9dcb47013c75af2d79f2270cf48394443882bae
# Parent fdacad5d0accf1c9bfa8510a915862f3763223fc
- Some style changes by nemo
- Add ability for schemes save and load
diff -r fdacad5d0acc -r e9dcb47013c7 QTfrontend/about.cpp
--- a/QTfrontend/about.cpp Mon Mar 16 14:43:15 2009 +0000
+++ b/QTfrontend/about.cpp Mon Mar 16 19:55:56 2009 +0000
@@ -35,6 +35,10 @@
lbl1->setOpenExternalLinks(true);
lbl1->setText(
+ ""
"
Hedgewars
"
"
" + QLabel::tr("Version") + " " + *cVersionString + "
"
"
http://www.hedgewars.org/
" +
@@ -47,7 +51,12 @@
QTextBrowser *lbl2 = new QTextBrowser(this);
lbl2->setOpenExternalLinks(true);
- lbl2->setText( QString("
") +
+ lbl2->setText(
+ "" +
+ QString("") +
QLabel::tr("Developers:") +
"
"
"Engine, frontend, net server: Andrey Korotaev <unC0Rr@gmail.com>
"
diff -r fdacad5d0acc -r e9dcb47013c7 QTfrontend/ammoSchemeModel.cpp
--- a/QTfrontend/ammoSchemeModel.cpp Mon Mar 16 14:43:15 2009 +0000
+++ b/QTfrontend/ammoSchemeModel.cpp Mon Mar 16 19:55:56 2009 +0000
@@ -18,11 +18,37 @@
#include
#include
+
#include "ammoSchemeModel.h"
+#include "hwconsts.h"
-AmmoSchemeModel::AmmoSchemeModel(QObject* parent) :
- QAbstractTableModel(parent)
+AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
+ QAbstractTableModel(parent),
+ fileConfig(fileName, QSettings::IniFormat)
{
+ spNames
+ << "name" // 0
+ << "fortsmode" // 1
+ << "divteams" // 2
+ << "solidland" // 3
+ << "border" // 4
+ << "lowgrav" // 5
+ << "laser" // 6
+ << "invulnerability" // 7
+ << "mines" // 8
+ << "damagefactor" // 9
+ << "turntime" // 10
+ << "health" // 11
+ << "suddendeath" // 12
+ << "caseprobability" // 13
+ ;
+
+
+ QStringList predefSchemesNames;
+ predefSchemesNames
+ << tr("Default")
+ << tr("Pro mode");
+
defaultScheme
<< QVariant(tr("Default")) // name 0
<< QVariant(false) // fortsmode 1
@@ -40,7 +66,43 @@
<< QVariant(5) // case prob 13
;
+ QList proMode;
+ proMode
+ << QVariant(tr("Pro mode"))// 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(false) // add mines 8
+ << QVariant(100) // damage modfier 9
+ << QVariant(15) // turn time 10
+ << QVariant(100) // init health 11
+ << QVariant(15) // sudden death 12
+ << QVariant(0) // case prob 13
+ ;
+
schemes.append(defaultScheme);
+ schemes.append(proMode);
+
+
+ int size = fileConfig.beginReadArray("schemes");
+ for (int i = 0; i < size; ++i) {
+ fileConfig.setArrayIndex(i);
+
+ if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString()))
+ {
+ QList scheme;
+
+ for (int k = 0; k < spNames.size(); ++k)
+ scheme << fileConfig.value(spNames[k], defaultScheme[k]);
+
+ schemes.append(scheme);
+ }
+ }
+ fileConfig.endArray();
}
QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
@@ -102,6 +164,7 @@
{
beginRemoveRows(parent, row, row);
+ fileConfig.remove(schemes[row][0].toString());
schemes.removeAt(row);
endRemoveRows();
@@ -118,3 +181,17 @@
return schemes[index.row()][index.column()];
}
+
+void AmmoSchemeModel::Save()
+{
+ fileConfig.beginWriteArray("schemes");
+ for (int i = 0; i < schemes.size(); ++i) {
+ fileConfig.setArrayIndex(i);
+
+ QList scheme = schemes[i];
+
+ for (int k = 0; k < spNames.size(); ++k)
+ fileConfig.setValue(spNames[k], scheme[k]);
+ }
+ fileConfig.endArray();
+}
diff -r fdacad5d0acc -r e9dcb47013c7 QTfrontend/ammoSchemeModel.h
--- a/QTfrontend/ammoSchemeModel.h Mon Mar 16 14:43:15 2009 +0000
+++ b/QTfrontend/ammoSchemeModel.h Mon Mar 16 19:55:56 2009 +0000
@@ -19,7 +19,9 @@
#ifndef _AMMO_SCHEME_MODEL_INCLUDED
#define _AMMO_SCHEME_MODEL_INCLUDED
+#include
#include
+#include
#include
class AmmoSchemeModel : public QAbstractTableModel
@@ -27,7 +29,7 @@
Q_OBJECT
public:
- AmmoSchemeModel(QObject *parent = 0);
+ AmmoSchemeModel(QObject * parent, const QString & fileName);
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
int rowCount(const QModelIndex & parent) const;
@@ -38,6 +40,9 @@
bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
QVariant data(const QModelIndex &index, int role) const;
+public slots:
+ void Save();
+
signals:
void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
@@ -46,6 +51,10 @@
private:
QList defaultScheme;
+
+ QSettings fileConfig;
+
+ QStringList spNames;
};
#endif // _AMMO_SCHEME_MODEL_INCLUDED
diff -r fdacad5d0acc -r e9dcb47013c7 QTfrontend/hwform.cpp
--- a/QTfrontend/hwform.cpp Mon Mar 16 14:43:15 2009 +0000
+++ b/QTfrontend/hwform.cpp Mon Mar 16 19:55:56 2009 +0000
@@ -150,7 +150,7 @@
connect(ui.pageScheme->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
- AmmoSchemeModel * ammoSchemeModel = new AmmoSchemeModel(this);
+ ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini");
ui.pageScheme->setModel(ammoSchemeModel);
ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel);
@@ -365,6 +365,8 @@
void HWForm::btnExitClicked()
{
+ ammoSchemeModel->Save();
+
if (eggTimer.elapsed() < 3000)
close();
else
diff -r fdacad5d0acc -r e9dcb47013c7 QTfrontend/hwform.h
--- a/QTfrontend/hwform.h Mon Mar 16 14:43:15 2009 +0000
+++ b/QTfrontend/hwform.h Mon Mar 16 19:55:56 2009 +0000
@@ -34,6 +34,7 @@
class GameUIConfig;
class HWNetRegisterServer;
class QCloseEvent;
+class AmmoSchemeModel;
class HWForm : public QMainWindow
{
@@ -123,6 +124,7 @@
HWTeam * editedTeam;
HWNewNet * hwnet;
GameUIConfig * config;
+ AmmoSchemeModel * ammoSchemeModel;
QStack PagesStack;
HWNetServer* pnetserver;
HWNetRegisterServer* pRegisterServer;
diff -r fdacad5d0acc -r e9dcb47013c7 QTfrontend/main.cpp
--- a/QTfrontend/main.cpp Mon Mar 16 14:43:15 2009 +0000
+++ b/QTfrontend/main.cpp Mon Mar 16 19:55:56 2009 +0000
@@ -62,12 +62,7 @@
"background-color: #870c8f;"
"}"
- "QPushButton, QLineEdit, QLabel, QHeaderView, "
- "QListWidget, QTableView, QTextBrowser, QSpinBox, "
- "QToolBox::tab, QToolBox::tab QWidget, QComboBox, "
- "QComboBox QAbstractItemView, IconedGroupBox, .QGroupBox, "
- "GameCFGWidget, TeamSelWidget, SelWeaponWidget, "
- "QCheckBox, QRadioButton, QMenu::item, QTabBar::tab:selected {"
+ "* {"
"color: #ffcc00;"
"}"
@@ -79,7 +74,8 @@
"QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, "
"QTextBrowser, QSpinBox, QToolBox, QComboBox, "
"QComboBox QAbstractItemView, IconedGroupBox, "
- ".QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, QTabWidget::pane {"
+ ".QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, "
+ "QTabWidget::pane, QTabBar::tab {"
"border: solid;"
"border-width: 3px;"
"border-color: #ffcc00;"
@@ -138,14 +134,10 @@
"}"
"QTabBar::tab {"
- "border-top: solid;"
- "border-left: solid;"
- "border-right: solid;"
- "border-width: 3px;"
+ "border-bottom-width: 0;"
"border-radius: 0;"
"border-top-left-radius: 6px;"
"border-top-right-radius: 6px;"
- "border-color: #ffcc00;"
"padding: 3px;"
"}"
"QTabBar::tab:!selected {"