diff --git a/ADeditor/ADeditor.pro b/ADeditor/ADeditor.pro
index 51a612b..edce422 100644
--- a/ADeditor/ADeditor.pro
+++ b/ADeditor/ADeditor.pro
@@ -19,7 +19,8 @@ SOURCES += main.cpp \
animationmodel.cpp \
animlabel.cpp \
../aliens.cpp \
- ../aditem.cpp
+ ../aditem.cpp \
+ wavemodel.cpp
HEADERS += mainwindow.h \
../loader.h \
alienmodel.h \
@@ -34,7 +35,8 @@ HEADERS += mainwindow.h \
animationmodel.h \
animlabel.h \
../aliens.h \
- ../aditem.h
+ ../aditem.h \
+ wavemodel.h
FORMS += mainwindow.ui
TRANSLATIONS += adeditor_ru.ts
RESOURCES += ADeditor.qrc
@@ -42,3 +44,5 @@ OTHER_FILES += ../schema.xml \
../data2.xml
+
+
diff --git a/ADeditor/ADeditor.pro.user b/ADeditor/ADeditor.pro.user
index 5dd97e9..bb08aaa 100644
--- a/ADeditor/ADeditor.pro.user
+++ b/ADeditor/ADeditor.pro.user
@@ -1,7 +1,11 @@
-
+
+
+ EnvironmentId
+ {948faa78-0b50-402e-a285-1bca3b08de64}
+
ProjectExplorer.Project.ActiveTarget
0
@@ -11,66 +15,32 @@
true
false
+ true
Cpp
- false
- CppGlobal
- true
- false
- true
- false
- false
- false
- true
- true
- false
- true
- false
- false
- false
- true
- false
+ CppGlobal
- 1
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
UTF-8
- Global
+ false
4
+ false
+ 80
+ true
true
1
true
- false
+ false
+ 0
true
-
- Cpp
-
- true
- false
- CppGlobal
- 4
- 1
- false
- true
- 0
- 8
-
-
-
- QmlJS
-
- true
- false
- QmlJSGlobal
- 4
- 1
- false
- true
- 0
- 8
-
-
- 2
0
8
true
@@ -81,19 +51,24 @@
false
+
+ ProjectExplorer.Project.PluginSettings
+
+
ProjectExplorer.Project.Target.0
- Desktop
- Desktop
- Qt4ProjectManager.Target.DesktopTarget
- 1
+ DesktopBuild
+ DesktopBuild
+ {3c749452-9483-442d-b011-933a1b5dac10}
+ 0
0
0
- ProjectExplorer.ToolChain.Mingw:D:/Qt/qtcreator-2.2.84/mingw/bin/gcc.exe.x86-windows-msys-pe-32bit.D:/Qt/qtcreator-2.2.84/pythongdb/gdb-i686-pc-mingw32.exe
+ D:/aliendefender/build-ADeditor-DesktopBuild-Debug
+ true
qmake
QtProjectManager.QMakeBuildStep
@@ -103,9 +78,11 @@
false
+ true
Сборка
Qt4ProjectManager.MakeStep
+
false
@@ -117,9 +94,11 @@
+ true
Сборка
Qt4ProjectManager.MakeStep
+
true
clean
@@ -132,18 +111,17 @@
2
false
- qt Отладка
+ Отладка
Qt4ProjectManager.Qt4BuildConfiguration
2
- C:/Users/Andrey/Desktop/aliendefender/ADeditor
- 7
- false
+ true
- ProjectExplorer.ToolChain.Mingw:D:/Qt/qtcreator-2.2.84/mingw/bin/gcc.exe.x86-windows-msys-pe-32bit.D:/Qt/qtcreator-2.2.84/pythongdb/gdb-i686-pc-mingw32.exe
+ D:/aliendefender/build-ADeditor-DesktopBuild-Release
+ true
qmake
QtProjectManager.QMakeBuildStep
@@ -153,9 +131,11 @@
false
+ true
Сборка
Qt4ProjectManager.MakeStep
+
false
@@ -167,9 +147,11 @@
+ true
Сборка
Qt4ProjectManager.MakeStep
+
true
clean
@@ -182,13 +164,11 @@
2
false
- qt Релиз
+ Выпуск
Qt4ProjectManager.Qt4BuildConfiguration
0
- C:/Users/Andrey/Desktop/aliendefender/ADeditor
- 7
- false
+ true
2
@@ -199,39 +179,29 @@
ProjectExplorer.BuildSteps.Deploy
1
- Без установки
+ Локальная установка
ProjectExplorer.DefaultDeployConfiguration
1
+
- true
- true
-
false
- false
- false
false
false
- false
- false
false
true
- true
- 0.01
0.01
10
- 10
true
- true
- 25
+ 1
25
-
+ 3
+ true
+ false
true
- true
- valgrind
valgrind
0
@@ -250,37 +220,22 @@
13
14
-
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
-
+ 2
+
ADeditor
- Qt4ProjectManager.Qt4RunConfiguration
- 2
+ Qt4ProjectManager.Qt4RunConfiguration:D:/aliendefender/ADeditor/ADeditor.pro
ADeditor.pro
false
false
-
- C:/Users/Andrey/Desktop/aliendefender
+
3768
- true
+ false
+ true
+ false
false
- false
+ true
1
@@ -290,11 +245,11 @@
1
- ProjectExplorer.Project.Updater.EnvironmentId
- {6c550070-c96c-41ad-865e-c5b9b5c3b79f}
+ ProjectExplorer.Project.Updater.FileVersion
+ 16
- ProjectExplorer.Project.Updater.FileVersion
- 10
+ Version
+ 16
diff --git a/ADeditor/ADeditor.pro.user.1.3 b/ADeditor/ADeditor.pro.user.1.3
index 35f4816..579f8c6 100644
--- a/ADeditor/ADeditor.pro.user.1.3
+++ b/ADeditor/ADeditor.pro.user.1.3
@@ -9,7 +9,7 @@
true
false
- System
+ UTF-8
false
false
4
@@ -19,7 +19,7 @@
false
true
0
- 8
+ 4
true
1
true
@@ -34,11 +34,11 @@
Desktop
Desktop
Qt4ProjectManager.Target.DesktopTarget
- 1
+ 0
0
0
- ProjectExplorer.ToolChain.Mingw:C:/Qt/qtcreator-2.2.0/mingw/bin/gcc.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe
+ ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.
qmake
@@ -78,63 +78,63 @@
2
false
- 4.6.3 (2) release Отладка
-
- Qt4ProjectManager.Qt4BuildConfiguration
- 2
- C:/Users/Dima/Desktop/aliendefender/ADeditor-build-desktop
- 5
- ProjectExplorer.ToolChain.Mingw:C:/Qt/qtcreator-2.2.0/mingw/bin/gcc.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe
- false
-
-
- ProjectExplorer.ToolChain.Mingw:C:/Qt/qtcreator-2.2.0/mingw/bin/gcc.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe
-
-
- qmake
-
- QtProjectManager.QMakeBuildStep
- false
-
- false
-
-
- Сборка
-
- Qt4ProjectManager.MakeStep
- false
-
-
-
- 2
- Сборка
-
- ProjectExplorer.BuildSteps.Build
-
-
-
- Сборка
-
- Qt4ProjectManager.MakeStep
- true
- clean
-
-
- 1
- Очистка
-
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- 4.6.3 (2) release Релиз
+ Qt в PATH Релиз
Qt4ProjectManager.Qt4BuildConfiguration
0
- C:/Users/Dima/Desktop/aliendefender/ADeditor-build-desktop
- 5
- ProjectExplorer.ToolChain.Mingw:C:/Qt/qtcreator-2.2.0/mingw/bin/gcc.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe
+ /home/andrey/aliendefender/ADeditor
+ 2
+ ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.
+ false
+
+
+ ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.
+
+
+ qmake
+
+ QtProjectManager.QMakeBuildStep
+ false
+
+ false
+
+
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+ false
+
+
+
+ 2
+ Сборка
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+ true
+ clean
+
+
+ 1
+ Очистка
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Qt в PATH Отладка
+
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+ /home/andrey/aliendefender/ADeditor
+ 2
+ ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-64bit.
false
2
@@ -152,6 +152,29 @@
1
+
+ true
+ 25
+
+ true
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
ADeditor
Qt4ProjectManager.Qt4RunConfiguration
@@ -161,7 +184,7 @@
false
false
-
+ /home/andrey/aliendefender
3768
true
false
@@ -175,7 +198,7 @@
ProjectExplorer.Project.Updater.EnvironmentId
- {0f364aaa-5a2f-49c5-b7a5-6b296e2f6fd0}
+ {9fe7c56a-57b2-4b67-8b16-62cd8b54e5ea}
ProjectExplorer.Project.Updater.FileVersion
diff --git a/ADeditor/alienmodel.cpp b/ADeditor/alienmodel.cpp
index 1539806..7f15130 100644
--- a/ADeditor/alienmodel.cpp
+++ b/ADeditor/alienmodel.cpp
@@ -29,7 +29,15 @@ QVariant AlienModel::data(const QModelIndex &index, int role) const
if (role == Qt::DisplayRole)
{
- return aliens.at(index.row()).name;
+ return aliens.at(index.row()).name;
}
- return QVariant();
+ if (role == Qt::DecorationRole)
+ {
+ return QIcon(":/icons/icons/list-add.png");
+ }
+ if (role == Qt::ToolTipRole)
+ {
+ return tr("id=%1").arg(aliens.at(index.row()).id);
+ }
+ return QVariant();
}
diff --git a/ADeditor/alienmodel.h b/ADeditor/alienmodel.h
index be63ae5..89bfe9c 100644
--- a/ADeditor/alienmodel.h
+++ b/ADeditor/alienmodel.h
@@ -2,6 +2,7 @@
#define ALIENMODEL_H
#include
+#include
#include "../loader.h"
class AlienModel : public QAbstractListModel
diff --git a/ADeditor/mainwindow.cpp b/ADeditor/mainwindow.cpp
index 696e6a5..17a4770 100644
--- a/ADeditor/mainwindow.cpp
+++ b/ADeditor/mainwindow.cpp
@@ -6,8 +6,8 @@
#include
MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::MainWindow)
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->pbSave->setIcon(QIcon::fromTheme("document-save", QIcon(":/icons/icons/document-save.png")));
@@ -24,6 +24,8 @@ MainWindow::MainWindow(QWidget *parent) :
ui->pbSlpDel->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png")));
ui->pbAnimAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png")));
ui->pbAnimDel->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png")));
+ ui->pbWaveAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png")));
+ ui->pbWaveDel->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png")));
ui->pbImgAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png")));
ui->pbImgDel->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png")));
ui->pbTwSplashEdit->setIcon(QIcon::fromTheme("edit", QIcon(":/icons/icons/edit.png")));
@@ -31,6 +33,15 @@ MainWindow::MainWindow(QWidget *parent) :
adloader = new Loader();
adloader->load("data2.xml");
+ wavePartModel = new WavePartModel(adloader->waves);
+ waveModel = new WaveModel(adloader->waves);
+// waveModel->setCurrentWave(0);
+ connect(waveModel,SIGNAL(needUpdateIndex()),wavePartModel,SLOT(updateIndex()));
+ ui->tableWaves->setModel((QAbstractItemModel * )waveModel);
+ ui->tableWaveParts->setModel((QAbstractItemModel * )wavePartModel);
+ connect(ui->tableWaves->selectionModel(),SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),wavePartModel,SLOT(setCurrentWave(QModelIndex,QModelIndex)));
+ connect(ui->tableWaveParts->selectionModel(),SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),this,SLOT(tbWavePartSelect(QModelIndex,QModelIndex)));
+
animModel = new AnimationModel(adloader->animations);
ui->lvAnimations->setModel((QAbstractItemModel * )animModel);
connect(ui->lvAnimations->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)),this,SLOT(lvAnimations_select(QModelIndex, QModelIndex)));
@@ -48,6 +59,7 @@ MainWindow::MainWindow(QWidget *parent) :
alModel = new AlienModel(adloader->aliens.values());
ui->lvAliens->setModel((QAbstractItemModel * )alModel);
ui->cbAlImage->setModel((QAbstractItemModel * )animModel);
+ ui->lvWaveAliens->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::ClearAndSelect);
@@ -246,45 +258,46 @@ void MainWindow::lvSplashes_select(QModelIndex index, QModelIndex)
ui->leSplName->setText(spl.name);
ui->cbSplImage->setCurrentIndex(adloader->animations.keys().indexOf(spl.imgType));
ui->lbSplAnim->setAnimation(adloader->animations.value(spl.imgType).pathes);
+ ui->sbSplZValue->setValue(spl.ZValue);
switch (spl.compositionMode)
{
case QPainter::RasterOp_NotSource :
ui->cbSplCompisitionMode->setCurrentIndex(1);
- break;
+ break;
case QPainter::CompositionMode_Plus :
ui->cbSplCompisitionMode->setCurrentIndex(2);
- break;
+ break;
case QPainter::CompositionMode_Multiply :
ui->cbSplCompisitionMode->setCurrentIndex(3);
- break;
+ break;
case QPainter::CompositionMode_Screen :
ui->cbSplCompisitionMode->setCurrentIndex(4);
- break;
+ break;
case QPainter::CompositionMode_Darken :
ui->cbSplCompisitionMode->setCurrentIndex(5);
- break;
+ break;
case QPainter::CompositionMode_Lighten :
ui->cbSplCompisitionMode->setCurrentIndex(6);
- break;
+ break;
case QPainter::CompositionMode_ColorDodge :
ui->cbSplCompisitionMode->setCurrentIndex(7);
- break;
+ break;
case QPainter::CompositionMode_ColorBurn :
ui->cbSplCompisitionMode->setCurrentIndex(8);
- break;
+ break;
case QPainter::CompositionMode_HardLight :
ui->cbSplCompisitionMode->setCurrentIndex(9);
- break;
+ break;
case QPainter::CompositionMode_SoftLight :
ui->cbSplCompisitionMode->setCurrentIndex(10);
- break;
+ break;
case QPainter::CompositionMode_Difference :
ui->cbSplCompisitionMode->setCurrentIndex(11);
- break;
+ break;
case QPainter::CompositionMode_SourceOver :
default:
ui->cbSplCompisitionMode->setCurrentIndex(0);
- break;
+ break;
}
}
}
@@ -423,7 +436,7 @@ void MainWindow::on_pbReload_clicked()
twModel->refresh(adloader->towers.values());
splModel->refresh(adloader->splashes.values());
trigModel->refresh(adloader->triggers.values());
-// animModel->refresh(adloader->animations.values());
+ // animModel->refresh(adloader->animations.values());
mapModel->refresh(adloader->maps.values());
ui->lvAnimations->reset();
ui->lvAnimations->selectionModel()->setCurrentIndex(ui->lvAnimations->model()->index(0,0),QItemSelectionModel::ClearAndSelect);
@@ -543,15 +556,18 @@ void MainWindow::on_pbAlDel_clicked()
if (adloader->aliens.size() < 2) return;
QMessageBox msgBox;
int id = adloader->aliens.keys().at(ui->lvAliens->currentIndex().row());
- for (int i=0; iwaveParts.size(); i++)
+ for (int i=0; iwaves.size(); i++)
{
- if (adloader->waveParts.values().at(i).alienId == id)
+ for (int j=0; jwaves[i].parts.size(); j++)
{
- msgBox.setText(tr("You can not delete alien %1 id=%2").arg(adloader->aliens.value(id).name).arg(id));
- msgBox.setInformativeText(tr("It used in wawe %1").arg(adloader->waveParts.values().at(i).waveId));
- msgBox.setStandardButtons(QMessageBox::Ok);
- msgBox.exec();
- return;
+ if (adloader->waves[i].parts[j].alienId == id)
+ {
+ msgBox.setText(tr("You can not delete alien %1 id=%2").arg(adloader->aliens.value(id).name).arg(id));
+ msgBox.setInformativeText(tr("It used in wawe %1").arg(adloader->waves[i].id));
+ msgBox.setStandardButtons(QMessageBox::Ok);
+ msgBox.exec();
+ return;
+ }
}
}
msgBox.setText(tr("Delete alien %1 id=%2").arg(adloader->aliens.value(id).name).arg(id));
@@ -823,7 +839,7 @@ void MainWindow::on_pbSlpDel_clicked()
for (int i=0; ichains.size(); i++)
{
if (adloader->chains.values().at(i).childSplashId == id
- || adloader->chains.values().at(i).parentSplashId == id)
+ || adloader->chains.values().at(i).parentSplashId == id)
{
msgBox.setText(tr("You can not delete splash %1 id=%2").arg(adloader->splashes.value(id).name).arg(id));
msgBox.setInformativeText(tr("It used by chain in tower %1 id=%2").arg(adloader->towers.value(adloader->chains.values().at(i).towerId).name).arg(adloader->chains.values().at(i).towerId));
@@ -1091,13 +1107,13 @@ void MainWindow::on_pbImgAdd_clicked()
/*if (fd.exec())
{
strl = fd.selectedFiles();*/
- for (int i=0; ianimations[id].pathes.append(strl);
- refresh_lwImages(adloader->animations.value(id).pathes);
- isSaved = false;
+ for (int i=0; ianimations[id].pathes.append(strl);
+ refresh_lwImages(adloader->animations.value(id).pathes);
+ isSaved = false;
//}
}
@@ -1133,7 +1149,7 @@ void MainWindow::on_pbAnimAdd_clicked()
anim.id = i;
adloader->animations.insert(anim.id,anim);
int index = adloader->animations.keys().indexOf(i);
-// animModel->refresh(adloader->animations.values());
+ // animModel->refresh(adloader->animations.values());
ui->lvAnimations->reset();
ui->lvAnimations->selectionModel()->setCurrentIndex(ui->lvAnimations->model()->index(index,0),QItemSelectionModel::ClearAndSelect);
isSaved = false;
@@ -1227,7 +1243,7 @@ void MainWindow::on_pbAnimDel_clicked()
if (ret == QMessageBox::Ok)
{
adloader->animations.remove(id);
-// animModel->refresh(adloader->animations.values());
+ // animModel->refresh(adloader->animations.values());
ui->lvAnimations->reset();
ui->lvAnimations->selectionModel()->setCurrentIndex(ui->lvAnimations->model()->index(0,0),QItemSelectionModel::ClearAndSelect);
isSaved = false;
@@ -1280,3 +1296,81 @@ void MainWindow::on_cbSplKeepOnAlien_toggled(bool checked)
adloader->splashes[id].keepOnAlien = checked;
if (lval != adloader->splashes[id].keepOnAlien) isSaved = false;
}
+
+
+void MainWindow::on_btWaveAddAlien_clicked()
+{
+ if (ui->lvWaveAliens->currentIndex().isValid())
+ wavePartModel->insertAlien(adloader->aliens.values().at(ui->lvWaveAliens->currentIndex().row()).id);
+ waveModel->refreshData();
+}
+
+
+void MainWindow::tbWavePartSelect(QModelIndex a, QModelIndex)
+{
+ ui->btWaveRemoveAlien->setEnabled(a.isValid());
+}
+
+
+void MainWindow::on_btWaveRemoveAlien_clicked()
+{
+ wavePartModel->removeAlien(ui->tableWaveParts->selectionModel()->currentIndex());
+ waveModel->refreshData();
+}
+
+
+void MainWindow::on_btWaveClear_clicked()
+{
+ wavePartModel->clearAliens();
+ waveModel->refreshData();
+}
+
+
+void MainWindow::on_pbWaveAdd_clicked()
+{
+// wavePartModel->setCurrentWave(QModelIndex());
+ QModelIndex a = ui->tableWaves->selectionModel()->currentIndex();
+ waveModel->addWave(a);
+ wavePartModel->setCurrentWave(waveModel->index(a.row()+1,a.column()));
+ //wavePartModel->setCurrentWave(a);
+// ui->tableWaves->selectionModel()->setCurrentIndex(waveModel->index(a.row()+1,a.column()),QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+}
+
+
+void MainWindow::on_pbWaveDel_clicked()
+{
+// wavePartModel->setCurrentWave(QModelIndex());
+ QModelIndex a = ui->tableWaves->selectionModel()->currentIndex();
+ waveModel->removeWave(a);
+ wavePartModel->setCurrentWave(waveModel->index(a.row(),a.column()));
+ //wavePartModel->setCurrentWave(a);
+ //ui->tableWaves->selectionModel()->setCurrentIndex(waveModel->index(a.row(),a.column()),QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+}
+
+
+void MainWindow::on_pbWaveCopy_clicked()
+{
+// wavePartModel->setCurrentWave(QModelIndex());
+ QModelIndex a = ui->tableWaves->selectionModel()->currentIndex();
+ waveModel->copyWave(a);
+ wavePartModel->setCurrentWave(waveModel->index(a.row()+1,a.column()));
+// ui->tableWaves->selectionModel()->setCurrentIndex(waveModel->index(a.row()+1,a.column()),QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+}
+
+
+void MainWindow::on_btWaveUp_clicked()
+{
+ wavePartModel->setCurrentWave(QModelIndex());
+ QModelIndex a = ui->tableWaves->selectionModel()->currentIndex();
+ waveModel->upWave(a);
+ ui->tableWaves->selectionModel()->setCurrentIndex(waveModel->index(a.row()-1,a.column()),QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+}
+
+
+void MainWindow::on_btWaveDown_clicked()
+{
+ wavePartModel->setCurrentWave(QModelIndex());
+ QModelIndex a = ui->tableWaves->selectionModel()->currentIndex();
+ waveModel->downWave(a);
+ ui->tableWaves->selectionModel()->setCurrentIndex(waveModel->index(a.row()+1,a.column()),QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+}
diff --git a/ADeditor/mainwindow.h b/ADeditor/mainwindow.h
index 93a348b..7820dd0 100644
--- a/ADeditor/mainwindow.h
+++ b/ADeditor/mainwindow.h
@@ -14,6 +14,7 @@
#include "mapmodel.h"
#include "animationmodel.h"
#include "animlabel.h"
+#include "wavemodel.h"
namespace Ui {
class MainWindow;
@@ -37,6 +38,8 @@ private:
TriggerModel* trigModel;
MapModel * mapModel;
AnimationModel * animModel;
+ WavePartModel * wavePartModel;
+ WaveModel * waveModel;
QGraphicsScene * mapScene;
//AnimLabel * alb;
@@ -109,12 +112,21 @@ private slots:
void lvSplashes_select(QModelIndex, QModelIndex);
void lvTriggers_select(QModelIndex, QModelIndex);
void lvMaps_select(QModelIndex, QModelIndex);
+ void tbWavePartSelect(QModelIndex, QModelIndex);
void on_cbAlRegeneration_toggled(bool checked);
void on_cbAlArmor_toggled(bool checked);
void on_cbSplCompisitionMode_currentIndexChanged(const QString &arg1);
void on_sbSplZValue_valueChanged(double arg1);
void on_sbSplAnimSpeed_valueChanged(double arg1);
void on_cbSplKeepOnAlien_toggled(bool checked);
+ void on_btWaveAddAlien_clicked();
+ void on_btWaveRemoveAlien_clicked();
+ void on_btWaveClear_clicked();
+ void on_pbWaveAdd_clicked();
+ void on_pbWaveDel_clicked();
+ void on_pbWaveCopy_clicked();
+ void on_btWaveUp_clicked();
+ void on_btWaveDown_clicked();
};
#endif // MAINWINDOW_H
diff --git a/ADeditor/mainwindow.ui b/ADeditor/mainwindow.ui
index ff21582..78c9787 100644
--- a/ADeditor/mainwindow.ui
+++ b/ADeditor/mainwindow.ui
@@ -6,8 +6,8 @@
0
0
- 598
- 497
+ 1170
+ 651
@@ -47,7 +47,7 @@
QTabWidget::Rounded
- 2
+ 6
true
@@ -1899,6 +1899,244 @@
+
+
+ Waves
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+
-
+
+
+ true
+
+
+ QAbstractItemView::SingleSelection
+
+
+ QAbstractItemView::SelectRows
+
+
+ false
+
+
+
+ -
+
+
+ 5
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Add
+
+
+
+ -
+
+
+ Copy
+
+
+
+ -
+
+
+ ...
+
+
+
+ 22
+ 22
+
+
+
+ Qt::UpArrow
+
+
+
+ -
+
+
+ ...
+
+
+
+ 22
+ 22
+
+
+
+ Qt::DownArrow
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 20
+ 20
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Delete
+
+
+
+
+
+
+
+
+
+ QAbstractItemView::DropOnly
+
+
+ true
+
+
+ QAbstractItemView::SingleSelection
+
+
+ QAbstractItemView::SelectRows
+
+
+ false
+
+
+ false
+
+
+ false
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 50
+ 80
+
+
+
+ add
+
+
+ Qt::LeftArrow
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 50
+ 80
+
+
+
+ remove
+
+
+ Qt::NoArrow
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 50
+ 80
+
+
+
+ clear
+
+
+ Qt::NoArrow
+
+
+
+
+
+
+
+ true
+
+
+ QAbstractItemView::DragDrop
+
+
+ QListView::Snap
+
+
+ true
+
+
+ QListView::Adjust
+
+
+ QListView::Batched
+
+
+ QListView::ListMode
+
+
+ true
+
+
+
+
+
+
diff --git a/ADeditor/wavemodel.cpp b/ADeditor/wavemodel.cpp
new file mode 100644
index 0000000..26f8716
--- /dev/null
+++ b/ADeditor/wavemodel.cpp
@@ -0,0 +1,332 @@
+#include "wavemodel.h"
+
+WavePartModel::WavePartModel(QHash &mwaves, QObject *parent) :
+ QAbstractTableModel(parent), waves(mwaves)
+{
+ curWave = -1;
+// wavelist = waves.values();
+}
+
+
+int WavePartModel::rowCount(const QModelIndex &) const
+{
+ if (curWave==-1) return 0;
+ return waves[curWave].parts.size();
+}
+
+
+QVariant WavePartModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || (role != Qt::DisplayRole && role != Qt::EditRole)) return QVariant();
+ if (curWave==-1) return QVariant();
+ if (index.row() >= waves[curWave].parts.size()) return QVariant();
+ if (index.column() == 0)
+ return QVariant(tr("alien %1").arg(waves[curWave].parts.at(index.row()).alienId));
+ if (index.column() == 1)
+ return QVariant(waves[curWave].parts.at(index.row()).count);
+ return QVariant();
+}
+
+
+bool WavePartModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (role != Qt::EditRole) return false;
+ if (curWave==-1) return false;
+ if (index.row() >= waves[curWave].parts.size()) return false;
+ if (index.column() == 1)
+ {
+ waves[curWave].parts[index.row()].count = value.toInt();
+ return true;
+ }
+ return false;
+}
+
+
+//bool WaveModel::insertRows(int row, int count, const QModelIndex &parent)
+//{
+// beginInsertRows(parent,row+1,row+count);
+// waves[curWave].parts.insert(row,count,tbWavePart );
+// endInsertRows();
+// return true;
+//}
+
+
+bool WavePartModel::removeRows(int row, int count, const QModelIndex &parent)
+{
+ beginRemoveRows(parent,row,row+count);
+ waves[curWave].parts.remove(row,count);
+ endRemoveRows();
+ return true;
+}
+
+
+void WavePartModel::insertAlien(int alId)
+{
+ //qDebug() << curWave;
+ if (curWave == -1) return;
+ for (int i=0; i0)
+ {
+ beginRemoveRows(QModelIndex(),0,rowCount()-1);
+ curWave = -1;
+ endRemoveRows();
+ return;
+ }
+ curWave = -1;
+ return;
+ }
+ int wave = a.row();
+ int id = waves.values().at(wave).id;
+ int lc = waves[id].parts.size();
+ if (lc > rowCount()) {
+ beginInsertRows(QModelIndex(),rowCount(),lc-1);
+ curWave = id;
+ endInsertRows();
+ emit dataChanged(index(0,0),index(rowCount()-1,1));
+ return;
+ }
+ if (lc < rowCount()) {
+ beginRemoveRows(QModelIndex(),lc,rowCount()-1);
+ curWave = id;
+ endRemoveRows();
+ emit dataChanged(index(0,0),index(rowCount()-1,1));
+ return;
+ }
+ curWave = id;
+ emit dataChanged(index(0,0),index(rowCount()-1,1));
+}
+
+
+//QStringList WavePartModel::waveList()
+//{
+// QStringList strwavelist;
+// for(int i=0; i= values.size()) return QVariant();
+ switch (index.column())
+ {
+ case 0:
+ return QVariant(tr("wave %1").arg(values.at(index.row()).id));
+ case 1:
+ return QVariant(values.at(index.row()).prise);
+ case 2:
+ return QVariant(values.at(index.row()).timeout);
+ case 3:
+ return QVariant(values.at(index.row()).parts.size());
+ default:
+ return QVariant();
+ }
+ return QVariant();
+}
+
+
+QVariant WaveModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Vertical || (role != Qt::DisplayRole && role != Qt::EditRole)) return QVariant();
+ switch (section)
+ {
+ case 0:
+ return QVariant(tr("#"));
+ case 1:
+ return QVariant(tr("prise"));
+ case 2:
+ return QVariant(tr("timeout"));
+ case 3:
+ return QVariant(tr("parts"));
+ default:
+ return QVariant();
+ }
+ return QVariant();
+}
+
+
+QVariant WavePartModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Vertical || (role != Qt::DisplayRole && role != Qt::EditRole)) return QVariant();
+ switch (section)
+ {
+ case 0:
+ return QVariant(tr("alien"));
+ case 1:
+ return QVariant(tr("count"));
+ default:
+ return QVariant();
+ }
+ return QVariant();
+}
+
+
+bool WaveModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (role != Qt::EditRole) return false;
+ if (index.row() >= values.size()) return false;
+ if (index.column() == 1)
+ {
+ waves[values.at(index.row()).id].prise = value.toInt();
+ refreshData();
+ return true;
+ }
+ if (index.column() == 2)
+ {
+ waves[values.at(index.row()).id].timeout = value.toInt();
+ refreshData();
+ return true;
+ }
+ return false;
+}
+
+
+void WaveModel::refreshData(bool inverse)
+{
+ if (inverse)
+ {
+ emit needUpdateIndex();
+ waves.clear();
+ for (int i=0; i &mwaves, QObject *parent) :
+ QAbstractTableModel(parent), waves(mwaves)
+{
+ refreshData();
+}
+
+
+void WavePartModel::removeAlien(QModelIndex index)
+{
+ if (!index.isValid()) return;
+ // for (int i=0; i
+#include
+#include "../loader.h"
+
+class WavePartModel : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ explicit WavePartModel(QHash &waves, QObject *parent = 0);
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent) const {return 2;}
+ //bool insertRows(int row, int count, const QModelIndex &parent);
+ bool removeRows(int row, int count, const QModelIndex &parent);
+ QVariant data(const QModelIndex &index, int role) const;
+// void refresh(QList &anims);
+ Qt::ItemFlags flags(const QModelIndex &index) const {Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+ if (index.column()==1) f = f | Qt::ItemIsEditable;
+ return f;}
+ bool setData(const QModelIndex &index, const QVariant &value, int role);
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+// QStringList waveList();
+
+public slots:
+ //void setLevel(int level) {this->level = level; dataChanged(index(0,0),index(rowCount()-1,1));}
+ void setCurrentWave(QModelIndex = QModelIndex(), QModelIndex b = QModelIndex());
+ void insertAlien(int alId);
+ void removeAlien(QModelIndex index);
+ void clearAliens();
+ void addWave() {int i=0; while(waves.contains(i)) i++;
+ tbWave w; w.id=i; w.prise=0; w.timeout=10; waves.insert(w.id,w);
+ setCurrentWave(index(waves.size()-1,0));}
+ void updateIndex();
+
+
+private:
+ QHash &waves;
+ int curWave;
+ //int level;
+
+};
+
+
+class WaveModel : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ explicit WaveModel(QHash &waves, QObject *parent = 0);
+ int rowCount(const QModelIndex &parent = QModelIndex()) const {return waves.size();}
+ int columnCount(const QModelIndex &parent = QModelIndex()) const {return 4;}
+ //bool insertRows(int row, int count, const QModelIndex &parent);
+ //bool removeRows(int row, int count, const QModelIndex &parent);
+ QVariant data(const QModelIndex &index, int role) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const {Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+ if (index.column()==1||index.column()==2) f = f | Qt::ItemIsEditable;
+ return f;}
+ bool setData(const QModelIndex &index, const QVariant &value, int role);
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+public slots:
+ void addWave(QModelIndex a);
+ void copyWave(QModelIndex a);
+ void removeWave(QModelIndex a);
+ void upWave(QModelIndex a);
+ void downWave(QModelIndex a);
+ void refreshData(bool inverse = false);
+
+private:
+ QHash &waves;
+ QList values;
+signals:
+ void needUpdateIndex();
+
+};
+
+#endif // WAVEMODEL_H
diff --git a/AdServer/AdServer.pro b/AdServer/AdServer.pro
new file mode 100644
index 0000000..06bd6e4
--- /dev/null
+++ b/AdServer/AdServer.pro
@@ -0,0 +1,27 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2012-07-14T18:11:58
+#
+#-------------------------------------------------
+
+QT += core gui network
+
+TARGET = AdServer
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ widget.cpp \
+ server.cpp \
+ connection.cpp \
+ client.cpp \
+ clientbase.cpp
+
+HEADERS += widget.h \
+ server.h \
+ connection.h \
+ client.h \
+ clientbase.h \
+ message.h
+
+FORMS += widget.ui
diff --git a/AdServer/client.cpp b/AdServer/client.cpp
new file mode 100644
index 0000000..6cf9c03
--- /dev/null
+++ b/AdServer/client.cpp
@@ -0,0 +1,16 @@
+#include "client.h"
+
+Client::Client(QObject *parent) :
+ ClientBase(parent)
+{
+ m_socket = new QTcpSocket();
+ connect(m_socket,SIGNAL(readyRead()),this,SLOT(readData()));
+ connect(m_socket,SIGNAL(disconnected()),this,SLOT(Disconnection()));
+}
+
+
+void Client::connectToServer(QHostAddress addr)
+{
+ m_socket->connectToHost(addr,44461);
+}
+
diff --git a/AdServer/client.h b/AdServer/client.h
new file mode 100644
index 0000000..ead18e7
--- /dev/null
+++ b/AdServer/client.h
@@ -0,0 +1,25 @@
+#ifndef CLIENT_H
+#define CLIENT_H
+
+#include
+#include "clientbase.h"
+
+
+class Client : public ClientBase
+{
+ Q_OBJECT
+public:
+ explicit Client(QObject *parent = 0);
+ void connectToServer(QHostAddress addr);
+
+private:
+
+signals:
+
+public slots:
+
+private slots:
+
+};
+
+#endif // CLIENT_H
diff --git a/AdServer/clientbase.cpp b/AdServer/clientbase.cpp
new file mode 100644
index 0000000..461e7ac
--- /dev/null
+++ b/AdServer/clientbase.cpp
@@ -0,0 +1,66 @@
+#include "clientbase.h"
+
+ClientBase::ClientBase(QObject *parent) :
+ QObject(parent)
+{
+}
+
+
+ClientBase::~ClientBase()
+{
+ closeConnection();
+ delete m_socket;
+}
+
+
+void ClientBase::closeConnection()
+{
+ m_socket->disconnectFromHost();
+}
+
+
+QString ClientBase::getStatus()
+{
+ QString s;
+ switch (m_socket->state())
+ {
+ case QAbstractSocket::UnconnectedState :
+ s = trUtf8("not connected");
+ break;
+ case QAbstractSocket::HostLookupState :
+ s = trUtf8("loking for server...");
+ break;
+ case QAbstractSocket::ConnectingState :
+ s = trUtf8("connecting...");
+ break;
+ case QAbstractSocket::ConnectedState :
+ s = trUtf8("connected!");
+ break;
+ case QAbstractSocket::ClosingState :
+ s = trUtf8("disconnecting....");
+ break;
+ default:
+ s = trUtf8("error");
+ }
+ s += trUtf8(" to %1:%2").arg(m_socket->peerAddress().toString()).arg(m_socket->peerPort());
+ return s;
+}
+
+
+void ClientBase::send(const QByteArray &ba)
+{
+ m_socket->write(ba);
+}
+
+
+void ClientBase::readData()
+{
+ QByteArray ba = m_socket->readAll();
+ if (!ba.isEmpty()) emit receive(ba);
+
+}
+
+void ClientBase::Disconnection()
+{
+ emit disconnected();
+}
diff --git a/AdServer/clientbase.h b/AdServer/clientbase.h
new file mode 100644
index 0000000..bdce035
--- /dev/null
+++ b/AdServer/clientbase.h
@@ -0,0 +1,36 @@
+#ifndef CLIENTBASE_H
+#define CLIENTBASE_H
+
+#include
+#include
+#include
+#include
+#include "message.h"
+
+
+class ClientBase : public QObject
+{
+ Q_OBJECT
+public:
+ explicit ClientBase(QObject *parent = 0);
+ ~ClientBase();
+ void closeConnection();
+ QString getStatus();
+ void send(const QByteArray &ba);
+
+public slots:
+
+protected:
+ QTcpSocket * m_socket;
+
+protected slots:
+ virtual void readData();
+ virtual void Disconnection();
+
+signals:
+ void disconnected();
+ void receive(QByteArray ba);
+
+};
+
+#endif // CLIENTBASE_H
diff --git a/AdServer/connection.cpp b/AdServer/connection.cpp
new file mode 100644
index 0000000..137d5c0
--- /dev/null
+++ b/AdServer/connection.cpp
@@ -0,0 +1,11 @@
+#include "connection.h"
+
+Connection::Connection(int id, QTcpSocket *socket, QObject *parent) :
+ ClientBase(parent)
+{
+ m_socket = socket;
+ m_id = id;
+ connect(m_socket,SIGNAL(readyRead()),this,SLOT(readData()));
+ connect(m_socket,SIGNAL(disconnected()),this,SLOT(Disconnection()));
+}
+
diff --git a/AdServer/connection.h b/AdServer/connection.h
new file mode 100644
index 0000000..e80fcc1
--- /dev/null
+++ b/AdServer/connection.h
@@ -0,0 +1,24 @@
+#ifndef CONNECTION_H
+#define CONNECTION_H
+
+#include
+#include "clientbase.h"
+
+
+class Connection : public ClientBase
+{
+ Q_OBJECT
+public:
+ explicit Connection(int id, QTcpSocket * socket, QObject *parent = 0);
+ int Id() const {return m_id;}
+
+private:
+ int m_id;
+
+signals:
+
+private slots:
+
+};
+
+#endif // CONNECTION_H
diff --git a/AdServer/main.cpp b/AdServer/main.cpp
new file mode 100644
index 0000000..eec9938
--- /dev/null
+++ b/AdServer/main.cpp
@@ -0,0 +1,33 @@
+#include
+#include "widget.h"
+//#include "stdafx.h"
+#include "windows.h"
+//#include "iostream.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ Widget w;
+ w.show();
+ WCHAR NameBuffer[MAX_PATH];
+ WCHAR SysNameBuffer[MAX_PATH];
+ DWORD VSNumber;
+ DWORD MCLength;
+ DWORD FileSF;
+
+
+ char *x="D:\\";
+ WCHAR b[10];
+
+ swprintf(b, L"%S", x);
+
+ if (GetVolumeInformation(b,NameBuffer, sizeof(NameBuffer),
+ &VSNumber,&MCLength,&FileSF,SysNameBuffer,sizeof(SysNameBuffer)))
+ {
+ qDebug() << QString::fromWCharArray(NameBuffer);
+ qDebug() << QString::fromWCharArray(SysNameBuffer);
+ qDebug() << VSNumber;
+ }
+
+ return a.exec();
+}
diff --git a/AdServer/message.h b/AdServer/message.h
new file mode 100644
index 0000000..9fca608
--- /dev/null
+++ b/AdServer/message.h
@@ -0,0 +1,37 @@
+#ifndef MESSAGE_H
+#define MESSAGE_H
+
+
+#pragma pack (push, 1)
+
+struct adMessageHeader
+{
+ int type;
+ int player;
+};
+
+
+struct adMessagePing // type = 1
+{
+ adMessageHeader header;
+ char name[32];
+};
+
+
+struct adMessagePong // type = 2
+{
+ adMessageHeader header;
+ int playerId;
+ unsigned int seed;
+};
+
+
+struct adMessageText // type = 3
+{
+ adMessageHeader header;
+ char text[256];
+};
+
+#pragma pack (pop)
+
+#endif // MESSAGE_H
diff --git a/AdServer/release/moc_client.cpp b/AdServer/release/moc_client.cpp
new file mode 100644
index 0000000..5e23a6c
--- /dev/null
+++ b/AdServer/release/moc_client.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'client.h'
+**
+** Created: Tue 8. Jan 13:24:46 2013
+** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "../client.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'client.h' doesn't include ."
+#elif Q_MOC_OUTPUT_REVISION != 63
+#error "This file was generated using the moc from 4.8.1. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_Client[] = {
+
+ // content:
+ 6, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 0, 0, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 0, // signalCount
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_Client[] = {
+ "Client\0"
+};
+
+void Client::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+ Q_UNUSED(_o);
+ Q_UNUSED(_id);
+ Q_UNUSED(_c);
+ Q_UNUSED(_a);
+}
+
+const QMetaObjectExtraData Client::staticMetaObjectExtraData = {
+ 0, qt_static_metacall
+};
+
+const QMetaObject Client::staticMetaObject = {
+ { &ClientBase::staticMetaObject, qt_meta_stringdata_Client,
+ qt_meta_data_Client, &staticMetaObjectExtraData }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &Client::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *Client::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *Client::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_Client))
+ return static_cast(const_cast< Client*>(this));
+ return ClientBase::qt_metacast(_clname);
+}
+
+int Client::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = ClientBase::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ return _id;
+}
+QT_END_MOC_NAMESPACE
diff --git a/AdServer/release/moc_clientbase.cpp b/AdServer/release/moc_clientbase.cpp
new file mode 100644
index 0000000..f700d01
--- /dev/null
+++ b/AdServer/release/moc_clientbase.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'clientbase.h'
+**
+** Created: Tue 8. Jan 13:24:47 2013
+** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "../clientbase.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'clientbase.h' doesn't include ."
+#elif Q_MOC_OUTPUT_REVISION != 63
+#error "This file was generated using the moc from 4.8.1. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_ClientBase[] = {
+
+ // content:
+ 6, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 4, 14, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 2, // signalCount
+
+ // signals: signature, parameters, type, tag, flags
+ 12, 11, 11, 11, 0x05,
+ 30, 27, 11, 11, 0x05,
+
+ // slots: signature, parameters, type, tag, flags
+ 50, 11, 11, 11, 0x09,
+ 61, 11, 11, 11, 0x09,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_ClientBase[] = {
+ "ClientBase\0\0disconnected()\0ba\0"
+ "receive(QByteArray)\0readData()\0"
+ "Disconnection()\0"
+};
+
+void ClientBase::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ Q_ASSERT(staticMetaObject.cast(_o));
+ ClientBase *_t = static_cast(_o);
+ switch (_id) {
+ case 0: _t->disconnected(); break;
+ case 1: _t->receive((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
+ case 2: _t->readData(); break;
+ case 3: _t->Disconnection(); break;
+ default: ;
+ }
+ }
+}
+
+const QMetaObjectExtraData ClientBase::staticMetaObjectExtraData = {
+ 0, qt_static_metacall
+};
+
+const QMetaObject ClientBase::staticMetaObject = {
+ { &QObject::staticMetaObject, qt_meta_stringdata_ClientBase,
+ qt_meta_data_ClientBase, &staticMetaObjectExtraData }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &ClientBase::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *ClientBase::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *ClientBase::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_ClientBase))
+ return static_cast(const_cast< ClientBase*>(this));
+ return QObject::qt_metacast(_clname);
+}
+
+int ClientBase::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QObject::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ if (_id < 4)
+ qt_static_metacall(this, _c, _id, _a);
+ _id -= 4;
+ }
+ return _id;
+}
+
+// SIGNAL 0
+void ClientBase::disconnected()
+{
+ QMetaObject::activate(this, &staticMetaObject, 0, 0);
+}
+
+// SIGNAL 1
+void ClientBase::receive(QByteArray _t1)
+{
+ void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) };
+ QMetaObject::activate(this, &staticMetaObject, 1, _a);
+}
+QT_END_MOC_NAMESPACE
diff --git a/AdServer/release/moc_connection.cpp b/AdServer/release/moc_connection.cpp
new file mode 100644
index 0000000..8a99a91
--- /dev/null
+++ b/AdServer/release/moc_connection.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'connection.h'
+**
+** Created: Tue 8. Jan 13:24:45 2013
+** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "../connection.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'connection.h' doesn't include ."
+#elif Q_MOC_OUTPUT_REVISION != 63
+#error "This file was generated using the moc from 4.8.1. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_Connection[] = {
+
+ // content:
+ 6, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 0, 0, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 0, // signalCount
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_Connection[] = {
+ "Connection\0"
+};
+
+void Connection::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+ Q_UNUSED(_o);
+ Q_UNUSED(_id);
+ Q_UNUSED(_c);
+ Q_UNUSED(_a);
+}
+
+const QMetaObjectExtraData Connection::staticMetaObjectExtraData = {
+ 0, qt_static_metacall
+};
+
+const QMetaObject Connection::staticMetaObject = {
+ { &ClientBase::staticMetaObject, qt_meta_stringdata_Connection,
+ qt_meta_data_Connection, &staticMetaObjectExtraData }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &Connection::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *Connection::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *Connection::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_Connection))
+ return static_cast(const_cast< Connection*>(this));
+ return ClientBase::qt_metacast(_clname);
+}
+
+int Connection::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = ClientBase::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ return _id;
+}
+QT_END_MOC_NAMESPACE
diff --git a/AdServer/release/moc_server.cpp b/AdServer/release/moc_server.cpp
new file mode 100644
index 0000000..6c0c508
--- /dev/null
+++ b/AdServer/release/moc_server.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'server.h'
+**
+** Created: Tue 8. Jan 13:24:44 2013
+** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "../server.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'server.h' doesn't include ."
+#elif Q_MOC_OUTPUT_REVISION != 63
+#error "This file was generated using the moc from 4.8.1. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_Server[] = {
+
+ // content:
+ 6, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 4, 14, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 1, // signalCount
+
+ // signals: signature, parameters, type, tag, flags
+ 11, 8, 7, 7, 0x05,
+
+ // slots: signature, parameters, type, tag, flags
+ 35, 7, 7, 7, 0x08,
+ 51, 7, 7, 7, 0x08,
+ 70, 8, 7, 7, 0x08,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_Server[] = {
+ "Server\0\0ba\0receiveData(QByteArray)\0"
+ "newConnection()\0connectionClosed()\0"
+ "received(QByteArray)\0"
+};
+
+void Server::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ Q_ASSERT(staticMetaObject.cast(_o));
+ Server *_t = static_cast(_o);
+ switch (_id) {
+ case 0: _t->receiveData((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
+ case 1: _t->newConnection(); break;
+ case 2: _t->connectionClosed(); break;
+ case 3: _t->received((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
+ default: ;
+ }
+ }
+}
+
+const QMetaObjectExtraData Server::staticMetaObjectExtraData = {
+ 0, qt_static_metacall
+};
+
+const QMetaObject Server::staticMetaObject = {
+ { &QObject::staticMetaObject, qt_meta_stringdata_Server,
+ qt_meta_data_Server, &staticMetaObjectExtraData }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &Server::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *Server::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *Server::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_Server))
+ return static_cast(const_cast< Server*>(this));
+ return QObject::qt_metacast(_clname);
+}
+
+int Server::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QObject::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ if (_id < 4)
+ qt_static_metacall(this, _c, _id, _a);
+ _id -= 4;
+ }
+ return _id;
+}
+
+// SIGNAL 0
+void Server::receiveData(QByteArray _t1)
+{
+ void *_a[] = { 0, const_cast(reinterpret_cast(&_t1)) };
+ QMetaObject::activate(this, &staticMetaObject, 0, _a);
+}
+QT_END_MOC_NAMESPACE
diff --git a/AdServer/release/moc_widget.cpp b/AdServer/release/moc_widget.cpp
new file mode 100644
index 0000000..595cb4c
--- /dev/null
+++ b/AdServer/release/moc_widget.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'widget.h'
+**
+** Created: Tue 8. Jan 13:24:43 2013
+** by: The Qt Meta Object Compiler version 63 (Qt 4.8.1)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "../widget.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'widget.h' doesn't include ."
+#elif Q_MOC_OUTPUT_REVISION != 63
+#error "This file was generated using the moc from 4.8.1. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_Widget[] = {
+
+ // content:
+ 6, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 9, 14, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 0, // signalCount
+
+ // slots: signature, parameters, type, tag, flags
+ 8, 7, 7, 7, 0x08,
+ 33, 7, 7, 7, 0x08,
+ 60, 7, 7, 7, 0x08,
+ 86, 7, 7, 7, 0x08,
+ 111, 7, 7, 7, 0x08,
+ 134, 7, 7, 7, 0x08,
+ 163, 160, 7, 7, 0x08,
+ 185, 7, 7, 7, 0x08,
+ 205, 7, 7, 7, 0x08,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_Widget[] = {
+ "Widget\0\0on_bpSetServer_clicked()\0"
+ "on_bpStartServer_clicked()\0"
+ "on_pbStopServer_clicked()\0"
+ "on_pbSetClient_clicked()\0"
+ "on_pbConnect_clicked()\0on_pbDisconnect_clicked()\0"
+ "ba\0onReceive(QByteArray)\0on_bpSend_clicked()\0"
+ "on_leText_returnPressed()\0"
+};
+
+void Widget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+{
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ Q_ASSERT(staticMetaObject.cast(_o));
+ Widget *_t = static_cast(_o);
+ switch (_id) {
+ case 0: _t->on_bpSetServer_clicked(); break;
+ case 1: _t->on_bpStartServer_clicked(); break;
+ case 2: _t->on_pbStopServer_clicked(); break;
+ case 3: _t->on_pbSetClient_clicked(); break;
+ case 4: _t->on_pbConnect_clicked(); break;
+ case 5: _t->on_pbDisconnect_clicked(); break;
+ case 6: _t->onReceive((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
+ case 7: _t->on_bpSend_clicked(); break;
+ case 8: _t->on_leText_returnPressed(); break;
+ default: ;
+ }
+ }
+}
+
+const QMetaObjectExtraData Widget::staticMetaObjectExtraData = {
+ 0, qt_static_metacall
+};
+
+const QMetaObject Widget::staticMetaObject = {
+ { &QWidget::staticMetaObject, qt_meta_stringdata_Widget,
+ qt_meta_data_Widget, &staticMetaObjectExtraData }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &Widget::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *Widget::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *Widget::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_Widget))
+ return static_cast(const_cast< Widget*>(this));
+ return QWidget::qt_metacast(_clname);
+}
+
+int Widget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QWidget::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ if (_id < 9)
+ qt_static_metacall(this, _c, _id, _a);
+ _id -= 9;
+ }
+ return _id;
+}
+QT_END_MOC_NAMESPACE
diff --git a/AdServer/server.cpp b/AdServer/server.cpp
new file mode 100644
index 0000000..f108047
--- /dev/null
+++ b/AdServer/server.cpp
@@ -0,0 +1,80 @@
+#include "server.h"
+
+Server::Server(QObject *parent) :
+ QObject(parent)
+{
+ m_server = new QTcpServer(this);
+ next_conn_id = 1;
+ connect(m_server,SIGNAL(newConnection()),this,SLOT(newConnection()));
+}
+
+
+QStringList Server::getIpList()
+{
+ QList list;
+ list = QNetworkInterface::allAddresses();
+ QStringList strl;
+ foreach(QHostAddress adr,list) {
+ if (adr.protocol() == QAbstractSocket::IPv4Protocol)
+ strl.append(adr.toString());
+ }
+ return strl;
+}
+
+
+void Server::startServer(QHostAddress a)
+{
+ m_server->listen(a,44461);
+}
+
+
+void Server::stopServer()
+{
+ m_server->close();
+ foreach (Connection * c, clients)
+ c->closeConnection();
+}
+
+QString Server::getStatus()
+{
+ QString s;
+ if (m_server->isListening())
+ s = trUtf8("Running");
+ else
+ s = trUtf8("Stopped");
+ s += "\n";
+ foreach (Connection * c, clients)
+ s += "\n" + c->getStatus();
+ //s += trUtf8("Connections %1").arg(clients.size());
+ return s;
+}
+
+
+void Server::send(const QByteArray &ba)
+{
+ foreach (Connection * c, clients)
+ c->send(ba);
+}
+
+
+void Server::newConnection()
+{
+ clients.append(new Connection(next_conn_id, m_server->nextPendingConnection()));
+ connect(clients.last(),SIGNAL(disconnected()),this,SLOT(connectionClosed()));
+ connect(clients.last(),SIGNAL(receive(QByteArray)),this,SLOT(received(QByteArray)));
+ next_conn_id++;
+}
+
+
+void Server::connectionClosed()
+{
+ sender()->deleteLater();
+ clients.removeOne((qobject_cast(sender())));
+}
+
+
+void Server::received(QByteArray ba)
+{
+ emit receiveData(ba);
+ send(ba);
+}
diff --git a/AdServer/server.h b/AdServer/server.h
new file mode 100644
index 0000000..e5b17f4
--- /dev/null
+++ b/AdServer/server.h
@@ -0,0 +1,37 @@
+#ifndef SERVER_H
+#define SERVER_H
+
+#include
+#include
+#include
+#include
+#include "connection.h"
+
+
+class Server : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Server(QObject *parent = 0);
+ QStringList getIpList();
+ void startServer(QHostAddress);
+ void stopServer();
+ QString getStatus();
+ void send(const QByteArray &ba);
+
+private:
+ QTcpServer * m_server;
+ QList clients;
+ int next_conn_id;
+
+private slots:
+ void newConnection();
+ void connectionClosed();
+ void received(QByteArray ba);
+
+signals:
+ void receiveData(QByteArray ba);
+
+};
+
+#endif // SERVER_H
diff --git a/AdServer/ui_widget.h b/AdServer/ui_widget.h
new file mode 100644
index 0000000..ac3b5a5
--- /dev/null
+++ b/AdServer/ui_widget.h
@@ -0,0 +1,213 @@
+/********************************************************************************
+** Form generated from reading UI file 'widget.ui'
+**
+** Created: Tue 8. Jan 13:24:36 2013
+** by: Qt User Interface Compiler version 4.8.1
+**
+** WARNING! All changes made in this file will be lost when recompiling UI file!
+********************************************************************************/
+
+#ifndef UI_WIDGET_H
+#define UI_WIDGET_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+QT_BEGIN_NAMESPACE
+
+class Ui_Widget
+{
+public:
+ QGridLayout *gridLayout;
+ QFrame *frameClient;
+ QVBoxLayout *verticalLayout_3;
+ QLineEdit *leIP;
+ QPushButton *pbConnect;
+ QPushButton *pbDisconnect;
+ QLabel *clienStatus;
+ QFrame *frameServer;
+ QVBoxLayout *verticalLayout;
+ QComboBox *cbIPList;
+ QPushButton *bpStartServer;
+ QPushButton *pbStopServer;
+ QLabel *serverStatus;
+ QListWidget *lwText;
+ QFrame *frameMain;
+ QVBoxLayout *verticalLayout_2;
+ QPushButton *bpSetServer;
+ QPushButton *pbSetClient;
+ QFrame *frameSend;
+ QHBoxLayout *horizontalLayout;
+ QLineEdit *leText;
+ QPushButton *bpSend;
+
+ void setupUi(QWidget *Widget)
+ {
+ if (Widget->objectName().isEmpty())
+ Widget->setObjectName(QString::fromUtf8("Widget"));
+ Widget->resize(474, 354);
+ gridLayout = new QGridLayout(Widget);
+ gridLayout->setSpacing(6);
+ gridLayout->setContentsMargins(11, 11, 11, 11);
+ gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
+ frameClient = new QFrame(Widget);
+ frameClient->setObjectName(QString::fromUtf8("frameClient"));
+ frameClient->setFrameShape(QFrame::StyledPanel);
+ frameClient->setFrameShadow(QFrame::Raised);
+ verticalLayout_3 = new QVBoxLayout(frameClient);
+ verticalLayout_3->setSpacing(6);
+ verticalLayout_3->setContentsMargins(11, 11, 11, 11);
+ verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
+ leIP = new QLineEdit(frameClient);
+ leIP->setObjectName(QString::fromUtf8("leIP"));
+
+ verticalLayout_3->addWidget(leIP);
+
+ pbConnect = new QPushButton(frameClient);
+ pbConnect->setObjectName(QString::fromUtf8("pbConnect"));
+
+ verticalLayout_3->addWidget(pbConnect);
+
+ pbDisconnect = new QPushButton(frameClient);
+ pbDisconnect->setObjectName(QString::fromUtf8("pbDisconnect"));
+
+ verticalLayout_3->addWidget(pbDisconnect);
+
+ clienStatus = new QLabel(frameClient);
+ clienStatus->setObjectName(QString::fromUtf8("clienStatus"));
+
+ verticalLayout_3->addWidget(clienStatus);
+
+
+ gridLayout->addWidget(frameClient, 1, 0, 1, 1);
+
+ frameServer = new QFrame(Widget);
+ frameServer->setObjectName(QString::fromUtf8("frameServer"));
+ frameServer->setFrameShape(QFrame::StyledPanel);
+ frameServer->setFrameShadow(QFrame::Raised);
+ verticalLayout = new QVBoxLayout(frameServer);
+ verticalLayout->setSpacing(6);
+ verticalLayout->setContentsMargins(11, 11, 11, 11);
+ verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
+ cbIPList = new QComboBox(frameServer);
+ cbIPList->setObjectName(QString::fromUtf8("cbIPList"));
+
+ verticalLayout->addWidget(cbIPList);
+
+ bpStartServer = new QPushButton(frameServer);
+ bpStartServer->setObjectName(QString::fromUtf8("bpStartServer"));
+
+ verticalLayout->addWidget(bpStartServer);
+
+ pbStopServer = new QPushButton(frameServer);
+ pbStopServer->setObjectName(QString::fromUtf8("pbStopServer"));
+
+ verticalLayout->addWidget(pbStopServer);
+
+ serverStatus = new QLabel(frameServer);
+ serverStatus->setObjectName(QString::fromUtf8("serverStatus"));
+
+ verticalLayout->addWidget(serverStatus);
+
+
+ gridLayout->addWidget(frameServer, 0, 0, 1, 1);
+
+ lwText = new QListWidget(Widget);
+ lwText->setObjectName(QString::fromUtf8("lwText"));
+ lwText->setProperty("isWrapping", QVariant(true));
+ lwText->setResizeMode(QListView::Adjust);
+
+ gridLayout->addWidget(lwText, 0, 2, 3, 1);
+
+ frameMain = new QFrame(Widget);
+ frameMain->setObjectName(QString::fromUtf8("frameMain"));
+ frameMain->setFrameShape(QFrame::StyledPanel);
+ frameMain->setFrameShadow(QFrame::Raised);
+ verticalLayout_2 = new QVBoxLayout(frameMain);
+ verticalLayout_2->setSpacing(6);
+ verticalLayout_2->setContentsMargins(11, 11, 11, 11);
+ verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
+ bpSetServer = new QPushButton(frameMain);
+ bpSetServer->setObjectName(QString::fromUtf8("bpSetServer"));
+ QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
+ sizePolicy.setHorizontalStretch(0);
+ sizePolicy.setVerticalStretch(0);
+ sizePolicy.setHeightForWidth(bpSetServer->sizePolicy().hasHeightForWidth());
+ bpSetServer->setSizePolicy(sizePolicy);
+
+ verticalLayout_2->addWidget(bpSetServer);
+
+ pbSetClient = new QPushButton(frameMain);
+ pbSetClient->setObjectName(QString::fromUtf8("pbSetClient"));
+ sizePolicy.setHeightForWidth(pbSetClient->sizePolicy().hasHeightForWidth());
+ pbSetClient->setSizePolicy(sizePolicy);
+
+ verticalLayout_2->addWidget(pbSetClient);
+
+
+ gridLayout->addWidget(frameMain, 0, 1, 2, 1);
+
+ frameSend = new QFrame(Widget);
+ frameSend->setObjectName(QString::fromUtf8("frameSend"));
+ frameSend->setFrameShape(QFrame::StyledPanel);
+ frameSend->setFrameShadow(QFrame::Raised);
+ horizontalLayout = new QHBoxLayout(frameSend);
+ horizontalLayout->setSpacing(6);
+ horizontalLayout->setContentsMargins(11, 11, 11, 11);
+ horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
+ leText = new QLineEdit(frameSend);
+ leText->setObjectName(QString::fromUtf8("leText"));
+
+ horizontalLayout->addWidget(leText);
+
+ bpSend = new QPushButton(frameSend);
+ bpSend->setObjectName(QString::fromUtf8("bpSend"));
+
+ horizontalLayout->addWidget(bpSend);
+
+
+ gridLayout->addWidget(frameSend, 2, 0, 1, 2);
+
+
+ retranslateUi(Widget);
+
+ QMetaObject::connectSlotsByName(Widget);
+ } // setupUi
+
+ void retranslateUi(QWidget *Widget)
+ {
+ Widget->setWindowTitle(QApplication::translate("Widget", "Widget", 0, QApplication::UnicodeUTF8));
+ leIP->setText(QApplication::translate("Widget", "127.0.0.1", 0, QApplication::UnicodeUTF8));
+ pbConnect->setText(QApplication::translate("Widget", "Connect", 0, QApplication::UnicodeUTF8));
+ pbDisconnect->setText(QApplication::translate("Widget", "Disconnect", 0, QApplication::UnicodeUTF8));
+ clienStatus->setText(QApplication::translate("Widget", "TextLabel", 0, QApplication::UnicodeUTF8));
+ bpStartServer->setText(QApplication::translate("Widget", "Start server", 0, QApplication::UnicodeUTF8));
+ pbStopServer->setText(QApplication::translate("Widget", "Stop server", 0, QApplication::UnicodeUTF8));
+ serverStatus->setText(QApplication::translate("Widget", "TextLabel", 0, QApplication::UnicodeUTF8));
+ bpSetServer->setText(QApplication::translate("Widget", "Server", 0, QApplication::UnicodeUTF8));
+ pbSetClient->setText(QApplication::translate("Widget", "client", 0, QApplication::UnicodeUTF8));
+ bpSend->setText(QApplication::translate("Widget", "Send", 0, QApplication::UnicodeUTF8));
+ } // retranslateUi
+
+};
+
+namespace Ui {
+ class Widget: public Ui_Widget {};
+} // namespace Ui
+
+QT_END_NAMESPACE
+
+#endif // UI_WIDGET_H
diff --git a/AdServer/widget.cpp b/AdServer/widget.cpp
new file mode 100644
index 0000000..24a6489
--- /dev/null
+++ b/AdServer/widget.cpp
@@ -0,0 +1,93 @@
+#include "widget.h"
+#include "ui_widget.h"
+
+Widget::Widget(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::Widget)
+{
+ ui->setupUi(this);
+ ui->frameClient->setVisible(false);
+ ui->frameServer->setVisible(false);
+ ui->frameSend->setVisible(false);
+ ui->lwText->setVisible(false);
+ server = new Server();
+ client = new Client();
+ ui->cbIPList->addItems(server->getIpList());
+ startTimer(40);
+}
+
+
+Widget::~Widget()
+{
+ delete ui;
+}
+
+
+void Widget::timerEvent(QTimerEvent *)
+{
+ ui->serverStatus->setText(server->getStatus());
+ ui->clienStatus->setText(client->getStatus());
+}
+
+
+void Widget::on_bpSetServer_clicked()
+{
+ ui->frameServer->setVisible(true);
+ ui->lwText->setVisible(true);
+ ui->frameMain->setVisible(false);
+// ui->frameSend->setVisible(true);
+ connect(server,SIGNAL(receiveData(QByteArray)),this,SLOT(onReceive(QByteArray)));
+}
+
+
+void Widget::on_bpStartServer_clicked()
+{
+ server->startServer(QHostAddress(ui->cbIPList->currentText()));
+}
+
+
+void Widget::on_pbStopServer_clicked()
+{
+ server->stopServer();
+}
+
+
+void Widget::on_pbSetClient_clicked()
+{
+ ui->frameClient->setVisible(true);
+ ui->lwText->setVisible(true);
+ ui->frameMain->setVisible(false);
+ ui->frameSend->setVisible(true);
+ connect(client,SIGNAL(receive(QByteArray)),this,SLOT(onReceive(QByteArray)));
+}
+
+
+void Widget::on_pbConnect_clicked()
+{
+ client->connectToServer(QHostAddress(ui->leIP->text()));
+}
+
+
+void Widget::on_pbDisconnect_clicked()
+{
+ client->closeConnection();
+}
+
+
+void Widget::onReceive(QByteArray ba)
+{
+ ui->lwText->addItem(QString::fromUtf8(ba.data(),ba.size()));
+}
+
+
+void Widget::on_bpSend_clicked()
+{
+ QByteArray ba = ui->leText->text().toUtf8();
+ client->send(ba);
+}
+
+
+void Widget::on_leText_returnPressed()
+{
+ on_bpSend_clicked();
+}
diff --git a/AdServer/widget.h b/AdServer/widget.h
new file mode 100644
index 0000000..7d0f283
--- /dev/null
+++ b/AdServer/widget.h
@@ -0,0 +1,48 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include
+#include "server.h"
+#include "client.h"
+
+namespace Ui {
+class Widget;
+}
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit Widget(QWidget *parent = 0);
+ ~Widget();
+
+private slots:
+ void on_bpSetServer_clicked();
+
+ void on_bpStartServer_clicked();
+
+ void on_pbStopServer_clicked();
+
+ void on_pbSetClient_clicked();
+
+ void on_pbConnect_clicked();
+
+ void on_pbDisconnect_clicked();
+
+ void onReceive(QByteArray ba);
+
+
+ void on_bpSend_clicked();
+
+ void on_leText_returnPressed();
+
+private:
+ Ui::Widget *ui;
+ Server * server;
+ Client * client;
+
+ void timerEvent(QTimerEvent *);
+};
+
+#endif // WIDGET_H
diff --git a/AdServer/widget.ui b/AdServer/widget.ui
new file mode 100644
index 0000000..492c3b7
--- /dev/null
+++ b/AdServer/widget.ui
@@ -0,0 +1,168 @@
+
+
+ Widget
+
+
+
+ 0
+ 0
+ 474
+ 354
+
+
+
+ Widget
+
+
+ -
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
-
+
+
+ 127.0.0.1
+
+
+
+ -
+
+
+ Connect
+
+
+
+ -
+
+
+ Disconnect
+
+
+
+ -
+
+
+ TextLabel
+
+
+
+
+
+
+ -
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
-
+
+
+ -
+
+
+ Start server
+
+
+
+ -
+
+
+ Stop server
+
+
+
+ -
+
+
+ TextLabel
+
+
+
+
+
+
+ -
+
+
+ true
+
+
+ QListView::Adjust
+
+
+
+ -
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Server
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ client
+
+
+
+
+
+
+ -
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
-
+
+
+ -
+
+
+ Send
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ad_graphics.cpp b/ad_graphics.cpp
index 67f08e5..5aeac74 100644
--- a/ad_graphics.cpp
+++ b/ad_graphics.cpp
@@ -27,6 +27,7 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
mapimg = new QImage(data->map->rect().size()*cellSize,QImage::Format_ARGB32);
//setDragMode(RubberBandDrag);
QPainter p(mapimg);
+ p.setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing);
for (int i=0; imap->cells().size(); i++) {
for (int j=0; jmap->cells().at(i).size(); j++) {
QPen pen;
@@ -42,8 +43,8 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
}
if (cel >= Map::Free || (cel <= Map::PlayerTower && cel !=Map::Wall))
{
- pen.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,150));
- brush.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,80));
+ pen.setColor(QColor(qAbs(cel+2)*345%100,(qAbs(cel+2)*721)%100,(qAbs(cel+2)*75)%100).lighter());
+ brush.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255).lighter());
}
p.setPen(pen);
p.setBrush(brush);
@@ -52,10 +53,11 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
}
p.end();
scene->setSceneRect(mapimg->rect());
- scene->setBackgroundBrush(*mapimg);
+ //scene->setBackgroundBrush(*mapimg);
setCacheMode(QGraphicsView::CacheBackground);
- setRenderHints(QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
+ setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing);
resize(mapimg->size());
+ m_scale.reset();
startTimer(50);
}
@@ -70,22 +72,22 @@ AD_Graphics::~AD_Graphics()
void AD_Graphics::mousePressEvent(QMouseEvent *event)
{
-// scene->clearSelection();
+ // scene->clearSelection();
if (event->button() == Qt::LeftButton)
{
if (m_building)
- emit add_tow((QPointF(event->pos())/cellSize).toPoint(),
+ emit add_tow((QPointF(mapToScene(event->pos())/cellSize).toPoint()),
event->modifiers().testFlag(Qt::ShiftModifier));
else
{
- QList list = scene->items(event->pos(), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
+ QList list = scene->items(mapToScene(event->pos()), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
ADItem * al = 0;
foreach(QGraphicsItem* x, list)
{
ADItem * i = qgraphicsitem_cast(x);
if (i->itemType() == ADItem::Tower)
{
-// i->setSelected(true);
+ // i->setSelected(true);
select_tow = i;
emit selected_tower_changed(i->tid());
return;
@@ -97,7 +99,7 @@ void AD_Graphics::mousePressEvent(QMouseEvent *event)
}
if (al != 0)
{
-// al->setSelected(true);
+ // al->setSelected(true);
select_al = al;
core->addata->players.at(0)->selectAlienId = select_al->id();
return;
@@ -130,17 +132,38 @@ void AD_Graphics::timerEvent(QTimerEvent * )
selection_al->next();
if (core->isWaveEnd())
scene->update();
+ QList moneyitemsdeads;
+ for(int i=0; iopacity();
+ moneyitems[i]->setOpacity(op - (1-op*0.999));
+ moneyitems[i]->moveBy(0.2,-0.4);
+ moneyitems[i]->setScale(moneyitems[i]->scale()+0.1);
+ if (op < 0.1)
+ {
+ moneyitemsdeads.append(i);
+ }
+ }
+ for (int i=0; iremoveItem(moneyitems[i]);
+ delete moneyitems[moneyitemsdeads.at(i)];
+ //moneyitems.removeAt(moneyitemsdeads.at(i));
+ }
}
-void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
+void AD_Graphics::drawBackground(QPainter * p, const QRectF & r)
{
+ p->setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing);
+ p->fillRect(r,Qt::black);
p->drawImage(0,0,*mapimg);
}
void AD_Graphics::drawForeground(QPainter *p, const QRectF &rect)
{
+ p->setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing);
QList l = scene->items();
foreach(QGraphicsItem * g,l)
{
@@ -160,8 +183,15 @@ void AD_Graphics::drawForeground(QPainter *p, const QRectF &rect)
if (focus_item->itemType() == ADItem::Tower)
{
float r = core->addata->curTowers[focus_item->tid()].src->radius*cellSize;
- p->setPen(Qt::black);
- p->setBrush(Qt::NoBrush);
+ QPen pen;
+ QBrush b;
+ b.setStyle(Qt::SolidPattern);
+ b.setColor(QColor(100,240,100,80));
+ pen.setColor(QColor(240,50,50,100));
+ pen.setStyle(Qt::DashDotLine);
+ pen.setWidthF(2.5);
+ p->setPen(pen);
+ p->setBrush(b);
p->drawEllipse(focus_item->pos(), r, r);
}
}
@@ -170,27 +200,55 @@ void AD_Graphics::drawForeground(QPainter *p, const QRectF &rect)
void AD_Graphics::mouseMoveEvent(QMouseEvent *event)
{
- QList li = scene->items(event->pos(), Qt::IntersectsItemBoundingRect, Qt::DescendingOrder);
+ QList li = scene->items(mapToScene(event->pos()), Qt::IntersectsItemBoundingRect, Qt::DescendingOrder);
foreach (QGraphicsItem * i, li) {
if (qgraphicsitem_cast(i)->itemType() == ADItem::Tower) {
focus_item = qgraphicsitem_cast(i);
-// selection_tow->setPos(focus_item->pos());
-// selection_tow->show();
+ // selection_tow->setPos(focus_item->pos());
+ // selection_tow->show();
return;
}
}
-// selection_tow->hide();
+ // selection_tow->hide();
focus_item = 0;
}
-void AD_Graphics::alienKilled(int id)
+void AD_Graphics::alienKilled(int id, bool missed)
{
if (select_al != 0) if (select_al->id() == id) select_al = 0;
+ QPointF alpos = core->addata->aliens->curAliens[id].pos;
+ if (missed)
+ {
+ MoneyItem * lm = new MoneyItem();
+ lm->setPos(QPointF(mapimg->width()/2+qrand()%20,mapimg->height()/2+qrand()%20));
+ lm->setText("missed");
+ lm->setColor(Qt::red);
+ lm->setScale(5);
+ moneyitems.append(lm);
+ scene->addItem(lm);
+ return;
+ }
QPainter p(mapimg);
- p.setCompositionMode(QPainter::CompositionMode_Plus);
- p.translate((core->addata->aliens->curAliens[id].pos+QPointF(0.5,0.5))*cellSize);
+ //p.setCompositionMode(QPainter::CompositionMode_Plus);
+ p.translate((alpos+QPointF(0.5,0.5))*cellSize);
+ p.rotate(qrand()%90);
p.drawImage(core->addata->bloodrect, *(core->addata->blood));
p.end();
resetCachedContent();
+ MoneyItem * m = new MoneyItem();
+ m->setPos(alpos*cellSize);
+ m->setMoney(core->addata->aliens->curAliens[id].src->prise);
+ moneyitems.append(m);
+ scene->addItem(m);
+}
+
+
+void AD_Graphics::resizeEvent(QResizeEvent *event)
+{
+ m_scale.reset();
+ float f = static_cast(qMin(event->size().width(),event->size().height()))/mapimg->size().width();
+ m_scale.scale(f,f);
+ setTransform(m_scale);
+ repaint();
}
diff --git a/ad_graphics.h b/ad_graphics.h
index 1644688..e505180 100644
--- a/ad_graphics.h
+++ b/ad_graphics.h
@@ -7,6 +7,7 @@
#include
#include "adcore.h"
+#include "moneyitem.h"
class AD_Graphics: public QGraphicsView
@@ -23,7 +24,7 @@ public:
public slots:
void selectTower(ADItem * item) {select_tow = item;}
void setBuilding(bool arg) {m_building = arg;}
- void alienKilled(int id);
+ void alienKilled(int id, bool missed);
void towerKilled(QPoint id) {focus_item = 0; if (select_tow != 0) if (select_tow->tid() == id) {select_tow = 0; emit selected_tower_changed(QPoint());}}
private:
@@ -31,6 +32,7 @@ private:
void drawForeground(QPainter *painter, const QRectF &rect);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
+ void resizeEvent(QResizeEvent *event);
QGraphicsScene * scene;
AD_Core * core;
@@ -42,7 +44,9 @@ private:
ADItem * selection_tow;
ADItem * selection_al;
QEasingCurve color_curve;
+// QList moneyitems;
+ QTransform m_scale;
bool m_building;
protected:
diff --git a/adcore.cpp b/adcore.cpp
index f196b3a..556a173 100644
--- a/adcore.cpp
+++ b/adcore.cpp
@@ -88,7 +88,10 @@ void AD_Core::waveProcessing()
void AD_Core::killAlien(int playerId, int alienId)
{
- addata->players[playerId]->money += addata->aliens->curAliens[alienId].src->prise;
+// qDebug() << playerId << alienId;
+ Player * pl = addata->players[playerId];
+ pl->money += addata->aliens->curAliens[alienId].src->prise;
+ pl->stats.killed_aliens++;
addata->aliens->delAlien(alienId);
}
diff --git a/aliendefender.pro b/aliendefender.pro
index 956c8bb..14e58a7 100644
--- a/aliendefender.pro
+++ b/aliendefender.pro
@@ -11,7 +11,9 @@ HEADERS += base_types.h \
form.h \
aditem.h \
touchbuttframe.h \
- touch_butt.h
+ touch_butt.h \
+ statuswidget.h \
+ moneyitem.h
SOURCES += map.cpp \
game_data.cpp \
aliens.cpp \
@@ -25,7 +27,9 @@ SOURCES += map.cpp \
form.cpp \
aditem.cpp \
touchbuttframe.cpp \
- touch_butt.cpp
+ touch_butt.cpp \
+ statuswidget.cpp \
+ moneyitem.cpp
RESOURCES += images.qrc
OTHER_FILES += schema.xml \
data2.xml
@@ -38,3 +42,7 @@ QT += core \
FORMS += \
form.ui
+
+
+
+
diff --git a/aliendefender.pro.user b/aliendefender.pro.user
index ca40126..f3cb8ac 100644
--- a/aliendefender.pro.user
+++ b/aliendefender.pro.user
@@ -1,6 +1,6 @@
-
+
ProjectExplorer.Project.ActiveTarget
@@ -11,139 +11,110 @@
true
false
+ false
Cpp
- true
- CppProject
- false
- false
- true
- false
- false
- false
- false
- true
- false
- true
- false
- false
- false
- true
- false
+ CppGlobal
- 1
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
UTF-8
- Project
+ false
4
+ false
true
1
true
- false
+ 0
true
-
- Cpp
-
- true
- false
- CppGlobal
- 4
- 1
- false
- true
- 0
- 8
-
-
-
- QmlJS
-
- true
- false
- QmlJSGlobal
- 4
- 1
- false
- true
- 0
- 8
-
-
- 2
0
- 4
- false
+ 8
+ true
1
true
true
true
- true
+ false
+
+ ProjectExplorer.Project.PluginSettings
+
+
ProjectExplorer.Project.Target.0
-
-
- Qt4ProjectManager.Target.DesktopTarget
+ Desktop
+ Desktop
+ {3afe59ac-faaf-4693-8ea4-2d027b7a8039}
1
0
0
- ProjectExplorer.ToolChain.Mingw:D:/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.D:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe
+ D:/build-aliendefender-Desktop-Release
+ true
qmake
QtProjectManager.QMakeBuildStep
false
- false
+ true
false
+ true
Сборка
Qt4ProjectManager.MakeStep
+
false
2
- Build
- Build
+ Сборка
+
ProjectExplorer.BuildSteps.Build
+ true
Сборка
Qt4ProjectManager.MakeStep
+
true
clean
1
- Clean
- Clean
+ Очистка
+
ProjectExplorer.BuildSteps.Clean
2
false
- Qt 4.7.4 for Desktop - MinGW 4.4 (Qt SDK) Отладка
- Debug
+ Выпуск
+
Qt4ProjectManager.Qt4BuildConfiguration
- 2
- D:/Dropbox/My Dropbox/projects/aliendefender-build-desktop
- 1
- false
+ 0
+ true
- ProjectExplorer.ToolChain.Mingw:D:/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.D:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe
+ D:/build-aliendefender-Desktop-d
+ true
qmake
QtProjectManager.QMakeBuildStep
@@ -153,134 +124,77 @@
false
+ true
Сборка
Qt4ProjectManager.MakeStep
+
false
2
- Build
- Build
+ Сборка
+
ProjectExplorer.BuildSteps.Build
+ true
Сборка
Qt4ProjectManager.MakeStep
+
true
-
+ clean
1
- Clean
- Clean
+ Очистка
+
ProjectExplorer.BuildSteps.Clean
2
false
- Qt 4.7.4 for Desktop - MinGW 4.4 (Qt SDK) Релиз
- Release
+ d
+
Qt4ProjectManager.Qt4BuildConfiguration
- 0
- D:/Dropbox/My Dropbox/projects/aliendefender-build-desktop
- 1
- false
+ 2
+ true
2
0
Установка
- Deploy
+
ProjectExplorer.BuildSteps.Deploy
1
- Без установки
- Без установки
+ Локальная установка
+
ProjectExplorer.DefaultDeployConfiguration
1
+
- true
- true
-
-
- false
- false
- false
- false
- false
- false
- false
- false
- true
- true
- 0.01
- 0.01
- 10
- 10
- true
- true
- 25
- 25
-
-
- true
- true
- valgrind
- valgrind
-
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
-
-
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
-
- Конфигурация запуска Qt4
- aliendefender
- Qt4ProjectManager.Qt4RunConfiguration
- 2
+ 2
+
+ aliendefender
+
+ Qt4ProjectManager.Qt4RunConfiguration:D:/aliendefender/aliendefender.pro
aliendefender.pro
false
false
-
3768
true
+ false
+ false
false
- false
+ true
1
@@ -291,10 +205,10 @@
ProjectExplorer.Project.Updater.EnvironmentId
- {4b0390db-ed56-4643-8092-f257ef99d7b5}
+ {d4869220-1aa4-4b0e-aa71-93573ae12656}
ProjectExplorer.Project.Updater.FileVersion
- 10
+ 15
diff --git a/aliendefender.pro.user.2.3pre1 b/aliendefender.pro.user.2.3pre1
index e629697..e6673ef 100644
--- a/aliendefender.pro.user.2.3pre1
+++ b/aliendefender.pro.user.2.3pre1
@@ -1,4 +1,6 @@
+
+
ProjectExplorer.Project.ActiveTarget
@@ -7,166 +9,245 @@
ProjectExplorer.Project.EditorSettings
- true
- false
- System
- false
- false
- 4
- true
- 1
- true
- false
- false
- 0
- 4
- true
- 1
- true
- true
- true
- false
+ true
+ false
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ System
+ false
+ 4
+ true
+ 1
+ true
+ 0
+ false
+ 0
+ 4
+ true
+ 1
+ true
+ true
+ true
+ false
+
+ ProjectExplorer.Project.PluginSettings
+
+
ProjectExplorer.Project.Target.0
-
-
- Qt4ProjectManager.Target.DesktopTarget
- 1
- 0
- 0
-
- ProjectExplorer.ToolChain.Mingw:D:/Qt/2010.04/mingw/bin/g++.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe
-
-
- qmake
-
- QtProjectManager.QMakeBuildStep
- false
-
- false
+ Desktop
+ Desktop
+ Qt4ProjectManager.Target.DesktopTarget
+ 1
+ 0
+ 0
+
+ ProjectExplorer.ToolChain.Mingw:D:/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.D:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe
+
+
+ qmake
+
+ QtProjectManager.QMakeBuildStep
+ false
+ false
+
+ false
-
- Сборка
-
- Qt4ProjectManager.MakeStep
- false
-
-
+
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+ false
+
+
- 2
- Build
- Build
- ProjectExplorer.BuildSteps.Build
+ 2
+ Сборка
+
+ ProjectExplorer.BuildSteps.Build
-
-
- Сборка
-
- Qt4ProjectManager.MakeStep
- true
- clean
-
+
+
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+ true
+ clean
+
- 1
- Clean
- Clean
- ProjectExplorer.BuildSteps.Clean
+ 1
+ Очистка
+
+ ProjectExplorer.BuildSteps.Clean
- 2
- false
-
- Debug
- Debug
- Qt4ProjectManager.Qt4BuildConfiguration
- 2
- D:/Dropbox/My Dropbox/projects/aliendefender-build-desktop
- 5
- ProjectExplorer.ToolChain.Mingw:D:/Qt/2010.04/mingw/bin/g++.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe
- false
+ 2
+ false
+
+ Qt 4.8.1 for Desktop - MinGW (Qt SDK) Релиз
+
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ /home/andrey/aliendefender
+ 3
+ false
-
- ProjectExplorer.ToolChain.Mingw:C:/Qt/qtcreator-2.2.0/mingw/bin/gcc.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe
-
-
- qmake
-
- QtProjectManager.QMakeBuildStep
- false
-
- false
+
+ ProjectExplorer.ToolChain.Mingw:D:/QtSDK/mingw/bin/mingw32-make.exe.x86-windows-msys-pe-32bit.D:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe
+
+
+ qmake
+
+ QtProjectManager.QMakeBuildStep
+ false
+ false
+
+ false
-
- Сборка
-
- Qt4ProjectManager.MakeStep
- false
-
-
+
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+ false
+
+
- 2
- Build
- Build
- ProjectExplorer.BuildSteps.Build
+ 2
+ Сборка
+
+ ProjectExplorer.BuildSteps.Build
-
-
- Сборка
-
- Qt4ProjectManager.MakeStep
- true
-
-
+
+
+ Сборка
+
+ Qt4ProjectManager.MakeStep
+ true
+ clean
+
- 1
- Clean
- Clean
- ProjectExplorer.BuildSteps.Clean
+ 1
+ Очистка
+
+ ProjectExplorer.BuildSteps.Clean
- 2
- false
-
- Release
- Release
- Qt4ProjectManager.Qt4BuildConfiguration
- 0
- D:/Dropbox/My Dropbox/projects/aliendefender-build-desktop
- 5
- ProjectExplorer.ToolChain.Mingw:C:/Qt/qtcreator-2.2.0/mingw/bin/gcc.exe.x86-windows-msys-pe-32bit.C:/Qt/qtcreator-2.2.0/pythongdb/gdb-i686-pc-mingw32.exe
- false
+ 2
+ false
+
+ Qt 4.8.1 for Desktop - MinGW (Qt SDK) Отладка
+
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+ /home/andrey/aliendefender
+ 3
+ false
- 2
-
-
- 0
- Установка
- Deploy
- ProjectExplorer.BuildSteps.Deploy
+ 2
+
+
+ 0
+ Установка
+
+ ProjectExplorer.BuildSteps.Deploy
- 1
- Без установки
- Без установки
- ProjectExplorer.DefaultDeployConfiguration
+ 1
+ Без установки
+
+ ProjectExplorer.DefaultDeployConfiguration
- 1
-
- Конфигурация запуска Qt4
- aliendefender
- Qt4ProjectManager.Qt4RunConfiguration
- 2
-
- aliendefender.pro
- false
- false
-
-
- 3768
- true
- false
+ 1
+
+ true
+ true
+
+
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ true
+ true
+ 0.01
+ 0.01
+ 10
+ 10
+ true
+ true
+ 25
+ 25
+
+
+ true
+ true
+ valgrind
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+ aliendefender
+
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ aliendefender.pro
+ false
+ false
+
+
+ 3768
+ true
+ false
+ false
- 1
+ 1
@@ -175,10 +256,10 @@
ProjectExplorer.Project.Updater.EnvironmentId
- {0f364aaa-5a2f-49c5-b7a5-6b296e2f6fd0}
+ {8144fe46-f732-4d02-8f44-6da2f1f5dd44}
ProjectExplorer.Project.Updater.FileVersion
- 9
+ 10
diff --git a/aliens.cpp b/aliens.cpp
index 620de65..0a89e7e 100644
--- a/aliens.cpp
+++ b/aliens.cpp
@@ -60,7 +60,7 @@ void Aliens::retrace(bool * OK)
void Aliens::delAlien(int id, bool missed)
{
- emit alien_killed(id);
+ emit alien_killed(id,missed);
if (missed)
{
m_missingAliens++;
diff --git a/aliens.h b/aliens.h
index 8ab6ff2..24e505d 100644
--- a/aliens.h
+++ b/aliens.h
@@ -20,7 +20,7 @@ public:
int missingAliens() {return m_missingAliens;}
signals:
- void alien_killed(int id);
+ void alien_killed(int id, bool missed);
public slots:
void delAlien(int id, bool missed = false);
diff --git a/base_types.h b/base_types.h
index aa2ad38..8cd76cb 100644
--- a/base_types.h
+++ b/base_types.h
@@ -42,6 +42,15 @@ struct srcAlienType
struct AlienType
{
+ AlienType ()
+ {
+ id = -1;
+ src = 0;
+ pos = QPointF();
+ wave = -1;
+ item = 0;
+ }
+
int id; // uses for QHash
int wave;
srcAlienType * src;
@@ -117,7 +126,7 @@ struct srcTowerType
QString name;
QImage * image;
int imgType;
- int PlayerId; // tower's owner
+ //int PlayerId; // tower's owner
unsigned int cost;
unsigned int reload;
unsigned int buildTime;
diff --git a/data2.xml b/data2.xml
index 30917ad..d8ceead 100644
--- a/data2.xml
+++ b/data2.xml
@@ -1,88 +1,161 @@
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -110,9 +183,6 @@
-
-
-
@@ -122,24 +192,45 @@
-
-
+
+
+
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
@@ -149,27 +240,50 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
@@ -182,7 +296,18 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/form.cpp b/form.cpp
index d17dc67..72c7eca 100644
--- a/form.cpp
+++ b/form.cpp
@@ -42,7 +42,7 @@ Form::Form(QWidget *parent) :
connect(morphtbf,SIGNAL(click(int)),this,SLOT(towerMorph(int)));
connect(graphics,SIGNAL(add_tow(QPoint,bool)),this,SLOT(add_tow(QPoint,bool)));
// connect(core.adtowers,SIGNAL(tower_killed(QPoint)),graphics,SLOT(towerKilled(QPoint)));
- connect(core.addata->aliens,SIGNAL(alien_killed(int)),graphics,SLOT(alienKilled(int)));
+ connect(core.addata->aliens,SIGNAL(alien_killed(int,bool)),graphics,SLOT(alienKilled(int,bool)));
connect(graphics,SIGNAL(cancel()),this,SLOT(cancel()));
connect(graphics,SIGNAL(selected_tower_changed(QPoint)),this,SLOT(selectedTowerChanged(QPoint)));
this->startTimer(50);
diff --git a/form.ui b/form.ui
index f750905..071c4fe 100644
--- a/form.ui
+++ b/form.ui
@@ -13,119 +13,126 @@
Form
-
-
- 0
-
+
-
-
-
-
- 2
-
-
-
-
- -
-
-
- Towers
+
+
+ Qt::Horizontal
-
-
- 0
+
+
+
+ 2
+
+
+
+
+
+ Towers
-
- 0
-
-
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ -
+
+
+ TextLabel
+
+
+ Qt::PlainText
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
+
+
+
+ -
+
+
+ Next wave
+
+
+
+ -
+
+
+ speed
+
+
+ x
+
+
+ 1
+
+
+ 0.100000000000000
+
+
+ 0.500000000000000
+
+
+ 1.000000000000000
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ Sell
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
- -
-
-
-
-
-
- TextLabel
-
-
- Qt::PlainText
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
-
-
-
- -
-
-
- Next wave
-
-
-
- -
-
-
- speed
-
-
- x
-
-
- 1
-
-
- 0.100000000000000
-
-
- 0.500000000000000
-
-
- 1.000000000000000
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Preferred
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Sell
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Preferred
-
-
-
- 20
- 40
-
-
-
-
-
-
diff --git a/loader.cpp b/loader.cpp
index e130681..2f1477a 100644
--- a/loader.cpp
+++ b/loader.cpp
@@ -1,5 +1,7 @@
#include "loader.h"
+bool tbWaveOnLevel_lessThan(const tbWaveOnLevel &a, const tbWaveOnLevel &b) {return a.waveId < b.waveId;}
+
Loader::Loader()
{
doc = new QDomDocument("data");
@@ -30,7 +32,7 @@ void Loader::load(QString filename)
readLevTowers();
readMorphs();
readWaves();
- readWaveParts();
+ // readWaveParts();
readLevWaves();
file->close();
@@ -93,6 +95,15 @@ void Loader::save(QString filename)
elem.setAttribute("id",w.id);
elem.setAttribute("prise",w.prise);
elem.setAttribute("timeout",w.timeout);
+ QDomElement cc;
+ for (int k=0; kplayers.append(pl);
+ gd->players.at(i)->money = levels.value(id).money/tbm.maxPlayers;
}
qDebug() << gd->players.size();
for (int i=0; imaxPlayers(); ++i)
@@ -332,41 +345,42 @@ Game_Data * Loader::loadlevel(int id)
QList wollist = levWaves.values(id);
if (wollist.isEmpty())
{
- qCritical() << tr("Error no waves on level!");
+ qCritical() << tr("Error: no waves on level!");
return 0;
}
tbWave tbw;
tbWavePart tbwpt;
- QList wplist;
+ //QList wplist;
QList alienIds;
QList animIds;
+ qSort(wollist.begin(),wollist.end(),tbWaveOnLevel_lessThan);
for (int i=0; iwaves.prepend(wt);
+ gd->waves.append(wt);
qDebug() << tr("load wave #%1 prise=%2 timeout=%3").arg(i+1).arg(wt.prise).arg(wt.timeout) << wt.types << wt.counts;
- wplist.clear();
+ //wplist.clear();
}
wollist.clear();
for (int i=0; ialiens->srcAliens.append(salt);
- qDebug() << tr("Alien %1 #%2 ").arg(salt.name).arg(i);
+ //qDebug() << tr("Alien %1 #%2 ").arg(salt.name).arg(i);
}
QList tollist = levTowers.values(id);
tbTower tbt;
@@ -462,7 +476,7 @@ Game_Data * Loader::loadlevel(int id)
{
piForeachA (j, morph_indexes[i])
{
- int index = (int)j.morph;
+ long int index = (long int)j.morph;
for (int k=0; kmaxPlayers(); ++k)
{
j.morph = &(gd->players[k]->srcTowers[index]);
@@ -607,10 +621,10 @@ void Loader::fillTowerChains(QList * animIds, QList * chlist,
QString Loader::createMapExample()
{
QVector < QVector < int > > Cells;
- Cells.resize(25);
+ Cells.resize(32);
for (int i=0; ielementsByTagName("wavePart");
- for (int i=0; ielementsByTagName("wavePart");
+// for (int i=0; i parts;
};
struct tbWaveOnLevel
@@ -134,6 +135,7 @@ struct tbLevel : tbHeader
{
int mapId;
unsigned int score;
+ unsigned int money;
};
struct tbAnimation : tbHeader
@@ -159,7 +161,7 @@ public:
QHash waves;
QHash animations;
QMultiHash levWaves;
- QMultiHash waveParts;
+// QMultiHash waveParts;
QMultiHash chains;
QMultiHash morphs;
QMultiHash levTowers;
@@ -180,7 +182,7 @@ private:
void readChains();
void readWaves();
void readLevWaves();
- void readWaveParts();
+// void readWaveParts();
void readUpgrades();
void readAnimations();
diff --git a/moneyitem.cpp b/moneyitem.cpp
new file mode 100644
index 0000000..48557b2
--- /dev/null
+++ b/moneyitem.cpp
@@ -0,0 +1,25 @@
+#include "moneyitem.h"
+#include
+#include
+
+MoneyItem::MoneyItem(QGraphicsItem *parent) : QGraphicsItem(parent)
+{
+ money = 0;
+ br = QRectF(0,0,100,50);
+ pen.setColor(Qt::yellow);
+ pen.setWidthF(2.5);
+}
+
+
+void MoneyItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ painter->setPen(pen);
+ if (str.isEmpty()) painter->drawText(br,Qt::AlignLeft, "+" + QString::number(money) + "$");
+ else painter->drawText(br,Qt::AlignLeft, str);
+}
+
+
+QRectF MoneyItem::boundingRect() const
+{
+ return br;
+}
diff --git a/moneyitem.h b/moneyitem.h
new file mode 100644
index 0000000..c54c2c8
--- /dev/null
+++ b/moneyitem.h
@@ -0,0 +1,25 @@
+#ifndef MONEYITEM_H
+#define MONEYITEM_H
+
+#include
+#include
+
+class MoneyItem : public QGraphicsItem
+{
+public:
+ explicit MoneyItem(QGraphicsItem *parent = 0);
+ QRectF boundingRect() const;
+ void setMoney(unsigned long long int val) {money = val;}
+ void setText(const QString &text) {str = text;}
+ void setColor(const QColor &color) {pen.setColor(color);}
+
+private:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+ unsigned long long int money;
+ QString str;
+ QRectF br;
+ QPen pen;
+};
+
+#endif // MONEYITEM_H
diff --git a/player.cpp b/player.cpp
index 1a012d0..4d7daa1 100644
--- a/player.cpp
+++ b/player.cpp
@@ -4,6 +4,6 @@ Player::Player(int Id, QObject *parent) :
QObject(parent)
{
playerId = Id;
- money = 100;
+ money = 0;
selectAlienId = -1;
}
diff --git a/player.h b/player.h
index 7e2884c..282db77 100644
--- a/player.h
+++ b/player.h
@@ -5,14 +5,26 @@
class Player : public QObject
{
-Q_OBJECT
+ Q_OBJECT
public:
- explicit Player(int Id, QObject *parent = 0);
- long long int money;
- unsigned long int score;
- int selectAlienId;
- QList srcTowers;
- int playerId;
+ struct PlayerStats
+ {
+ int killed_aliens;
+ int builded_towers;
+ int spend_money;
+ double all_damage;
+ double player_experience;
+ };
+
+ explicit Player(int Id, QObject *parent = 0);
+ long long int money;
+ unsigned long int score;
+ int selectAlienId;
+ QList srcTowers;
+ int playerId;
+ QString name;
+ PlayerStats stats;
+
signals:
public slots:
diff --git a/schema.xml b/schema.xml
index 80d7228..62ef6ad 100644
--- a/schema.xml
+++ b/schema.xml
@@ -32,13 +32,13 @@
-
+
@@ -217,7 +217,7 @@
-
+
@@ -229,6 +229,9 @@
+
+
+
@@ -251,6 +254,7 @@
+
diff --git a/splashes.cpp b/splashes.cpp
index a5edd7a..ff156d0 100644
--- a/splashes.cpp
+++ b/splashes.cpp
@@ -54,7 +54,8 @@ void Splashes::addSplash(srcTowerType *srctower, int id, QPointF pos, QPointF de
else spl.src = &(gameData->srcSplashes[id]);
spl.id = nextId;
spl.towerId = towerId;
- spl.PlayerId = srctower->PlayerId;
+ //qDebug() << "player"<< srctower->PlayerId;
+ spl.PlayerId = gameData->curTowers[towerId].PlayerId;
spl.AlienId = aim;
spl.pos = pos;
spl.destination = dest;
@@ -125,11 +126,13 @@ void Splashes::update()
bool keep = spl->src->keepOnAlien;
if (spl->src->keepOnAlien)
{
+// qDebug() << "keep on alien start";
if (gameData->aliens->curAliens.contains(spl->AlienId))
{
spl->pos = gameData->aliens->curAliens[spl->AlienId].pos;
spl->angle = gameData->aliens->curAliens[spl->AlienId].angle;
} else deadIndexes.insert(spl->id,spl->id);
+// qDebug() << "keep on alien done";
} else {
if (spl->src->autoControl && spl->AlienId != -1)
{
@@ -178,10 +181,14 @@ void Splashes::update()
for (QHash::iterator j = dead.begin();
j != dead.end(); ++j)
{
+// qDebug() << j->tower;
gameData->curTowers[j->tower].experience += gameData->curTowers[j->tower].src->expByKill;
+// qDebug() << "emit1";
emit killAlien(j->player,j->id);
+// qDebug() << "emit2";
}
dead.clear();
+// qDebug() << "finish";
}
@@ -200,6 +207,7 @@ void Splashes::doTriggerOnTimer(QHash::iterator
for(QList::iterator i = spl->trigsOnTimer.begin();
i != spl->trigsOnTimer.end(); ++i)
{
+// qDebug() << "timer trigger start";
srcTriggerType * strig = i->src;
i->timer++;
if (i->timer >= strig->timer)
@@ -215,8 +223,11 @@ void Splashes::doTriggerOnTimer(QHash::iterator
if (gameData->aliens->curAliens.contains(spl->AlienId))
{
hh = gameData->aliens->curAliens[spl->AlienId].health -= dmg;
+// qDebug() << "shot from" << spl->towerId << spl->AlienId;
if (hh <= 0) dead.insert(spl->AlienId, DeadAlienIndex(spl->AlienId, spl->PlayerId, spl->towerId));
else gameData->curTowers[spl->towerId].experience += hh * gameData->curTowers[spl->towerId].src->expByDamage;
+ } else {
+ deadIndexes->insert(spl->id,spl->id);
}
} else {
for (QHash::iterator
@@ -251,6 +262,7 @@ void Splashes::doTriggerOnTimer(QHash::iterator
}
}
}
+// qDebug() << "timer trigger stop";
}
}
@@ -317,12 +329,12 @@ void Splashes::doTriggerOnDest(QHash::iterator
void Splashes::doTriggerOnAlien(QHash::iterator spl, QHash *deadIndexes)
{
- foreach(TriggerOnAlien t, spl->trigsOnAlien)
+ for (int n=0; ntrigsOnAlien.size(); n++)
{
+ TriggerOnAlien * t = &spl->trigsOnAlien[n];
/// TODO: different aims for childs
- if (t.src->delParent) deadIndexes->insert(spl->id,spl->id);
- float dmg = t.src->damage;
- float rad = t.src->radius;
+ float dmg = t->src->damage;
+ float rad = t->src->radius;
if (dmg > 0 && rad > 0)
{
float hh;
@@ -330,24 +342,25 @@ void Splashes::doTriggerOnAlien(QHash::iterator spl, QHashaliens->curAliens.begin();
i != gameData->aliens->curAliens.end(); ++i)
{
- if (distance2(spl->pos, i->pos) < rad*rad)
+ if (distance2(spl->pos, i->pos) < rad*rad && !t->triggerAliens.contains(i->id))
{
+ if (t->src->delParent) deadIndexes->insert(spl->id,spl->id);
hh = i->health -= dmg;
if (hh <= 0) dead.insert(i->id, DeadAlienIndex(i->id, spl->PlayerId, spl->towerId));
else gameData->curTowers[spl->towerId].experience += hh * gameData->curTowers[spl->towerId].src->expByDamage;
- if (t.src->count > 0 && t.src->childId > 0)
+ if (t->src->count > 0 && t->src->childId > 0)
{
- if (!t.triggerAliens.contains(i->id))
- {
- for (int j=0; jcount; ++j)
+// if (!t.triggerAliens.contains(i->id))
+// {
+ for (int j=0; jsrc->count; ++j)
{
/// TODO: randomRadiusPos
- addSplash(spl->srcTow,t.src->childId,
+ addSplash(spl->srcTow,t->src->childId,
spl->pos,i->pos,i->id,spl->towerId);
}
- t.triggerAliens.append(i->id);
- }
+// }
}
+ t->triggerAliens.append(i->id);
}
}
}
diff --git a/statuswidget.cpp b/statuswidget.cpp
new file mode 100644
index 0000000..fd8e3f4
--- /dev/null
+++ b/statuswidget.cpp
@@ -0,0 +1,5 @@
+#include "statuswidget.h"
+
+Statuswidget::Statuswidget()
+{
+}
diff --git a/statuswidget.h b/statuswidget.h
new file mode 100644
index 0000000..ec6eec4
--- /dev/null
+++ b/statuswidget.h
@@ -0,0 +1,12 @@
+#ifndef STATUSWIDGET_H
+#define STATUSWIDGET_H
+
+#include
+
+class Statuswidget : public QGraphicsWidget
+{
+public:
+ Statuswidget();
+};
+
+#endif // STATUSWIDGET_H
diff --git a/towers.cpp b/towers.cpp
index 11da53c..88def49 100644
--- a/towers.cpp
+++ b/towers.cpp
@@ -48,6 +48,8 @@ bool Towers::addTower(int playerId, int srcId, QPoint pos)
scene->addItem(tw.item);
gameData->curTowers.insert(tw.pos,tw);
p->money -= tw.src->cost;
+ p->stats.spend_money += tw.src->cost;
+ p->stats.builded_towers++;
return true;
}
return false;
@@ -106,13 +108,20 @@ void Towers::update()
{
AlienType al = gameData->aliens->curAliens.value(gameData->players.at(i->PlayerId)->selectAlienId);
if (distance2(al.pos+QPointF(0.5f,0.5f), i->pos) < rad2) i->aim = al.id;
+ else i->aim = -1;
+ }
+ if (i->aim == 0)
+ {
+ qDebug() << tr("err tower") << i->pos << gameData->players.at(i->PlayerId)->selectAlienId;
+ qFatal("tower has incorrect aim = 0");
+ return;
}
if (i->aim < 0)
{
for (QHash::iterator j = gameData->aliens->curAliens.begin(); j != gameData->aliens->curAliens.end(); ++j)
{
- float dist = distance2(i->pos, (*j).pos+QPointF(0.5f,0.5f));
- if (dist < rad2) i->aim = (*j).id;
+ float dist = distance2(i->pos, j->pos+QPointF(0.5f,0.5f));
+ if (dist < rad2) i->aim = j->id;
}
}
if (i->aim > 0)
@@ -144,6 +153,7 @@ bool Towers::morphTower(QPoint id, int index)
// tower_killed(id);
TowerType & t(gameData->curTowers[id]);
gameData->players[t.PlayerId]->money -= t.src->morphs[index].cost;
+ gameData->players[t.PlayerId]->stats.spend_money += t.src->morphs[index].cost;
t.src = t.src->morphs[index].morph;
t.build = 0;
t.reload = 0;