Porytiles
Loading...
Searching...
No Matches
anim_multi_palette_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// NOTE: DO NOT EDIT THIS FILE DIRECTLY. It is AUTO-GENERATED from config_schema.yaml.
13// To add new config values or make other changes, edit config_schema.yaml and regenerate via:
14//
15// uv run scripts/generate_config.py
16
17namespace porytiles {
18
30 error,
32 warning,
34 split
35};
36
50[[nodiscard]] inline std::optional<AnimMultiPaletteSubtileResolutionStrategy>
52{
53 // Phase 1: Exact match against C++ constant names
54 if (str == "error") {
56 }
57 if (str == "warning") {
59 }
60 if (str == "split") {
62 }
63
64 // Phase 2: Case-insensitive fuzzy match
65 std::string lower_str = str;
66 std::ranges::transform(
67 lower_str, lower_str.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
68
69 // Fuzzy names for error
70 if (lower_str == "error") {
72 }
73 if (lower_str == "err") {
75 }
76 // Fuzzy names for warning
77 if (lower_str == "warning") {
79 }
80 if (lower_str == "warn") {
82 }
83 // Fuzzy names for split
84 if (lower_str == "split") {
86 }
87
88 return std::nullopt;
89}
90
99[[nodiscard]] inline std::string to_string(const AnimMultiPaletteSubtileResolutionStrategy m)
100{
101 switch (m) {
103 return "error";
105 return "warning";
107 return "split";
108 }
109 panic("unhandled AnimMultiPaletteSubtileResolutionStrategy value");
110}
111
117inline std::ostream &operator<<(std::ostream &os, const AnimMultiPaletteSubtileResolutionStrategy m)
118{
119 return os << to_string(m);
120}
121
122} // namespace porytiles
123
124template <>
125struct std::formatter<porytiles::AnimMultiPaletteSubtileResolutionStrategy> {
126 constexpr auto parse(std::format_parse_context &ctx)
127 {
128 return ctx.begin();
129 }
130
132 {
133 return std::format_to(ctx.out(), "{}", porytiles::to_string(value));
134 }
135};
void panic(const StringViewSourceLoc &s)
Unconditionally terminates the program with a panic message.
Definition panic.cpp:43
std::optional< AnimMultiPaletteSubtileResolutionStrategy > anim_multi_palette_subtile_resolution_strategy_from_str(const std::string &str)
Parses a string into a AnimMultiPaletteSubtileResolutionStrategy with fuzzy matching.
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::string to_string(const PrimaryPairingMode m)
Converts a PrimaryPairingMode to its canonical string representation.
AnimMultiPaletteSubtileResolutionStrategy
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).
auto format(const porytiles::AnimMultiPaletteSubtileResolutionStrategy &value, auto &ctx) const