-
Notifications
You must be signed in to change notification settings - Fork 1
/
handler.h
65 lines (57 loc) · 2 KB
/
handler.h
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
61
62
63
64
65
#ifndef HANDLER_H
#define HANDLER_H
#include "definitions.h"
#include "tile.h"
#include <QList>
#include <QSet>
#include <QObject>
#include <QTimer>
#include <QRandomGenerator>
#include <QVariant>
#include <QDebug>
class Handler : public QObject {
Q_OBJECT
Q_PROPERTY (QList<int> tileMap READ getTileMap NOTIFY updateCanvas)
public:
Handler(const QList<QList<int>>& sockets, const int& dimensionsWidth,const int& dimensionsHeight, const int& m_numberOfTiles,
const QList<constructParameters>& precollapedTilesConstructionInstructions ,const QList<constructParameters>& weightmapConstructionInstructions, const QList<QList<int>>& availableWeightLists);
~Handler();
public slots:
void drawGrid();
void startCollapsing();
int getDimensionsWidth() { return m_dimensionsWidth; }
int getDimensionsHeight() {return m_dimensionsHeight; }
QList<int> getTilesToHighlight() {return m_tilesToBeColoredDifferently;}
QList<int> getTileMap() const{
return (*tileMap);
}
signals:
void gridInit();
void tileMapChanged(int index, int newTile);
void updateCanvas();
private:
QList<int> *tileMap;
QRandomGenerator *m_randomGenerator;
QVector<QObject*> *objectTileMap;
QList<QList<int>> m_rules;
QList<Tile> allTiles;
QList<int> m_disadvantageWeightMap;
QList<QList<int>> m_availableDisadvantageWeightList;
QList<constructParameters> m_weightmapConstructionInstructions;
QList<constructParameters> m_precollapedTilesConstructionInstructions;
QList<QList<int>> m_sockets;
QSet<int> m_indecesToCheck;
QTimer *m_performanceTimer;
QList<int> m_tilesToBeColoredDifferently;
int m_fps;
int m_dimensionsWidth;
int m_dimensionsHeight;
int m_dimensionsWidthHeight;
int m_numberOfTiles;
int calculateIndexToCollapseNext() const;
bool checkIfTileFits(const int& pos,const Tile& tile) const;
void enableSurroundingIndecesToBeChecked(const int& pos);
void collapse();
void constructWeightmap(const QList<constructParameters>& weightmapConstructionInstructions);
};
#endif // HANDLER_H