The Battle for Wesnoth  1.19.5+dev
mouse_action_select.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  by Fabian Mueller <fabianmueller5@gmx.de>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
18 
20 
21 namespace editor {
22 
23 std::set<map_location> mouse_action_select::affected_hexes(
24  editor_display& disp, const map_location& hex)
25 {
26  if (has_shift_modifier()) {
27  return disp.get_map().get_contiguous_terrain_tiles(hex);
28  } else {
30  }
31 }
32 
33 std::unique_ptr<editor_action> mouse_action_select::key_event(
34  editor_display& disp, const SDL_Event& event)
35 {
36  auto ret = mouse_action::key_event(disp, event);
38  return ret;
39 }
40 
41 std::unique_ptr<editor_action> mouse_action_select::click_perform_left(
42  editor_display& /*disp*/, const std::set<map_location>& hexes)
43 {
44  auto chain = std::make_unique<editor_action_chain>();
45  if (has_ctrl_modifier())
46  chain->append_action(std::make_unique<editor_action_deselect>(hexes));
47  else
48  chain->append_action(std::make_unique<editor_action_select>(hexes));
49  return chain;
50 }
51 
52 std::unique_ptr<editor_action> mouse_action_select::click_perform_right(
53  editor_display& /*disp*/, const std::set<map_location>& /*hexes*/)
54 {
55  return nullptr;
56 }
57 
58 std::unique_ptr<editor_action> mouse_action_select::click_right(editor_display& /*disp*/, int /*x*/, int /*y*/)
59 {
60  return nullptr;
61 }
62 
64 {
65  texture tex;
66  if (has_shift_modifier()) {
67  tex = image::get_texture(image::locator{"editor/tool-overlay-select-wand.png"});
68  } else {
69  tex = image::get_texture(image::locator{"editor/tool-overlay-select-brush.png"});
70  }
71  disp.set_mouseover_hex_overlay(tex);
72 }
73 
74 
75 } //end namespace editor
Editor action classes.
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 ...
void set_mouseover_hex_overlay(const texture &image)
Sets texture to be drawn in hex under the mouse's location.
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.
Definition: editor_map.cpp:115
std::unique_ptr< editor_action > click_perform_right(editor_display &disp, const std::set< map_location > &hexes) override
Right click/drag.
std::unique_ptr< 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.
virtual void set_mouse_overlay(editor_display &disp) override
Set the mouse overlay for this action.
std::unique_ptr< editor_action > click_perform_left(editor_display &disp, const std::set< map_location > &hexes) override
Left click/drag selects.
std::unique_ptr< editor_action > key_event(editor_display &disp, const SDL_Event &e) override
Force a fake "move" event to update brush overlay on key event.
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.
bool has_ctrl_modifier() const
map_location previous_move_hex_
The hex previously used in move operations.
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.
Generic locator abstracting the location of an image.
Definition: picture.hpp:59
Wrapper class to encapsulate creation and management of an SDL_Texture.
Definition: texture.hpp:33
Manage the empty-palette in the editor.
Definition: action.cpp:31
texture get_texture(const image::locator &i_locator, TYPE type, bool skip_cache)
Returns an image texture suitable for hardware-accelerated rendering.
Definition: picture.cpp:920
Encapsulates the map of the game.
Definition: location.hpp:45