Porytiles
Loading...
Searching...
No Matches
per_anim_overrides.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <format>
4#include <ostream>
5#include <string>
6#include <unordered_map>
7
9
10namespace porytiles {
11
18using PerAnimOverrides = std::unordered_map<std::string, PerAnimOverride>;
19
27[[nodiscard]] inline std::string to_string(const PerAnimOverrides &configs)
28{
29 if (configs.empty()) {
30 return "{}";
31 }
32 std::string result = "{";
33 bool first = true;
34 for (const auto &[key, value] : configs) {
35 if (!first) {
36 result += ", ";
37 }
38 result +=
39 key + "={linking=" + (value.linking.has_value() ? to_string(*value.linking) : "none") +
40 ", palette_strategy=" +
41 (value.palette_resolution_strategy.has_value() ? to_string(*value.palette_resolution_strategy) : "none") +
42 ", per_tile_strategies=" + std::to_string(value.per_tile_palette_resolution_strategies.size()) + "}";
43 first = false;
44 }
45 result += "}";
46 return result;
47}
48
54inline std::ostream &operator<<(std::ostream &os, const PerAnimOverrides &configs)
55{
56 return os << to_string(configs);
57}
58
59} // namespace porytiles
60
61template <>
62struct std::formatter<porytiles::PerAnimOverrides> {
63 constexpr auto parse(std::format_parse_context &ctx)
64 {
65 return ctx.begin();
66 }
67
68 auto format(const porytiles::PerAnimOverrides &value, auto &ctx) const
69 {
70 return std::format_to(ctx.out(), "{}", porytiles::to_string(value));
71 }
72};
std::ostream & operator<<(std::ostream &os, const PrimaryPairingMode m)
Stream insertion operator for PrimaryPairingMode.
std::unordered_map< std::string, PerAnimOverride > PerAnimOverrides
Per-animation configuration map.
std::string to_string(const PrimaryPairingMode m)
Converts a PrimaryPairingMode to its canonical string representation.
auto format(const porytiles::PerAnimOverrides &value, auto &ctx) const
constexpr auto parse(std::format_parse_context &ctx)