Go to the documentation of this file.
10 #ifndef SCRIPT_SCANNER_HPP
11 #define SCRIPT_SCANNER_HPP
14 #include "../fileio_func.h"
15 #include "../core/string_compare_type.hpp"
17 typedef std::map<const char *, class ScriptInfo *, StringCompare>
ScriptInfoList;
25 virtual void Initialize() = 0;
60 char *
GetConsoleList(
char *p,
const char *last,
bool newest_only)
const;
78 bool AddFile(
const std::string &filename,
size_t basepath_length,
const std::string &tar_filename)
override;
virtual void GetScriptName(ScriptInfo *info, char *name, const char *last)=0
Get the script name how to store the script in memory.
class Squirrel * engine
The engine we're scanning with.
std::string GetMainScript()
Get the current main script the ScanDir is currently tracking.
virtual void RegisterAPI(class Squirrel *engine)=0
Register the API for this ScriptInfo.
std::string tar_file
If, which tar file the script was in.
char * GetConsoleList(char *p, const char *last, bool newest_only) const
Get the list of registered scripts to print on the console.
void RescanDir()
Rescan the script dir.
void ResetEngine()
Reset the engine to ensure a clean environment for further steps.
const ScriptInfoList * GetUniqueInfoList()
Get the list of the latest version of all registered scripts.
void Initialize()
Perform all initialization steps to create the engine.
std::map< const char *, class ScriptInfo *, StringCompare > ScriptInfoList
A list that maps AI names to their AIInfo object.
virtual const char * GetFileName() const =0
Get the filename to scan for this type of script.
Container for all important information about a piece of content.
bool AddFile(const std::string &filename, size_t basepath_length, const std::string &tar_filename) override
Add a file with the given filename.
Scanner to help finding scripts.
std::map< const char *, class ScriptInfo *, StringCompare > ScriptInfoList
Type for the list of scripts.
class Squirrel * GetEngine()
Get the engine of the main squirrel handler (it indexes all available scripts).
std::string main_script
The full path of the script.
bool HasScript(const struct ContentInfo *ci, bool md5sum)
Check whether we have a script with the exact characteristics as ci.
ScriptInfoList info_list
The list of all script.
const ScriptInfoList * GetInfoList()
Get the list of all registered scripts.
virtual const char * GetScannerName() const =0
Get the type of the script, in plural.
void RegisterScript(class ScriptInfo *info)
Register a ScriptInfo to the scanner.
void Reset()
Reset all allocated lists.
virtual Subdirectory GetDirectory() const =0
Get the directory to scan in.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Helper for scanning for files with a given name.
const char * FindMainScript(const ContentInfo *ci, bool md5sum)
Find a script of a ContentInfo.
std::string GetTarFile()
Get the current tar file the ScanDir is currently tracking.
All static information from an Script like name, version, etc.
ScriptInfoList info_single_list
The list of all unique script. The best script (highest version) is shown.