The Battle for Wesnoth  1.13.4+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 - 2016 by Fabian Mueller <[email protected]>
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 
15 #include "mouse_action_select.hpp"
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  image = scale_surface(adjust_surface_alpha(image, alpha), zoom, zoom);
74  disp.set_mouseover_hex_overlay(image);
75 }
76 
77 
78 } //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:878
bool has_shift_modifier() const
editor_action * click_right(editor_display &disp, int x, int y)
Right click does nothing for now.
map_location previous_move_hex_
The hex previously used in move operations.
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glew.h:3783
double get_zoom_factor() const
Returns the current zoom factor.
Definition: display.hpp:269
Container action wrapping several actions into one.
Definition: action.hpp:79
surface scale_surface(const surface &surf, int w, int h)
Definition: utils.cpp:443
bool has_ctrl_modifier() const
virtual void set_mouse_overlay(editor_display &disp)
Set the mouse overlay for this 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.
Definition: editor_map.cpp:126
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 * key_event(editor_display &disp, const SDL_Event &e)
Force a fake "move" event to update brush overlay on key event.
surface adjust_surface_alpha(const surface &surf, fixed_t amount, bool optimize)
Definition: utils.cpp:1202
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...
GLclampf GLclampf GLclampf alpha
Definition: glew.h:1488
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:458
Manage the empty-palette in the editor.
Definition: action.cpp:28
Encapsulates the map of the game.
Definition: location.hpp:38
editor_action * click_perform_right(editor_display &disp, const std::set< map_location > &hexes)
Right click/drag.
Base class for all editor actions.
Definition: action_base.hpp:41
std::set< map_location > affected_hexes(editor_display &disp, const map_location &hex)
Overridden to allow special behavior based on modifier keys.
GLsizeiptr size
Definition: glew.h:1649
cl_event event
Definition: glew.h:3070
Deselect the given locations.
editor_action * click_perform_left(editor_display &disp, const std::set< map_location > &hexes)
Left click/drag selects.
Editor action classes.
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 ...