The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
mouse_action_select.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2017 by Fabian Mueller <fabianmueller5@gmx.de>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
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,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
17 
19 
20 namespace editor {
21 
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 disp.map().get_contiguous_terrain_tiles(hex);
27  } else {
29  }
30 }
31 
33  editor_display& disp, const SDL_Event& event)
34 {
35  editor_action* ret = mouse_action::key_event(disp, event);
37  return ret;
38 }
39 
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 }
48 
50  editor_display& /*disp*/, const std::set<map_location>& /*hexes*/)
51 {
52  return nullptr;
53 }
54 
56 {
57  return nullptr;
58 }
59 
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 alpha = 196;
69  int size = image->w;
70  int zoom = static_cast<int>(size * disp.get_zoom_factor());
71 
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 }
77 
78 
79 } //end namespace editor
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
Definition: image.cpp:926
bool has_shift_modifier() const
map_location previous_move_hex_
The hex previously used in move operations.
double get_zoom_factor() const
Returns the current zoom factor.
Definition: display.hpp:262
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:262
editor_action * click_perform_left(editor_display &disp, const std::set< map_location > &hexes) override
Left click/drag selects.
bool has_ctrl_modifier() 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.
Definition: editor_map.cpp:116
void adjust_surface_alpha(surface &surf, fixed_t amount)
Definition: utils.cpp:1162
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.
Select the given locations.
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's location ...
Definition: display.hpp:442
Manage the empty-palette in the editor.
Definition: action.cpp:29
Encapsulates the map of the game.
Definition: location.hpp:40
size_t size(const utf8::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
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.
Definition: image.cpp:109
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.
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 ...