bn::affine_bg_map_item class

Contains the required information to generate affine background maps.

The assets conversion tools generate an object of this type in the build folder for each *.bmp file with affine_bg type.

The map cells are not copied but referenced, so they should outlive the affine_bg_map_item to avoid dangling references.

Constructors, destructors, conversion operators

affine_bg_map_item(const affine_bg_map_cell& cells_ref, const size& dimensions) constexpr
Constructor.
affine_bg_map_item(const affine_bg_map_cell& cells_ref, const size& dimensions, compression_type compression) constexpr
Constructor.

Public functions

auto cells_ref() const -> const affine_bg_map_cell& constexpr
Returns the referenced map cells.
auto dimensions() const -> const size& constexpr
Returns the size in map cells of the referenced map cells.
auto big() const -> bool constexpr
Indicates if maps generated with this item are big or not.
auto compression() const -> compression_type constexpr
Returns the compression type.
auto cell_index(int map_x, int map_y) const -> int constexpr
Returns the index of the referenced map cell in the specified map coordinates.
auto cell_index(const point& map_position) const -> int constexpr
Returns the index of the referenced map cell in the specified map coordinates.
auto cell(int map_x, int map_y) const -> affine_bg_map_cell constexpr
Returns the referenced map cell in the specified map coordinates.
auto cell(const point& map_position) const -> affine_bg_map_cell constexpr
Returns the referenced map cell in the specified map coordinates.
auto decompress(affine_bg_map_cell& decompressed_cells_ref, const size& decompressed_dimensions) const -> affine_bg_map_item
Decompresses the stored data in the map cells referenced by decompressed_cells_ref.
auto find_map(const affine_bg_tiles_ptr& tiles, const bg_palette_ptr& palette) const -> optional<affine_bg_map_ptr>
Searches for an affine_bg_map_ptr which references the information provided by this item.
auto create_map(affine_bg_tiles_ptr tiles, bg_palette_ptr palette) const -> affine_bg_map_ptr
Searches for an affine_bg_map_ptr which references the information provided by this item. If it is not found, it creates an affine_bg_map_ptr which references it.
auto create_new_map(affine_bg_tiles_ptr tiles, bg_palette_ptr palette) const -> affine_bg_map_ptr
Creates an affine_bg_map_ptr which references the information provided by this item.
auto create_map_optional(affine_bg_tiles_ptr tiles, bg_palette_ptr palette) const -> optional<affine_bg_map_ptr>
Searches for an affine_bg_map_ptr which references the information provided by this item. If it is not found, it creates an affine_bg_map_ptr which references it.
auto create_new_map_optional(affine_bg_tiles_ptr tiles, bg_palette_ptr palette) const -> optional<affine_bg_map_ptr>
Creates an affine_bg_map_ptr which references the information provided by this item.

Friends

auto operator==(const affine_bg_map_item& a, const affine_bg_map_item& b) -> friend bool defaulted constexpr
Default equal operator.

Function documentation

bn::affine_bg_map_item::affine_bg_map_item(const affine_bg_map_cell& cells_ref, const size& dimensions) constexpr

Constructor.

Parameters
cells_ref Reference to one or more affine background map cells.
dimensions Size in map cells of the referenced map cells.

The map cells are not copied but referenced, so they should outlive the affine_bg_map_item to avoid dangling references.

bn::affine_bg_map_item::affine_bg_map_item(const affine_bg_map_cell& cells_ref, const size& dimensions, compression_type compression) constexpr

Constructor.

Parameters
cells_ref Reference to one or more affine background map cells.
dimensions Size in map cells of the referenced map cells.
compression Compression type.

The map cells are not copied but referenced, so they should outlive the affine_bg_map_item to avoid dangling references.

bool bn::affine_bg_map_item::big() const constexpr

Indicates if maps generated with this item are big or not.

Big backgrounds are slower CPU wise and don't support wrapping (they can't be moved beyond their boundaries), but can have any width or height multiple of 256 pixels.

int bn::affine_bg_map_item::cell_index(int map_x, int map_y) const constexpr

Returns the index of the referenced map cell in the specified map coordinates.

Parameters
map_x Horizontal position of the map cell [0..dimensions().width()).
map_y Vertical position of the map cell [0..dimensions().height()).
Returns The index of the referenced map cell.

The map cells are not copied but referenced, so they should outlive the affine_bg_map_item to avoid dangling references.

int bn::affine_bg_map_item::cell_index(const point& map_position) const constexpr

Returns the index of the referenced map cell in the specified map coordinates.

Parameters
map_position Position of the map cell.
Returns The index of the referenced map cell.

The map cells are not copied but referenced, so they should outlive the affine_bg_map_item to avoid dangling references.

affine_bg_map_cell bn::affine_bg_map_item::cell(int map_x, int map_y) const constexpr

Returns the referenced map cell in the specified map coordinates.

Parameters
map_x Horizontal position of the map cell [0..dimensions().width()).
map_y Vertical position of the map cell [0..dimensions().height()).
Returns The referenced map cell.

The map cells are not copied but referenced, so they should outlive the affine_bg_map_item to avoid dangling references.

affine_bg_map_cell bn::affine_bg_map_item::cell(const point& map_position) const constexpr

Returns the referenced map cell in the specified map coordinates.

Parameters
map_position Position of the map cell.
Returns The referenced map cell.

The map cells are not copied but referenced, so they should outlive the affine_bg_map_item to avoid dangling references.

affine_bg_map_item bn::affine_bg_map_item::decompress(affine_bg_map_cell& decompressed_cells_ref, const size& decompressed_dimensions) const

Decompresses the stored data in the map cells referenced by decompressed_cells_ref.

Parameters
decompressed_cells_ref Destination of the decompressed map cells.
decompressed_dimensions Size in map cells of the destination data.
Returns An affine_bg_map_item pointing to the decompressed map cells.

If the source and destination map cells overlap, the behavior is undefined.

optional<affine_bg_map_ptr> bn::affine_bg_map_item::find_map(const affine_bg_tiles_ptr& tiles, const bg_palette_ptr& palette) const

Searches for an affine_bg_map_ptr which references the information provided by this item.

Parameters
tiles Referenced tiles of the map to search.
palette Referenced color palette of the map to search.
Returns affine_bg_map_ptr which references the information provided by this item if it has been found; bn::nullopt otherwise.

affine_bg_map_ptr bn::affine_bg_map_item::create_map(affine_bg_tiles_ptr tiles, bg_palette_ptr palette) const

Searches for an affine_bg_map_ptr which references the information provided by this item. If it is not found, it creates an affine_bg_map_ptr which references it.

Parameters
tiles Referenced tiles of the map to search or handle.
palette Referenced color palette of the map to search or handle.
Returns affine_bg_map_ptr which references the information provided by this item if it has been found; otherwise it returns an affine_bg_map_ptr which references it.

The map cells are not copied but referenced, so they should outlive the affine_bg_map_ptr to avoid dangling references.

affine_bg_map_ptr bn::affine_bg_map_item::create_new_map(affine_bg_tiles_ptr tiles, bg_palette_ptr palette) const

Creates an affine_bg_map_ptr which references the information provided by this item.

Parameters
tiles Referenced tiles of the map to handle.
palette Referenced color palette of the map to handle.
Returns affine_bg_map_ptr which references the information provided by this item.

The map system does not support multiple affine_bg_map_ptr items referencing to the same map cells. If you are not sure if the information provided by this item is already referenced or not, you should use the create_map method instead.

The map cells are not copied but referenced, so they should outlive the affine_bg_map_ptr to avoid dangling references.

optional<affine_bg_map_ptr> bn::affine_bg_map_item::create_map_optional(affine_bg_tiles_ptr tiles, bg_palette_ptr palette) const

Searches for an affine_bg_map_ptr which references the information provided by this item. If it is not found, it creates an affine_bg_map_ptr which references it.

Parameters
tiles Referenced tiles of the map to search or handle.
palette Referenced color palette of the map to search or handle.
Returns affine_bg_map_ptr which references the information provided by this item if it has been found; otherwise it returns an affine_bg_map_ptr which references it if it could be allocated; bn::nullopt otherwise.

The map cells are not copied but referenced, so they should outlive the affine_bg_map_ptr to avoid dangling references.

optional<affine_bg_map_ptr> bn::affine_bg_map_item::create_new_map_optional(affine_bg_tiles_ptr tiles, bg_palette_ptr palette) const

Creates an affine_bg_map_ptr which references the information provided by this item.

Parameters
tiles Referenced tiles of the map to handle.
palette Referenced color palette of the map to handle.
Returns affine_bg_map_ptr which references the information provided by this item if the affine_bg_map_ptr can be allocated; bn::nullopt otherwise.

The map system does not support multiple affine_bg_map_ptr items referencing to the same map cells. If you are not sure if the information provided by this item is already referenced or not, you should use the create_map_optional method instead.

The map cells are not copied but referenced, so they should outlive the affine_bg_map_ptr to avoid dangling references.