1 /*
2  * Copyright (C) 2002-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_LOGIC_MAP_OBJECTS_TRIBES_TRIBE_BASIC_INFO_H
21 #define WL_LOGIC_MAP_OBJECTS_TRIBES_TRIBE_BASIC_INFO_H
22 
23 #include <memory>
24 
25 #include "scripting/lua_table.h"
26 
27 namespace Widelands {
28 
29 /// Basic information about the tribe that is determined only from the conf
30 /// file and needed before the actual game.
31 struct TribeBasicInfo {
32 
33 	/// Script path and localized name for a starting condition
34 	struct Initialization {
InitializationTribeBasicInfo::Initialization35 		Initialization(const std::string& init_script,
36 		               const std::string& init_descname,
37 		               const std::string& init_tooltip,
38 		               const std::set<std::string>& tags)
39 		   : script(init_script),
40 		     descname(init_descname),
41 		     tooltip(init_tooltip),
42 		     required_map_tags(tags) {
43 		}
44 		std::string script;
45 		std::string descname;
46 		std::string tooltip;
47 		std::set<std::string> required_map_tags;
48 	};
49 
50 	explicit TribeBasicInfo(std::unique_ptr<LuaTable> table);
51 
52 	/// Internal name to reference this tribe
53 	std::string name;
54 	/// Who designed this tribe
55 	std::string author;
56 	/// Name to present to the user
57 	std::string descname;
58 	/// Basic information about this tribe
59 	std::string tooltip;
60 	/// Filepath of the tribe's icon
61 	std::string icon;
62 
63 	std::vector<Initialization> initializations;
64 };
65 
66 /// Returns a string vector with the names of all tribes.
67 std::vector<std::string> get_all_tribenames();
68 
69 /// Returns a vector with the basic info for all tribes.
70 std::vector<TribeBasicInfo> get_all_tribeinfos();
71 
72 /// Returns the basic preload info for a tribe.
73 TribeBasicInfo get_tribeinfo(const std::string& tribename);
74 
75 /// Returns whether this tribe is listed in tribes/preload.lua.
76 bool tribe_exists(const std::string& tribename);
77 
78 }  // namespace Widelands
79 
80 #endif  // end of include guard: WL_LOGIC_MAP_OBJECTS_TRIBES_TRIBE_BASIC_INFO_H
81