The Battle for Wesnoth  1.19.5+dev
mouse_action_village.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::unique_ptr<editor_action> mouse_action_village::up_left(editor_display& disp, int x, int y)
24 {
25  map_location hex = disp.hex_clicked_on(x, y);
26  if (!disp.get_map().on_board(hex)) return nullptr;
27  if (!disp.get_map().is_village(hex)) return nullptr;
28 
29  return std::make_unique<editor_action_village>(hex, disp.playing_team_index());
30 }
31 
32 std::unique_ptr<editor_action> mouse_action_village::up_right(editor_display& disp, int x, int y)
33 {
34  map_location hex = disp.hex_clicked_on(x, y);
35  if (!disp.get_map().on_board(hex)) return nullptr;
36  if (!disp.get_map().is_village(hex)) return nullptr;
37 
38  return std::make_unique<editor_action_village_delete>(hex);
39 }
40 
42 {
45  // center 60px icon on blank hex template
47  "misc/blank-hex.png",
48  "~BLIT(icons/action/editor-tool-village_60.png,6,6)"
49  )
50  )
51  );
52 }
53 
54 
55 } //end namespace editor
Editor action classes.
std::size_t playing_team_index() const
The playing team is the team whose turn it is.
Definition: display.hpp:116
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...
Definition: display.cpp:538
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::unique_ptr< editor_action > up_right(editor_display &disp, int x, int y) override
If clicked on a village hex field, unassigns it's ownership.
std::unique_ptr< editor_action > up_left(editor_display &disp, int x, int y) override
If clicked on a village hex field, assigns the ownership of it to the current side.
virtual void set_mouse_overlay(editor_display &disp) override
Set the mouse overlay for this action.
bool on_board(const map_location &loc) const
Tell if a location is on the map.
Definition: map.cpp:385
bool is_village(const map_location &loc) const
Definition: map.cpp:66
Generic locator abstracting the location of an image.
Definition: picture.hpp:59
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