-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker.h
87 lines (76 loc) · 2.34 KB
/
worker.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef WORKER_H
#define WORKER_H
#include <QObject>
#include <QPixmap>
#include <QTimer>
#include <QJsonObject>
#include <QJsonArray>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QList>
#include "classes/position.h"
#include "sceneimageviewer.h"
#include "classes/replay.h"
class Worker : public QObject
{
Q_OBJECT
public:
explicit Worker(SceneImageViewer* imageViewer, QObject* parent = nullptr);
~Worker();
void setMatchStartTime(long matchStartTime);
bool isMatchRunning();
bool isPlayerOnTank();
void fetchAndDisplayMap();
void fetchMapObjects();
QPixmap getDrawedMapImage();
QPixmap getOriginalMapImage() const;
void setOriginalMapImage(const QPixmap& originalMapImage);
void clearMarkers();
void addPosition(const Position& position);
void addPOI(const Position& position);
bool havePOIBeenDrawnFunc() const;
public slots:
void startTimer();
void stopTimer();
void performTask();
signals:
void updatePixmap(const QPixmap& pixmap);
void changeStackedWidget(int index);
void updateProgressBar(double progress);
void updateStatusLabel(QString msg);
private:
void onTimeout();
void updatePOI();
bool shouldUpdateMarkers();
void updateMarkers();
bool shouldEndMatch();
void endMatch();
void saveImage();
void restartScheduler();
QFile getLatestReplay(const QDir& replayDirectory);
void drawMarkers(QPixmap& displayImage);
void drawMarkers(QPixmap& displayImage, QPainter& painter, const QList<Position>& positionCache);
void drawSpecialMarkers(QPixmap& displayImage);
void drawCaptureZoneMarker(QPixmap& displayImage, QPainter& painter, const Position& pos);
static void drawRespawnBaseTank(QPixmap& displayImage, QPainter& painter, const QList<Position>& group);
QJsonObject fetchJsonElement(QString url);
QJsonArray fetchJsonArray(QString url);
QPixmap fetchMapImage();
Position getPositionFromJsonElement(QJsonObject element);
bool shouldLoadMap();
QJsonArray exportPositionsToJson(Replay& replayData);
void uploadReplay(Replay& replayData, const QString& uploader);
QPixmap originalMapImage;
QPixmap drawedMapImage;
QList<Position> positionCache;
QList<Position> poi;
static bool havePOIBeenDrawn;
SceneImageViewer* imageViewer;
QTimer* m_timer;
qint64 matchStartTime;
static QString DATA_URL;
static QString MAP_URL;
static QString MAP_INFO;
QNetworkAccessManager* networkManager;
};
#endif // WORKER_H