mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r11092) -Add: allow 'blitter=<value>' in openttd.cfg to set the blitter (so you don't have to keep on doing 'openttd -b 32bpp-optimized'..)
This commit is contained in:
parent
1e4f8d7a23
commit
f1336fba68
|
@ -4,6 +4,7 @@
|
|||
#define BLITTER_FACTORY_HPP
|
||||
|
||||
#include "base.hpp"
|
||||
#include "../string.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
|
@ -61,12 +62,15 @@ public:
|
|||
*/
|
||||
static Blitter *SelectBlitter(const char *name)
|
||||
{
|
||||
const char *default_blitter = "8bpp-optimized";
|
||||
|
||||
if (GetBlitters().size() == 0) return NULL;
|
||||
const char *bname = (StrEmpty(name)) ? default_blitter : name;
|
||||
|
||||
Blitters::iterator it = GetBlitters().begin();
|
||||
for (; it != GetBlitters().end(); it++) {
|
||||
BlitterFactoryBase *b = (*it).second;
|
||||
if (strcasecmp(name, b->name) == 0) {
|
||||
if (strcasecmp(bname, b->name) == 0) {
|
||||
Blitter *newb = b->CreateInstance();
|
||||
delete *GetActiveBlitter();
|
||||
*GetActiveBlitter() = newb;
|
||||
|
|
|
@ -89,8 +89,6 @@ extern Player* DoStartupNewPlayer(bool is_ai);
|
|||
extern void ShowOSErrorBox(const char *buf);
|
||||
extern void SetDefaultRailGui();
|
||||
|
||||
const char *_default_blitter = "8bpp-optimized";
|
||||
|
||||
/* TODO: usrerror() for errors which are not of an internal nature but
|
||||
* caused by the user, i.e. missing files or fatal configuration errors.
|
||||
* Post-0.4.0 since Celestar doesn't want this in SVN before. --pasky */
|
||||
|
@ -474,7 +472,7 @@ int ttd_main(int argc, char *argv[])
|
|||
if (!StrEmpty(musicdriver)) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
|
||||
if (!StrEmpty(sounddriver)) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
|
||||
if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
|
||||
if (StrEmpty(blitter)) ttd_strlcpy(blitter, _default_blitter, sizeof(blitter));
|
||||
if (!StrEmpty(blitter)) ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter));
|
||||
if (resolution[0] != 0) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
|
||||
if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
|
||||
if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed;
|
||||
|
@ -519,9 +517,11 @@ int ttd_main(int argc, char *argv[])
|
|||
/* Initialize game palette */
|
||||
GfxInitPalettes();
|
||||
|
||||
DEBUG(misc, 1, "Loading blitter '%s'...", blitter);
|
||||
if (BlitterFactoryBase::SelectBlitter(blitter) == NULL)
|
||||
error("Failed to select requested blitter '%s'; does it exist?", blitter);
|
||||
DEBUG(misc, 1, "Loading blitter...");
|
||||
if (BlitterFactoryBase::SelectBlitter(_ini_blitter) == NULL)
|
||||
StrEmpty(_ini_blitter) ?
|
||||
error("Failed to autoprobe blitter") :
|
||||
error("Failed to select requested blitter '%s'; does it exist?", _ini_blitter);
|
||||
|
||||
DEBUG(driver, 1, "Loading drivers...");
|
||||
|
||||
|
|
|
@ -1245,6 +1245,7 @@ static const SettingDescGlobVarList _misc_settings[] = {
|
|||
SDTG_STR("videodriver", SLE_STRB,C|S,0, _ini_videodriver, NULL, STR_NULL, NULL),
|
||||
SDTG_STR("musicdriver", SLE_STRB,C|S,0, _ini_musicdriver, NULL, STR_NULL, NULL),
|
||||
SDTG_STR("sounddriver", SLE_STRB,C|S,0, _ini_sounddriver, NULL, STR_NULL, NULL),
|
||||
SDTG_STR("blitter", SLE_STRB,C|S,0, _ini_blitter, NULL, STR_NULL, NULL),
|
||||
SDTG_STR("language", SLE_STRB, S, 0, _dynlang.curr_file, NULL, STR_NULL, NULL),
|
||||
SDTG_LIST("resolution", SLE_UINT16, S, 0, _cur_resolution, "640,480", STR_NULL, NULL),
|
||||
SDTG_STR("screenshot_format",SLE_STRB, S, 0, _screenshot_format_name,NULL, STR_NULL, NULL),
|
||||
|
|
|
@ -315,7 +315,7 @@ VARDEF SmallFiosItem _file_to_saveload;
|
|||
|
||||
VARDEF Vehicle *_place_clicked_vehicle;
|
||||
|
||||
VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32];
|
||||
VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32], _ini_blitter[32];
|
||||
|
||||
VARDEF int _num_resolutions;
|
||||
VARDEF uint16 _resolutions[32][2];
|
||||
|
|
Loading…
Reference in New Issue