14 #define GETTEXT_DOMAIN "wesnoth-editor"
29 #include <boost/make_shared.hpp>
30 #include <boost/shared_ptr.hpp>
36 WRN_ED << type <<
" error in load map " << filename <<
": " << e_msg << std::endl;
38 symbols[
"type"] =
type;
39 const char* error_msg =
"There was an error ($type) while loading the file:";
110 for (
size_t i = 1;
i <
tiles_.size(); ++
i) {
112 ERR_ED <<
"tiles_[ " <<
i <<
"] has size() " <<
tiles_[
i].size() <<
" but tiles[0] has size() " <<
tiles_[0].size() << std::endl;
118 ERR_ED <<
"Off-map tile in selection: " << loc << std::endl;
129 std::set<map_location>
result;
130 std::deque<map_location> queue;
131 result.insert(start);
132 queue.push_back(start);
137 for (
int i = 0;
i < 6; ++
i) {
139 && result.find(adj[i]) == result.end()) {
140 result.insert(adj[i]);
141 queue.push_back(adj[i]);
145 }
while (!queue.empty());
151 std::set<map_location> label_locs;
157 bool is_number = std::find_if(pair.first.begin(), pair.first.end(), [](
char c) {
return !std::isdigit(
c); }) == pair.first.end();
166 label_locs.insert(
map_location(pair.second.x, pair.second.y));
203 std::set<map_location> new_selection;
204 for (
int x = -1;
x <
w() + 1; ++
x) {
205 for (
int y = -1;
y <
h() + 1; ++
y) {
231 if (old_w == width && old_h == height && x_offset == 0 && y_offset == 0) {
236 const int left_resize = -x_offset;
237 const int right_resize = (width - old_w) + x_offset;
238 const int top_resize = -y_offset;
239 const int bottom_resize = (height - old_h) + y_offset;
241 if(right_resize > 0) {
243 }
else if(right_resize < 0) {
246 if(bottom_resize > 0) {
248 }
else if(bottom_resize < 0) {
251 if(left_resize > 0) {
253 }
else if(left_resize < 0) {
258 }
else if(top_resize < 0) {
263 if(x_offset || y_offset) {
273 if (target.
w() !=
w() || target.
h() !=
h()) {
290 return h() == other.
h()
298 for (
int y = 0;
y <
h; ++
y) {
387 for (
size_t x = 0;
x <
tiles_.size(); ++
x) {
399 for (
size_t x = 0;
x <
tiles_.size(); ++
x) {
int total_width() const
Real width of the map, including borders.
bool on_board_with_border(const map_location &loc) const
Contains an x and y coordinate used for starting positions in maps.
void resize(int width, int height, int x_offset, int y_offset, const t_translation::t_terrain &filler=t_translation::NONE_TERRAIN)
Resize the map.
std::set< map_location > selection_
The selected hexes.
std::string write_game_map(const t_map &map, const tstarting_positions &starting_positions, coordinate border_offset)
Write a gamemap in to a vector string.
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...
GLuint GLuint GLsizei GLenum type
const t_terrain NONE_TERRAIN
void get_adjacent_tiles(const map_location &a, map_location *res)
Function which, given a location, will place all adjacent locations in res.
void sanity_check()
Debugging aid.
Base class for editor actions.
GLint GLint GLint GLint GLint GLint y
void expand_top(int count, const t_translation::t_terrain &filler)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
void expand_left(int count, const t_translation::t_terrain &filler)
t_translation::t_list clone_column(int x, const t_translation::t_terrain &filler)
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.
~editor_map()
editor_map destructor
std::string user_message
The message for the user explaining what went wrong.
int total_height() const
Real height of the map, including borders.
const terrain_label * set_label(const map_location &loc, const t_string &text, const int creator=-1, const std::string &team="", const SDL_Color 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="")
editor_map_load_exception wrap_exc(const char *type, const std::string &e_msg, const std::string &filename)
Exception wrapping utility.
std::vector< std::vector< t_terrain > > t_map
static UNUSEDNOWARN std::string _(const char *str)
std::map< std::string, t_string > string_map
bool everything_selected() const
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 in_selection(const map_location &loc) const
void invert_selection()
Invert the selection, i.e.
GLubyte GLubyte GLubyte GLubyte w
bool same_size_as(const gamemap &other) const
A precondition to several map operations.
int w() const
Effective map width.
Encapsulates the map of the game.
int border_size() const
Size of the map border.
map_display and display: classes which take care of displaying the map and game-data on the screen...
int w_
Sizes of the map area.
Manage the empty-palette in the editor.
void shrink_left(int count)
static const ::config * terrain
The terrain used to create the cache.
GLuint GLuint GLsizei count
void expand_bottom(int count, const t_translation::t_terrain &filler)
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
bool add_to_selection(const map_location &loc)
Add a location to the selection.
Encapsulates the map of the game.
GLenum GLenum GLvoid GLvoid * column
static editor_map from_string(const config &terrain_cfg, const std::string &data)
Wrapper around editor_map(cfg, data) that catches possible exceptions and wraps them in a editor_map_...
void expand_right(int count, const t_translation::t_terrain &filler)
This class adds extra editor-specific functionality to a normal gamemap.
int h() const
Effective map height.
editor_map(const config &terrain_cfg)
Empty map constructor.
void clear_selection()
Clear the selection.
GLfloat GLfloat GLfloat GLfloat h
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
GLint GLint GLint GLint GLint x
void set_terrain(const map_location &loc, const t_translation::t_terrain &terrain, const terrain_type_data::tmerge_mode mode=terrain_type_data::BOTH, bool replace_if_failed=false)
Clobbers over the terrain at location 'loc', with the given terrain.
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
t_translation::t_terrain get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
void select_all()
Select all map hexes.
tstarting_positions starting_positions_
The size of the starting positions array is MAX_PLAYERS + 1, because the positions themselves are num...
int total_width_
Sizes of the map including the borders.
GLint GLint GLint GLint GLint GLint GLsizei width
t_translation::t_map tiles_
A config object defines a single node in a WML file, with access to child nodes.
Helper class, don't construct this directly.
void shrink_right(int count)
GLsizei const GLcharARB ** string
void clear_border_cache()
Clears the border cache, needed for the editor.
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.
std::vector< t_terrain > t_list
void shrink_bottom(int count)