Porytiles
Loading...
Searching...
No Matches
metatile_attribute.cpp
Go to the documentation of this file.
2
3#include <string>
4
7
8namespace porytiles2::attr {
9
10std::string to_string(LayerType layerType)
11{
12 switch (layerType) {
14 return "Normal - Middle/Top";
16 return "Covered - Bottom/Middle";
18 return "Split - Bottom/Top";
19 default:
20 panic("to_string(LayerType) unknown LayerType");
21 }
22}
23
25{
26 if (i > static_cast<std::uint8_t>(LayerType::split)) {
27 return FormattableError{
28 "invalid layer type integer value '{}': must be 0, 1, or 2", FormatParam{i, Style::bold}};
29 }
30 return static_cast<LayerType>(i);
31}
32
33} // namespace porytiles2::attr
A result type that maintains a chainable sequence of errors for debugging and error reporting.
A text parameter with associated styling for formatted output.
General-purpose error implementation with formatted message support.
Definition error.hpp:117
ChainableResult< LayerType > layer_type_from_int(std::uint8_t i)
std::string to_string(LayerType layerType)
void panic(const StringViewSourceLoc &s)
Unconditionally terminates the program with a panic message.
Definition panic.hpp:53
@ bold
Bold text formatting.