The Battle for Wesnoth  1.15.3+dev
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2018 by Fabian Mueller <>
3  Part of the Battle for Wesnoth Project
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
12  See the COPYING file for more details.
13 */
20 namespace editor {
22 std::set<map_location> mouse_action_select::affected_hexes(
23  editor_display& disp, const map_location& hex)
24 {
25  if (has_shift_modifier()) {
26  return;
27  } else {
29  }
30 }
33  editor_display& disp, const SDL_Event& event)
34 {
35  editor_action* ret = mouse_action::key_event(disp, event);
37  return ret;
38 }
41  editor_display& /*disp*/, const std::set<map_location>& hexes)
42 {
43  if (has_ctrl_modifier())
44  return new editor_action_chain(new editor_action_deselect(hexes));
45  else
46  return new editor_action_chain(new editor_action_select(hexes));
47 }
50  editor_display& /*disp*/, const std::set<map_location>& /*hexes*/)
51 {
52  return nullptr;
53 }
56 {
57  return nullptr;
58 }
61 {
62  surface image;
63  if (has_shift_modifier()) {
64  image = image::get_image("editor/tool-overlay-select-wand.png");
65  } else {
66  image = image::get_image("editor/tool-overlay-select-brush.png");
67  }
68  uint8_t alpha = 196;
69  int size = image->w;
70  int zoom = static_cast<int>(size * disp.get_zoom_factor());
72  // Add the alpha factor and scale the image
73  adjust_surface_alpha(image, alpha);
74  image = scale_surface(image, zoom, zoom);
75  disp.set_mouseover_hex_overlay(image);
76 }
79 } //end namespace editor
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
Definition: picture.cpp:833
const editor_map & map() const
map_location previous_move_hex_
The hex previously used in move operations.
static double get_zoom_factor()
Returns the current zoom factor.
Definition: display.hpp:258
virtual void set_mouse_overlay(editor_display &disp) override
Set the mouse overlay for this action.
Container action wrapping several actions into one.
Definition: action.hpp:90
surface scale_surface(const surface &surf, int w, int h)
Scale a surface using alpha-weighted modified bilinear filtering Note: causes artifacts with alpha gr...
Definition: utils.cpp:196
editor_action * click_perform_left(editor_display &disp, const std::set< map_location > &hexes) override
Left click/drag selects.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
void adjust_surface_alpha(surface &surf, fixed_t amount)
Definition: utils.cpp:1086
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.
editor_action * click_right(editor_display &disp, int x, int y) override
Right click does nothing for now.
std::set< map_location > affected_hexes(editor_display &disp, const map_location &hex) override
Overridden to allow special behavior based on modifier keys.
bool has_shift_modifier() const
Select the given locations.
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.
Definition: editor_map.cpp:115
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...
void set_mouseover_hex_overlay(const surface &image)
mouseover_hex_overlay_ require a prerendered surface and is drawn underneath the mouse&#39;s location ...
Definition: display.hpp:443
Manage the empty-palette in the editor.
Definition: action.cpp:29
Encapsulates the map of the game.
Definition: location.hpp:42
Base class for all editor actions.
Definition: action_base.hpp:40
editor_action * click_perform_right(editor_display &disp, const std::set< map_location > &hexes) override
Right click/drag.
this module manages the cache of images.
bool has_ctrl_modifier() const
Deselect the given locations.
Editor action classes.
editor_action * key_event(editor_display &disp, const SDL_Event &e) override
Force a fake "move" event to update brush overlay on key event.
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 ...