17 layer_mode, component.
detect_layer_mode(), std::vector<TilemapEntry>,
"Layer mode detection failed.");
28 std::vector<TilemapEntry> result;
34 for (std::size_t i = 0; i < num_metatiles; ++i) {
36 constexpr std::size_t transparent_entries = 4;
37 const auto &attribute = metatile_attributes[i];
40 switch (attribute.layer_type()) {
43 for (std::size_t j = 0; j < transparent_entries; ++j) {
44 result.push_back(transparent);
48 result.push_back(metatiles_bin[input_offset + j]);
55 result.push_back(metatiles_bin[input_offset + j]);
58 for (std::size_t j = 0; j < transparent_entries; ++j) {
59 result.push_back(transparent);
65 for (std::size_t j = 0; j < transparent_entries; ++j) {
66 result.push_back(metatiles_bin[input_offset + j]);
69 for (std::size_t j = 0; j < transparent_entries; ++j) {
70 result.push_back(transparent);
74 result.push_back(metatiles_bin[input_offset + j]);
84 const std::vector<TilemapEntry> &entries,
86 const std::vector<std::optional<LayerType>> &explicit_layer_types)
89 if (entries.size() != expected_entries_size) {
91 "entries vector size " + std::to_string(entries.size()) +
" did not match expected size " +
92 std::to_string(expected_entries_size));
95 std::vector<TilemapEntry> result;
98 for (std::size_t i = 0; i < source_metatiles.size(); ++i) {
99 const auto &metatile = source_metatiles[i];
107 const LayerMode layer_mode = metatile.infer_layer_mode(extrinsic_transparency_);
111 const LayerType inferred = metatile.infer_layer_type(extrinsic_transparency_);
112 const LayerType layer_type = (i < explicit_layer_types.size() && explicit_layer_types[i].has_value())
113 ? explicit_layer_types[i].value()
120 bool drops_visible =
false;
121 for (std::size_t j = drop_begin; j < drop_begin + 4; ++j) {
122 if (entries[input_offset + j].tile_index() != 0) {
123 drops_visible =
true;
128 std::vector<std::string> lines;
130 "Metatile {}: layer type '{}' drops a layer that contains visible tiles. Those tiles will be "
134 if (is_implied_triple) {
136 "This metatile has content on all three layers. Pin its layer type via a '{}' layer_type pin to "
137 "control which layer is dropped.",
140 diag_->
warning(
"dual-layer-drop", lines);
147 result.push_back(entries[input_offset + j]);
154 result.push_back(entries[input_offset + j]);
160 for (std::size_t j = 0; j < 4; ++j) {
161 result.push_back(entries[input_offset + j]);
164 result.push_back(entries[input_offset + j]);
#define PT_TRY_ASSIGN_CHAIN_ERR(var, expr, return_type,...)
Unwraps a ChainableResult, chaining a new error message on failure.
A result type that maintains a chainable sequence of errors for debugging and error reporting.
ChainableResult< std::vector< TilemapEntry > > triple_layerize(const PorymapTilesetComponent &component)
Converts a tileset component to triple-layer format.
std::vector< TilemapEntry > dual_layerize(const std::vector< TilemapEntry > &entries, const std::vector< Metatile< Rgba32 > > &source_metatiles, const std::vector< std::optional< LayerType > > &explicit_layer_types={})
Converts a tileset from triple-layer format to dual-layer format.
const std::vector< TilemapEntry > & metatiles_bin() const
ChainableResult< LayerMode > detect_layer_mode() const
const std::vector< MetatileAttribute > & metatile_attributes_bin() const
static const Style bold
Bold text 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.
Represents a tilemap entry referencing a tile with palette and flip attributes.
const TextFormatter & formatter() const
virtual void warning(const std::string &tag, const std::vector< std::string > &lines) const =0
Display a tagged warning message.
LayerMode
Specifies whether a metatile uses dual-layer or triple-layer mode.
void panic(const StringViewSourceLoc &s)
Unconditionally terminates the program with a panic message.
std::string layer_type_csv_token(LayerType layer_type)
Converts a LayerType to its lowercase CSV token.
LayerType
Specifies which layers of a metatile are used for rendering.