-
Notifications
You must be signed in to change notification settings - Fork 54
/
ContentLoader.h
131 lines (118 loc) · 4.93 KB
/
ContentLoader.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
#pragma once
#include "tinyxml.h"
#include "BuildingConfiguration.h"
#include "CreatureConfiguration.h"
#include "VegetationConfiguration.h"
#include "GroundMaterialConfiguration.h"
#include "ColorConfiguration.h"
#include "commonTypes.h"
#include "FluidConfiguration.h"
#include "ItemConfiguration.h"
#include "common.h"
namespace df {
struct world_raws;
}
class ContentLoader
{
private:
bool parseContentIndexFile( const char* filepath );
bool parseContentXMLFile( const char* filepath );
bool parseBuildingContent( TiXmlElement* elemRoot );
bool parseCreatureContent( TiXmlElement* elemRoot );
bool parseTerrainContent ( TiXmlElement* elemRoot );
bool parseGrowthContent(TiXmlElement* elemRoot);
bool parseTreeContent( TiXmlElement* elemRoot );
bool parseShrubContent( TiXmlElement* elemRoot );
bool parseColorContent( TiXmlElement* elemRoot );
bool parseFluidContent( TiXmlElement* elemRoot );
bool parseGrassContent( TiXmlElement* elemRoot );
bool parseItemContent( TiXmlElement* elemRoot );
void flushCreatureConfig();
bool translationComplete;
void gatherStyleIndices(df::world_raws * raws);
public:
ContentLoader(void);
~ContentLoader(void);
bool Load();
bool reload_configs();
std::vector<std::unique_ptr<BuildingConfiguration>> buildingConfigs;
std::vector<std::unique_ptr<std::vector<CreatureConfiguration>>> creatureConfigs;
std::vector<std::unique_ptr<VegetationConfiguration>> treeConfigs;
std::vector<std::unique_ptr<VegetationConfiguration>> shrubConfigs;
std::vector<std::unique_ptr<VegetationConfiguration>> grassConfigs;
std::vector<std::unique_ptr<TerrainConfiguration>> terrainFloorConfigs;
std::vector<std::unique_ptr<TerrainConfiguration>> terrainWallConfigs;
std::vector<ColorConfiguration> colorConfigs;
MaterialMatcher<ALLEGRO_COLOR> materialColorConfigs;
MaterialMatcher<c_sprite> growthTopConfigs;
MaterialMatcher<c_sprite> growthBottomConfigs;
std::vector<std::unique_ptr<ItemConfiguration>> itemConfigs;
FluidConfiguration lava[8];
FluidConfiguration water[8];
//race.caste.hairtype.styletype
std::vector<std::vector<std::vector<int32_t>*>*> style_indices;
std::vector<std::vector<int32_t>*> position_Indices;
std::vector<std::string> professionStrings;
std::map <uint32_t, std::string> custom_workshop_types;
DFHack::Materials * Mats;
std::vector<DFHack::t_matgloss> organic;
std::vector<DFHack::t_matglossInorganic> inorganic;
uint32_t currentTick;
uint32_t currentYear;
uint8_t currentMonth;
uint8_t currentDay;
uint8_t currentHour;
uint8_t currentTickRel;
DFHack::t_gamemodes gameMode;
int obsidian;
};
extern ContentLoader * contentLoader;
extern const char* getDocument(TiXmlNode* element);
bool getLocalFilename(char * buffer, const char* filename, const char* relativeto);
extern void contentError(const char* message, TiXmlNode* element);
extern void contentWarning(const char* message, TiXmlNode* element);
extern char getAnimFrames(const char* framestring);
extern int loadConfigImgFile(const char* filename, TiXmlElement* referrer);
MAT_BASICS lookupMaterialType(const char* strValue);
int lookupMaterialIndex(int matType, const char* strValue);
template <typename T>
int lookupIndexedType(const char* indexName, std::vector<T>& typeVector)
{
if (indexName == NULL || indexName[0] == 0) {
return INVALID_INDEX;
}
uint32_t vsize = (uint32_t)typeVector.size();
for(uint32_t i=0; i < vsize; i++) {
if (typeVector[i].id == indexName) {
return i;
}
}
return INVALID_INDEX;
}
template <typename T>
int lookupIndexedPonterType(const char* indexName, std::vector<T*>& typeVector)
{
if (indexName == NULL || indexName[0] == 0) {
return INVALID_INDEX;
}
uint32_t vsize = (uint32_t)typeVector.size();
for(uint32_t i=0; i < vsize; i++) {
if (typeVector[i]->id == indexName) {
return i;
}
}
return INVALID_INDEX;
}
const char *lookupMaterialTypeName(int matType);
const char *lookupMaterialName(int matType,int matIndex);
const char *lookupBuildingSubtype(int main_type, int i);
uint8_t lookupMaterialFore(int matType,int matIndex);
uint8_t lookupMaterialBack(int matType,int matIndex);
uint8_t lookupMaterialBright(int matType,int matIndex);
const char *lookupTreeName(int matIndex);
ALLEGRO_COLOR lookupMaterialColor(DFHack::t_matglossPair matt, DFHack::t_matglossPair dyematt, ALLEGRO_COLOR defaultColor=al_map_rgb(255,255,255));
ALLEGRO_COLOR lookupMaterialColor(DFHack::t_matglossPair matt, ALLEGRO_COLOR defaultColor=al_map_rgb(255,255,255));
ALLEGRO_COLOR lookupMaterialColor(int matType, int matIndex, int dyeType, int dyeIndex, ALLEGRO_COLOR defaultColor=al_map_rgb(255,255,255));
ALLEGRO_COLOR lookupMaterialColor(int matType, int matIndex, ALLEGRO_COLOR defaultColor=al_map_rgb(255,255,255));
const char * lookupFormName(int formType);
ShadeBy getShadeType(const char* Input);