The Battle for Wesnoth
1.13.4+dev
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
editor
action
action_village.hpp
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
/**
16
* @file
17
* Editor action classes. Some important points:
18
* - This is a polymorphic hierarchy of classes, so actions are usually passed around
19
* as editor_action pointers
20
* - The pointers can, in general, be null. Always check for null before doing anything.
21
* The helper functions perform_ that take a pointer do that.
22
* - The perform() functions can throw when an error occurs. Use smart pointers if you
23
* need to ensure the pointer is deleted.
24
*/
25
26
#ifndef EDITOR_ACTION_VILLAGE_HPP
27
#define EDITOR_ACTION_VILLAGE_HPP
28
29
#include "
action.hpp
"
30
31
32
namespace
editor
{
33
34
/**
35
* Sets the ownership of a village to the current side.
36
*/
37
class
editor_action_village
:
public
editor_action_location
38
{
39
public
:
40
editor_action_village
(
map_location
loc,
int
side_number
)
41
:
editor_action_location
(loc),
side_number_
(side_number)
42
{
43
}
44
editor_action_village
*
clone
()
const
;
45
editor_action
*
perform
(
map_context
& mc)
const
;
46
void
perform_without_undo
(
map_context
& mc)
const
;
47
const
char
*
get_name
()
const
{
return
"village"
; }
48
private
:
49
int
side_number_
;
50
};
51
52
/**
53
* Clears the ownership of a village.
54
*/
55
class
editor_action_village_delete
:
public
editor_action_location
56
{
57
public
:
58
editor_action_village_delete
(
map_location
loc)
59
:
editor_action_location
(loc)
60
{
61
}
62
editor_action_village_delete
*
clone
()
const
;
63
editor_action
*
perform
(
map_context
& mc)
const
;
64
void
perform_without_undo
(
map_context
& mc)
const
;
65
const
char
*
get_name
()
const
{
return
"village_delete"
; }
66
};
67
68
69
}
//end namespace editor
70
71
#endif
editor::editor_action_village_delete::editor_action_village_delete
editor_action_village_delete(map_location loc)
Definition:
action_village.hpp:58
editor::editor_action_location
Base class for actions which act on a specified location (and possibly on other locations that can be...
Definition:
action.hpp:177
editor::editor_action_village::side_number_
int side_number_
Definition:
action_village.hpp:49
editor::editor_action_village
Sets the ownership of a village to the current side.
Definition:
action_village.hpp:37
editor::editor_action_village_delete::get_name
const char * get_name() const
Definition:
action_village.hpp:65
editor::editor_action_village::perform_without_undo
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Definition:
action_village.cpp:53
editor::editor_action_village::clone
editor_action_village * clone() const
Action cloning.
Definition:
action_village.cpp:28
editor::editor_action_village_delete::perform
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
Definition:
action_village.cpp:71
editor::editor_action_village::perform
editor_action * perform(map_context &mc) const
Perform the action, returning an undo action that, when performed, shall reverse any effects of this ...
Definition:
action_village.cpp:33
action.hpp
Editor action classes.
editor
Manage the empty-palette in the editor.
Definition:
action.cpp:28
map_location
Encapsulates the map of the game.
Definition:
location.hpp:38
editor::editor_action_village_delete::clone
editor_action_village_delete * clone() const
Action cloning.
Definition:
action_village.cpp:66
editor::editor_action
Base class for all editor actions.
Definition:
action_base.hpp:41
editor::map_context
This class wraps around a map to provide a concise interface for the editor to work with...
Definition:
map_context.hpp:41
editor::editor_action_village_delete::perform_without_undo
void perform_without_undo(map_context &mc) const
Perform the action without creating an undo action.
Definition:
action_village.cpp:86
editor::editor_action_village::get_name
const char * get_name() const
Definition:
action_village.hpp:47
editor::editor_action_village::editor_action_village
editor_action_village(map_location loc, int side_number)
Definition:
action_village.hpp:40
ai::side_number
int side_number
Definition:
game_info.hpp:44
editor::editor_action_village_delete
Clears the ownership of a village.
Definition:
action_village.hpp:55
Generated by
1.8.8