~mzanetti/machines-vs-machines/qmake-based

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef LEVELPACK_H
#define LEVELPACK_H

#include <QObject>

#include "engine.h"
#include "enemies.h"
#

class Level;

class LevelPack : public QAbstractListModel
{
    Q_OBJECT
    Q_PROPERTY(QString id READ id CONSTANT)
    Q_PROPERTY(QString name READ name CONSTANT)
    Q_PROPERTY(QString levelSelectBackground READ levelSelectBackground CONSTANT)

    Q_PROPERTY(Enemies* enemies READ enemies CONSTANT)
    Q_PROPERTY(TowerFactory* towers READ towers CONSTANT)

public:
    enum Roles {
        RoleHighscore
    };

    explicit LevelPack(Engine *engine, const QString &id, const QString &name, const QString &levelSelectBackground, QObject *parent = 0);

    QString id() const;
    QString name() const;
    QString levelSelectBackground() const;

    int rowCount(const QModelIndex &parent) const;
    QVariant data(const QModelIndex &index, int role) const;
    QHash<int, QByteArray> roleNames() const;
    Q_INVOKABLE Level *get(int index) const;

    Enemies *enemies() const;
    TowerFactory *towers() const;

    Level *addLevel(const QVariantMap &levelMap);

    void init();

private slots:
    void levelHighscoreChanged();

private:
    Engine *m_engine;
    QString m_id;
    QString m_name;
    QString m_levelSelectBackground;

    Enemies *m_enemies;

    QList<Level*> m_levels;

};

#endif // LEVELPACK_H