Porytiles
Loading...
Searching...
No Matches
anim_multi_pal_subtile_resolution_strategy.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <cctype>
5#include <format>
6#include <optional>
7#include <ostream>
8#include <string>
9
11
12/*
13 * NOTE: DO NOT EDIT THIS FILE DIRECTLY. It is AUTO-GENERATED from config_schema.yaml.
14 * To add new config values or make other changes, edit config_schema.yaml and regenerate via:
15 *
16 * uv run scripts/generate_config.py
17 */
18
19namespace porytiles {
20
36 error,
40 warning,
44 split
45};
46
62[[nodiscard]] inline std::optional<AnimMultiPalSubtileResolutionStrategy> anim_multi_pal_subtile_resolution_strategy_from_str(const std::string &str)
63{
64 // Phase 1: Exact match against C++ constant names
65 if (str == "error") {
67 }
68 if (str == "warning") {
70 }
71 if (str == "split") {
73 }
74
75 // Phase 2: Case-insensitive fuzzy match
76 std::string lower_str = str;
77 std::ranges::transform(
78 lower_str, lower_str.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
79
80 // Fuzzy names for error
81 if (lower_str == "error") {
83 }
84 if (lower_str == "err") {
86 }
87 // Fuzzy names for warning
88 if (lower_str == "warning") {
90 }
91 if (lower_str == "warn") {
93 }
94 // Fuzzy names for split
95 if (lower_str == "split") {
97 }
98
99 return std::nullopt;
100}
101
112[[nodiscard]] inline std::string to_string(const AnimMultiPalSubtileResolutionStrategy m)
113{
114 switch (m) {
116 return "error";
118 return "warning";
120 return "split";
121 }
122 panic("unhandled AnimMultiPalSubtileResolutionStrategy value");
123}
124
132inline std::ostream &operator<<(std::ostream &os, const AnimMultiPalSubtileResolutionStrategy m)
133{
134 return os << to_string(m);
135}
136
137} // namespace porytiles
138
139template <>
140struct std::formatter<porytiles::AnimMultiPalSubtileResolutionStrategy> {
141 constexpr auto parse(std::format_parse_context &ctx)
142 {
143 return ctx.begin();
144 }
145
147 {
148 return std::format_to(ctx.out(), "{}", porytiles::to_string(value));
149 }
150};
void panic(const StringViewSourceLoc &s)
Unconditionally terminates the program with a panic message.
Definition panic.cpp:43
AnimMultiPalSubtileResolutionStrategy
Strategy for handling animation subtiles referenced with multiple palettes.
@ warning
Emit a warning and continue decompilation using the lowest palette index.
@ error
Emit a formatted error and fail decompilation.
@ split
Split the animation into separate animations for each palette variant (not yet implemented).
std::ostream & operator<<(std::ostream &os, const PrimaryPairingMode m)
Stream insertion operator for PrimaryPairingMode.
@ warning
Emit a warning and continue decompilation.
@ error
Emit a formatted error and fail decompilation.
std::optional< AnimMultiPalSubtileResolutionStrategy > anim_multi_pal_subtile_resolution_strategy_from_str(const std::string &str)
Parses a string into a AnimMultiPalSubtileResolutionStrategy with fuzzy matching.
std::string to_string(const PrimaryPairingMode m)
Converts a PrimaryPairingMode to its canonical string representation.
auto format(const porytiles::AnimMultiPalSubtileResolutionStrategy &value, auto &ctx) const