OpenTTD Source 20260218-master-g2123fca5ea
game_scanner.hpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD 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, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef GAME_SCANNER_HPP
11#define GAME_SCANNER_HPP
12
14
16class GameScannerInfo : public ScriptScanner {
17public:
18 void Initialize() override;
19
27 class GameInfo *FindInfo(const std::string &name, int version, bool force_exact_match);
28
29protected:
30 std::string GetScriptName(ScriptInfo &info) override;
31 std::string_view GetFileName() const override { return PATHSEP "info.nut"; }
32 Subdirectory GetDirectory() const override { return GAME_DIR; }
33 std::string_view GetScannerName() const override { return "Game Scripts"; }
34 void RegisterAPI(class Squirrel &engine) override;
35};
36
37
39class GameScannerLibrary : public ScriptScanner {
40public:
41 void Initialize() override;
42
49 class GameLibrary *FindLibrary(const std::string &library, int version);
50
51protected:
52 std::string GetScriptName(ScriptInfo &info) override;
53 std::string_view GetFileName() const override { return PATHSEP "library.nut"; }
54 Subdirectory GetDirectory() const override { return GAME_LIBRARY_DIR; }
55 std::string_view GetScannerName() const override { return "GS Libraries"; }
56 void RegisterAPI(class Squirrel &engine) override;
57};
58
59#endif /* GAME_SCANNER_HPP */
All static information from an Game like name, version, etc.
Definition game_info.hpp:16
All static information from an Game library like name, version, etc.
Definition game_info.hpp:58
Game instantiation of a ScriptScanner.
std::string_view GetFileName() const override
Get the filename to scan for this type of script.
std::string GetScriptName(ScriptInfo &info) override
Get the script name how to store the script in memory.
void Initialize() override
Initialize the scanner by scanning for scripts and creating dummies if needed.
Subdirectory GetDirectory() const override
Get the directory to scan in.
void RegisterAPI(class Squirrel &engine) override
Register the API for this ScriptInfo.
class GameInfo * FindInfo(const std::string &name, int version, bool force_exact_match)
Check if we have a game by name and version available in our list.
std::string_view GetScannerName() const override
Get the type of the script, in plural.
Game instantiation of a ScriptScanner for libraries.
void Initialize() override
Initialize the scanner by scanning for scripts and creating dummies if needed.
std::string GetScriptName(ScriptInfo &info) override
Get the script name how to store the script in memory.
std::string_view GetFileName() const override
Get the filename to scan for this type of script.
class GameLibrary * FindLibrary(const std::string &library, int version)
Find a library in the pool.
Subdirectory GetDirectory() const override
Get the directory to scan in.
void RegisterAPI(class Squirrel &engine) override
Register the API for this ScriptInfo.
std::string_view GetScannerName() const override
Get the type of the script, in plural.
All static information from an Script like name, version, etc.
std::unique_ptr< class Squirrel > engine
The engine we're scanning with.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition fileio_type.h:88
@ GAME_LIBRARY_DIR
Subdirectory for all GS libraries.
@ GAME_DIR
Subdirectory for all game scripts.
Declarations of the class for the script scanner.