The Battle for Wesnoth  1.15.0-dev
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Types | Private Attributes | List of all members
editor::map_context Class Reference

This class wraps around a map to provide a concise interface for the editor to work with. More...

#include <map_context.hpp>

Inheritance diagram for editor::map_context:
Inheritance graph

Public Member Functions

 map_context (const map_context &)=delete
 
map_contextoperator= (const map_context &)=delete
 
 map_context (const editor_map &map, bool pure_map, const config &schedule)
 Create a map context from an existing map. More...
 
 map_context (const config &game_config, const std::string &filename)
 Create map_context from a map file. More...
 
virtual ~map_context ()
 Map context destructor. More...
 
bool select_area (int index)
 Select the nth tod area. More...
 
void new_side ()
 Adds a new side to the map. More...
 
void remove_side ()
 removes the last side from the scenario More...
 
void save_area (const std::set< map_location > &area)
 
void new_area (const std::set< map_location > &area)
 
void remove_area (int index)
 
map_labelsget_labels ()
 
void replace_schedule (const std::vector< time_of_day > &schedule)
 
virtual const unit_mapunits () const override
 Const units accessor. More...
 
unit_mapunits ()
 Local non-const overload of units. More...
 
virtual const std::vector< team > & teams () const override
 Const teams accessor. More...
 
std::vector< team > & teams ()
 Local non-const overload of teams. More...
 
virtual const editor_mapmap () const override
 Const map accessor. More...
 
editor_mapmap ()
 Local non-const overload of map. More...
 
virtual const std::vector< std::string > & hidden_label_categories () const override
 
void replace_local_schedule (const std::vector< time_of_day > &schedule)
 Replace the [time]s of the currently active area. More...
 
void set_starting_time (int time)
 TODO. More...
 
void set_local_starting_time (int time)
 TODO. More...
 
const tod_managerget_time_manager () const
 
tod_managerget_time_manager ()
 
mp_game_settingsget_mp_settings ()
 
game_classificationget_classification ()
 
int get_active_area () const
 
void set_active_area (int index)
 
bool is_in_playlist (std::string track_id)
 
void add_to_playlist (const sound::music_track &track)
 
void draw_terrain (const t_translation::terrain_code &terrain, const map_location &loc, bool one_layer_only=false)
 Draw a terrain on a single location on the map. More...
 
void draw_terrain_actual (const t_translation::terrain_code &terrain, const map_location &loc, bool one_layer_only=false)
 Actual drawing function used by both overloaded variants of draw_terrain. More...
 
void draw_terrain (const t_translation::terrain_code &terrain, const std::set< map_location > &locs, bool one_layer_only=false)
 Draw a terrain on a set of locations on the map. More...
 
bool needs_reload () const
 Getter for the reload flag. More...
 
void set_needs_reload (bool value=true)
 Setter for the reload flag. More...
 
bool needs_terrain_rebuild () const
 Getter for the terrain rebuild flag. More...
 
void set_needs_terrain_rebuild (bool value=true)
 Setter for the terrain rebuild flag. More...
 
void set_scenario_setup (const std::string &id, const std::string &name, const std::string &description, int turns, int xp_mod, bool victory_defeated, bool random_time)
 TODO. More...
 
void set_side_setup (editor_team_info &info)
 TODO. More...
 
bool needs_labels_reset () const
 Getter for the labels reset flag. More...
 
void set_needs_labels_reset (bool value=true)
 Setter for the labels reset flag. More...
 
const std::set< map_locationchanged_locations () const
 
void clear_changed_locations ()
 
void add_changed_location (const map_location &loc)
 
void add_changed_location (const std::set< map_location > &locs)
 
void set_everything_changed ()
 
bool everything_changed () const
 
void set_labels (display &disp)
 
void clear_starting_position_labels (display &disp)
 
void set_starting_position_labels (display &disp)
 
void reset_starting_position_labels (display &disp)
 
const std::string & get_filename () const
 
void set_filename (const std::string &fn)
 
const std::string & get_map_data_key () const
 
const std::string & get_id () const
 
const std::string & get_description () const
 
const std::string & get_name () const
 
const t_string get_default_context_name () const
 
int get_xp_mod () const
 
bool random_start_time () const
 
bool victory_defeated () const
 
bool is_embedded () const
 
bool is_pure_map () const
 
void set_embedded (bool v)
 
bool save_map ()
 Saves the map under the current filename. More...
 
bool save_scenario ()
 Saves the scenario under the current filename. More...
 
void load_scenario (const config &game_config)
 
config to_config ()
 
void set_map (const editor_map &map)
 
void perform_action (const editor_action &action)
 Performs an action (thus modifying the map). More...
 
void perform_partial_action (const editor_action &action)
 Performs a partial action, assumes that the top undo action has been modified to maintain coherent state of the undo stacks, and so a new undo action is not created. More...
 
bool modified () const
 
void clear_modified ()
 Clear the modified state. More...
 
void add_to_recent_files ()
 Adds the map to the editor's recent files list. More...
 
bool can_undo () const
 
bool can_redo () const
 
editor_actionlast_undo_action ()
 
editor_actionlast_redo_action ()
 
const editor_actionlast_undo_action () const
 const version of last_undo_action More...
 
const editor_actionlast_redo_action () const
 const version of last_redo_action More...
 
void undo ()
 Un-does the last action, and puts it in the redo stack for a possible redo. More...
 
void redo ()
 Re-does a previously undid action, and puts it back in the undo stack. More...
 
void partial_undo ()
 Un-does a single step from a undo action chain. More...
 
void clear_undo_redo ()
 Clear the undo and redo stacks. More...
 
overlay_mapget_overlays ()
 
- Public Member Functions inherited from display_context
std::vector< std::string > & hidden_label_categories_ref ()
 
const teamget_team (int side) const
 
template<typename T = void>
bool has_team (int side) const
 
bool would_be_discovered (const map_location &loc, int side_num, bool see_all=true)
 Given a location and a side number, indicates whether an invisible unit of that side at that location would be revealed (perhaps ambushed), based on what team side_num can see. More...
 
const unitget_visible_unit (const map_location &loc, const team &current_team, bool see_all=false) const
 
bool unit_can_move (const unit &u) const
 Will return true iff the unit u has any possible moves it can do (including attacking etc). More...
 
int village_owner (const map_location &loc) const
 Given the location of a village, will return the 0-based index of the team that currently owns it, and -1 if it is unowned. More...
 
int side_units (int side_num) const
 Returns the number of units of the side side_num. More...
 
int side_units_cost (int side_num) const
 Returns the total cost of units of side side_num. More...
 
int side_upkeep (int side_num) const
 
team_data calculate_team_data (const class team &tm) const
 
bool is_observer () const
 Check if we are an observer in this game. More...
 
virtual ~display_context ()
 

Protected Member Functions

void trim_stack (action_stack &stack)
 Checks if an action stack reached its capacity and removes the front element if so. More...
 
void perform_action_between_stacks (action_stack &from, action_stack &to)
 Perform an action at the back of one stack, and then move it to the back of the other stack. More...
 

Protected Attributes

std::string filename_
 The actual filename of this map. More...
 
std::string map_data_key_
 When a scenario file is loaded, the referenced map is loaded instead. More...
 
bool embedded_
 Whether the map context refers to a map embedded in a scenario file. More...
 
bool pure_map_
 Whether the map context refers to a file containing only the pure map data. More...
 
editor_map map_
 The map object of this map_context. More...
 
action_stack undo_stack_
 The undo stack. More...
 
action_stack redo_stack_
 The redo stack. More...
 
int actions_since_save_
 Number of actions performed since the map was saved. More...
 
std::set< map_locationstarting_position_label_locs_
 Cache of set starting position labels. More...
 
bool needs_reload_
 Refresh flag indicating the map in this context should be completely reloaded by the display. More...
 
bool needs_terrain_rebuild_
 Refresh flag indicating the terrain in the map has changed and requires a rebuild. More...
 
bool needs_labels_reset_
 Refresh flag indicating the labels in the map have changed. More...
 
std::set< map_locationchanged_locations_
 
bool everything_changed_
 

Static Protected Attributes

static const std::size_t max_action_stack_size_ = 100
 Action stack (i.e. More...
 

Private Types

typedef std::map< std::string, sound::music_trackmusic_map
 
typedef std::multimap< map_location, overlayoverlay_map
 

Private Attributes

std::string scenario_id_
 
std::string scenario_name_
 
std::string scenario_description_
 
int xp_mod_
 
bool victory_defeated_
 
bool random_time_
 
int active_area_
 
map_labels labels_
 
unit_map units_
 
std::vector< teamteams_
 
std::vector< std::string > lbl_categories_
 
std::unique_ptr< tod_managertod_manager_
 
mp_game_settings mp_settings_
 
game_classification game_classification_
 
music_map music_tracks_
 
overlay_map overlays_
 

Detailed Description

This class wraps around a map to provide a concise interface for the editor to work with.

The actual map object can change rapidly (be assigned to), the map context persists data (like the undo stacks) in this case. The functionality is here, not in editor_controller as e.g. the undo stack is part of the map, not the editor as a whole. This might allow many maps to be open at the same time.

Definition at line 55 of file map_context.hpp.

Member Typedef Documentation

◆ music_map

typedef std::map<std::string, sound::music_track> editor::map_context::music_map
private

Definition at line 502 of file map_context.hpp.

◆ overlay_map

typedef std::multimap<map_location, overlay> editor::map_context::overlay_map
private

Definition at line 505 of file map_context.hpp.

Constructor & Destructor Documentation

◆ map_context() [1/3]

editor::map_context::map_context ( const map_context )
delete

◆ map_context() [2/3]

editor::map_context::map_context ( const editor_map map,
bool  pure_map,
const config schedule 
)
explicit

Create a map context from an existing map.

The filename is set to be empty, indicating a new map. Marked "explicit" to avoid automatic conversions.

Definition at line 55 of file map_context.cpp.

◆ map_context() [3/3]

editor::map_context::map_context ( const config game_config,
const std::string &  filename 
)

Create map_context from a map file.

If the map cannot be loaded, an exception will be thrown and the object will not be constructed. If the map file is a scenario, the map specified in its map_data key will be loaded, and the stored filename updated accordingly. Maps embedded inside scenarios do not change the filename, but set the "embedded" flag instead.

Definition at line 87 of file map_context.cpp.

References _(), add_to_recent_files(), filesystem::directory_name(), e, embedded_, filesystem::file_exists(), filename_, editor::editor_map::from_string(), filesystem::get_short_wml_path(), filesystem::get_wml_location(), filesystem::is_directory(), load_scenario(), LOG_ED, log_editor, log_scope2, map_, game::error::message, pure_map_, and filesystem::read_file().

◆ ~map_context()

editor::map_context::~map_context ( )
virtual

Map context destructor.

Definition at line 223 of file map_context.cpp.

References redo_stack_, and undo_stack_.

Member Function Documentation

◆ add_changed_location() [1/2]

void editor::map_context::add_changed_location ( const map_location loc)

◆ add_changed_location() [2/2]

void editor::map_context::add_changed_location ( const std::set< map_location > &  locs)

Definition at line 433 of file map_context.cpp.

References changed_locations_, and everything_changed().

◆ add_to_playlist()

void editor::map_context::add_to_playlist ( const sound::music_track track)
inline

Definition at line 211 of file map_context.hpp.

References sound::music_track::id().

Referenced by editor::editor_controller::do_execute_command().

◆ add_to_recent_files()

void editor::map_context::add_to_recent_files ( )

Adds the map to the editor's recent files list.

Definition at line 717 of file map_context.cpp.

References preferences::editor::add_recent_files_entry(), and get_filename().

Referenced by map_context(), and save_map().

◆ can_redo()

bool editor::map_context::can_redo ( ) const
Returns
true when redo can be performed, false otherwise

Definition at line 727 of file map_context.cpp.

References redo_stack_.

Referenced by editor::editor_controller::can_execute_command(), and redo().

◆ can_undo()

bool editor::map_context::can_undo ( ) const
Returns
true when undo can be performed, false otherwise

Definition at line 722 of file map_context.cpp.

References undo_stack_.

Referenced by editor::editor_controller::can_execute_command(), partial_undo(), perform_partial_action(), and undo().

◆ changed_locations()

const std::set<map_location> editor::map_context::changed_locations ( ) const
inline

Definition at line 280 of file map_context.hpp.

Referenced by editor::context_manager::refresh_after_action().

◆ clear_changed_locations()

void editor::map_context::clear_changed_locations ( )

◆ clear_modified()

void editor::map_context::clear_modified ( )

Clear the modified state.

Definition at line 712 of file map_context.cpp.

References actions_since_save_.

Referenced by save_map(), and save_scenario().

◆ clear_starting_position_labels()

void editor::map_context::clear_starting_position_labels ( display disp)

◆ clear_undo_redo()

void editor::map_context::clear_undo_redo ( )

Clear the undo and redo stacks.

Definition at line 804 of file map_context.cpp.

References redo_stack_, and undo_stack_.

◆ draw_terrain() [1/2]

void editor::map_context::draw_terrain ( const t_translation::terrain_code terrain,
const map_location loc,
bool  one_layer_only = false 
)

◆ draw_terrain() [2/2]

void editor::map_context::draw_terrain ( const t_translation::terrain_code terrain,
const std::set< map_location > &  locs,
bool  one_layer_only = false 
)

Draw a terrain on a set of locations on the map.

Sets the refresh flags accordingly.

Definition at line 408 of file map_context.cpp.

References draw_terrain_actual(), gamemap::get_terrain_info(), map_, and terrain_type::terrain_with_default_base().

◆ draw_terrain_actual()

void editor::map_context::draw_terrain_actual ( const t_translation::terrain_code terrain,
const map_location loc,
bool  one_layer_only = false 
)

◆ everything_changed()

bool editor::map_context::everything_changed ( ) const

Definition at line 445 of file map_context.cpp.

References everything_changed_.

Referenced by add_changed_location().

◆ get_active_area()

int editor::map_context::get_active_area ( ) const
inline
Returns
the index of the currently active area.

Definition at line 199 of file map_context.hpp.

Referenced by editor::context_manager::expand_areas_menu(), editor::editor_controller::get_action_state(), and editor::context_manager::rename_area_dialog().

◆ get_classification()

game_classification& editor::map_context::get_classification ( )
inline

Definition at line 191 of file map_context.hpp.

Referenced by editor::context_manager::refresh_on_context_change().

◆ get_default_context_name()

const t_string editor::map_context::get_default_context_name ( ) const

◆ get_description()

const std::string& editor::map_context::get_description ( ) const
inline

Definition at line 302 of file map_context.hpp.

Referenced by editor::context_manager::edit_scenario_dialog().

◆ get_filename()

const std::string& editor::map_context::get_filename ( ) const
inline

◆ get_id()

const std::string& editor::map_context::get_id ( ) const
inline

Definition at line 301 of file map_context.hpp.

Referenced by editor::context_manager::edit_scenario_dialog().

◆ get_labels()

map_labels& editor::map_context::get_labels ( )
inline

◆ get_map_data_key()

const std::string& editor::map_context::get_map_data_key ( ) const
inline

Definition at line 299 of file map_context.hpp.

Referenced by editor::context_manager::load_map().

◆ get_mp_settings()

mp_game_settings& editor::map_context::get_mp_settings ( )
inline

Definition at line 188 of file map_context.hpp.

◆ get_name()

const std::string& editor::map_context::get_name ( ) const
inline

◆ get_overlays()

overlay_map& editor::map_context::get_overlays ( )
inline

Definition at line 510 of file map_context.hpp.

Referenced by editor::editor_display::get_overlays().

◆ get_time_manager() [1/2]

const tod_manager* editor::map_context::get_time_manager ( ) const
inline

◆ get_time_manager() [2/2]

tod_manager* editor::map_context::get_time_manager ( )
inline

Definition at line 184 of file map_context.hpp.

◆ get_xp_mod()

int editor::map_context::get_xp_mod ( ) const
inline

Definition at line 307 of file map_context.hpp.

Referenced by editor::context_manager::edit_scenario_dialog().

◆ hidden_label_categories()

virtual const std::vector<std::string>& editor::map_context::hidden_label_categories ( ) const
inlineoverridevirtual

Implements display_context.

Definition at line 157 of file map_context.hpp.

◆ is_embedded()

bool editor::map_context::is_embedded ( ) const
inline

◆ is_in_playlist()

bool editor::map_context::is_in_playlist ( std::string  track_id)
inline

Definition at line 207 of file map_context.hpp.

Referenced by editor::editor_controller::get_action_state().

◆ is_pure_map()

bool editor::map_context::is_pure_map ( ) const
inline

◆ last_redo_action() [1/2]

editor_action * editor::map_context::last_redo_action ( )
Returns
a pointer to the last redo action or nullptr if the undo stack is empty

Definition at line 737 of file map_context.cpp.

References redo_stack_.

◆ last_redo_action() [2/2]

const editor_action * editor::map_context::last_redo_action ( ) const

const version of last_redo_action

Definition at line 747 of file map_context.cpp.

References redo_stack_.

◆ last_undo_action() [1/2]

editor_action * editor::map_context::last_undo_action ( )
Returns
a pointer to the last undo action or nullptr if the undo stack is empty

Definition at line 732 of file map_context.cpp.

References undo_stack_.

Referenced by editor::editor_controller::mouse_motion(), partial_undo(), and perform_partial_action().

◆ last_undo_action() [2/2]

const editor_action * editor::map_context::last_undo_action ( ) const

const version of last_undo_action

Definition at line 742 of file map_context.cpp.

References undo_stack_.

◆ load_scenario()

void editor::map_context::load_scenario ( const config game_config)

◆ map() [1/2]

virtual const editor_map& editor::map_context::map ( ) const
inlineoverridevirtual

◆ map() [2/2]

editor_map& editor::map_context::map ( )
inline

Local non-const overload of map.

Definition at line 152 of file map_context.hpp.

◆ modified()

bool editor::map_context::modified ( ) const
Returns
whether the map was modified since the last save

Definition at line 707 of file map_context.cpp.

References actions_since_save_.

Referenced by editor::editor_controller::can_execute_command(), and editor::context_manager::expand_open_maps_menu().

◆ needs_labels_reset()

bool editor::map_context::needs_labels_reset ( ) const
inline

Getter for the labels reset flag.

Set when the labels need to be refreshed.

Definition at line 273 of file map_context.hpp.

◆ needs_reload()

bool editor::map_context::needs_reload ( ) const
inline

Getter for the reload flag.

Reload is the highest level of required refreshing, set when the map size has changed or the map was reassigned.

Definition at line 242 of file map_context.hpp.

◆ needs_terrain_rebuild()

bool editor::map_context::needs_terrain_rebuild ( ) const
inline

Getter for the terrain rebuild flag.

Set whenever any terrain has changed.

Definition at line 252 of file map_context.hpp.

◆ new_area()

void editor::map_context::new_area ( const std::set< map_location > &  area)
inline

Definition at line 102 of file map_context.hpp.

Referenced by editor::editor_controller::add_area().

◆ new_side()

void editor::map_context::new_side ( )

Adds a new side to the map.

Definition at line 229 of file map_context.cpp.

References actions_since_save_, map(), and teams_.

Referenced by editor::editor_controller::do_execute_command(), and editor::context_manager::new_scenario().

◆ operator=()

map_context& editor::map_context::operator= ( const map_context )
delete

◆ partial_undo()

void editor::map_context::partial_undo ( )

Un-does a single step from a undo action chain.

The action is separated from the chain and it's undo (the redo) is added as a stand-alone action to the redo stack. Precondition: the last undo action has to actually be an action chain.

Definition at line 780 of file map_context.cpp.

References actions_since_save_, can_undo(), editor::editor_action_chain::empty(), last_undo_action(), editor::editor_action_chain::pop_first_action(), redo_stack_, and undo_stack_.

Referenced by editor::editor_controller::do_execute_command().

◆ perform_action()

void editor::map_context::perform_action ( const editor_action action)

Performs an action (thus modifying the map).

An appropriate undo action is added to the undo stack. The redo stack is cleared. Note that this may throw, use caution when calling this with a dereferenced pointer that you own (i.e. use a smart pointer).

Definition at line 666 of file map_context.cpp.

References actions_since_save_, editor::editor_action::get_id(), editor::editor_action::get_instance_count(), editor::editor_action::get_name(), LOG_ED, editor::editor_action::perform(), redo_stack_, trim_stack(), undo(), and undo_stack_.

Referenced by editor::editor_controller::mouse_motion(), editor::editor_controller::perform_delete(), and editor::context_manager::perform_refresh().

◆ perform_action_between_stacks()

void editor::map_context::perform_action_between_stacks ( action_stack from,
action_stack to 
)
protected

Perform an action at the back of one stack, and then move it to the back of the other stack.

This is the implementation of both undo and redo which only differ in the direction.

Definition at line 817 of file map_context.cpp.

References editor::editor_action::perform(), and trim_stack().

Referenced by redo(), and undo().

◆ perform_partial_action()

void editor::map_context::perform_partial_action ( const editor_action action)

Performs a partial action, assumes that the top undo action has been modified to maintain coherent state of the undo stacks, and so a new undo action is not created.

Definition at line 686 of file map_context.cpp.

References can_undo(), editor::editor_action::get_id(), editor::editor_action::get_instance_count(), editor::editor_action::get_name(), last_undo_action(), LOG_ED, editor::editor_action::perform(), editor::editor_action_chain::prepend_action(), redo_stack_, and undo().

Referenced by editor::editor_controller::mouse_motion().

◆ random_start_time()

bool editor::map_context::random_start_time ( ) const
inline

Definition at line 309 of file map_context.hpp.

Referenced by editor::context_manager::edit_scenario_dialog().

◆ redo()

void editor::map_context::redo ( )

Re-does a previously undid action, and puts it back in the undo stack.

Definition at line 766 of file map_context.cpp.

References actions_since_save_, can_redo(), LOG_ED, perform_action_between_stacks(), redo_stack_, undo_stack_, and WRN_ED.

Referenced by editor::editor_controller::redo().

◆ remove_area()

void editor::map_context::remove_area ( int  index)

◆ remove_side()

void editor::map_context::remove_side ( )
inline

removes the last side from the scenario

Definition at line 93 of file map_context.hpp.

Referenced by editor::editor_controller::do_execute_command().

◆ replace_local_schedule()

void editor::map_context::replace_local_schedule ( const std::vector< time_of_day > &  schedule)

Replace the [time]s of the currently active area.

Definition at line 306 of file map_context.cpp.

References actions_since_save_, active_area_, pure_map_, and tod_manager_.

Referenced by editor::editor_controller::do_execute_command().

◆ replace_schedule()

void editor::map_context::replace_schedule ( const std::vector< time_of_day > &  schedule)

◆ reset_starting_position_labels()

void editor::map_context::reset_starting_position_labels ( display disp)

◆ save_area()

void editor::map_context::save_area ( const std::set< map_location > &  area)
inline

Definition at line 98 of file map_context.hpp.

Referenced by editor::editor_controller::save_area().

◆ save_map()

bool editor::map_context::save_map ( )

Saves the map under the current filename.

Filename must be valid. May throw an exception on failure.

Definition at line 613 of file map_context.cpp.

References _(), add_to_recent_files(), clear_modified(), e, get_filename(), is_embedded(), map_, wfl::msg(), filesystem::read_file(), VGETTEXT, game::error::what(), gamemap::write(), and filesystem::write_file().

Referenced by editor::context_manager::write_map().

◆ save_scenario()

bool editor::map_context::save_scenario ( )

Saves the scenario under the current filename.

Filename must be valid. May throw an exception on failure.

Definition at line 576 of file map_context.cpp.

References filesystem::base_name(), clear_modified(), e, filename_, get_filename(), is_embedded(), wfl::msg(), scenario_id_, scenario_name_, to_config(), VGETTEXT, game::error::what(), config_writer::write(), and filesystem::write_file().

Referenced by editor::context_manager::write_scenario().

◆ select_area()

bool editor::map_context::select_area ( int  index)

Select the nth tod area.

Parameters
indexof the tod area to select.

Definition at line 369 of file map_context.cpp.

References map_, editor::editor_map::set_selection(), and tod_manager_.

Referenced by editor::editor_controller::do_execute_command().

◆ set_active_area()

void editor::map_context::set_active_area ( int  index)
inline

Definition at line 203 of file map_context.hpp.

References utf8::index().

Referenced by editor::editor_controller::do_execute_command().

◆ set_embedded()

void editor::map_context::set_embedded ( bool  v)
inline

◆ set_everything_changed()

void editor::map_context::set_everything_changed ( )

◆ set_filename()

void editor::map_context::set_filename ( const std::string &  fn)
inline

◆ set_labels()

void editor::map_context::set_labels ( display disp)

◆ set_local_starting_time()

void editor::map_context::set_local_starting_time ( int  time)
inline

TODO.

Definition at line 175 of file map_context.hpp.

Referenced by editor::editor_controller::do_execute_command().

◆ set_map()

void editor::map_context::set_map ( const editor_map map)

◆ set_needs_labels_reset()

void editor::map_context::set_needs_labels_reset ( bool  value = true)
inline

◆ set_needs_reload()

void editor::map_context::set_needs_reload ( bool  value = true)
inline

Setter for the reload flag.

Definition at line 247 of file map_context.hpp.

Referenced by editor::context_manager::reload_map(), and set_map().

◆ set_needs_terrain_rebuild()

void editor::map_context::set_needs_terrain_rebuild ( bool  value = true)
inline

◆ set_scenario_setup()

void editor::map_context::set_scenario_setup ( const std::string &  id,
const std::string &  name,
const std::string &  description,
int  turns,
int  xp_mod,
bool  victory_defeated,
bool  random_time 
)

◆ set_side_setup()

void editor::map_context::set_side_setup ( editor_team_info info)

◆ set_starting_position_labels()

void editor::map_context::set_starting_position_labels ( display disp)

◆ set_starting_time()

void editor::map_context::set_starting_time ( int  time)

TODO.

Definition at line 283 of file map_context.cpp.

References actions_since_save_, pure_map_, and tod_manager_.

Referenced by editor::editor_controller::do_execute_command().

◆ teams() [1/2]

virtual const std::vector<team>& editor::map_context::teams ( ) const
inlineoverridevirtual

◆ teams() [2/2]

std::vector<team>& editor::map_context::teams ( )
inline

Local non-const overload of teams.

Definition at line 140 of file map_context.hpp.

◆ to_config()

config editor::map_context::to_config ( )

◆ trim_stack()

void editor::map_context::trim_stack ( action_stack stack)
protected

Checks if an action stack reached its capacity and removes the front element if so.

Definition at line 810 of file map_context.cpp.

References max_action_stack_size_.

Referenced by perform_action(), and perform_action_between_stacks().

◆ undo()

void editor::map_context::undo ( )

Un-does the last action, and puts it in the redo stack for a possible redo.

Definition at line 752 of file map_context.cpp.

References actions_since_save_, can_undo(), LOG_ED, perform_action_between_stacks(), redo_stack_, undo_stack_, and WRN_ED.

Referenced by perform_action(), perform_partial_action(), and editor::editor_controller::undo().

◆ units() [1/2]

virtual const unit_map& editor::map_context::units ( ) const
inlineoverridevirtual

◆ units() [2/2]

unit_map& editor::map_context::units ( )
inline

Local non-const overload of units.

Definition at line 128 of file map_context.hpp.

◆ victory_defeated()

bool editor::map_context::victory_defeated ( ) const
inline

Member Data Documentation

◆ actions_since_save_

int editor::map_context::actions_since_save_
protected

Number of actions performed since the map was saved.

Zero means the map was not modified.

Definition at line 460 of file map_context.hpp.

Referenced by clear_modified(), modified(), new_side(), partial_undo(), perform_action(), redo(), remove_area(), replace_local_schedule(), replace_schedule(), set_scenario_setup(), set_side_setup(), set_starting_time(), and undo().

◆ active_area_

int editor::map_context::active_area_
private

Definition at line 492 of file map_context.hpp.

Referenced by remove_area(), and replace_local_schedule().

◆ changed_locations_

std::set<map_location> editor::map_context::changed_locations_
protected

Definition at line 482 of file map_context.hpp.

Referenced by add_changed_location(), and clear_changed_locations().

◆ embedded_

bool editor::map_context::embedded_
protected

Whether the map context refers to a map embedded in a scenario file.

This distinction is important in order to avoid overwriting the scenario.

Definition at line 413 of file map_context.hpp.

Referenced by map_context().

◆ everything_changed_

bool editor::map_context::everything_changed_
protected

◆ filename_

std::string editor::map_context::filename_
protected

The actual filename of this map.

An empty string indicates a new map.

Definition at line 401 of file map_context.hpp.

Referenced by load_scenario(), map_context(), and save_scenario().

◆ game_classification_

game_classification editor::map_context::game_classification_
private

Definition at line 500 of file map_context.hpp.

◆ labels_

map_labels editor::map_context::labels_
private

Definition at line 494 of file map_context.hpp.

Referenced by load_scenario(), and to_config().

◆ lbl_categories_

std::vector<std::string> editor::map_context::lbl_categories_
private

Definition at line 497 of file map_context.hpp.

◆ map_

editor_map editor::map_context::map_
protected

◆ map_data_key_

std::string editor::map_context::map_data_key_
protected

When a scenario file is loaded, the referenced map is loaded instead.

The verbatim form of the reference is kept here.

Definition at line 407 of file map_context.hpp.

◆ max_action_stack_size_

const std::size_t editor::map_context::max_action_stack_size_ = 100
staticprotected

Action stack (i.e.

undo and redo) maximum size

Definition at line 455 of file map_context.hpp.

Referenced by editor::editor_team_info::editor_team_info(), and trim_stack().

◆ mp_settings_

mp_game_settings editor::map_context::mp_settings_
private

Definition at line 499 of file map_context.hpp.

◆ music_tracks_

music_map editor::map_context::music_tracks_
private

Definition at line 503 of file map_context.hpp.

Referenced by load_scenario(), and to_config().

◆ needs_labels_reset_

bool editor::map_context::needs_labels_reset_
protected

Refresh flag indicating the labels in the map have changed.

Definition at line 480 of file map_context.hpp.

◆ needs_reload_

bool editor::map_context::needs_reload_
protected

Refresh flag indicating the map in this context should be completely reloaded by the display.

Definition at line 470 of file map_context.hpp.

◆ needs_terrain_rebuild_

bool editor::map_context::needs_terrain_rebuild_
protected

Refresh flag indicating the terrain in the map has changed and requires a rebuild.

Definition at line 475 of file map_context.hpp.

◆ overlays_

overlay_map editor::map_context::overlays_
private

Definition at line 506 of file map_context.hpp.

Referenced by load_scenario(), and to_config().

◆ pure_map_

bool editor::map_context::pure_map_
protected

Whether the map context refers to a file containing only the pure map data.

Definition at line 418 of file map_context.hpp.

Referenced by map_context(), replace_local_schedule(), replace_schedule(), and set_starting_time().

◆ random_time_

bool editor::map_context::random_time_
private

Definition at line 490 of file map_context.hpp.

Referenced by load_scenario(), set_scenario_setup(), and to_config().

◆ redo_stack_

action_stack editor::map_context::redo_stack_
protected

◆ scenario_description_

std::string editor::map_context::scenario_description_
private

Definition at line 487 of file map_context.hpp.

Referenced by load_scenario(), set_scenario_setup(), and to_config().

◆ scenario_id_

std::string editor::map_context::scenario_id_
private

Definition at line 487 of file map_context.hpp.

Referenced by load_scenario(), save_scenario(), set_scenario_setup(), and to_config().

◆ scenario_name_

std::string editor::map_context::scenario_name_
private

Definition at line 487 of file map_context.hpp.

Referenced by load_scenario(), save_scenario(), set_scenario_setup(), and to_config().

◆ starting_position_label_locs_

std::set<map_location> editor::map_context::starting_position_label_locs_
protected

Cache of set starting position labels.

Necessary for removing them.

Definition at line 465 of file map_context.hpp.

Referenced by clear_starting_position_labels(), and set_starting_position_labels().

◆ teams_

std::vector<team> editor::map_context::teams_
private

Definition at line 496 of file map_context.hpp.

Referenced by load_scenario(), new_side(), set_side_setup(), and to_config().

◆ tod_manager_

std::unique_ptr<tod_manager> editor::map_context::tod_manager_
private

◆ undo_stack_

action_stack editor::map_context::undo_stack_
protected

The undo stack.

A double-ended queues due to the need to add items to one end, and remove from both when performing the undo or when trimming the size. This container owns all contents, i.e. no action in the stack shall be deleted, and unless otherwise noted the contents could be deleted at an time during normal operation of the stack. To work on an action, either remove it from the container or make a copy. Actions are inserted at the back of the container and disappear from the front when the capacity is exceeded.

Todo:
Use boost's pointer-owning container?

Definition at line 445 of file map_context.hpp.

Referenced by can_undo(), clear_undo_redo(), last_undo_action(), partial_undo(), perform_action(), redo(), undo(), and ~map_context().

◆ units_

unit_map editor::map_context::units_
private

Definition at line 495 of file map_context.hpp.

Referenced by load_scenario(), and to_config().

◆ victory_defeated_

bool editor::map_context::victory_defeated_
private

Definition at line 490 of file map_context.hpp.

Referenced by load_scenario(), set_scenario_setup(), and to_config().

◆ xp_mod_

int editor::map_context::xp_mod_
private

Definition at line 489 of file map_context.hpp.

Referenced by load_scenario(), set_scenario_setup(), and to_config().


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