This class adds extra editor-specific functionality to a normal gamemap. More...
#include <editor_map.hpp>
Public Member Functions | |
editor_map () | |
Empty map constructor. More... | |
editor_map (const std::string &data) | |
Create an editor map from a map data string. More... | |
editor_map (std::size_t width, std::size_t height, const t_translation::terrain_code &filler) | |
Create an editor map with the given dimensions and filler terrain. More... | |
editor_map (const gamemap &map) | |
Create an editor_map by upgrading an existing gamemap. More... | |
~editor_map () | |
editor_map destructor More... | |
void | sanity_check () |
Debugging aid. More... | |
std::set< map_location > | get_contiguous_terrain_tiles (const map_location &start) const |
Get a contiguous set of tiles having the same terrain as the starting location. More... | |
std::set< map_location > | set_starting_position_labels (display &disp) |
Set labels for staring positions in the given display object. More... | |
bool | in_selection (const map_location &loc) const |
bool | add_to_selection (const map_location &loc) |
Add a location to the selection. More... | |
bool | remove_from_selection (const map_location &loc) |
Remove a location to the selection. More... | |
bool | set_selection (const std::set< map_location > &area) |
Select the given area. More... | |
const std::set< map_location > & | selection () const |
Return the selection set. More... | |
void | clear_selection () |
Clear the selection. More... | |
void | invert_selection () |
Invert the selection, i.e. More... | |
void | select_all () |
Select all map hexes. More... | |
bool | everything_selected () const |
void | resize (int width, int height, int x_offset, int y_offset, const t_translation::terrain_code &filler=t_translation::NONE_TERRAIN) |
Resize the map. More... | |
gamemap | mask_to (const gamemap &target) const |
A sort-of diff operation returning a mask that, when applied to the current editor_map, will transform it into the target map. More... | |
bool | same_size_as (const gamemap &other) const |
A precondition to several map operations. More... | |
![]() | |
const t_translation::ter_list & | underlying_mvt_terrain (const map_location &loc) const |
const t_translation::ter_list & | underlying_def_terrain (const map_location &loc) const |
const t_translation::ter_list & | underlying_union_terrain (const map_location &loc) const |
std::string | get_terrain_string (const map_location &loc) const |
std::string | get_terrain_editor_string (const map_location &loc) const |
bool | is_village (const map_location &loc) const |
int | gives_healing (const map_location &loc) const |
bool | is_castle (const map_location &loc) const |
bool | is_keep (const map_location &loc) const |
const t_translation::ter_list & | underlying_mvt_terrain (const t_translation::terrain_code &terrain) const |
const t_translation::ter_list & | underlying_def_terrain (const t_translation::terrain_code &terrain) const |
const t_translation::ter_list & | underlying_union_terrain (const t_translation::terrain_code &terrain) const |
std::string | get_terrain_string (const t_translation::terrain_code &terrain) const |
std::string | get_terrain_editor_string (const t_translation::terrain_code &terrain) const |
std::string | get_underlying_terrain_string (const t_translation::terrain_code &terrain) const |
bool | is_village (const t_translation::terrain_code &terrain) const |
int | gives_healing (const t_translation::terrain_code &terrain) const |
bool | is_castle (const t_translation::terrain_code &terrain) const |
bool | is_keep (const t_translation::terrain_code &terrain) const |
const terrain_type & | get_terrain_info (const t_translation::terrain_code &terrain) const |
const std::shared_ptr< terrain_type_data > & | tdata () const |
gamemap (const std::string &data) | |
Loads a map. More... | |
virtual | ~gamemap () |
void | read (const std::string &data, const bool allow_invalid=true) |
std::string | write () const |
void | overlay (const gamemap &m, map_location loc, const std::vector< overlay_rule > &rules=std::vector< overlay_rule >(), bool is_odd=false, bool ignore_special_locations=false) |
Overlays another map onto this one at the given position. More... | |
int | w () const |
Effective map width, in hexes. More... | |
int | h () const |
Effective map height, in hexes. More... | |
int | border_size () const |
Size of the map border. More... | |
int | total_width () const |
Real width of the map, including borders. More... | |
int | total_height () const |
Real height of the map, including borders. More... | |
const t_translation::terrain_code | operator[] (const map_location &loc) const |
t_translation::terrain_code | get_terrain (const map_location &loc) const |
Looks up terrain at a particular location. More... | |
void | write_terrain (const map_location &loc, config &cfg) const |
Writes the terrain at loc to cfg. More... | |
void | set_starting_position (int side, const map_location &loc) |
Manipulate starting positions of the different sides. More... | |
map_location | starting_position (int side) const |
void | set_special_location (const std::string &id, const map_location &loc) |
map_location | special_location (const std::string &id) const |
const std::string * | is_starting_position (const map_location &loc) const |
returns the side number of the side starting at position loc, 0 if no such side exists. More... | |
int | num_valid_starting_positions () const |
bool | on_board (const map_location &loc) const |
Tell if a location is on the map. More... | |
bool | on_board_with_border (const map_location &loc) const |
bool | empty () const |
Tell if the map is of 0 size. More... | |
const std::vector< map_location > & | villages () const |
Return a list of the locations of villages on the map. More... | |
const terrain_type & | get_terrain_info (const map_location &loc) const |
Shortcut to get_terrain_info(get_terrain(loc)). More... | |
const t_translation::ter_list & | get_terrain_list () const |
Gets the list of terrains. More... | |
void | set_terrain (const map_location &loc, const t_translation::terrain_code &terrain, const terrain_type_data::merge_mode mode=terrain_type_data::BOTH, bool replace_if_failed=false) |
Clobbers over the terrain at location 'loc', with the given terrain. More... | |
std::vector< map_location > | parse_location_range (const std::string &xvals, const std::string &yvals, bool with_border=false) const |
Parses ranges of locations into a vector of locations, using this map's dimensions as bounds. More... | |
const starting_positions & | special_locations () const |
template<typename F > | |
void | for_each_loc (const F &f) const |
template<typename F > | |
void | for_each_walkable_loc (const F &f) const |
Static Public Member Functions | |
static editor_map | from_string (const std::string &data) |
Wrapper around editor_map(cfg, data) that catches possible exceptions and wraps them in a editor_map_load_exception. More... | |
![]() | |
static void | overlay_impl (const t_translation::ter_map &m1, t_translation::starting_positions &m1_st, const t_translation::ter_map &m2, const t_translation::starting_positions &m2_st, std::function< void(const map_location &, const t_translation::terrain_code &, terrain_type_data::merge_mode, bool)> set_terrain, map_location loc, const std::vector< overlay_rule > &rules, bool is_odd, bool ignore_special_locations) |
Protected Member Functions | |
void | expand_right (int count, const t_translation::terrain_code &filler) |
void | expand_left (int count, const t_translation::terrain_code &filler) |
void | expand_top (int count, const t_translation::terrain_code &filler) |
void | expand_bottom (int count, const t_translation::terrain_code &filler) |
void | shrink_right (int count) |
void | shrink_left (int count) |
void | shrink_top (int count) |
void | shrink_bottom (int count) |
Protected Attributes | |
std::set< map_location > | selection_ |
The selected hexes. More... | |
![]() | |
t_translation::ter_map | tiles_ |
starting_positions | starting_positions_ |
std::vector< map_location > | villages_ |
int | w_ |
Sizes of the map area. More... | |
int | h_ |
Additional Inherited Members | |
![]() | |
enum | { MAX_PLAYERS = 9 } |
Maximum number of players supported. More... | |
using | starting_positions = t_translation::starting_positions |
![]() | |
static const int | default_border = 1 |
The default border style for a map. More... | |
This class adds extra editor-specific functionality to a normal gamemap.
Definition at line 69 of file editor_map.hpp.
editor::editor_map::editor_map | ( | ) |
editor::editor_map::editor_map | ( | const std::string & | data | ) |
Create an editor map from a map data string.
Definition at line 46 of file editor_map.cpp.
References sanity_check().
editor::editor_map::editor_map | ( | std::size_t | width, |
std::size_t | height, | ||
const t_translation::terrain_code & | filler | ||
) |
Create an editor map with the given dimensions and filler terrain.
Definition at line 66 of file editor_map.cpp.
References sanity_check().
|
explicit |
Create an editor_map by upgrading an existing gamemap.
The map data is copied. Marked "explicit" to avoid potentially harmful automatic conversions.
Definition at line 73 of file editor_map.cpp.
References sanity_check().
editor::editor_map::~editor_map | ( | ) |
editor_map destructor
Definition at line 80 of file editor_map.cpp.
bool editor::editor_map::add_to_selection | ( | const map_location & | loc | ) |
Add a location to the selection.
The location should be valid (i.e. on the map)
Definition at line 161 of file editor_map.cpp.
References gamemap::on_board_with_border(), and selection_.
Referenced by editor::editor_action_select::perform_without_undo(), and set_selection().
void editor::editor_map::clear_selection | ( | ) |
Clear the selection.
Definition at line 181 of file editor_map.cpp.
References selection_.
Referenced by editor::editor_action_select_none::perform_without_undo(), select_all(), and set_selection().
bool editor::editor_map::everything_selected | ( | ) | const |
Definition at line 205 of file editor_map.cpp.
References LOG_ED, selection_, gamemap::total_height(), and gamemap::total_width().
Referenced by editor::editor_controller::can_execute_command(), and editor::editor_controller::get_action_state().
|
protected |
Definition at line 350 of file editor_map.cpp.
References t_translation::ter_map::get(), t_translation::ter_map::h, gamemap::h_, t_translation::NONE_TERRAIN, gamemap::tiles_, and t_translation::ter_map::w.
Referenced by resize().
|
protected |
Definition at line 316 of file editor_map.cpp.
References t_translation::ter_map::get(), t_translation::ter_map::h, t_translation::NONE_TERRAIN, gamemap::tiles_, t_translation::ter_map::w, and gamemap::w_.
Referenced by resize().
|
protected |
Definition at line 299 of file editor_map.cpp.
References t_translation::ter_map::get(), t_translation::ter_map::h, t_translation::NONE_TERRAIN, gamemap::tiles_, t_translation::ter_map::w, and gamemap::w_.
Referenced by resize().
|
protected |
Definition at line 333 of file editor_map.cpp.
References t_translation::ter_map::get(), t_translation::ter_map::h, gamemap::h_, t_translation::NONE_TERRAIN, gamemap::tiles_, and t_translation::ter_map::w.
Referenced by resize().
|
static |
Wrapper around editor_map(cfg, data) that catches possible exceptions and wraps them in a editor_map_load_exception.
Definition at line 53 of file editor_map.cpp.
References e, editor_map(), game::error::message, wml_exception::user_message, and editor::wrap_exc().
Referenced by editor::map_context::load_scenario(), and editor::map_context::map_context().
std::set< map_location > editor::editor_map::get_contiguous_terrain_tiles | ( | const map_location & | start | ) | const |
Get a contiguous set of tiles having the same terrain as the starting location.
Useful for flood fill or magic wand selection
Definition at line 113 of file editor_map.cpp.
References get_adjacent_tiles(), gamemap::get_terrain(), and gamemap::on_board_with_border().
Referenced by editor::mouse_action_select::affected_hexes(), editor::mouse_action_fill::affected_hexes(), and editor::editor_action_fill::perform_without_undo().
bool editor::editor_map::in_selection | ( | const map_location & | loc | ) | const |
Definition at line 156 of file editor_map.cpp.
References selection_.
Referenced by editor::editor_action_deselect::perform().
void editor::editor_map::invert_selection | ( | ) |
Invert the selection, i.e.
select all the map hexes that were not selected.
Definition at line 186 of file editor_map.cpp.
References gamemap::h(), selection_, and gamemap::w().
Referenced by editor::editor_action_select_inverse::perform_without_undo(), and select_all().
A sort-of diff operation returning a mask that, when applied to the current editor_map, will transform it into the target map.
Definition at line 276 of file editor_map.cpp.
References _(), gamemap::border_size(), t_translation::FOGGED, gamemap::get_terrain(), gamemap::h(), gamemap::set_terrain(), gamemap::w(), map_location::x, and map_location::y.
bool editor::editor_map::remove_from_selection | ( | const map_location & | loc | ) |
Remove a location to the selection.
The location does not actually have to be selected
Definition at line 176 of file editor_map.cpp.
References selection_.
Referenced by editor::editor_action_deselect::perform_without_undo().
void editor::editor_map::resize | ( | int | width, |
int | height, | ||
int | x_offset, | ||
int | y_offset, | ||
const t_translation::terrain_code & | filler = t_translation::NONE_TERRAIN |
||
) |
Resize the map.
If the filler is NONE, the border terrain will be copied when expanding, otherwise the filler terrain will be inserted there
Definition at line 211 of file editor_map.cpp.
References map_location::add(), expand_bottom(), expand_left(), expand_right(), expand_top(), gamemap::for_each_loc(), gamemap::h(), gamemap::is_village(), sanity_check(), shrink_bottom(), shrink_left(), shrink_right(), shrink_top(), gamemap::starting_positions_, gamemap::villages_, and gamemap::w().
bool editor::editor_map::same_size_as | ( | const gamemap & | other | ) | const |
A precondition to several map operations.
Definition at line 293 of file editor_map.cpp.
References gamemap::h(), and gamemap::w().
void editor::editor_map::sanity_check | ( | ) |
Debugging aid.
Check if the widths and heights correspond to the actual map data sizes.
Definition at line 84 of file editor_map.cpp.
References gamemap::border_size(), ERR_ED, t_translation::ter_map::h, gamemap::h(), gamemap::h_, gamemap::on_board_with_border(), selection_, gamemap::tiles_, gamemap::total_height(), gamemap::total_width(), t_translation::ter_map::w, gamemap::w(), and gamemap::w_.
Referenced by editor_map(), and resize().
void editor::editor_map::select_all | ( | ) |
Select all map hexes.
Definition at line 199 of file editor_map.cpp.
References clear_selection(), and invert_selection().
Referenced by editor::editor_action_select_all::perform_without_undo().
|
inline |
Return the selection set.
Definition at line 148 of file editor_map.hpp.
References t_translation::NONE_TERRAIN.
Referenced by editor::editor_controller::add_area(), editor::editor_controller::can_execute_command(), editor::context_manager::expand_areas_menu(), editor::editor_controller::export_selection_coords(), editor::editor_controller::get_action_state(), and editor::editor_controller::save_area().
bool editor::editor_map::set_selection | ( | const std::set< map_location > & | area | ) |
Select the given area.
area | to select. |
Definition at line 166 of file editor_map.cpp.
References add_to_selection(), and clear_selection().
Referenced by editor::map_context::select_area().
std::set< map_location > editor::editor_map::set_starting_position_labels | ( | display & | disp | ) |
Set labels for staring positions in the given display object.
Definition at line 134 of file editor_map.cpp.
References c, display::labels(), map_labels::set_label(), gamemap::starting_positions_, and VGETTEXT.
Referenced by editor::map_context::set_starting_position_labels().
|
protected |
Definition at line 412 of file editor_map.cpp.
References t_translation::ter_map::get(), t_translation::ter_map::h, gamemap::h_, gamemap::tiles_, and t_translation::ter_map::w.
Referenced by resize().
|
protected |
Definition at line 382 of file editor_map.cpp.
References t_translation::ter_map::get(), t_translation::ter_map::h, gamemap::tiles_, t_translation::ter_map::w, and gamemap::w_.
Referenced by resize().
|
protected |
Definition at line 367 of file editor_map.cpp.
References t_translation::ter_map::get(), t_translation::ter_map::h, gamemap::tiles_, t_translation::ter_map::w, and gamemap::w_.
Referenced by resize().
|
protected |
Definition at line 397 of file editor_map.cpp.
References t_translation::ter_map::get(), t_translation::ter_map::h, gamemap::h_, gamemap::tiles_, and t_translation::ter_map::w.
Referenced by resize().
|
protected |
The selected hexes.
Definition at line 203 of file editor_map.hpp.
Referenced by add_to_selection(), clear_selection(), everything_selected(), in_selection(), invert_selection(), remove_from_selection(), and sanity_check().