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
|
#include "GFX.hpp"
using namespace OpenVic;
using namespace OpenVic::GFX;
using namespace OpenVic::NodeTools;
Font::Font(
std::string_view new_identifier, colour_argb_t new_colour, std::string_view new_fontname, std::string_view new_charset,
uint32_t new_height
) : HasIdentifierAndAlphaColour { new_identifier, new_colour, false }, fontname { new_fontname }, charset { new_charset },
height { new_height } {}
node_callback_t Sprite::expect_sprites(length_callback_t length_callback, callback_t<std::unique_ptr<Sprite>&&> callback) {
return expect_dictionary_keys_and_length(
length_callback,
"spriteType", ZERO_OR_MORE, _expect_instance<Sprite, IconTextureSprite>(callback),
"progressbartype", ZERO_OR_MORE, _expect_instance<Sprite, ProgressBar>(callback),
"PieChartType", ZERO_OR_MORE, _expect_instance<Sprite, PieChart>(callback),
"LineChartType", ZERO_OR_MORE, _expect_instance<Sprite, LineChart>(callback),
"textSpriteType", ZERO_OR_MORE, _expect_instance<Sprite, IconTextureSprite>(callback),
"maskedShieldType", ZERO_OR_MORE, _expect_instance<Sprite, MaskedFlag>(callback),
"tileSpriteType", ZERO_OR_MORE, _expect_instance<Sprite, TileTextureSprite>(callback),
"corneredTileSpriteType", ZERO_OR_MORE, _expect_instance<Sprite, CorneredTileTextureSprite>(callback),
/* Each only has one vanilla instance which isn't used anywhere. */
"BarChartType", ZERO_OR_MORE, success_callback,
"scrollingSprite", ZERO_OR_MORE, success_callback
);
}
TextureSprite::TextureSprite() : texture_file {} {}
bool TextureSprite::_fill_key_map(case_insensitive_key_map_t& key_map) {
bool ret = Sprite::_fill_key_map(key_map);
ret &= add_key_map_entries(key_map,
"texturefile", ZERO_OR_ONE, expect_string(assign_variable_callback_string(texture_file)),
"norefcount", ZERO_OR_ONE, success_callback,
"allwaystransparent", ZERO_OR_ONE, success_callback,
"loadType", ZERO_OR_ONE, success_callback
);
return ret;
}
IconTextureSprite::IconTextureSprite() : no_of_frames { NO_FRAMES } {}
bool IconTextureSprite::_fill_key_map(case_insensitive_key_map_t& key_map) {
bool ret = TextureSprite::_fill_key_map(key_map);
ret &= add_key_map_entries(key_map,
"noOfFrames", ZERO_OR_ONE, expect_uint(assign_variable_callback(no_of_frames)),
"effectFile", ZERO_OR_ONE, success_callback,
"transparencecheck", ZERO_OR_ONE, success_callback,
"clicksound", ZERO_OR_ONE, success_callback
);
return ret;
}
TileTextureSprite::TileTextureSprite() : size {} {}
bool TileTextureSprite::_fill_key_map(case_insensitive_key_map_t& key_map) {
bool ret = TextureSprite::_fill_key_map(key_map);
ret &= add_key_map_entries(key_map,
"size", ONE_EXACTLY, expect_ivec2(assign_variable_callback(size))
);
return ret;
}
CorneredTileTextureSprite::CorneredTileTextureSprite() : size {}, border_size {} {}
bool CorneredTileTextureSprite::_fill_key_map(case_insensitive_key_map_t& key_map) {
bool ret = TextureSprite::_fill_key_map(key_map);
ret &= add_key_map_entries(key_map,
"size", ONE_EXACTLY, expect_ivec2(assign_variable_callback(size)),
"borderSize", ONE_EXACTLY, expect_ivec2(assign_variable_callback(border_size))
);
return ret;
}
ProgressBar::ProgressBar() : back_colour {}, back_texture_file {}, progress_colour {}, progress_texture_file {}, size {} {}
bool ProgressBar::_fill_key_map(case_insensitive_key_map_t& key_map) {
bool ret = Sprite::_fill_key_map(key_map);
ret &= add_key_map_entries(key_map,
"color", ONE_EXACTLY, expect_colour(assign_variable_callback(progress_colour)),
"colortwo", ONE_EXACTLY, expect_colour(assign_variable_callback(back_colour)),
"textureFile1", ZERO_OR_ONE, expect_string(assign_variable_callback_string(progress_texture_file)),
"textureFile2", ZERO_OR_ONE, expect_string(assign_variable_callback_string(back_texture_file)),
"size", ONE_EXACTLY, expect_ivec2(assign_variable_callback(size)),
"effectFile", ONE_EXACTLY, success_callback,
"allwaystransparent", ZERO_OR_ONE, success_callback,
"loadType", ZERO_OR_ONE, success_callback,
"horizontal", ZERO_OR_ONE, success_callback
);
return ret;
}
PieChart::PieChart() : size {} {}
bool PieChart::_fill_key_map(case_insensitive_key_map_t& key_map) {
bool ret = Sprite::_fill_key_map(key_map);
ret &= add_key_map_entries(key_map, "size", ONE_EXACTLY, expect_uint(assign_variable_callback(size)));
return ret;
}
LineChart::LineChart() : size {}, linewidth {} {}
bool LineChart::_fill_key_map(case_insensitive_key_map_t& key_map) {
bool ret = Sprite::_fill_key_map(key_map);
ret &= add_key_map_entries(key_map,
"size", ONE_EXACTLY, expect_ivec2(assign_variable_callback(size)),
"linewidth", ONE_EXACTLY, expect_uint(assign_variable_callback(linewidth)),
"allwaystransparent", ZERO_OR_ONE, success_callback
);
return ret;
}
MaskedFlag::MaskedFlag() : overlay_file {}, mask_file {} {}
bool MaskedFlag::_fill_key_map(case_insensitive_key_map_t& key_map) {
bool ret = Sprite::_fill_key_map(key_map);
ret &= add_key_map_entries(key_map,
"textureFile1", ONE_EXACTLY, expect_string(assign_variable_callback_string(overlay_file)),
"textureFile2", ONE_EXACTLY, expect_string(assign_variable_callback_string(mask_file)),
"effectFile", ONE_EXACTLY, success_callback,
"allwaystransparent", ZERO_OR_ONE, success_callback,
"flipv", ZERO_OR_ONE, success_callback
);
return ret;
}
|