diff --git a/ADeditor/ADeditor.pro b/ADeditor/ADeditor.pro index 606bb6b..51a612b 100644 --- a/ADeditor/ADeditor.pro +++ b/ADeditor/ADeditor.pro @@ -17,7 +17,9 @@ SOURCES += main.cpp \ triggermodel.cpp \ mapmodel.cpp \ animationmodel.cpp \ - animlabel.cpp + animlabel.cpp \ + ../aliens.cpp \ + ../aditem.cpp HEADERS += mainwindow.h \ ../loader.h \ alienmodel.h \ @@ -30,9 +32,13 @@ HEADERS += mainwindow.h \ triggermodel.h \ mapmodel.h \ animationmodel.h \ - animlabel.h + animlabel.h \ + ../aliens.h \ + ../aditem.h FORMS += mainwindow.ui TRANSLATIONS += adeditor_ru.ts RESOURCES += ADeditor.qrc OTHER_FILES += ../schema.xml \ ../data2.xml + + diff --git a/ADeditor/ADeditor.pro.user b/ADeditor/ADeditor.pro.user index a597870..478d1f2 100644 --- a/ADeditor/ADeditor.pro.user +++ b/ADeditor/ADeditor.pro.user @@ -1,287 +1,300 @@ + + - RunConfiguration0-BaseEnvironmentBase - 2 - - - RunConfiguration0-CommandLineArguments - - - - RunConfiguration0-ProFile - ADeditor.pro - - - RunConfiguration0-RunConfiguration.name - ADeditor - - - RunConfiguration0-UseDyldImageSuffix - false - - - RunConfiguration0-UseTerminal - false - - - RunConfiguration0-UserEnvironmentChanges - - - - RunConfiguration0-UserSetName - false - - - RunConfiguration0-UserSetWorkingDirectory - true - - - RunConfiguration0-UserWorkingDirectory - /home/andrey/AD/aliendefender - - - RunConfiguration0-type - Qt4ProjectManager.Qt4RunConfiguration - - - activeRunConfiguration + ProjectExplorer.Project.ActiveTarget 0 - activebuildconfiguration - Debug - - - buildConfiguration-Debug + ProjectExplorer.Project.EditorSettings - Debug - 0 - 0 - - 2 + true + false + + Cpp + + false + CppGlobal + true + false + true + false + false + false + true + true + false + true + false + false + false + true + false + + + 1 + UTF-8 + Global + 4 + true + 1 + true + false + 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 + 1 + true + true + true + false - buildConfiguration-Release + ProjectExplorer.Project.Target.0 - Release - 0 - - 0 + Desktop + Desktop + Qt4ProjectManager.Target.DesktopTarget + 1 + 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 + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Сборка + + Qt4ProjectManager.MakeStep + false + + + + 2 + Сборка + + ProjectExplorer.BuildSteps.Build + + + + Сборка + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Очистка + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + qt Отладка + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + C:/Users/Andrey/Desktop/aliendefender/ADeditor + 7 + false + + + 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 + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Сборка + + Qt4ProjectManager.MakeStep + false + + + + 2 + Сборка + + ProjectExplorer.BuildSteps.Build + + + + Сборка + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Очистка + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + qt Релиз + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + C:/Users/Andrey/Desktop/aliendefender/ADeditor + 7 + false + + 2 + + + 0 + Установка + + 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 + + ADeditor + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + ADeditor.pro + false + false + + C:/Users/Andrey/Desktop/aliendefender + 3768 + true + false + false + + 1 - buildconfiguration-Debug-buildstep0 - - Debug - - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-2HAd2azpnh,guid=fd81c6d6610b4c57717ec20c4c90d3de - DEFAULTS_PATH=/usr/share/gconf/gnome.default.path - DESKTOP_SESSION=gnome - DISPLAY=:0.0 - GDMSESSION=gnome - GDM_KEYBOARD_LAYOUT=us - GDM_LANG=ru_RU.UTF-8 - GNOME_DESKTOP_SESSION_ID=this-is-deprecated - GNOME_KEYRING_CONTROL=/tmp/keyring-vNW3fv - GTK_MODULES=canberra-gtk-module - HOME=/home/andrey - LANG=ru_RU.UTF-8 - LD_LIBRARY_PATH=/usr/lib/qtcreator: - LOGNAME=andrey - MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path - ORBIT_SOCKETDIR=/tmp/orbit-andrey - PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games - PWD=/home/andrey - QTDIR=/usr/share/qt4 - SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1158,unix/buull-eeePC:/tmp/.ICE-unix/1158 - SHELL=/bin/bash - SPEECHD_PORT=6561 - SSH_AGENT_PID=1195 - SSH_AUTH_SOCK=/tmp/keyring-vNW3fv/ssh - USER=andrey - USERNAME=andrey - XAUTHORITY=/var/run/gdm/auth-for-andrey-Len9P0/database - XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg - XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ - XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1284559837.801731-819619931 - - - /home/andrey/AD/aliendefender/ADeditor/ADeditor.pro - -spec - linux-g++ - -r - CONFIG+=debug - - /usr/bin/qmake-qt4 - false - /home/andrey/AD/aliendefender/ADeditor - + ProjectExplorer.Project.TargetCount + 1 - buildconfiguration-Debug-buildstep1 - - Debug - - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-2HAd2azpnh,guid=fd81c6d6610b4c57717ec20c4c90d3de - DEFAULTS_PATH=/usr/share/gconf/gnome.default.path - DESKTOP_SESSION=gnome - DISPLAY=:0.0 - GDMSESSION=gnome - GDM_KEYBOARD_LAYOUT=us - GDM_LANG=ru_RU.UTF-8 - GNOME_DESKTOP_SESSION_ID=this-is-deprecated - GNOME_KEYRING_CONTROL=/tmp/keyring-vNW3fv - GTK_MODULES=canberra-gtk-module - HOME=/home/andrey - LANG=ru_RU.UTF-8 - LD_LIBRARY_PATH=/usr/lib/qtcreator: - LOGNAME=andrey - MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path - ORBIT_SOCKETDIR=/tmp/orbit-andrey - PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games - PWD=/home/andrey - QTDIR=/usr/share/qt4 - SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1158,unix/buull-eeePC:/tmp/.ICE-unix/1158 - SHELL=/bin/bash - SPEECHD_PORT=6561 - SSH_AGENT_PID=1195 - SSH_AUTH_SOCK=/tmp/keyring-vNW3fv/ssh - USER=andrey - USERNAME=andrey - XAUTHORITY=/var/run/gdm/auth-for-andrey-Len9P0/database - XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg - XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ - XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1284559837.801731-819619931 - - false - - -j2 - -w - - /usr/bin/make - true - /home/andrey/AD/aliendefender/ADeditor - - -j2 - - + ProjectExplorer.Project.Updater.EnvironmentId + {6c550070-c96c-41ad-865e-c5b9b5c3b79f} - buildconfiguration-Debug-cleanstep0 - - Debug - - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wExeabp7q4,guid=18815993df3603fdc64a3f6d4c7b5822 - DEFAULTS_PATH=/usr/share/gconf/gnome.default.path - DESKTOP_SESSION=gnome - DISPLAY=:0.0 - GDMSESSION=gnome - GDM_KEYBOARD_LAYOUT=us - GDM_LANG=ru_RU.UTF-8 - GNOME_DESKTOP_SESSION_ID=this-is-deprecated - GNOME_KEYRING_CONTROL=/tmp/keyring-4vN5uf - GTK_MODULES=canberra-gtk-module - HOME=/home/andrey - LANG=ru_RU.UTF-8 - LD_LIBRARY_PATH=/usr/lib/qtcreator: - LOGNAME=andrey - MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path - ORBIT_SOCKETDIR=/tmp/orbit-andrey - PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games - PWD=/home/andrey - QTDIR=/usr/share/qt4 - SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205 - SHELL=/bin/bash - SPEECHD_PORT=6561 - SSH_AGENT_PID=1239 - SSH_AUTH_SOCK=/tmp/keyring-4vN5uf/ssh - USER=andrey - USERNAME=andrey - XAUTHORITY=/var/run/gdm/auth-for-andrey-x9URui/database - XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg - XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ - XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283151906.338331-318132279 - - true - - clean - -w - - /usr/bin/make - true - /home/andrey/AD/aliendefender/ADeditor - true - - clean - - - - - buildconfiguration-Release-buildstep0 - - Release - - - - buildconfiguration-Release-buildstep1 - - Release - - - - buildconfiguration-Release-cleanstep0 - - Release - - - - buildconfigurations - - Debug - Release - - - - buildstep0 - - - - - - - buildstep1 - - - - - - buildsteps - - trolltech.qt4projectmanager.qmake - trolltech.qt4projectmanager.make - - - - cleanstep0 - - - true - - - - cleansteps - - trolltech.qt4projectmanager.make - - - - defaultFileEncoding - UTF-8 - - - project - + ProjectExplorer.Project.Updater.FileVersion + 10 diff --git a/ADeditor/ADeditor.pro.user.1.3 b/ADeditor/ADeditor.pro.user.1.3 index 86b2921..a597870 100644 --- a/ADeditor/ADeditor.pro.user.1.3 +++ b/ADeditor/ADeditor.pro.user.1.3 @@ -34,11 +34,11 @@ RunConfiguration0-UserSetWorkingDirectory - false + true RunConfiguration0-UserWorkingDirectory - + /home/andrey/AD/aliendefender RunConfiguration0-type @@ -76,7 +76,7 @@ Debug - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-7vJZaf9AwI,guid=f26a2301f932cefdec6dd3bc4c79669f + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-2HAd2azpnh,guid=fd81c6d6610b4c57717ec20c4c90d3de DEFAULTS_PATH=/usr/share/gconf/gnome.default.path DESKTOP_SESSION=gnome DISPLAY=:0.0 @@ -84,7 +84,7 @@ GDM_KEYBOARD_LAYOUT=us GDM_LANG=ru_RU.UTF-8 GNOME_DESKTOP_SESSION_ID=this-is-deprecated - GNOME_KEYRING_CONTROL=/tmp/keyring-U899U4 + GNOME_KEYRING_CONTROL=/tmp/keyring-vNW3fv GTK_MODULES=canberra-gtk-module HOME=/home/andrey LANG=ru_RU.UTF-8 @@ -95,17 +95,17 @@ PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games PWD=/home/andrey QTDIR=/usr/share/qt4 - SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1236,unix/buull-eeePC:/tmp/.ICE-unix/1236 + SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1158,unix/buull-eeePC:/tmp/.ICE-unix/1158 SHELL=/bin/bash SPEECHD_PORT=6561 - SSH_AGENT_PID=1270 - SSH_AUTH_SOCK=/tmp/keyring-U899U4/ssh + SSH_AGENT_PID=1195 + SSH_AUTH_SOCK=/tmp/keyring-vNW3fv/ssh USER=andrey USERNAME=andrey - XAUTHORITY=/var/run/gdm/auth-for-andrey-6T6AjI/database + XAUTHORITY=/var/run/gdm/auth-for-andrey-Len9P0/database XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ - XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283024543.354844-1194058895 + XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1284559837.801731-819619931 /home/andrey/AD/aliendefender/ADeditor/ADeditor.pro @@ -124,7 +124,7 @@ Debug - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-7vJZaf9AwI,guid=f26a2301f932cefdec6dd3bc4c79669f + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-2HAd2azpnh,guid=fd81c6d6610b4c57717ec20c4c90d3de DEFAULTS_PATH=/usr/share/gconf/gnome.default.path DESKTOP_SESSION=gnome DISPLAY=:0.0 @@ -132,7 +132,7 @@ GDM_KEYBOARD_LAYOUT=us GDM_LANG=ru_RU.UTF-8 GNOME_DESKTOP_SESSION_ID=this-is-deprecated - GNOME_KEYRING_CONTROL=/tmp/keyring-U899U4 + GNOME_KEYRING_CONTROL=/tmp/keyring-vNW3fv GTK_MODULES=canberra-gtk-module HOME=/home/andrey LANG=ru_RU.UTF-8 @@ -143,25 +143,29 @@ PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games PWD=/home/andrey QTDIR=/usr/share/qt4 - SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1236,unix/buull-eeePC:/tmp/.ICE-unix/1236 + SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1158,unix/buull-eeePC:/tmp/.ICE-unix/1158 SHELL=/bin/bash SPEECHD_PORT=6561 - SSH_AGENT_PID=1270 - SSH_AUTH_SOCK=/tmp/keyring-U899U4/ssh + SSH_AGENT_PID=1195 + SSH_AUTH_SOCK=/tmp/keyring-vNW3fv/ssh USER=andrey USERNAME=andrey - XAUTHORITY=/var/run/gdm/auth-for-andrey-6T6AjI/database + XAUTHORITY=/var/run/gdm/auth-for-andrey-Len9P0/database XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ - XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283024543.354844-1194058895 + XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1284559837.801731-819619931 false + -j2 -w /usr/bin/make true /home/andrey/AD/aliendefender/ADeditor + + -j2 + @@ -169,7 +173,7 @@ Debug - DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-7vJZaf9AwI,guid=f26a2301f932cefdec6dd3bc4c79669f + DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wExeabp7q4,guid=18815993df3603fdc64a3f6d4c7b5822 DEFAULTS_PATH=/usr/share/gconf/gnome.default.path DESKTOP_SESSION=gnome DISPLAY=:0.0 @@ -177,7 +181,7 @@ GDM_KEYBOARD_LAYOUT=us GDM_LANG=ru_RU.UTF-8 GNOME_DESKTOP_SESSION_ID=this-is-deprecated - GNOME_KEYRING_CONTROL=/tmp/keyring-U899U4 + GNOME_KEYRING_CONTROL=/tmp/keyring-4vN5uf GTK_MODULES=canberra-gtk-module HOME=/home/andrey LANG=ru_RU.UTF-8 @@ -188,17 +192,17 @@ PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games PWD=/home/andrey QTDIR=/usr/share/qt4 - SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1236,unix/buull-eeePC:/tmp/.ICE-unix/1236 + SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205 SHELL=/bin/bash SPEECHD_PORT=6561 - SSH_AGENT_PID=1270 - SSH_AUTH_SOCK=/tmp/keyring-U899U4/ssh + SSH_AGENT_PID=1239 + SSH_AUTH_SOCK=/tmp/keyring-4vN5uf/ssh USER=andrey USERNAME=andrey - XAUTHORITY=/var/run/gdm/auth-for-andrey-6T6AjI/database + XAUTHORITY=/var/run/gdm/auth-for-andrey-x9URui/database XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/ - XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283024543.354844-1194058895 + XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283151906.338331-318132279 true @@ -274,7 +278,7 @@ defaultFileEncoding - System + UTF-8 project diff --git a/ADeditor/ADeditor.qrc b/ADeditor/ADeditor.qrc index f807fe2..573cf69 100644 --- a/ADeditor/ADeditor.qrc +++ b/ADeditor/ADeditor.qrc @@ -10,4 +10,7 @@ icons/view-refresh.png icons/edit.png + + ../schema.xml + diff --git a/ADeditor/animationmodel.cpp b/ADeditor/animationmodel.cpp index c07339a..0ba27c6 100644 --- a/ADeditor/animationmodel.cpp +++ b/ADeditor/animationmodel.cpp @@ -1,35 +1,42 @@ #include "animationmodel.h" -AnimationModel::AnimationModel(QList manims, QObject *parent) : - QAbstractListModel(parent) +AnimationModel::AnimationModel(QHash &manims, QObject *parent) : + QAbstractListModel(parent), anims(manims) { - anims = manims; +// anims = manims; } -void AnimationModel::refresh(QListmanims) -{ - anims = manims; -} +//void AnimationModel::refresh(QListmanims) +//{ +// anims = manims; +//} int AnimationModel::rowCount(const QModelIndex &) const { - return anims.count(); + return anims.count(); } QVariant AnimationModel::data(const QModelIndex &index, int role) const { - if (!index.isValid()) - return QVariant(); - - if (index.row() >= anims.size()) - return QVariant(); - - if (role == Qt::DisplayRole) - { - return anims.at(index.row()).id; - } - return QVariant(); + if (!index.isValid()) return QVariant(); + if (index.row() >= anims.size()) return QVariant(); + if (role == Qt::DisplayRole) + return tr("(%1) ").arg(anims.values().at(index.row()).id) + anims[anims.values().at(index.row()).id].name; + if (role == Qt::EditRole) + return anims[anims.values().at(index.row()).id].name; + return QVariant(); +} + + +bool AnimationModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (role != Qt::EditRole) return false; + if (!index.isValid()) return false; + if (index.row() >= anims.size()) return false; + anims[anims.values().at(index.row()).id].name = value.toString(); + emit dataChanged(index, index); + return true; } diff --git a/ADeditor/animationmodel.h b/ADeditor/animationmodel.h index 24bf755..b60892f 100644 --- a/ADeditor/animationmodel.h +++ b/ADeditor/animationmodel.h @@ -8,17 +8,18 @@ class AnimationModel : public QAbstractListModel { Q_OBJECT public: - explicit AnimationModel(QList anims, QObject *parent = 0); - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role) const; - void refresh(QList anims); - + explicit AnimationModel(QHash &anims, QObject *parent = 0); + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; +// void refresh(QList &anims); + Qt::ItemFlags flags(const QModelIndex &) const {return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;} + bool setData(const QModelIndex &index, const QVariant &value, int role); signals: public slots: private: - QList anims; + QHash &anims; }; #endif // ANIMATIONMODEL_H diff --git a/ADeditor/mainwindow.cpp b/ADeditor/mainwindow.cpp index 65ab9e0..31616f2 100644 --- a/ADeditor/mainwindow.cpp +++ b/ADeditor/mainwindow.cpp @@ -6,1180 +6,1277 @@ #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"))); - ui->pbReload->setIcon(QIcon::fromTheme("edit-undo", QIcon(":/icons/icons/edit-undo.png"))); - ui->pbAlAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png"))); - ui->pbAlDel->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png"))); - ui->pbTrigAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png"))); - ui->pbTrigDel->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png"))); - ui->pbTwAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png"))); - ui->pbTwDel->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png"))); - ui->pbMapAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png"))); - ui->pbMapDelete->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png"))); - ui->pbSplAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png"))); - 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->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"))); - ui->pbMapEdit->setIcon(QIcon::fromTheme("edit", QIcon(":/icons/icons/edit.png"))); - adloader = new Loader(this); - adloader->load("data2.xml"); + ui->setupUi(this); + ui->pbSave->setIcon(QIcon::fromTheme("document-save", QIcon(":/icons/icons/document-save.png"))); + ui->pbReload->setIcon(QIcon::fromTheme("edit-undo", QIcon(":/icons/icons/edit-undo.png"))); + ui->pbAlAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png"))); + ui->pbAlDel->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png"))); + ui->pbTrigAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png"))); + ui->pbTrigDel->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png"))); + ui->pbTwAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png"))); + ui->pbTwDel->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png"))); + ui->pbMapAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png"))); + ui->pbMapDelete->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/icons/list-remove.png"))); + ui->pbSplAdd->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/icons/list-add.png"))); + 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->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"))); + ui->pbMapEdit->setIcon(QIcon::fromTheme("edit", QIcon(":/icons/icons/edit.png"))); + adloader = new Loader(this); + adloader->load("data2.xml"); - animModel = new AnimationModel(adloader->animations.values()); - ui->lvAnimations->setModel((QAbstractItemModel * )animModel); - connect(ui->lvAnimations->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)),this,SLOT(lvAnimations_select(QModelIndex, QModelIndex))); - ui->lvAnimations->selectionModel()->setCurrentIndex(ui->lvAnimations->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + animModel = new AnimationModel(adloader->animations); + ui->lvAnimations->setModel((QAbstractItemModel * )animModel); + connect(ui->lvAnimations->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)),this,SLOT(lvAnimations_select(QModelIndex, QModelIndex))); + ui->lvAnimations->selectionModel()->setCurrentIndex(ui->lvAnimations->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - mapScene = new QGraphicsScene(); - ui->gvMap->setScene(mapScene); - ui->gvMap->scale(10,10); + mapScene = new QGraphicsScene(); + ui->gvMap->setScene(mapScene); + ui->gvMap->scale(10,10); - mapModel = new MapModel(adloader->maps.values()); - ui->lvMaps->setModel((QAbstractItemModel * )mapModel); - connect(ui->lvMaps->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvMaps_select(QModelIndex, QModelIndex))); - ui->lvMaps->selectionModel()->setCurrentIndex(ui->lvMaps->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + mapModel = new MapModel(adloader->maps.values()); + ui->lvMaps->setModel((QAbstractItemModel * )mapModel); + connect(ui->lvMaps->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvMaps_select(QModelIndex, QModelIndex))); + ui->lvMaps->selectionModel()->setCurrentIndex(ui->lvMaps->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - alModel = new AlienModel(adloader->aliens.values()); - ui->lvAliens->setModel((QAbstractItemModel * )alModel); - ui->cbAlImage->setModel((QAbstractItemModel * )animModel); - 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); + alModel = new AlienModel(adloader->aliens.values()); + ui->lvAliens->setModel((QAbstractItemModel * )alModel); + ui->cbAlImage->setModel((QAbstractItemModel * )animModel); + 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); - splModel = new SplashModel(adloader->splashes.values()); - ui->lvSplashes->setModel((QAbstractItemModel * )splModel); - ui->cbSplImage->setModel((QAbstractItemModel * )animModel); - connect(ui->lvSplashes->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvSplashes_select(QModelIndex, QModelIndex))); - ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + splModel = new SplashModel(adloader->splashes.values()); + ui->lvSplashes->setModel((QAbstractItemModel * )splModel); + ui->cbSplImage->setModel((QAbstractItemModel * )animModel); + connect(ui->lvSplashes->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvSplashes_select(QModelIndex, QModelIndex))); + ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - twModel = new TowerModel(adloader->towers.values()); - ui->lvTowers->setModel((QAbstractItemModel * )twModel); - ui->cbTwSplash->setModel((QAbstractItemModel * )splModel); - ui->cbTwImage->setModel((QAbstractItemModel * )animModel); - connect(ui->lvTowers->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvTowers_select(QModelIndex, QModelIndex))); - ui->lvTowers->selectionModel()->setCurrentIndex(ui->lvTowers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + twModel = new TowerModel(adloader->towers.values()); + ui->lvTowers->setModel((QAbstractItemModel * )twModel); + ui->cbTwSplash->setModel((QAbstractItemModel * )splModel); + ui->cbTwImage->setModel((QAbstractItemModel * )animModel); + connect(ui->lvTowers->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvTowers_select(QModelIndex, QModelIndex))); + ui->lvTowers->selectionModel()->setCurrentIndex(ui->lvTowers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - trigModel = new TriggerModel(adloader->triggers.values()); - ui->lvTriggers->setModel((QAbstractItemModel * )trigModel); - connect(ui->lvTriggers->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvTriggers_select(QModelIndex,QModelIndex))); - ui->lvTriggers->selectionModel()->setCurrentIndex(ui->lvTriggers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - ui->cbTrigChildAim->addItem(tr("no aim"),QVariant(srcTriggerType::noAim)); - ui->cbTrigChildAim->addItem(tr("random side"),QVariant(srcTriggerType::allSide)); - ui->cbTrigChildAim->addItem(tr("parent aim"),QVariant(srcTriggerType::parentAim)); - ui->cbTrigChildAim->addItem(tr("nearlest alien"),QVariant(srcTriggerType::nearlestAlien)); - ui->cbTrigType->addItem(tr("on destination"),QVariant(srcTriggerType::onDestination)); - ui->cbTrigType->addItem(tr("on alien in radius"),QVariant(srcTriggerType::onAlienInRadius)); - ui->cbTrigType->addItem(tr("on timer"),QVariant(srcTriggerType::onTimer)); - isSaved = true; - QSettings sett("Alien_Defender","aliendefender"); - this->restoreGeometry(sett.value("session/geometry").toByteArray()); - this->restoreState(sett.value("session/mainwindow").toByteArray()); - ui->splitter->restoreState(sett.value("session/split1").toByteArray()); - ui->splitter_2->restoreState(sett.value("session/split2").toByteArray()); - ui->splitter_3->restoreState(sett.value("session/split3").toByteArray()); - ui->splitter_4->restoreState(sett.value("session/split4").toByteArray()); - ui->splitter_5->restoreState(sett.value("session/split5").toByteArray()); - ui->splitter_6->restoreState(sett.value("session/split6").toByteArray()); - ui->tabWidget->setCurrentIndex(sett.value("session/tab").toInt()); - //alb = new AnimLabel(); - //ui->verticalLayout->addWidget(alb); - //alb->setAnimation(adloader->animations.value(1).pathes); + trigModel = new TriggerModel(adloader->triggers.values()); + ui->lvTriggers->setModel((QAbstractItemModel * )trigModel); + connect(ui->lvTriggers->selectionModel(),SIGNAL(currentChanged(QModelIndex, QModelIndex)),this,SLOT(lvTriggers_select(QModelIndex,QModelIndex))); + ui->lvTriggers->selectionModel()->setCurrentIndex(ui->lvTriggers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + ui->cbTrigChildAim->addItem(tr("no aim"),QVariant(srcTriggerType::noAim)); + ui->cbTrigChildAim->addItem(tr("random side"),QVariant(srcTriggerType::allSide)); + ui->cbTrigChildAim->addItem(tr("parent aim"),QVariant(srcTriggerType::parentAim)); + ui->cbTrigChildAim->addItem(tr("nearest alien"),QVariant(srcTriggerType::nearestAlien)); + ui->cbTrigType->addItem(tr("on destination"),QVariant(srcTriggerType::onDestination)); + ui->cbTrigType->addItem(tr("on alien in radius"),QVariant(srcTriggerType::onAlienInRadius)); + ui->cbTrigType->addItem(tr("on timer"),QVariant(srcTriggerType::onTimer)); + isSaved = true; + QSettings sett("Alien_Defender","aliendefender"); + this->restoreGeometry(sett.value("session/geometry").toByteArray()); + this->restoreState(sett.value("session/mainwindow").toByteArray()); + ui->splitter->restoreState(sett.value("session/split1").toByteArray()); + ui->splitter_2->restoreState(sett.value("session/split2").toByteArray()); + ui->splitter_3->restoreState(sett.value("session/split3").toByteArray()); + ui->splitter_4->restoreState(sett.value("session/split4").toByteArray()); + ui->splitter_5->restoreState(sett.value("session/split5").toByteArray()); + ui->splitter_6->restoreState(sett.value("session/split6").toByteArray()); + ui->tabWidget->setCurrentIndex(sett.value("session/tab").toInt()); + //alb = new AnimLabel(); + //ui->verticalLayout->addWidget(alb); + //alb->setAnimation(adloader->animations.value(1).pathes); } MainWindow::~MainWindow() { - delete ui; + delete ui; } void MainWindow::changeEvent(QEvent *e) { - QMainWindow::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } + QMainWindow::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } } void MainWindow::on_cbAlArmor_toggled(bool checked) { - int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; - float lval = adloader->aliens[id].armor; - ui->sbAlArmor->setEnabled(checked); - if (checked) adloader->aliens[id].armor = ui->sbAlArmor->value(); - else adloader->aliens[id].armor = 0; - if (lval != adloader->aliens[id].armor) isSaved = false; + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + float lval = adloader->aliens[id].armor; + ui->sbAlArmor->setEnabled(checked); + if (checked) adloader->aliens[id].armor = ui->sbAlArmor->value(); + else adloader->aliens[id].armor = 0; + if (lval != adloader->aliens[id].armor) isSaved = false; } void MainWindow::on_cbAlRegeneration_toggled(bool checked) { - int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; - float lval = adloader->aliens[id].regeneration; - ui->sbAlregeneration->setEnabled(checked); - if (checked) adloader->aliens[id].regeneration = ui->sbAlregeneration->value(); - else adloader->aliens[id].regeneration = 0; - if (lval != adloader->aliens[id].regeneration) isSaved = false; + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + float lval = adloader->aliens[id].regeneration; + ui->sbAlregeneration->setEnabled(checked); + if (checked) adloader->aliens[id].regeneration = ui->sbAlregeneration->value(); + else adloader->aliens[id].regeneration = 0; + if (lval != adloader->aliens[id].regeneration) isSaved = false; } void MainWindow::lvAnimations_select(QModelIndex index, QModelIndex) { - if (index.isValid()) - { - ui->lwImages->clear(); - refresh_lwImages(adloader->animations.values().at(index.row()).pathes); - } + if (index.isValid()) + { + ui->lwImages->clear(); + refresh_lwImages(adloader->animations.values().at(index.row()).pathes); + } } void MainWindow::lvAliens_select(QModelIndex index, QModelIndex) { - if (index.isValid()) - { - tbAlien al = adloader->aliens.values().at(index.row()); - ui->leAlName->setText(al.name); - ui->sbAlHealth->setValue(al.health); - ui->sbAlArmor->setValue(al.armor); - if (al.armor > 0) ui->cbAlArmor->setChecked(true); - else ui->cbAlArmor->setChecked(false); - ui->sbAlSpeed->setValue(al.speed); - ui->sbAlPrise->setValue(al.prise); - ui->sbAlregeneration->setValue(al.regeneration); - if (al.regeneration > 0) ui->cbAlRegeneration->setChecked(true); - else ui->cbAlRegeneration->setChecked(false); - ui->sbAlScore->setValue(al.score); - ui->cbAlIsFly->setChecked(al.isFlying); - ui->cbAlImage->setCurrentIndex(adloader->animations.keys().indexOf(al.imgType)); - ui->lbAlAnim->setAnimation(adloader->animations.value(al.imgType).pathes); - } + if (index.isValid()) + { + tbAlien al = adloader->aliens.values().at(index.row()); + ui->leAlName->setText(al.name); + ui->sbAlHealth->setValue(al.health); + ui->sbAlArmor->setValue(al.armor); + if (al.armor > 0) ui->cbAlArmor->setChecked(true); + else ui->cbAlArmor->setChecked(false); + ui->sbAlSpeed->setValue(al.speed); + ui->sbAlPrise->setValue(al.prise); + ui->sbAlregeneration->setValue(al.regeneration); + if (al.regeneration > 0) ui->cbAlRegeneration->setChecked(true); + else ui->cbAlRegeneration->setChecked(false); + ui->sbAlScore->setValue(al.score); + ui->cbAlIsFly->setChecked(al.isFlying); + ui->cbAlImage->setCurrentIndex(adloader->animations.keys().indexOf(al.imgType)); + ui->lbAlAnim->setAnimation(adloader->animations.value(al.imgType).pathes); + } } void MainWindow::lvMaps_select(QModelIndex index, QModelIndex) { - if (index.isValid()) - { - tbMap map = adloader->maps.values().at(index.row()); - ui->leMapName->setText(map.name); - ui->sbMapHei->setValue(map.size.height()); - ui->sbMapWid->setValue(map.size.width()); - ui->sbMapPlayers->setValue(map.maxPlayers); - Map m(map.data,map.size,map.name,map.maxPlayers,map.imgType); - QPixmap pix(map.size); - QPainter p(&pix); - p.fillRect(m.rect(),Qt::white); - for (int i=0; i= 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,200)); - p.setPen(pen); - p.drawPoint(i,j); - } - } - p.end(); - mapScene->clear(); - mapScene->addPixmap(pix); - ui->gvMap->centerOn(0,0); - //ui->gvMap->resetCachedContent(); - //ui->pbMapEdit->setIcon(QIcon(pix)); - } + if (index.isValid()) + { + tbMap map = adloader->maps.values().at(index.row()); + ui->leMapName->setText(map.name); + ui->sbMapHei->setValue(map.size.height()); + ui->sbMapWid->setValue(map.size.width()); + ui->sbMapPlayers->setValue(map.maxPlayers); + Map m(map.data,map.size,map.name,map.maxPlayers,map.imgType); + QPixmap pix(map.size); + QPainter p(&pix); + p.fillRect(m.rect(),Qt::white); + for (int i=0; i= 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,200)); + p.setPen(pen); + p.drawPoint(i,j); + } + } + p.end(); + mapScene->clear(); + mapScene->addPixmap(pix); + ui->gvMap->centerOn(0,0); + //ui->gvMap->resetCachedContent(); + //ui->pbMapEdit->setIcon(QIcon(pix)); + } } void MainWindow::lvTowers_select(QModelIndex index, QModelIndex) { - if (index.isValid()) - { - tbTower tw = adloader->towers.values().at(index.row()); - ui->sbTwBuildTime->setValue(tw.buildTime); - ui->sbTwCost->setValue(tw.cost); - ui->sbTwExpByDam->setValue(tw.expByDamage); - if (tw.expByDamage > 0) - ui->cbTwExpByDam->setChecked(true); - else - ui->cbTwExpByDam->setChecked(false); - ui->sbTwExpByKill->setValue(tw.expByKill); - if (tw.expByKill > 0) - ui->cbTwExpByKill->setChecked(true); - else - ui->cbTwExpByKill->setChecked(false); - ui->sbTwExpByShot->setValue(tw.expByShot); - if (tw.expByShot > 0) - ui->cbTwExpByShot->setChecked(true); - else - ui->cbTwExpByShot->setChecked(false); - ui->leTwName->setText(tw.name); - ui->sbTwRadius->setValue(tw.radius); - ui->sbTwReload->setValue(tw.reload); - ui->cbTwSplash->setCurrentIndex(adloader->splashes.keys().indexOf(tw.splashId)); - ui->cbTwImage->setCurrentIndex(adloader->animations.keys().indexOf(tw.imgType)); - ui->lbTwAnim->setAnimation(adloader->animations.value(tw.imgType).pathes); - } + if (index.isValid()) + { + tbTower tw = adloader->towers.values().at(index.row()); + ui->sbTwBuildTime->setValue(tw.buildTime); + ui->sbTwCost->setValue(tw.cost); + ui->sbTwExpByDam->setValue(tw.expByDamage); + if (tw.expByDamage > 0) + ui->cbTwExpByDam->setChecked(true); + else + ui->cbTwExpByDam->setChecked(false); + ui->sbTwExpByKill->setValue(tw.expByKill); + if (tw.expByKill > 0) + ui->cbTwExpByKill->setChecked(true); + else + ui->cbTwExpByKill->setChecked(false); + ui->sbTwExpByShot->setValue(tw.expByShot); + if (tw.expByShot > 0) + ui->cbTwExpByShot->setChecked(true); + else + ui->cbTwExpByShot->setChecked(false); + ui->leTwName->setText(tw.name); + ui->sbTwRadius->setValue(tw.radius); + ui->sbTwReload->setValue(tw.reload); + ui->cbTwSplash->setCurrentIndex(adloader->splashes.keys().indexOf(tw.splashId)); + ui->cbTwImage->setCurrentIndex(adloader->animations.keys().indexOf(tw.imgType)); + ui->lbTwAnim->setAnimation(adloader->animations.value(tw.imgType).pathes); + } } void MainWindow::lvSplashes_select(QModelIndex index, QModelIndex) { - if (index.isValid()) - { - tbSplash spl = adloader->splashes.values().at(index.row()); - ui->sbSplLifeTime->setValue(spl.lifetime); - ui->sbSplSpeed->setValue(spl.speed); - ui->cbSplAutoControl->setChecked(spl.autoControl); - ui->leSplName->setText(spl.name); - ui->cbSplImage->setCurrentIndex(adloader->animations.keys().indexOf(spl.imgType)); - ui->lbSplAnim->setAnimation(adloader->animations.value(spl.imgType).pathes); - } + if (index.isValid()) + { + tbSplash spl = adloader->splashes.values().at(index.row()); + ui->sbSplLifeTime->setValue(spl.lifetime); + ui->sbSplSpeed->setValue(spl.speed); + ui->cbSplAutoControl->setChecked(spl.autoControl); + ui->cbSplKeepOnAlien->setChecked(spl.keepOnAlien); + ui->leSplName->setText(spl.name); + ui->cbSplImage->setCurrentIndex(adloader->animations.keys().indexOf(spl.imgType)); + ui->lbSplAnim->setAnimation(adloader->animations.value(spl.imgType).pathes); + switch (spl.compositionMode) + { + case QPainter::RasterOp_NotSource : + ui->cbSplCompisitionMode->setCurrentIndex(1); + break; + case QPainter::CompositionMode_Plus : + ui->cbSplCompisitionMode->setCurrentIndex(2); + break; + case QPainter::CompositionMode_Multiply : + ui->cbSplCompisitionMode->setCurrentIndex(3); + break; + case QPainter::CompositionMode_Screen : + ui->cbSplCompisitionMode->setCurrentIndex(4); + break; + case QPainter::CompositionMode_Darken : + ui->cbSplCompisitionMode->setCurrentIndex(5); + break; + case QPainter::CompositionMode_Lighten : + ui->cbSplCompisitionMode->setCurrentIndex(6); + break; + case QPainter::CompositionMode_ColorDodge : + ui->cbSplCompisitionMode->setCurrentIndex(7); + break; + case QPainter::CompositionMode_ColorBurn : + ui->cbSplCompisitionMode->setCurrentIndex(8); + break; + case QPainter::CompositionMode_HardLight : + ui->cbSplCompisitionMode->setCurrentIndex(9); + break; + case QPainter::CompositionMode_SoftLight : + ui->cbSplCompisitionMode->setCurrentIndex(10); + break; + case QPainter::CompositionMode_Difference : + ui->cbSplCompisitionMode->setCurrentIndex(11); + break; + case QPainter::CompositionMode_SourceOver : + default: + ui->cbSplCompisitionMode->setCurrentIndex(0); + break; + } + } } void MainWindow::lvTriggers_select(QModelIndex index, QModelIndex) { - if (index.isValid()) - { - tbTrigger trig = adloader->triggers.values().at(index.row()); - ui->sbTrigCount->setValue(trig.count); - if (trig.count > 0) - ui->cbTrigCount->setChecked(true); - else - ui->cbTrigCount->setChecked(false); - ui->sbTrigDamage->setValue(trig.damage); - if (trig.damage > 0) - ui->cbTrigDamage->setChecked(true); - else - ui->cbTrigDamage->setChecked(false); - ui->sbTrigDamRadius->setValue(trig.radius); - if (trig.radius > 0) - ui->cbTrigDamRad->setChecked(true); - else - ui->cbTrigDamRad->setChecked(false); - ui->sbTrigChance->setValue(trig.chance); - if (trig.chance == 100) - ui->cbTrigChance->setChecked(false); - else - ui->cbTrigChance->setChecked(true); - ui->sbTrigRandomRadius->setValue(trig.randomPosRadius); - if (trig.randomPosRadius > 0) - ui->cbTrigRandRadius->setChecked(true); - else - ui->cbTrigRandRadius->setChecked(false); + if (index.isValid()) + { + tbTrigger trig = adloader->triggers.values().at(index.row()); + ui->sbTrigCount->setValue(trig.count); + if (trig.count > 0) + ui->cbTrigCount->setChecked(true); + else + ui->cbTrigCount->setChecked(false); + ui->sbTrigDamage->setValue(trig.damage); + if (trig.damage > 0) + ui->cbTrigDamage->setChecked(true); + else + ui->cbTrigDamage->setChecked(false); + ui->sbTrigDamRadius->setValue(trig.radius); + if (trig.radius > 0) + ui->cbTrigDamRad->setChecked(true); + else + ui->cbTrigDamRad->setChecked(false); + ui->sbTrigChance->setValue(trig.chance); + if (trig.chance == 100) + ui->cbTrigChance->setChecked(false); + else + ui->cbTrigChance->setChecked(true); + ui->sbTrigRandomRadius->setValue(trig.randomPosRadius); + if (trig.randomPosRadius > 0) + ui->cbTrigRandRadius->setChecked(true); + else + ui->cbTrigRandRadius->setChecked(false); - ui->sbTrigTimer->setValue(trig.timer); - switch (trig.type) - { - case srcTriggerType::onDestination : - ui->cbTrigType->setCurrentIndex(0); - break; - case srcTriggerType::onAlienInRadius : - ui->cbTrigType->setCurrentIndex(1); - break; - case srcTriggerType::onTimer : - ui->cbTrigType->setCurrentIndex(2); - break; - } - if (trig.type != srcTriggerType::onTimer) - { - ui->lbTrigTimer->setVisible(false); - ui->sbTrigTimer->setVisible(false); - } else { - ui->lbTrigTimer->setVisible(true); - ui->sbTrigTimer->setVisible(true); - } - switch (trig.childAim) - { - case srcTriggerType::noAim : - ui->cbTrigChildAim->setCurrentIndex(0); - break; - case srcTriggerType::allSide : - ui->cbTrigChildAim->setCurrentIndex(1); - break; - case srcTriggerType::parentAim : - ui->cbTrigChildAim->setCurrentIndex(2); - break; - case srcTriggerType::nearlestAlien : - ui->cbTrigChildAim->setCurrentIndex(3); - break; - } - ui->leTrigName->setText(trig.name); - } + ui->sbTrigTimer->setValue(trig.timer); + switch (trig.type) + { + case srcTriggerType::onDestination : + ui->cbTrigType->setCurrentIndex(0); + break; + case srcTriggerType::onAlienInRadius : + ui->cbTrigType->setCurrentIndex(1); + break; + case srcTriggerType::onTimer : + ui->cbTrigType->setCurrentIndex(2); + break; + } + if (trig.type != srcTriggerType::onTimer) + { + ui->lbTrigTimer->setVisible(false); + ui->sbTrigTimer->setVisible(false); + } else { + ui->lbTrigTimer->setVisible(true); + ui->sbTrigTimer->setVisible(true); + } + switch (trig.childAim) + { + case srcTriggerType::noAim : + ui->cbTrigChildAim->setCurrentIndex(0); + break; + case srcTriggerType::allSide : + ui->cbTrigChildAim->setCurrentIndex(1); + break; + case srcTriggerType::parentAim : + ui->cbTrigChildAim->setCurrentIndex(2); + break; + case srcTriggerType::nearestAlien : + ui->cbTrigChildAim->setCurrentIndex(3); + break; + } + ui->leTrigName->setText(trig.name); + } } void MainWindow::closeEvent(QCloseEvent *event) { - QSettings sett("Alien_Defender","aliendefender"); - sett.setValue("session/geometry",this->saveGeometry()); - sett.setValue("session/mainwindow",this->saveState()); - sett.setValue("session/split1",ui->splitter->saveState()); - sett.setValue("session/split2",ui->splitter_2->saveState()); - sett.setValue("session/split3",ui->splitter_3->saveState()); - sett.setValue("session/split4",ui->splitter_4->saveState()); - sett.setValue("session/split5",ui->splitter_5->saveState()); - sett.setValue("session/split6",ui->splitter_6->saveState()); - sett.setValue("session/tab",ui->tabWidget->currentIndex()); - if (!isSaved) - { - QMessageBox msgBox; - msgBox.setText(tr("Save changes?")); - msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Save); - msgBox.setEscapeButton(QMessageBox::Discard); - int ret = msgBox.exec(); - switch (ret) - { - case QMessageBox::Save : - adloader->save("data2.xml"); - adloader->load("data2.xml"); - adloader->save("data2.xml"); - event->accept(); - break; - case QMessageBox::Cancel : - event->ignore(); - break; - } - } else { - event->accept(); - } + QSettings sett("Alien_Defender","aliendefender"); + sett.setValue("session/geometry",this->saveGeometry()); + sett.setValue("session/mainwindow",this->saveState()); + sett.setValue("session/split1",ui->splitter->saveState()); + sett.setValue("session/split2",ui->splitter_2->saveState()); + sett.setValue("session/split3",ui->splitter_3->saveState()); + sett.setValue("session/split4",ui->splitter_4->saveState()); + sett.setValue("session/split5",ui->splitter_5->saveState()); + sett.setValue("session/split6",ui->splitter_6->saveState()); + sett.setValue("session/tab",ui->tabWidget->currentIndex()); + if (!isSaved) + { + QMessageBox msgBox; + msgBox.setText(tr("Save changes?")); + msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Save); + msgBox.setEscapeButton(QMessageBox::Discard); + int ret = msgBox.exec(); + switch (ret) + { + case QMessageBox::Save : + adloader->save("data2.xml"); + adloader->load("data2.xml"); + adloader->save("data2.xml"); + event->accept(); + break; + case QMessageBox::Cancel : + event->ignore(); + break; + } + } else { + event->accept(); + } } void MainWindow::on_pbSave_clicked() { - adloader->save("data2.xml"); - adloader->load("data2.xml"); - adloader->save("data2.xml"); - isSaved = true; + adloader->save("data2.xml"); + adloader->load("data2.xml"); + adloader->save("data2.xml"); + isSaved = true; } void MainWindow::on_pbReload_clicked() { - QMessageBox msgBox; - msgBox.setText(tr("All unsaved changes will be lost")); - msgBox.setInformativeText(tr("Are you sure?")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - int ret = msgBox.exec(); - if (ret == QMessageBox::Ok) - { - adloader->load("data2.xml"); - alModel->refresh(adloader->aliens.values()); - twModel->refresh(adloader->towers.values()); - splModel->refresh(adloader->splashes.values()); - trigModel->refresh(adloader->triggers.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); - ui->lvMaps->reset(); - ui->lvMaps->selectionModel()->setCurrentIndex(ui->lvMaps->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - ui->lvAliens->reset(); - ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - ui->lvSplashes->reset(); - ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - ui->lvTowers->reset(); - ui->lvTowers->selectionModel()->setCurrentIndex(ui->lvTowers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - ui->lvTriggers->reset(); - ui->lvTriggers->selectionModel()->setCurrentIndex(ui->lvTriggers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - isSaved = true; - } + QMessageBox msgBox; + msgBox.setText(tr("All unsaved changes will be lost")); + msgBox.setInformativeText(tr("Are you sure?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret = msgBox.exec(); + if (ret == QMessageBox::Ok) + { + adloader->load("data2.xml"); + alModel->refresh(adloader->aliens.values()); + twModel->refresh(adloader->towers.values()); + splModel->refresh(adloader->splashes.values()); + trigModel->refresh(adloader->triggers.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); + ui->lvMaps->reset(); + ui->lvMaps->selectionModel()->setCurrentIndex(ui->lvMaps->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + ui->lvAliens->reset(); + ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + ui->lvSplashes->reset(); + ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + ui->lvTowers->reset(); + ui->lvTowers->selectionModel()->setCurrentIndex(ui->lvTowers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + ui->lvTriggers->reset(); + ui->lvTriggers->selectionModel()->setCurrentIndex(ui->lvTriggers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + isSaved = true; + } } void MainWindow::on_sbAlHealth_valueChanged(double value) { - int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; - float lval = adloader->aliens[id].health; - adloader->aliens[id].health = value; - if (lval != adloader->aliens[id].health) isSaved = false; + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + float lval = adloader->aliens[id].health; + adloader->aliens[id].health = value; + if (lval != adloader->aliens[id].health) isSaved = false; } void MainWindow::on_sbAlArmor_valueChanged(double value) { - int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; - float lval = adloader->aliens[id].armor; - adloader->aliens[id].armor = value; - if (lval != adloader->aliens[id].armor) isSaved = false; + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + float lval = adloader->aliens[id].armor; + adloader->aliens[id].armor = value; + if (lval != adloader->aliens[id].armor) isSaved = false; } void MainWindow::on_sbAlregeneration_valueChanged(double value) { - int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; - float lval = adloader->aliens[id].regeneration; - adloader->aliens[id].regeneration = value; - if (lval != adloader->aliens[id].regeneration) isSaved = false; + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + float lval = adloader->aliens[id].regeneration; + adloader->aliens[id].regeneration = value; + if (lval != adloader->aliens[id].regeneration) isSaved = false; } void MainWindow::on_sbAlSpeed_valueChanged(double value) { - int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; - float lval = adloader->aliens[id].speed; - adloader->aliens[id].speed = value; - if (lval != adloader->aliens[id].speed) isSaved = false; + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + float lval = adloader->aliens[id].speed; + adloader->aliens[id].speed = value; + if (lval != adloader->aliens[id].speed) isSaved = false; } void MainWindow::on_sbAlPrise_valueChanged(int val) { - int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; - unsigned int lval = adloader->aliens[id].prise; - adloader->aliens[id].prise = val; - if (lval != adloader->aliens[id].prise) isSaved = false; + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + unsigned int lval = adloader->aliens[id].prise; + adloader->aliens[id].prise = val; + if (lval != adloader->aliens[id].prise) isSaved = false; } void MainWindow::on_sbAlScore_valueChanged(int val) { - int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; - unsigned int lval = adloader->aliens[id].score; - adloader->aliens[id].score = val; - if (lval != adloader->aliens[id].score) isSaved = false; + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + unsigned int lval = adloader->aliens[id].score; + adloader->aliens[id].score = val; + if (lval != adloader->aliens[id].score) isSaved = false; } void MainWindow::on_cbAlIsFly_toggled(bool checked) { - int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; - bool lval = adloader->aliens[id].isFlying; - adloader->aliens[id].isFlying = checked; - if (lval != adloader->aliens[id].isFlying) isSaved = false; + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + bool lval = adloader->aliens[id].isFlying; + adloader->aliens[id].isFlying = checked; + if (lval != adloader->aliens[id].isFlying) isSaved = false; } void MainWindow::on_leAlName_editingFinished() { - int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; - QString lval = adloader->aliens[id].name; - adloader->aliens[id].name = ui->leAlName->text(); - alModel->refresh(adloader->aliens.values()); - QModelIndex mindex = ui->lvAliens->currentIndex(); - ui->lvAliens->reset(); - ui->lvAliens->setCurrentIndex(mindex); - if (lval != adloader->aliens[id].name) isSaved = false; + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + QString lval = adloader->aliens[id].name; + adloader->aliens[id].name = ui->leAlName->text(); + alModel->refresh(adloader->aliens.values()); + QModelIndex mindex = ui->lvAliens->currentIndex(); + ui->lvAliens->reset(); + ui->lvAliens->setCurrentIndex(mindex); + if (lval != adloader->aliens[id].name) isSaved = false; } void MainWindow::on_pbAlAdd_clicked() { - int i = 1; - while (adloader->aliens.contains(i)) i++; - tbAlien al; - al.id = i; - al.name = tr("Alien"); - al.health = 1; - al.prise = 0; - al.score = 1; - al.speed = 1; - adloader->aliens.insert(al.id,al); - int index = adloader->aliens.keys().indexOf(i); - alModel->refresh(adloader->aliens.values()); - ui->lvAliens->reset(); - ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(index,0),QItemSelectionModel::ClearAndSelect); - isSaved = false; + int i = 1; + while (adloader->aliens.contains(i)) i++; + tbAlien al; + al.id = i; + al.name = tr("Alien"); + al.health = 1; + al.prise = 0; + al.score = 1; + al.speed = 1; + adloader->aliens.insert(al.id,al); + int index = adloader->aliens.keys().indexOf(i); + alModel->refresh(adloader->aliens.values()); + ui->lvAliens->reset(); + ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(index,0),QItemSelectionModel::ClearAndSelect); + isSaved = false; } 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++) - { - if (adloader->waveParts.values().at(i).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->waveParts.values().at(i).waveId)); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); - return; - } - } - msgBox.setText(tr("Delete alien %1 id=%2").arg(adloader->aliens.value(id).name).arg(id)); - msgBox.setInformativeText(tr("Are you sure?")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - int ret = msgBox.exec(); - if (ret == QMessageBox::Ok) - { - adloader->aliens.remove(id); - alModel->refresh(adloader->aliens.values()); - ui->lvAliens->reset(); - ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - isSaved = false; - } + 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++) + { + if (adloader->waveParts.values().at(i).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->waveParts.values().at(i).waveId)); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + return; + } + } + msgBox.setText(tr("Delete alien %1 id=%2").arg(adloader->aliens.value(id).name).arg(id)); + msgBox.setInformativeText(tr("Are you sure?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret = msgBox.exec(); + if (ret == QMessageBox::Ok) + { + adloader->aliens.remove(id); + alModel->refresh(adloader->aliens.values()); + ui->lvAliens->reset(); + ui->lvAliens->selectionModel()->setCurrentIndex(ui->lvAliens->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + isSaved = false; + } } void MainWindow::on_leTwName_editingFinished() { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - QString lval = adloader->towers[id].name; - adloader->towers[id].name = ui->leTwName->text(); - twModel->refresh(adloader->towers.values()); - QModelIndex mindex = ui->lvTowers->currentIndex(); - ui->lvTowers->reset(); - ui->lvTowers->setCurrentIndex(mindex); - if (lval != adloader->towers[id].name) isSaved = false; + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + QString lval = adloader->towers[id].name; + adloader->towers[id].name = ui->leTwName->text(); + twModel->refresh(adloader->towers.values()); + QModelIndex mindex = ui->lvTowers->currentIndex(); + ui->lvTowers->reset(); + ui->lvTowers->setCurrentIndex(mindex); + if (lval != adloader->towers[id].name) isSaved = false; } void MainWindow::on_sbTwBuildTime_valueChanged(int val) { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - unsigned int lval = adloader->towers[id].buildTime; - adloader->towers[id].buildTime = val; - if (lval != adloader->towers[id].buildTime) isSaved = false; + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + unsigned int lval = adloader->towers[id].buildTime; + adloader->towers[id].buildTime = val; + if (lval != adloader->towers[id].buildTime) isSaved = false; } void MainWindow::on_sbTwCost_valueChanged(int val) { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - unsigned int lval = adloader->towers[id].cost; - adloader->towers[id].cost = val; - if (lval != adloader->towers[id].cost) isSaved = false; + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + unsigned int lval = adloader->towers[id].cost; + adloader->towers[id].cost = val; + if (lval != adloader->towers[id].cost) isSaved = false; } void MainWindow::on_cbTwSplash_currentIndexChanged(int index) { - if (!ui->lvTowers->currentIndex().isValid()) return; - if (index >= 0) - { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - int lval = adloader->towers[id].splashId; - adloader->towers[id].splashId = adloader->splashes.values().at(index).id; - if (lval != adloader->towers[id].splashId) isSaved = false; - } + if (!ui->lvTowers->currentIndex().isValid()) return; + if (index >= 0) + { + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + int lval = adloader->towers[id].splashId; + adloader->towers[id].splashId = adloader->splashes.values().at(index).id; + if (lval != adloader->towers[id].splashId) isSaved = false; + } } void MainWindow::on_sbTwReload_valueChanged(int val) { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - unsigned int lval = adloader->towers[id].reload; - adloader->towers[id].reload = val; - if (lval != adloader->towers[id].reload) isSaved = false; + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + unsigned int lval = adloader->towers[id].reload; + adloader->towers[id].reload = val; + if (lval != adloader->towers[id].reload) isSaved = false; } void MainWindow::on_sbTwRadius_valueChanged(double val) { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - float lval = adloader->towers[id].radius; - adloader->towers[id].radius = val; - if (lval != adloader->towers[id].radius) isSaved = false; + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + float lval = adloader->towers[id].radius; + adloader->towers[id].radius = val; + if (lval != adloader->towers[id].radius) isSaved = false; } void MainWindow::on_sbTwExpByShot_valueChanged(double val) { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - float lval = adloader->towers[id].expByShot; - adloader->towers[id].expByShot = val; - if (lval != adloader->towers[id].expByShot) isSaved = false; + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + float lval = adloader->towers[id].expByShot; + adloader->towers[id].expByShot = val; + if (lval != adloader->towers[id].expByShot) isSaved = false; } void MainWindow::on_cbTwExpByShot_toggled(bool checked) { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - float lval = adloader->towers[id].expByShot; - ui->sbTwExpByShot->setEnabled(checked); - if (checked) adloader->towers[id].expByShot = ui->sbTwExpByShot->value(); - else adloader->towers[id].expByShot = 0; - if (lval != adloader->towers[id].expByShot) isSaved = false; + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + float lval = adloader->towers[id].expByShot; + ui->sbTwExpByShot->setEnabled(checked); + if (checked) adloader->towers[id].expByShot = ui->sbTwExpByShot->value(); + else adloader->towers[id].expByShot = 0; + if (lval != adloader->towers[id].expByShot) isSaved = false; } void MainWindow::on_sbTwExpByDam_valueChanged(double val) { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - float lval = adloader->towers[id].expByDamage; - adloader->towers[id].expByDamage = val; - if (lval != adloader->towers[id].expByDamage) isSaved = false; + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + float lval = adloader->towers[id].expByDamage; + adloader->towers[id].expByDamage = val; + if (lval != adloader->towers[id].expByDamage) isSaved = false; } void MainWindow::on_cbTwExpByDam_toggled(bool checked) { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - float lval = adloader->towers[id].expByDamage; - ui->sbTwExpByDam->setEnabled(checked); - if (checked) adloader->towers[id].expByDamage = ui->sbTwExpByDam->value(); - else adloader->towers[id].expByDamage = 0; - if (lval != adloader->towers[id].expByDamage) isSaved = false; + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + float lval = adloader->towers[id].expByDamage; + ui->sbTwExpByDam->setEnabled(checked); + if (checked) adloader->towers[id].expByDamage = ui->sbTwExpByDam->value(); + else adloader->towers[id].expByDamage = 0; + if (lval != adloader->towers[id].expByDamage) isSaved = false; } void MainWindow::on_sbTwExpByKill_valueChanged(double val) { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - float lval = adloader->towers[id].expByKill; - adloader->towers[id].expByKill = val; - if (lval != adloader->towers[id].expByKill) isSaved = false; + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + float lval = adloader->towers[id].expByKill; + adloader->towers[id].expByKill = val; + if (lval != adloader->towers[id].expByKill) isSaved = false; } void MainWindow::on_cbTwExpByKill_toggled(bool checked) { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - float lval = adloader->towers[id].expByKill; - ui->sbTwExpByKill->setEnabled(checked); - if (checked) adloader->towers[id].expByKill = ui->sbTwExpByKill->value(); - else adloader->towers[id].expByKill = 0; - if (lval != adloader->towers[id].expByKill) isSaved = false; + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + float lval = adloader->towers[id].expByKill; + ui->sbTwExpByKill->setEnabled(checked); + if (checked) adloader->towers[id].expByKill = ui->sbTwExpByKill->value(); + else adloader->towers[id].expByKill = 0; + if (lval != adloader->towers[id].expByKill) isSaved = false; } void MainWindow::on_pbTwAdd_clicked() { - int i = 1; - while (adloader->towers.contains(i)) i++; - tbTower tw; - tw.id = i; - tw.name = tr("Tower"); - tw.splashId = adloader->splashes.keys().at(0); - tw.buildTime = 1; - tw.cost = 1; - tw.radius = 1; - tw.reload = 1; - adloader->towers.insert(tw.id,tw); - int index = adloader->towers.keys().indexOf(i); - twModel->refresh(adloader->towers.values()); - ui->lvTowers->reset(); - ui->lvTowers->selectionModel()->setCurrentIndex(ui->lvTowers->model()->index(index,0),QItemSelectionModel::ClearAndSelect); - isSaved = false; + int i = 1; + while (adloader->towers.contains(i)) i++; + tbTower tw; + tw.id = i; + tw.name = tr("Tower"); + tw.splashId = adloader->splashes.keys().at(0); + tw.buildTime = 1; + tw.cost = 1; + tw.radius = 1; + tw.reload = 1; + adloader->towers.insert(tw.id,tw); + int index = adloader->towers.keys().indexOf(i); + twModel->refresh(adloader->towers.values()); + ui->lvTowers->reset(); + ui->lvTowers->selectionModel()->setCurrentIndex(ui->lvTowers->model()->index(index,0),QItemSelectionModel::ClearAndSelect); + isSaved = false; } void MainWindow::on_pbTwDel_clicked() { - if (adloader->towers.size() < 2) return; - QMessageBox msgBox; - int id = adloader->towers.keys().at(ui->lvTowers->currentIndex().row()); - for (int i=0; ilevTowers.size(); i++) - { - if (adloader->levTowers.values().at(i).towerId == id) - { - msgBox.setText(tr("You can not delete tower %1 id=%2").arg(adloader->towers.value(id).name).arg(id)); - msgBox.setInformativeText(tr("It used in level %1").arg(adloader->levTowers.values().at(i).levelId)); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); - return; - } - } - msgBox.setText(tr("Delete tower %1 id=%2").arg(adloader->towers.value(id).name).arg(id)); - msgBox.setInformativeText(tr("Are you sure?")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - int ret = msgBox.exec(); - if (ret == QMessageBox::Ok) - { - adloader->towers.remove(id); - twModel->refresh(adloader->towers.values()); - ui->lvTowers->reset(); - ui->lvTowers->selectionModel()->setCurrentIndex(ui->lvTowers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - isSaved = false; - } + if (adloader->towers.size() < 2) return; + QMessageBox msgBox; + int id = adloader->towers.keys().at(ui->lvTowers->currentIndex().row()); + for (int i=0; ilevTowers.size(); i++) + { + if (adloader->levTowers.values().at(i).towerId == id) + { + msgBox.setText(tr("You can not delete tower %1 id=%2").arg(adloader->towers.value(id).name).arg(id)); + msgBox.setInformativeText(tr("It used in level %1").arg(adloader->levTowers.values().at(i).levelId)); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + return; + } + } + msgBox.setText(tr("Delete tower %1 id=%2").arg(adloader->towers.value(id).name).arg(id)); + msgBox.setInformativeText(tr("Are you sure?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret = msgBox.exec(); + if (ret == QMessageBox::Ok) + { + adloader->towers.remove(id); + twModel->refresh(adloader->towers.values()); + ui->lvTowers->reset(); + ui->lvTowers->selectionModel()->setCurrentIndex(ui->lvTowers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + isSaved = false; + } } void MainWindow::on_leSplName_editingFinished() { - int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; - QString lval = adloader->splashes[id].name; - adloader->splashes[id].name = ui->leSplName->text(); - splModel->refresh(adloader->splashes.values()); - //ui->lvSplashes->setModel((QAbstractItemModel * )splModel); - //ui->cbTwSplash->setModel((QAbstractItemModel * )splModel); - QModelIndex mindex = ui->lvSplashes->currentIndex(); - ui->lvSplashes->reset(); - ui->lvSplashes->setCurrentIndex(mindex); - if (lval != adloader->splashes[id].name) isSaved = false; + int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; + QString lval = adloader->splashes[id].name; + adloader->splashes[id].name = ui->leSplName->text(); + splModel->refresh(adloader->splashes.values()); + //ui->lvSplashes->setModel((QAbstractItemModel * )splModel); + //ui->cbTwSplash->setModel((QAbstractItemModel * )splModel); + QModelIndex mindex = ui->lvSplashes->currentIndex(); + ui->lvSplashes->reset(); + ui->lvSplashes->setCurrentIndex(mindex); + if (lval != adloader->splashes[id].name) isSaved = false; } void MainWindow::on_sbSplSpeed_valueChanged(double val) { - int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; - float lval = adloader->splashes[id].speed; - adloader->splashes[id].speed = val; - if (lval != adloader->splashes[id].speed) isSaved = false; + int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; + float lval = adloader->splashes[id].speed; + adloader->splashes[id].speed = val; + if (lval != adloader->splashes[id].speed) isSaved = false; } void MainWindow::on_cbSplAutoControl_toggled(bool checked) { - int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; - bool lval = adloader->splashes[id].autoControl; - adloader->splashes[id].autoControl = checked; - if (lval != adloader->splashes[id].autoControl) isSaved = false; + int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; + bool lval = adloader->splashes[id].autoControl; + adloader->splashes[id].autoControl = checked; + if (lval != adloader->splashes[id].autoControl) isSaved = false; } void MainWindow::on_sbSplLifeTime_valueChanged(int val) { - int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; - unsigned int lval = adloader->splashes[id].lifetime; - adloader->splashes[id].lifetime = val; - if (lval != adloader->splashes[id].lifetime) isSaved = false; + int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; + unsigned int lval = adloader->splashes[id].lifetime; + adloader->splashes[id].lifetime = val; + if (lval != adloader->splashes[id].lifetime) isSaved = false; } void MainWindow::on_pbSplAdd_clicked() { - int i = 1; - while (adloader->splashes.contains(i)) i++; - tbSplash spl; - spl.id = i; - spl.name = tr("Splash"); - spl.lifetime = 1; - spl.speed = 1; - adloader->splashes.insert(spl.id,spl); - int index = adloader->splashes.keys().indexOf(i); - splModel->refresh(adloader->splashes.values()); - ui->lvSplashes->reset(); - ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(index,0),QItemSelectionModel::ClearAndSelect); - isSaved = false; + int i = 1; + while (adloader->splashes.contains(i)) i++; + tbSplash spl; + spl.id = i; + spl.name = tr("Splash"); + spl.lifetime = 1; + spl.speed = 1; + adloader->splashes.insert(spl.id,spl); + int index = adloader->splashes.keys().indexOf(i); + splModel->refresh(adloader->splashes.values()); + ui->lvSplashes->reset(); + ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(index,0),QItemSelectionModel::ClearAndSelect); + isSaved = false; } void MainWindow::on_pbSlpDel_clicked() { - if (adloader->splashes.size() < 2) return; - QMessageBox msgBox; - int id = adloader->splashes.keys().at(ui->lvSplashes->currentIndex().row()); - for (int i=0; itowers.size(); i++) - { - if (adloader->towers.values().at(i).splashId == 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 tower %1 id=%2").arg(adloader->towers.values().at(i).name).arg(adloader->towers.values().at(i).id)); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); - return; - } - } - for (int i=0; ichains.size(); i++) - { - if (adloader->chains.values().at(i).childSplashId == 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)); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); - return; - } - } - msgBox.setText(tr("Delete splash %1 id=%2").arg(adloader->splashes.value(id).name).arg(id)); - msgBox.setInformativeText(tr("Are you sure?")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - int ret = msgBox.exec(); - if (ret == QMessageBox::Ok) - { - adloader->splashes.remove(id); - splModel->refresh(adloader->splashes.values()); - ui->lvSplashes->reset(); - ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - isSaved = false; - } + if (adloader->splashes.size() < 2) return; + QMessageBox msgBox; + int id = adloader->splashes.keys().at(ui->lvSplashes->currentIndex().row()); + for (int i=0; itowers.size(); i++) + { + if (adloader->towers.values().at(i).splashId == 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 tower %1 id=%2").arg(adloader->towers.values().at(i).name).arg(adloader->towers.values().at(i).id)); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + return; + } + } + for (int i=0; ichains.size(); i++) + { + if (adloader->chains.values().at(i).childSplashId == 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)); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + return; + } + } + msgBox.setText(tr("Delete splash %1 id=%2").arg(adloader->splashes.value(id).name).arg(id)); + msgBox.setInformativeText(tr("Are you sure?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret = msgBox.exec(); + if (ret == QMessageBox::Ok) + { + adloader->splashes.remove(id); + splModel->refresh(adloader->splashes.values()); + ui->lvSplashes->reset(); + ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + isSaved = false; + } } void MainWindow::on_pbTwSplashEdit_clicked() { - int splIndex = adloader->splashes.keys().indexOf(adloader->towers.values().at(ui->lvTowers->currentIndex().row()).splashId); - ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(splIndex,0),QItemSelectionModel::ClearAndSelect); - ui->tabWidget->setCurrentWidget(ui->tabSplashes); + int splIndex = adloader->splashes.keys().indexOf(adloader->towers.values().at(ui->lvTowers->currentIndex().row()).splashId); + ui->lvSplashes->selectionModel()->setCurrentIndex(ui->lvSplashes->model()->index(splIndex,0),QItemSelectionModel::ClearAndSelect); + ui->tabWidget->setCurrentWidget(ui->tabSplashes); } void MainWindow::on_cbTrigChance_toggled(bool checked) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - int lval = adloader->triggers[id].chance; - ui->sbTrigChance->setEnabled(checked); - if (checked) adloader->triggers[id].chance = ui->sbTrigChance->value(); - else adloader->triggers[id].chance = 100; - if (lval != adloader->triggers[id].chance) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + int lval = adloader->triggers[id].chance; + ui->sbTrigChance->setEnabled(checked); + if (checked) adloader->triggers[id].chance = ui->sbTrigChance->value(); + else adloader->triggers[id].chance = 100; + if (lval != adloader->triggers[id].chance) isSaved = false; } void MainWindow::on_sbTrigChance_valueChanged(int val) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - int lval = adloader->triggers[id].chance; - adloader->triggers[id].chance = val; - if (lval != adloader->triggers[id].chance) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + int lval = adloader->triggers[id].chance; + adloader->triggers[id].chance = val; + if (lval != adloader->triggers[id].chance) isSaved = false; } void MainWindow::on_leTrigName_editingFinished() { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - QString lval = adloader->triggers[id].name; - adloader->triggers[id].name = ui->leTrigName->text(); - trigModel->refresh(adloader->triggers.values()); - QModelIndex mindex = ui->lvTriggers->currentIndex(); - ui->lvTriggers->reset(); - ui->lvTriggers->setCurrentIndex(mindex); - if (lval != adloader->triggers[id].name) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + QString lval = adloader->triggers[id].name; + adloader->triggers[id].name = ui->leTrigName->text(); + trigModel->refresh(adloader->triggers.values()); + QModelIndex mindex = ui->lvTriggers->currentIndex(); + ui->lvTriggers->reset(); + ui->lvTriggers->setCurrentIndex(mindex); + if (lval != adloader->triggers[id].name) isSaved = false; } void MainWindow::on_sbTrigCount_valueChanged(int val) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - int lval = adloader->triggers[id].count; - adloader->triggers[id].count = val; - if (lval != adloader->triggers[id].count) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + int lval = adloader->triggers[id].count; + adloader->triggers[id].count = val; + if (lval != adloader->triggers[id].count) isSaved = false; } void MainWindow::on_sbTrigRandomRadius_valueChanged(double value) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - float lval = adloader->triggers[id].randomPosRadius; - adloader->triggers[id].randomPosRadius = value; - if (lval != adloader->triggers[id].randomPosRadius) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + float lval = adloader->triggers[id].randomPosRadius; + adloader->triggers[id].randomPosRadius = value; + if (lval != adloader->triggers[id].randomPosRadius) isSaved = false; } void MainWindow::on_cbTrigDelPar_toggled(bool checked) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - bool lval = adloader->triggers[id].delParent; - adloader->triggers[id].delParent = checked; - if (lval != adloader->triggers[id].delParent) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + bool lval = adloader->triggers[id].delParent; + adloader->triggers[id].delParent = checked; + if (lval != adloader->triggers[id].delParent) isSaved = false; } void MainWindow::on_sbTrigTimer_valueChanged(int val) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - unsigned int lval = adloader->triggers[id].timer; - adloader->triggers[id].timer = val; - if (lval != adloader->triggers[id].timer) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + unsigned int lval = adloader->triggers[id].timer; + adloader->triggers[id].timer = val; + if (lval != adloader->triggers[id].timer) isSaved = false; } void MainWindow::on_sbTrigDamage_valueChanged(double value) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - float lval = adloader->triggers[id].damage; - adloader->triggers[id].damage = value; - if (lval != adloader->triggers[id].damage) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + float lval = adloader->triggers[id].damage; + adloader->triggers[id].damage = value; + if (lval != adloader->triggers[id].damage) isSaved = false; } void MainWindow::on_sbTrigDamRadius_valueChanged(double value) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - float lval = adloader->triggers[id].radius; - adloader->triggers[id].radius = value; - if (lval != adloader->triggers[id].radius) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + float lval = adloader->triggers[id].radius; + adloader->triggers[id].radius = value; + if (lval != adloader->triggers[id].radius) isSaved = false; } void MainWindow::on_cbTrigDamRad_toggled(bool checked) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - float lval = adloader->triggers[id].radius; - ui->sbTrigDamRadius->setEnabled(checked); - if (checked) adloader->triggers[id].radius = ui->sbTrigDamRadius->value(); - else adloader->triggers[id].radius = 0; - if (lval != adloader->triggers[id].radius) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + float lval = adloader->triggers[id].radius; + ui->sbTrigDamRadius->setEnabled(checked); + if (checked) adloader->triggers[id].radius = ui->sbTrigDamRadius->value(); + else adloader->triggers[id].radius = 0; + if (lval != adloader->triggers[id].radius) isSaved = false; } void MainWindow::on_cbTrigDamage_toggled(bool checked) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - float lval = adloader->triggers[id].damage; - ui->sbTrigDamage->setEnabled(checked); - if (checked) adloader->triggers[id].damage = ui->sbTrigDamage->value(); - else adloader->triggers[id].damage = 0; - if (lval != adloader->triggers[id].damage) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + float lval = adloader->triggers[id].damage; + ui->sbTrigDamage->setEnabled(checked); + if (checked) adloader->triggers[id].damage = ui->sbTrigDamage->value(); + else adloader->triggers[id].damage = 0; + if (lval != adloader->triggers[id].damage) isSaved = false; } void MainWindow::on_cbTrigRandRadius_toggled(bool checked) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - float lval = adloader->triggers[id].randomPosRadius; - ui->sbTrigRandomRadius->setEnabled(checked); - if (checked) adloader->triggers[id].randomPosRadius = ui->sbTrigRandomRadius->value(); - else adloader->triggers[id].randomPosRadius = 0; - if (lval != adloader->triggers[id].randomPosRadius) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + float lval = adloader->triggers[id].randomPosRadius; + ui->sbTrigRandomRadius->setEnabled(checked); + if (checked) adloader->triggers[id].randomPosRadius = ui->sbTrigRandomRadius->value(); + else adloader->triggers[id].randomPosRadius = 0; + if (lval != adloader->triggers[id].randomPosRadius) isSaved = false; } void MainWindow::on_cbTrigCount_toggled(bool checked) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - int lval = adloader->triggers[id].count; - ui->sbTrigCount->setEnabled(checked); - if (checked) adloader->triggers[id].count = ui->sbTrigCount->value(); - else adloader->triggers[id].count = 0; - if (lval != adloader->triggers[id].count) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + int lval = adloader->triggers[id].count; + ui->sbTrigCount->setEnabled(checked); + if (checked) adloader->triggers[id].count = ui->sbTrigCount->value(); + else adloader->triggers[id].count = 0; + if (lval != adloader->triggers[id].count) isSaved = false; } void MainWindow::on_pbTrigAdd_clicked() { - int i = 1; - while (adloader->triggers.contains(i)) i++; - tbTrigger trig; - trig.id = i; - trig.name = tr("Trigger"); - trig.count = 0; - trig.damage = 0; - trig.radius = 0; - trig.timer = 10; - trig.chance = 100; - trig.delParent =true ; - trig.childAim = srcTriggerType::noAim; - trig.randomPosRadius = 0; - trig.type = srcTriggerType::onDestination; - adloader->triggers.insert(trig.id,trig); - int index = adloader->triggers.keys().indexOf(i); - trigModel->refresh(adloader->triggers.values()); - ui->lvTriggers->reset(); - ui->lvTriggers->selectionModel()->setCurrentIndex(ui->lvTriggers->model()->index(index,0),QItemSelectionModel::ClearAndSelect); - isSaved = false; + int i = 1; + while (adloader->triggers.contains(i)) i++; + tbTrigger trig; + trig.id = i; + trig.name = tr("Trigger"); + trig.count = 0; + trig.damage = 0; + trig.radius = 0; + trig.timer = 10; + trig.chance = 100; + trig.delParent =true ; + trig.childAim = srcTriggerType::noAim; + trig.randomPosRadius = 0; + trig.type = srcTriggerType::onDestination; + adloader->triggers.insert(trig.id,trig); + int index = adloader->triggers.keys().indexOf(i); + trigModel->refresh(adloader->triggers.values()); + ui->lvTriggers->reset(); + ui->lvTriggers->selectionModel()->setCurrentIndex(ui->lvTriggers->model()->index(index,0),QItemSelectionModel::ClearAndSelect); + isSaved = false; } void MainWindow::on_pbTrigDel_clicked() { - if (adloader->triggers.size() < 2) return; - QMessageBox msgBox; - int id = adloader->triggers.keys().at(ui->lvTriggers->currentIndex().row()); - for (int i=0; ichains.size(); i++) - { - if (adloader->chains.values().at(i).triggerId == id) - { - msgBox.setText(tr("You can not delete trigger %1 id=%2").arg(adloader->triggers.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)); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); - return; - } - } - msgBox.setText(tr("Delete trigger %1 id=%2").arg(adloader->triggers.value(id).name).arg(id)); - msgBox.setInformativeText(tr("Are you sure?")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - int ret = msgBox.exec(); - if (ret == QMessageBox::Ok) - { - adloader->triggers.remove(id); - trigModel->refresh(adloader->triggers.values()); - ui->lvTriggers->reset(); - ui->lvTriggers->selectionModel()->setCurrentIndex(ui->lvTriggers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - isSaved = false; - } + if (adloader->triggers.size() < 2) return; + QMessageBox msgBox; + int id = adloader->triggers.keys().at(ui->lvTriggers->currentIndex().row()); + for (int i=0; ichains.size(); i++) + { + if (adloader->chains.values().at(i).triggerId == id) + { + msgBox.setText(tr("You can not delete trigger %1 id=%2").arg(adloader->triggers.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)); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + return; + } + } + msgBox.setText(tr("Delete trigger %1 id=%2").arg(adloader->triggers.value(id).name).arg(id)); + msgBox.setInformativeText(tr("Are you sure?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret = msgBox.exec(); + if (ret == QMessageBox::Ok) + { + adloader->triggers.remove(id); + trigModel->refresh(adloader->triggers.values()); + ui->lvTriggers->reset(); + ui->lvTriggers->selectionModel()->setCurrentIndex(ui->lvTriggers->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + isSaved = false; + } } void MainWindow::on_cbTrigType_currentIndexChanged(int index) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - srcTriggerType::triggerType lval = adloader->triggers[id].type; - adloader->triggers[id].type = (srcTriggerType::triggerType)ui->cbTrigType->itemData(index).toInt(); - if (adloader->triggers[id].type != srcTriggerType::onTimer) - { - ui->lbTrigTimer->setVisible(false); - ui->sbTrigTimer->setVisible(false); - } else { - ui->lbTrigTimer->setVisible(true); - ui->sbTrigTimer->setVisible(true); - ui->sbTrigTimer->setValue(adloader->triggers[id].timer); - } - if (lval != adloader->triggers[id].type) isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + srcTriggerType::triggerType lval = adloader->triggers[id].type; + adloader->triggers[id].type = (srcTriggerType::triggerType)ui->cbTrigType->itemData(index).toInt(); + if (adloader->triggers[id].type == srcTriggerType::onAlienInRadius) + { + ui->lbTrigChildAim->hide(); + ui->cbTrigChildAim->hide(); + } else { + ui->lbTrigChildAim->show(); + ui->cbTrigChildAim->show(); + } + if (adloader->triggers[id].type != srcTriggerType::onTimer) + { + ui->lbTrigTimer->setVisible(false); + ui->sbTrigTimer->setVisible(false); + } else { + ui->lbTrigTimer->setVisible(true); + ui->sbTrigTimer->setVisible(true); + ui->sbTrigTimer->setValue(adloader->triggers[id].timer); + } + if (lval != adloader->triggers[id].type) isSaved = false; } void MainWindow::on_cbTrigChildAim_currentIndexChanged(int index) { - int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; - srcTriggerType::aimType lval = adloader->triggers[id].childAim; - adloader->triggers[id].childAim = (srcTriggerType::aimType)ui->cbTrigChildAim->itemData(index).toInt(); - if (lval != adloader->triggers[id].childAim)isSaved = false; + int id = adloader->triggers.values().at(ui->lvTriggers->currentIndex().row()).id; + srcTriggerType::aimType lval = adloader->triggers[id].childAim; + adloader->triggers[id].childAim = (srcTriggerType::aimType)ui->cbTrigChildAim->itemData(index).toInt(); + if (lval != adloader->triggers[id].childAim)isSaved = false; } void MainWindow::on_pbImgAdd_clicked() { - int id = adloader->animations.values().at(ui->lvAnimations->currentIndex().row()).id; - QFileDialog fd; - QStringList strl; - fd.setNameFilter(tr("Images (*.png)")); - fd.setFileMode(QFileDialog::ExistingFiles); - QDir dir; - if (fd.exec()) - { - strl = fd.selectedFiles(); - for (int i=0; ianimations[id].pathes.append(strl); - refresh_lwImages(adloader->animations.value(id).pathes); - isSaved = false; - } + int id = adloader->animations.values().at(ui->lvAnimations->currentIndex().row()).id; + QStringList strl; + /*QFileDialog fd; + fd.setNameFilter(tr()); + fd.setFileMode(QFileDialog::ExistingFiles);*/ + QDir dir; + strl = QFileDialog::getOpenFileNames(this, "Select images", QString()/*qApp->applicationDirPath()*/, "Images (*.png)"); + /*if (fd.exec()) + { + strl = fd.selectedFiles();*/ + for (int i=0; ianimations[id].pathes.append(strl); + refresh_lwImages(adloader->animations.value(id).pathes); + isSaved = false; + //} } void MainWindow::refresh_lwImages(QStringList pathes) { - ui->lwImages->clear(); - for (int i=0; ilwImages->addItem(new QListWidgetItem(QIcon(pathes.at(i)),pathes.at(i))); - } + ui->lwImages->clear(); + for (int i=0; ilwImages->addItem(new QListWidgetItem(QIcon(pathes.at(i)),pathes.at(i))); + } } void MainWindow::on_pbImgDel_clicked() { - if (!ui->lwImages->selectedItems().isEmpty()) - { - int id = adloader->animations.values().at(ui->lvAnimations->currentIndex().row()).id; - for (int i=0; ilwImages->selectedItems().size(); ++i) - adloader->animations[id].pathes.removeOne(ui->lwImages->selectedItems().at(i)->text()); - refresh_lwImages(adloader->animations.value(id).pathes); - isSaved = false; - } + if (!ui->lwImages->selectedItems().isEmpty()) + { + int id = adloader->animations.values().at(ui->lvAnimations->currentIndex().row()).id; + for (int i=0; ilwImages->selectedItems().size(); ++i) + adloader->animations[id].pathes.removeOne(ui->lwImages->selectedItems().at(i)->text()); + refresh_lwImages(adloader->animations.value(id).pathes); + isSaved = false; + } } void MainWindow::on_pbAnimAdd_clicked() { - int i = 1; - while (adloader->animations.contains(i)) i++; - tbAnimation anim; - anim.id = i; - adloader->animations.insert(anim.id,anim); - int index = adloader->animations.keys().indexOf(i); - animModel->refresh(adloader->animations.values()); - ui->lvAnimations->reset(); - ui->lvAnimations->selectionModel()->setCurrentIndex(ui->lvAnimations->model()->index(index,0),QItemSelectionModel::ClearAndSelect); - isSaved = false; + int i = 1; + while (adloader->animations.contains(i)) i++; + tbAnimation anim; + anim.id = i; + adloader->animations.insert(anim.id,anim); + int index = adloader->animations.keys().indexOf(i); +// animModel->refresh(adloader->animations.values()); + ui->lvAnimations->reset(); + ui->lvAnimations->selectionModel()->setCurrentIndex(ui->lvAnimations->model()->index(index,0),QItemSelectionModel::ClearAndSelect); + isSaved = false; } void MainWindow::on_cbAlImage_currentIndexChanged(int index) { - if (!ui->lvAliens->currentIndex().isValid()) return; - if (index >= 0) - { - int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; - int lval = adloader->aliens[id].imgType; - adloader->aliens[id].imgType = adloader->animations.values().at(index).id; - ui->lbAlAnim->setAnimation(adloader->animations.value(adloader->aliens[id].imgType).pathes); - if (lval != adloader->aliens[id].imgType) isSaved = false; - } + if (!ui->lvAliens->currentIndex().isValid()) return; + if (index >= 0) + { + int id = adloader->aliens.values().at(ui->lvAliens->currentIndex().row()).id; + int lval = adloader->aliens[id].imgType; + adloader->aliens[id].imgType = adloader->animations.values().at(index).id; + ui->lbAlAnim->setAnimation(adloader->animations.value(adloader->aliens[id].imgType).pathes); + if (lval != adloader->aliens[id].imgType) isSaved = false; + } } void MainWindow::on_cbTwImage_currentIndexChanged(int index) { - if (!ui->lvTowers->currentIndex().isValid()) return; - if (index >= 0) - { - int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; - int lval = adloader->towers[id].imgType; - adloader->towers[id].imgType = adloader->animations.values().at(index).id; - ui->lbTwAnim->setAnimation(adloader->animations.value(adloader->towers[id].imgType).pathes); - if (lval != adloader->towers[id].imgType) isSaved = false; - } + if (!ui->lvTowers->currentIndex().isValid()) return; + if (index >= 0) + { + int id = adloader->towers.values().at(ui->lvTowers->currentIndex().row()).id; + int lval = adloader->towers[id].imgType; + adloader->towers[id].imgType = adloader->animations.values().at(index).id; + ui->lbTwAnim->setAnimation(adloader->animations.value(adloader->towers[id].imgType).pathes); + if (lval != adloader->towers[id].imgType) isSaved = false; + } } void MainWindow::on_cbSplImage_currentIndexChanged(int index) { - if (!ui->lvSplashes->currentIndex().isValid()) return; - if (index >= 0) - { - int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; - int lval = adloader->splashes[id].imgType; - adloader->splashes[id].imgType = adloader->animations.values().at(index).id; - ui->lbSplAnim->setAnimation(adloader->animations.value(adloader->splashes[id].imgType).pathes); - if (lval != adloader->splashes[id].imgType) isSaved = false; - } + if (!ui->lvSplashes->currentIndex().isValid()) return; + if (index >= 0) + { + int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; + int lval = adloader->splashes[id].imgType; + adloader->splashes[id].imgType = adloader->animations.values().at(index).id; + ui->lbSplAnim->setAnimation(adloader->animations.value(adloader->splashes[id].imgType).pathes); + if (lval != adloader->splashes[id].imgType) isSaved = false; + } } void MainWindow::on_pbAnimDel_clicked() { - if (adloader->animations.size() < 2) return; - QMessageBox msgBox; - int id = adloader->animations.keys().at(ui->lvAnimations->currentIndex().row()); - for (int i=0; itowers.size(); i++) - { - if (adloader->towers.values().at(i).imgType == id) - { - msgBox.setText(tr("You can not delete anim %1").arg(id)); - msgBox.setInformativeText(tr("It used by tower %1 id=%2").arg(adloader->towers.values().at(i).name).arg(adloader->towers.values().at(i).id)); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); - return; - } - } - for (int i=0; ialiens.size(); i++) - { - if (adloader->aliens.values().at(i).imgType == id) - { - msgBox.setText(tr("You can not delete anim %1").arg(id)); - msgBox.setInformativeText(tr("It used by alien %1 id=%2").arg(adloader->aliens.values().at(i).name).arg(adloader->aliens.values().at(i).id)); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); - return; - } - } - for (int i=0; isplashes.size(); i++) - { - if (adloader->splashes.values().at(i).imgType == id) - { - msgBox.setText(tr("You can not delete anim %1").arg(id)); - msgBox.setInformativeText(tr("It used by splash %1 id=%2").arg(adloader->splashes.values().at(i).name).arg(adloader->splashes.values().at(i).id)); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.exec(); - return; - } - } - msgBox.setText(tr("Delete anim %1").arg(id)); - msgBox.setInformativeText(tr("Are you sure?")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - int ret = msgBox.exec(); - if (ret == QMessageBox::Ok) - { - adloader->animations.remove(id); - animModel->refresh(adloader->animations.values()); - ui->lvAnimations->reset(); - ui->lvAnimations->selectionModel()->setCurrentIndex(ui->lvAnimations->model()->index(0,0),QItemSelectionModel::ClearAndSelect); - isSaved = false; - } + if (adloader->animations.size() < 2) return; + QMessageBox msgBox; + int id = adloader->animations.keys().at(ui->lvAnimations->currentIndex().row()); + for (int i=0; itowers.size(); i++) + { + if (adloader->towers.values().at(i).imgType == id) + { + msgBox.setText(tr("You can not delete anim %1").arg(id)); + msgBox.setInformativeText(tr("It used by tower %1 id=%2").arg(adloader->towers.values().at(i).name).arg(adloader->towers.values().at(i).id)); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + return; + } + } + for (int i=0; ialiens.size(); i++) + { + if (adloader->aliens.values().at(i).imgType == id) + { + msgBox.setText(tr("You can not delete anim %1").arg(id)); + msgBox.setInformativeText(tr("It used by alien %1 id=%2").arg(adloader->aliens.values().at(i).name).arg(adloader->aliens.values().at(i).id)); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + return; + } + } + for (int i=0; isplashes.size(); i++) + { + if (adloader->splashes.values().at(i).imgType == id) + { + msgBox.setText(tr("You can not delete anim %1").arg(id)); + msgBox.setInformativeText(tr("It used by splash %1 id=%2").arg(adloader->splashes.values().at(i).name).arg(adloader->splashes.values().at(i).id)); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + return; + } + } + msgBox.setText(tr("Delete anim %1").arg(id)); + msgBox.setInformativeText(tr("Are you sure?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + int ret = msgBox.exec(); + if (ret == QMessageBox::Ok) + { + adloader->animations.remove(id); +// animModel->refresh(adloader->animations.values()); + ui->lvAnimations->reset(); + ui->lvAnimations->selectionModel()->setCurrentIndex(ui->lvAnimations->model()->index(0,0),QItemSelectionModel::ClearAndSelect); + isSaved = false; + } +} + + +void MainWindow::on_cbSplCompisitionMode_currentIndexChanged(const QString &str) +{ + int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; + QPainter::CompositionMode lval = adloader->splashes[id].compositionMode; + if (str == "NotSource") adloader->splashes[id].compositionMode = QPainter::RasterOp_NotSource; + if (str == "Plus") adloader->splashes[id].compositionMode = QPainter::CompositionMode_Plus; + if (str == "Multiply") adloader->splashes[id].compositionMode = QPainter::CompositionMode_Multiply; + if (str == "Screen") adloader->splashes[id].compositionMode = QPainter::CompositionMode_Screen; + if (str == "Overlay") adloader->splashes[id].compositionMode = QPainter::CompositionMode_Overlay; + if (str == "Darken") adloader->splashes[id].compositionMode = QPainter::CompositionMode_Darken; + if (str == "Lighten") adloader->splashes[id].compositionMode = QPainter::CompositionMode_Lighten; + if (str == "ColorDodge") adloader->splashes[id].compositionMode = QPainter::CompositionMode_ColorDodge; + if (str == "ColorBurn") adloader->splashes[id].compositionMode = QPainter::CompositionMode_ColorBurn; + if (str == "HardLight") adloader->splashes[id].compositionMode = QPainter::CompositionMode_HardLight; + if (str == "SoftLight") adloader->splashes[id].compositionMode = QPainter::CompositionMode_SoftLight; + if (str == "Difference") adloader->splashes[id].compositionMode = QPainter::CompositionMode_Difference; + if (lval != adloader->splashes[id].compositionMode) isSaved = false; +} + + +void MainWindow::on_sbSplZValue_valueChanged(double val) +{ + int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; + float lval = adloader->splashes[id].ZValue; + adloader->splashes[id].ZValue = val; + if (lval != adloader->splashes[id].ZValue) isSaved = false; +} + + +void MainWindow::on_sbSplAnimSpeed_valueChanged(double val) +{ + int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; + float lval = adloader->splashes[id].animSpeed; + adloader->splashes[id].animSpeed = val; + if (lval != adloader->splashes[id].animSpeed) isSaved = false; +} + + +void MainWindow::on_cbSplKeepOnAlien_toggled(bool checked) +{ + int id = adloader->splashes.values().at(ui->lvSplashes->currentIndex().row()).id; + bool lval = adloader->splashes[id].keepOnAlien; + adloader->splashes[id].keepOnAlien = checked; + if (lval != adloader->splashes[id].keepOnAlien) isSaved = false; } diff --git a/ADeditor/mainwindow.h b/ADeditor/mainwindow.h index edde59c..93a348b 100644 --- a/ADeditor/mainwindow.h +++ b/ADeditor/mainwindow.h @@ -16,101 +16,105 @@ #include "animlabel.h" namespace Ui { - class MainWindow; +class MainWindow; } class MainWindow : public QMainWindow { - Q_OBJECT + Q_OBJECT public: - MainWindow(QWidget *parent = 0); - ~MainWindow(); + MainWindow(QWidget *parent = 0); + ~MainWindow(); protected: - void changeEvent(QEvent *e); + void changeEvent(QEvent *e); private: - Ui::MainWindow *ui; - Loader * adloader; - AlienModel * alModel; - TowerModel * twModel; - SplashModel * splModel; - TriggerModel* trigModel; - MapModel * mapModel; - AnimationModel * animModel; - QGraphicsScene * mapScene; + Ui::MainWindow *ui; + Loader * adloader; + AlienModel * alModel; + TowerModel * twModel; + SplashModel * splModel; + TriggerModel* trigModel; + MapModel * mapModel; + AnimationModel * animModel; + QGraphicsScene * mapScene; - //AnimLabel * alb; + //AnimLabel * alb; - bool isSaved; + bool isSaved; - void refresh_lwImages(QStringList pathes); - void closeEvent(QCloseEvent *); + void refresh_lwImages(QStringList pathes); + void closeEvent(QCloseEvent *); private slots: - void on_pbAnimDel_clicked(); - void on_cbSplImage_currentIndexChanged(int index); - void on_cbTwImage_currentIndexChanged(int index); - void on_cbAlImage_currentIndexChanged(int index); - void on_pbAnimAdd_clicked(); - void on_pbImgDel_clicked(); - void on_pbImgAdd_clicked(); - void on_cbTrigChildAim_currentIndexChanged(int index); - void on_cbTrigType_currentIndexChanged(int index); - void on_cbTrigCount_toggled(bool checked); - void on_leTrigName_editingFinished(); - void on_pbTwSplashEdit_clicked(); - void on_cbTrigDamRad_toggled(bool checked); - void on_cbTrigDamage_toggled(bool checked); - void on_cbTrigDelPar_toggled(bool checked); - void on_cbTrigChance_toggled(bool checked); - void on_cbTrigRandRadius_toggled(bool checked); - void on_cbTwExpByKill_toggled(bool checked); - void on_cbTwExpByDam_toggled(bool checked); - void on_cbTwExpByShot_toggled(bool checked); - void on_cbAlIsFly_toggled(bool checked); - void on_pbTrigDel_clicked(); - void on_pbTrigAdd_clicked(); - void on_sbTrigChance_valueChanged(int ); - void on_sbTrigDamRadius_valueChanged(double ); - void on_sbTrigDamage_valueChanged(double ); - void on_sbTrigTimer_valueChanged(int ); - void on_sbTrigRandomRadius_valueChanged(double ); - void on_sbTrigCount_valueChanged(int ); - void on_pbReload_clicked(); - void on_pbSlpDel_clicked(); - void on_pbSplAdd_clicked(); - void on_sbSplLifeTime_valueChanged(int ); - void on_cbSplAutoControl_toggled(bool checked); - void on_sbSplSpeed_valueChanged(double ); - void on_leSplName_editingFinished(); - void on_pbTwDel_clicked(); - void on_sbTwExpByKill_valueChanged(double ); - void on_sbTwExpByDam_valueChanged(double ); - void on_sbTwExpByShot_valueChanged(double ); - void on_sbTwRadius_valueChanged(double ); - void on_sbTwReload_valueChanged(int ); - void on_cbTwSplash_currentIndexChanged(int index); - void on_sbTwCost_valueChanged(int ); - void on_sbTwBuildTime_valueChanged(int ); - void on_pbTwAdd_clicked(); - void on_leTwName_editingFinished(); - void on_pbAlDel_clicked(); - void on_pbAlAdd_clicked(); - void on_leAlName_editingFinished(); - void on_sbAlScore_valueChanged(int ); - void on_sbAlPrise_valueChanged(int ); - void on_sbAlSpeed_valueChanged(double ); - void on_sbAlregeneration_valueChanged(double ); - void on_sbAlArmor_valueChanged(double ); - void on_sbAlHealth_valueChanged(double ); - void on_pbSave_clicked(); - void lvAliens_select(QModelIndex, QModelIndex); - void lvAnimations_select(QModelIndex, QModelIndex); - void lvTowers_select(QModelIndex, QModelIndex); - void lvSplashes_select(QModelIndex, QModelIndex); - void lvTriggers_select(QModelIndex, QModelIndex); - void lvMaps_select(QModelIndex, QModelIndex); - void on_cbAlRegeneration_toggled(bool checked); - void on_cbAlArmor_toggled(bool checked); + void on_pbAnimDel_clicked(); + void on_cbSplImage_currentIndexChanged(int index); + void on_cbTwImage_currentIndexChanged(int index); + void on_cbAlImage_currentIndexChanged(int index); + void on_pbAnimAdd_clicked(); + void on_pbImgDel_clicked(); + void on_pbImgAdd_clicked(); + void on_cbTrigChildAim_currentIndexChanged(int index); + void on_cbTrigType_currentIndexChanged(int index); + void on_cbTrigCount_toggled(bool checked); + void on_leTrigName_editingFinished(); + void on_pbTwSplashEdit_clicked(); + void on_cbTrigDamRad_toggled(bool checked); + void on_cbTrigDamage_toggled(bool checked); + void on_cbTrigDelPar_toggled(bool checked); + void on_cbTrigChance_toggled(bool checked); + void on_cbTrigRandRadius_toggled(bool checked); + void on_cbTwExpByKill_toggled(bool checked); + void on_cbTwExpByDam_toggled(bool checked); + void on_cbTwExpByShot_toggled(bool checked); + void on_cbAlIsFly_toggled(bool checked); + void on_pbTrigDel_clicked(); + void on_pbTrigAdd_clicked(); + void on_sbTrigChance_valueChanged(int ); + void on_sbTrigDamRadius_valueChanged(double ); + void on_sbTrigDamage_valueChanged(double ); + void on_sbTrigTimer_valueChanged(int ); + void on_sbTrigRandomRadius_valueChanged(double ); + void on_sbTrigCount_valueChanged(int ); + void on_pbReload_clicked(); + void on_pbSlpDel_clicked(); + void on_pbSplAdd_clicked(); + void on_sbSplLifeTime_valueChanged(int ); + void on_cbSplAutoControl_toggled(bool checked); + void on_sbSplSpeed_valueChanged(double ); + void on_leSplName_editingFinished(); + void on_pbTwDel_clicked(); + void on_sbTwExpByKill_valueChanged(double ); + void on_sbTwExpByDam_valueChanged(double ); + void on_sbTwExpByShot_valueChanged(double ); + void on_sbTwRadius_valueChanged(double ); + void on_sbTwReload_valueChanged(int ); + void on_cbTwSplash_currentIndexChanged(int index); + void on_sbTwCost_valueChanged(int ); + void on_sbTwBuildTime_valueChanged(int ); + void on_pbTwAdd_clicked(); + void on_leTwName_editingFinished(); + void on_pbAlDel_clicked(); + void on_pbAlAdd_clicked(); + void on_leAlName_editingFinished(); + void on_sbAlScore_valueChanged(int ); + void on_sbAlPrise_valueChanged(int ); + void on_sbAlSpeed_valueChanged(double ); + void on_sbAlregeneration_valueChanged(double ); + void on_sbAlArmor_valueChanged(double ); + void on_sbAlHealth_valueChanged(double ); + void on_pbSave_clicked(); + void lvAliens_select(QModelIndex, QModelIndex); + void lvAnimations_select(QModelIndex, QModelIndex); + void lvTowers_select(QModelIndex, QModelIndex); + void lvSplashes_select(QModelIndex, QModelIndex); + void lvTriggers_select(QModelIndex, QModelIndex); + void lvMaps_select(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); }; #endif // MAINWINDOW_H diff --git a/ADeditor/mainwindow.ui b/ADeditor/mainwindow.ui index 87d1449..ff21582 100644 --- a/ADeditor/mainwindow.ui +++ b/ADeditor/mainwindow.ui @@ -47,7 +47,7 @@ QTabWidget::Rounded - 5 + 2 true @@ -875,19 +875,7 @@ QFrame::Raised - - - QLayout::SetDefaultConstraint - - - 5 - - - 5 - - - 2 - + @@ -964,7 +952,7 @@ - LifeTime + Life time Qt::AlignCenter @@ -986,6 +974,197 @@ + + + + + + + 0 + 0 + + + + Animation speed + + + Qt::AlignCenter + + + + + + + true + + + 0.010000000000000 + + + 999999999.000000000000000 + + + 1.000000000000000 + + + + + + + + + + + + 0 + 0 + + + + Z value + + + Qt::AlignCenter + + + + + + + true + + + 1.000000000000000 + + + + + + + + + + + + 0 + 0 + + + + Composition mode + + + Qt::AlignCenter + + + + + + + true + + + + Source + + + + + NotSource + + + + + Plus + + + + + Multiply + + + + + Screen + + + + + Overlay + + + + + Darken + + + + + Lighten + + + + + ColorDodge + + + + + ColorBurn + + + + + HardLight + + + + + SoftLight + + + + + Difference + + + + + + + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + Keep on alien + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -1000,7 +1179,7 @@ Qt::LeftToRight - AutoControl + Auto control @@ -1258,7 +1437,7 @@ - + 0 @@ -1673,6 +1852,9 @@ QAbstractItemView::NoEditTriggers + + QAbstractItemView::InternalMove + QAbstractItemView::ExtendedSelection diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 6f629f0..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 2.6) -project(Alien_Defender) -find_package(Qt4 REQUIRED) -include_directories(${QT_INCLUDES}) -file(GLOB MOCS "./*.h") -file(GLOB CPPS "./*.cpp") -file(GLOB UIS "./*.ui") -file(GLOB RES "./*.qrc") -add_definitions(-Wall -O2 -g3 -ggdb) -qt4_wrap_ui(CUIS ${UIS}) -qt4_wrap_cpp(CMOCS ${MOCS}) -qt4_add_resources(CRES ${RES}) -add_executable(AlienDefender ${CMOCS} ${CUIS} ${CPPS} ${CRES}) -target_link_libraries(AlienDefender ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTXMLPATTERNS_LIBRARY}) diff --git a/ad_graphics.cpp b/ad_graphics.cpp index 2c80e7d..869f877 100644 --- a/ad_graphics.cpp +++ b/ad_graphics.cpp @@ -4,16 +4,24 @@ -AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(parent) +AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(parent) , color_curve(QEasingCurve::InQuad) { + focus_item = select_tow = select_al = 0; data = adcore->addata; core = adcore; setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); setAlignment(Qt::AlignLeft | Qt::AlignTop); + setMouseTracking(true); scene = new QGraphicsScene(); scene->setItemIndexMethod(QGraphicsScene::NoIndex); core->setScene(scene); setScene(scene); + selection_al = new ADItem(-1, ADItem::Other, core->addata->alienSelect.images); + selection_al->hide(); + selection_tow = new ADItem(-1, ADItem::Other, core->addata->towerSelect.images); + selection_tow->hide(); + scene->addItem(selection_al); + scene->addItem(selection_tow); //setCacheMode(); //setViewportUpdateMode(QGraphicsView::FullViewportUpdate); mapimg = new QImage(data->map->rect().size()*cellSize,QImage::Format_ARGB32); @@ -46,6 +54,7 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren scene->setSceneRect(mapimg->rect()); scene->setBackgroundBrush(*mapimg); setCacheMode(QGraphicsView::CacheBackground); + setRenderHints(QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing); resize(mapimg->size()); startTimer(50); } @@ -53,13 +62,15 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren AD_Graphics::~AD_Graphics() { + delete selection_tow; + delete selection_al; delete scene; } 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()); @@ -72,8 +83,9 @@ void AD_Graphics::mousePressEvent(QMouseEvent *event) ADItem * i = qgraphicsitem_cast(x); if (i->itemType() == ADItem::Tower) { - i->setSelected(true); - emit tower_select(i->tid()); +// i->setSelected(true); + select_tow = i; + emit selected_tower_changed(i->tid()); return; } if (i->itemType() == ADItem::Alien) @@ -83,19 +95,37 @@ void AD_Graphics::mousePressEvent(QMouseEvent *event) } if (al != 0) { - al->setSelected(true); - emit alien_select(al->id()); +// al->setSelected(true); + select_al = al; + core->addata->players.at(0)->selectAlienId = select_al->id(); return; } } } if (event->button() == Qt::RightButton) + { + select_al = 0; + select_tow = 0; + emit selected_tower_changed(QPoint()); emit cancel(); + } } void AD_Graphics::timerEvent(QTimerEvent * ) { + if (select_al != 0) + { + selection_al->setPos(select_al->pos()); + selection_al->show(); + } else selection_al->hide(); + if (select_tow != 0) + { + selection_tow->setPos(select_tow->pos()); + selection_tow->show(); + } else selection_tow->hide(); + selection_tow->next(); + selection_al->next(); if (!core->isWaveEnd()) scene->update(); } @@ -116,9 +146,38 @@ void AD_Graphics::drawForeground(QPainter *p, const QRectF &rect) if (i->isBarVisible()) { p->setPen(Qt::black); - p->setBrush(QBrush(QColor(qRound(255*(1-i->value())),qRound(255*i->value()),0))); + p->setBrush(Qt::NoBrush); + p->drawRect(i->pos().x()-cellSize-1,i->pos().y()-cellSize*1.25-1,cellSize*2+2,cellSize/4+2); + p->setPen(Qt::NoPen); + p->setBrush(QBrush(QColor::fromHsv(120*color_curve.valueForProgress(i->value()),230,230))); p->drawRect(i->pos().x()-cellSize,i->pos().y()-cellSize*1.25,cellSize*2*i->value(),cellSize/4); } } + if (focus_item != 0) + { + 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); + p->drawEllipse(focus_item->pos(), r, r); + } + } +} + + +void AD_Graphics::mouseMoveEvent(QMouseEvent *event) +{ + QList li = scene->items(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(); + return; + } + } +// selection_tow->hide(); + focus_item = 0; } diff --git a/ad_graphics.h b/ad_graphics.h index d69b67e..97411b9 100644 --- a/ad_graphics.h +++ b/ad_graphics.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "adcore.h" @@ -14,42 +15,43 @@ class AD_Graphics: public QGraphicsView Q_PROPERTY(bool building READ building WRITE setBuilding) public: explicit AD_Graphics(AD_Core * core, QWidget * parent = 0); + QPoint selectedTower() {if (select_tow != 0) return select_tow->tid(); else return QPoint();} + int selectedAlien() {if (select_al != 0) return select_al->id(); else return -1;} ~AD_Graphics(); - - bool building() const - { - return m_building; - } + bool building() const {return m_building;} public slots: - void setBuilding(bool arg) - { - m_building = arg; - } + void selectTower(ADItem * item) {select_tow = item;} + void setBuilding(bool arg) {m_building = arg;} + void alienKilled(int id) {if (select_al != 0) if (select_al->id() == id) select_al = 0;} + void towerKilled(QPoint id) {if (select_tow != 0) if (select_tow->tid() == id) {select_tow = 0; emit selected_tower_changed(QPoint());}} private: void drawBackground(QPainter * p, const QRectF &); void drawForeground(QPainter *painter, const QRectF &rect); void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); QGraphicsScene * scene; AD_Core * core; QImage * mapimg; Game_Data * data; + ADItem * focus_item; + ADItem * select_al; + ADItem * select_tow; + ADItem * selection_tow; + ADItem * selection_al; + QEasingCurve color_curve; bool m_building; -private slots: - protected: - void timerEvent(QTimerEvent * ); -signals: +signals: void cancel(); void add_tow(QPoint pnt); - void tower_select(QPoint id); - void alien_select(int id); + void selected_tower_changed(QPoint id); }; #endif // AD_GRAPHICS_H diff --git a/adcore.cpp b/adcore.cpp index b49a6f0..f346428 100644 --- a/adcore.cpp +++ b/adcore.cpp @@ -8,7 +8,7 @@ AD_Core::AD_Core(QObject *parent) : adloader->load("data2.xml"); addata = adloader->loadlevel(1); delete adloader; - if (addata != 0) qDebug("Sucsess"); + if (addata != 0) qDebug("Success"); else qFatal("Error"); adtowers = new Towers(addata); adsplashes = new Splashes(addata); @@ -17,7 +17,7 @@ AD_Core::AD_Core(QObject *parent) : connect(adsplashes,SIGNAL(killAlien(int,int)),this,SLOT(killAlien(int,int))); waveInProgress = false; waveEnd = false; - startTimer(50); + timer = startTimer(40); } @@ -26,6 +26,10 @@ void AD_Core::next() adtowers->update(); adsplashes->update(); addata->aliens->update(); + foreach(Player * p, addata->players) + { + if (!addata->aliens->curAliens.contains(p->selectAlienId)) p->selectAlienId = -1; + } waveProcessing(); step++; } @@ -81,7 +85,7 @@ void AD_Core::waveProcessing() void AD_Core::killAlien(int playerId, int alienId) { - addata->players.at(playerId)->money += addata->aliens->curAliens[alienId].src->prise; + addata->players[playerId]->money += addata->aliens->curAliens[alienId].src->prise; addata->aliens->delAlien(alienId); } @@ -92,3 +96,10 @@ void AD_Core::setScene(QGraphicsScene *scene) adtowers->setScene(scene); adsplashes->setScene(scene); } + + +void AD_Core::setSpeed(float x) +{ + killTimer(timer); + timer = startTimer(qRound(40.f/x)); +} diff --git a/adcore.h b/adcore.h index 78aaf5e..8ccd013 100644 --- a/adcore.h +++ b/adcore.h @@ -10,33 +10,36 @@ class AD_Core : public QThread { -Q_OBJECT + Q_OBJECT public: - explicit AD_Core(QObject *parent = 0); - Game_Data * addata; - Towers * adtowers; - Splashes * adsplashes; - long int step; + explicit AD_Core(QObject *parent = 0); + Game_Data * addata; + Towers * adtowers; + Splashes * adsplashes; + long int step; - void setScene(QGraphicsScene * scene); - bool isWaveEnd() {return waveEnd;} + void setScene(QGraphicsScene * scene); + bool isWaveEnd() {return waveEnd;} + void setSpeed(float x); public slots: - void next(); - void nextWave(); + void next(); + void nextWave(); private: - void timerEvent(QTimerEvent * ); - void waveProcessing(); + void timerEvent(QTimerEvent * ); + void waveProcessing(); - bool waveInProgress; - bool waveEnd; - int wavetime; + bool waveInProgress; + bool waveEnd; + int wavetime; + int timer; private slots: - void killAlien(int playerId, int alienId); + void killAlien(int playerId, int alienId); signals: + }; #endif // ADCORE_H diff --git a/aditem.cpp b/aditem.cpp index b4788fb..a51cf1a 100644 --- a/aditem.cpp +++ b/aditem.cpp @@ -6,69 +6,80 @@ ADItem::ADItem(int id, adType type, QList *images_, QRectF geometry, QGraphicsItem *parent) : QGraphicsItem(parent) { - m_id = id; - m_type = type; - anim = 0; - images = images_; - animcount = images->size(); - QSize size = images->at(0)->size(); - staticImage = false; - if (animcount == 1) staticImage = true; - if (geometry.isNull()) br = QRect(QPoint(-(size.width()/2), -(size.height()/2)), size); - else br = geometry; - if (type == Alien) - { - setFlag(QGraphicsItem::ItemIsSelectable); - barValue = 1.f; - hasBar = true; - } else hasBar = false; - if (staticImage) - { - setCacheMode(QGraphicsItem::ItemCoordinateCache); - img = (*images)[0]; - } + m_id = id; + m_type = type; + anim = 0; + images = images_; + animcount = images->size(); + QSize size = images->at(0)->size(); + staticImage = false; + if (animcount == 1) staticImage = true; + if (geometry.isNull()) br = QRect(QPoint(-(size.width()/2), -(size.height()/2)), size); + else br = geometry; + hasBar = false; + switch (type) + { + case Alien : + setFlag(QGraphicsItem::ItemIsSelectable); + barValue = 1.f; + hasBar = true; + setZValue(-1.f); + break; + case Other : + default: + setZValue(3.f); + } + if (staticImage) + { + setCacheMode(QGraphicsItem::ItemCoordinateCache); + img = (*images)[0]; + } + cmode = QPainter::CompositionMode_SourceOver; } ADItem::ADItem(QPoint id, QImage *image, QRectF geometry, QGraphicsItem *parent) : - QGraphicsItem(parent) + QGraphicsItem(parent) { - hasBar = true; - barValue = 0.f; - m_type = Tower; - m_tid = id; - img = image; - QSize size = img->size(); - if (geometry.isNull()) br = QRect(QPoint(-(size.width()/2),-(size.height()/2)),size); - else br = geometry; - staticImage = true; - setFlag(QGraphicsItem::ItemIsSelectable); + hasBar = true; + barValue = 0.f; + m_type = Tower; + setZValue(-2.f); + m_tid = id; + img = image; + QSize size = img->size(); + if (geometry.isNull()) br = QRectF(QPoint(-(size.width()/2),-(size.height()/2)),size); + else br = geometry; + staticImage = true; + setFlag(QGraphicsItem::ItemIsSelectable); + cmode = QPainter::CompositionMode_SourceOver; } void ADItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { - if (staticImage) - painter->drawImage(br,*img); - else painter->drawImage(br, *(images->at(qRound(anim)))); - if (isSelected()) - { - painter->setPen(Qt::red); - painter->drawRect(br); - } + painter->setCompositionMode(cmode); + if (staticImage) + painter->drawImage(br,*img); + else painter->drawImage(br, *(images->at(qRound(anim)))); + // if (isSelected()) + // { + // painter->setPen(Qt::red); + // painter->drawRect(br); + // } } QRectF ADItem::boundingRect() const { - return br; + return br; } void ADItem::next(float step) { - if (staticImage) return; - anim+=step; - if (qRound(anim) >= animcount) - anim = 0; + if (staticImage) return; + anim+=step; + if (qRound(anim) >= animcount) + anim = 0; } diff --git a/aditem.h b/aditem.h index a20c263..14aa381 100644 --- a/aditem.h +++ b/aditem.h @@ -2,37 +2,40 @@ #define ADITEM_H #include +#include class ADItem : public QGraphicsItem { public: - enum adType {Alien, Tower, Splash}; - explicit ADItem(int id, adType type, QList *images, QRectF geometry = QRectF(), QGraphicsItem *parent = 0); - explicit ADItem(QPoint id, QImage * image, QRectF geometry = QRectF(), QGraphicsItem *parent = 0); - void setBarValue(float val) {barValue = val;} - void setBarVisible(bool visible = true) {hasBar = visible;} - void hideBar() {hasBar = false; setCacheMode(QGraphicsItem::ItemCoordinateCache);} - float value() {return barValue;} - bool isBarVisible() {return hasBar;} - void next(float step); - QPoint tid() {return m_tid;} - int id() {return m_id;} - adType itemType() {return m_type;} + enum adType {Alien, Tower, Splash, Other}; + explicit ADItem(int id, adType type, QList *images, QRectF geometry = QRectF(), QGraphicsItem *parent = 0); + explicit ADItem(QPoint id, QImage * image, QRectF geometry = QRectF(), QGraphicsItem *parent = 0); + void setBarValue(float val) {barValue = val;} + void setBarVisible(bool visible = true) {hasBar = visible;} + void setCompositionMode(QPainter::CompositionMode mode) {cmode = mode;} + void hideBar() {hasBar = false; setCacheMode(QGraphicsItem::ItemCoordinateCache);} + float value() {return barValue;} + bool isBarVisible() {return hasBar;} + void next(float step = 1.f); + QPoint tid() {return m_tid;} + int id() {return m_id;} + adType itemType() {return m_type;} + QRectF boundingRect() const; private: - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - QRectF boundingRect() const; - QList * images; - QImage * img; - float anim; - adType m_type; - int m_id; - QPoint m_tid; - int animcount; - bool staticImage; - bool hasBar; - float barValue; - QRectF br; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + QList * images; + QImage * img; + float anim; + adType m_type; + int m_id; + QPoint m_tid; + int animcount; + bool staticImage; + bool hasBar; + float barValue; + QRectF br; + QPainter::CompositionMode cmode; }; #endif // ADITEM_H diff --git a/aliendefender.kdev4 b/aliendefender.kdev4 deleted file mode 100644 index ef3da10..0000000 --- a/aliendefender.kdev4 +++ /dev/null @@ -1,3 +0,0 @@ -[Project] -Manager=KDevCMakeManager -Name=aliendefender diff --git a/aliendefender.pro.user b/aliendefender.pro.user index b682870..093587a 100644 --- a/aliendefender.pro.user +++ b/aliendefender.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -87,7 +87,7 @@ Qt4ProjectManager.Target.DesktopTarget - 0 + 1 0 0 @@ -132,7 +132,7 @@ 2 false - Debug + qt Отладка Debug Qt4ProjectManager.Qt4BuildConfiguration 2 @@ -141,7 +141,7 @@ false - INVALID + 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 qmake @@ -182,12 +182,12 @@ 2 false - Release + qt Релиз Release Qt4ProjectManager.Qt4BuildConfiguration 0 D:/Dropbox/My Dropbox/projects/aliendefender-build-desktop - -1 + 7 false 2 diff --git a/aliendefender.pro.user.2.3pre1 b/aliendefender.pro.user.2.3pre1 new file mode 100644 index 0000000..de64635 --- /dev/null +++ b/aliendefender.pro.user.2.3pre1 @@ -0,0 +1,184 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + System + false + false + 4 + true + 1 + true + false + false + 0 + 4 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.Target.0 + + + + Qt4ProjectManager.Target.DesktopTarget + 0 + 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 + + + Сборка + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + Сборка + + Qt4ProjectManager.MakeStep + true + clean + + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + D:/Dropbox/My Dropbox/projects/aliendefender-build-desktop + 7 + 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 + + + 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 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + Сборка + + Qt4ProjectManager.MakeStep + true + + + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + D:/Dropbox/My Dropbox/projects/aliendefender-build-desktop + 2 + 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 + + + 0 + Установка + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + Без установки + Без установки + ProjectExplorer.DefaultDeployConfiguration + + 1 + + Конфигурация запуска Qt4 + aliendefender + Qt4ProjectManager.Qt4RunConfiguration + 2 + + aliendefender.pro + false + false + + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {00000000-0000-0000-0000-000000000000} + + + ProjectExplorer.Project.Updater.FileVersion + 9 + + diff --git a/aliens.cpp b/aliens.cpp index 431dfbd..620de65 100644 --- a/aliens.cpp +++ b/aliens.cpp @@ -60,6 +60,7 @@ void Aliens::retrace(bool * OK) void Aliens::delAlien(int id, bool missed) { + emit alien_killed(id); if (missed) { m_missingAliens++; diff --git a/aliens.h b/aliens.h index 987863c..8ab6ff2 100644 --- a/aliens.h +++ b/aliens.h @@ -11,28 +11,29 @@ class Aliens : public QObject { Q_OBJECT public: - explicit Aliens(Map * map, QObject *parent = 0); - void addAlien(int srcId); - void update(); - void setScene(QGraphicsScene * scene_) {scene = scene_;} - QList srcAliens; - QHash curAliens; - int missingAliens() {return m_missingAliens;} + explicit Aliens(Map * map, QObject *parent = 0); + void addAlien(int srcId); + void update(); + void setScene(QGraphicsScene * scene_) {scene = scene_;} + QList srcAliens; + QHash curAliens; + int missingAliens() {return m_missingAliens;} signals: + void alien_killed(int id); public slots: - void delAlien(int id, bool missed = false); - void retrace(bool * OK); + void delAlien(int id, bool missed = false); + void retrace(bool * OK); private: - Map * map; - QGraphicsScene * scene; + Map * map; + QGraphicsScene * scene; - QPointF globStart; - QPointF globFinish; - int nextId; - int m_missingAliens; + QPointF globStart; + QPointF globFinish; + int nextId; + int m_missingAliens; }; diff --git a/base_types.h b/base_types.h index c0213a6..c0fe569 100644 --- a/base_types.h +++ b/base_types.h @@ -15,180 +15,230 @@ #include #include #include +#include #include "aditem.h" const float cellSize = 20.f; +struct srcAlienType; +struct srcTowerType; +struct srcSplashType; +struct srcTriggerType; struct srcAlienType { - QString name; - float speed; - float health; - float armor; - float regeneration; - bool isFlying; - unsigned int score; - int imgType; - QList * images; - unsigned int prise; + QString name; + float speed; + float health; + float armor; + float regeneration; + bool isFlying; + unsigned int score; + int imgType; + QList * images; + unsigned int prise; }; struct AlienType { - int id; // uses for QHash - srcAlienType * src; - QPointF pos; - float angle; // -180 .. 180 - float speed; // cells per tick (speed=1 is 60cells by 1 sec for 60fps e.g.) - float health; - QPoint finish; - QVector path; - int pathIndex; - ADItem * item; + int id; // uses for QHash + srcAlienType * src; + QPointF pos; + float angle; // -180 .. 180 + float speed; // cells per tick (speed=1 is 60cells by 1 sec for 60fps e.g.) + float health; + QPoint finish; + QVector path; + int pathIndex; + ADItem * item; }; struct srcTriggerType { - enum triggerType - { - onDestination, - onTimer, - onAlienInRadius - }; + enum triggerType + { + onDestination, + onTimer, + onAlienInRadius + }; - enum aimType - { - noAim, - parentAim, - allSide, - nearlestAlien - }; - int childId; // =-1 for none birth splash (e.q. only damage) - aimType childAim; - bool delParent; - float damage; - float radius; - triggerType type; - unsigned int timer; - int count; - float randomPosRadius; + enum aimType + { + noAim, + parentAim, + allSide, + nearestAlien + }; + int childId; // =-1 for none birth splash (e.q. only damage) + aimType childAim; + bool delParent; + float damage; + float radius; + triggerType type; + unsigned int timer; + int count; + float randomPosRadius; }; struct TriggerOnDest { - srcTriggerType * src; + srcTriggerType * src; }; struct TriggerOnTimer { - srcTriggerType * src; - unsigned int timer; + srcTriggerType * src; + unsigned int timer; }; struct TriggerOnAlien { - srcTriggerType * src; - QList triggerAliens; + srcTriggerType * src; + QList triggerAliens; }; -struct srcSplashType; +struct MorphType +{ + srcTowerType * morph; + float expRequired; + unsigned int cost; +}; + struct srcTowerType { - QString name; - QImage * image; - int imgType; - int PlayerId; // tower's owner - unsigned int cost; - unsigned int reload; - unsigned int buildTime; - float radius; // in cells - float expByShot; - float expByKill; - float expByDamage; - QList triggers; - QList splashes; + QString name; + QImage * image; + int imgType; + int PlayerId; // tower's owner + unsigned int cost; + unsigned int reload; + unsigned int buildTime; + float radius; // in cells + float expByShot; + float expByKill; + float expByDamage; + bool isRoot; + QList triggers; + QList splashes; + QList morphs; }; struct TowerType { - srcTowerType * src; - int aim; // aim alien Id - int PlayerId; // tower's owner - QPoint pos; // same as Id; not QPointF because tower fixed on grid - float angle; // -180 .. 180 - unsigned int reload; // time for reload in ticks - unsigned int build; - float experience; - ADItem * item; - bool isBilding; + srcTowerType * src; + int aim; // aim alien Id + int PlayerId; // tower's owner + QPoint pos; // same as Id; not QPointF because tower fixed on grid + float angle; // -180 .. 180 + unsigned int reload; // time for reload in ticks + unsigned int build; + float experience; + ADItem * item; + bool isBilding; }; struct srcSplashType { - QString name; - int imgType; - float speed; // in cells - int lifetime; - bool autoControl; - QList triggerIndexes; - QList * images; + QString name; + int imgType; + float speed; // in cells + int lifetime; + bool autoControl; + bool keepOnAlien; + float animSpeed; + float ZValue; + QPainter::CompositionMode compositionMode; + QList triggerIndexes; + QList * images; }; struct SplashType { - int id; - srcSplashType * src; - srcTowerType * srcTow; + int id; + srcSplashType * src; + srcTowerType * srcTow; QPoint towerId; // parent tower, (0,0) or null for non parent - int PlayerId; - int AlienId; // aim alien (different from tower.AlienId) - QPointF destination; - int life; // in ticks - float angle; // -180 .. 180 - QPointF pos; - QList trigsOnAlien; - QList trigsOnDest; - QList trigsOnTimer; - ADItem * item; + int PlayerId; + int AlienId; // aim alien (different from tower.AlienId) + QPointF destination; + int life; // in ticks + float angle; // -180 .. 180 + QPointF pos; + QList trigsOnAlien; + QList trigsOnDest; + QList trigsOnTimer; + ADItem * item; }; -/// DEPRECATED !!! + struct AnimationType { - QList * images; + QList * images; }; -/// DEPRECATED !!! struct WaveType { - QList types; // some types of aliens (e.g. 2 fly and 3 grount in one wave) - QList counts; // count aliens of each type - unsigned int timeout; // time in ticks - unsigned int prise; + QList types; // some types of aliens (e.g. 2 fly and 3 grount in one wave) + QList counts; // count aliens of each type + unsigned int timeout; // time in ticks + unsigned int prise; }; inline uint qHash(const QPoint &pos) { - return qHash(pos.x() + (pos.y() << 16)); + return qHash(pos.x() + (pos.y() << 16)); } inline float distance2(const QPointF &p1, const QPointF &p2) { - return (p1.x()-p2.x())*(p1.x()-p2.x())+(p1.y()-p2.y())*(p1.y()-p2.y()); + return (p1.x()-p2.x())*(p1.x()-p2.x())+(p1.y()-p2.y())*(p1.y()-p2.y()); } + +template +class _PIForeachC { +public: + _PIForeachC(const Type & t): _t(t) {_it = _t.begin(); _break = false;} + typename Type::value_type _var; + typename Type::const_iterator _it; + const Type & _t; + bool _break, _inv; + inline bool isEnd() {return _it == _t.end();} + inline void operator ++() {_it++; _break = false;} +}; + +template +class _PIForeach { +public: + _PIForeach(Type & t): _t(t) {_it = _t.begin(); _break = false;} + typename Type::value_type _var; + typename Type::iterator _it; + Type & _t; + bool _break, _inv; + inline bool isEnd() {return _it == _t.end();} + inline void operator ++() {_it++; _break = false;} +}; + +#define piForTimes(c) for(int i = 0; i < c; ++i) + +#define piForeach(i,c) for(_PIForeach _for(c); !_for.isEnd(); ++_for) for(i = *_for._it; !_for._break; _for._break = true) +#define piForeachA(i,c) for(_PIForeach _for(c); !_for.isEnd(); ++_for) for(typeof(_for._var) & i(*_for._it); !_for._break; _for._break = true) +#define piForeachC(i,c) for(_PIForeachC _for(c); !_for.isEnd(); ++_for) for(const i = *_for._it; !_for._break; _for._break = true) +#define piForeachCA(i,c) for(_PIForeachC _for(c); !_for.isEnd(); ++_for) for(const typeof(_for._var) & i(*_for._it); !_for._break; _for._break = true) + +#define piForeachAC piForeachCA + #endif // BASE_TYPES_H diff --git a/clean b/clean deleted file mode 100755 index cf2793d..0000000 --- a/clean +++ /dev/null @@ -1,14 +0,0 @@ -#! /bin/bash -VERBOSE=1 make clean -for i in $( ls -1 ); do - if [ "`ls -1 --file-type | grep $i | grep -o /`" = "/" ]; then - cd $i - rm -rvf ./CMakeFiles - rm -vf ./CMakeCache.txt ./Makefile ./cmake_install.cmake ./install_manifest.txt ./*~ - cd ../ - fi -done -rm -rvf ./CMakeFiles -rm -vf ./CMakeCache.txt ./Makefile ./cmake_install.cmake ./install_manifest.txt ./*~ ./*cxx ./moc_* ./*.o -cd ADeditor -make clean \ No newline at end of file diff --git a/data2.xml b/data2.xml index a9961af..7091d57 100644 --- a/data2.xml +++ b/data2.xml @@ -1,8 +1,8 @@ - - + + @@ -13,105 +13,106 @@ - - - - - - - + + + + + + + + - + - + - + + - - - - - + + + + + + + - - - - - - - + + + + + + + + + - + - - - + + + + - + + - + + + - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/form.cpp b/form.cpp index 742074b..60eb469 100644 --- a/form.cpp +++ b/form.cpp @@ -1,37 +1,40 @@ #include "form.h" #include "ui_form.h" -#include "touchbuttframe.h" Form::Form(QWidget *parent) : QWidget(parent), ui(new Ui::Form) { - buildTowerId = -1; - cur_tow = QPoint(); - cur_al = -1; + buildTowerId = -1; ui->setupUi(this); - graphics = new AD_Graphics(&core); - ui->widget->layout()->addWidget(graphics); - TouchButtFrame * tbf = new TouchButtFrame(); - tbf->addButton(tr("delete")); - foreach (srcTowerType i, core.addata->players.at(0)->srcTowers) - { - tbf->addButton(i.name); - //QPushButton * butt = new QPushButton(i.name); - //towerButtons << butt; - //butt->setAutoDefault(true); - //butt->setAutoExclusive(true); - //butt->setCheckable(true); - } - ui->gbTowers->layout()->addWidget(tbf); - connect(tbf,SIGNAL(click(int)),this,SLOT(towerBuild(int))); - connect(tbf,SIGNAL(click(int)),tbf,SLOT(set_green(int))); - connect(graphics,SIGNAL(add_tow(QPoint)),this,SLOT(add_tow(QPoint))); - connect(graphics,SIGNAL(tower_select(QPoint)),this,SLOT(towerSelected(QPoint))); - connect(graphics,SIGNAL(alien_select(int)),this,SLOT(alienSelected(int))); + graphics = new AD_Graphics(&core); + ui->widget->layout()->addWidget(graphics); + TouchButtFrame * tbf = new TouchButtFrame(); + tbf->setOrientation(Qt::Vertical); + morphtbf = new TouchButtFrame(); + morphtbf->setOrientation(Qt::Vertical); + tbf->addButton(tr("delete")); + foreach (srcTowerType i, core.addata->players.at(0)->srcTowers) + { + tbf->addButton(i.name); + //QPushButton * butt = new QPushButton(i.name); + //towerButtons << butt; + //butt->setAutoDefault(true); + //butt->setAutoExclusive(true); + //butt->setCheckable(true); + } + ui->gbTowers->layout()->addWidget(tbf); + ui->verticalLayout_2->addWidget(morphtbf); + connect(tbf,SIGNAL(click(int)),this,SLOT(towerBuild(int))); + connect(tbf,SIGNAL(click(int)),tbf,SLOT(set_green(int))); + connect(morphtbf,SIGNAL(click(int)),this,SLOT(towerMorph(int))); + connect(graphics,SIGNAL(add_tow(QPoint)),this,SLOT(add_tow(QPoint))); + connect(core.adtowers,SIGNAL(tower_killed(QPoint)),graphics,SLOT(towerKilled(QPoint))); + connect(core.addata->aliens,SIGNAL(alien_killed(int)),graphics,SLOT(alienKilled(int))); connect(graphics,SIGNAL(cancel()),this,SLOT(cancel())); - this->startTimer(50); + connect(graphics,SIGNAL(selected_tower_changed(QPoint)),this,SLOT(selectedTowerChanged(QPoint))); + this->startTimer(50); } @@ -43,38 +46,37 @@ Form::~Form() void Form::on_pbNextWave_clicked() { - core.nextWave(); + core.nextWave(); } void Form::towerBuild(int index) { - buildTowerId = index-1; - if (index == 0) buildTowerId = -9; - graphics->setBuilding(true); - setCursor(Qt::CrossCursor); + buildTowerId = index-1; + if (index == 0) buildTowerId = -9; + graphics->setBuilding(true); + setCursor(Qt::CrossCursor); } void Form::add_tow(QPoint pnt) { - if (buildTowerId == -1) return; - if (buildTowerId == -9) {core.adtowers->delTower(pnt); return;} - core.adtowers->addTower(0,buildTowerId,pnt); + if (buildTowerId == -1) return; + if (buildTowerId == -9) + { + core.adtowers->delTower(pnt); + emit tower_killed(); + return; + } + core.adtowers->addTower(0,buildTowerId,pnt); } -//void Form::del_tow(QPoint pnt) -//{ -// core.adtowers->delTower(pnt); -//} - - void Form::cancel() { - buildTowerId = -1; - graphics->setBuilding(false); - setCursor(Qt::ArrowCursor); + buildTowerId = -1; + graphics->setBuilding(false); + setCursor(Qt::ArrowCursor); } @@ -82,37 +84,28 @@ void Form::timerEvent(QTimerEvent *) { QString twstr; QString alstr; - if (!cur_tow.isNull()) + if (!graphics->selectedTower().isNull()) { - if (core.addata->curTowers.contains(cur_tow)) - { - TowerType tw = core.addata->curTowers.value(cur_tow); - twstr = "\n\n " + tw.src->name; - if (tw.isBilding) twstr += tr("\n build %1/%2").arg(tw.build).arg(tw.src->buildTime); - twstr += tr("\n player %1\n exp %2").arg(tw.PlayerId).arg(tw.experience); - twstr += tr("\n reload %1/%2\n alien %3").arg(tw.reload).arg(tw.src->reload).arg(tw.aim); - twstr += tr("\n cost %1\n radius %2").arg(tw.src->cost).arg(tw.src->radius); - } else { - cur_tow = QPoint(); - } + TowerType &tw = core.addata->curTowers[graphics->selectedTower()]; + twstr = "\n\n " + tw.src->name; + if (tw.isBilding) twstr += tr("\n build %1/%2").arg(tw.build).arg(tw.src->buildTime); + twstr += tr("\n player %1\n exp %2").arg(tw.PlayerId).arg(tw.experience); + twstr += tr("\n reload %1/%2\n alien %3").arg(tw.reload).arg(tw.src->reload).arg(tw.aim); + twstr += tr("\n cost %1\n radius %2").arg(tw.src->cost).arg(tw.src->radius-1); + for (int i=0; imorphs.size(); ++i) + morphtbf->Button(i)->setEnabled(core.adtowers->canMorph(tw.pos,i)); } - if (cur_al != -1) + if (graphics->selectedAlien() != -1) { - if (core.addata->aliens->curAliens.contains(cur_al)) - { - AlienType al = core.addata->aliens->curAliens.value(cur_al); - alstr = "\n\n " + al.src->name; - if (al.src->isFlying) alstr += tr("\n flying"); - else alstr += tr("\n ground"); - alstr += tr("\n health %1/%2").arg(al.health).arg(al.src->health); - alstr += tr("\n speed %1/%2").arg(al.speed).arg(al.src->speed); - alstr += tr("\n armor %1\n regeneration %2").arg(al.src->armor).arg(al.src->regeneration); - alstr += tr("\n prise %1").arg(al.src->prise); - } else { - cur_al = -1; - } + AlienType al = core.addata->aliens->curAliens.value(graphics->selectedAlien()); + alstr = "\n\n " + al.src->name; + if (al.src->isFlying) alstr += tr("\n flying"); + else alstr += tr("\n ground"); + alstr += tr("\n health %1/%2").arg(al.health).arg(al.src->health); + alstr += tr("\n speed %1/%2").arg(al.speed).arg(al.src->speed); + alstr += tr("\n armor %1\n regeneration %2").arg(al.src->armor).arg(al.src->regeneration); + alstr += tr("\n prise %1").arg(al.src->prise); } - if (!core.addata->aliens->curAliens.contains(cur_al)) cur_al = -1; ui->lbInfo->setText(tr(" money %1 \n missing %2").arg(core.addata->players.at(0)->money).arg(core.addata->aliens->missingAliens()) + tr("\n aliens %1").arg(core.addata->aliens->curAliens.size()) + tr("\n towers %1").arg(core.addata->curTowers.size()) @@ -121,15 +114,27 @@ void Form::timerEvent(QTimerEvent *) } -void Form::towerSelected(QPoint id) +void Form::on_sbSpeed_valueChanged(double val) { - cur_tow = id; + core.setSpeed(val); } -void Form::alienSelected(int id) +void Form::selectedTowerChanged(QPoint id) { - cur_al = id; + morphtbf->deleteButtons(); + if (id.isNull()) return; + srcTowerType * t = core.addata->curTowers[id].src; + piForeachCA(i, t->morphs) + morphtbf->addButton(i.morph->name); } +void Form::towerMorph(int index) +{ + QPoint id(graphics->selectedTower()); + graphics->towerKilled(id); + core.adtowers->morphTower(id,index); + graphics->selectTower(core.addata->curTowers[id].item); + selectedTowerChanged(graphics->selectedTower()); +} diff --git a/form.h b/form.h index 9ce9039..1051240 100644 --- a/form.h +++ b/form.h @@ -4,6 +4,8 @@ #include #include "adcore.h" #include "ad_graphics.h" +#include "touchbuttframe.h" + namespace Ui { class Form; @@ -18,24 +20,25 @@ public: ~Form(); private slots: - void on_pbNextWave_clicked(); - void towerBuild(int index); - void add_tow(QPoint pnt); - //void del_tow(QPoint pnt); - void cancel(); - void towerSelected(QPoint id); - void alienSelected(int id); + void on_pbNextWave_clicked(); + void towerBuild(int index); + void towerMorph(int index); + void add_tow(QPoint pnt); + void selectedTowerChanged(QPoint id); + void cancel(); + + void on_sbSpeed_valueChanged(double arg1); private: - void timerEvent(QTimerEvent *); + void timerEvent(QTimerEvent *); + Ui::Form *ui; + int buildTowerId; + AD_Core core; + AD_Graphics * graphics; + TouchButtFrame * morphtbf; - Ui::Form *ui; - int buildTowerId; - AD_Core core; - AD_Graphics * graphics; - QPoint cur_tow; - int cur_al; - //QList towerButtons; +signals: + void tower_killed(); }; #endif // FORM_H diff --git a/form.ui b/form.ui index 9357572..669bf46 100644 --- a/form.ui +++ b/form.ui @@ -52,7 +52,7 @@ 0 0 135 - 194 + 324 @@ -85,11 +85,36 @@ + + + + speed + + + x + + + 1 + + + 0.100000000000000 + + + 0.500000000000000 + + + 1.000000000000000 + + + Qt::Vertical + + QSizePolicy::Preferred + 20 diff --git a/game_data.cpp b/game_data.cpp index b35fad6..25f83f1 100644 --- a/game_data.cpp +++ b/game_data.cpp @@ -3,7 +3,8 @@ Game_Data::Game_Data(Map *mapp, QObject *parent) : QObject(parent) { - map = mapp; - curWave = 0; - aliens = new Aliens(map); + map = mapp; + curWave = 0; +// alienSelect.images = towerSelect.images = 0; + aliens = new Aliens(map); } diff --git a/game_data.h b/game_data.h index 8cf2c1c..6086c83 100644 --- a/game_data.h +++ b/game_data.h @@ -11,18 +11,20 @@ class Game_Data : public QObject { Q_OBJECT public: - explicit Game_Data(Map * map, QObject *parent = 0); - QList srcSplashes; - QList srcTriggers; - QHash curSplashes; - QHash curTowers; - QList waves; - QList players; - QList curAnimations; - Map * map; - Aliens * aliens; - int curWave; - int missingAliens; + explicit Game_Data(Map * map, QObject *parent = 0); + QList srcSplashes; + QList srcTriggers; + QHash curSplashes; + QHash curTowers; + QList waves; + QList players; + QList curAnimations; + AnimationType towerSelect; + AnimationType alienSelect; + Map * map; + Aliens * aliens; + int curWave; + int missingAliens; signals: diff --git a/images.qrc b/images.qrc index 9e5f8d3..038ad78 100644 --- a/images.qrc +++ b/images.qrc @@ -1,30 +1,6 @@ - - images/Aliens/Al_00_0.png - images/Aliens/Al_00_1.png - images/Aliens/Al_00_2.png - images/Aliens/Al_00_3.png - images/Aliens/Al_00_4.png - images/Aliens/Al_00_5.png - images/Aliens/Al_00_6.png - images/Aliens/Al_00_7.png - images/Aliens/Al_00_8.png - images/Aliens/Al_00_9.png - images/Aliens/Al_00_10.png - images/Aliens/Al_00_11.png - images/Aliens/Al_00_12.png - images/Aliens/Al_00_13.png - images/Aliens/Al_00_14.png - images/Aliens/Al_00_15.png - images/Aliens/Al_00_16.png - images/Aliens/Al_00_17.png - images/Aliens/Al_00_18.png - images/Aliens/Al_00_19.png - images/Towers/00_0.png - images/Splashes/Rocket.png - images/Towers/01_6.png - images/Splashes/Shot_0.png - images/Splashes/Smoke_01.png - images/Splashes/expl.png + + schema.xml + images/select.png diff --git a/images/Interface/select_alien_0000.png b/images/Interface/select_alien_0000.png new file mode 100644 index 0000000..a0719d9 Binary files /dev/null and b/images/Interface/select_alien_0000.png differ diff --git a/images/Interface/select_alien_0001.png b/images/Interface/select_alien_0001.png new file mode 100644 index 0000000..9185d55 Binary files /dev/null and b/images/Interface/select_alien_0001.png differ diff --git a/images/Interface/select_alien_0002.png b/images/Interface/select_alien_0002.png new file mode 100644 index 0000000..dfdb610 Binary files /dev/null and b/images/Interface/select_alien_0002.png differ diff --git a/images/Interface/select_alien_0003.png b/images/Interface/select_alien_0003.png new file mode 100644 index 0000000..3de96f2 Binary files /dev/null and b/images/Interface/select_alien_0003.png differ diff --git a/images/Interface/select_alien_0004.png b/images/Interface/select_alien_0004.png new file mode 100644 index 0000000..2c46d97 Binary files /dev/null and b/images/Interface/select_alien_0004.png differ diff --git a/images/Interface/select_alien_0005.png b/images/Interface/select_alien_0005.png new file mode 100644 index 0000000..598cb0c Binary files /dev/null and b/images/Interface/select_alien_0005.png differ diff --git a/images/Interface/select_alien_0006.png b/images/Interface/select_alien_0006.png new file mode 100644 index 0000000..c4824d3 Binary files /dev/null and b/images/Interface/select_alien_0006.png differ diff --git a/images/Interface/select_alien_0007.png b/images/Interface/select_alien_0007.png new file mode 100644 index 0000000..ac76711 Binary files /dev/null and b/images/Interface/select_alien_0007.png differ diff --git a/images/Interface/select_alien_0008.png b/images/Interface/select_alien_0008.png new file mode 100644 index 0000000..a4258af Binary files /dev/null and b/images/Interface/select_alien_0008.png differ diff --git a/images/Interface/select_alien_0009.png b/images/Interface/select_alien_0009.png new file mode 100644 index 0000000..5081915 Binary files /dev/null and b/images/Interface/select_alien_0009.png differ diff --git a/images/Interface/select_alien_0010.png b/images/Interface/select_alien_0010.png new file mode 100644 index 0000000..3f13507 Binary files /dev/null and b/images/Interface/select_alien_0010.png differ diff --git a/images/Interface/select_alien_0011.png b/images/Interface/select_alien_0011.png new file mode 100644 index 0000000..99d1f3c Binary files /dev/null and b/images/Interface/select_alien_0011.png differ diff --git a/images/Interface/select_alien_0012.png b/images/Interface/select_alien_0012.png new file mode 100644 index 0000000..55d89c9 Binary files /dev/null and b/images/Interface/select_alien_0012.png differ diff --git a/images/Interface/select_alien_0013.png b/images/Interface/select_alien_0013.png new file mode 100644 index 0000000..830e2be Binary files /dev/null and b/images/Interface/select_alien_0013.png differ diff --git a/images/Interface/select_alien_0014.png b/images/Interface/select_alien_0014.png new file mode 100644 index 0000000..074987d Binary files /dev/null and b/images/Interface/select_alien_0014.png differ diff --git a/images/Interface/select_alien_0015.png b/images/Interface/select_alien_0015.png new file mode 100644 index 0000000..8761131 Binary files /dev/null and b/images/Interface/select_alien_0015.png differ diff --git a/images/Interface/select_alien_0016.png b/images/Interface/select_alien_0016.png new file mode 100644 index 0000000..db5e996 Binary files /dev/null and b/images/Interface/select_alien_0016.png differ diff --git a/images/Interface/select_alien_0017.png b/images/Interface/select_alien_0017.png new file mode 100644 index 0000000..2a3c93d Binary files /dev/null and b/images/Interface/select_alien_0017.png differ diff --git a/images/Interface/select_alien_0018.png b/images/Interface/select_alien_0018.png new file mode 100644 index 0000000..0305a9d Binary files /dev/null and b/images/Interface/select_alien_0018.png differ diff --git a/images/Interface/select_alien_0019.png b/images/Interface/select_alien_0019.png new file mode 100644 index 0000000..3a2469b Binary files /dev/null and b/images/Interface/select_alien_0019.png differ diff --git a/images/Interface/select_alien_0020.png b/images/Interface/select_alien_0020.png new file mode 100644 index 0000000..3cada8c Binary files /dev/null and b/images/Interface/select_alien_0020.png differ diff --git a/images/Interface/select_alien_0021.png b/images/Interface/select_alien_0021.png new file mode 100644 index 0000000..e75a2f1 Binary files /dev/null and b/images/Interface/select_alien_0021.png differ diff --git a/images/Interface/select_alien_0022.png b/images/Interface/select_alien_0022.png new file mode 100644 index 0000000..b857c01 Binary files /dev/null and b/images/Interface/select_alien_0022.png differ diff --git a/images/Interface/select_alien_0023.png b/images/Interface/select_alien_0023.png new file mode 100644 index 0000000..d25bff8 Binary files /dev/null and b/images/Interface/select_alien_0023.png differ diff --git a/images/Interface/select_alien_0024.png b/images/Interface/select_alien_0024.png new file mode 100644 index 0000000..484c509 Binary files /dev/null and b/images/Interface/select_alien_0024.png differ diff --git a/images/Interface/select_alien_0025.png b/images/Interface/select_alien_0025.png new file mode 100644 index 0000000..69c836f Binary files /dev/null and b/images/Interface/select_alien_0025.png differ diff --git a/images/Interface/select_alien_0026.png b/images/Interface/select_alien_0026.png new file mode 100644 index 0000000..069a44b Binary files /dev/null and b/images/Interface/select_alien_0026.png differ diff --git a/images/Interface/select_alien_0027.png b/images/Interface/select_alien_0027.png new file mode 100644 index 0000000..e2eece5 Binary files /dev/null and b/images/Interface/select_alien_0027.png differ diff --git a/images/Interface/select_alien_0028.png b/images/Interface/select_alien_0028.png new file mode 100644 index 0000000..091ed58 Binary files /dev/null and b/images/Interface/select_alien_0028.png differ diff --git a/images/Interface/select_alien_0029.png b/images/Interface/select_alien_0029.png new file mode 100644 index 0000000..e3d7ca2 Binary files /dev/null and b/images/Interface/select_alien_0029.png differ diff --git a/images/Interface/select_alien_0030.png b/images/Interface/select_alien_0030.png new file mode 100644 index 0000000..9225806 Binary files /dev/null and b/images/Interface/select_alien_0030.png differ diff --git a/images/Interface/select_alien_0031.png b/images/Interface/select_alien_0031.png new file mode 100644 index 0000000..7e07964 Binary files /dev/null and b/images/Interface/select_alien_0031.png differ diff --git a/images/Interface/select_alien_0032.png b/images/Interface/select_alien_0032.png new file mode 100644 index 0000000..49cd253 Binary files /dev/null and b/images/Interface/select_alien_0032.png differ diff --git a/images/Interface/select_alien_0033.png b/images/Interface/select_alien_0033.png new file mode 100644 index 0000000..7b3ec66 Binary files /dev/null and b/images/Interface/select_alien_0033.png differ diff --git a/images/Interface/select_alien_0034.png b/images/Interface/select_alien_0034.png new file mode 100644 index 0000000..a534a81 Binary files /dev/null and b/images/Interface/select_alien_0034.png differ diff --git a/images/Interface/select_alien_0035.png b/images/Interface/select_alien_0035.png new file mode 100644 index 0000000..0afc0e1 Binary files /dev/null and b/images/Interface/select_alien_0035.png differ diff --git a/images/Interface/select_alien_0036.png b/images/Interface/select_alien_0036.png new file mode 100644 index 0000000..69b52cd Binary files /dev/null and b/images/Interface/select_alien_0036.png differ diff --git a/images/Interface/select_alien_0037.png b/images/Interface/select_alien_0037.png new file mode 100644 index 0000000..e45adad Binary files /dev/null and b/images/Interface/select_alien_0037.png differ diff --git a/images/Interface/select_alien_0038.png b/images/Interface/select_alien_0038.png new file mode 100644 index 0000000..c06cf26 Binary files /dev/null and b/images/Interface/select_alien_0038.png differ diff --git a/images/Interface/select_alien_0039.png b/images/Interface/select_alien_0039.png new file mode 100644 index 0000000..b8467a7 Binary files /dev/null and b/images/Interface/select_alien_0039.png differ diff --git a/images/Interface/select_alien_0040.png b/images/Interface/select_alien_0040.png new file mode 100644 index 0000000..4db2cbd Binary files /dev/null and b/images/Interface/select_alien_0040.png differ diff --git a/images/Interface/select_alien_0041.png b/images/Interface/select_alien_0041.png new file mode 100644 index 0000000..e706868 Binary files /dev/null and b/images/Interface/select_alien_0041.png differ diff --git a/images/Interface/select_alien_0042.png b/images/Interface/select_alien_0042.png new file mode 100644 index 0000000..f9e2a88 Binary files /dev/null and b/images/Interface/select_alien_0042.png differ diff --git a/images/Interface/select_alien_0043.png b/images/Interface/select_alien_0043.png new file mode 100644 index 0000000..c60a8ca Binary files /dev/null and b/images/Interface/select_alien_0043.png differ diff --git a/images/Interface/select_alien_0044.png b/images/Interface/select_alien_0044.png new file mode 100644 index 0000000..aafb736 Binary files /dev/null and b/images/Interface/select_alien_0044.png differ diff --git a/images/Interface/select_alien_0045.png b/images/Interface/select_alien_0045.png new file mode 100644 index 0000000..2c6f581 Binary files /dev/null and b/images/Interface/select_alien_0045.png differ diff --git a/images/Interface/select_alien_0046.png b/images/Interface/select_alien_0046.png new file mode 100644 index 0000000..2e4aea9 Binary files /dev/null and b/images/Interface/select_alien_0046.png differ diff --git a/images/Interface/select_alien_0047.png b/images/Interface/select_alien_0047.png new file mode 100644 index 0000000..1f2f9f8 Binary files /dev/null and b/images/Interface/select_alien_0047.png differ diff --git a/images/Interface/select_alien_0048.png b/images/Interface/select_alien_0048.png new file mode 100644 index 0000000..0d32519 Binary files /dev/null and b/images/Interface/select_alien_0048.png differ diff --git a/images/Interface/select_alien_0049.png b/images/Interface/select_alien_0049.png new file mode 100644 index 0000000..ba3ed00 Binary files /dev/null and b/images/Interface/select_alien_0049.png differ diff --git a/images/Interface/select_alien_0050.png b/images/Interface/select_alien_0050.png new file mode 100644 index 0000000..84c618d Binary files /dev/null and b/images/Interface/select_alien_0050.png differ diff --git a/images/Interface/select_tower_0000.png b/images/Interface/select_tower_0000.png new file mode 100644 index 0000000..31f611e Binary files /dev/null and b/images/Interface/select_tower_0000.png differ diff --git a/images/Interface/select_tower_0001.png b/images/Interface/select_tower_0001.png new file mode 100644 index 0000000..6acfb07 Binary files /dev/null and b/images/Interface/select_tower_0001.png differ diff --git a/images/Interface/select_tower_0002.png b/images/Interface/select_tower_0002.png new file mode 100644 index 0000000..3f6c274 Binary files /dev/null and b/images/Interface/select_tower_0002.png differ diff --git a/images/Interface/select_tower_0003.png b/images/Interface/select_tower_0003.png new file mode 100644 index 0000000..febced8 Binary files /dev/null and b/images/Interface/select_tower_0003.png differ diff --git a/images/Interface/select_tower_0004.png b/images/Interface/select_tower_0004.png new file mode 100644 index 0000000..60e6ad1 Binary files /dev/null and b/images/Interface/select_tower_0004.png differ diff --git a/images/Interface/select_tower_0005.png b/images/Interface/select_tower_0005.png new file mode 100644 index 0000000..70abf81 Binary files /dev/null and b/images/Interface/select_tower_0005.png differ diff --git a/images/Interface/select_tower_0006.png b/images/Interface/select_tower_0006.png new file mode 100644 index 0000000..be6898f Binary files /dev/null and b/images/Interface/select_tower_0006.png differ diff --git a/images/Interface/select_tower_0007.png b/images/Interface/select_tower_0007.png new file mode 100644 index 0000000..09beb55 Binary files /dev/null and b/images/Interface/select_tower_0007.png differ diff --git a/images/Interface/select_tower_0008.png b/images/Interface/select_tower_0008.png new file mode 100644 index 0000000..36376b7 Binary files /dev/null and b/images/Interface/select_tower_0008.png differ diff --git a/images/Interface/select_tower_0009.png b/images/Interface/select_tower_0009.png new file mode 100644 index 0000000..b182728 Binary files /dev/null and b/images/Interface/select_tower_0009.png differ diff --git a/images/Interface/select_tower_0010.png b/images/Interface/select_tower_0010.png new file mode 100644 index 0000000..7349b4f Binary files /dev/null and b/images/Interface/select_tower_0010.png differ diff --git a/images/Interface/select_tower_0011.png b/images/Interface/select_tower_0011.png new file mode 100644 index 0000000..6224bbf Binary files /dev/null and b/images/Interface/select_tower_0011.png differ diff --git a/images/Interface/select_tower_0012.png b/images/Interface/select_tower_0012.png new file mode 100644 index 0000000..665922b Binary files /dev/null and b/images/Interface/select_tower_0012.png differ diff --git a/images/Interface/select_tower_0013.png b/images/Interface/select_tower_0013.png new file mode 100644 index 0000000..962a311 Binary files /dev/null and b/images/Interface/select_tower_0013.png differ diff --git a/images/Interface/select_tower_0014.png b/images/Interface/select_tower_0014.png new file mode 100644 index 0000000..24c7743 Binary files /dev/null and b/images/Interface/select_tower_0014.png differ diff --git a/images/Interface/select_tower_0015.png b/images/Interface/select_tower_0015.png new file mode 100644 index 0000000..afbdc67 Binary files /dev/null and b/images/Interface/select_tower_0015.png differ diff --git a/images/Interface/select_tower_0016.png b/images/Interface/select_tower_0016.png new file mode 100644 index 0000000..02c4230 Binary files /dev/null and b/images/Interface/select_tower_0016.png differ diff --git a/images/Interface/select_tower_0017.png b/images/Interface/select_tower_0017.png new file mode 100644 index 0000000..5849a0d Binary files /dev/null and b/images/Interface/select_tower_0017.png differ diff --git a/images/Interface/select_tower_0018.png b/images/Interface/select_tower_0018.png new file mode 100644 index 0000000..ed4c202 Binary files /dev/null and b/images/Interface/select_tower_0018.png differ diff --git a/images/Interface/select_tower_0019.png b/images/Interface/select_tower_0019.png new file mode 100644 index 0000000..ca0258a Binary files /dev/null and b/images/Interface/select_tower_0019.png differ diff --git a/images/Interface/select_tower_0020.png b/images/Interface/select_tower_0020.png new file mode 100644 index 0000000..d6ec922 Binary files /dev/null and b/images/Interface/select_tower_0020.png differ diff --git a/images/Interface/select_tower_0021.png b/images/Interface/select_tower_0021.png new file mode 100644 index 0000000..a6ef4a4 Binary files /dev/null and b/images/Interface/select_tower_0021.png differ diff --git a/images/Interface/select_tower_0022.png b/images/Interface/select_tower_0022.png new file mode 100644 index 0000000..4a60538 Binary files /dev/null and b/images/Interface/select_tower_0022.png differ diff --git a/images/Interface/select_tower_0023.png b/images/Interface/select_tower_0023.png new file mode 100644 index 0000000..2e6c28a Binary files /dev/null and b/images/Interface/select_tower_0023.png differ diff --git a/images/Interface/select_tower_0024.png b/images/Interface/select_tower_0024.png new file mode 100644 index 0000000..1511111 Binary files /dev/null and b/images/Interface/select_tower_0024.png differ diff --git a/images/Interface/select_tower_0025.png b/images/Interface/select_tower_0025.png new file mode 100644 index 0000000..5bf9f06 Binary files /dev/null and b/images/Interface/select_tower_0025.png differ diff --git a/images/Interface/select_tower_0026.png b/images/Interface/select_tower_0026.png new file mode 100644 index 0000000..05241b2 Binary files /dev/null and b/images/Interface/select_tower_0026.png differ diff --git a/images/Interface/select_tower_0027.png b/images/Interface/select_tower_0027.png new file mode 100644 index 0000000..befc12d Binary files /dev/null and b/images/Interface/select_tower_0027.png differ diff --git a/images/Interface/select_tower_0028.png b/images/Interface/select_tower_0028.png new file mode 100644 index 0000000..2edaadb Binary files /dev/null and b/images/Interface/select_tower_0028.png differ diff --git a/images/Interface/select_tower_0029.png b/images/Interface/select_tower_0029.png new file mode 100644 index 0000000..63540b4 Binary files /dev/null and b/images/Interface/select_tower_0029.png differ diff --git a/images/Interface/select_tower_0030.png b/images/Interface/select_tower_0030.png new file mode 100644 index 0000000..26eefc6 Binary files /dev/null and b/images/Interface/select_tower_0030.png differ diff --git a/images/Interface/select_tower_0031.png b/images/Interface/select_tower_0031.png new file mode 100644 index 0000000..d4091cf Binary files /dev/null and b/images/Interface/select_tower_0031.png differ diff --git a/images/Interface/select_tower_0032.png b/images/Interface/select_tower_0032.png new file mode 100644 index 0000000..69abb82 Binary files /dev/null and b/images/Interface/select_tower_0032.png differ diff --git a/images/Interface/select_tower_0033.png b/images/Interface/select_tower_0033.png new file mode 100644 index 0000000..deb25c0 Binary files /dev/null and b/images/Interface/select_tower_0033.png differ diff --git a/images/Interface/select_tower_0034.png b/images/Interface/select_tower_0034.png new file mode 100644 index 0000000..ddb14e8 Binary files /dev/null and b/images/Interface/select_tower_0034.png differ diff --git a/images/Interface/select_tower_0035.png b/images/Interface/select_tower_0035.png new file mode 100644 index 0000000..ab92c1f Binary files /dev/null and b/images/Interface/select_tower_0035.png differ diff --git a/images/Interface/select_tower_0036.png b/images/Interface/select_tower_0036.png new file mode 100644 index 0000000..0352f49 Binary files /dev/null and b/images/Interface/select_tower_0036.png differ diff --git a/images/Interface/select_tower_0037.png b/images/Interface/select_tower_0037.png new file mode 100644 index 0000000..9639b57 Binary files /dev/null and b/images/Interface/select_tower_0037.png differ diff --git a/images/Interface/select_tower_0038.png b/images/Interface/select_tower_0038.png new file mode 100644 index 0000000..2627ed8 Binary files /dev/null and b/images/Interface/select_tower_0038.png differ diff --git a/images/Interface/select_tower_0039.png b/images/Interface/select_tower_0039.png new file mode 100644 index 0000000..2a91018 Binary files /dev/null and b/images/Interface/select_tower_0039.png differ diff --git a/images/Interface/select_tower_0040.png b/images/Interface/select_tower_0040.png new file mode 100644 index 0000000..cdf0224 Binary files /dev/null and b/images/Interface/select_tower_0040.png differ diff --git a/images/Interface/select_tower_0041.png b/images/Interface/select_tower_0041.png new file mode 100644 index 0000000..48cdaa8 Binary files /dev/null and b/images/Interface/select_tower_0041.png differ diff --git a/images/Interface/select_tower_0042.png b/images/Interface/select_tower_0042.png new file mode 100644 index 0000000..de35cd1 Binary files /dev/null and b/images/Interface/select_tower_0042.png differ diff --git a/images/Interface/select_tower_0043.png b/images/Interface/select_tower_0043.png new file mode 100644 index 0000000..c839a98 Binary files /dev/null and b/images/Interface/select_tower_0043.png differ diff --git a/images/Interface/select_tower_0044.png b/images/Interface/select_tower_0044.png new file mode 100644 index 0000000..1978802 Binary files /dev/null and b/images/Interface/select_tower_0044.png differ diff --git a/images/Interface/select_tower_0045.png b/images/Interface/select_tower_0045.png new file mode 100644 index 0000000..269631d Binary files /dev/null and b/images/Interface/select_tower_0045.png differ diff --git a/images/Interface/select_tower_0046.png b/images/Interface/select_tower_0046.png new file mode 100644 index 0000000..79e51e1 Binary files /dev/null and b/images/Interface/select_tower_0046.png differ diff --git a/images/Interface/select_tower_0047.png b/images/Interface/select_tower_0047.png new file mode 100644 index 0000000..128f400 Binary files /dev/null and b/images/Interface/select_tower_0047.png differ diff --git a/images/Interface/select_tower_0048.png b/images/Interface/select_tower_0048.png new file mode 100644 index 0000000..5fcf61c Binary files /dev/null and b/images/Interface/select_tower_0048.png differ diff --git a/images/Interface/select_tower_0049.png b/images/Interface/select_tower_0049.png new file mode 100644 index 0000000..081f8e9 Binary files /dev/null and b/images/Interface/select_tower_0049.png differ diff --git a/images/Interface/select_tower_0050.png b/images/Interface/select_tower_0050.png new file mode 100644 index 0000000..996882d Binary files /dev/null and b/images/Interface/select_tower_0050.png differ diff --git a/images/Splashes/Smoke_00.png b/images/Splashes/Smoke_00.png deleted file mode 100644 index 03060ee..0000000 Binary files a/images/Splashes/Smoke_00.png and /dev/null differ diff --git a/images/Splashes/Smoke_01.png b/images/Splashes/Smoke_01.png deleted file mode 100644 index 8200f2f..0000000 Binary files a/images/Splashes/Smoke_01.png and /dev/null differ diff --git a/images/Splashes/Smoke_02.png b/images/Splashes/Smoke_02.png deleted file mode 100644 index ea108ef..0000000 Binary files a/images/Splashes/Smoke_02.png and /dev/null differ diff --git a/images/Splashes/Smoke_03.png b/images/Splashes/Smoke_03.png deleted file mode 100644 index c8f386a..0000000 Binary files a/images/Splashes/Smoke_03.png and /dev/null differ diff --git a/images/Splashes/Smoke_04.png b/images/Splashes/Smoke_04.png deleted file mode 100644 index 20e430a..0000000 Binary files a/images/Splashes/Smoke_04.png and /dev/null differ diff --git a/images/Splashes/Smoke_05.png b/images/Splashes/Smoke_05.png deleted file mode 100644 index 57f7e80..0000000 Binary files a/images/Splashes/Smoke_05.png and /dev/null differ diff --git a/images/Splashes/Smoke_06.png b/images/Splashes/Smoke_06.png deleted file mode 100644 index 07e11a4..0000000 Binary files a/images/Splashes/Smoke_06.png and /dev/null differ diff --git a/images/Splashes/Smoke_07.png b/images/Splashes/Smoke_07.png deleted file mode 100644 index 1e4aa3d..0000000 Binary files a/images/Splashes/Smoke_07.png and /dev/null differ diff --git a/images/Splashes/Smoke_08.png b/images/Splashes/Smoke_08.png deleted file mode 100644 index 9fa8768..0000000 Binary files a/images/Splashes/Smoke_08.png and /dev/null differ diff --git a/images/Splashes/Smoke_09.png b/images/Splashes/Smoke_09.png deleted file mode 100644 index d9f0e67..0000000 Binary files a/images/Splashes/Smoke_09.png and /dev/null differ diff --git a/images/Splashes/Smoke_10.png b/images/Splashes/Smoke_10.png deleted file mode 100644 index abdd255..0000000 Binary files a/images/Splashes/Smoke_10.png and /dev/null differ diff --git a/images/Splashes/smoke_0001.png b/images/Splashes/smoke_0001.png new file mode 100644 index 0000000..7732fe9 Binary files /dev/null and b/images/Splashes/smoke_0001.png differ diff --git a/images/Splashes/smoke_0002.png b/images/Splashes/smoke_0002.png new file mode 100644 index 0000000..985e71e Binary files /dev/null and b/images/Splashes/smoke_0002.png differ diff --git a/images/Splashes/smoke_0003.png b/images/Splashes/smoke_0003.png new file mode 100644 index 0000000..9994016 Binary files /dev/null and b/images/Splashes/smoke_0003.png differ diff --git a/images/Splashes/smoke_0004.png b/images/Splashes/smoke_0004.png new file mode 100644 index 0000000..99313fa Binary files /dev/null and b/images/Splashes/smoke_0004.png differ diff --git a/images/Splashes/smoke_0005.png b/images/Splashes/smoke_0005.png new file mode 100644 index 0000000..60514ec Binary files /dev/null and b/images/Splashes/smoke_0005.png differ diff --git a/images/Splashes/smoke_0006.png b/images/Splashes/smoke_0006.png new file mode 100644 index 0000000..95b16e7 Binary files /dev/null and b/images/Splashes/smoke_0006.png differ diff --git a/images/Splashes/smoke_0007.png b/images/Splashes/smoke_0007.png new file mode 100644 index 0000000..42ee329 Binary files /dev/null and b/images/Splashes/smoke_0007.png differ diff --git a/images/Splashes/smoke_0008.png b/images/Splashes/smoke_0008.png new file mode 100644 index 0000000..b1f62fb Binary files /dev/null and b/images/Splashes/smoke_0008.png differ diff --git a/images/Splashes/smoke_0009.png b/images/Splashes/smoke_0009.png new file mode 100644 index 0000000..b1d1ee8 Binary files /dev/null and b/images/Splashes/smoke_0009.png differ diff --git a/images/Splashes/smoke_0010.png b/images/Splashes/smoke_0010.png new file mode 100644 index 0000000..c305053 Binary files /dev/null and b/images/Splashes/smoke_0010.png differ diff --git a/images/Splashes/smoke_0011.png b/images/Splashes/smoke_0011.png new file mode 100644 index 0000000..03d92b5 Binary files /dev/null and b/images/Splashes/smoke_0011.png differ diff --git a/images/Splashes/smoke_0012.png b/images/Splashes/smoke_0012.png new file mode 100644 index 0000000..31d5644 Binary files /dev/null and b/images/Splashes/smoke_0012.png differ diff --git a/images/Splashes/smoke_0013.png b/images/Splashes/smoke_0013.png new file mode 100644 index 0000000..268977d Binary files /dev/null and b/images/Splashes/smoke_0013.png differ diff --git a/images/Splashes/smoke_0014.png b/images/Splashes/smoke_0014.png new file mode 100644 index 0000000..53cace6 Binary files /dev/null and b/images/Splashes/smoke_0014.png differ diff --git a/images/Splashes/smoke_0015.png b/images/Splashes/smoke_0015.png new file mode 100644 index 0000000..5b52f2a Binary files /dev/null and b/images/Splashes/smoke_0015.png differ diff --git a/images/Splashes/smoke_0016.png b/images/Splashes/smoke_0016.png new file mode 100644 index 0000000..8187d6a Binary files /dev/null and b/images/Splashes/smoke_0016.png differ diff --git a/images/Splashes/smoke_0017.png b/images/Splashes/smoke_0017.png new file mode 100644 index 0000000..4092b00 Binary files /dev/null and b/images/Splashes/smoke_0017.png differ diff --git a/images/Splashes/smoke_0018.png b/images/Splashes/smoke_0018.png new file mode 100644 index 0000000..6df2f82 Binary files /dev/null and b/images/Splashes/smoke_0018.png differ diff --git a/images/Splashes/smoke_0019.png b/images/Splashes/smoke_0019.png new file mode 100644 index 0000000..55be6a8 Binary files /dev/null and b/images/Splashes/smoke_0019.png differ diff --git a/images/Splashes/smoke_0020.png b/images/Splashes/smoke_0020.png new file mode 100644 index 0000000..9662d43 Binary files /dev/null and b/images/Splashes/smoke_0020.png differ diff --git a/images/Splashes/smoke_0021.png b/images/Splashes/smoke_0021.png new file mode 100644 index 0000000..8c885b6 Binary files /dev/null and b/images/Splashes/smoke_0021.png differ diff --git a/images/Splashes/smoke_0022.png b/images/Splashes/smoke_0022.png new file mode 100644 index 0000000..b95db5d Binary files /dev/null and b/images/Splashes/smoke_0022.png differ diff --git a/images/Splashes/smoke_0023.png b/images/Splashes/smoke_0023.png new file mode 100644 index 0000000..d94c425 Binary files /dev/null and b/images/Splashes/smoke_0023.png differ diff --git a/images/Splashes/smoke_0024.png b/images/Splashes/smoke_0024.png new file mode 100644 index 0000000..76804af Binary files /dev/null and b/images/Splashes/smoke_0024.png differ diff --git a/images/Splashes/smoke_0025.png b/images/Splashes/smoke_0025.png new file mode 100644 index 0000000..39402f8 Binary files /dev/null and b/images/Splashes/smoke_0025.png differ diff --git a/images/Splashes/smoke_0026.png b/images/Splashes/smoke_0026.png new file mode 100644 index 0000000..3ec25e7 Binary files /dev/null and b/images/Splashes/smoke_0026.png differ diff --git a/images/Splashes/smoke_0027.png b/images/Splashes/smoke_0027.png new file mode 100644 index 0000000..863179a Binary files /dev/null and b/images/Splashes/smoke_0027.png differ diff --git a/images/Splashes/smoke_0028.png b/images/Splashes/smoke_0028.png new file mode 100644 index 0000000..7b6c41b Binary files /dev/null and b/images/Splashes/smoke_0028.png differ diff --git a/images/Splashes/smoke_0029.png b/images/Splashes/smoke_0029.png new file mode 100644 index 0000000..97e668e Binary files /dev/null and b/images/Splashes/smoke_0029.png differ diff --git a/images/Splashes/splashrocket.png b/images/Splashes/splashrocket.png deleted file mode 100644 index 52f430c..0000000 Binary files a/images/Splashes/splashrocket.png and /dev/null differ diff --git a/images/select.png b/images/select.png new file mode 100644 index 0000000..9ab8f8b Binary files /dev/null and b/images/select.png differ diff --git a/loader.cpp b/loader.cpp index 90d5359..de02598 100644 --- a/loader.cpp +++ b/loader.cpp @@ -1,908 +1,1115 @@ #include "loader.h" Loader::Loader(QObject *parent) : - QObject(parent) + QObject(parent) { - doc = new QDomDocument("data"); - qDebug() << createMapExample(); + doc = new QDomDocument("data"); + qDebug() << createMapExample(); } void Loader::load(QString filename) { - validate(filename); - file = new QFile(filename); - if (!file->open(QIODevice::ReadOnly)) - qFatal("No file data.xml found!"); - if (!doc->setContent(file)) - { - file->close(); - qFatal("Error parsing data.xml"); - } - readAnimations(); - readAliens(); - readMaps(); - readLevels(); - //readMorphs(); - readSplashes(); - readTowers(); - readTriggers(); - readChains(); - //readUpgrades(); - readLevTowers(); - readWaves(); - readWaveParts(); - readLevWaves(); + validate(filename); + file = new QFile(filename); + if (!file->open(QIODevice::ReadOnly)) + qFatal("No file data.xml found!"); + if (!doc->setContent(file)) + { + file->close(); + qFatal("Error parsing data.xml"); + } + readAnimations(); + readAliens(); + readMaps(); + readLevels(); + readSplashes(); + readTowers(); + readTriggers(); + readChains(); + //readUpgrades(); + readLevTowers(); + readMorphs(); + readWaves(); + readWaveParts(); + readLevWaves(); - file->close(); + file->close(); } void Loader::save(QString filename) { - QDomDocument data("data"); - QFile cfile(filename); - if (!cfile.open(QIODevice::WriteOnly)) - return; - cfile.resize(0); - QDomElement elem; - QDomElement root = data.createElement("ADdata"); - data.appendChild(root); - QDomElement child = data.createElement("aliens"); - root.appendChild(child); - for (int i=0; i 0) - elem.setAttribute("armor",al.armor); - if (al.isFlying) - elem.setAttribute("flying","true"); - elem.setAttribute("prise",al.prise); - if (al.regeneration > 0) - elem.setAttribute("regeneration",al.regeneration); - elem.setAttribute("score",al.score); - elem.setAttribute("speed",al.speed); - elem.setAttribute("imageType",al.imgType); - } - child = data.createElement("maps"); - root.appendChild(child); - for (int i=0; i 0) - elem.setAttribute("expByDamage",tw.expByDamage); - if (tw.expByKill > 0) - elem.setAttribute("expByKill",tw.expByKill); - if (tw.expByShot > 0) - elem.setAttribute("expByShot",tw.expByShot); - } - child = data.createElement("triggers"); - root.appendChild(child); - for (int i=0; i 0) - elem.setAttribute("count",trig.count); - if (trig.damage > 0) - elem.setAttribute("damage",trig.damage); - if (trig.radius > 0) - elem.setAttribute("radius",trig.radius); - if (trig.delParent) - elem.setAttribute("delParent","true"); - if (trig.randomPosRadius > 0) - elem.setAttribute("randomPosRadius",trig.randomPosRadius); - switch (trig.childAim) - { - case srcTriggerType::allSide : - elem.setAttribute("childAim","allSide"); - break; - case srcTriggerType::nearlestAlien : - elem.setAttribute("childAim","nearlestAlien"); - break; - case srcTriggerType::parentAim : - elem.setAttribute("childAim","parentAim"); - break; - default: - elem.setAttribute("childAim","noAim"); - break; - } - switch (trig.type) - { - case srcTriggerType::onTimer : - elem.setAttribute("type","onTimer"); - elem.setAttribute("timer",trig.timer); - break; - case srcTriggerType::onDestination : - elem.setAttribute("type","onDestination"); - break; - case srcTriggerType::onAlienInRadius : - elem.setAttribute("type","onAlienInRadius"); - break; - } - } - child = data.createElement("chains"); - root.appendChild(child); - for (int i=0; i 0) - elem.setAttribute("child",ch.childSplashId); - } - child = data.createElement("towersOnLevels"); - root.appendChild(child); - for (int i=0; i 0) + elem.setAttribute("armor",al.armor); + if (al.isFlying) + elem.setAttribute("flying","true"); + elem.setAttribute("prise",al.prise); + if (al.regeneration > 0) + elem.setAttribute("regeneration",al.regeneration); + elem.setAttribute("score",al.score); + elem.setAttribute("speed",al.speed); + elem.setAttribute("imageType",al.imgType); + } + child = data.createElement("maps"); + root.appendChild(child); + for (int i=0; i 0) + elem.setAttribute("expByDamage",tw.expByDamage); + if (tw.expByKill > 0) + elem.setAttribute("expByKill",tw.expByKill); + if (tw.expByShot > 0) + elem.setAttribute("expByShot",tw.expByShot); + } + child = data.createElement("triggers"); + root.appendChild(child); + for (int i=0; i 0) + elem.setAttribute("count",trig.count); + if (trig.damage > 0) + elem.setAttribute("damage",trig.damage); + if (trig.radius > 0) + elem.setAttribute("radius",trig.radius); + if (trig.delParent) + elem.setAttribute("delParent","true"); + if (trig.randomPosRadius > 0) + elem.setAttribute("randomPosRadius",trig.randomPosRadius); + switch (trig.childAim) + { + case srcTriggerType::allSide : + elem.setAttribute("childAim","allSide"); + break; + case srcTriggerType::nearestAlien : + elem.setAttribute("childAim","nearestAlien"); + break; + case srcTriggerType::parentAim : + elem.setAttribute("childAim","parentAim"); + break; + default: + elem.setAttribute("childAim","noAim"); + break; + } + switch (trig.type) + { + case srcTriggerType::onTimer : + elem.setAttribute("type","onTimer"); + elem.setAttribute("timer",trig.timer); + break; + case srcTriggerType::onDestination : + elem.setAttribute("type","onDestination"); + break; + case srcTriggerType::onAlienInRadius : + elem.setAttribute("type","onAlienInRadius"); + break; + } + } + child = data.createElement("chains"); + root.appendChild(child); + for (int i=0; i 0) + elem.setAttribute("child",ch.childSplashId); + } + child = data.createElement("towersOnLevels"); + root.appendChild(child); + for (int i=0; imaxPlayers(); i++) - { - Player * pl = new Player(i); - gd->players.append(pl); - } - qDebug() << gd->players.size(); - for (int i=0; imaxPlayers(); ++i) - gd->players.push_back(new Player(i)); - QList wollist = levWaves.values(id); - if (wollist.isEmpty()) - { - qCritical() << tr("Error no waves on level!"); - return 0; - } - tbWave tbw; - tbWavePart tbwpt; - QList wplist; - QList alienIds; - QList animIds; - for (int i=0; iwaves.prepend(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(); - } - wollist.clear(); - for (int i=0; ialiens->srcAliens.append(salt); - qDebug() << tr("Alien %1 #%2 ").arg(salt.name).arg(i); - } - QList tollist = levTowers.values(id); - tbTower tbt; - for (int i=0; i chlist = chains.values(tbt.id); - QList trigIds; - tbSplash tbs = splashes.value(tbt.splashId); - srcSplashType sst; - sst.autoControl = tbs.autoControl; - if (!animIds.contains(tbs.imgType)) - animIds.append(tbs.imgType); - sst.imgType = animIds.indexOf(tbs.imgType); - sst.lifetime = tbs.lifetime; - sst.name = tbs.name; - sst.speed = tbs.speed; - stt.splashes.append(sst); - int recursiveCheck = 1; - fillTowerChains(&animIds,&chlist,&trigIds,&stt, - tbt.splashId,0,&recursiveCheck); - for (int k=0; kmaxPlayers(); ++k) - gd->players[k]->srcTowers.append(stt); - qDebug() << tr("Tower %1 trig=%2 splash=%3").arg(stt.name).arg(stt.triggers.size()).arg(stt.splashes.size()) << tr("chain lenght %1").arg(recursiveCheck); - } - for (int i=0; i; - for (int k=0; kappend(new QImage(animations.value(animIds.at(i)) - .pathes.at(k))); - gd->curAnimations.append(anim); - } - for (int i=0; ialiens->srcAliens.size(); i++) - gd->aliens->srcAliens[i].images = gd->curAnimations.at(gd->aliens->srcAliens.at(i).imgType).images; - for (int i=0; iplayers.size(); i++) - for (int j=0; jplayers.at(i)->srcTowers.size(); j++) - { - gd->players[i]->srcTowers[j].image = gd->curAnimations.at(gd->players.at(i)->srcTowers.at(j).imgType).images->at(0); - for (int k=0; kplayers.at(i)->srcTowers.at(j).splashes.size(); k++) - gd->players[i]->srcTowers[j].splashes[k].images = gd->curAnimations.at(gd->players.at(i)->srcTowers.at(j).splashes.at(k).imgType).images; - } - return gd; + if (!levels.contains(id)) + { + qCritical() << tr("Error Level %1 not found!").arg(id); + return 0; + } + qDebug() << tr("Loading level %1 ...").arg(levels.value(id).name); + tbMap tbm = maps.value(levels.value(id).mapId); + Map * map = new Map(tbm.data,tbm.size,tbm.name,tbm.maxPlayers,tbm.imgType); + Game_Data * gd = new Game_Data(map); + for (int i=0; imaxPlayers(); i++) + { + Player * pl = new Player(i); + gd->players.append(pl); + } + qDebug() << gd->players.size(); + for (int i=0; imaxPlayers(); ++i) + gd->players.push_back(new Player(i)); + QList wollist = levWaves.values(id); + if (wollist.isEmpty()) + { + qCritical() << tr("Error no waves on level!"); + return 0; + } + tbWave tbw; + tbWavePart tbwpt; + QList wplist; + QList alienIds; + QList animIds; + for (int i=0; iwaves.prepend(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(); + } + wollist.clear(); + for (int i=0; ialiens->srcAliens.append(salt); + qDebug() << tr("Alien %1 #%2 ").arg(salt.name).arg(i); + } + QList tollist = levTowers.values(id); + tbTower tbt; + QList < QList > morph_indexes; + for (int i=0; i chlist = chains.values(tbt.id); + QList trigIds; + tbSplash tbs = splashes.value(tbt.splashId); + srcSplashType sst; + sst.autoControl = tbs.autoControl; + if (!animIds.contains(tbs.imgType)) + animIds.append(tbs.imgType); + sst.imgType = animIds.indexOf(tbs.imgType); + sst.lifetime = tbs.lifetime; + sst.name = tbs.name; + sst.speed = tbs.speed; + sst.animSpeed = tbs.animSpeed; + sst.ZValue = tbs.ZValue; + sst.compositionMode = tbs.compositionMode; + sst.keepOnAlien = tbs.keepOnAlien; + stt.splashes.append(sst); + int recursiveCheck = 1; + fillTowerChains(&animIds,&chlist,&trigIds,&stt, + tbt.splashId,0,&recursiveCheck); + morph_indexes.append(QList()); + QList morphlist = morphs.values(tbt.id); + bool contain; + tbTowerOnLevel j; + MorphType m; + foreach (tbMorph tmh, morphlist) + { + contain = false; + foreach(j,tollist) + { + if (j.towerId == tmh.toId) + { + contain = true; + break; + } + } + m.cost = tmh.cost; + m.expRequired = tmh.expRequired; + m.morph = (srcTowerType*)tollist.indexOf(j); + if (contain) morph_indexes[i].append(m); + } + for (int k=0; kmaxPlayers(); ++k) + gd->players[k]->srcTowers.append(stt); + qDebug() << tr("Tower %1 trig=%2 splash=%3").arg(stt.name).arg(stt.triggers.size()).arg(stt.splashes.size()) << tr("chain lenght %1").arg(recursiveCheck); + } + for (int i=0; imaxPlayers(); ++k) + { + j.morph = &(gd->players[k]->srcTowers[index]); + gd->players[k]->srcTowers[i].morphs.append(j); + } + } + } + QString morphtree; + foreach (srcTowerType i, gd->players[0]->srcTowers) + { + printMorphs(&i,morphtree,""); + } + qDebug() << morphtree + "\n"; + + /// =================================== + + for (int i=0; i; + for (int k=0; kappend(new QImage(animations.value(animIds.at(i)) + .pathes.at(k))); + gd->curAnimations.append(anim); + } + for (int i=0; ialiens->srcAliens.size(); i++) + gd->aliens->srcAliens[i].images = gd->curAnimations.at(gd->aliens->srcAliens.at(i).imgType).images; + for (int i=0; iplayers.size(); i++) + for (int j=0; jplayers.at(i)->srcTowers.size(); j++) + { + gd->players[i]->srcTowers[j].image = gd->curAnimations.at(gd->players.at(i)->srcTowers.at(j).imgType).images->at(0); + for (int k=0; kplayers.at(i)->srcTowers.at(j).splashes.size(); k++) + gd->players[i]->srcTowers[j].splashes[k].images = gd->curAnimations.at(gd->players.at(i)->srcTowers.at(j).splashes.at(k).imgType).images; + } + gd->towerSelect.images = gd->alienSelect.images = 0; + for (QHash::iterator i = animations.begin(); + i != animations.end(); ++i) + { + if (i->name == "tower select") + { + AnimationType anim; + anim.images = new QList; + for (int k = 0; k < i->pathes.size(); k++) + anim.images->append(new QImage(i->pathes.at(k))); + gd->towerSelect = anim; + } + if (i->name == "alien select") + { + AnimationType anim; + anim.images = new QList; + for (int k = 0; k < i->pathes.size(); k++) + anim.images->append(new QImage(i->pathes.at(k))); + gd->alienSelect = anim; + } + } + if (gd->towerSelect.images == 0) + { + AnimationType anim; + anim.images = new QList; + anim.images->append(new QImage(":/images/select.png")); + gd->towerSelect = anim; + } + if (gd->alienSelect.images == 0) + { + AnimationType anim; + anim.images = new QList; + anim.images->append(new QImage(":/images/select.png")); + gd->alienSelect = anim; + } + return gd; } void Loader::fillTowerChains(QList * animIds, QList * chlist, - QList * trigIds, srcTowerType * stt, - int parId, int parIndex, int * recursiveCheck) + QList * trigIds, srcTowerType * stt, + int parId, int parIndex, int * recursiveCheck) { - if (*recursiveCheck > 100) - { - qCritical("circle dependencies detected!"); - return; - } - for (int i=0; isize(); i++) - { - if (chlist->at(i).parentSplashId == parId) - { - int trigid = chlist->at(i).triggerId; - if (!(trigIds->contains(trigid))) - { - srcTriggerType strigt; - tbTrigger tbtrig = triggers.value(trigid); - strigt.count = tbtrig.count; - strigt.damage = tbtrig.damage; - strigt.delParent = tbtrig.delParent; - strigt.radius = tbtrig.radius; - if (strigt.radius <= 0 && strigt.damage>0 && !splashes.value(parId).autoControl) - qCritical("Wrong trigger or chain, because damage >0 radius=0 and not autocontrol.\nThis damage will be ignored!"); - strigt.randomPosRadius = tbtrig.randomPosRadius; - strigt.timer = tbtrig.timer; - strigt.type = tbtrig.type; - strigt.childAim = tbtrig.childAim; - strigt.childId = -1; - stt->triggers.append(strigt); - trigIds->append(trigid); - } - stt->splashes[parIndex].triggerIndexes.append(trigIds->indexOf(trigid)); - if (chlist->at(i).childSplashId > 0 && stt->triggers.at(trigIds->indexOf(trigid)).count > 0) - { - tbSplash tbs = splashes.value(chlist->at(i).childSplashId); - srcSplashType sst; - sst.autoControl = tbs.autoControl; - if (!animIds->contains(tbs.imgType)) - animIds->append(tbs.imgType); - sst.imgType = animIds->indexOf(tbs.imgType); - sst.lifetime = tbs.lifetime; - sst.name = tbs.name; - sst.speed = tbs.speed; - stt->splashes.append(sst); - stt->triggers[stt->splashes.at(parIndex).triggerIndexes.size()-1].childId = stt->splashes.size() - 1; - *recursiveCheck += 1; - fillTowerChains(animIds,chlist,trigIds,stt,chlist->at(i).childSplashId, stt->splashes.size()-1,recursiveCheck); - } - } - } + if (*recursiveCheck > 100) + { + qCritical("circle dependencies detected!"); + return; + } + for (int i=0; isize(); i++) + { + if (chlist->at(i).parentSplashId == parId) + { + int trigid = chlist->at(i).triggerId; + if (!(trigIds->contains(trigid))) + { + srcTriggerType strigt; + tbTrigger tbtrig = triggers.value(trigid); + strigt.count = tbtrig.count; + strigt.damage = tbtrig.damage; + strigt.delParent = tbtrig.delParent; + strigt.radius = tbtrig.radius; + if (strigt.radius <= 0 && strigt.damage>0 && !splashes.value(parId).autoControl) + qCritical("Wrong trigger or chain, because damage >0 radius=0 and not autocontrol.\nThis damage will be ignored!"); + strigt.randomPosRadius = tbtrig.randomPosRadius; + strigt.timer = tbtrig.timer; + strigt.type = tbtrig.type; + strigt.childAim = tbtrig.childAim; + strigt.childId = -1; + stt->triggers.append(strigt); + trigIds->append(trigid); + } + stt->splashes[parIndex].triggerIndexes.append(trigIds->indexOf(trigid)); + if (chlist->at(i).childSplashId > 0 && stt->triggers.at(trigIds->indexOf(trigid)).count > 0) + { + tbSplash tbs = splashes.value(chlist->at(i).childSplashId); + srcSplashType sst; + sst.autoControl = tbs.autoControl; + if (!animIds->contains(tbs.imgType)) + animIds->append(tbs.imgType); + sst.imgType = animIds->indexOf(tbs.imgType); + sst.lifetime = tbs.lifetime; + sst.name = tbs.name; + sst.speed = tbs.speed; + sst.animSpeed = tbs.animSpeed; + sst.ZValue = tbs.ZValue; + sst.compositionMode = tbs.compositionMode; + sst.keepOnAlien = tbs.keepOnAlien; + stt->splashes.append(sst); + stt->triggers[stt->splashes.at(parIndex).triggerIndexes.size()-1].childId = stt->splashes.size() - 1; + *recursiveCheck += 1; + fillTowerChains(animIds,chlist,trigIds,stt,chlist->at(i).childSplashId, stt->splashes.size()-1,recursiveCheck); + } + } + } } QString Loader::createMapExample() { - QVector < QVector < int > > Cells; + QVector < QVector < int > > Cells; Cells.resize(25); - for (int i=0; ielementsByTagName("alien"); - for (int i=0; ielementsByTagName("alien"); + for (int i=0; ielementsByTagName("wave"); - for (int i=0; ielementsByTagName("wave"); + for (int i=0; ielementsByTagName("wavePart"); - for (int i=0; ielementsByTagName("wavePart"); + for (int i=0; ielementsByTagName("chain"); - for (int i=0; i 0) - { - if (!splashes.contains(chain.childSplashId)) - { - qCritical("invalid child splash Id"); - OK = false; - } - } - chain.parentSplashId = nm.namedItem("parent").nodeValue().toInt(); - if (!splashes.contains(chain.parentSplashId)) - { - qCritical("invalid parent splash Id"); - OK = false; - } - chain.triggerId = nm.namedItem("trigger").nodeValue().toInt(); - if (!triggers.contains(chain.triggerId)) - { - qCritical("invalid parent splash Id"); - OK = false; - } - if (OK) - { - chains.insert(chain.towerId,chain); - //qDebug() << tr("Tower=%1 parent=%2 child=%3 trigger=%4").arg(chain.towerId).arg(chain.parentSplashId).arg(chain.childSplashId).arg(chain.triggerId); - } - } - //qDebug("================"); - qDebug() << tr("Found %1 chains").arg(chains.size()); - //qDebug("================"); + chains.clear(); + QDomNodeList celems = doc->elementsByTagName("chain"); + for (int i=0; i 0) + { + if (!splashes.contains(chain.childSplashId)) + { + qCritical("invalid child splash Id"); + OK = false; + } + } + chain.parentSplashId = nm.namedItem("parent").nodeValue().toInt(); + if (!splashes.contains(chain.parentSplashId)) + { + qCritical("invalid parent splash Id"); + OK = false; + } + chain.triggerId = nm.namedItem("trigger").nodeValue().toInt(); + if (!triggers.contains(chain.triggerId)) + { + qCritical("invalid parent splash Id"); + OK = false; + } + if (OK) + { + chains.insert(chain.towerId,chain); + //qDebug() << tr("Tower=%1 parent=%2 child=%3 trigger=%4").arg(chain.towerId).arg(chain.parentSplashId).arg(chain.childSplashId).arg(chain.triggerId); + } + } + //qDebug("================"); + qDebug() << tr("Found %1 chains").arg(chains.size()); + //qDebug("================"); +} + + +void Loader::readMorphs() +{ + morphs.clear(); + QDomNodeList celems = doc->elementsByTagName("morph"); + for (int i=0; ielementsByTagName("waveOnLevel"); - for (int i=0; ielementsByTagName("waveOnLevel"); + for (int i=0; ielementsByTagName("towerOnLevel"); - for (int i=0; ielementsByTagName("towerOnLevel"); + for (int i=0; ielementsByTagName("level"); - for (int i=0; ielementsByTagName("level"); + for (int i=0; ielementsByTagName("trigger"); - for (int i=0; i0)) trig.chance = 100; - str = nm.namedItem("delParent").nodeValue(); - trig.delParent = (str == "true"); - str = nm.namedItem("type").nodeValue(); - if (str == "onDestination") - trig.type = srcTriggerType::onDestination; - if (str == "onTimer") - trig.type = srcTriggerType::onTimer; - if (str == "onAlienInRadius") - trig.type = srcTriggerType::onAlienInRadius; - str = nm.namedItem("childAim").nodeValue(); - trig.childAim = srcTriggerType::noAim; - if (str == "allSide") - trig.childAim = srcTriggerType::allSide; - if (str == "parentAim") - trig.childAim = srcTriggerType::parentAim; - if (str == "nearlestAlien") - trig.childAim = srcTriggerType::nearlestAlien; - triggers.insert(trig.id,trig); - //qDebug() << tr("Trigger %1 id=%2 damage=%3 radius=%4 delParent=%5 timer=%6").arg(trig.name).arg(trig.id).arg(trig.damage).arg(trig.radius).arg(trig.delParent).arg(trig.timer) - // << tr("count=%1 chance=%2 randomPosRadius=%3 type=%4 childAim=%5").arg(trig.count).arg(trig.chance).arg(trig.randomPosRadius).arg(trig.type).arg(trig.childAim); - } - //qDebug("================"); - qDebug() << tr("Found %1 triggers").arg(triggers.size()); - //qDebug("================"); + triggers.clear(); + QString str; + QDomNodeList trelems = doc->elementsByTagName("trigger"); + for (int i=0; i0)) trig.chance = 100; + str = nm.namedItem("delParent").nodeValue(); + trig.delParent = (str == "true"); + str = nm.namedItem("type").nodeValue(); + if (str == "onDestination") + trig.type = srcTriggerType::onDestination; + if (str == "onTimer") + trig.type = srcTriggerType::onTimer; + if (str == "onAlienInRadius") + trig.type = srcTriggerType::onAlienInRadius; + str = nm.namedItem("childAim").nodeValue(); + trig.childAim = srcTriggerType::noAim; + if (str == "allSide") + trig.childAim = srcTriggerType::allSide; + if (str == "parentAim") + trig.childAim = srcTriggerType::parentAim; + if (str == "nearestAlien") + trig.childAim = srcTriggerType::nearestAlien; + triggers.insert(trig.id,trig); + //qDebug() << tr("Trigger %1 id=%2 damage=%3 radius=%4 delParent=%5 timer=%6").arg(trig.name).arg(trig.id).arg(trig.damage).arg(trig.radius).arg(trig.delParent).arg(trig.timer) + // << tr("count=%1 chance=%2 randomPosRadius=%3 type=%4 childAim=%5").arg(trig.count).arg(trig.chance).arg(trig.randomPosRadius).arg(trig.type).arg(trig.childAim); + } + //qDebug("================"); + qDebug() << tr("Found %1 triggers").arg(triggers.size()); + //qDebug("================"); } void Loader::readSplashes() { - splashes.clear(); - QString str; - QDomNodeList selems = doc->elementsByTagName("splash"); - for (int i=0; ielementsByTagName("splash"); + for (int i=0; ielementsByTagName("animation"); - for (int i=0; ielementsByTagName("animation"); + for (int i=0; ielementsByTagName("tower"); - for (int i=0; ielementsByTagName("tower"); + for (int i=0; ielementsByTagName("map"); - for (int i=0; ielementsByTagName("map"); + for (int i=0; iname + ":"; + foreach (MorphType i, stt->morphs) + printMorphs(i.morph,str,prefix+" "); +} + diff --git a/loader.h b/loader.h index f216aab..513a01e 100644 --- a/loader.h +++ b/loader.h @@ -10,182 +10,187 @@ struct tbHeader { - int id; - QString name; + int id; + QString name; }; struct tbAlien : tbHeader { - float speed; - float health; - float armor; - float regeneration; - bool isFlying; - unsigned int score; - int imgType; - unsigned int prise; + float speed; + float health; + float armor; + float regeneration; + bool isFlying; + unsigned int score; + int imgType; + unsigned int prise; }; struct tbSplash : tbHeader { - float speed; - unsigned int lifetime; - bool autoControl; - int imgType; + float speed; + unsigned int lifetime; + bool autoControl; + bool keepOnAlien; + int imgType; + float animSpeed; + float ZValue; + QPainter::CompositionMode compositionMode; }; struct tbTrigger : tbHeader { - float damage; - float radius; - int chance; - bool delParent; - srcTriggerType::aimType childAim; - srcTriggerType::triggerType type; - unsigned int timer; - int count; - float randomPosRadius; + float damage; + float radius; + int chance; + bool delParent; + srcTriggerType::aimType childAim; + srcTriggerType::triggerType type; + unsigned int timer; + int count; + float randomPosRadius; }; struct tbTower : tbHeader { - float radius; - unsigned int cost; - unsigned int reload; - unsigned int buildTime; - float expByShot; - float expByKill; - float expByDamage; - int splashId; - int imgType; + float radius; + unsigned int cost; + unsigned int reload; + unsigned int buildTime; + float expByShot; + float expByKill; + float expByDamage; + int splashId; + int imgType; }; struct tbChain { - int towerId; - int parentSplashId; - int childSplashId; - int triggerId; + int towerId; + int parentSplashId; + int childSplashId; + int triggerId; }; struct tbUpgrade { - int towerId; - int triggerId; - unsigned int cost; - float towRadius; - unsigned int towReload; - float trigDamage; - float trigDamageRadius; + int towerId; + int triggerId; + unsigned int cost; + float towRadius; + unsigned int towReload; + float trigDamage; + float trigDamageRadius; }; struct tbMorph { - int fromId; - int toId; - int cost; - float expRequired; + int fromId; + int toId; + int cost; + float expRequired; }; struct tbWavePart { - int waveId; - int alienId; - unsigned int count; + int waveId; + int alienId; + unsigned int count; }; struct tbWave { - int id; - unsigned int timeout; - unsigned int prise; - //int type; + int id; + unsigned int timeout; + unsigned int prise; + //int type; }; struct tbWaveOnLevel { - int levelId; - int waveId; + int levelId; + int waveId; }; struct tbMap : tbHeader { - unsigned int maxPlayers; - QByteArray data; - QSize size; - int imgType; + unsigned int maxPlayers; + QByteArray data; + QSize size; + int imgType; }; struct tbTowerOnLevel { - int levelId; - int towerId; - //int enableWaveId; + bool operator ==(const tbTowerOnLevel & other) const {return levelId == other.levelId && towerId == other.towerId;} + int levelId; + int towerId; + //int enableWaveId; }; struct tbLevel : tbHeader { - int mapId; - unsigned int score; + int mapId; + unsigned int score; }; -struct tbAnimation +struct tbAnimation : tbHeader { - int id; - QStringList pathes; + QStringList pathes; }; class Loader : public QObject { - Q_OBJECT + Q_OBJECT public: - explicit Loader(QObject *parent = 0); - void save(QString filename); - void load(QString filename); - Game_Data * loadlevel(int id); + explicit Loader(QObject *parent = 0); + void save(QString filename); + void load(QString filename); + Game_Data * loadlevel(int id); - QHash aliens; - QHash maps; - QHash levels; - QHash splashes; - QHash towers; - QHash triggers; - QHash waves; - QHash animations; - QMultiHash levWaves; - QMultiHash waveParts; - QMultiHash chains; - QMultiHash morphs; - QMultiHash levTowers; - QMultiHash upgrades; + QHash aliens; + QHash maps; + QHash levels; + QHash splashes; + QHash towers; + QHash triggers; + QHash waves; + QHash animations; + QMultiHash levWaves; + QMultiHash waveParts; + QMultiHash chains; + QMultiHash morphs; + QMultiHash levTowers; + QMultiHash upgrades; signals: public slots: private: - QDomDocument * doc; - QFile * file; + QDomDocument * doc; + QFile * file; - void readAliens(); - void readMaps(); - void readLevels(); - void readMorphs(); - void readSplashes(); - void readTowers(); - void readLevTowers(); - void readTriggers(); - void readChains(); - void readWaves(); - void readLevWaves(); - void readWaveParts(); - void readUpgrades(); - void readAnimations(); + void readAliens(); + void readMaps(); + void readLevels(); + void readMorphs(); + void readSplashes(); + void readTowers(); + void readLevTowers(); + void readTriggers(); + void readChains(); + void readWaves(); + void readLevWaves(); + void readWaveParts(); + void readUpgrades(); + void readAnimations(); - void fillTowerChains(QList * animIds, QList * chlist, QList * trigIds, srcTowerType * stt, int parId, int parIndex, int * recursiveCheck); - void validate(QString filename); - QString createMapExample(); + void fillTowerChains(QList * animIds, QList * chlist, QList * trigIds, srcTowerType * stt, int parId, int parIndex, int * recursiveCheck); + void validate(QString filename); + QString createMapExample(); + void printMorphs(srcTowerType * stt, QString & str, const QString & prefix); }; #endif // LOADER_H diff --git a/main.cpp b/main.cpp index 6988e5f..0597576 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "form.h" #include "ui_form.h" @@ -7,9 +8,10 @@ int main(int argc, char *argv[]) { - QApplication a(argc, argv); - a.setStyle("cleanlooks"); - Form f; - f.show(); - return a.exec(); + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); + QApplication a(argc, argv); + a.setStyle("cleanlooks"); + Form f; + f.show(); + return a.exec(); } diff --git a/make.sh b/make.sh deleted file mode 100755 index 2bdfa58..0000000 --- a/make.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/bash -cmake ./ -make $@ -cd ADeditor -qmake -make $@ \ No newline at end of file diff --git a/schema.xml b/schema.xml index 96db649..80d7228 100644 --- a/schema.xml +++ b/schema.xml @@ -1,130 +1,159 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + @@ -132,102 +161,103 @@ - - + + - + - - + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - + + + + + - - - - - - - - + + + + + + + + - - - - + + + + - - - - - + + + + + - - - - - + + + + + - - - + + + - - - - + + + + - - - - - + + + + + - - - - + + + + + diff --git a/splashes.cpp b/splashes.cpp index d80d0e9..6088bd6 100644 --- a/splashes.cpp +++ b/splashes.cpp @@ -81,22 +81,24 @@ void Splashes::addSplash(SplashType * spl) case srcTriggerType::onDestination : tod.src = trig; spl->trigsOnDest.append(tod); - break; + break; case srcTriggerType::onAlienInRadius : toa.src = trig; spl->trigsOnAlien.append(toa); - break; + break; case srcTriggerType::onTimer : tot.src = trig; tot.timer = 0; spl->trigsOnTimer.append(tot); - break; + break; } } spl->item = new ADItem(spl->id, ADItem::Splash, spl->src->images); spl->item->setPos(spl->pos*cellSize); spl->item->setRotation(spl->angle); + spl->item->setZValue(spl->src->ZValue); + spl->item->setCompositionMode(spl->src->compositionMode); scene->addItem(spl->item); gameData->curSplashes.insert(spl->id,*spl); nextId++; @@ -115,47 +117,60 @@ void Splashes::update() deadIndexes.insert(spl->id,spl->id); if (!spl->trigsOnTimer.isEmpty()) doTriggerOnTimer(spl,&deadIndexes); + if (!spl->trigsOnAlien.isEmpty()) + doTriggerOnAlien(spl,&deadIndexes); float arctg; float speed = spl->src->speed; float speed2 = speed*speed; - if (spl->src->autoControl && spl->AlienId != -1) + bool keep = spl->src->keepOnAlien; + if (spl->src->keepOnAlien) { - bool badAl = false; if (gameData->aliens->curAliens.contains(spl->AlienId)) - spl->destination = gameData->aliens->curAliens.value(spl->AlienId).pos+QPointF(0.5,0.5); - else { - badAl = true; - spl->AlienId = -1; - } - if (distance2(spl->pos, spl->destination) < speed2) { - if (badAl) - deadIndexes.insert(spl->id,spl->id); - spl->pos = spl->destination; - doTriggerOnDest(spl,&deadIndexes,badAl); - } - arctg = std::atan2(spl->pos.x() - spl->destination.x(),spl->pos.y() - spl->destination.y()); - spl->angle = 180.0f*(-arctg)/M_PI; + spl->pos = gameData->aliens->curAliens[spl->AlienId].pos; + spl->angle = gameData->aliens->curAliens[spl->AlienId].angle; + } else deadIndexes.insert(spl->id,spl->id); } else { - if (!gameData->map->rect().contains(spl->pos.toPoint())) - deadIndexes.insert(spl->id,spl->id); - if (!spl->trigsOnDest.isEmpty()) + if (spl->src->autoControl && spl->AlienId != -1) { + bool badAl = false; + if (gameData->aliens->curAliens.contains(spl->AlienId)) + { + spl->destination = gameData->aliens->curAliens.value(spl->AlienId).pos+QPointF(0.5,0.5); + } else { + badAl = true; + spl->AlienId = -1; + keep = false; + } if (distance2(spl->pos, spl->destination) < speed2) { + if (badAl) + deadIndexes.insert(spl->id,spl->id); spl->pos = spl->destination; - doTriggerOnDest(spl,&deadIndexes,true); + doTriggerOnDest(spl,&deadIndexes,badAl); } + arctg = std::atan2(spl->pos.x() - spl->destination.x(), spl->pos.y() - spl->destination.y()); + spl->angle = 180.0f*(-arctg)/M_PI; + } else { + if (!gameData->map->rect().contains(spl->pos.toPoint())) + deadIndexes.insert(spl->id,spl->id); + if (!spl->trigsOnDest.isEmpty()) + { + if (distance2(spl->pos, spl->destination) < speed2) + { + spl->pos = spl->destination; + doTriggerOnDest(spl,&deadIndexes,true); + } + } + arctg = -spl->angle*M_PI/180.f; } - arctg = -spl->angle*M_PI/180.f; + spl->pos.rx() -= speed*std::sin(arctg); + spl->pos.ry() -= speed*std::cos(arctg); } - spl->pos.rx() -= speed*std::sin(arctg); - spl->pos.ry() -= speed*std::cos(arctg); /// TODO: smooth splash rotate spl->item->setPos(spl->pos*cellSize); spl->item->setRotation(spl->angle); - if (speed == 0) spl->item->next(1.f); - else spl->item->next(speed*cellSize); + spl->item->next(spl->src->animSpeed); } for (QHash::iterator j = deadIndexes.begin(); j != deadIndexes.end(); ++j) @@ -187,6 +202,31 @@ void Splashes::doTriggerOnTimer(QHash::iterator if (i->timer >= strig->timer) { /// TODO : add damage and other effects + float dmg = strig->damage; + float rad = strig->radius; + if (dmg > 0) + { + float hh; + if (!(rad > 0)) + { + if (gameData->aliens->curAliens.contains(spl->AlienId)) + { + hh = gameData->aliens->curAliens[spl->AlienId].health -= dmg; + if (hh <= 0) dead.insert(spl->AlienId, DeadAlienIndex(spl->AlienId, spl->PlayerId)); + } + } else { + for (QHash::iterator + a = gameData->aliens->curAliens.begin(); + a != gameData->aliens->curAliens.end(); ++a) + { + if (distance2(spl->pos, a->pos) < rad*rad) + { + hh = a->health -= dmg; + if (hh <= 0) dead.insert(a->id, DeadAlienIndex(a->id, spl->PlayerId)); + } + } + } + } i->timer = 0; if (strig->delParent) deadIndexes->insert(spl->id,spl->id); if (strig->count > 0 && strig->childId > 0) @@ -221,9 +261,13 @@ void Splashes::doTriggerOnDest(QHash::iterator int aim; switch(t.src->childAim) { - case srcTriggerType::parentAim : aim = spl->AlienId; break; + case srcTriggerType::parentAim : + aim = spl->AlienId; + break; /// TODO : other aim types - case srcTriggerType::noAim : aim = -1; break; + case srcTriggerType::nearestAlien : + + case srcTriggerType::noAim : default : aim = -1; } if (t.src->count > 0 && t.src->childId > 0) @@ -262,3 +306,42 @@ void Splashes::doTriggerOnDest(QHash::iterator } } } + + +void Splashes::doTriggerOnAlien(QHash::iterator spl, QHash *deadIndexes) +{ + foreach(TriggerOnAlien t, spl->trigsOnAlien) + { + /// 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; + if (dmg > 0 && rad > 0) + { + float hh; + for (QHash::iterator + i = gameData->aliens->curAliens.begin(); + i != gameData->aliens->curAliens.end(); ++i) + { + if (distance2(spl->pos, i->pos) < rad*rad) + { + hh = i->health -= dmg; + if (hh <= 0) dead.insert(i->id, DeadAlienIndex(i->id, spl->PlayerId)); + if (t.src->count > 0 && t.src->childId > 0) + { + if (!t.triggerAliens.contains(i->id)) + { + for (int j=0; jcount; ++j) + { + /// TODO: randomRadiusPos + addSplash(spl->srcTow,t.src->childId, + spl->pos,i->pos,i->id,spl->towerId); + } + t.triggerAliens.append(i->id); + } + } + } + } + } + } +} diff --git a/splashes.h b/splashes.h index 9a5f7d6..331d74c 100644 --- a/splashes.h +++ b/splashes.h @@ -13,7 +13,6 @@ public: void setScene(QGraphicsScene * scene_) {scene = scene_;} signals: - /// TODO : fix killalien - new function for adding alien in kill list and del aliens in finish update void killAlien(int playerId, int alienId); public slots: @@ -40,6 +39,8 @@ private: bool badAl); void doTriggerOnTimer(QHash::iterator spl, QHash * deadIndexes); + void doTriggerOnAlien(QHash::iterator + spl, QHash * deadIndexes); }; #endif // SPLASHES_H diff --git a/touch_butt.h b/touch_butt.h index 5f2971b..5c040d0 100644 --- a/touch_butt.h +++ b/touch_butt.h @@ -16,8 +16,8 @@ public: void setRed(); void setGreen(); void setWhite(); - void setColor(QColor colr, QColor colg, QColor colw, QColor colp); - QColor color() const {return next_col;} + void setColor(QColor colr, QColor colg, QColor colw, QColor colp); + QColor color() const {return next_col;} public slots: void butt_click(); void butt_toggle(bool checked); diff --git a/touchbuttframe.cpp b/touchbuttframe.cpp index 8a77ca5..4fb7dfb 100644 --- a/touchbuttframe.cpp +++ b/touchbuttframe.cpp @@ -1,67 +1,102 @@ #include "touchbuttframe.h" -TouchButtFrame::TouchButtFrame(QWidget *parent, QColor cr, QColor cg, QColor cw, QColor cp, Orientation orientation) : +TouchButtFrame::TouchButtFrame(QWidget *parent, QColor cr, QColor cg, QColor cw, QColor cp, Qt::Orientation orientation) : QFrame(parent) { colr = cr; colg = cg; colw = cw; colp = cp; - setFrameShape(QFrame::StyledPanel);; - if (orientation == Horizontal) lay = new QHBoxLayout(); - else lay = new QVBoxLayout(); - count = 0; - + setFrameShape(QFrame::StyledPanel); + lay = new QBoxLayout(QBoxLayout::LeftToRight); + lay->setContentsMargins(0,0,0,0); + if (orientation == Qt::Vertical) lay->setDirection(QBoxLayout::TopToBottom); } -void TouchButtFrame::addButton(QString caption) + +void TouchButtFrame::addButton(const QString &caption) { - touch_butt * butt = new touch_butt(count,caption,colr,colg,colw,colp); + touch_butt * butt = new touch_butt(lay->count(),caption,colr,colg,colw,colp); butt->setMinimumHeight(50); butt->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); butt->setCheckable(true); butt->setAutoExclusive(true); butt->setAutoFillBackground(true); - if (lay->isEmpty()) butt->setChecked(true); - connect(butt,SIGNAL(touch_click(int)),SLOT(butt_click(int))); - connect(butt,SIGNAL(touch_toggle(int,bool)),SLOT(butt_toggle(int,bool))); lay->addWidget(butt); this->setLayout(lay); - count++; + connect(butt,SIGNAL(touch_click(int)),SLOT(butt_click(int))); + connect(butt,SIGNAL(touch_toggle(int,bool)),SLOT(butt_toggle(int,bool))); } void TouchButtFrame::butt_click(int index) { - //qDebug() << "button" << index << "clicked!"; - //if (((touch_butt*)lay->itemAt(index)->widget())->isChecked()) - //((touch_butt*)lay->itemAt(index)->widget())->setGreen(); emit click(index); } void TouchButtFrame::butt_toggle(int index,bool checked) { - //if (((touch_butt*)lay->itemAt(index)->widget())->isChecked()) - //qDebug() << "button" << index << "toggled" << checked; emit toggle(index,checked); } - void TouchButtFrame::resetColors() { - for (int i=0; icount(); ++i) { Button(i)->setColor(colr,colg,colw,colp); } } -int TouchButtFrame::buttCount() +void TouchButtFrame::deleteButtons() { - return count; + while (!lay->isEmpty()) + delete Button(0); +} + + +void TouchButtFrame::setButtons(const QStringList &captions) +{ + int cur = currentButton(); + deleteButtons(); + for (int i=0; isetChecked(true); + else if (!captions.isEmpty()) Button(0)->setChecked(true); +} + + +void TouchButtFrame::setCurrentButton(int index) +{ + if (Button(index) != 0) + { + if (currentButton() != -1) Button(currentButton())->setChecked(false); + Button(index)->setChecked(true); + } +} + + +int TouchButtFrame::currentButton() +{ + for (int i=0; iisChecked()) return i; + return -1; +} + + +QStringList TouchButtFrame::buttons() +{ + QStringList l; + for (int i=0; icount(); ++i) + l.append(Button(i)->text()); + return l; } touch_butt * TouchButtFrame::Button(int index) { - return ((touch_butt*)lay->itemAt(index)->widget()); + if (index >= 0 && index < lay->count()) + return (qobject_cast(lay->itemAt(index)->widget())); + else return 0; } diff --git a/touchbuttframe.h b/touchbuttframe.h index 97b9350..f11f332 100644 --- a/touchbuttframe.h +++ b/touchbuttframe.h @@ -2,50 +2,61 @@ #define TOUCHBUTTFRAME_H #include -#include +#include #include #include "touch_butt.h" class TouchButtFrame : public QFrame { - Q_OBJECT - Q_PROPERTY(QColor ColorYes READ colorYes WRITE setColorYes) - Q_PROPERTY(QColor ColorNo READ colorNo WRITE setColorNo) - Q_PROPERTY(QColor ColorDefault READ colorDefault WRITE setColorDefault) - Q_PROPERTY(QColor ColorPush READ colorPush WRITE setColorPush) + Q_OBJECT + Q_PROPERTY(QColor colorYes READ colorYes WRITE setColorYes) + Q_PROPERTY(QColor colorNo READ colorNo WRITE setColorNo) + Q_PROPERTY(QColor colorDefault READ colorDefault WRITE setColorDefault) + Q_PROPERTY(QColor colorPush READ colorPush WRITE setColorPush) + Q_PROPERTY(QStringList buttons READ buttons WRITE setButtons) + Q_PROPERTY(int currentButton READ currentButton WRITE setCurrentButton) + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) public: - enum Orientation { - Horizontal = 0, - Vertical = 1 - }; - TouchButtFrame(QWidget * parent = 0, - QColor red = Qt::red, QColor green = Qt::green, QColor white = Qt::white, QColor push = Qt::darkYellow, - Orientation orientation = Vertical); - void addButton(QString caption); - int buttCount(); - QColor colorYes() const {return colg;} - QColor colorNo() const {return colr;} - QColor colorDefault() const {return colw;} - QColor colorPush() const {return colp;} - void setColorYes(QColor ColorYes) {colg = ColorYes; resetColors();} - void setColorNo(QColor ColorNo) {colr = ColorNo; resetColors();} - void setColorDefault(QColor ColorDefault) {colw = ColorDefault; resetColors();} - void setColorPush(QColor ColorPush) {colp = ColorPush; resetColors();} - touch_butt * Button(int index); + TouchButtFrame(QWidget * parent = 0, + QColor red = Qt::red, QColor green = Qt::green, QColor white = Qt::white, QColor push = Qt::yellow, + Qt::Orientation orientation = Qt::Horizontal); + void setButtons(const QStringList &captions); + QStringList buttons(); + int buttCount() const {return lay->count();} + int currentButton(); + void setCurrentButton(int index); + QColor colorYes() const {return colg;} + QColor colorNo() const {return colr;} + QColor colorDefault() const {return colw;} + QColor colorPush() const {return colp;} + void setColorYes(QColor ColorYes) {colg = ColorYes; resetColors();} + void setColorNo(QColor ColorNo) {colr = ColorNo; resetColors();} + void setColorDefault(QColor ColorDefault) {colw = ColorDefault; resetColors();} + void setColorPush(QColor ColorPush) {colp = ColorPush; resetColors();} + void setOrientation(Qt::Orientation orientation) + {if (orientation == Qt::Horizontal) lay->setDirection(QBoxLayout::LeftToRight); + else lay->setDirection(QBoxLayout::TopToBottom);} + Qt::Orientation orientation() const + {if (lay->direction()==0) return Qt::Horizontal; + else return Qt::Vertical;} + void deleteButtons(); + void addButton(const QString &caption); + touch_butt * Button(int index); public slots: - void set_green(int index) {Button(index)->setGreen();} -private slots: - void butt_click(int index); - void butt_toggle(int index, bool checked); + void butt_click(int index); + void butt_toggle(int index, bool checked); + void set_green(int index) {if (Button(index) != 0) Button(index)->setGreen();} + void set_red(int index) {if (Button(index) != 0) Button(index)->setRed();} + void set_white(int index) {if (Button(index) != 0) Button(index)->setWhite();} private: - QColor colr,colg,colw,colp; - QLayout * lay; - int count; - void resetColors(); + QColor colr,colg,colw,colp; + QBoxLayout * lay; + //int count; + void resetColors(); signals: - void click(int index); - void toggle(int index, bool checked); + void click(int index); + void toggle(int index, bool checked); }; #endif // TOUCHBUTTFRAME_H diff --git a/towers.cpp b/towers.cpp index 7034574..02bcd81 100644 --- a/towers.cpp +++ b/towers.cpp @@ -3,131 +3,153 @@ #include Towers::Towers(Game_Data *gd, QObject *parent) : - QObject(parent) + QObject(parent) { - gameData = gd; + gameData = gd; } bool Towers::addTower(int playerId, int srcId, QPoint pos) { - if (playerId < 0 || playerId >= gameData->players.size()) - { - qCritical("ERROR out of players range"); - return false; - } - Player * p = gameData->players.at(playerId); - if (srcId < 0 || srcId >= p->srcTowers.size()) - { - qCritical("ERROR out of towers range"); - return false; - } - if (p->money < p->srcTowers.at(srcId).cost) - { - qDebug() << "not enought money!"; - return false; - } - QRect alrec(pos,QSize(2,2)); - for (QHash::iterator i = gameData->aliens->curAliens.begin(); i != gameData->aliens->curAliens.end(); ++i) - if (alrec.contains(i->pos.toPoint())) return false; - TowerType tw; - tw.src = &(p->srcTowers[srcId]); - tw.PlayerId = playerId; - tw.angle = 0; - tw.build = 0; - tw.reload = 0; - tw.aim = -1; - tw.experience = 0; - tw.isBilding = true; - if (gameData->map->addTowerOnMap(playerId,pos)) - { - tw.pos = pos; - tw.item = new ADItem(tw.pos,tw.src->image,QRectF(-cellSize,-cellSize,cellSize*2,cellSize*2)); + if (playerId < 0 || playerId >= gameData->players.size()) + { + qCritical("ERROR out of players range"); + return false; + } + Player * p = gameData->players.at(playerId); + if (srcId < 0 || srcId >= p->srcTowers.size()) + { + qCritical("ERROR out of towers range"); + return false; + } + if (p->money < p->srcTowers.at(srcId).cost) + { + qDebug() << "not enought money!"; + return false; + } + QRect alrec(pos,QSize(2,2)); + for (QHash::iterator i = gameData->aliens->curAliens.begin(); i != gameData->aliens->curAliens.end(); ++i) + if (alrec.contains(i->pos.toPoint())) return false; + TowerType tw; + tw.src = &(p->srcTowers[srcId]); + tw.PlayerId = playerId; + tw.angle = 0; + tw.build = 0; + tw.reload = 0; + tw.aim = -1; + tw.experience = 0; + tw.isBilding = true; + if (gameData->map->addTowerOnMap(playerId,pos)) + { + tw.pos = pos; + tw.item = new ADItem(tw.pos,tw.src->image,QRectF(-cellSize,-cellSize,cellSize*2,cellSize*2)); tw.item->setPos(tw.pos * cellSize); - tw.item->rotate(tw.angle); - tw.item->setOpacity(0.5); - scene->addItem(tw.item); - gameData->curTowers.insert(tw.pos,tw); - p->money -= tw.src->cost; - return true; - } - return false; + tw.item->setRotation(tw.angle); + tw.item->setOpacity(0.5); + scene->addItem(tw.item); + gameData->curTowers.insert(tw.pos,tw); + p->money -= tw.src->cost; + return true; + } + return false; } void Towers::delTower(QPoint pos) { - QPoint p; - if (gameData->curTowers.contains(pos)) p = pos; + QPoint p; + if (gameData->curTowers.contains(pos)) p = pos; if (gameData->curTowers.contains(pos+QPoint(1,0))) p = pos+QPoint(1,0); if (gameData->curTowers.contains(pos+QPoint(1,1))) p = pos+QPoint(1,1); if (gameData->curTowers.contains(pos+QPoint(0,1))) p = pos+QPoint(0,1); - if (gameData->curTowers.contains(p)) - { - TowerType * t = &(gameData->curTowers[p]); - gameData->map->delTowerOnMap(t->PlayerId,p); - scene->removeItem(t->item); - delete t->item; - gameData->curTowers.remove(p); - } + if (gameData->curTowers.contains(p)) + { + tower_killed(pos); + TowerType * t = &(gameData->curTowers[p]); + gameData->map->delTowerOnMap(t->PlayerId,p); + scene->removeItem(t->item); + delete t->item; + gameData->curTowers.remove(p); + } } void Towers::update() { - for (QHash::iterator i = gameData->curTowers.begin(); i != gameData->curTowers.end(); ++i) - { - if (i->isBilding) - { - if (i->build < i->src->buildTime) - { - i->build++; - i->item->setBarValue((float)(i->build)/i->src->buildTime); - } else { - i->isBilding = false; - i->item->hideBar(); - i->item->setOpacity(1.0); - } - } else { - float rad = i->src->radius; - float rad2 = rad*rad; - if (!(gameData->aliens->curAliens.contains(i->aim))) - i->aim = -1; - else - { - if (distance2(i->pos,gameData->aliens->curAliens.value(i->aim).pos) > rad2) - i->aim = -1; - } - if (gameData->players.at(i->PlayerId)->selectAlienId > 0) - { - AlienType al = gameData->aliens->curAliens.value(gameData->players.at(i->PlayerId)->selectAlienId); - if (distance2(al.pos, i->pos) < rad2) i->aim = al.id; - } - 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); - if (dist < rad2) i->aim = (*j).id; - } - } - if (i->aim > 0) - { - float arctg = std::atan2(i->pos.x() - gameData->aliens->curAliens.value(i->aim).pos.x(),i->pos.y() - gameData->aliens->curAliens.value(i->aim).pos.y()); - i->angle = 180.0f*(-arctg)/M_PI; - i->item->setRotation(i->angle); - } + for (QHash::iterator i = gameData->curTowers.begin(); i != gameData->curTowers.end(); ++i) + { + if (i->isBilding) + { + if (i->build < i->src->buildTime) + { + i->build++; + i->item->setBarValue((float)(i->build)/i->src->buildTime); + } else { + i->isBilding = false; + i->item->hideBar(); + i->item->setOpacity(1.0); + } + } else { + float rad = i->src->radius; + float rad2 = rad*rad; + if (!(gameData->aliens->curAliens.contains(i->aim))) + i->aim = -1; + else + { + if (distance2(i->pos,gameData->aliens->curAliens.value(i->aim).pos+QPointF(0.5f,0.5f)) > rad2) + i->aim = -1; + } + if (gameData->players.at(i->PlayerId)->selectAlienId > 0) + { + 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; + } + 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; + } + } + if (i->aim > 0) + { + float arctg = std::atan2(i->pos.x() - gameData->aliens->curAliens[i->aim].pos.x() - 0.5f, i->pos.y() - gameData->aliens->curAliens[i->aim].pos.y() - 0.5f); + i->angle = 180.0f*(-arctg)/M_PI; + i->item->setRotation(i->angle); + } /// TODO: smooth rotate tower to aim - if (i->reload < i->src->reload) - i->reload++; - else - { - if (i->aim > 0) - { - i->reload = 0; - i->experience += i->src->expByShot; - emit shot((*i)); - } - } - } - } + if (i->reload < i->src->reload) + i->reload++; + else + { + if (i->aim > 0) + { + i->reload = 0; + i->experience += i->src->expByShot; + emit shot((*i)); + } + } + } + } } + + +bool Towers::morphTower(QPoint id, int index) +{ + if (!canMorph(id, index)) return false; + tower_killed(id); + TowerType & t(gameData->curTowers[id]); + t.src = t.src->morphs[index].morph; + t.build = 0; + t.reload = 0; + t.isBilding = true; + scene->removeItem(t.item); + //delete t.item; + t.item = new ADItem(t.pos,t.src->image,QRectF(-cellSize,-cellSize,cellSize*2,cellSize*2)); + t.item->setPos(t.pos * cellSize); + t.item->setRotation(t.angle); + t.item->setOpacity(0.5); + scene->addItem(t.item); + return true; +} + diff --git a/towers.h b/towers.h index fd8928b..77cd242 100644 --- a/towers.h +++ b/towers.h @@ -7,20 +7,24 @@ class Towers : public QObject { Q_OBJECT public: - explicit Towers(Game_Data * gd, QObject *parent = 0); - bool addTower(int playerId, int srcId, QPoint pos); - void delTower(QPoint pos); - void update(); - void setScene(QGraphicsScene * scene_) {scene = scene_;} + explicit Towers(Game_Data * gd, QObject *parent = 0); + bool addTower(int playerId, int srcId, QPoint pos); + void delTower(QPoint pos); + bool morphTower(QPoint id, int index); + bool canMorph(QPoint id, int index) {return gameData->players[gameData->curTowers[id].PlayerId]->money >= gameData->curTowers[id].src->morphs[index].cost && + gameData->curTowers[id].experience >= gameData->curTowers[id].src->morphs[index].expRequired;} + void update(); + void setScene(QGraphicsScene * scene_) {scene = scene_;} signals: - void shot(const TowerType &tow); + void shot(const TowerType &tow); + void tower_killed(QPoint id); public slots: private: - Game_Data * gameData; - QGraphicsScene * scene; + Game_Data * gameData; + QGraphicsScene * scene; }; #endif // TOWERS_H