This class wraps around a map to provide a concise interface for the editor to work with. More...
#include <map_context.hpp>
Public Member Functions | |
map_context (const map_context &)=delete | |
map_context & | operator= (const map_context &)=delete |
map_context (const editor_map &map, bool pure_map, const config &schedule, const std::string &addon_id) | |
Create a map context from an existing map. More... | |
map_context (const game_config_view &game_config, const std::string &filename, const std::string &addon_id) | |
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_labels & | get_labels () |
void | replace_schedule (const std::vector< time_of_day > &schedule) |
virtual const unit_map & | units () const override |
Const units accessor. More... | |
unit_map & | units () |
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_map & | map () const override |
Const map accessor. More... | |
editor_map & | map () |
Local non-const overload of map. More... | |
virtual const std::vector< std::string > & | hidden_label_categories () const override |
virtual std::vector< std::string > & | hidden_label_categories () 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) |
void | set_local_starting_time (int time) |
const tod_manager * | get_time_manager () const |
tod_manager * | get_time_manager () |
mp_game_settings & | get_mp_settings () |
game_classification & | get_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) |
void | set_side_setup (editor_team_info &info) |
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_location > | changed_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_id () const |
const std::string & | get_description () const |
const std::string & | get_name () const |
const t_string | get_default_context_name () const |
utils::optional< 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) |
void | save_map () |
Saves the map under the current filename. More... | |
void | save_scenario () |
Saves the scenario under the current filename. More... | |
void | save_schedule (const std::string &schedule_id, const std::string &schedule_name) |
Save custom time of day schedule in the utils directory. More... | |
config | convert_scenario (const config &old_scenario) |
Convert an old-style editor scenario config to a config with a top level [multiplayer] tag. More... | |
void | load_scenario () |
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_action * | last_undo_action () |
editor_action * | last_redo_action () |
const editor_action * | last_undo_action () const |
const version of last_undo_action More... | |
const editor_action * | last_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... | |
void | set_addon_id (const std::string &addon_id) |
overlay_map & | get_overlays () |
virtual const unit_map & | units () const=0 |
virtual const std::vector< team > & | teams () const=0 |
virtual const gamemap & | map () const=0 |
Public Member Functions inherited from display_context | |
const team & | get_team (int side) const |
This getter takes a 1-based side number, not a 0-based team number. More... | |
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 unit * | get_visible_unit (const map_location &loc, const team ¤t_team, bool see_all=false) const |
unit_const_ptr | get_visible_unit_shared_ptr (const map_location &loc, const team ¤t_team, bool see_all=false) const |
can_move_result | unit_can_move (const unit &u) const |
Work out what u can do - this does not check which player's turn is currently active, the result is calculated assuming that the unit's owner is currently active. More... | |
orb_status | unit_orb_status (const unit &u) const |
Returns an enumurated summary of whether this unit can move and/or attack. More... | |
int | village_owner (const map_location &loc) const |
Given the location of a village, will return the 1-based number of the team that currently owns it, and 0 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 |
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_location > | starting_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_location > | changed_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_track > | music_map |
typedef std::map< map_location, std::vector< overlay > > | overlay_map |
Private Attributes | |
std::string | addon_id_ |
utils::optional< config > | previous_cfg_ |
std::string | scenario_id_ |
std::string | scenario_name_ |
std::string | scenario_description_ |
utils::optional< int > | xp_mod_ |
utils::optional< bool > | victory_defeated_ |
bool | random_time_ |
int | active_area_ |
map_labels | labels_ |
unit_map | units_ |
std::vector< team > | teams_ |
std::vector< std::string > | lbl_categories_ |
std::unique_ptr< tod_manager > | tod_manager_ |
mp_game_settings | mp_settings_ |
game_classification | game_classification_ |
music_map | music_tracks_ |
overlay_map | overlays_ |
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 62 of file map_context.hpp.
|
private |
Definition at line 517 of file map_context.hpp.
|
private |
Definition at line 520 of file map_context.hpp.
|
delete |
|
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 60 of file map_context.cpp.
editor::map_context::map_context | ( | const game_config_view & | game_config, |
const std::string & | filename, | ||
const std::string & | addon_id | ||
) |
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 111 of file map_context.cpp.
References _(), add_to_recent_files(), addon_id_, gui2::dialogs::message::auto_close, filesystem::base_name(), filesystem::directory_name(), e, embedded_, filesystem::file_exists(), filename, filename_, editor::editor_map::from_string(), filesystem::get_current_editor_dir(), editor::get_map_location(), filesystem::get_short_wml_path(), filesystem::get_wml_location(), filesystem::is_cfg(), filesystem::is_directory(), filesystem::is_map(), filesystem::is_mask(), load_scenario(), LOG_ED, log_editor, log_scope2, map_, pure_map_, filesystem::read_file(), gui2::show_message(), and editor::start().
|
virtual |
Map context destructor.
Definition at line 297 of file map_context.cpp.
References redo_stack_, and undo_stack_.
void editor::map_context::add_changed_location | ( | const map_location & | loc | ) |
Definition at line 584 of file map_context.cpp.
References changed_locations_, and everything_changed().
Referenced by draw_terrain_actual(), editor::editor_action_select::perform(), editor::editor_action_deselect::perform(), editor::editor_action_paste::perform_without_undo(), editor::editor_action_select::perform_without_undo(), editor::editor_action_deselect::perform_without_undo(), editor::editor_action_unit::perform_without_undo(), editor::editor_action_unit_delete::perform_without_undo(), editor::editor_action_unit_replace::perform_without_undo(), and editor::editor_action_village_delete::perform_without_undo().
void editor::map_context::add_changed_location | ( | const std::set< map_location > & | locs | ) |
Definition at line 591 of file map_context.cpp.
References changed_locations_, and everything_changed().
|
inline |
Definition at line 216 of file map_context.hpp.
References sound::music_track::id(), and music_tracks_.
Referenced by editor::editor_controller::do_execute_command().
void editor::map_context::add_to_recent_files | ( | ) |
Adds the map to the editor's recent files list.
Definition at line 1012 of file map_context.cpp.
References prefs::add_recent_files_entry(), prefs::get(), and get_filename().
Referenced by map_context(), and save_map().
bool editor::map_context::can_redo | ( | ) | const |
Definition at line 1022 of file map_context.cpp.
References redo_stack_.
Referenced by editor::editor_controller::can_execute_command(), and redo().
bool editor::map_context::can_undo | ( | ) | const |
Definition at line 1017 of file map_context.cpp.
References undo_stack_.
Referenced by editor::editor_controller::can_execute_command(), partial_undo(), perform_partial_action(), and undo().
|
inline |
Definition at line 279 of file map_context.hpp.
References changed_locations_.
void editor::map_context::clear_changed_locations | ( | ) |
Definition at line 578 of file map_context.cpp.
References changed_locations_, and everything_changed_.
Referenced by editor::context_manager::refresh_all().
void editor::map_context::clear_modified | ( | ) |
Clear the modified state.
Definition at line 1007 of file map_context.cpp.
References actions_since_save_.
Referenced by save_map(), and save_scenario().
void editor::map_context::clear_starting_position_labels | ( | display & | disp | ) |
Definition at line 608 of file map_context.cpp.
References map_labels::clear_all(), display::labels(), and starting_position_label_locs_.
Referenced by reset_starting_position_labels().
void editor::map_context::clear_undo_redo | ( | ) |
Clear the undo and redo stacks.
Definition at line 1099 of file map_context.cpp.
References redo_stack_, and undo_stack_.
Convert an old-style editor scenario config to a config with a top level [multiplayer] tag.
old_scenario | the original scenario config |
Definition at line 386 of file map_context.cpp.
References config::add_child(), addon_id_, config::all_children_view(), config::append_attributes(), filesystem::base_name(), c, ERR_ED, filesystem::file_exists(), filename_, filesystem::get_current_editor_dir(), filesystem::get_next_filename(), filesystem::map_extension, config::remove_attribute(), and filesystem::write_file().
Referenced by load_scenario().
void editor::map_context::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.
Sets the refresh flags accordingly.
Definition at line 532 of file map_context.cpp.
References draw_terrain_actual(), gamemap::get_terrain_info(), map_, and terrain_type::terrain_with_default_base().
Referenced by editor::editor_action_paint_area::perform_without_undo(), editor::editor_action_fill::perform_without_undo(), and editor::editor_action_shuffle_area::perform_without_undo().
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 566 of file map_context.cpp.
References draw_terrain_actual(), gamemap::get_terrain_info(), map_, and terrain_type::terrain_with_default_base().
void editor::map_context::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.
Definition at line 541 of file map_context.cpp.
References add_changed_location(), t_translation::terrain_code::base, terrain_type_data::BASE, gamemap_base::get_terrain(), LOG_ED, map_, t_translation::NO_LAYER, gamemap_base::on_board_with_border(), terrain_type_data::OVERLAY, and gamemap::set_terrain().
Referenced by draw_terrain().
bool editor::map_context::everything_changed | ( | ) | const |
Definition at line 603 of file map_context.cpp.
References everything_changed_.
Referenced by add_changed_location().
|
inline |
Definition at line 204 of file map_context.hpp.
References active_area_.
Referenced by editor::editor_controller::get_action_state().
|
inline |
Definition at line 197 of file map_context.hpp.
References game_classification_.
Referenced by editor::context_manager::refresh_on_context_change().
const t_string editor::map_context::get_default_context_name | ( | ) | const |
Definition at line 1127 of file map_context.cpp.
References _(), and is_pure_map().
Referenced by editor::context_manager::expand_open_maps_menu().
|
inline |
Definition at line 299 of file map_context.hpp.
References scenario_description_.
Referenced by editor::context_manager::edit_scenario_dialog().
|
inline |
Definition at line 294 of file map_context.hpp.
References filename_.
Referenced by add_to_recent_files(), editor::editor_controller::can_execute_command(), editor::context_manager::expand_open_maps_menu(), editor::context_manager::load_map_dialog(), save_map(), and save_scenario().
|
inline |
Definition at line 298 of file map_context.hpp.
References scenario_id_.
Referenced by editor::context_manager::edit_scenario_dialog().
|
inline |
Definition at line 117 of file map_context.hpp.
References labels_.
Referenced by editor::editor_controller::display_redraw_callback(), editor::editor_controller::do_execute_command(), editor::mouse_action_map_label::drag_end_left(), editor::editor_action_label::perform_without_undo(), editor::editor_action_label_delete::perform_without_undo(), editor::context_manager::refresh_on_context_change(), and editor::mouse_action_map_label::up_left().
|
inline |
Definition at line 194 of file map_context.hpp.
References mp_settings_.
|
inline |
Definition at line 300 of file map_context.hpp.
References scenario_name_.
Referenced by editor::context_manager::edit_scenario_dialog(), and editor::context_manager::expand_open_maps_menu().
|
inline |
Definition at line 525 of file map_context.hpp.
References overlays_.
Referenced by editor::editor_display::get_overlays().
|
inline |
Definition at line 190 of file map_context.hpp.
References tod_manager_.
|
inline |
Definition at line 186 of file map_context.hpp.
References tod_manager_.
Referenced by editor::editor_controller::can_execute_command(), editor::editor_controller::custom_tods_dialog(), editor::editor_controller::do_execute_command(), editor::context_manager::edit_scenario_dialog(), editor::editor_controller::get_action_state(), editor::editor_display::get_time_of_day(), editor::context_manager::get_tod_man(), and editor::context_manager::refresh_on_context_change().
|
inline |
Definition at line 304 of file map_context.hpp.
References xp_mod_.
Referenced by editor::context_manager::edit_scenario_dialog().
|
inlineoverridevirtual |
Implements display_context.
Definition at line 164 of file map_context.hpp.
References lbl_categories_.
|
inlineoverridevirtual |
Implements display_context.
Definition at line 169 of file map_context.hpp.
References lbl_categories_.
|
inline |
Definition at line 309 of file map_context.hpp.
References embedded_.
Referenced by editor::context_manager::expand_open_maps_menu(), save_map(), and save_scenario().
|
inline |
Definition at line 212 of file map_context.hpp.
References music_tracks_.
Referenced by editor::editor_controller::get_action_state().
|
inline |
Definition at line 311 of file map_context.hpp.
References pure_map_.
Referenced by editor::editor_controller::can_execute_command(), editor::context_manager::expand_open_maps_menu(), and get_default_context_name().
editor_action * editor::map_context::last_redo_action | ( | ) |
Definition at line 1032 of file map_context.cpp.
References redo_stack_.
const editor_action * editor::map_context::last_redo_action | ( | ) | const |
const version of last_redo_action
Definition at line 1042 of file map_context.cpp.
References redo_stack_.
editor_action * editor::map_context::last_undo_action | ( | ) |
Definition at line 1027 of file map_context.cpp.
References undo_stack_.
Referenced by editor::editor_controller::mouse_motion(), partial_undo(), and perform_partial_action().
const editor_action * editor::map_context::last_undo_action | ( | ) | const |
const version of last_undo_action
Definition at line 1037 of file map_context.cpp.
References undo_stack_.
void editor::map_context::load_scenario | ( | ) |
Definition at line 451 of file map_context.cpp.
References addon_id_, filesystem::base_name(), config::child_range(), convert_scenario(), unit::create(), ERR_ED, filename_, config::find_child(), editor::editor_map::from_string(), config::get(), filesystem::get_current_editor_dir(), config::has_child(), unit_map::insert(), labels_, config::mandatory_child(), map_, music_tracks_, overlays_, preprocess_file(), previous_cfg_, random_time_, read(), map_labels::read(), filesystem::read_file(), scenario_description_, scenario_id_, scenario_name_, utils::split_set(), teams_, resources::tod_manager, tod_manager_, units_, victory_defeated_, and xp_mod_.
Referenced by map_context().
|
inline |
|
inlineoverridevirtual |
Const map accessor.
Implements display_context.
Definition at line 153 of file map_context.hpp.
References map_.
Referenced by editor::editor_controller::add_area(), editor::editor_controller::allow_mouse_wheel_scroll(), editor::context_manager::apply_mask_dialog(), editor::editor_controller::can_execute_command(), editor::context_manager::create_mask_to_dialog(), editor::editor_controller::export_selection_coords(), editor::editor_controller::get_action_state(), editor::context_manager::new_map_dialog(), editor::context_manager::new_scenario_dialog(), new_side(), editor::editor_action::perform(), editor::editor_action_paste::perform(), editor::editor_action_deselect::perform(), editor::editor_action_paste::perform_without_undo(), editor::editor_action_fill::perform_without_undo(), editor::editor_action_starting_position::perform_without_undo(), editor::editor_action_shuffle_area::perform_without_undo(), editor::editor_action_select::perform_without_undo(), editor::editor_action_deselect::perform_without_undo(), editor::editor_action_select_all::perform_without_undo(), editor::editor_action_select_none::perform_without_undo(), editor::editor_action_select_inverse::perform_without_undo(), editor::editor_controller::save_area(), set_map(), and editor::editor_controller::terrain_description().
virtual const gamemap& display_context::map |
bool editor::map_context::modified | ( | ) | const |
Definition at line 1002 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().
|
inline |
Getter for the labels reset flag.
Set when the labels need to be refreshed.
Definition at line 272 of file map_context.hpp.
References needs_labels_reset_.
|
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 247 of file map_context.hpp.
References needs_reload_.
|
inline |
Getter for the terrain rebuild flag.
Set whenever any terrain has changed.
Definition at line 257 of file map_context.hpp.
References needs_terrain_rebuild_.
|
inline |
Definition at line 109 of file map_context.hpp.
References actions_since_save_, active_area_, and tod_manager_.
Referenced by editor::editor_controller::add_area().
void editor::map_context::new_side | ( | ) |
Adds a new side to the map.
Definition at line 303 of file map_context.cpp.
References actions_since_save_, map(), and teams_.
Referenced by editor::editor_controller::do_execute_command().
|
delete |
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 1075 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().
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 961 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(), and editor::editor_controller::perform_delete().
|
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 1112 of file map_context.cpp.
References trim_stack().
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 981 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().
|
inline |
Definition at line 306 of file map_context.hpp.
References random_time_.
Referenced by editor::context_manager::edit_scenario_dialog().
void editor::map_context::redo | ( | ) |
Re-does a previously undid action, and puts it back in the undo stack.
Definition at line 1061 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().
void editor::map_context::remove_area | ( | int | index | ) |
Definition at line 363 of file map_context.cpp.
References actions_since_save_, active_area_, utf8::index(), and tod_manager_.
Referenced by editor::editor_controller::do_execute_command().
|
inline |
removes the last side from the scenario
Definition at line 100 of file map_context.hpp.
References actions_since_save_, and teams_.
Referenced by editor::editor_controller::do_execute_command().
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 378 of file map_context.cpp.
References actions_since_save_, active_area_, pure_map_, and tod_manager_.
Referenced by editor::editor_controller::do_execute_command().
void editor::map_context::replace_schedule | ( | const std::vector< time_of_day > & | schedule | ) |
Definition at line 370 of file map_context.cpp.
References actions_since_save_, pure_map_, and tod_manager_.
Referenced by editor::editor_controller::custom_tods_dialog(), editor::editor_controller::do_execute_command(), and editor::editor_controller::update_map_schedule().
void editor::map_context::reset_starting_position_labels | ( | display & | disp | ) |
Definition at line 620 of file map_context.cpp.
References clear_starting_position_labels(), set_needs_labels_reset(), and set_starting_position_labels().
Referenced by editor::context_manager::reload_map().
|
inline |
Definition at line 105 of file map_context.hpp.
References active_area_, and tod_manager_.
Referenced by editor::editor_controller::save_area().
void 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 912 of file map_context.cpp.
References _(), add_to_recent_files(), clear_modified(), e, get_filename(), is_embedded(), map_, wfl::msg(), filesystem::read_file(), VGETTEXT, gamemap::write(), and filesystem::write_file().
void 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 868 of file map_context.cpp.
References filesystem::base_name(), clear_modified(), e, filename_, get_filename(), is_embedded(), wfl::msg(), pure_map_, scenario_id_, scenario_name_, to_config(), VGETTEXT, config_writer::write(), and filesystem::write_file().
void editor::map_context::save_schedule | ( | const std::string & | schedule_id, |
const std::string & | schedule_name | ||
) |
Save custom time of day schedule in the utils directory.
Definition at line 802 of file map_context.cpp.
References _(), config::add_child(), addon_id_, config::child_range(), e, filesystem::file_exists(), filesystem::get_current_editor_dir(), wfl::msg(), preprocess_file(), read(), gui2::show_transient_message(), t, tod_manager_, VGETTEXT, config_writer::write(), and filesystem::write_file().
Referenced by editor::editor_controller::custom_tods_dialog().
bool editor::map_context::select_area | ( | int | index | ) |
Select the nth tod area.
index | of the tod area to select. |
Definition at line 527 of file map_context.cpp.
References utf8::index(), map_, editor::editor_map::set_selection(), and tod_manager_.
Referenced by editor::editor_controller::do_execute_command().
|
inline |
Definition at line 208 of file map_context.hpp.
References active_area_, and utf8::index().
Referenced by editor::editor_controller::do_execute_command().
|
inline |
Definition at line 405 of file map_context.hpp.
References addon_id_.
|
inline |
Definition at line 313 of file map_context.hpp.
References embedded_.
void editor::map_context::set_everything_changed | ( | ) |
Definition at line 598 of file map_context.cpp.
References everything_changed_.
Referenced by editor::editor_action_select_all::perform_without_undo(), editor::editor_action_select_none::perform_without_undo(), and editor::editor_action_select_inverse::perform_without_undo().
|
inline |
Definition at line 296 of file map_context.hpp.
References filename_.
void editor::map_context::set_labels | ( | display & | disp | ) |
|
inline |
Definition at line 181 of file map_context.hpp.
References actions_since_save_, active_area_, and tod_manager_.
Referenced by editor::editor_controller::do_execute_command().
void editor::map_context::set_map | ( | const editor_map & | map | ) |
Definition at line 950 of file map_context.cpp.
References gamemap_base::h(), map(), map_, set_needs_reload(), set_needs_terrain_rebuild(), and gamemap_base::w().
|
inline |
Setter for the labels reset flag.
Definition at line 277 of file map_context.hpp.
References needs_labels_reset_.
Referenced by editor::editor_action_starting_position::perform_without_undo(), and reset_starting_position_labels().
|
inline |
Setter for the reload flag.
Definition at line 252 of file map_context.hpp.
References needs_reload_.
Referenced by editor::context_manager::reload_map(), and set_map().
|
inline |
Setter for the terrain rebuild flag.
Definition at line 262 of file map_context.hpp.
References needs_terrain_rebuild_.
Referenced by editor::editor_action_paste::perform_without_undo(), editor::editor_action_paint_area::perform_without_undo(), editor::editor_action_fill::perform_without_undo(), editor::editor_action_shuffle_area::perform_without_undo(), editor::context_manager::refresh_all(), and set_map().
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 | ||
) |
Definition at line 337 of file map_context.cpp.
References actions_since_save_, id, random_time_, scenario_description_, scenario_id_, scenario_name_, tod_manager_, victory_defeated(), victory_defeated_, and xp_mod_.
Referenced by editor::context_manager::edit_scenario_dialog().
void editor::map_context::set_side_setup | ( | editor_team_info & | info | ) |
Definition at line 316 of file map_context.cpp.
References actions_since_save_, lg::info(), utils::split_set(), t, and teams_.
Referenced by editor::context_manager::edit_side_dialog().
void editor::map_context::set_starting_position_labels | ( | display & | disp | ) |
Definition at line 614 of file map_context.cpp.
References map_, editor::editor_map::set_starting_position_labels(), and starting_position_label_locs_.
Referenced by editor::editor_controller::editor_controller(), and reset_starting_position_labels().
void editor::map_context::set_starting_time | ( | int | time | ) |
Definition at line 355 of file map_context.cpp.
References actions_since_save_, pure_map_, and tod_manager_.
Referenced by editor::editor_controller::do_execute_command().
|
inline |
Local non-const overload of teams.
Definition at line 147 of file map_context.hpp.
References teams_.
|
inlineoverridevirtual |
Const teams accessor.
Implements display_context.
Definition at line 141 of file map_context.hpp.
References teams_.
Referenced by editor::editor_controller::can_execute_command(), editor::editor_controller::do_execute_command(), editor::editor_action_village::perform_without_undo(), editor::editor_action_village_delete::perform_without_undo(), and editor::context_manager::refresh_all().
virtual const std::vector<team>& display_context::teams |
config editor::map_context::to_config | ( | ) |
Definition at line 627 of file map_context.cpp.
References config::add_child(), addon_id_, config::append(), team::base_income(), unit::can_recruit(), config::child_count(), config::child_range(), team::controller(), unit::facing(), filesystem::get_current_editor_dir(), unit::get_location(), string_enums::enum_base< Definition >::get_string(), team::gold(), overlay::halo, config::has_child(), team::hidden(), overlay::id, unit::id(), overlay::image, utils::join(), labels_, unit::loyal(), config::mandatory_child(), map_, filesystem::map_extension, music_tracks_, overlay::name, unit::name(), team::no_leader(), overlays_, game_config::path, preprocess_file(), previous_cfg_, random_time_, read(), team::recruits(), config::remove_attribute(), config::remove_children(), scenario_description_, scenario_id_, scenario_name_, team::share_vision(), unit::side(), overlay::submerge, t, overlay::team_name, team::team_name(), teams_, tod_manager_, unit::type_id(), units_, unit::unrenamable(), team::user_team_name(), team::uses_fog(), team::uses_shroud(), victory_defeated_, team::villages(), overlay::visible_in_fog, gamemap::write(), map_location::write(), map_labels::write(), map_location::write_direction(), filesystem::write_file(), and xp_mod_.
Referenced by save_scenario().
|
protected |
Checks if an action stack reached its capacity and removes the front element if so.
Definition at line 1105 of file map_context.cpp.
References max_action_stack_size_.
Referenced by perform_action(), and perform_action_between_stacks().
void editor::map_context::undo | ( | ) |
Un-does the last action, and puts it in the redo stack for a possible redo.
Definition at line 1047 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().
|
inline |
Local non-const overload of units.
Definition at line 135 of file map_context.hpp.
References units_.
|
inlineoverridevirtual |
Const units accessor.
Implements display_context.
Definition at line 129 of file map_context.hpp.
References units_.
Referenced by editor::editor_controller::can_execute_command(), editor::editor_controller::change_unit_id(), editor::editor_controller::do_execute_command(), editor::editor_controller::get_action_state(), editor::editor_action_unit::perform_without_undo(), editor::editor_action_unit_delete::perform_without_undo(), editor::editor_action_unit_replace::perform_without_undo(), editor::editor_action_unit_facing::perform_without_undo(), editor::editor_controller::rename_unit(), and editor::editor_controller::unit_description().
virtual const unit_map& display_context::units |
|
inline |
Definition at line 307 of file map_context.hpp.
References victory_defeated_.
Referenced by editor::context_manager::edit_scenario_dialog(), and set_scenario_setup().
|
protected |
Number of actions performed since the map was saved.
Zero means the map was not modified.
Definition at line 473 of file map_context.hpp.
Referenced by clear_modified(), modified(), new_area(), new_side(), partial_undo(), perform_action(), redo(), remove_area(), remove_side(), replace_local_schedule(), replace_schedule(), set_local_starting_time(), set_scenario_setup(), set_side_setup(), set_starting_time(), and undo().
|
private |
Definition at line 507 of file map_context.hpp.
Referenced by get_active_area(), new_area(), remove_area(), replace_local_schedule(), save_area(), set_active_area(), and set_local_starting_time().
|
private |
Definition at line 499 of file map_context.hpp.
Referenced by convert_scenario(), load_scenario(), map_context(), save_schedule(), set_addon_id(), and to_config().
|
protected |
Definition at line 495 of file map_context.hpp.
Referenced by add_changed_location(), changed_locations(), and clear_changed_locations().
|
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 426 of file map_context.hpp.
Referenced by is_embedded(), map_context(), and set_embedded().
|
protected |
Definition at line 496 of file map_context.hpp.
Referenced by clear_changed_locations(), everything_changed(), and set_everything_changed().
|
protected |
The actual filename of this map.
An empty string indicates a new map.
Definition at line 414 of file map_context.hpp.
Referenced by convert_scenario(), get_filename(), load_scenario(), map_context(), save_scenario(), and set_filename().
|
private |
Definition at line 515 of file map_context.hpp.
Referenced by get_classification().
|
private |
Definition at line 509 of file map_context.hpp.
Referenced by get_labels(), load_scenario(), and to_config().
|
private |
Definition at line 512 of file map_context.hpp.
Referenced by hidden_label_categories().
|
protected |
The map object of this map_context.
Definition at line 436 of file map_context.hpp.
Referenced by draw_terrain(), draw_terrain_actual(), load_scenario(), map(), map_context(), save_map(), select_area(), set_map(), set_starting_position_labels(), and to_config().
|
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 420 of file map_context.hpp.
|
staticprotected |
Action stack (i.e.
undo and redo) maximum size
Definition at line 468 of file map_context.hpp.
Referenced by trim_stack().
|
private |
Definition at line 514 of file map_context.hpp.
Referenced by get_mp_settings().
|
private |
Definition at line 518 of file map_context.hpp.
Referenced by add_to_playlist(), is_in_playlist(), load_scenario(), and to_config().
|
protected |
Refresh flag indicating the labels in the map have changed.
Definition at line 493 of file map_context.hpp.
Referenced by needs_labels_reset(), and set_needs_labels_reset().
|
protected |
Refresh flag indicating the map in this context should be completely reloaded by the display.
Definition at line 483 of file map_context.hpp.
Referenced by needs_reload(), and set_needs_reload().
|
protected |
Refresh flag indicating the terrain in the map has changed and requires a rebuild.
Definition at line 488 of file map_context.hpp.
Referenced by needs_terrain_rebuild(), and set_needs_terrain_rebuild().
|
private |
Definition at line 521 of file map_context.hpp.
Referenced by get_overlays(), load_scenario(), and to_config().
|
private |
Definition at line 500 of file map_context.hpp.
Referenced by load_scenario(), and to_config().
|
protected |
Whether the map context refers to a file containing only the pure map data.
Definition at line 431 of file map_context.hpp.
Referenced by is_pure_map(), map_context(), replace_local_schedule(), replace_schedule(), save_scenario(), and set_starting_time().
|
private |
Definition at line 505 of file map_context.hpp.
Referenced by load_scenario(), random_start_time(), set_scenario_setup(), and to_config().
|
protected |
The redo stack.
Definition at line 463 of file map_context.hpp.
Referenced by can_redo(), clear_undo_redo(), last_redo_action(), partial_undo(), perform_action(), perform_partial_action(), redo(), undo(), and ~map_context().
|
private |
Definition at line 501 of file map_context.hpp.
Referenced by get_description(), load_scenario(), set_scenario_setup(), and to_config().
|
private |
Definition at line 501 of file map_context.hpp.
Referenced by get_id(), load_scenario(), save_scenario(), set_scenario_setup(), and to_config().
|
private |
Definition at line 501 of file map_context.hpp.
Referenced by get_name(), load_scenario(), save_scenario(), set_scenario_setup(), and to_config().
|
protected |
Cache of set starting position labels.
Necessary for removing them.
Definition at line 478 of file map_context.hpp.
Referenced by clear_starting_position_labels(), and set_starting_position_labels().
|
private |
Definition at line 511 of file map_context.hpp.
Referenced by load_scenario(), new_side(), remove_side(), set_side_setup(), teams(), and to_config().
|
private |
Definition at line 513 of file map_context.hpp.
Referenced by get_time_manager(), load_scenario(), new_area(), remove_area(), replace_local_schedule(), replace_schedule(), save_area(), save_schedule(), select_area(), set_local_starting_time(), set_scenario_setup(), set_starting_time(), and to_config().
|
protected |
The undo stack.
A double-ended queue 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.
Definition at line 458 of file map_context.hpp.
Referenced by can_undo(), clear_undo_redo(), last_undo_action(), partial_undo(), perform_action(), redo(), undo(), and ~map_context().
|
private |
Definition at line 510 of file map_context.hpp.
Referenced by load_scenario(), to_config(), and units().
|
private |
Definition at line 504 of file map_context.hpp.
Referenced by load_scenario(), set_scenario_setup(), to_config(), and victory_defeated().
|
private |
Definition at line 503 of file map_context.hpp.
Referenced by get_xp_mod(), load_scenario(), set_scenario_setup(), and to_config().