The Battle for Wesnoth  1.19.7+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 44 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 22 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 28 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 35 of file map_fragment.cpp.

References area_, items_, and loc.

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 43 of file map_fragment.cpp.

References add_tile(), and loc.

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 91 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 78 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 165 of file map_fragment.cpp.

References area_, items_, and loc.

◆ empty()

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

Definition at line 160 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 140 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 148 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 50 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 70 of file map_fragment.hpp.

References items_.

◆ 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 55 of file map_fragment.cpp.

References i, items_, and loc.

Referenced by editor::mouse_action_paste::affected_hexes(), editor::editor_action_paste::perform(), and editor::editor_action_paste::perform_without_undo().

◆ 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 64 of file map_fragment.cpp.

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

Referenced by editor::editor_action_paste::perform_without_undo().

◆ rotate_60_ccw()

void editor::map_fragment::rotate_60_ccw ( )

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

Definition at line 120 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 100 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 71 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 137 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: