16 #define GETTEXT_DOMAIN "wesnoth-editor"
34 symbols[
"type"] =
type;
35 const char* error_msg =
"There was an error ($type) while loading the file:";
61 throw wrap_exc(
"wml",
e.user_message,
"");
68 :
gamemap(width + 2, height + 2, filler)
82 std::set<map_location> result;
83 std::deque<map_location> queue;
85 queue.push_back(
start);
90 && result.find(adj) == result.end()) {
96 }
while (!queue.empty());
102 std::set<map_location> label_locs;
108 bool is_number =
std::find_if(pair.first.begin(), pair.first.end(), [](
char c) { return !std::isdigit(c); }) == pair.first.end();
117 label_locs.insert(pair.second);
195 if (old_w == width && old_h == height && x_offset == 0 && y_offset == 0) {
200 std::set<map_location> old_selection =
selection();
203 const int left_resize = -x_offset;
204 const int right_resize = (width - old_w) + x_offset;
205 const int top_resize = -y_offset;
206 const int bottom_resize = (height - old_h) + y_offset;
208 if(right_resize > 0) {
210 }
else if(right_resize < 0) {
213 if(bottom_resize > 0) {
215 }
else if(bottom_resize < 0) {
218 if(left_resize > 0) {
220 }
else if(left_resize < 0) {
225 }
else if(top_resize < 0) {
237 if(x_offset || y_offset) {
265 if (target.
w() !=
w() || target.
h() !=
h()) {
282 return h() == other.
h()
289 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
290 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
294 for (
int x =
tiles().
w, x_end =
tiles().
w + count; x != x_end; ++x) {
295 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
299 tiles() = std::move(tiles_new);
305 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
306 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
310 for (
int x = 0, x_end = count; x != x_end; ++x) {
311 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
315 tiles() = std::move(tiles_new);
321 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
322 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
326 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
327 for (
int y = 0, y_end = count; y != y_end; ++y) {
331 tiles() = std::move(tiles_new);
337 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
338 for (
int y = 0, y_end =
tiles().
h; y != y_end; ++y) {
342 for (
int x = 0, x_end =
tiles().
w; x != x_end; ++x) {
343 for (
int y =
tiles().
h, y_end =
tiles().
h + count; y != y_end; ++y) {
347 tiles() = std::move(tiles_new);
352 if(count < 0 || count >
tiles().
w) {
356 for (
int x = 0, x_end = tiles_new.
w; x != x_end; ++x) {
357 for (
int y = 0, y_end = tiles_new.
h; y != y_end; ++y) {
361 tiles() = std::move(tiles_new);
366 if (count < 0 || count >
tiles().
w) {
370 for (
int x = 0, x_end = tiles_new.
w; x != x_end; ++x) {
371 for (
int y = 0, y_end = tiles_new.
h; y != y_end; ++y) {
375 tiles() = std::move(tiles_new);
380 if (count < 0 || count >
tiles().
h) {
384 for (
int x = 0, x_end = tiles_new.
w; x != x_end; ++x) {
385 for (
int y = 0, y_end = tiles_new.
h; y != y_end; ++y) {
389 tiles() = std::move(tiles_new);
394 if (count < 0 || count >
tiles().
h) {
398 for (
int x = 0, x_end = tiles_new.
w; x != x_end; ++x) {
399 for (
int y = 0, y_end = tiles_new.
h; y != y_end; ++y) {
403 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.
static std::set< map_location > get_locations(const selection_mask &mask)
bool select(const map_location &loc)
Marks loc as selected.
const boost::dynamic_bitset< uint64_t > & mask() const
Read-only access to the underlying bitset.
selection_mask inverted() const
bool selected(const map_location &loc) const
bool deselect(const map_location &loc)
Marks loc as unselected.
This class adds extra editor-specific functionality to a normal gamemap.
void shrink_left(int count)
bool everything_selected() const
bool add_to_selection(const map_location &loc)
Add a location to the selection.
bool anything_selected() const
void shrink_top(int count)
void expand_left(int count, const t_translation::terrain_code &filler)
selection_mask 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_bottom(int count)
static editor_map from_string(std::string_view data)
Wrapper around editor_map(cfg, data) that catches possible exceptions and wraps them in a editor_map_...
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,...
std::set< map_location > selection() const
Return the selection set.
bool nothing_selected() const
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)
void set_selection(const std::set< map_location > &area)
Select the given area.
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.
std::set< map_location > selection_inverse() const
Returns a set of all hexes not currently selected.
editor_map()
Empty map constructor.
void clear_selection()
Clear the selection.
void expand_bottom(int count, const t_translation::terrain_code &filler)
std::size_t num_selected() const
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
bool on_board_with_border(const map_location &loc) const
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_
gamemap_base::set_terrain_result 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, utils::span< map_location, 6 > 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.
constexpr terrain_code NONE_TERRAIN
const terrain_code FOGGED
auto * find_if(Container &container, const Predicate &predicate)
Convenience wrapper for using find_if on a container without needing to comare to end()
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)
map_location plus(int x_diff, int y_diff) const
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...