-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
action_label.hpp
73 lines (64 loc) · 2.32 KB
/
action_label.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
Copyright (C) 2010 - 2017 by Fabian Mueller <fabianmueller5@gmx.de>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
/**
* @file
* Editor action classes. Some important points:
* - This is a polymorphic hierarchy of classes, so actions are usually passed around
* as editor_action pointers
* - The pointers can, in general, be null. Always check for null before doing anything.
* The helper functions perform_ that take a pointer do that.
* - The perform() functions can throw when an error occurs. Use smart pointers if you
* need to ensure the pointer is deleted.
*/
#pragma once
#include "color.hpp"
#include "editor/action/action.hpp"
#include "map/map.hpp"
namespace editor {
/**
* Set label action
*/
class editor_action_label : public editor_action_location
{
public:
editor_action_label(map_location loc, const std::string& text, const std::string& team_name,
color_t color, bool visible_fog, bool visible_shroud, bool immutable, std::string category)
: editor_action_location(loc), text_(text) , team_name_(team_name), category_(category), color_(color)
, visible_fog_(visible_fog), visible_shroud_(visible_shroud), immutable_(immutable)
{
}
editor_action_label* clone() const;
editor_action* perform(map_context& mc) const;
void perform_without_undo(map_context& mc) const;
const char* get_name() const { return "label"; }
protected:
const std::string text_;
const std::string team_name_;
const std::string category_;
color_t color_;
bool visible_fog_;
bool visible_shroud_;
bool immutable_;
};
class editor_action_label_delete : public editor_action_location
{
public:
editor_action_label_delete(map_location loc)
: editor_action_location(loc)
{
}
editor_action_label_delete* clone() const;
editor_action* perform(map_context& mc) const;
void perform_without_undo(map_context& mc) const;
const char* get_name() const { return "label_delete"; }
};
} //end namespace editor