-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiniData.h
156 lines (116 loc) · 4.68 KB
/
iniData.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/* OpenBRF -- by marco tarini. Provided under GNU General Public License */
#ifndef INIDATA_H
#define INIDATA_H
#include <map>
#include <vector>
#include <qpair.h>
#include "brfData.h"
//typedef QPair<int,int> Pair;
class QDir;
class IniData
{
public:
BrfData ¤tBrf;
typedef enum {MODULE_RES, COMMON_RES, CORE_RES} Origin;
IniData(BrfData ¤tBrf);
std::vector<BrfData> file;
std::vector<QString> filename; // full path included
std::vector<int> iniLine; // at which line of moudle.ini
std::vector<Origin> origin;
bool isWarband;
// bitmasks of txt files used
class UsedInType{
public:
uint direct;
uint indirect;
uint directOrIndirect()const{return direct|indirect;}
};
typedef std::vector< ObjCoord > ObjCoordV; // vectors of objects used
// which brfObject is used BY which other brfObject
ObjCoordV& usedBy(ObjCoord);
ObjCoordV usedBy(ObjCoord) const;
// which brfObject is used IN which txt file
UsedInType& usedIn(ObjCoord);
UsedInType usedIn(ObjCoord) const;
const char* getName(ObjCoord);
unsigned int getSize(ObjCoord);
void updateBeacuseBrfDataSaved();
QString mat2tex(const QString &s, bool *hasBump, bool *hasSpec, bool * hasTransp);
QString stats();
bool loadAll(int howFast);
// 1 = only filenames.
// 2 = fast only (only Mat & Tex, skip the rest).
// 3 = full BRF
// 4 = full BRF + all txts
int updated; // 0 = no.
QString modPath;
QString mabPath;
QString name() const;
int nRefObjects() const;
int nObjects() const;
bool addBrfFile(const char* name, Origin origin, int line, int howFast);
bool setPath(QString mabPath, QString modPath); // return true if changed them
QStringList namelist[N_TOKEN];
void updateNeededLists(); // only these needed for autocompletion
void updateAllLists(); // all
bool saveLists(const QString &fn);
int findFile(const QString &fn,bool onlyModFolder=false); // returns index of a given file
// returns: index of file, of object inside file
ObjCoord indexOf(const QString &name, int kind);
// as above, bust strong matching (no ".")
ObjCoord indexOfStrict(const QString &name, int kind);
BrfShader* findShader(const QString &fn);
BrfTexture* findTexture(const QString &fn);
BrfMaterial* findMaterial(const QString &name, ObjCoord startFrom=ObjCoord() );
QStringList errorList; // list all error strings when scanning module
bool findErrors(int maxErr); // true if there's more
QString searchAllNames(const QString &s,bool commonResToo, int token) const;
QString errorStringOnScan; // string on scan
static QString tokenFullName(int k);
static QString tokenPlurName(int k);
QString nameShort(ObjCoord o) const;
QString nameFull(ObjCoord o) const;
int totSize(uint t, bool commonRes) const;
int totUsed(uint t,bool commonRes) const;
int totSize(int fileIndex) const;
int totUsed(int fileIndex) const;
int totFiles(bool commonRes) const;
private:
QString link(int i, int j, int kind) const; // given an object j of kind kind in file i, returns a strig link
QString linkShort(int i, int j, int kind) const;
QString shortFileName(int i) const;
template<class T> bool checkDuplicated(std::vector<T> &v, int fi, int maxErr);
void checkUses(int i, int j, int kind, char* usedName, int usedKind);
void addUsedBy(int i, int j, int kind, char* usedName, int usedKind);
void checkFile(int i, int j, int kind, char* fileName, QDir* d0, QDir* d1, bool forFrame );
std::map<QString, ObjCoord> indexing[N_TOKEN+1];
void prepareIndex(int kind);
enum {MESH_NO_EXT = N_TOKEN };
QStringList errorListOnLoad; // list all error strings on load
template<class T> void searchAllNamesV(const QString &s, int t, const std::vector<T> &v, int i, QString &res) const;
class ModuleTxtNameList{
public:
ModuleTxtNameList(int _tok, int _);
int brfToken; // mesh, or material...
int txtIndex; // from which file
QStringList name;
QString test();
void append(const QString& s);
void appendLRx(const QString& s);
void appendNon0(const QString& s);
void appendNonNone(const QString& s);
};
std::vector<ModuleTxtNameList> txtNameList;
void setAllUsedInNone();
void setAllUsedByNone();
bool readModuleTxts(const QString& pathMod, const QString& pathData );
void updateUsedBy();
void updateUsedIn();
void propagateUsedIn();
void propagateUsedIn(int from);
std::vector< std::vector< ObjCoordV > > usedByV[N_TOKEN];
std::vector< std::vector< UsedInType > > usedInV[N_TOKEN];
static QString tr(char*);
void debugShowUsedFlags();
};
#endif // INIDATA_H