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_location > | get_area () const |
Get the area covered by this map fragment. More... | |
std::set< map_location > | get_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_info > | items_ |
The data of this map_fragment. More... | |
std::set< map_location > | area_ |
A map fragment – a collection of locations and information abut them.
Definition at line 44 of file map_fragment.hpp.
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().
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().
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().
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.
bool editor::map_fragment::empty | ( | ) | const |
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().
|
inline |
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().
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().
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().
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().
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().
|
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().
|
protected |
The data of this map_fragment.
Definition at line 136 of file map_fragment.hpp.
Referenced by add_tile(), center_by_mass(), center_of_mass(), dump(), empty(), flip_horizontal(), flip_vertical(), get_items(), get_offset_area(), paste_into(), rotate_60_ccw(), rotate_60_cw(), and shift().