16 #define GETTEXT_DOMAIN "wesnoth-editor" 32 WRN_ED << type <<
" error in load map " << filename <<
": " << e_msg << std::endl;
34 symbols[
"type"] =
type;
35 const char* error_msg =
"There was an error ($type) while loading the file:";
107 ERR_ED <<
"Off-map tile in selection: " << loc << std::endl;
118 std::set<map_location> result;
119 std::deque<map_location> queue;
120 result.insert(start);
121 queue.push_back(start);
126 && result.find(adj) == result.end()) {
128 queue.push_back(adj);
132 }
while (!queue.empty());
138 std::set<map_location> label_locs;
144 bool is_number = std::find_if(pair.first.begin(), pair.first.end(), [](
char c) {
return !std::isdigit(
c); }) == pair.first.end();
153 label_locs.insert(pair.second);
190 std::set<map_location> new_selection;
191 for (
int x = -1; x <
w() + 1; ++x) {
192 for (
int y = -1; y <
h() + 1; ++y) {
194 new_selection.emplace(x, y);
218 if (old_w == width && old_h == height && x_offset == 0 && y_offset == 0) {
223 const int left_resize = -x_offset;
224 const int right_resize = (width - old_w) + x_offset;
225 const int top_resize = -y_offset;
226 const int bottom_resize = (height - old_h) + y_offset;
228 if(right_resize > 0) {
230 }
else if(right_resize < 0) {
233 if(bottom_resize > 0) {
235 }
else if(bottom_resize < 0) {
238 if(left_resize > 0) {
240 }
else if(left_resize < 0) {
245 }
else if(top_resize < 0) {
250 if(x_offset || y_offset) {
280 if (target.
w() !=
w() || target.
h() !=
h()) {
297 return h() == other.
h()
304 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
305 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
309 for (
int x =
tiles().
w, x_end =
tiles().
w + count; x != x_end; ++x) {
310 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
314 tiles() = std::move(tiles_new);
320 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
321 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
325 for (
int x = 0, x_end = count; x != x_end; ++x) {
326 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
330 tiles() = std::move(tiles_new);
336 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
337 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
341 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
342 for (
int y = 0, y_end = count; y != y_end; ++y) {
346 tiles() = std::move(tiles_new);
352 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
353 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
357 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
358 for (
int y =
tiles().
h, y_end =
tiles().
h + count; y != y_end; ++y) {
362 tiles() = std::move(tiles_new);
367 if(count < 0 || count >
tiles().
w) {
371 for (
int x = 0, x_end = tiles_new.
w; x != x_end; ++x) {
372 for (
int y = 0, y_end = tiles_new.
h; y != y_end; ++y) {
376 tiles() = std::move(tiles_new);
381 if (count < 0 || count >
tiles().
w) {
385 for (
int x = 0, x_end = tiles_new.
w; x != x_end; ++x) {
386 for (
int y = 0, y_end = tiles_new.
h; y != y_end; ++y) {
390 tiles() = std::move(tiles_new);
395 if (count < 0 || count >
tiles().
h) {
399 for (
int x = 0, x_end = tiles_new.
w; x != x_end; ++x) {
400 for (
int y = 0, y_end = tiles_new.
h; y != y_end; ++y) {
404 tiles() = std::move(tiles_new);
409 if (count < 0 || count >
tiles().
h) {
413 for (
int x = 0, x_end = tiles_new.
w; x != x_end; ++x) {
414 for (
int y = 0, y_end = tiles_new.
h; y != y_end; ++y) {
418 tiles() = std::move(tiles_new);
void expand_bottom(int count, const t_translation::terrain_code &filler)
const terrain_code NONE_TERRAIN
location_map & special_locations()
static editor_map from_string(const std::string &data)
Wrapper around editor_map(cfg, data) that catches possible exceptions and wraps them in a editor_map_...
std::map< std::string, t_string > string_map
void get_adjacent_tiles(const map_location &a, map_location *res)
Function which, given a location, will place all adjacent locations in res.
std::vector< map_location > villages_
void set_terrain(const map_location &loc, const terrain_code &terrain, const terrain_type_data::merge_mode mode=terrain_type_data::BOTH, bool replace_if_failed=false) override
Clobbers over the terrain at location 'loc', with the given terrain.
std::set< map_location > selection_
The selected hexes.
std::set< map_location > set_starting_position_labels(display &disp)
Set labels for staring positions in the given display object.
void shrink_top(int count)
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
bool in_selection(const map_location &loc) const
std::string user_message
The message for the user explaining what went wrong.
bool same_size_as(const gamemap &other) const
A precondition to several map operations.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
void sanity_check()
Debugging aid.
void for_each_loc(const F &f) const
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Base class for editor actions.
void resize(int width, int height, int x_offset, int y_offset, const t_translation::terrain_code &filler=t_translation::NONE_TERRAIN)
Resize the map.
static std::string _(const char *str)
~editor_map()
editor_map destructor
editor_map_load_exception wrap_exc(const char *type, const std::string &e_msg, const std::string &filename)
Exception wrapping utility.
void add(int x_diff, int y_diff)
std::string label
What to show in the filter's drop-down list.
int w() const
Effective map width.
const terrain_code FOGGED
EXIT_STATUS start(const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.
const terrain_label * set_label(const map_location &loc, const t_string &text, const int creator=-1, const std::string &team="", const color_t color=font::NORMAL_COLOR, const bool visible_in_fog=true, const bool visible_in_shroud=false, const bool immutable=false, const std::string &category="", const t_string &tooltip="")
void expand_left(int count, const t_translation::terrain_code &filler)
void invert_selection()
Invert the selection, i.e.
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
bool on_board_with_border(const map_location &loc) const
Encapsulates the map of the game.
std::set< map_location > get_contiguous_terrain_tiles(const map_location &start) const
Get a contiguous set of tiles having the same terrain as the starting location.
map_display and display: classes which take care of displaying the map and game-data on the screen...
editor_map()
Empty map constructor.
Manage the empty-palette in the editor.
void shrink_left(int count)
gamemap mask_to(const gamemap &target) const
A sort-of diff operation returning a mask that, when applied to the current editor_map, will transform it into the target map.
bool add_to_selection(const map_location &loc)
Add a location to the selection.
Encapsulates the map of the game.
Helper class, don't construct this directly.
int total_width() const
Real width of the map, including borders.
This class adds extra editor-specific functionality to a normal gamemap.
bool everything_selected() const
void expand_right(int count, const t_translation::terrain_code &filler)
void clear_selection()
Clear the selection.
terrain_code & get(int x, int y)
int total_height() const
Real height of the map, including borders.
std::string write_game_map(const ter_map &map, const starting_positions &starting_positions, coordinate border_offset)
Write a gamemap in to a vector string.
void select_all()
Select all map hexes.
bool is_village(const map_location &loc) const
void expand_top(int count, const t_translation::terrain_code &filler)
int border_size() const
Size of the map border.
int h() const
Effective map height.
void shrink_right(int count)
bool set_selection(const std::set< map_location > &area)
Select the given area.
bool remove_from_selection(const map_location &loc)
Remove a location to the selection.
void shrink_bottom(int count)