1 /*
2  * This file is part of EasyRPG Player.
3  *
4  * EasyRPG Player is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * EasyRPG Player 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 EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef EP_FILEFINDER_RTP_H
19 #define EP_FILEFINDER_RTP_H
20 
21 #include "directory_tree.h"
22 #include "rtp.h"
23 #include "string_view.h"
24 
25 class FileFinder_RTP {
26 public:
27 	/**
28 	 * Manages RTP folders.
29 	 *
30 	 * @param no_rtp If true disables RTP support completely
31 	 * @param no_rtp_warnings If true disables warnings when a RTP asset is used
32 	 * @param rtp_path Custom RTP path to use
33 	 */
34 	FileFinder_RTP(bool no_rtp, bool no_rtp_warnings, std::string rtp_path);
35 
36 	/**
37 	 * Looks up a file in the list of RTPs
38 	 *
39 	 * @param dir Directory containing the file
40 	 * @param name Filename
41 	 * @param exts Extensions to probe
42 	 * @return A handle to the file or an invalid handle if not found
43 	 */
44 	 Filesystem_Stream::InputStream Lookup(StringView dir, StringView name, Span<StringView> exts) const;
45 
46 private:
47 	void AddPath(StringView p);
48 	void ReadRegistry(StringView company, StringView product, StringView key);
49 	Filesystem_Stream::InputStream LookupInternal(StringView dir, StringView name, Span<StringView> exts, bool& is_rtp_asset) const;
50 
51 	using search_path_list = std::vector<FilesystemView>;
52 
53 	/** all RTP search paths */
54 	search_path_list search_paths;
55 	/** RTP was disabled with --disable-rtp */
56 	bool disable_rtp = true;
57 	/** Game has FullPackageFlag=1, RTP will still be used as RPG_RT does */
58 	bool game_has_full_package_flag = false;
59 	/** warning about "game has FullPackageFlag=1 but needs RTP" shown */
60 	mutable bool warning_broken_rtp_game_shown = false;
61 	/** RTP candidates per search_path */
62 	std::vector<RTP::RtpHitInfo> detected_rtp;
63 	/** the RTP the game uses, when only one left the RTP of the game is known */
64 	mutable std::vector<RTP::Type> game_rtp;
65 };
66 
67 #endif
68