OpenTTD Source: src/game/game_scanner.hpp Source File

OpenTTD Source 14.0-beta1

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 <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef GAME_SCANNER_HPP
11 #define GAME_SCANNER_HPP
12
13 #include "../script/script_scanner.hpp"
14
15 class GameScannerInfo : public ScriptScanner {
16 public:
17 void Initialize() override;
18
26 class GameInfo *FindInfo(const std::string &name, int version, bool force_exact_match);
27
28 protected:
29 std::string GetScriptName(ScriptInfo *info) override;
30 const char *GetFileName() const override { return PATHSEP "info.nut"; }
31 Subdirectory GetDirectory() const override { return GAME_DIR; }
32 const char *GetScannerName() const override { return "Game Scripts"; }
33 void RegisterAPI(class Squirrel *engine) override;
34 };
35
36
37 class GameScannerLibrary : public ScriptScanner {
38 public:
39 void Initialize() override;
40
47 class GameLibrary *FindLibrary(const std::string &library, int version);
48
49 protected:
50 std::string GetScriptName(ScriptInfo *info) override;
51 const char *GetFileName() const override { return PATHSEP "library.nut"; }
52 Subdirectory GetDirectory() const override { return GAME_LIBRARY_DIR; }
53 const char *GetScannerName() const override { return "GS Libraries"; }
54 void RegisterAPI(class Squirrel *engine) override;
55 };
56
57 #endif /* GAME_SCANNER_HPP */
GameScannerInfo::GetScannerName
const char * GetScannerName() const override
Get the type of the script, in plural.
Definition: game_scanner.hpp:32
GameScannerInfo::GetScriptName
std::string GetScriptName(ScriptInfo *info) override
Get the script name how to store the script in memory.
Definition: game_scanner.cpp:26
GameScannerLibrary::FindLibrary
class GameLibrary * FindLibrary(const std::string &library, int version)
Find a library in the pool.
Definition: game_scanner.cpp:89
ScriptScanner::engine
class Squirrel * engine
The engine we're scanning with.
Definition: script_scanner.hpp:87
GAME_LIBRARY_DIR
@ GAME_LIBRARY_DIR
Subdirectory for all GS libraries.
Definition: fileio_type.h:122
GameScannerInfo
Definition: game_scanner.hpp:15
GameScannerLibrary::GetFileName
const char * GetFileName() const override
Get the filename to scan for this type of script.
Definition: game_scanner.hpp:51
GameScannerLibrary::GetScannerName
const char * GetScannerName() const override
Get the type of the script, in plural.
Definition: game_scanner.hpp:53
ScriptInfo::version
int version
Version of the script.
Definition: script_info.hpp:152
Squirrel
Definition: squirrel.hpp:23
GameScannerInfo::RegisterAPI
void RegisterAPI(class Squirrel *engine) override
Register the API for this ScriptInfo.
Definition: game_scanner.cpp:31
ScriptScanner
Scanner to help finding scripts.
Definition: script_scanner.hpp:19
GAME_DIR
@ GAME_DIR
Subdirectory for all game scripts.
Definition: fileio_type.h:121
GameScannerLibrary::GetDirectory
Subdirectory GetDirectory() const override
Get the directory to scan in.
Definition: game_scanner.hpp:52
GameScannerLibrary::GetScriptName
std::string GetScriptName(ScriptInfo *info) override
Get the script name how to store the script in memory.
Definition: game_scanner.cpp:78
GameInfo
All static information from an Game like name, version, etc.
Definition: game_info.hpp:16
ScriptInfo::name
std::string name
Full name of the script.
Definition: script_info.hpp:147
GameScannerInfo::FindInfo
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.
Definition: game_scanner.cpp:36
Subdirectory
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:108
GameScannerLibrary::RegisterAPI
void RegisterAPI(class Squirrel *engine) override
Register the API for this ScriptInfo.
Definition: game_scanner.cpp:84
GameLibrary
All static information from an Game library like name, version, etc.
Definition: game_info.hpp:49
GameScannerLibrary
Definition: game_scanner.hpp:37
ScriptInfo
All static information from an Script like name, version, etc.
Definition: script_info.hpp:30
GameScannerInfo::GetFileName
const char * GetFileName() const override
Get the filename to scan for this type of script.
Definition: game_scanner.hpp:30
GameScannerInfo::GetDirectory
Subdirectory GetDirectory() const override
Get the directory to scan in.
Definition: game_scanner.hpp:31