map_editor Namespace Reference


Classes

class  map_editor
 A map editor. Receives SDL events and can execute hotkey commands. More...
struct  size_specs
 Size specifications for the map editor. More...
struct  terrain_group
 Stores the info about the data in editor-groups.cfg in a nice format. More...
class  terrain_palette
 Palette where the terrain to be drawn can be selected. More...
class  brush_bar
 A bar where the brush is drawn. More...
class  map_undo_action
 A saved action that may be undone. More...

Typedefs

typedef std::deque
< map_undo_action
map_undo_list
typedef std::vector< std::pair
< gamemap::location,
t_translation::t_terrain > > 
terrain_log

Enumerations

enum  FLIP_AXIS { NO_FLIP, FLIP_X, FLIP_Y }

Functions

bool check_data (std::string &data, std::string &filename, bool &from_scenario, config &game_cfg)
 map_editor (editor_display &gui, editormap &map, config &theme, config &game_config)
void load_tooltips ()
 ~map_editor ()
void handle_event (const SDL_Event &event)
void handle_keyboard_event (const SDL_KeyboardEvent &event, const int, const int)
void handle_mouse_button_event (const SDL_MouseButtonEvent &event, const int mousex, const int mousey)
void left_click (const gamemap::location hex_clicked)
void right_click (const gamemap::location hex_clicked)
void change_language ()
 Change the language (effectively reload the editor).
void edit_save_as ()
void perform_set_starting_pos ()
void edit_set_start_pos ()
void perform_flood_fill (const t_translation::t_terrain fill_with)
void edit_flood_fill ()
void edit_save_map ()
void edit_quit ()
void edit_new_map ()
void edit_load_map ()
void edit_fill_selection ()
void edit_cut ()
void edit_copy ()
void perform_paste ()
void edit_paste ()
void edit_rotate_selection ()
void edit_revert ()
void edit_resize ()
void edit_flip ()
void edit_select_all ()
void edit_draw ()
void edit_refresh ()
void edit_update ()
void edit_auto_update ()
hotkey::ACTION_STATE get_action_state (hotkey::HOTKEY_COMMAND command) const
void copy_buffer (map_buffer &buffer, const std::set< gamemap::location > &locs, const gamemap::location &origin)
void paste_buffer (const map_buffer &buffer, const gamemap::location &loc, map_undo_action &undo_action)
void insert_selection_in_clipboard ()
void perform_fill_hexes (std::set< gamemap::location > &fill_hexes, const t_translation::t_terrain terrain, map_undo_action &undo_action)
void perform_selection_move ()
bool can_execute_command (hotkey::HOTKEY_COMMAND command, int) const
void toggle_grid ()
void save_undo_action (const map_undo_action &action)
void undo ()
void redo ()
void preferences ()
void redraw_everything ()
void highlight_selected_hexes (const bool clear_old)
void clear_highlighted_hexes_in_gui ()
void set_mouseover_overlay ()
bool changed_since_save () const
void set_starting_position (const int player, const gamemap::location loc)
void set_abort (const ABORT_MODE abort)
void set_file_to_save_as (const std::string filename, bool from_scenario)
void left_button_down (const int mousex, const int mousey)
void draw_on_mouseover_hexes (const t_translation::t_terrain terrain, const bool one_layer_only)
void draw_terrain (const t_translation::t_terrain terrain, const std::vector< gamemap::location > &hexes, const bool one_layer_only)
void terrain_changed (const gamemap::location &hex)
void right_button_down (const int, const int)
void middle_button_down (const int mousex, const int mousey)
bool confirm_exit_and_save ()
bool save_map (const std::string fn, const bool display_confirmation)
bool verify_filename (const std::string &filename, bool show_error) const
void show_menu (const std::vector< std::string > &items, const int xloc, const int yloc, const bool)
void execute_command (const hotkey::HOTKEY_COMMAND command)
void recalculate_starting_pos_labels ()
void update_mouse_over_hexes (const gamemap::location mouse_over_hex)
void left_button_func_changed (const LEFT_BUTTON_FUNC func)
void update_l_button_palette ()
std::string get_action_name (const LEFT_BUTTON_FUNC func) const
bool is_left_button_func_menu (const theme::menu &menu) const
void main_loop ()
bool confirm_modification_disposal (display &disp)
 Notify the user that the map is changed and ask if the user wants to proceed.
std::string new_map_dialog (display &disp, const t_translation::t_terrain fill_terrain, const bool confirmation_needed, const config &gconfig)
 Show a dialog to create new map.
void preferences_dialog (display &disp, config &prefs)
 Show a dialog where the user may set the preferences used in the editor.
bool resize_dialog (display &disp, unsigned &width, unsigned &height, int &x_offset, int &y_offset, bool &do_expand)
 Show a dialog asking for the new size of the map.
FLIP_AXIS flip_dialog (display &disp)
void adjust_sizes (const display &disp, size_specs &sizes)
 Adjust the internal size specifications to fit the display.
static bool is_invalid_terrain (t_translation::t_terrain c)
void add_undo_action (const map_undo_action &action)
 Add an undo action to the undo stack.
bool exist_undo_actions ()
 Return true if there exist any undo actions in the undo stack.
bool exist_redo_actions ()
 Return true if there exist any redo actions in the redo stack.
map_undo_action pop_undo_action ()
 Remove, store in the redo stack and return the last undo action stored.
map_undo_action pop_redo_action ()
 Remove, store in the undo stack and return the last redo action stored.
void clear_undo_actions ()
 Clear all stored information about performed actions.
std::vector< gamemap::locationget_tiles (const gamemap &map, const gamemap::location &a, const unsigned int radius)
 Return the tiles that are within radius from the location.
void flood_fill (gamemap &map, const gamemap::location &start_loc, const t_translation::t_terrain fill_with, terrain_log *log=NULL)
 Flood fill the map with the terrain fill_with starting from the location start_loc.
std::set< gamemap::locationget_component (const gamemap &map, const gamemap::location &start_loc)
 Return the area that would be flood filled if a flood fill was requested.
std::string resize_map (editormap &map, const unsigned new_w, const unsigned new_h, const int off_x, const int off_y, const bool do_expand, const t_translation::t_terrain fill_with)
 Return the string representation of the map after it has been resized to new_w X new_h.
std::string flip_map (editormap &map, const FLIP_AXIS axis)
 Return the string representation of the map after it has been flipped around the axis.
bool valid_mapdata (const std::string &data, const config &cfg)
 Return true if the data is valid to create a map with, othwerwise false.
std::string new_map (const size_t width, const size_t height, const t_translation::t_terrain filler)
 Returns a string representating a new empty map of width by height of the terrain filler.


Typedef Documentation

Definition at line 99 of file editor_undo.hpp.

Definition at line 171 of file map_manip.hpp.


Enumeration Type Documentation

Enumerator:
NO_FLIP 
FLIP_X 
FLIP_Y 

Definition at line 29 of file map_manip.hpp.


Function Documentation

void map_editor::map_editor::add_undo_action ( const map_undo_action &  action  ) 

Add an undo action to the undo stack.

Resize the stack if it gets larger than the maximum size. Add an operation to the number done since save. If keep_selection is true, it indicates that the selection has not changed and the currently selected terrain should be kept if this action is redone/undone. Also clear the redo stack.

Definition at line 121 of file editor_undo.cpp.

References redo_stack, undo_limit, and undo_stack.

Referenced by save_undo_action().

void map_editor::map_editor::adjust_sizes ( const display disp,
size_specs &  sizes 
)

bool map_editor::can_execute_command ( hotkey::HOTKEY_COMMAND  command,
int   
) const

void map_editor::change_language (  ) 

bool map_editor::changed_since_save (  )  const

Definition at line 1108 of file editor.cpp.

Referenced by confirm_exit_and_save(), edit_load_map(), and edit_new_map().

bool map_editor::check_data ( std::string &  data,
std::string &  filename,
bool &  from_scenario,
config game_cfg 
)

void map_editor::clear_highlighted_hexes_in_gui (  ) 

Definition at line 1053 of file editor.cpp.

Referenced by highlight_selected_hexes(), and left_click().

void map_editor::map_editor::clear_undo_actions (  ) 

Clear all stored information about performed actions.

Definition at line 159 of file editor_undo.cpp.

References redo_stack, and undo_stack.

Referenced by edit_load_map(), and edit_new_map().

bool map_editor::confirm_exit_and_save (  ) 

Definition at line 1297 of file editor.cpp.

References _, changed_since_save(), save_map(), and gui::YES_NO.

Referenced by main_loop().

bool map_editor::map_editor::confirm_modification_disposal ( display disp  ) 

Notify the user that the map is changed and ask if the user wants to proceed.

Return true if yes is answered.

Definition at line 50 of file editor_dialogs.cpp.

References _, and gui::OK_CANCEL.

Referenced by edit_load_map(), and new_map_dialog().

void map_editor::copy_buffer ( map_buffer &  buffer,
const std::set< gamemap::location > &  locs,
const gamemap::location origin 
)

void map_editor::draw_on_mouseover_hexes ( const t_translation::t_terrain  terrain,
const bool  one_layer_only 
)

Definition at line 1212 of file editor.cpp.

References draw_terrain(), get_tiles(), map_, and gamemap::on_board().

Referenced by left_button_down(), left_click(), and right_button_down().

void map_editor::draw_terrain ( const t_translation::t_terrain  terrain,
const std::vector< gamemap::location > &  hexes,
const bool  one_layer_only 
)

void map_editor::edit_auto_update (  ) 

Definition at line 806 of file editor.cpp.

void map_editor::edit_copy (  ) 

Definition at line 660 of file editor.cpp.

References insert_selection_in_clipboard().

Referenced by edit_cut().

void map_editor::edit_cut (  ) 

Definition at line 655 of file editor.cpp.

References edit_copy(), and edit_fill_selection().

void map_editor::edit_draw (  ) 

Definition at line 787 of file editor.cpp.

References left_button_func_changed().

void map_editor::edit_fill_selection (  ) 

Definition at line 649 of file editor.cpp.

References perform_fill_hexes(), and save_undo_action().

Referenced by edit_cut().

void map_editor::edit_flip (  ) 

void map_editor::edit_flood_fill (  ) 

Definition at line 600 of file editor.cpp.

References left_button_func_changed().

void map_editor::edit_load_map (  ) 

void map_editor::edit_new_map (  ) 

void map_editor::edit_paste (  ) 

Definition at line 671 of file editor.cpp.

References left_button_func_changed().

void map_editor::edit_quit (  ) 

Definition at line 608 of file editor.cpp.

References set_abort().

void map_editor::edit_refresh (  ) 

Definition at line 791 of file editor.cpp.

References image::flush_cache(), and redraw_everything().

void map_editor::edit_resize (  ) 

void map_editor::edit_revert (  ) 

void map_editor::edit_rotate_selection (  ) 

void map_editor::edit_save_as (  ) 

void map_editor::edit_save_map (  ) 

Definition at line 604 of file editor.cpp.

References save_map().

void map_editor::edit_select_all (  ) 

Definition at line 771 of file editor.cpp.

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

void map_editor::edit_set_start_pos (  ) 

Definition at line 580 of file editor.cpp.

References left_button_func_changed().

void map_editor::edit_update (  ) 

Definition at line 796 of file editor.cpp.

References recalculate_starting_pos_labels().

void map_editor::execute_command ( const hotkey::HOTKEY_COMMAND  command  ) 

bool map_editor::map_editor::exist_redo_actions (  ) 

Return true if there exist any redo actions in the redo stack.

Definition at line 135 of file editor_undo.cpp.

References redo_stack.

Referenced by redo().

bool map_editor::map_editor::exist_undo_actions (  ) 

Return true if there exist any undo actions in the undo stack.

Definition at line 131 of file editor_undo.cpp.

References undo_stack.

Referenced by undo().

FLIP_AXIS map_editor::flip_dialog ( display disp  ) 

std::string map_editor::map_editor::flip_map ( editormap map,
const FLIP_AXIS  axis 
)

Return the string representation of the map after it has been flipped around the axis.

Definition at line 389 of file map_manip.cpp.

References editormap::flip().

Referenced by edit_flip().

void map_editor::map_editor::flood_fill ( gamemap map,
const gamemap::location start_loc,
const t_translation::t_terrain  fill_with,
terrain_log *  log = NULL 
)

Flood fill the map with the terrain fill_with starting from the location start_loc.

If log is non-null it will contain the positions of the changed tiles and the terrains they had before the filling started.

Definition at line 327 of file map_manip.cpp.

References t_translation::t_terrain::base, get_component(), gamemap::get_terrain(), loc, t_translation::NO_LAYER, gamemap::OVERLAY, and gamemap::set_terrain().

Referenced by perform_flood_fill().

std::string map_editor::get_action_name ( const LEFT_BUTTON_FUNC  func  )  const

hotkey::ACTION_STATE map_editor::get_action_state ( hotkey::HOTKEY_COMMAND  command  )  const

std::set< gamemap::location > map_editor::map_editor::get_component ( const gamemap map,
const gamemap::location start_loc 
)

Return the area that would be flood filled if a flood fill was requested.

Definition at line 350 of file map_manip.cpp.

References gamemap::get_terrain(), get_tiles(), loc, and gamemap::on_board().

Referenced by flood_fill(), and left_button_down().

std::vector< gamemap::location > map_editor::map_editor::get_tiles ( const gamemap map,
const gamemap::location a,
const unsigned int  radius 
)

void map_editor::handle_event ( const SDL_Event &  event  ) 

void map_editor::handle_keyboard_event ( const SDL_KeyboardEvent &  event,
const   int,
const   int 
)

void map_editor::handle_mouse_button_event ( const SDL_MouseButtonEvent &  event,
const int  mousex,
const int  mousey 
)

void map_editor::highlight_selected_hexes ( const bool  clear_old  ) 

Definition at line 1043 of file editor.cpp.

References clear_highlighted_hexes_in_gui().

Referenced by edit_select_all(), paste_buffer(), redo(), and undo().

void map_editor::insert_selection_in_clipboard (  ) 

Definition at line 854 of file editor.cpp.

References copy_buffer(), and distance_between().

Referenced by edit_copy().

static bool map_editor::is_invalid_terrain ( t_translation::t_terrain  c  )  [static]

bool map_editor::is_left_button_func_menu ( const theme::menu menu  )  const

Definition at line 1515 of file editor.cpp.

References get_action_name(), and theme::menu::items().

Referenced by update_l_button_palette().

void map_editor::left_button_down ( const int  mousex,
const int  mousey 
)

void map_editor::left_button_func_changed ( const LEFT_BUTTON_FUNC  func  ) 

void map_editor::left_click ( const gamemap::location  hex_clicked  ) 

void map_editor::load_tooltips (  ) 

Todo:
This should be replaced by a WML tag called 'tooltip=' in the data/themes/editor.cfg file. The theme and display classes should then load the given tooltip in the button.

Definition at line 215 of file editor.cpp.

References _, tooltips::add_tooltip(), tooltips::clear_tooltips(), theme::menus(), screen, display::screen_area(), and text.

Referenced by change_language(), map_editor(), and redraw_everything().

void map_editor::main_loop (  ) 

map_editor::map_editor ( editor_display gui,
editormap map,
config theme,
config game_config 
)

void map_editor::middle_button_down ( const int  mousex,
const int  mousey 
)

Definition at line 1289 of file editor.cpp.

References gamemap::location::valid(), and display::WARP.

Referenced by main_loop().

std::string map_editor::new_map ( const size_t  width,
const size_t  height,
const t_translation::t_terrain  filler 
)

Returns a string representating a new empty map of width by height of the terrain filler.

Definition at line 413 of file map_manip.cpp.

References gamemap::default_map_header, map, and t_translation::write_game_map().

Referenced by change_language(), edit_load_map(), edit_revert(), main(), and new_map_dialog().

std::string map_editor::map_editor::new_map_dialog ( display disp,
const t_translation::t_terrain  fill_terrain,
const bool  confirmation_needed,
const config gconfig 
)

Show a dialog to create new map.

If confirmation_needed is true, the user will be asked if she wants to continue even though the changes to the current map is lost. fill_terrain will be used to fill the map if a new one is created. Return the string representation of the new map, or the empty string if the operation failed or was cancelled.

Definition at line 58 of file editor_dialogs.cpp.

References _, util::scoped_resource< T, ReleasePolicy >::assign(), cfg, config::child(), confirm_modification_disposal(), create_map_generator(), gamemap::default_border, cursor::draw(), font::draw_text(), dummy_cfg, config::find_child(), util::scoped_resource< T, ReleasePolicy >::get(), display::h(), map, map_max_height, map_max_width, map_min_height, map_min_width, new_map(), font::NORMAL_COLOUR, events::pump(), events::raise_draw_event(), events::raise_process_event(), screen_area(), display::update_display(), update_rect(), display::video(), and display::w().

Referenced by edit_new_map().

void map_editor::paste_buffer ( const map_buffer &  buffer,
const gamemap::location loc,
map_undo_action &  undo_action 
)

void map_editor::perform_fill_hexes ( std::set< gamemap::location > &  fill_hexes,
const t_translation::t_terrain  terrain,
map_undo_action &  undo_action 
)

void map_editor::perform_flood_fill ( const t_translation::t_terrain  fill_with  ) 

void map_editor::perform_paste (  ) 

Definition at line 665 of file editor.cpp.

References paste_buffer(), and save_undo_action().

Referenced by left_click().

void map_editor::perform_selection_move (  ) 

void map_editor::perform_set_starting_pos (  ) 

Todo:
TODO: only use 1 undo to revert it (instead of 2)

Definition at line 548 of file editor.cpp.

References _, map_, gamemap::MAX_PLAYERS, gui::OK_CANCEL, gui::dialog::set_menu(), set_starting_position(), gui::dialog::show(), and starting_side_at().

Referenced by left_click().

map_undo_action map_editor::map_editor::pop_redo_action (  ) 

Remove, store in the undo stack and return the last redo action stored.

Definition at line 149 of file editor_undo.cpp.

References redo_stack, undo_limit, and undo_stack.

Referenced by redo().

map_undo_action map_editor::map_editor::pop_undo_action (  ) 

Remove, store in the redo stack and return the last undo action stored.

Definition at line 139 of file editor_undo.cpp.

References redo_stack, undo_limit, and undo_stack.

Referenced by undo().

void map_editor::preferences (  ) 

Definition at line 1027 of file editor.cpp.

References preferences_dialog().

void map_editor::preferences_dialog ( display disp,
config prefs 
)

void map_editor::recalculate_starting_pos_labels (  ) 

void map_editor::redo (  ) 

void map_editor::redraw_everything (  ) 

Definition at line 1032 of file editor.cpp.

References adjust_sizes(), load_tooltips(), and update_l_button_palette().

Referenced by edit_refresh(), main_loop(), and map_editor().

bool map_editor::map_editor::resize_dialog ( display disp,
unsigned &  width,
unsigned &  height,
int &  x_offset,
int &  y_offset,
bool &  do_expand 
)

Show a dialog asking for the new size of the map.

Return the chosen width and height. Checks are made to see that the desired values will result in a feasible map.

Definition at line 488 of file editor_dialogs.cpp.

References _, cursor::draw(), font::draw_text(), display::h(), lexical_cast(), map_max_height, map_max_width, map_min_height, map_min_width, font::NORMAL_COLOUR, events::pump(), events::raise_draw_event(), events::raise_process_event(), screen_area(), gui::button::TYPE_CHECK, display::update_display(), update_rect(), display::video(), and display::w().

Referenced by edit_resize().

std::string map_editor::map_editor::resize_map ( editormap map,
const unsigned  new_w,
const unsigned  new_h,
const int  off_x,
const int  off_y,
const bool  do_expand,
const t_translation::t_terrain  fill_with 
)

Return the string representation of the map after it has been resized to new_w X new_h.

If the new dimensions are smaller than the current ones, the map will be cropped from the bottom and from the right. If the map becomes larger than the current dimensions, the new map area appeard at the bottom and/or the right and is filled with the terrain fill_with.

Definition at line 381 of file map_manip.cpp.

References editormap::resize().

Referenced by edit_resize().

void map_editor::right_button_down ( const   int,
const   int 
)

Todo:
TODO evaluate if this is what is the smartest thing to do.

Definition at line 1282 of file editor.cpp.

References draw_on_mouseover_hexes().

Referenced by main_loop().

void map_editor::right_click ( const gamemap::location  hex_clicked  ) 

Definition at line 446 of file editor.cpp.

References gamemap::get_terrain(), key_, map_, and perform_flood_fill().

Referenced by handle_mouse_button_event().

bool map_editor::save_map ( const std::string  fn,
const bool  display_confirmation 
)

void map_editor::save_undo_action ( const map_undo_action &  action  ) 

void map_editor::set_abort ( const ABORT_MODE  abort  ) 

Definition at line 1134 of file editor.cpp.

Referenced by edit_quit(), execute_command(), handle_keyboard_event(), and main_loop().

void map_editor::set_file_to_save_as ( const std::string  filename,
bool  from_scenario 
)

Definition at line 1138 of file editor.cpp.

Referenced by edit_save_as().

void map_editor::set_mouseover_overlay (  ) 

void map_editor::set_starting_position ( const int  player,
const gamemap::location  loc 
)

void map_editor::show_menu ( const std::vector< std::string > &  items,
const int  xloc,
const int  yloc,
const   bool 
)

void map_editor::terrain_changed ( const gamemap::location hex  ) 

Definition at line 1254 of file editor.cpp.

Referenced by paste_buffer(), perform_fill_hexes(), perform_flood_fill(), redo(), and undo().

void map_editor::toggle_grid (  ) 

Definition at line 946 of file editor.cpp.

References preferences::grid(), and preferences::set_grid().

void map_editor::undo (  ) 

void map_editor::update_l_button_palette (  ) 

void map_editor::update_mouse_over_hexes ( const gamemap::location  mouse_over_hex  ) 

Definition at line 1429 of file editor.cpp.

References get_tiles(), map_, set_mouseover_overlay(), and size.

Referenced by left_button_down(), and main_loop().

bool map_editor::map_editor::valid_mapdata ( const std::string &  data,
const config cfg 
)

Return true if the data is valid to create a map with, othwerwise false.

Definition at line 393 of file map_manip.cpp.

References twml_exception::dev_message, gamemap::h(), twml_exception::user_message, and gamemap::w().

Referenced by check_data().

bool map_editor::verify_filename ( const std::string &  filename,
bool  show_error 
) const

Definition at line 1368 of file editor.cpp.

References _.

Referenced by edit_load_map(), edit_save_as(), and save_map().

map_editor::~map_editor (  ) 

Definition at line 270 of file editor.cpp.

References hotkeys_, ostream_file(), hotkey::save_hotkeys(), io_exception::what(), and write().


Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs