1 /*
2  * Copyright (C) 2012-2020 by the Widelands Development Team
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  *
18  */
19 
20 #ifndef WL_EDITOR_TOOLS_ACTION_ARGS_H
21 #define WL_EDITOR_TOOLS_ACTION_ARGS_H
22 
23 #include "logic/field.h"
24 #include "logic/map.h"
25 #include "logic/widelands_geometry.h"
26 
27 namespace Widelands {
28 class BobDescr;
29 }  // namespace Widelands
30 
31 class EditorInteractive;
32 struct EditorToolAction;
33 
34 /// Class to save important and changeable properties of classes needed for actions
35 // Implementations in editor_history.cc
36 struct EditorActionArgs {
37 	explicit EditorActionArgs(EditorInteractive& base);
38 
39 	// TODO(sirver): This class does its own reference counting. This design is
40 	// brittle and on a quick overview I have a feeling that it might not be
41 	// correct.
42 	EditorActionArgs(const EditorActionArgs&) = default;
43 	EditorActionArgs& operator=(const EditorActionArgs&) = default;
44 
45 	~EditorActionArgs();
46 
47 	uint32_t sel_radius;
48 
49 	int32_t change_by;                                     // resources, change height tools
50 	std::list<Widelands::Field::Height> original_heights;  // change height tool
51 	Widelands::DescriptionIndex current_resource;          // resources change tools
52 	Widelands::ResourceAmount set_to;                      // resources change tools
53 	Widelands::Extent new_map_size;                        // resize tool
54 
55 	struct ResourceState {
56 		Widelands::Coords location;
57 		Widelands::DescriptionIndex idx;
58 		Widelands::ResourceAmount amount;
59 	};
60 
61 	std::list<ResourceState> original_resource;                         // resources set tool
62 	std::list<const Widelands::BobDescr *> old_bob_type, new_bob_type;  // bob change tools
63 	std::list<std::string> old_immovable_types;                         // immovable change tools
64 	std::list<Widelands::DescriptionIndex> new_immovable_types;         // immovable change tools
65 	Widelands::HeightInterval interval;                                 // noise height tool
66 	std::list<Widelands::DescriptionIndex> terrain_type, original_terrain_type;  // set terrain tool
67 	Widelands::ResizeHistory resized;                                            // resize tool
68 
69 	std::list<EditorToolAction*> draw_actions;  // draw tool
70 
71 	uint32_t refcount;
72 };
73 
74 #endif  // end of include guard: WL_EDITOR_TOOLS_ACTION_ARGS_H
75