Porytiles
Loading...
Searching...
No Matches
tiles_pal_mode.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <string>
5
7
8namespace porytiles {
9
11
12[[nodiscard]] inline std::optional<TilesPalMode> TilesPalModeFromStr(const std::string &str) {
13 if (str == "true-color") {
14 return std::optional{TilesPalMode::kTrueColor};
15 }
16 if (str == "greyscale") {
17 return std::optional{TilesPalMode::kGreyscale};
18 }
19 return std::nullopt;
20}
21
22[[nodiscard]] inline std::string TilesPalModeToStr(const TilesPalMode m) {
23 switch (m) {
25 return "true-color";
27 return "greyscale";
28 }
29 Panic("unhandled OutputPalette value");
30}
31
32inline std::ostream &operator<<(std::ostream &os, const TilesPalMode m) {
33 return os << TilesPalModeToStr(m);
34}
35
36} // namespace porytiles
void Panic(const StringViewSourceLoc &s) noexcept
Definition panic.hpp:31
std::ostream & operator<<(std::ostream &os, const TilesPalMode m)
std::optional< TilesPalMode > TilesPalModeFromStr(const std::string &str)
std::string TilesPalModeToStr(const TilesPalMode m)