 |
Cytopia
0.3
A city building simulation game
|
Go to the documentation of this file. 1 #ifndef JSON_SERIALIZATION_HXX_
2 #define JSON_SERIALIZATION_HXX_
10 #include "../../services/AudioMixer.hxx"
20 point.
x = j.at(
"x").get<
int>();
21 point.
y = j.at(
"y").get<
int>();
22 point.
z = j.at(
"z").get<
int>();
23 point.
height = j.at(
"height").get<
int>();
30 mapNodeData.
tileIndex = j.at(
"tileIndex").get<std::int32_t>();
38 s.
screenWidth = j[
"Graphics"][
"Resolution"].value(
"Screen_Width", 800);
39 s.
screenHeight = j[
"Graphics"][
"Resolution"].value(
"Screen_Height", 600);
40 s.
vSync = j[
"Graphics"].value(
"VSYNC",
false);
41 s.
fullScreen = j[
"Graphics"].value(
"FullScreen",
false);
43 s.
mapSize = j[
"Game"].value(
"MapSize", 64);
45 s.
biome = j[
"Game"].value(
"Biome",
"GrassLands");
49 s.
uiDataJSONFile = j[
"ConfigFiles"].value(
"UIDataJSONFile",
"resources/data/TileData.json");
50 s.
tileDataJSONFile = j[
"ConfigFiles"].value(
"TileDataJSONFile",
"resources/data/UIData.json");
51 s.
uiLayoutJSONFile = j[
"ConfigFiles"].value(
"UILayoutJSONFile",
"resources/data/UILayout.json");
52 s.
audioConfigJSONFile = j[
"ConfigFiles"].value(
"AudioConfigJSONFile",
"resources/data/AudioConfig.json");
54 s.
playMusic = j[
"Audio"].value(
"PlayMusic",
true);
57 s.
musicVolume = j[
"Audio"].value(
"MusicVolume", 0.5f);
60 s.
fontFileName = j[
"User Interface"].value(
"FontFilename",
"resources/fonts/arcadeclassics.ttf");
70 if (j.find(
"trees") != j.end())
72 for (
const auto &it : j[
"trees"].items())
74 if (it.key() ==
"light")
76 std::vector<std::string> temp = it.value();
79 if (it.key() ==
"medium")
81 std::vector<std::string> temp = it.value();
84 if (it.key() ==
"dense")
86 std::vector<std::string> temp = it.value();
92 if (j.find(
"terrainFlora") != j.end())
94 for (
const auto &it : j[
"terrainFlora"].items())
96 if (it.key() ==
"light")
98 std::vector<std::string> temp = it.value();
101 if (it.key() ==
"medium")
103 std::vector<std::string> temp = it.value();
106 if (it.key() ==
"dense")
108 std::vector<std::string> temp = it.value();
114 if (j.find(
"bushes") != j.end())
116 for (
const auto &it : j[
"bushes"].items())
118 if (it.key() ==
"light")
120 std::vector<std::string> temp = it.value();
123 if (it.key() ==
"medium")
125 std::vector<std::string> temp = it.value();
128 if (it.key() ==
"dense")
130 std::vector<std::string> temp = it.value();
136 if (j.find(
"waterFlora") != j.end())
138 for (
const auto &it : j[
"waterFlora"].items())
140 if (it.key() ==
"light")
142 std::vector<std::string> temp = it.value();
145 if (it.key() ==
"medium")
147 std::vector<std::string> temp = it.value();
150 if (it.key() ==
"dense")
152 std::vector<std::string> temp = it.value();
158 if (j.find(
"terrain") != j.end())
160 std::vector<std::string> temp = j[
"terrain"];
163 if (j.find(
"water") != j.end())
165 std::vector<std::string> temp = j[
"water"];
168 if (j.find(
"waterdecoration") != j.end())
170 std::vector<std::string> temp = j[
"waterdecoration"];
173 if (j.find(
"terrainRocks") != j.end())
175 std::vector<std::string> temp = j[
"terrainRocks"];
178 if (j.find(
"terrainDecoration") != j.end())
180 std::vector<std::string> temp = j[
"terrainDecoration"];
186 inline void from_json(
const json &j, AudioTrigger &trigger) { trigger = AudioTrigger::_from_string(j.get<
string>().c_str()); }
194 std::vector<string> triggers;
195 j[
"triggers"].get_to(triggers);
196 std::transform(triggers.begin(), triggers.end(), std::back_inserter(config.
triggers),
197 [](
const string &trigger) { return AudioTrigger::_from_string(trigger.c_str()); });
203 j[
"Music"].get_to(config.
Music);
204 j[
"Sound"].get_to(config.
Sound);
213 j =
json{{
"x", point.
x}, {
"y", point.
y}, {
"z", point.
z}, {
"height", point.
height}};
std::vector< std::string > bushesLight
Bushes Light IDs.
std::vector< std::string > terrain
Terrain IDs.
float soundEffectsVolume
the volume of sound effects as float between [0, 1]
std::vector< std::string > treesMedium
Trees Medium IDs.
bool vSync
if vSync is enabled or not
std::vector< std::string > treesDense
Trees Dense IDs.
FilePath fontFileName
FilePath of the Font that should be used.
std::vector< std::string > waterFloraLight
Water Flora Light IDs.
std::string buildMenuPosition
location of the build menu
const Point & getCoordinates() const
get iso coordinates of this node
ScreenDimension screenHeight
the screen height
int subMenuButtonWidth
The width in pixels of the buttons used in the build sub menues on the UI.
int maxElevationHeight
the maximum elevation height
std::vector< std::string > terrainRocks
Terrain Rocks IDs.
float zoneLayerTransparency
the value of the zone layer transparency, (0 - 1.0). where 0 is full opaque and 1 for full transparen...
std::vector< std::string > water
Water IDs.
void to_json(json &j, const Point &point)
JSON serializer for Point class.
int audioChannels
the number of channels used for sound playback 1=Mono,2=Stereo
const std::vector< MapNodeData > & getMapNodeData() const
std::vector< std::string > treesLight
Trees Light IDs.
int mapSize
the size of the map
std::string gameLanguage
the code for the current game language
FilePath uiDataJSONFile
JSONFile that contains uiData.
FilePath tileDataJSONFile
JSONFile that contains tileData.
ScreenDimension screenWidth
the screen width
Class that holds map nodes.
std::vector< std::string > waterDecoration
Water Decoration IDs.
bool playSoundEffects
true if sound effects should be played
std::vector< std::string > terrainFloraDense
Terrain Flora (Flowers) Dense IDs.
int subMenuButtonHeight
The height in pixels of the buttons used in the build sub menues on the UI.
FilePath uiLayoutJSONFile
The file path to the UI layout file.
bool showBuildingsInBlueprint
indicates whether we want to see buildings inside Blueprint layer or not
int settingsVersion
the version of the Settings file. Overwrite cache settings if a newer version exists
bool audio3DStatus
whether to play 3D sound or not
std::vector< std::string > waterFloraMedium
Water Flora Medium IDs.
Vector< AudioTrigger > triggers
int height
The height level.
std::vector< std::string > bushesMedium
Bushes Medium IDs.
std::vector< std::string > terrainDecoration
Terrain Decoration IDs.
std::vector< std::string > terrainFloraMedium
Terrain Flora (Flowers) Medium IDs.
float musicVolume
the volume of music as float between [0, 1]
Mapping< string, SoundtrackConfiguration > Sound
bool playMusic
true if music should be played
std::vector< std::string > terrainFloraLight
Terrain Flora (Flowers) Light IDs.
void from_json(const json &j, Point &point)
JSON deserializer for Point class.
FilePath audioConfigJSONFile
file path to Audio Configuration
bool writeErrorLogFile
Write errors to a log file.
std::string biome
this is used for biomedata
Mapping< string, SoundtrackConfiguration > Music
std::vector< std::string > waterFloraDense
Water Flora Dense IDs.
std::vector< std::string > bushesDense
Bushes Dense IDs.
WeakType & get() noexcept