14 #define GETTEXT_DOMAIN "wesnoth-editor"
48 std::set<map_location>
res;
92 if (!
has_alt_modifier() && (event.key.keysym.sym >=
'1' && event.key.keysym.sym <=
'9')) {
93 int side =
event.key.keysym.sym -
'0';
106 if ((
has_alt_modifier() && (event.key.keysym.sym >=
'1' && event.key.keysym.sym <=
'9'))
107 ||
event.key.keysym.sym == SDLK_DELETE) {
108 int res =
event.key.keysym.sym -
'0';
111 if (res == 0 && old_id !=
nullptr) {
113 }
else if (res > 0 && (old_id ==
nullptr || *old_id == std::to_string(res))) {
127 return key_[SDLK_RALT] ||
key_[SDLK_LALT];
132 return key_[SDLK_RSHIFT] ||
key_[SDLK_LSHIFT];
140 return key_[SDLK_RCTRL] ||
key_[SDLK_LCTRL];
150 if (image_fg ==
nullptr || image_bg ==
nullptr) {
151 ERR_ED <<
"Missing terrain icon" << std::endl;
166 static const int size = image_fg->w;
167 static const int half_size = size / 2;
168 static const int quarter_size = size / 4;
169 static const int offset = 2;
170 static const int new_size = half_size - 2;
180 blit_surface ( image_bg,
nullptr, image, &rcDestRight );
221 return drag_generic<&brush_drag_mouse_action::click_perform_left>(disp,
x,
y,
partial, last_undo);
227 return drag_generic<&brush_drag_mouse_action::click_perform_right>(disp,
x,
y,
partial, last_undo);
236 template <editor_action* (brush_drag_mouse_action::*perform_func)(editor_display&, const std::set<map_location>&)>
243 LOG_ED <<
"Last undo is " << last_undo <<
" and as x " << last_undo_x <<
"\n";
395 if (!
click_)
return nullptr;
404 if (player_starting_at_hex) {
413 if(!player_starting_at_hex || new_player_at_hex != *player_starting_at_hex) {
437 if (player_starting_at_hex !=
nullptr) {
editor_action * drag_end(editor_display &disp, int x, int y)
End of dragging.
editor_action * click_left(editor_display &disp, int x, int y)
A click, possibly the beginning of a drag.
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
terrain_palette & terrain_palette_
virtual void set_mouse_overlay(editor_display &disp)
Set the mouse overlay for this action.
virtual editor_action * click_perform_left(editor_display &disp, const std::set< map_location > &hexes)=0
The actual action function which is called by click() and drag().
surface create_neutral_surface(int w, int h)
void set_mouse_overlay(editor_display &disp)
Set the mouse overlay for this action.
bool has_shift_modifier() const
virtual void set_mouse_overlay(editor_display &disp)
Set the mouse overlay for this action.
const CKey & key_
Key presses, used for modifiers (alt, shift) in some operations.
editor_action * click_right(editor_display &disp, int x, int y)
A click, possibly the beginning of a drag.
virtual bool has_context_menu() const
const brush & get_brush()
Brush accessor.
const t_translation::t_terrain & selected_bg_item() const
map_location previous_move_hex_
The hex previously used in move operations.
const brush *const *const brush_
Current brush handle.
editor_action * click_perform_right(editor_display &disp, const std::set< map_location > &hexes)
Create an appropriate editor_action and return it.
void set_brush_locs(const std::set< map_location > &hexes)
editor_action * click_right(editor_display &disp, int x, int y)
Right click does nothing for now.
virtual void set_mouse_overlay(editor_display &disp)
Set the mouse overlay for this action.
void set_terrain_mouse_overlay(editor_display &disp, const t_translation::t_terrain &fg, const t_translation::t_terrain &bg)
Helper function for derived classes that need a active-terrain mouse overlay.
editor_action * up_left(editor_display &disp, int x, int y)
Left click displays a player-number-selector dialog and then creates an action or returns nullptr if ...
const map_location hex_clicked_on(int x, int y) const
given x,y co-ordinates of an onscreen pixel, will return the location of the hex that this pixel corr...
Paste a map fragment into the map.
double get_zoom_factor() const
Returns the current zoom factor.
Container action wrapping several actions into one.
GLint GLint GLint GLint GLint GLint y
virtual editor_action * drag_left(editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
Drag operation.
surface scale_surface(const surface &surf, int w, int h)
bool has_ctrl_modifier() const
Set starting position action.
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.
const t_translation::t_terrain & selected_fg_item() const
void blit_surface(const surface &surf, const SDL_Rect *srcrect, surface &dst, const SDL_Rect *dstrect)
Replacement for sdl_blit.
const std::string & selected_item() const
Return the currently selected item.
map_location previous_drag_hex_
The previous hex dragged into.
location_palette & location_palette_
surface mask_surface(const surface &surf, const surface &mask, bool *empty_result, const std::string &filename)
Applies a mask on a surface.
editor_action * click_left(editor_display &disp, int x, int y)
Handle terrain sampling before calling generic handler.
virtual editor_action * up_left(editor_display &disp, int x, int y)
virtual editor_action * key_event(editor_display &disp, const SDL_Event &e)
Function called by the controller on a key event for the current mouse action.
const map_fragment & paste_
Reference to the buffer used for pasting (e.g.
std::set< map_location > get_offset_area(const map_location &offset) const
Get the area covered by this map fragment, shifted by an offset.
map_location starting_position(int side) const
editor_action * click_perform_left(editor_display &disp, const std::set< map_location > &hexes)
Create an appropriate editor_action and return it.
virtual editor_action * drag_right(editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
Drag operation.
const std::string & editor_image() const
surface adjust_surface_alpha(const surface &surf, fixed_t amount, bool optimize)
editor_action * click_left(editor_display &disp, int x, int y)
Left / right click fills with the respective terrain.
GLboolean GLboolean GLboolean GLboolean a
editor_action * up_right(editor_display &disp, int x, int y)
Right click only erases the starting position if there is one.
void update_brush_highlights(editor_display &disp, const map_location &hex)
Unconditionally update the brush highlights for the current tool when hex is the center location...
GLclampf GLclampf GLclampf alpha
The brush class represents a single brush – a set of relative locations around a "hotspot"...
bool has_context_menu() const
editor_action * click_left(editor_display &disp, int x, int y)
Calls click_perform_left()
std::set< map_location > affected_hexes(editor_display &disp, const map_location &hex)
Show an outline of where the paste will go.
virtual editor_action * up_right(editor_display &disp, int x, int y)
void set_mouseover_hex_overlay(const surface &image)
mouseover_hex_overlay_ require a prerendered surface and is drawn underneath the mouse's location ...
Manage the empty-palette in the editor.
Paint the same terrain on a number of locations on the map.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
terrain_palette & terrain_palette_
Encapsulates the map of the game.
const terrain_type & get_terrain_info(const t_translation::t_terrain &terrain) const
void select_fg_item(const t_translation::t_terrain &terrain)
void add_item(const std::string &id)
void scroll_to_tile(const map_location &loc, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, bool force=true)
Scroll such that location loc is on-screen.
bool has_alt_modifier() const
Base class for all editor actions.
surface get_hexmask()
function to get the standard hex mask
std::set< map_location > affected_hexes(editor_display &disp, const map_location &hex)
Tiles that will be painted to, possibly use modifier keys here.
editor_action * drag_right(editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
Calls click_perform for every new hex the mouse is dragged into.
void select_bg_item(const t_translation::t_terrain &terrain)
GLint GLint GLint GLint GLint x
editor_action * click_right(editor_display &disp, int x, int y)
Handle terrain sampling before calling generic handler.
Base class for actions that: 1) operate on an area 2) can be used as undo for a click-drag operation ...
GLdouble GLdouble GLdouble r
editor_action * drag_generic(editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
Template helper gathering actions common for both drag_right and drag_left.
virtual void set_mouse_overlay(editor_display &disp)
Set the mouse overlay for this action.
t_translation::t_terrain get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
Creates an empty SDL_Rect.
bool on_board(const map_location &loc) const
Tell if a location is on the map.
editor_action * click_left(editor_display &disp, int x, int y)
Return a paste with offset action.
editor_action * drag_left(editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
Calls click_perform() for every new hex the mouse is dragged into.
const gamemap & get_map() const
virtual editor_action * drag_end_left(editor_display &disp, int x, int y)
The end of dragging.
editor_action * click_right(editor_display &disp, int x, int y)
Left / right click fills with the respective terrain.
virtual void move(editor_display &disp, const map_location &hex)
Mouse move (not a drag).
this module manages the cache of images.
const std::string * is_starting_position(const map_location &loc) const
returns the side number of the side starting at position loc, 0 if no such side exists.
editor_action * click_right(editor_display &disp, int x, int y)
Calls click_perform_right()
virtual std::set< map_location > affected_hexes(editor_display &disp, const map_location &hex)
Locations that would be affected by a click, used by move to update highlights.
virtual editor_action * click_perform_right(editor_display &disp, const std::set< map_location > &hexes)=0
The actual action function which is called by click() and drag().
int hex_size() const
Function which returns the size of a hex in pixels (from top tip to bottom tip or left edge to right ...
GLsizei const GLcharARB ** string
virtual editor_action * drag_end_right(editor_display &disp, int x, int y)
const editor_map & map() const
std::set< map_location > affected_hexes(editor_display &disp, const map_location &hex)
The affected hexes of a brush action are the result of projecting the current brush on the mouseover ...
std::set< map_location > project(const map_location &hotspot) const
Get a set of locations affected (i.e.