15const std::filesystem::path metatiles_rel_path = std::filesystem::path{
"src"} /
"data" /
"tilesets" /
"metatiles.h";
25detect_attr_size(
const std::filesystem::path &metatiles_path,
const TextFormatter *format)
27 if (!std::filesystem::exists(metatiles_path)) {
31 std::ifstream in{metatiles_path};
36 bool found_u16 =
false;
37 bool found_u32 =
false;
40 while (std::getline(in, line)) {
41 if (line.find(
"gMetatileAttributes_") == std::string::npos) {
45 if (line.find(
"const u16") != std::string::npos) {
48 if (line.find(
"const u32") != std::string::npos) {
53 if (!found_u16 && !found_u32) {
57 const std::string source_info = metatiles_path.string();
59 if (found_u16 && found_u32) {
62 "Mixed u16/u32 attribute declarations found in '{}'.",
67 const std::size_t attr_size = found_u32 ? 4 : 2;
77 return "MetatilesHeaderProvider";
83 if (!cached_result_.has_value()) {
84 cached_result_ = detect_attr_size(project_root_ / metatiles_rel_path, format_);
86 return cached_result_.value();
Abstract base class for applying text styling with context-aware formatting.
virtual std::string format(const std::string &format_str, const std::vector< FormatParam > ¶ms) const
Formats a string with styled parameters using fmtlib syntax.
ConfigScopeType
Specifies the scope type for configuration value lookups.
A small container that holds an optional-wrapped value, validation state, and metadata about the valu...
static LayerValue valid(T val, std::string source_key, std::string source_info)
Creates a LayerValue representing a valid configuration value.
static LayerValue not_provided()
Creates a LayerValue representing that the provider does not supply this configuration.
static LayerValue invalid(std::string error, std::string source_info)
Creates a LayerValue representing an invalid configuration value.