Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes

editor::editor_map Class Reference

This class adds extra editor-specific functionality to a normal gamemap. More...

#include <editor_map.hpp>

Inheritance diagram for editor::editor_map:
Inheritance graph
[legend]
Collaboration diagram for editor::editor_map:
Collaboration graph
[legend]

List of all members.

Public Member Functions

std::vector< team > & get_teams ()
 Get the team from the current map context object.
unit_mapget_units ()
 Get the unit map from the current map context object.
const unit_mapget_units () const
tod_managerget_time_manager ()
game_stateget_game_state ()
 editor_map (const config &terrain_cfg, const display &disp)
 Empty map constructor.
 editor_map (const config &terrain_cfg, const config &level, const display &disp)
 Create an editor map from a map data string.
 editor_map (const config &terrain_cfg, const std::string &data, const display &disp)
 editor_map (const config &terrain_cfg, size_t width, size_t height, t_translation::t_terrain filler, const display &disp)
 Create an editor map with the given dimensions and filler terrain.
 editor_map (const gamemap &map, const display &disp)
 Create an editor_map by upgrading an existing gamemap.
 ~editor_map ()
 editor_map destructor
void sanity_check ()
 Debugging aid.
std::set< map_locationget_contiguous_terrain_tiles (const map_location &start) const
 Get a contiguous set of tiles having the same terrain as the starting location.
map_labelsget_map_labels ()
const map_labelsget_map_labels () const
std::set< map_locationset_starting_position_labels (display &disp)
 Set labels for staring positions in the given display object.
bool in_selection (const map_location &loc) const
bool add_to_selection (const map_location &loc)
 Add a location to the selection.
bool remove_from_selection (const map_location &loc)
 Remove a location to the selection.
const std::set< map_location > & selection () const
 Return the selection set.
void clear_selection ()
 Clear the selection.
void invert_selection ()
 Invert the selection, i.e.
void select_all ()
 Select all map hexes.
bool everything_selected () const
void resize (int width, int height, int x_offset, int y_offset, t_translation::t_terrain filler=t_translation::NONE_TERRAIN)
 Resize the map.
editor_map mask_to (const editor_map &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.
bool same_size_as (const gamemap &other) const
 A precondition to several map operations.
void write (config &) const

Static Public Member Functions

static editor_map from_string (const config &terrain_cfg, const std::string &data, const display &disp)
 Wrapper around editor_map(cfg, data) that catches possible exceptions and wraps them in a editor_map_load_exception.

Protected Member Functions

t_translation::t_list clone_column (int x, t_translation::t_terrain filler)
void expand_right (int count, t_translation::t_terrain filler)
void expand_left (int count, t_translation::t_terrain filler)
void expand_top (int count, t_translation::t_terrain filler)
void expand_bottom (int count, t_translation::t_terrain 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_locationselection_
 The selected hexes.

Private Attributes

map_labels labels_
 The labels of this map.
unit_map units_
 TODO.
std::vector< teamteams_
tod_manager tod_manager_
game_state state_

Detailed Description

This class adds extra editor-specific functionality to a normal gamemap.

Definition at line 75 of file editor_map.hpp.


Constructor & Destructor Documentation

editor::editor_map::editor_map ( const config terrain_cfg,
const display disp 
) [explicit]

Empty map constructor.

Definition at line 44 of file editor_map.cpp.

Referenced by from_string().

Here is the caller graph for this function:

editor::editor_map::editor_map ( const config terrain_cfg,
const config level,
const display disp 
)

Create an editor map from a map data string.

Definition at line 55 of file editor_map.cpp.

References unit_map::add(), team::build(), team::change_controller(), config::child_range(), labels_, map_labels::read(), sanity_check(), teams_, and units_.

Here is the call graph for this function:

editor::editor_map::editor_map ( const config terrain_cfg,
const std::string &  data,
const display disp 
)

Definition at line 84 of file editor_map.cpp.

References sanity_check().

Here is the call graph for this function:

editor::editor_map::editor_map ( const config terrain_cfg,
size_t  width,
size_t  height,
t_translation::t_terrain  filler,
const display disp 
)

Create an editor map with the given dimensions and filler terrain.

Definition at line 109 of file editor_map.cpp.

References sanity_check().

Here is the call graph for this function:

editor::editor_map::editor_map ( const gamemap map,
const display disp 
) [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 130 of file editor_map.cpp.

References sanity_check().

Here is the call graph for this function:

editor::editor_map::~editor_map (  ) 

editor_map destructor

Definition at line 142 of file editor_map.cpp.


Member Function Documentation

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)

Returns:
true if the selected hexes set was modified

Definition at line 223 of file editor_map.cpp.

References gamemap::on_board_with_border(), and selection_.

Here is the call graph for this function:

void editor::editor_map::clear_selection (  ) 

Clear the selection.

Definition at line 233 of file editor_map.cpp.

References selection_.

Referenced by editor::editor_action_select_inverse::clone(), and select_all().

Here is the caller graph for this function:

t_translation::t_list editor::editor_map::clone_column ( int  x,
t_translation::t_terrain  filler 
) [protected]

Definition at line 334 of file editor_map.cpp.

References gamemap::h(), t_translation::NONE_TERRAIN, and gamemap::tiles_.

Referenced by expand_left(), and expand_right().

Here is the call graph for this function:

Here is the caller graph for this function:

bool editor::editor_map::everything_selected (  )  const
Returns:
true if the entire map is selected, false otherwise

Definition at line 257 of file editor_map.cpp.

References LOG_ED, selection_, gamemap::total_height(), and gamemap::total_width().

Here is the call graph for this function:

void editor::editor_map::expand_bottom ( int  count,
t_translation::t_terrain  filler 
) [protected]

Definition at line 385 of file editor_map.cpp.

References gamemap::h(), gamemap::h_, t_translation::NONE_TERRAIN, gui2::terrain, gamemap::tiles_, and gamemap::total_height_.

Referenced by resize().

Here is the call graph for this function:

Here is the caller graph for this function:

void editor::editor_map::expand_left ( int  count,
t_translation::t_terrain  filler 
) [protected]

Definition at line 358 of file editor_map.cpp.

References gamemap::clear_border_cache(), clone_column(), gamemap::tiles_, gamemap::total_width_, and gamemap::w_.

Referenced by resize().

Here is the call graph for this function:

Here is the caller graph for this function:

void editor::editor_map::expand_right ( int  count,
t_translation::t_terrain  filler 
) [protected]

Definition at line 348 of file editor_map.cpp.

References clone_column(), gamemap::tiles_, gamemap::total_width_, gamemap::w(), and gamemap::w_.

Referenced by resize().

Here is the call graph for this function:

Here is the caller graph for this function:

void editor::editor_map::expand_top ( int  count,
t_translation::t_terrain  filler 
) [protected]

Definition at line 368 of file editor_map.cpp.

References gamemap::clear_border_cache(), gamemap::h_, t_translation::NONE_TERRAIN, gui2::terrain, gamemap::tiles_, and gamemap::total_height_.

Referenced by resize().

Here is the call graph for this function:

Here is the caller graph for this function:

editor_map editor::editor_map::from_string ( const config terrain_cfg,
const std::string &  data,
const display disp 
) [static]

Wrapper around editor_map(cfg, data) that catches possible exceptions and wraps them in a editor_map_load_exception.

Definition at line 96 of file editor_map.cpp.

References editor_map(), game::error::message, twml_exception::user_message, and editor::wrap_exc().

Referenced by editor::map_context::map_context().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns:
a contiguous set of locations that will always contain at least the starting element

Definition at line 181 of file editor_map.cpp.

References get_adjacent_tiles(), gamemap::get_terrain(), gamemap::on_board_with_border(), and gui2::terrain.

Referenced by editor::mouse_action_select::affected_hexes(), and editor::editor_action_starting_position::clone().

Here is the call graph for this function:

Here is the caller graph for this function:

game_state& editor::editor_map::get_game_state (  )  [inline]

Definition at line 97 of file editor_map.hpp.

References state_.

Referenced by editor::map_context_refresher::refresh().

Here is the caller graph for this function:

map_labels& editor::editor_map::get_map_labels (  )  [inline]
Returns:
the map labels of the map

Definition at line 151 of file editor_map.hpp.

References labels_.

Referenced by editor::mouse_action_map_label::drag_left(), editor::mouse_action_map_label::up_left(), and editor::mouse_action_map_label::up_right().

Here is the caller graph for this function:

const map_labels& editor::editor_map::get_map_labels (  )  const [inline]

Definition at line 154 of file editor_map.hpp.

References labels_.

std::vector<team>& editor::editor_map::get_teams (  )  [inline]

Get the team from the current map context object.

Definition at line 80 of file editor_map.hpp.

References teams_.

Referenced by editor::map_context_refresher::refresh().

Here is the caller graph for this function:

tod_manager& editor::editor_map::get_time_manager (  )  [inline]

Definition at line 93 of file editor_map.hpp.

References tod_manager_.

Referenced by editor::map_context_refresher::refresh().

Here is the caller graph for this function:

unit_map& editor::editor_map::get_units (  )  [inline]

Get the unit map from the current map context object.

Definition at line 85 of file editor_map.hpp.

References units_.

Referenced by editor::mouse_action_unit::click_left(), and editor::map_context_refresher::refresh().

Here is the caller graph for this function:

const unit_map& editor::editor_map::get_units (  )  const [inline]

Definition at line 89 of file editor_map.hpp.

References units_.

bool editor::editor_map::in_selection ( const map_location loc  )  const
Returns:
true when the location is part of the selection, false otherwise

Definition at line 218 of file editor_map.cpp.

References selection_.

void editor::editor_map::invert_selection (  ) 

Invert the selection, i.e.

select all the map hexes that were not selected.

Definition at line 238 of file editor_map.cpp.

References gamemap::h(), selection_, and gamemap::w().

Referenced by editor::editor_action_resize_map::clone(), and select_all().

Here is the call graph for this function:

Here is the caller graph for this function:

editor_map editor::editor_map::mask_to ( const editor_map 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.

Definition at line 311 of file editor_map.cpp.

References _, gamemap::border_size(), t_translation::FOGGED, gamemap::get_terrain(), gamemap::h(), mask, gamemap::set_terrain(), gamemap::w(), map_location::x, and map_location::y.

Referenced by editor::editor_action_shuffle_area::clone().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns:
true if the selected hexes set was modified

Definition at line 228 of file editor_map.cpp.

References selection_.

void editor::editor_map::resize ( int  width,
int  height,
int  x_offset,
int  y_offset,
t_translation::t_terrain  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 263 of file editor_map.cpp.

References expand_bottom(), expand_left(), expand_right(), expand_top(), gamemap::h(), gamemap::MAX_PLAYERS, sanity_check(), shrink_bottom(), shrink_left(), shrink_right(), shrink_top(), gamemap::startingPositions_, gamemap::w(), map_location::x, and map_location::y.

Referenced by editor::editor_action_apply_mask::clone().

Here is the call graph for this function:

Here is the caller graph for this function:

bool editor::editor_map::same_size_as ( const gamemap other  )  const

A precondition to several map operations.

Returns:
true if this map has the same dimensions as the other map

Definition at line 328 of file editor_map.cpp.

References gamemap::h(), and gamemap::w().

Here is the call graph for this function:

void editor::editor_map::sanity_check (  ) 

Debugging aid.

Check if the widths and heights correspond to the actual map data sizes.

Definition at line 146 of file editor_map.cpp.

References gamemap::border_size(), ERR_ED, gamemap::h(), gamemap::h_, gamemap::on_board_with_border(), selection_, gamemap::tiles_, gamemap::total_height(), gamemap::total_width(), gamemap::w(), and gamemap::w_.

Referenced by editor_map(), and resize().

Here is the call graph for this function:

Here is the caller graph for this function:

void editor::editor_map::select_all (  ) 

Select all map hexes.

Definition at line 251 of file editor_map.cpp.

References clear_selection(), and invert_selection().

Referenced by editor::editor_action_select_none::clone().

Here is the call graph for this function:

Here is the caller graph for this function:

const std::set<map_location>& editor::editor_map::selection (  )  const [inline]

Return the selection set.

Definition at line 182 of file editor_map.hpp.

References selection_.

std::set< map_location > editor::editor_map::set_starting_position_labels ( display disp  ) 

Set labels for staring positions in the given display object.

Returns:
the locations where the labels were added

Definition at line 204 of file editor_map.cpp.

References _, display::labels(), map_labels::set_label(), gamemap::startingPositions_, and schema_validation::valid.

Referenced by editor::map_context::set_starting_position_labels().

Here is the call graph for this function:

Here is the caller graph for this function:

void editor::editor_map::shrink_bottom ( int  count  )  [protected]

Definition at line 434 of file editor_map.cpp.

References gamemap::h_, gamemap::tiles_, and gamemap::total_height_.

Referenced by resize().

Here is the caller graph for this function:

void editor::editor_map::shrink_left ( int  count  )  [protected]

Definition at line 412 of file editor_map.cpp.

References gamemap::tiles_, gamemap::total_width_, and gamemap::w_.

Referenced by resize().

Here is the caller graph for this function:

void editor::editor_map::shrink_right ( int  count  )  [protected]

Definition at line 402 of file editor_map.cpp.

References gamemap::tiles_, gamemap::total_width_, and gamemap::w_.

Referenced by resize().

Here is the caller graph for this function:

void editor::editor_map::shrink_top ( int  count  )  [protected]

Definition at line 422 of file editor_map.cpp.

References gamemap::h_, gamemap::tiles_, and gamemap::total_height_.

Referenced by resize().

Here is the caller graph for this function:

void editor::editor_map::write ( config cfg  )  const [virtual]

Reimplemented from gamemap.

Definition at line 446 of file editor_map.cpp.

References config::add_child(), labels_, preferences::map(), and map_labels::write().

Referenced by editor::map_context::save().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

The labels of this map.

Definition at line 248 of file editor_map.hpp.

Referenced by editor_map(), get_map_labels(), and write().

Definition at line 259 of file editor_map.hpp.

Referenced by get_game_state().

std::vector<team> editor::editor_map::teams_ [private]

Definition at line 255 of file editor_map.hpp.

Referenced by editor_map(), and get_teams().

Definition at line 257 of file editor_map.hpp.

Referenced by get_time_manager().

TODO.

Definition at line 253 of file editor_map.hpp.

Referenced by editor_map(), and get_units().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:19:52 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs