The Battle for Wesnoth  1.15.1+dev
Public Member Functions | Protected Attributes | List of all members
editor::map_fragment Class Reference

A map fragment – a collection of locations and information abut them. More...

#include <map_fragment.hpp>

Public Member Functions

 map_fragment ()
 Create an empty map fragment. More...
 
 map_fragment (const gamemap &map, const std::set< map_location > &area)
 Create a map fragment from the specified locations on the map. More...
 
void add_tile (const gamemap &map, const map_location &loc)
 Add a single location and pull its info from the map. More...
 
void add_tiles (const gamemap &map, const std::set< map_location > &loc)
 Add many locations and pull their info from the map. More...
 
const std::vector< tile_info > & get_items () const
 Get the tile_info vector. More...
 
std::set< map_locationget_area () const
 Get the area covered by this map fragment. More...
 
std::set< map_locationget_offset_area (const map_location &offset) const
 Get the area covered by this map fragment, shifted by an offset. More...
 
void paste_into (gamemap &map, const map_location &loc) const
 Paste the map fragment into the map, treating loc as the (0,0) point (offset). More...
 
void shift (const map_location &offset)
 Shift all tiles in the map fragment by the specified offset. More...
 
map_location center_of_mass () const
 Get the center of the map fragment, mass-wise. More...
 
void center_by_mass ()
 Shift the map fragment so it is roughly centered around the (0,0) point, mass-wise. More...
 
bool empty () const
 
void rotate_60_cw ()
 Rotate the map fragment 60 degrees clockwise around (0,0) More...
 
void rotate_60_ccw ()
 Rotate the map fragment 60 degrees counter-clockwise around (0,0) More...
 
void flip_horizontal ()
 Flip the map fragment horizontally. More...
 
void flip_vertical ()
 Flip the map fragment vertically. More...
 
std::string dump () const
 Debug dump to a string. More...
 

Protected Attributes

std::vector< tile_infoitems_
 The data of this map_fragment. More...
 
std::set< map_locationarea_
 

Detailed Description

A map fragment – a collection of locations and information abut them.

Definition at line 43 of file map_fragment.hpp.

Constructor & Destructor Documentation

◆ map_fragment() [1/2]

editor::map_fragment::map_fragment ( )

Create an empty map fragment.

Definition at line 20 of file map_fragment.cpp.

◆ map_fragment() [2/2]

editor::map_fragment::map_fragment ( const gamemap map,
const std::set< map_location > &  area 
)

Create a map fragment from the specified locations on the map.

Definition at line 26 of file map_fragment.cpp.

References add_tiles().

Member Function Documentation

◆ add_tile()

void editor::map_fragment::add_tile ( const gamemap map,
const map_location loc 
)

Add a single location and pull its info from the map.

Definition at line 33 of file map_fragment.cpp.

References area_, and items_.

Referenced by add_tiles().

◆ add_tiles()

void editor::map_fragment::add_tiles ( const gamemap map,
const std::set< map_location > &  loc 
)

Add many locations and pull their info from the map.

Definition at line 41 of file map_fragment.cpp.

References add_tile().

Referenced by map_fragment().

◆ center_by_mass()

void editor::map_fragment::center_by_mass ( )

Shift the map fragment so it is roughly centered around the (0,0) point, mass-wise.

Definition at line 89 of file map_fragment.cpp.

References area_, center_of_mass(), items_, and shift().

Referenced by flip_horizontal(), and flip_vertical().

◆ center_of_mass()

map_location editor::map_fragment::center_of_mass ( ) const

Get the center of the map fragment, mass-wise.

Definition at line 76 of file map_fragment.cpp.

References items_, map_location::vector_sum_assign(), map_location::x, and map_location::y.

Referenced by center_by_mass().

◆ dump()

std::string editor::map_fragment::dump ( ) const

Debug dump to a string.

Definition at line 163 of file map_fragment.cpp.

References area_, and items_.

◆ empty()

bool editor::map_fragment::empty ( ) const
Returns
true if the map_fragment is empty

Definition at line 158 of file map_fragment.cpp.

References items_.

Referenced by editor::context_manager::clipboard_empty().

◆ flip_horizontal()

void editor::map_fragment::flip_horizontal ( )

Flip the map fragment horizontally.

Definition at line 138 of file map_fragment.cpp.

References center_by_mass(), and items_.

◆ flip_vertical()

void editor::map_fragment::flip_vertical ( )

Flip the map fragment vertically.

Definition at line 146 of file map_fragment.cpp.

References center_by_mass(), and items_.

◆ get_area()

std::set< map_location > editor::map_fragment::get_area ( ) const

Get the area covered by this map fragment.

Definition at line 48 of file map_fragment.cpp.

References area_.

Referenced by rotate_60_ccw(), and rotate_60_cw().

◆ get_items()

const std::vector<tile_info>& editor::map_fragment::get_items ( ) const
inline

Get the tile_info vector.

Definition at line 69 of file map_fragment.hpp.

References editor::tile_info::offset.

◆ get_offset_area()

std::set< map_location > editor::map_fragment::get_offset_area ( const map_location offset) const

Get the area covered by this map fragment, shifted by an offset.

Definition at line 53 of file map_fragment.cpp.

References i, and items_.

◆ paste_into()

void editor::map_fragment::paste_into ( gamemap map,
const map_location loc 
) const

Paste the map fragment into the map, treating loc as the (0,0) point (offset).

Definition at line 62 of file map_fragment.cpp.

References i, items_, and gamemap::set_terrain().

◆ rotate_60_ccw()

void editor::map_fragment::rotate_60_ccw ( )

Rotate the map fragment 60 degrees counter-clockwise around (0,0)

Definition at line 118 of file map_fragment.cpp.

References area_, get_area(), map_location::get_direction(), is_odd(), items_, map_location::NORTH, map_location::NORTH_EAST, utf8::size(), map_location::SOUTH_EAST, and map_location::ZERO().

◆ rotate_60_cw()

void editor::map_fragment::rotate_60_cw ( )

Rotate the map fragment 60 degrees clockwise around (0,0)

Definition at line 98 of file map_fragment.cpp.

References area_, get_area(), map_location::get_direction(), is_odd(), items_, utf8::size(), map_location::SOUTH, map_location::SOUTH_EAST, map_location::SOUTH_WEST, and map_location::ZERO().

◆ shift()

void editor::map_fragment::shift ( const map_location offset)

Shift all tiles in the map fragment by the specified offset.

Definition at line 69 of file map_fragment.cpp.

References items_.

Referenced by center_by_mass().

Member Data Documentation

◆ area_

std::set<map_location> editor::map_fragment::area_
protected

Definition at line 136 of file map_fragment.hpp.

Referenced by add_tile(), center_by_mass(), dump(), get_area(), rotate_60_ccw(), and rotate_60_cw().

◆ items_

std::vector<tile_info> editor::map_fragment::items_
protected

The documentation for this class was generated from the following files: