16 #define GETTEXT_DOMAIN "wesnoth-editor"
34 symbols[
"type"] =
type;
35 const char* error_msg =
"There was an error ($type) while loading the file:";
62 throw wrap_exc(
"wml",
e.user_message,
"");
107 ERR_ED <<
"Off-map tile in selection: " <<
loc;
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);
Base class for editor actions.
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
This class adds extra editor-specific functionality to a normal gamemap.
void sanity_check()
Debugging aid.
void shrink_left(int count)
bool everything_selected() const
bool add_to_selection(const map_location &loc)
Add a location to the selection.
std::set< map_location > selection_
The selected hexes.
bool set_selection(const std::set< map_location > &area)
Select the given area.
~editor_map()
editor_map destructor
void shrink_top(int count)
void expand_left(int count, const t_translation::terrain_code &filler)
std::set< map_location > set_starting_position_labels(display &disp)
Set labels for staring positions in the given display object.
void shrink_bottom(int count)
void invert_selection()
Invert the selection, i.e.
void shrink_right(int count)
void select_all()
Select all map hexes.
bool same_size_as(const gamemap &other) const
A precondition to several map operations.
gamemap mask_to(const gamemap &target) const
A sort-of diff operation returning a mask that, when applied to the current editor_map,...
void expand_right(int count, const t_translation::terrain_code &filler)
bool in_selection(const map_location &loc) const
bool remove_from_selection(const map_location &loc)
Remove a location to the selection.
void expand_top(int count, const t_translation::terrain_code &filler)
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::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.
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.
editor_map()
Empty map constructor.
void clear_selection()
Clear the selection.
void expand_bottom(int count, const t_translation::terrain_code &filler)
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
int w() const
Effective map width.
int h() const
Effective map height.
void for_each_loc(const F &f) const
int total_width() const
Real width of the map, including borders.
bool on_board_with_border(const map_location &loc) const
int total_height() const
Real height of the map, including borders.
int border_size() const
Size of the map border.
location_map & special_locations()
Encapsulates the map of the game.
bool is_village(const map_location &loc) const
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.
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="")
map_display and display: classes which take care of displaying the map and game-data on the screen.
static std::string _(const char *str)
std::string label
What to show in the filter's drop-down list.
void get_adjacent_tiles(const map_location &a, map_location *res)
Function which, given a location, will place all adjacent locations in res.
Manage the empty-palette in the editor.
editor_map_load_exception wrap_exc(const char *type, const std::string &e_msg, const std::string &filename)
Exception wrapping utility.
EXIT_STATUS start(bool clear_id, const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.
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.
const terrain_code FOGGED
const terrain_code NONE_TERRAIN
std::map< std::string, t_string > string_map
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
std::string filename
Filename.
Encapsulates the map of the game.
void add(int x_diff, int y_diff)
terrain_code & get(int x, int y)
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
Helper class, don't construct this directly.
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...