-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevelinteractor.cpp
More file actions
54 lines (45 loc) · 1.7 KB
/
levelinteractor.cpp
File metadata and controls
54 lines (45 loc) · 1.7 KB
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
#include "levelinteractor.h"
#include "constants.h"
#include "leveldatamodel.h"
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(lvlia, "app.levelinteractor")
LevelInteractor::LevelInteractor(QObject *parent)
: QObject { parent }
{
}
ILevelManager *LevelInteractor::levelManager() const
{
return m_levelManager;
}
void LevelInteractor::setLevelManager(ILevelManager *manager)
{
if (m_levelManager == manager) {
return;
}
m_levelManager = manager;
emit levelManagerChanged();
}
void LevelInteractor::addSimpleObject(int type, const QRectF &boundingRect, const QColor &color, bool isStatic,
bool gameItem) const
{
m_levelManager->levelData()->addSimpleObject(type, boundingRect, isStatic, gameItem, color);
}
void LevelInteractor::addPolygonObject(int type, const OptimizerResult &optimizerResult, const QColor &color, bool isStatic,
bool gameItem) const
{
if (optimizerResult.originalPoints.count() > 2 && optimizerResult.optimizedPoints.count() > 2) {
if (optimizerResult.isLine) {
m_levelManager->levelData()->addLineObject(Constants::ShapeType_Line, optimizerResult.originalPoints,
optimizerResult.optimizedPoints, isStatic, gameItem, color);
} else {
m_levelManager->levelData()->addPolygonObject(Constants::ShapeType_Polygon, optimizerResult.originalPoints,
optimizerResult.optimizedPoints, isStatic, gameItem, color);
}
} else {
qCDebug(lvlia) << "ignoring input, not enough points";
}
}
void LevelInteractor::removeObject(int index) const
{
m_levelManager->levelData()->removeObject(index);
}