-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
91 lines (76 loc) · 2 KB
/
mainwindow.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
88
89
90
91
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QGraphicsScene>
#include <QTimer>
#include <QGraphicsTextItem>
#include <QGraphicsSceneMouseEvent>
#include <QHBoxLayout>
#include <QChartView>
#include <QLineSeries>
#include <QValueAxis>
#include <QPair>
#include <cmath>
#include "geneticworld.h"
#include "boteditor.h"
#include "botstruct.h"
#include "kled.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class Scene : public QGraphicsScene {
Q_OBJECT
public:
explicit Scene(QObject *parent = nullptr);
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
signals:
void mousePress(QPointF);
};
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
BotEditor *botEditorWindow;
Scene *scene;
GeneticWorld *world;
KLed *statusLed;
KLed *processTimeLed;
KLed *seasonLed;
QTimer *renderTimer;
QTimer *graphTimer;
QChart *historyPlot;
QValueAxis *historyAxisX;
QValueAxis *historyAxisY;
QGridLayout *historyLayout;
QChartView *historyView;
QLineSeries *aliveBotHistory;
QLineSeries *organicBotHistory;
uint botSize;
bool worldInited = false;
QColor botColorByType(Bot *bot);
QColor botColorByEnergy(Bot *bot);
QColor botColorByUsedGens(Bot *bot);
QColor botColorByOld(Bot *bot);
QColor botColorByMinerals(Bot *bot);
void initWorld(uint x, uint y);
void updateWorldSettings();
QPair<QPair<int, int>, QPair<int, int>> _find2Max();
void renderGraph(bool reset);
void updateSeasonLed();
void closeEvent(QCloseEvent *event);
private slots:
void renderTypeChanged();
void renderGraph();
void openBotEditor();
void mousePress(QPointF position);
void renderUI();
void start();
void stop();
void newWorld();
};
QGraphicsTextItem* textWidget(QString text, uint x, uint y, QColor color);
#endif // MAINWINDOW_H