The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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

editor::map_fragment::map_fragment ( )

Create an empty map fragment.

Definition at line 22 of file map_fragment.cpp.

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

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_, and items_.

Referenced by 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().

Referenced by editor::editor_action_paste::extend(), and map_fragment().

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().

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().

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

Debug dump to a string.

Definition at line 165 of file map_fragment.cpp.

References area_, and items_.

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().

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_.

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_.

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().

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_.

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, and items_.

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

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_, and gamemap::set_terrain().

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

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, map_location::SOUTH_EAST, and map_location::ZERO().

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_, map_location::SOUTH, map_location::SOUTH_EAST, map_location::SOUTH_WEST, and map_location::ZERO().

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

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().

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

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