-
Notifications
You must be signed in to change notification settings - Fork 17
/
Consist.h
132 lines (124 loc) · 3.73 KB
/
Consist.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* This file is part of TSRE5.
*
* TSRE5 - train sim game engine and MSTS/OR Editors.
* Copyright (C) 2016 Piotr Gadecki <[email protected]>
*
* Licensed under GNU General Public License 3.0 or later.
*
* See LICENSE.md or https://www.gnu.org/licenses/gpl.html
*/
#ifndef CONSIST_H
#define CONSIST_H
#include <QString>
#include <unordered_map>
#include <QVector>
#include "GameObj.h"
class Eng;
class TextObj;
class FileBuffer;
class QTextStream;
class GLUU;
class Activity;
class SimpleHud;
class ContentHierarchyInfo;
class Consist : public GameObj {
public:
static std::unordered_map<int, TextObj*> txtNumbers;
static int lastTxtNumbersColor;
static TextObj * txtEngineE;
static TextObj * txtEngineD;
static TextObj * txtEngineS;
static TextObj * txtEngineF;
static TextObj * txtEngineW;
static TextObj * txtEngineT;
struct EngItem{
bool flip = false;
int uid = 0;
int eng = -1;
Eng *engPointer = NULL;
float pos = 0;
float conLength = 0;
int type = 0;
TextObj * txt = NULL;
QString epath;
QString ename;
};
Consist();
Consist(Consist * con, bool fullCopy = true);
virtual ~Consist();
int lastTxtColor;
QString name;
QString path;
QString pathid;
QString conName;
QString displayName;
QString showName;
unsigned int serial = 0;
float maxVelocity[2];
int nextWagonUID = 0;
float durability = 0;
float conLength = 0;
float mass = 0;
float emass = 0;
int loaded = -1;
bool isOnTrack = false;
bool kierunek = false;
int ref = 0;
int posInit = false;
int selectedIdx = -1;
float textColor[3];
QVector<EngItem> engItems;
Consist(QString p, QString n);
Consist(QString src, QString p, QString n);
void load();
bool load(FileBuffer* data);
void refreshEngData();
void save();
void save(QString woff, QTextStream *out);
bool select(int idx);
bool unselect();
void appendEngItem(int id, int pos = 2, bool flip = false);
int getSelectedEngId();
void replaceEngItemSelected(int id);
void replaceEngItemById(int oldId, int newId);
void deteleSelected();
void flipSelected();
void moveLeftSelected();
void moveRightSelected();
bool isNewConsist();
bool isBroken();
bool isUnSaved();
void setModified(bool val);
void setNewConsistFlag();
void setFileName(QString n);
void setDisplayName(QString n);
void reverse();
void setTextColor(float *bgColor);
void setDurability(float val);
void initOnTrack(float *posTXZ, int direction, QMap<int, int> *junctionDirections = NULL);
bool getWagonWorldPosition(int id, float *posTW);
void updateSim(float deltaTime);
void renderHud();
void getCameraPosition(float *out);
void renderOnTrack(GLUU* gluu, float * playerT, int selectionColor);
void render(int selectionColor = 0, bool renderText = false);
void render(int aktwx, int aktwz, int selectionColor, bool renderText);
void initPos();
void setMaxVelocityFixed(bool val);
bool isMaxVelocityFixed();
QString getFirstEngName();
void setTrainSpeed(float val);
float getTrainSpeed();
float getTrainDistanceTravelled();
void fillContentHierarchyInfo(QVector<ContentHierarchyInfo*>& list, int parent);
private:
bool newConsist = false;
bool modified = false;
bool defaultValue = false;
bool maxVelocityFixed = false;
float trainSpeed = 0.0;
float trainTotalDistance = 0.0;
SimpleHud *hud = NULL;
void replaceEngItem(int id, int pos);
};
#endif /* CONSIST_H */