16 #define GETTEXT_DOMAIN "wesnoth-editor"
51 std::set<map_location> res;
95 if (!
has_alt_modifier() && (event.key.keysym.sym >=
'1' && event.key.keysym.sym <=
'9')) {
96 int side =
event.key.keysym.sym -
'0';
108 std::unique_ptr<editor_action> a;
109 if ((
has_alt_modifier() && (event.key.keysym.sym >=
'1' && event.key.keysym.sym <=
'9'))
110 || event.key.keysym.sym == SDLK_DELETE) {
111 int res =
event.key.keysym.sym -
'0';
114 if (res == 0 && old_id !=
nullptr) {
115 a = std::make_unique<editor_action_starting_position>(
map_location(), *old_id);
116 }
else if (res > 0 && (old_id ==
nullptr || *old_id == std::to_string(res))) {
117 a = std::make_unique<editor_action_starting_position>(
previous_move_hex_, std::to_string(res));
130 return key_[SDLK_RALT] ||
key_[SDLK_LALT];
135 return key_[SDLK_RSHIFT] ||
key_[SDLK_LSHIFT];
141 return key_[SDLK_RGUI] ||
key_[SDLK_LGUI];
143 return key_[SDLK_RCTRL] ||
key_[SDLK_LCTRL];
154 const std::string blank_hex =
"misc/blank-hex.png";
157 ERR_ED <<
"Missing terrain icon";
169 static const int half_size =
size / 2;
170 static const int quarter_size =
size / 4;
171 static const int offset = 2;
172 static const int new_size = half_size - 2;
175 std::stringstream
path;
178 <<
"~BLIT(" << fg_path <<
"~SCALE(" << new_size <<
"," << new_size
179 <<
")," << offset <<
"," << quarter_size <<
")"
180 <<
"~BLIT(" << bg_path <<
"~SCALE(" << new_size <<
"," << new_size
181 <<
")," << half_size <<
"," << quarter_size <<
")";
210 return drag_generic<&brush_drag_mouse_action::click_perform_left>(disp, x, y,
partial, last_undo);
216 return drag_generic<&brush_drag_mouse_action::click_perform_right>(disp, x, y,
partial, last_undo);
230 if (hex != previous_drag_hex_) {
232 LOG_ED <<
"Last undo is " << last_undo <<
" and as x " << last_undo_x;
234 auto a = (this->*perform_func)(disp, affected_hexes(disp, hex));
235 previous_drag_hex_ = hex;
278 auto chain = std::make_unique<editor_action_chain>();
279 chain->append_action(std::make_unique<editor_action_paint_area>(
289 auto chain = std::make_unique<editor_action_chain>();
290 chain->append_action(std::make_unique<editor_action_paint_area>(
319 return std::make_unique<editor_action_paste>(
paste_, hex);
333 "misc/blank-hex.png",
334 "~BLIT(icons/action/editor-paste_60.png,6,6)"
382 if (!
click_)
return nullptr;
391 if (player_starting_at_hex) {
398 std::unique_ptr<editor_action> a;
400 if(!player_starting_at_hex || new_player_at_hex != *player_starting_at_hex) {
402 a = std::make_unique<editor_action_starting_position>(hex, new_player_at_hex);
406 a = std::make_unique<editor_action_starting_position>(
map_location(), *player_starting_at_hex);
424 if (player_starting_at_hex !=
nullptr) {
425 return std::make_unique<editor_action_starting_position>(
map_location(), *player_starting_at_hex);
442 "misc/blank-hex.png",
443 "~BLIT(icons/action/editor-tool-starting-position_60.png,6,6)"
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.
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...
A brush-drag mouse action base class which adds brush and drag processing to a basic mouse action.
std::unique_ptr< editor_action > click_left(editor_display &disp, int x, int y)
Calls click_perform_left()
std::unique_ptr< 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.
const brush *const *const brush_
Current brush handle.
virtual std::unique_ptr< 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().
const brush & get_brush()
Brush accessor.
std::unique_ptr< 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.
std::unique_ptr< editor_action > drag_end(editor_display &disp, int x, int y)
End of dragging.
std::unique_ptr< 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.
map_location previous_drag_hex_
The previous hex dragged into.
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 ...
virtual std::unique_ptr< 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().
std::unique_ptr< editor_action > click_right(editor_display &disp, int x, int y)
Calls click_perform_right()
The brush class represents a single brush – a set of relative locations around a "hotspot",...
std::set< map_location > project(const map_location &hotspot) const
Get a set of locations affected (i.e.
Base class for actions that: 1) operate on an area 2) can be used as undo for a click-drag operation ...
Base class for all editor actions.
void set_mouseover_hex_overlay(const texture &image)
Sets texture to be drawn in hex under the mouse's location.
void clear_mouseover_hex_overlay()
void set_brush_locs(const std::set< map_location > &hexes)
const editor_map & get_map() const
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 std::string & selected_item() const
Return the currently selected item.
void add_item(const std::string &id)
std::set< map_location > get_offset_area(const map_location &offset) const
Get the area covered by this map fragment, shifted by an offset.
terrain_palette & terrain_palette_
std::set< map_location > affected_hexes(editor_display &disp, const map_location &hex) override
Tiles that will be painted to, possibly use modifier keys here.
std::unique_ptr< editor_action > click_left(editor_display &disp, int x, int y) override
Left / right click fills with the respective terrain.
std::unique_ptr< editor_action > click_right(editor_display &disp, int x, int y) override
Left / right click fills with the respective terrain.
virtual void set_mouse_overlay(editor_display &disp) override
Set the mouse overlay for this action.
std::unique_ptr< editor_action > click_perform_right(editor_display &disp, const std::set< map_location > &hexes) override
Create an appropriate editor_action and return it.
std::unique_ptr< editor_action > click_right(editor_display &disp, int x, int y) override
Handle terrain sampling before calling generic handler.
terrain_palette & terrain_palette_
void set_mouse_overlay(editor_display &disp) override
Set the mouse overlay for this action.
std::unique_ptr< editor_action > click_left(editor_display &disp, int x, int y) override
Handle terrain sampling before calling generic handler.
std::unique_ptr< editor_action > click_perform_left(editor_display &disp, const std::set< map_location > &hexes) override
Create an appropriate editor_action and return it.
virtual bool has_context_menu() const override
std::set< map_location > affected_hexes(editor_display &disp, const map_location &hex) override
Show an outline of where the paste will go.
std::unique_ptr< editor_action > click_left(editor_display &disp, int x, int y) override
Return a paste with offset action.
virtual void set_mouse_overlay(editor_display &disp) override
Set the mouse overlay for this action.
std::unique_ptr< editor_action > click_right(editor_display &disp, int x, int y) override
Right click does nothing for now.
const map_fragment & paste_
Reference to the buffer used for pasting (e.g.
std::unique_ptr< editor_action > up_right(editor_display &disp, int x, int y) override
Right click only erases the starting position if there is one.
std::unique_ptr< editor_action > up_left(editor_display &disp, int x, int y) override
Left click displays a player-number-selector dialog and then creates an action or returns nullptr if ...
std::unique_ptr< editor_action > click_right(editor_display &disp, int x, int y) override
A click, possibly the beginning of a drag.
std::unique_ptr< editor_action > click_left(editor_display &disp, int x, int y) override
A click, possibly the beginning of a drag.
virtual void set_mouse_overlay(editor_display &disp) override
Set the mouse overlay for this action.
location_palette & location_palette_
bool has_shift_modifier() const
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.
virtual std::unique_ptr< editor_action > drag_end_right(editor_display &disp, int x, int y)
virtual bool has_context_menu() const
void set_terrain_mouse_overlay(editor_display &disp, const t_translation::terrain_code &fg, const t_translation::terrain_code &bg)
Helper function for derived classes that need a active-terrain mouse overlay.
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 std::unique_ptr< editor_action > up_left(editor_display &disp, int x, int y)
bool has_ctrl_modifier() const
const CKey & key_
Key presses, used for modifiers (alt, shift) in some operations.
map_location previous_move_hex_
The hex previously used in move operations.
virtual void move(editor_display &disp, const map_location &hex)
Mouse move (not a drag).
virtual std::unique_ptr< editor_action > up_right(editor_display &disp, int x, int y)
virtual std::unique_ptr< 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.
virtual std::unique_ptr< editor_action > drag_left(editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
Drag operation.
virtual std::unique_ptr< editor_action > drag_right(editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
Drag operation.
virtual void set_mouse_overlay(editor_display &disp)
Set the mouse overlay for this action.
bool has_alt_modifier() const
virtual std::unique_ptr< editor_action > drag_end_left(editor_display &disp, int x, int y)
The end of dragging.
void select_fg_item(const t_translation::terrain_code &terrain)
const t_translation::terrain_code & selected_bg_item() const
const t_translation::terrain_code & selected_fg_item() const
void select_bg_item(const t_translation::terrain_code &terrain)
terrain_code get_terrain(const map_location &loc) const
Looks up terrain at a particular location.
static const int MAX_PLAYERS
Maximum number of players supported.
map_location starting_position(int side) const
const std::string * is_special_location(const map_location &loc) const
returns the name of the special location at position loc, null if no such location exists.
bool on_board(const map_location &loc) const
Tell if a location is on the map.
const terrain_type & get_terrain_info(const t_translation::terrain_code &terrain) const
Generic locator abstracting the location of an image.
const std::string & editor_image() const
Manage the empty-palette in the editor.
bool exists(const image::locator &i_locator)
Returns true if the given image actually exists, without loading it.
texture get_texture(const image::locator &i_locator, TYPE type, bool skip_cache)
Returns an image texture suitable for hardware-accelerated rendering.
point get_size(const locator &i_locator, bool skip_cache)
Returns the width and height of an image.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
@ partial
There are still moves and/or attacks possible, but the unit doesn't fit in the "unmoved" status.
Encapsulates the map of the game.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...