OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
17 #include "table/strings.h"
43 if (parm.empty())
return nullptr;
45 size_t len = strlen(name);
46 for (
auto &p : parm) {
47 if (p.compare(0, len, name) == 0) {
48 if (p.length() == len)
return "";
49 if (p[len] ==
'=')
return p.c_str() + len + 1;
76 return p !=
nullptr ? atoi(p) : def;
122 const char *err = newd->
Start({});
123 if (err ==
nullptr) {
135 ErrorMessageData msg(STR_VIDEO_DRIVER_ERROR, STR_VIDEO_DRIVER_ERROR_NO_HARDWARE_ACCELERATION);
143 std::istringstream buffer(
name);
145 std::getline(buffer, dname,
':');
148 std::vector<std::string> parms;
149 while (std::getline(buffer, param,
',')) {
150 parms.push_back(param);
162 if (strcasecmp(dname.c_str(), d->
name) != 0)
continue;
167 const char *err = newd->
Start(parms);
168 if (err !=
nullptr) {
170 usererror(
"Unable to load driver '%s'. The error was: %s", d->
name, err);
217 type(type), priority(priority), name(name), description(description)
225 assert(drivers.find(buf) == drivers.end());
226 drivers.insert(Drivers::value_type(buf,
this));
239 Drivers::iterator it =
GetDrivers().find(buf);
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.
void CDECL usererror(const char *s,...)
Error handling for fatal user errors.
Dimensions (a width and height) of a rectangle in 2D.
const char * name
The name of the drivers of this factory.
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.
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.
std::string _ini_musicdriver
The music driver a stored in the configuration file.
int priority
The priority of this factory.
std::map< std::string, DriverFactoryBase * > Drivers
Type for a map of drivers.
static char * GetDriversInfo(char *p, const char *last)
Build a human readable list of available drivers, grouped by type.
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.
void ScheduleErrorMessage(const ErrorMessageData &data)
Schedule an error.
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.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
static void SelectDriver(const std::string &name, Driver::Type type)
Find the requested driver and return its class.
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
A driver for communicating with the user.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
#define lastof(x)
Get the last element of an fixed size array.
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.