This commit is contained in:
unknown
2010-08-25 23:49:21 +04:00
parent 8d6a589224
commit 71a6a951e0
10 changed files with 566 additions and 40 deletions

View File

@@ -46,7 +46,7 @@
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Debug</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/Users/Andrey/Desktop/aliendefender/build</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/Users/Andrey/Desktop/ADeditor-build</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">5</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>

View File

@@ -0,0 +1,283 @@
<!DOCTYPE QtCreatorProject>
<qtcreator>
<data>
<variable>RunConfiguration0-BaseEnvironmentBase</variable>
<value type="int">2</value>
</data>
<data>
<variable>RunConfiguration0-CommandLineArguments</variable>
<valuelist type="QVariantList"/>
</data>
<data>
<variable>RunConfiguration0-ProFile</variable>
<value type="QString">ADeditor.pro</value>
</data>
<data>
<variable>RunConfiguration0-RunConfiguration.name</variable>
<value type="QString">ADeditor</value>
</data>
<data>
<variable>RunConfiguration0-UseDyldImageSuffix</variable>
<value type="bool">false</value>
</data>
<data>
<variable>RunConfiguration0-UseTerminal</variable>
<value type="bool">false</value>
</data>
<data>
<variable>RunConfiguration0-UserEnvironmentChanges</variable>
<valuelist type="QVariantList"/>
</data>
<data>
<variable>RunConfiguration0-UserSetName</variable>
<value type="bool">false</value>
</data>
<data>
<variable>RunConfiguration0-UserSetWorkingDirectory</variable>
<value type="bool">false</value>
</data>
<data>
<variable>RunConfiguration0-UserWorkingDirectory</variable>
<value type="QString"></value>
</data>
<data>
<variable>RunConfiguration0-type</variable>
<value type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
</data>
<data>
<variable>activeRunConfiguration</variable>
<value type="int">0</value>
</data>
<data>
<variable>activebuildconfiguration</variable>
<value type="QString">Debug</value>
</data>
<data>
<variable>buildConfiguration-Debug</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<value key="QtVersionId" type="int">0</value>
<value key="ToolChain" type="int">0</value>
<value key="addQDumper" type=""></value>
<value key="buildConfiguration" type="int">2</value>
</valuemap>
</data>
<data>
<variable>buildConfiguration-Release</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
<value key="QtVersionId" type="int">0</value>
<value key="addQDumper" type=""></value>
<value key="buildConfiguration" type="int">0</value>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Debug-buildstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-5i8Go7nPio,guid=870ffe971971ceac89206f0e4c5facbd</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
<value type="QString">GDMSESSION=gnome</value>
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7vXnOW</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/andrey</value>
<value type="QString">LANG=ru_RU.UTF-8</value>
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
<value type="QString">LOGNAME=andrey</value>
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
<value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-andrey</value>
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/andrey</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1124,unix/buull-eeePC:/tmp/.ICE-unix/1124</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=6561</value>
<value type="QString">SSH_AGENT_PID=1158</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7vXnOW/ssh</value>
<value type="QString">USER=andrey</value>
<value type="QString">USERNAME=andrey</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-HWCXAG/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1281338556.676663-803309736</value>
</valuelist>
<valuelist key="abstractProcess.arguments" type="QVariantList">
<value type="QString">/home/andrey/AD/aliendefender/ADeditor/ADeditor.pro</value>
<value type="QString">-spec</value>
<value type="QString">linux-g++</value>
<value type="QString">-r</value>
<value type="QString">CONFIG+=debug</value>
</valuelist>
<value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value>
<value key="abstractProcess.enabled" type="bool">false</value>
<value key="abstractProcess.workingDirectory" type="QString">/home/andrey/AD/aliendefender/ADeditor</value>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Debug-buildstep1</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-5i8Go7nPio,guid=870ffe971971ceac89206f0e4c5facbd</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
<value type="QString">GDMSESSION=gnome</value>
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7vXnOW</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/andrey</value>
<value type="QString">LANG=ru_RU.UTF-8</value>
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
<value type="QString">LOGNAME=andrey</value>
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
<value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-andrey</value>
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/andrey</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1124,unix/buull-eeePC:/tmp/.ICE-unix/1124</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=6561</value>
<value type="QString">SSH_AGENT_PID=1158</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7vXnOW/ssh</value>
<value type="QString">USER=andrey</value>
<value type="QString">USERNAME=andrey</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-HWCXAG/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1281338556.676663-803309736</value>
</valuelist>
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
<valuelist key="abstractProcess.arguments" type="QVariantList">
<value type="QString">-w</value>
</valuelist>
<value key="abstractProcess.command" type="QString">/usr/bin/make</value>
<value key="abstractProcess.enabled" type="bool">true</value>
<value key="abstractProcess.workingDirectory" type="QString">/home/andrey/AD/aliendefender/ADeditor</value>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Debug-cleanstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-5i8Go7nPio,guid=870ffe971971ceac89206f0e4c5facbd</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
<value type="QString">GDMSESSION=gnome</value>
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-7vXnOW</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/andrey</value>
<value type="QString">LANG=ru_RU.UTF-8</value>
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
<value type="QString">LOGNAME=andrey</value>
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
<value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-andrey</value>
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/andrey</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1124,unix/buull-eeePC:/tmp/.ICE-unix/1124</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=6561</value>
<value type="QString">SSH_AGENT_PID=1158</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-7vXnOW/ssh</value>
<value type="QString">USER=andrey</value>
<value type="QString">USERNAME=andrey</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-HWCXAG/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1281338556.676663-803309736</value>
</valuelist>
<value key="abstractProcess.IgnoreReturnValue" type="bool">true</value>
<valuelist key="abstractProcess.arguments" type="QVariantList">
<value type="QString">clean</value>
<value type="QString">-w</value>
</valuelist>
<value key="abstractProcess.command" type="QString">/usr/bin/make</value>
<value key="abstractProcess.enabled" type="bool">true</value>
<value key="abstractProcess.workingDirectory" type="QString">/home/andrey/AD/aliendefender/ADeditor</value>
<value key="cleanConfig" type="bool">true</value>
<valuelist key="makeargs" type="QVariantList">
<value type="QString">clean</value>
</valuelist>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Release-buildstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Release-buildstep1</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Release-cleanstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
</valuemap>
</data>
<data>
<variable>buildconfigurations</variable>
<valuelist type="QVariantList">
<value type="QString">Debug</value>
<value type="QString">Release</value>
</valuelist>
</data>
<data>
<variable>buildstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
<value key="mkspec" type="QString"></value>
</valuemap>
</data>
<data>
<variable>buildstep1</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
</valuemap>
</data>
<data>
<variable>buildsteps</variable>
<valuelist type="QVariantList">
<value type="QString">trolltech.qt4projectmanager.qmake</value>
<value type="QString">trolltech.qt4projectmanager.make</value>
</valuelist>
</data>
<data>
<variable>cleanstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
<value key="clean" type="bool">true</value>
</valuemap>
</data>
<data>
<variable>cleansteps</variable>
<valuelist type="QVariantList">
<value type="QString">trolltech.qt4projectmanager.make</value>
</valuelist>
</data>
<data>
<variable>defaultFileEncoding</variable>
<value type="QByteArray">System</value>
</data>
<data>
<variable>project</variable>
<valuemap type="QVariantMap"/>
</data>
</qtcreator>

View File

@@ -8,7 +8,7 @@ class AlienModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit AlienModel(QList <tbHeader*> *data, QObject *parent = 0);
explicit AlienModel(QList<tbAlien> aliens, QObject *parent = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
void refresh(QList<tbAlien> aliens);
@@ -17,7 +17,7 @@ signals:
public slots:
private:
QList <tbHeader*> *data;
QList<tbAlien> aliens;
};
#endif // ALIENMODEL_H

View File

@@ -11,14 +11,22 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this);
adloader = new Loader(this);
adloader->load("data2.xml");
alModel = new AlienModel(adloader->aliens.values());
ui->lvAliens->setModel((QAbstractItemModel * )alModel);
connect(ui->lvAliens->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvAliens_select(QModelIndex, QModelIndex)));
ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(0,0),QItemSelectionModel::Select);
splModel = new SplashModel(adloader->splashes.values());
ui->lvSplashes->setModel((QAbstractItemModel * )splModel);
connect(ui->lvSplashes->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvSplashes_select(QModelIndex, QModelIndex)));
ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(0,0),QItemSelectionModel::Select);
twModel = new TowerModel(adloader->towers.values());
ui->lvTowers->setModel((QAbstractItemModel * )twModel);
connect(ui->lvTowers->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvTowers_select(QModelIndex, QModelIndex)));
ui->lvTowers->selectionModel()->setCurrentIndex(ui->lvTowers->model()->index(0,0),QItemSelectionModel::Select);
ui->cbTwSplash->setModel((QAbstractItemModel * )splModel);
}
@@ -89,6 +97,17 @@ void MainWindow::lvTowers_select(QModelIndex index, QModelIndex)
ui->leTwName->setText(tw.name);
ui->sbTwRadius->setValue(tw.radius);
ui->sbTwReload->setValue(tw.reload);
ui->cbTwSplash->setCurrentIndex(adloader->splashes.keys().indexOf(tw.splashId));
}
void MainWindow::lvSplashes_select(QModelIndex index, QModelIndex)
{
tbSplash spl = adloader->splashes.values().at(index.row());
ui->sbSplLifeTime->setValue(spl.lifetime);
ui->sbSplSpeed->setValue(spl.speed);
ui->cbSplAutoControl->setChecked(spl.autoControl);
ui->leSplName->setText(spl.name);
}
@@ -99,48 +118,56 @@ void MainWindow::on_pbSave_clicked()
alModel->refresh(adloader->aliens.values());
}
void MainWindow::on_sbAlHealth_valueChanged(double value)
{
int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id;
adloader->aliens[id].health = value;
}
void MainWindow::on_sbAlArmor_valueChanged(double value)
{
int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id;
adloader->aliens[id].armor = value;
}
void MainWindow::on_sbAlregeneration_valueChanged(double value)
{
int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id;
adloader->aliens[id].regeneration = value;
}
void MainWindow::on_sbAlSpeed_valueChanged(double value)
{
int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id;
adloader->aliens[id].speed = value;
}
void MainWindow::on_sbAlPrise_valueChanged(int val)
{
int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id;
adloader->aliens[id].prise = val;
}
void MainWindow::on_sbAlScore_valueChanged(int val)
{
int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id;
adloader->aliens[id].score = val;
}
void MainWindow::on_cbAlIsFly_clicked(bool checked)
{
int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id;
adloader->aliens[id].isFlying = checked;
}
void MainWindow::on_leAlName_editingFinished()
{
int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id;
@@ -149,12 +176,14 @@ void MainWindow::on_leAlName_editingFinished()
ui->lvAliens->setModel((QAbstractItemModel * )alModel);
}
void MainWindow::on_pbAlAdd_clicked()
{
int i = 1;
while (adloader->aliens.contains(i)) i++;
tbAlien al;
al.id = i;
al.name = tr("Alien");
adloader->aliens.insert(al.id,al);
int index = adloader->aliens.keys().indexOf(i);
alModel->refresh(adloader->aliens.values());
@@ -163,6 +192,7 @@ void MainWindow::on_pbAlAdd_clicked()
ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(index,0),QItemSelectionModel::Select);
}
void MainWindow::on_pbAlDel_clicked()
{
QMessageBox msgBox;
@@ -182,6 +212,7 @@ void MainWindow::on_pbAlDel_clicked()
}
}
void MainWindow::on_leTwName_editingFinished()
{
int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id;
@@ -190,7 +221,161 @@ void MainWindow::on_leTwName_editingFinished()
ui->lvTowers->setModel((QAbstractItemModel * )twModel);
}
void MainWindow::on_sbTwBuildTime_valueChanged(int val)
{
int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id;
adloader->towers[id].buildTime = val;
}
void MainWindow::on_sbTwCost_valueChanged(int val)
{
int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id;
adloader->towers[id].cost = val;
}
void MainWindow::on_cbTwSplash_currentIndexChanged(int index)
{
int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id;
adloader->towers[id].splashId = adloader->splashes.values().at(index).id;
}
void MainWindow::on_sbTwReload_valueChanged(int val)
{
int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id;
adloader->towers[id].reload = val;
}
void MainWindow::on_sbTwRadius_valueChanged(double val)
{
int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id;
adloader->towers[id].radius = val;
}
void MainWindow::on_sbTwExpByShot_valueChanged(double val)
{
int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id;
adloader->towers[id].expByShot = val;
}
void MainWindow::on_sbTwExpByDam_valueChanged(double val)
{
int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id;
adloader->towers[id].expByDamage = val;
}
void MainWindow::on_sbTwExpByKill_valueChanged(double val)
{
int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id;
adloader->towers[id].expByKill = val;
}
void MainWindow::on_pbTwAdd_clicked()
{
int i = 1;
while (adloader->towers.contains(i)) i++;
tbTower tw;
tw.id = i;
tw.name = tr("Tower");
adloader->towers.insert(tw.id,tw);
int index = adloader->towers.keys().indexOf(i);
twModel->refresh(adloader->towers.values());
ui->lvTowers->setModel((QAbstractItemModel * )twModel);
ui->lvTowers->reset();
ui->lvTowers->selectionModel()->setCurrentIndex(ui->lvTowers->model()->index(index,0),QItemSelectionModel::Select);
}
void MainWindow::on_pbTwDel_clicked()
{
QMessageBox msgBox;
int id = adloader->towers.keys().at(ui->lvTowers->currentIndex().row());
msgBox.setText(tr("Delete tower %1 id=%2").arg(adloader->towers.value(id).name).arg(id));
msgBox.setInformativeText(tr("Are you sure?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
int ret = msgBox.exec();
if (ret == QMessageBox::Ok)
{
adloader->towers.remove(id);
twModel->refresh(adloader->towers.values());
ui->lvTowers->setModel((QAbstractItemModel * )twModel);
ui->lvTowers->reset();
ui->lvTowers->selectionModel()->setCurrentIndex(ui->lvTowers->model()->index(0,0),QItemSelectionModel::Select);
}
}
void MainWindow::on_leSplName_editingFinished()
{
int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id;
adloader->splashes[id].name = ui->leSplName->text();
splModel->refresh(adloader->splashes.values());
ui->lvSplashes->setModel((QAbstractItemModel * )splModel);
ui->cbTwSplash->setModel((QAbstractItemModel * )splModel);
}
void MainWindow::on_sbSplSpeed_valueChanged(double val)
{
int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id;
adloader->splashes[id].speed = val;
}
void MainWindow::on_cbSplAutoControl_toggled(bool checked)
{
int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id;
adloader->splashes[id].autoControl = checked;
}
void MainWindow::on_sbSplLifeTime_valueChanged(int val)
{
int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id;
adloader->splashes[id].lifetime = val;
}
void MainWindow::on_pbSplAdd_clicked()
{
int i = 1;
while (adloader->splashes.contains(i)) i++;
tbSplash spl;
spl.id = i;
spl.name = tr("Splash");
adloader->splashes.insert(spl.id,spl);
int index = adloader->splashes.keys().indexOf(i);
splModel->refresh(adloader->splashes.values());
ui->lvSplashes->setModel((QAbstractItemModel * )splModel);
ui->lvSplashes->reset();
ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(index,0),QItemSelectionModel::Select);
ui->cbTwSplash->setModel((QAbstractItemModel * )splModel);
}
void MainWindow::on_pbSlpDel_clicked()
{
QMessageBox msgBox;
int id = adloader->splashes.keys().at(ui->lvSplashes->currentIndex().row());
msgBox.setText(tr("Delete splash %1 id=%2").arg(adloader->splashes.value(id).name).arg(id));
msgBox.setInformativeText(tr("Are you sure?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
int ret = msgBox.exec();
if (ret == QMessageBox::Ok)
{
adloader->splashes.remove(id);
splModel->refresh(adloader->splashes.values());
ui->lvSplashes->setModel((QAbstractItemModel * )splModel);
ui->lvSplashes->reset();
ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(0,0),QItemSelectionModel::Select);
ui->cbTwSplash->setModel((QAbstractItemModel * )splModel);
}
}

View File

@@ -7,7 +7,7 @@
#include "alienmodel.h"
#include "towermodel.h"
#include "splashmodel.h"
namespace Ui {
class MainWindow;
@@ -27,8 +27,24 @@ private:
Loader * adloader;
AlienModel * alModel;
TowerModel * twModel;
SplashModel * splModel;
private slots:
void on_pbSlpDel_clicked();
void on_pbSplAdd_clicked();
void on_sbSplLifeTime_valueChanged(int );
void on_cbSplAutoControl_toggled(bool checked);
void on_sbSplSpeed_valueChanged(double );
void on_leSplName_editingFinished();
void on_pbTwDel_clicked();
void on_sbTwExpByKill_valueChanged(double );
void on_sbTwExpByDam_valueChanged(double );
void on_sbTwExpByShot_valueChanged(double );
void on_sbTwRadius_valueChanged(double );
void on_sbTwReload_valueChanged(int );
void on_cbTwSplash_currentIndexChanged(int index);
void on_sbTwCost_valueChanged(int );
void on_sbTwBuildTime_valueChanged(int );
void on_pbTwAdd_clicked();
void on_leTwName_editingFinished();
void on_pbAlDel_clicked();
@@ -44,6 +60,7 @@ private slots:
void on_pbSave_clicked();
void lvAliens_select(QModelIndex, QModelIndex);
void lvTowers_select(QModelIndex, QModelIndex);
void lvSplashes_select(QModelIndex, QModelIndex);
void on_cbAlRegeneration_toggled(bool checked);
void on_cbAlArmor_toggled(bool checked);
};

View File

@@ -512,7 +512,14 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="cbTwSplash"/>
<widget class="QComboBox" name="cbTwSplash">
<property name="maxVisibleItems">
<number>10</number>
</property>
<property name="duplicatesEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
@@ -856,6 +863,29 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_42">
<item>
<widget class="QLabel" name="label_37">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>LifeTime</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbSplLifeTime"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
@@ -892,29 +922,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_42">
<item>
<widget class="QLabel" name="label_37">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>LifeTime</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbSplLifeTime"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_46" stretch="10,4,0,1">
<item>

View File

@@ -112,7 +112,12 @@
<xsd:attribute name="id" type="xsd:positiveInteger" use="required"/>
<xsd:attribute name="count" type="xsd:positiveInteger" use="optional"/>
<xsd:attribute name="timer" type="xsd:positiveInteger" use="optional"/>
<xsd:attribute name="chance" type="xsd:positiveInteger" use="optional"/>
<xsd:attribute name="chance" use="optional"/>
<xsd:simpleType>
<xsd:restriction base="xsd:positiveInteger">
<xsd:maxInclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:attribute name="randomPosRadius" type="xsd:float" use="optional"/>
<xsd:attribute name="damage" type="xsd:float" use="optional"/>
<xsd:attribute name="radius" type="xsd:float" use="optional"/>
@@ -159,7 +164,7 @@
<xsd:attribute name="width" type="xsd:positiveInteger" use="required"/>
<xsd:attribute name="height" type="xsd:positiveInteger" use="required"/>
<xsd:attribute name="imageType" type="xsd:integer" use="required"/>
<xsd:attribute name="data" type="xsd:string" use="required"/>
<xsd:attribute name="data" type="xsd:base64Binary" use="required"/>
</xsd:complexType>
<xsd:complexType name="morphType">

View File

@@ -1,6 +1,35 @@
#include "splashmodel.h"
SplashModel::SplashModel(QList<tbSplash> splashes, QObject *parent) :
SplashModel::SplashModel(QList<tbSplash> msplashes, QObject *parent) :
QAbstractListModel(parent)
{
splashes = msplashes;
}
void SplashModel::refresh(QList<tbSplash> msplashes)
{
splashes = msplashes;
}
int SplashModel::rowCount(const QModelIndex &) const
{
return splashes.count();
}
QVariant SplashModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= splashes.size())
return QVariant();
if (role == Qt::DisplayRole)
{
return splashes.at(index.row()).name;
}
return QVariant();
}

View File

@@ -9,8 +9,8 @@ class SplashModel : public QAbstractListModel
Q_OBJECT
public:
explicit SplashModel(QList <tbSplash> splashes, QObject *parent = 0);
//int rowCount(const QModelIndex &parent = QModelIndex()) const;
//QVariant data(const QModelIndex &index, int role) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
void refresh(QList <tbSplash> splashes);
signals: