Porytiles
Loading...
Searching...
No Matches
yaml_file_provider.cpp
Go to the documentation of this file.
2
3#include <cstdint>
4#include <filesystem>
5#include <fstream>
6#include <map>
7#include <sstream>
8
9#include "yaml-cpp/yaml.h"
10
13
15
16namespace porytiles {
17
18/*
19 * NOTE: DO NOT EDIT THIS FILE DIRECTLY. It is AUTO-GENERATED from config_schema.yaml.
20 * To add new config values or make other changes, edit config_schema.yaml and regenerate via:
21 *
22 * uv run scripts/generate_config.py
23 */
24
26 gsl::not_null<const TextFormatter *> format,
27 const UserDiagnostics *diagnostics,
28 const std::filesystem::path &project_root)
29 : format_{format}, diagnostics_{diagnostics}, project_root_{project_root}
30{
31 // Config files are loaded lazily when first accessed via the anonymous namespace functions
32}
33
35 const UserDiagnostics *diagnostics,
36 const std::filesystem::path &project_root)
37 : owned_format_{std::make_unique<PlainTextFormatter>()}, format_{owned_format_.get()}, diagnostics_{diagnostics},
38 project_root_{project_root}
39{
40 // Config files are loaded lazily when first accessed via the anonymous namespace functions
41}
42
43std::string YamlFileProvider::name() const
44{
45 return "YamlFileProvider";
46}
47
48bool YamlFileProvider::preload_and_validate(ConfigScopeType type, const std::string &scope) const
49{
50 return preload_and_validate_yaml_files(format_, diagnostics_, project_root_, type, scope);
51}
52
54{
55 auto paths_result = get_config_path_chain(project_root_, type, scope);
56 if (!paths_result.has_value()) {
57 return LayerValue<std::size_t>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
58 }
59 return search_config_files<std::size_t>(
60 format_,
61 paths_result.value(),
62 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
63 [](const YAML::Node &doc) { return doc["fieldmap"]["num_tiles_in_primary"]; },
64 parse_size_t,
65 "fieldmap.num_tiles_in_primary",
66 "fieldmap.num_tiles_in_primary");
67}
68
70{
71 auto paths_result = get_config_path_chain(project_root_, type, scope);
72 if (!paths_result.has_value()) {
73 return LayerValue<std::size_t>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
74 }
75 return search_config_files<std::size_t>(
76 format_,
77 paths_result.value(),
78 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
79 [](const YAML::Node &doc) { return doc["fieldmap"]["num_tiles_total"]; },
80 parse_size_t,
81 "fieldmap.num_tiles_total",
82 "fieldmap.num_tiles_total");
83}
84
86{
87 auto paths_result = get_config_path_chain(project_root_, type, scope);
88 if (!paths_result.has_value()) {
89 return LayerValue<std::size_t>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
90 }
91 return search_config_files<std::size_t>(
92 format_,
93 paths_result.value(),
94 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
95 [](const YAML::Node &doc) { return doc["fieldmap"]["num_metatiles_in_primary"]; },
96 parse_size_t,
97 "fieldmap.num_metatiles_in_primary",
98 "fieldmap.num_metatiles_in_primary");
99}
100
102{
103 auto paths_result = get_config_path_chain(project_root_, type, scope);
104 if (!paths_result.has_value()) {
105 return LayerValue<std::size_t>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
106 }
107 return search_config_files<std::size_t>(
108 format_,
109 paths_result.value(),
110 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
111 [](const YAML::Node &doc) { return doc["fieldmap"]["num_metatiles_total"]; },
112 parse_size_t,
113 "fieldmap.num_metatiles_total",
114 "fieldmap.num_metatiles_total");
115}
116
118{
119 auto paths_result = get_config_path_chain(project_root_, type, scope);
120 if (!paths_result.has_value()) {
121 return LayerValue<std::size_t>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
122 }
123 return search_config_files<std::size_t>(
124 format_,
125 paths_result.value(),
126 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
127 [](const YAML::Node &doc) { return doc["fieldmap"]["num_pals_in_primary"]; },
128 parse_size_t,
129 "fieldmap.num_pals_in_primary",
130 "fieldmap.num_pals_in_primary");
131}
132
134{
135 auto paths_result = get_config_path_chain(project_root_, type, scope);
136 if (!paths_result.has_value()) {
137 return LayerValue<std::size_t>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
138 }
139 return search_config_files<std::size_t>(
140 format_,
141 paths_result.value(),
142 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
143 [](const YAML::Node &doc) { return doc["fieldmap"]["num_pals_total"]; },
144 parse_size_t,
145 "fieldmap.num_pals_total",
146 "fieldmap.num_pals_total");
147}
148
150{
151 auto paths_result = get_config_path_chain(project_root_, type, scope);
152 if (!paths_result.has_value()) {
153 return LayerValue<std::size_t>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
154 }
155 return search_config_files<std::size_t>(
156 format_,
157 paths_result.value(),
158 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
159 [](const YAML::Node &doc) { return doc["fieldmap"]["max_map_data_size"]; },
160 parse_size_t,
161 "fieldmap.max_map_data_size",
162 "fieldmap.max_map_data_size");
163}
164
166{
167 auto paths_result = get_config_path_chain(project_root_, type, scope);
168 if (!paths_result.has_value()) {
169 return LayerValue<std::size_t>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
170 }
171 return search_config_files<std::size_t>(
172 format_,
173 paths_result.value(),
174 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
175 [](const YAML::Node &doc) { return doc["fieldmap"]["num_tiles_per_metatile"]; },
176 parse_size_t,
177 "fieldmap.num_tiles_per_metatile",
178 "fieldmap.num_tiles_per_metatile");
179}
180
182{
183 auto paths_result = get_config_path_chain(project_root_, type, scope);
184 if (!paths_result.has_value()) {
185 return LayerValue<Rgba32>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
186 }
187 return search_config_files<Rgba32>(
188 format_,
189 paths_result.value(),
190 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
191 [](const YAML::Node &doc) { return doc["tileset"]["extrinsic_transparency"]; },
192 parse_rgba32,
193 "tileset.extrinsic_transparency",
194 "tileset.extrinsic_transparency");
195}
196
198{
199 auto paths_result = get_config_path_chain(project_root_, type, scope);
200 if (!paths_result.has_value()) {
201 return LayerValue<ArtifactEditMode>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
202 }
203 return search_config_files<ArtifactEditMode>(
204 format_,
205 paths_result.value(),
206 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
207 [](const YAML::Node &doc) { return doc["tileset"]["tiles"]["edit_mode"]; },
208 parse_artifact_edit_mode,
209 "tileset.tiles.edit_mode",
210 "tileset.tiles.edit_mode");
211}
212
214{
215 auto paths_result = get_config_path_chain(project_root_, type, scope);
216 if (!paths_result.has_value()) {
217 return LayerValue<ArtifactEditMode>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
218 }
219 return search_config_files<ArtifactEditMode>(
220 format_,
221 paths_result.value(),
222 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
223 [](const YAML::Node &doc) { return doc["tileset"]["palettes"]["edit_mode"]; },
224 parse_artifact_edit_mode,
225 "tileset.palettes.edit_mode",
226 "tileset.palettes.edit_mode");
227}
228
230{
231 auto paths_result = get_config_path_chain(project_root_, type, scope);
232 if (!paths_result.has_value()) {
233 return LayerValue<bool>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
234 }
235 return search_config_files<bool>(
236 format_,
237 paths_result.value(),
238 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
239 [](const YAML::Node &doc) { return doc["tileset"]["palettes"]["packing"]["hints_enabled"]; },
240 parse_bool,
241 "tileset.palettes.packing.hints_enabled",
242 "tileset.palettes.packing.hints_enabled");
243}
244
246{
247 auto paths_result = get_config_path_chain(project_root_, type, scope);
248 if (!paths_result.has_value()) {
249 return LayerValue<std::vector<PaletteHint>>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
250 }
251 return search_config_files<std::vector<PaletteHint>>(
252 format_,
253 paths_result.value(),
254 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
255 [](const YAML::Node &doc) { return doc["tileset"]["palettes"]["packing"]["hints"]; },
256 parse_pal_hints,
257 "tileset.palettes.packing.hints",
258 "tileset.palettes.packing.hints");
259}
260
262{
263 auto paths_result = get_config_path_chain(project_root_, type, scope);
264 if (!paths_result.has_value()) {
265 return LayerValue<PackingStrategyType>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
266 }
267 return search_config_files<PackingStrategyType>(
268 format_,
269 paths_result.value(),
270 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
271 [](const YAML::Node &doc) { return doc["tileset"]["palettes"]["packing"]["strategy"]; },
272 parse_packing_strategy_type,
273 "tileset.palettes.packing.strategy",
274 "tileset.palettes.packing.strategy");
275}
276
278{
279 auto paths_result = get_config_path_chain(project_root_, type, scope);
280 if (!paths_result.has_value()) {
281 return LayerValue<PackingStrategyParams>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
282 }
283 return search_config_files<PackingStrategyParams>(
284 format_,
285 paths_result.value(),
286 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
287 [](const YAML::Node &doc) { return doc["tileset"]["palettes"]["packing"]["strategy_params"]; },
288 parse_packing_strategy_params,
289 "tileset.palettes.packing.strategy_params",
290 "tileset.palettes.packing.strategy_params");
291}
292
294{
295 auto paths_result = get_config_path_chain(project_root_, type, scope);
296 if (!paths_result.has_value()) {
297 return LayerValue<TileSharingPacking>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
298 }
299 return search_config_files<TileSharingPacking>(
300 format_,
301 paths_result.value(),
302 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
303 [](const YAML::Node &doc) { return doc["tileset"]["tiles"]["sharing"]["packing"]; },
304 parse_tile_sharing_packing,
305 "tileset.tiles.sharing.packing",
306 "tileset.tiles.sharing.packing");
307}
308
310{
311 auto paths_result = get_config_path_chain(project_root_, type, scope);
312 if (!paths_result.has_value()) {
313 return LayerValue<TileSharingAlignment>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
314 }
315 return search_config_files<TileSharingAlignment>(
316 format_,
317 paths_result.value(),
318 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
319 [](const YAML::Node &doc) { return doc["tileset"]["tiles"]["sharing"]["alignment"]; },
320 parse_tile_sharing_alignment,
321 "tileset.tiles.sharing.alignment",
322 "tileset.tiles.sharing.alignment");
323}
324
326{
327 auto paths_result = get_config_path_chain(project_root_, type, scope);
328 if (!paths_result.has_value()) {
329 return LayerValue<TilesPalMode>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
330 }
331 return search_config_files<TilesPalMode>(
332 format_,
333 paths_result.value(),
334 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
335 [](const YAML::Node &doc) { return doc["tileset"]["tiles"]["palette_mode"]; },
336 parse_tiles_pal_mode,
337 "tileset.tiles.palette_mode",
338 "tileset.tiles.palette_mode");
339}
340
342{
343 auto paths_result = get_config_path_chain(project_root_, type, scope);
344 if (!paths_result.has_value()) {
345 return LayerValue<AnimPalResolutionStrategy>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
346 }
347 return search_config_files<AnimPalResolutionStrategy>(
348 format_,
349 paths_result.value(),
350 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
351 [](const YAML::Node &doc) { return doc["tileset"]["animations"]["palette_resolution_strategy"]; },
352 parse_anim_pal_resolution_strategy,
353 "tileset.animations.palette_resolution_strategy",
354 "tileset.animations.palette_resolution_strategy");
355}
356
358{
359 auto paths_result = get_config_path_chain(project_root_, type, scope);
360 if (!paths_result.has_value()) {
361 return LayerValue<AnimKeyFrameResolutionStrategy>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
362 }
363 return search_config_files<AnimKeyFrameResolutionStrategy>(
364 format_,
365 paths_result.value(),
366 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
367 [](const YAML::Node &doc) { return doc["tileset"]["animations"]["key_frame_resolution_strategy"]; },
368 parse_anim_key_frame_resolution_strategy,
369 "tileset.animations.key_frame_resolution_strategy",
370 "tileset.animations.key_frame_resolution_strategy");
371}
372
374{
375 auto paths_result = get_config_path_chain(project_root_, type, scope);
376 if (!paths_result.has_value()) {
377 return LayerValue<AnimMultiPalSubtileResolutionStrategy>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
378 }
379 return search_config_files<AnimMultiPalSubtileResolutionStrategy>(
380 format_,
381 paths_result.value(),
382 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
383 [](const YAML::Node &doc) { return doc["tileset"]["animations"]["multi_palette_subtile_resolution_strategy"]; },
384 parse_anim_multi_pal_subtile_resolution_strategy,
385 "tileset.animations.multi_palette_subtile_resolution_strategy",
386 "tileset.animations.multi_palette_subtile_resolution_strategy");
387}
388
390{
391 auto paths_result = get_config_path_chain(project_root_, type, scope);
392 if (!paths_result.has_value()) {
393 return LayerValue<FrameLinking>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
394 }
395 return search_config_files<FrameLinking>(
396 format_,
397 paths_result.value(),
398 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
399 [](const YAML::Node &doc) { return doc["tileset"]["animations"]["frame_linking"]; },
400 parse_frame_linking,
401 "tileset.animations.frame_linking",
402 "tileset.animations.frame_linking");
403}
404
406{
407 auto paths_result = get_config_path_chain(project_root_, type, scope);
408 if (!paths_result.has_value()) {
409 return LayerValue<PerAnimOverrides>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
410 }
411 return search_config_files<PerAnimOverrides>(
412 format_,
413 paths_result.value(),
414 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
415 [](const YAML::Node &doc) { return doc["tileset"]["animations"]["per_animation_overrides"]; },
416 parse_per_anim_overrides,
417 "tileset.animations.per_animation_overrides",
418 "tileset.animations.per_animation_overrides");
419}
420
422{
423 auto paths_result = get_config_path_chain(project_root_, type, scope);
424 if (!paths_result.has_value()) {
425 return LayerValue<bool>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
426 }
427 return search_config_files<bool>(
428 format_,
429 paths_result.value(),
430 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
431 [](const YAML::Node &doc) { return doc["tileset"]["animations"]["cross_tileset_linking"]; },
432 parse_bool,
433 "tileset.animations.cross_tileset_linking",
434 "tileset.animations.cross_tileset_linking");
435}
436
438{
439 auto paths_result = get_config_path_chain(project_root_, type, scope);
440 if (!paths_result.has_value()) {
441 return LayerValue<bool>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
442 }
443 return search_config_files<bool>(
444 format_,
445 paths_result.value(),
446 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
447 [](const YAML::Node &doc) { return doc["verify_checksums"]; },
448 parse_bool,
449 "verify_checksums",
450 "verify_checksums");
451}
452
454{
455 auto paths_result = get_config_path_chain(project_root_, type, scope);
456 if (!paths_result.has_value()) {
457 return LayerValue<PrimaryPairingMode>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
458 }
459 return search_config_files<PrimaryPairingMode>(
460 format_,
461 paths_result.value(),
462 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
463 [](const YAML::Node &doc) { return doc["tileset"]["primary_pairing"]["mode"]; },
464 parse_primary_pairing_mode,
465 "tileset.primary_pairing.mode",
466 "tileset.primary_pairing.mode");
467}
468
470{
471 auto paths_result = get_config_path_chain(project_root_, type, scope);
472 if (!paths_result.has_value()) {
473 return LayerValue<std::vector<std::string>>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
474 }
475 return search_config_files<std::vector<std::string>>(
476 format_,
477 paths_result.value(),
478 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
479 [](const YAML::Node &doc) { return doc["tileset"]["primary_pairing"]["partners"]; },
480 parse_string_vector,
481 "tileset.primary_pairing.partners",
482 "tileset.primary_pairing.partners");
483}
484
486{
487 auto paths_result = get_config_path_chain(project_root_, type, scope);
488 if (!paths_result.has_value()) {
489 return LayerValue<std::vector<std::string>>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
490 }
491 return search_config_files<std::vector<std::string>>(
492 format_,
493 paths_result.value(),
494 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
495 [](const YAML::Node &doc) { return doc["diagnostics"]["warnings"]["exclude"]; },
496 parse_string_vector,
497 "diagnostics.warnings.exclude",
498 "diagnostics.warnings.exclude");
499}
500
502{
503 auto paths_result = get_config_path_chain(project_root_, type, scope);
504 if (!paths_result.has_value()) {
505 return LayerValue<std::vector<std::string>>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
506 }
507 return search_config_files<std::vector<std::string>>(
508 format_,
509 paths_result.value(),
510 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
511 [](const YAML::Node &doc) { return doc["diagnostics"]["warnings"]["include"]; },
512 parse_string_vector,
513 "diagnostics.warnings.include",
514 "diagnostics.warnings.include");
515}
516
518{
519 auto paths_result = get_config_path_chain(project_root_, type, scope);
520 if (!paths_result.has_value()) {
521 return LayerValue<std::vector<std::string>>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
522 }
523 return search_config_files<std::vector<std::string>>(
524 format_,
525 paths_result.value(),
526 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
527 [](const YAML::Node &doc) { return doc["diagnostics"]["remarks"]["exclude"]; },
528 parse_string_vector,
529 "diagnostics.remarks.exclude",
530 "diagnostics.remarks.exclude");
531}
532
534{
535 auto paths_result = get_config_path_chain(project_root_, type, scope);
536 if (!paths_result.has_value()) {
537 return LayerValue<std::vector<std::string>>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
538 }
539 return search_config_files<std::vector<std::string>>(
540 format_,
541 paths_result.value(),
542 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
543 [](const YAML::Node &doc) { return doc["diagnostics"]["remarks"]["include"]; },
544 parse_string_vector,
545 "diagnostics.remarks.include",
546 "diagnostics.remarks.include");
547}
548
550{
551 auto paths_result = get_config_path_chain(project_root_, type, scope);
552 if (!paths_result.has_value()) {
553 return LayerValue<std::string>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
554 }
555 return search_config_files<std::string>(
556 format_,
557 paths_result.value(),
558 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
559 [](const YAML::Node &doc) { return doc["tileset"]["paths"]["primary"]["src"]; },
560 parse_string,
561 "tileset.paths.primary.src",
562 "tileset.paths.primary.src");
563}
564
566{
567 auto paths_result = get_config_path_chain(project_root_, type, scope);
568 if (!paths_result.has_value()) {
569 return LayerValue<std::string>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
570 }
571 return search_config_files<std::string>(
572 format_,
573 paths_result.value(),
574 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
575 [](const YAML::Node &doc) { return doc["tileset"]["paths"]["primary"]["bin"]; },
576 parse_string,
577 "tileset.paths.primary.bin",
578 "tileset.paths.primary.bin");
579}
580
582{
583 auto paths_result = get_config_path_chain(project_root_, type, scope);
584 if (!paths_result.has_value()) {
585 return LayerValue<std::string>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
586 }
587 return search_config_files<std::string>(
588 format_,
589 paths_result.value(),
590 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
591 [](const YAML::Node &doc) { return doc["tileset"]["paths"]["secondary"]["src"]; },
592 parse_string,
593 "tileset.paths.secondary.src",
594 "tileset.paths.secondary.src");
595}
596
598{
599 auto paths_result = get_config_path_chain(project_root_, type, scope);
600 if (!paths_result.has_value()) {
601 return LayerValue<std::string>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
602 }
603 return search_config_files<std::string>(
604 format_,
605 paths_result.value(),
606 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
607 [](const YAML::Node &doc) { return doc["tileset"]["paths"]["secondary"]["bin"]; },
608 parse_string,
609 "tileset.paths.secondary.bin",
610 "tileset.paths.secondary.bin");
611}
612
614{
615 auto paths_result = get_config_path_chain(project_root_, type, scope);
616 if (!paths_result.has_value()) {
617 return LayerValue<std::size_t>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
618 }
619 return search_config_files<std::size_t>(
620 format_,
621 paths_result.value(),
622 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
623 [](const YAML::Node &doc) { return doc["fieldmap"]["metatile_attribute_size"]; },
624 parse_size_t,
625 "fieldmap.metatile_attribute_size",
626 "fieldmap.metatile_attribute_size");
627}
628
630{
631 auto paths_result = get_config_path_chain(project_root_, type, scope);
632 if (!paths_result.has_value()) {
633 return LayerValue<bool>::invalid(paths_result.error().join(PlainTextFormatter{}), "config path resolution");
634 }
635 return search_config_files<bool>(
636 format_,
637 paths_result.value(),
638 [this](const std::filesystem::path &p) { return load_yaml_file(p, format_, diagnostics_); },
639 [](const YAML::Node &doc) { return doc["tileset"]["animations"]["wire_anim_code"]; },
640 parse_bool,
641 "tileset.animations.wire_anim_code",
642 "tileset.animations.wire_anim_code");
643}
644
645} // namespace porytiles
TextFormatter implementation that strips all styling from text.
Abstract class for structured error reporting and diagnostic output.
LayerValue< std::size_t > num_tiles_in_primary(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::vector< std::string > > diagnostic_remarks_exclude(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::string > tileset_paths_secondary_bin(ConfigScopeType type, const std::string &scope) const override
LayerValue< Rgba32 > extrinsic_transparency(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::vector< std::string > > primary_pairing_partners(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > num_pals_in_primary(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > num_metatiles_in_primary(ConfigScopeType type, const std::string &scope) const override
LayerValue< AnimKeyFrameResolutionStrategy > global_anim_key_frame_resolution_strategy(ConfigScopeType type, const std::string &scope) const override
LayerValue< bool > tileset_animations_wire_anim_code(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > max_map_data_size(ConfigScopeType type, const std::string &scope) const override
YamlFileProvider(gsl::not_null< const TextFormatter * > format, const UserDiagnostics *diagnostics, const std::filesystem::path &project_root)
Constructs a YamlFileProvider that searches for configuration across multiple YAML files.
LayerValue< std::string > tileset_paths_primary_src(ConfigScopeType type, const std::string &scope) const override
LayerValue< PerAnimOverrides > per_anim_overrides(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::string > tileset_paths_primary_bin(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::string > tileset_paths_secondary_src(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > metatile_attr_size(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > num_pals_total(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::vector< std::string > > diagnostic_remarks_include(ConfigScopeType type, const std::string &scope) const override
LayerValue< PrimaryPairingMode > primary_pairing_mode(ConfigScopeType type, const std::string &scope) const override
LayerValue< ArtifactEditMode > tiles_edit_mode(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::vector< PaletteHint > > pal_hints(ConfigScopeType type, const std::string &scope) const override
LayerValue< TilesPalMode > tiles_pal_mode(ConfigScopeType type, const std::string &scope) const override
LayerValue< bool > cross_tileset_anim_linking(ConfigScopeType type, const std::string &scope) const override
LayerValue< bool > verify_checksums(ConfigScopeType type, const std::string &scope) const override
LayerValue< PackingStrategyType > packing_strategy(ConfigScopeType type, const std::string &scope) const override
LayerValue< FrameLinking > global_frame_linking(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::vector< std::string > > diagnostic_warnings_include(ConfigScopeType type, const std::string &scope) const override
LayerValue< ArtifactEditMode > pals_edit_mode(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > num_tiles_total(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > num_metatiles_total(ConfigScopeType type, const std::string &scope) const override
bool preload_and_validate(ConfigScopeType type, const std::string &scope) const
Eagerly loads all YAML config files and validates them for unknown keys.
std::string name() const override
Gets the name of this config layer.
LayerValue< bool > pal_hints_enabled(ConfigScopeType type, const std::string &scope) const override
LayerValue< AnimPalResolutionStrategy > global_anim_pal_resolution_strategy(ConfigScopeType type, const std::string &scope) const override
LayerValue< TileSharingPacking > tile_sharing_packing(ConfigScopeType type, const std::string &scope) const override
LayerValue< AnimMultiPalSubtileResolutionStrategy > global_anim_multi_pal_subtile_resolution_strategy(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::size_t > num_tiles_per_metatile(ConfigScopeType type, const std::string &scope) const override
LayerValue< std::vector< std::string > > diagnostic_warnings_exclude(ConfigScopeType type, const std::string &scope) const override
LayerValue< PackingStrategyParams > packing_strategy_params(ConfigScopeType type, const std::string &scope) const override
LayerValue< TileSharingAlignment > tile_sharing_alignment(ConfigScopeType type, const std::string &scope) const override
ConfigScopeType
Specifies the scope type for configuration value lookups.
Utility functions for string manipulation and formatting.
A small container that holds an optional-wrapped value, validation state, and metadata about the valu...
static LayerValue invalid(std::string error, std::string source_info)
Creates a LayerValue representing an invalid configuration value.