|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
18 #include "table/strings.h"
52 if (parm.empty())
return nullptr;
54 size_t len = strlen(name);
55 for (
auto &p : parm) {
56 if (p.compare(0, len, name) == 0) {
57 if (p.length() == len)
return "";
58 if (p[len] ==
'=')
return p.c_str() + len + 1;
85 return p !=
nullptr ? atoi(p) : def;
131 if (!filename.empty()) {
132 unlink(filename.c_str());
137 ErrorMessageData msg(STR_VIDEO_DRIVER_ERROR, STR_VIDEO_DRIVER_ERROR_HARDWARE_ACCELERATION_CRASH,
true);
151 const char *err = newd->
Start({});
152 if (err ==
nullptr) {
164 ErrorMessageData msg(STR_VIDEO_DRIVER_ERROR, STR_VIDEO_DRIVER_ERROR_NO_HARDWARE_ACCELERATION,
true);
172 std::istringstream buffer(
name);
174 std::getline(buffer, dname,
':');
177 std::vector<std::string> parms;
178 while (std::getline(buffer, param,
',')) {
179 parms.push_back(param);
195 const char *err = newd->
Start(parms);
196 if (err !=
nullptr) {
198 UserError(
"Unable to load driver '{}'. The error was: {}", d->
name, err);
219 if (!filename.empty()) unlink(filename.c_str());
240 fmt::format_to(output_iterator,
"\n");
252 type(type), priority(priority), name(name), description(description)
258 assert(drivers.find(typed_name) == drivers.end());
259 drivers.insert(Drivers::value_type(typed_name,
this));
270 Drivers::iterator it =
GetDrivers().find(typed_name);
static const char * GetDriverTypeName(Driver::Type type)
Get the driver type name.
static bool SelectDriverImpl(const std::string &name, Driver::Type type)
Find the requested driver and return its class.
static Driver ** GetActiveDriver(Driver::Type type)
Get the active driver for the given type.
Dimensions (a width and height) of a rectangle in 2D.
void ScheduleErrorMessage(ErrorList &datas)
Schedule a list of errors.
const char * name
The name of the drivers of this factory.
std::string FioFindFullPath(Subdirectory subdir, const std::string &filename)
Find a path to the filename in one of the search directories.
std::string _ini_blitter
The blitter as stored in the configuration file.
DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description)
Construct a new DriverFactory.
virtual Driver * CreateInstance() const =0
Create an instance of this driver-class.
virtual ~DriverFactoryBase()
Frees memory used for this->name.
static void GetDriversInfo(std::back_insert_iterator< std::string > &output_iterator)
Build a human readable list of available drivers, grouped by type.
const char * GetDriverParam(const StringList &parm, const char *name)
Get a string parameter the list of parameters.
static Drivers & GetDrivers()
Get the map with drivers.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
std::string _ini_musicdriver
The music driver a stored in the configuration file.
@ BASE_DIR
Base directory for all subdirectories.
int priority
The priority of this factory.
std::map< std::string, DriverFactoryBase * > Drivers
Type for a map of drivers.
FILE * FioFOpenFile(const std::string &filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
virtual const char * Start(const StringList &parm)=0
Start this driver.
Driver::Type type
The type of driver.
std::vector< std::string > StringList
Type for a list of strings.
std::vector< Dimension > _resolutions
List of resolutions.
The data of the error message.
@ DT_END
Helper for iteration.
int GetDriverParamInt(const StringList &parm, const char *name, int def)
Get an integer parameter the list of parameters.
bool _rightclick_emulate
Whether right clicking is emulated.
@ DT_BEGIN
Helper for iteration.
@ DT_VIDEO
A video driver.
bool _blitter_autodetected
Was the blitter autodetected or specified by the user?
std::string _ini_sounddriver
The sound driver a stored in the configuration file.
bool _video_hw_accel
Whether to consider hardware accelerated video drivers.
virtual bool UsesHardwareAcceleration() const
Does the driver use hardware acceleration (video-drivers only).
const char * GetDescription() const
Get a nice description of the driver-class.
bool StrEqualsIgnoreCase(const std::string_view str1, const std::string_view str2)
Compares two string( view)s for equality, while ignoring the case of the characters.
static void SelectDriver(const std::string &name, Driver::Type type)
Find the requested driver and return its class.
A driver for communicating with the user.
bool GetDriverParamBool(const StringList &parm, const char *name)
Get a boolean parameter the list of parameters.
Dimension _cur_resolution
The current resolution.
Base for all driver factories.
std::string _ini_videodriver
The video driver a stored in the configuration file.
static void MarkVideoDriverOperational()
Mark the current video driver as operational.
void FioFCloseFile(FILE *f)
Close a file in a safe way.
static const std::string HWACCELERATION_TEST_FILE
Filename to test if we crashed last time we tried to use hardware acceleration.