Changeset - r21436:38079fc3bcd8
[Not reviewed]
src/blitter/32bpp_anim.cpp
Show inline comments
 
@@ -479,13 +479,13 @@ void Blitter_32bppAnim::PaletteAnimate(c
 
			anim++;
 
		}
 
		dst += _screen.pitch - this->anim_buf_width;
 
	}
 

	
 
	/* Make sure the backend redraws the whole screen */
 
	_video_driver->MakeDirty(0, 0, _screen.width, _screen.height);
 
	VideoDriver::GetInstance()->MakeDirty(0, 0, _screen.width, _screen.height);
 
}
 

	
 
Blitter::PaletteAnimation Blitter_32bppAnim::UsePaletteAnimation()
 
{
 
	return Blitter::PALETTE_ANIMATION_BLITTER;
 
}
src/bootstrap_gui.cpp
Show inline comments
 
@@ -243,13 +243,13 @@ bool HandleBootstrap()
 

	
 
	/* Finally ask the question. */
 
	new BootstrapBackground();
 
	new BootstrapAskForDownloadWindow();
 

	
 
	/* Process the user events. */
 
	_video_driver->MainLoop();
 
	VideoDriver::GetInstance()->MainLoop();
 

	
 
	/* _exit_game is used to get out of the video driver's main loop.
 
	 * In case GM_BOOTSTRAP is still set we did not exit it via the
 
	 * "download complete" event, so it was a manual exit. Obey it. */
 
	_exit_game = _game_mode == GM_BOOTSTRAP;
 
	if (_exit_game) return false;
src/console_gui.cpp
Show inline comments
 
@@ -184,13 +184,13 @@ struct IConsoleWindow : Window
 
		ResizeWindow(this, _screen.width, _screen.height / 3);
 
	}
 

	
 
	~IConsoleWindow()
 
	{
 
		_iconsole_mode = ICONSOLE_CLOSED;
 
		_video_driver->EditBoxLostFocus();
 
		VideoDriver::GetInstance()->EditBoxLostFocus();
 
	}
 

	
 
	/**
 
	 * Scroll the content of the console.
 
	 * @param amount Number of lines to scroll back.
 
	 */
 
@@ -373,13 +373,13 @@ struct IConsoleWindow : Window
 
	{
 
		this->Scroll(-wheel);
 
	}
 

	
 
	virtual void OnFocusLost()
 
	{
 
		_video_driver->EditBoxLostFocus();
 
		VideoDriver::GetInstance()->EditBoxLostFocus();
 
	}
 
};
 

	
 
int IConsoleWindow::scroll = 0;
 

	
 
void IConsoleGUIInit()
src/crashlog.cpp
Show inline comments
 
@@ -137,20 +137,20 @@ char *CrashLog::LogConfiguration(char *b
 
			" Sound set:    %s (%u)\n"
 
			" Video driver: %s\n\n",
 
			BlitterFactory::GetCurrentBlitter() == NULL ? "none" : BlitterFactory::GetCurrentBlitter()->GetName(),
 
			BaseGraphics::GetUsedSet() == NULL ? "none" : BaseGraphics::GetUsedSet()->name,
 
			BaseGraphics::GetUsedSet() == NULL ? UINT32_MAX : BaseGraphics::GetUsedSet()->version,
 
			_current_language == NULL ? "none" : _current_language->file,
 
			_music_driver == NULL ? "none" : _music_driver->GetName(),
 
			MusicDriver::GetInstance() == NULL ? "none" : MusicDriver::GetInstance()->GetName(),
 
			BaseMusic::GetUsedSet() == NULL ? "none" : BaseMusic::GetUsedSet()->name,
 
			BaseMusic::GetUsedSet() == NULL ? UINT32_MAX : BaseMusic::GetUsedSet()->version,
 
			_networking ? (_network_server ? "server" : "client") : "no",
 
			_sound_driver == NULL ? "none" : _sound_driver->GetName(),
 
			SoundDriver::GetInstance() == NULL ? "none" : SoundDriver::GetInstance()->GetName(),
 
			BaseSounds::GetUsedSet() == NULL ? "none" : BaseSounds::GetUsedSet()->name,
 
			BaseSounds::GetUsedSet() == NULL ? UINT32_MAX : BaseSounds::GetUsedSet()->version,
 
			_video_driver == NULL ? "none" : _video_driver->GetName()
 
			VideoDriver::GetInstance() == NULL ? "none" : VideoDriver::GetInstance()->GetName()
 
	);
 

	
 
	buffer += seprintf(buffer, last,
 
			"Fonts:\n"
 
			" Small:  %s\n"
 
			" Medium: %s\n"
 
@@ -481,10 +481,10 @@ bool CrashLog::MakeCrashLog() const
 
/**
 
 * Try to close the sound/video stuff so it doesn't keep lingering around
 
 * incorrect video states or so, e.g. keeping dpmi disabled.
 
 */
 
/* static */ void CrashLog::AfterCrashLogCleanup()
 
{
 
	if (_music_driver != NULL) _music_driver->Stop();
 
	if (_sound_driver != NULL) _sound_driver->Stop();
 
	if (_video_driver != NULL) _video_driver->Stop();
 
	if (MusicDriver::GetInstance() != NULL) MusicDriver::GetInstance()->Stop();
 
	if (SoundDriver::GetInstance() != NULL) SoundDriver::GetInstance()->Stop();
 
	if (VideoDriver::GetInstance() != NULL) VideoDriver::GetInstance()->Stop();
 
}
src/driver.cpp
Show inline comments
 
@@ -15,23 +15,20 @@
 
#include "music/music_driver.hpp"
 
#include "video/video_driver.hpp"
 
#include "string_func.h"
 

	
 
#include "safeguards.h"
 

	
 
VideoDriver *_video_driver; ///< The currently active video driver.
 
char *_ini_videodriver;     ///< The video driver a stored in the configuration file.
 
int _num_resolutions;       ///< The number of resolutions.
 
Dimension _resolutions[32]; ///< List of resolutions.
 
Dimension _cur_resolution;  ///< The current resolution.
 
bool _rightclick_emulate;   ///< Whether right clicking is emulated.
 

	
 
SoundDriver *_sound_driver; ///< The currently active sound driver.
 
char *_ini_sounddriver;     ///< The sound driver a stored in the configuration file.
 

	
 
MusicDriver *_music_driver; ///< The currently active music driver.
 
char *_ini_musicdriver;     ///< The music driver a stored in the configuration file.
 

	
 
char *_ini_blitter;         ///< The blitter as stored in the configuration file.
 
bool _blitter_autodetected; ///< Was the blitter autodetected or specified by the user?
 

	
 
/**
 
@@ -85,15 +82,31 @@ int GetDriverParamInt(const char * const
 
/**
 
 * Find the requested driver and return its class.
 
 * @param name the driver to select.
 
 * @param type the type of driver to select
 
 * @post Sets the driver so GetCurrentDriver() returns it too.
 
 */
 
Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
 
void DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
 
{
 
	if (GetDrivers().size() == 0) return NULL;
 
	if (!DriverFactoryBase::SelectDriverImpl(name, type)) {
 
		StrEmpty(name) ?
 
			usererror("Failed to autoprobe %s driver", GetDriverTypeName(type)) :
 
			usererror("Failed to select requested %s driver '%s'", GetDriverTypeName(type), name);
 
	}
 
}
 

	
 
/**
 
 * Find the requested driver and return its class.
 
 * @param name the driver to select.
 
 * @param type the type of driver to select
 
 * @post Sets the driver so GetCurrentDriver() returns it too.
 
 * @return True upon success, otherwise false.
 
 */
 
bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
 
{
 
	if (GetDrivers().size() == 0) return false;
 

	
 
	if (StrEmpty(name)) {
 
		/* Probe for this driver, but do not fall back to dedicated/null! */
 
		for (int priority = 10; priority > 0; priority--) {
 
			Drivers::iterator it = GetDrivers().begin();
 
			for (; it != GetDrivers().end(); ++it) {
 
@@ -106,13 +119,13 @@ Driver *DriverFactoryBase::SelectDriver(
 
				Driver *newd = d->CreateInstance();
 
				const char *err = newd->Start(NULL);
 
				if (err == NULL) {
 
					DEBUG(driver, 1, "Successfully probed %s driver '%s'", GetDriverTypeName(type), d->name);
 
					delete *GetActiveDriver(type);
 
					*GetActiveDriver(type) = newd;
 
					return newd;
 
					return true;
 
				}
 

	
 
				DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", GetDriverTypeName(type), d->name, err);
 
				delete newd;
 
			}
 
		}
 
@@ -157,13 +170,13 @@ Driver *DriverFactoryBase::SelectDriver(
 
				usererror("Unable to load driver '%s'. The error was: %s", d->name, err);
 
			}
 

	
 
			DEBUG(driver, 1, "Successfully loaded %s driver '%s'", GetDriverTypeName(type), d->name);
 
			delete *GetActiveDriver(type);
 
			*GetActiveDriver(type) = newd;
 
			return newd;
 
			return true;
 
		}
 
		usererror("No such %s driver: %s\n", GetDriverTypeName(type), buffer);
 
	}
 
}
 

	
 
/**
src/driver.h
Show inline comments
 
@@ -56,12 +56,16 @@ public:
 
DECLARE_POSTFIX_INCREMENT(Driver::Type)
 

	
 

	
 
/** Base for all driver factories. */
 
class DriverFactoryBase {
 
private:
 
	friend class MusicDriver;
 
	friend class SoundDriver;
 
	friend class VideoDriver;
 

	
 
	Driver::Type type;       ///< The type of driver.
 
	int priority;            ///< The priority of this factory.
 
	const char *name;        ///< The name of the drivers of this factory.
 
	const char *description; ///< The description of this driver.
 

	
 
	typedef std::map<const char *, DriverFactoryBase *, StringCompare> Drivers; ///< Type for a map of drivers.
 
@@ -94,12 +98,14 @@ private:
 
	static const char *GetDriverTypeName(Driver::Type type)
 
	{
 
		static const char * const driver_type_name[] = { "music", "sound", "video" };
 
		return driver_type_name[type];
 
	}
 

	
 
	static bool SelectDriverImpl(const char *name, Driver::Type type);
 

	
 
protected:
 
	DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description);
 

	
 
	virtual ~DriverFactoryBase();
 

	
 
public:
 
@@ -111,13 +117,13 @@ public:
 
		for (Driver::Type dt = Driver::DT_BEGIN; dt < Driver::DT_END; dt++) {
 
			Driver *driver = *GetActiveDriver(dt);
 
			if (driver != NULL) driver->Stop();
 
		}
 
	}
 

	
 
	static Driver *SelectDriver(const char *name, Driver::Type type);
 
	static void SelectDriver(const char *name, Driver::Type type);
 
	static char *GetDriversInfo(char *p, const char *last);
 

	
 
	/**
 
	 * Get a nice description of the driver-class.
 
	 * @return The description.
 
	 */
src/genworld.cpp
Show inline comments
 
@@ -328,13 +328,13 @@ void GenerateWorld(GenWorldMode mode, ui
 
	if (_gw.thread != NULL) {
 
		_gw.thread->Join();
 
		delete _gw.thread;
 
		_gw.thread = NULL;
 
	}
 

	
 
	if (!_video_driver->HasGUI() || !ThreadObject::New(&_GenerateWorld, NULL, &_gw.thread)) {
 
	if (!VideoDriver::GetInstance()->HasGUI() || !ThreadObject::New(&_GenerateWorld, NULL, &_gw.thread)) {
 
		DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode");
 
		_gw.threaded = false;
 
		_modal_progress_work_mutex->EndCritical();
 
		_GenerateWorld(NULL);
 
		_modal_progress_work_mutex->BeginCritical();
 
		return;
src/gfx.cpp
Show inline comments
 
@@ -85,13 +85,13 @@ void GfxScroll(int left, int top, int wi
 
#ifdef ENABLE_NETWORK
 
	if (_networking) NetworkUndrawChatMessage();
 
#endif /* ENABLE_NETWORK */
 

	
 
	blitter->ScrollBuffer(_screen.dst_ptr, left, top, width, height, xo, yo);
 
	/* This part of the screen is now dirty. */
 
	_video_driver->MakeDirty(left, top, width, height);
 
	VideoDriver::GetInstance()->MakeDirty(left, top, width, height);
 
}
 

	
 

	
 
/**
 
 * Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
 
 *
 
@@ -1183,13 +1183,13 @@ void UndrawMouseCursor()
 
	if (_screen.dst_ptr == NULL) return;
 

	
 
	if (_cursor.visible) {
 
		Blitter *blitter = BlitterFactory::GetCurrentBlitter();
 
		_cursor.visible = false;
 
		blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, _cursor.draw_pos.x, _cursor.draw_pos.y), _cursor_backup.GetBuffer(), _cursor.draw_size.x, _cursor.draw_size.y);
 
		_video_driver->MakeDirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y);
 
		VideoDriver::GetInstance()->MakeDirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y);
 
	}
 
}
 

	
 
void DrawMouseCursor()
 
{
 
#if defined(WINCE)
 
@@ -1243,13 +1243,13 @@ void DrawMouseCursor()
 
	blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, _cursor.draw_pos.x, _cursor.draw_pos.y), buffer, _cursor.draw_size.x, _cursor.draw_size.y);
 

	
 
	/* Draw cursor on screen */
 
	_cur_dpi = &_screen;
 
	DrawSprite(_cursor.sprite, _cursor.pal, _cursor.pos.x + _cursor.short_vehicle_offset, _cursor.pos.y);
 

	
 
	_video_driver->MakeDirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y);
 
	VideoDriver::GetInstance()->MakeDirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y);
 

	
 
	_cursor.visible = true;
 
	_cursor.dirty = false;
 
}
 

	
 
void RedrawScreenRect(int left, int top, int right, int bottom)
 
@@ -1267,13 +1267,13 @@ void RedrawScreenRect(int left, int top,
 
#ifdef ENABLE_NETWORK
 
	if (_networking) NetworkUndrawChatMessage();
 
#endif /* ENABLE_NETWORK */
 

	
 
	DrawOverlappedWindowForAll(left, top, right, bottom);
 

	
 
	_video_driver->MakeDirty(left, top, right - left, bottom - top);
 
	VideoDriver::GetInstance()->MakeDirty(left, top, right - left, bottom - top);
 
}
 

	
 
/**
 
 * Repaints the rectangle blocks which are marked as 'dirty'.
 
 *
 
 * @see SetDirtyBlocks
 
@@ -1576,18 +1576,18 @@ void SetAnimatedMouseCursor(const AnimCu
 
	_cursor.pal = PAL_NONE;
 
	SwitchAnimatedCursor();
 
}
 

	
 
bool ChangeResInGame(int width, int height)
 
{
 
	return (_screen.width == width && _screen.height == height) || _video_driver->ChangeResolution(width, height);
 
	return (_screen.width == width && _screen.height == height) || VideoDriver::GetInstance()->ChangeResolution(width, height);
 
}
 

	
 
bool ToggleFullScreen(bool fs)
 
{
 
	bool result = _video_driver->ToggleFullscreen(fs);
 
	bool result = VideoDriver::GetInstance()->ToggleFullscreen(fs);
 
	if (_fullscreen != fs && _num_resolutions == 0) {
 
		DEBUG(driver, 0, "Could not find a suitable fullscreen resolution");
 
	}
 
	return result;
 
}
 

	
src/gfxinit.cpp
Show inline comments
 
@@ -286,15 +286,15 @@ static bool SwitchNewGRFBlitter()
 
		Blitter *new_blitter = BlitterFactory::SelectBlitter(repl_blitter);
 
		if (new_blitter == NULL) NOT_REACHED();
 
		DEBUG(misc, 1, "Successfully switched to %s.", repl_blitter);
 
		break;
 
	}
 

	
 
	if (!_video_driver->AfterBlitterChange()) {
 
	if (!VideoDriver::GetInstance()->AfterBlitterChange()) {
 
		/* Failed to switch blitter, let's hope we can return to the old one. */
 
		if (BlitterFactory::SelectBlitter(cur_blitter) == NULL || !_video_driver->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
 
		if (BlitterFactory::SelectBlitter(cur_blitter) == NULL || !VideoDriver::GetInstance()->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
 
	}
 

	
 
	return true;
 
}
 

	
 
/** Check whether we still use the right blitter, or use another (better) one. */
src/music/extmidi.cpp
Show inline comments
 
@@ -34,14 +34,14 @@
 

	
 
/** Factory for the midi player that uses external players. */
 
static FMusicDriver_ExtMidi iFMusicDriver_ExtMidi;
 

	
 
const char *MusicDriver_ExtMidi::Start(const char * const * parm)
 
{
 
	if (strcmp(_video_driver->GetName(), "allegro") == 0 ||
 
			strcmp(_sound_driver->GetName(), "allegro") == 0) {
 
	if (strcmp(VideoDriver::GetInstance()->GetName(), "allegro") == 0 ||
 
			strcmp(SoundDriver::GetInstance()->GetName(), "allegro") == 0) {
 
		return "the extmidi driver does not work when Allegro is loaded.";
 
	}
 

	
 
	const char *command = GetDriverParam(parm, "cmd");
 
	if (StrEmpty(command)) command = EXTERNAL_PLAYER;
 

	
src/music/music_driver.hpp
Show inline comments
 
@@ -36,12 +36,18 @@ public:
 

	
 
	/**
 
	 * Set the volume, if possible.
 
	 * @param vol The new volume.
 
	 */
 
	virtual void SetVolume(byte vol) = 0;
 

	
 
	/**
 
	 * Get the currently active instance of the music driver.
 
	 */
 
	static MusicDriver *GetInstance() {
 
		return static_cast<MusicDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_MUSIC));
 
	}
 
};
 

	
 
extern MusicDriver *_music_driver;
 
extern char *_ini_musicdriver;
 

	
 
#endif /* MUSIC_MUSIC_DRIVER_HPP */
src/music_gui.cpp
Show inline comments
 
@@ -173,28 +173,28 @@ static void SkipToNextSong()
 

	
 
	_song_is_active = false;
 
}
 

	
 
static void MusicVolumeChanged(byte new_vol)
 
{
 
	_music_driver->SetVolume(new_vol);
 
	MusicDriver::GetInstance()->SetVolume(new_vol);
 
}
 

	
 
static void DoPlaySong()
 
{
 
	char filename[MAX_PATH];
 
	if (FioFindFullPath(filename, lastof(filename), BASESET_DIR, BaseMusic::GetUsedSet()->files[_music_wnd_cursong - 1].filename) == NULL) {
 
		FioFindFullPath(filename, lastof(filename), OLD_GM_DIR, BaseMusic::GetUsedSet()->files[_music_wnd_cursong - 1].filename);
 
	}
 
	_music_driver->PlaySong(filename);
 
	MusicDriver::GetInstance()->PlaySong(filename);
 
	SetWindowDirty(WC_MUSIC_WINDOW, 0);
 
}
 

	
 
static void DoStopMusic()
 
{
 
	_music_driver->StopSong();
 
	MusicDriver::GetInstance()->StopSong();
 
	SetWindowDirty(WC_MUSIC_WINDOW, 0);
 
}
 

	
 
static void SelectSongToPlay()
 
{
 
	uint i = 0;
 
@@ -270,13 +270,13 @@ void MusicLoop()
 
	} else if (_settings_client.music.playing && !_song_is_active) {
 
		PlayPlaylistSong();
 
	}
 

	
 
	if (!_song_is_active) return;
 

	
 
	if (!_music_driver->IsSongPlaying()) {
 
	if (!MusicDriver::GetInstance()->IsSongPlaying()) {
 
		if (_game_mode != GM_MENU) {
 
			StopMusic();
 
			SkipToNextSong();
 
			PlayPlaylistSong();
 
		} else {
 
			ResetMusic();
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -166,13 +166,13 @@ void NetworkUndrawChatMessage()
 
		if (width <= 0 || height <= 0) return;
 

	
 
		_chatmessage_visible = false;
 
		/* Put our 'shot' back to the screen */
 
		blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height);
 
		/* And make sure it is updated next time */
 
		_video_driver->MakeDirty(x, y, width, height);
 
		VideoDriver::GetInstance()->MakeDirty(x, y, width, height);
 

	
 
		_chatmessage_dirty = true;
 
	}
 
}
 

	
 
/** Check if a message is expired. */
 
@@ -253,13 +253,13 @@ void NetworkDrawChatMessage()
 
	for (int i = count - 1; i >= 0; i--) {
 
		ypos = DrawStringMultiLine(_chatmsg_box.x + 3, _chatmsg_box.x + _chatmsg_box.width - 1, top, ypos, _chatmsg_list[i].message, _chatmsg_list[i].colour, SA_LEFT | SA_BOTTOM | SA_FORCE) - NETWORK_CHAT_LINE_SPACING;
 
		if (ypos < top) break;
 
	}
 

	
 
	/* Make sure the data is updated next flush */
 
	_video_driver->MakeDirty(x, y, width, height);
 
	VideoDriver::GetInstance()->MakeDirty(x, y, width, height);
 

	
 
	_chatmessage_visible = true;
 
	_chatmessage_dirty = false;
 
}
 

	
 
/**
src/newgrf_config.cpp
Show inline comments
 
@@ -772,13 +772,13 @@ void ScanNewGRFFiles(NewGRFScanCallback 
 
{
 
	/* First set the modal progress. This ensures that it will eventually let go of the paint mutex. */
 
	SetModalProgress(true);
 
	/* Only then can we really start, especially by marking the whole screen dirty. Get those other windows hidden!. */
 
	MarkWholeScreenDirty();
 

	
 
	if (!_video_driver->HasGUI() || !ThreadObject::New(&DoScanNewGRFFiles, callback, NULL)) {
 
	if (!VideoDriver::GetInstance()->HasGUI() || !ThreadObject::New(&DoScanNewGRFFiles, callback, NULL)) {
 
		_modal_progress_work_mutex->EndCritical();
 
		_modal_progress_paint_mutex->EndCritical();
 
		DoScanNewGRFFiles(callback);
 
		_modal_progress_paint_mutex->BeginCritical();
 
		_modal_progress_work_mutex->BeginCritical();
 
	} else {
src/openttd.cpp
Show inline comments
 
@@ -94,13 +94,13 @@ void CDECL usererror(const char *s, ...)
 

	
 
	va_start(va, s);
 
	vseprintf(buf, lastof(buf), s, va);
 
	va_end(va);
 

	
 
	ShowOSErrorBox(buf, false);
 
	if (_video_driver != NULL) _video_driver->Stop();
 
	if (VideoDriver::GetInstance() != NULL) VideoDriver::GetInstance()->Stop();
 

	
 
	exit(1);
 
}
 

	
 
/**
 
 * Error handling for fatal non-user errors.
 
@@ -340,13 +340,13 @@ static void LoadIntroGame(bool load_newg
 
	_cursor.fix_at = false;
 

	
 
	if (load_newgrfs) CheckForMissingSprites();
 
	CheckForMissingGlyphs();
 

	
 
	/* Play main theme */
 
	if (_music_driver->IsSongPlaying()) ResetMusic();
 
	if (MusicDriver::GetInstance()->IsSongPlaying()) ResetMusic();
 
}
 

	
 
void MakeNewgameSettingsLive()
 
{
 
	for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
 
		if (_settings_game.ai_config[c] != NULL) {
 
@@ -433,13 +433,13 @@ struct AfterNewGRFScan : NewGRFScanCallb
 
		WindowDesc::LoadFromConfig();
 

	
 
		/* We have loaded the config, so we may possibly save it. */
 
		*save_config_ptr = save_config;
 

	
 
		/* restore saved music volume */
 
		_music_driver->SetVolume(_settings_client.music.music_vol);
 
		MusicDriver::GetInstance()->SetVolume(_settings_client.music.music_vol);
 

	
 
		if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
 
		if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
 

	
 
#if defined(ENABLE_NETWORK)
 
		if (dedicated_host != NULL) {
 
@@ -772,18 +772,13 @@ int openttd_main(int argc, char *argv[])
 
				usererror("Failed to select requested blitter '%s'; does it exist?", blitter);
 
		}
 
	}
 
	free(blitter);
 

	
 
	if (videodriver == NULL && _ini_videodriver != NULL) videodriver = stredup(_ini_videodriver);
 
	_video_driver = (VideoDriver*)DriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
 
	if (_video_driver == NULL) {
 
		StrEmpty(videodriver) ?
 
			usererror("Failed to autoprobe video driver") :
 
			usererror("Failed to select requested video driver '%s'", videodriver);
 
	}
 
	DriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
 
	free(videodriver);
 

	
 
	InitializeSpriteSorter();
 

	
 
	/* Initialize the zoom level of the screen to normal */
 
	_screen.zoom = ZOOM_LVL_NORMAL;
 
@@ -808,13 +803,13 @@ int openttd_main(int argc, char *argv[])
 
	if (!HandleBootstrap()) {
 
		ShutdownGame();
 

	
 
		goto exit_bootstrap;
 
	}
 

	
 
	_video_driver->ClaimMousePointer();
 
	VideoDriver::GetInstance()->ClaimMousePointer();
 

	
 
	/* initialize screenshot formats */
 
	InitializeScreenshotFormats();
 

	
 
	BaseSounds::FindSets();
 
	if (sounds_set == NULL && BaseSounds::ini_set != NULL) sounds_set = stredup(BaseSounds::ini_set);
 
@@ -840,27 +835,17 @@ int openttd_main(int argc, char *argv[])
 
			ScheduleErrorMessage(msg);
 
		}
 
	}
 
	free(music_set);
 

	
 
	if (sounddriver == NULL && _ini_sounddriver != NULL) sounddriver = stredup(_ini_sounddriver);
 
	_sound_driver = (SoundDriver*)DriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND);
 
	if (_sound_driver == NULL) {
 
		StrEmpty(sounddriver) ?
 
			usererror("Failed to autoprobe sound driver") :
 
			usererror("Failed to select requested sound driver '%s'", sounddriver);
 
	}
 
	DriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND);
 
	free(sounddriver);
 

	
 
	if (musicdriver == NULL && _ini_musicdriver != NULL) musicdriver = stredup(_ini_musicdriver);
 
	_music_driver = (MusicDriver*)DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
 
	if (_music_driver == NULL) {
 
		StrEmpty(musicdriver) ?
 
			usererror("Failed to autoprobe music driver") :
 
			usererror("Failed to select requested music driver '%s'", musicdriver);
 
	}
 
	DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
 
	free(musicdriver);
 

	
 
	/* Take our initial lock on whatever we might want to do! */
 
	_modal_progress_paint_mutex->BeginCritical();
 
	_modal_progress_work_mutex->BeginCritical();
 

	
 
@@ -872,13 +857,13 @@ int openttd_main(int argc, char *argv[])
 
	CheckForMissingGlyphs();
 

	
 
	/* ScanNewGRFFiles now has control over the scanner. */
 
	ScanNewGRFFiles(scanner);
 
	scanner = NULL;
 

	
 
	_video_driver->MainLoop();
 
	VideoDriver::GetInstance()->MainLoop();
 

	
 
	WaitTillSaved();
 

	
 
	/* only save config if we have to */
 
	if (save_config) {
 
		SaveToConfig();
 
@@ -940,13 +925,13 @@ void HandleExitGameRequest()
 

	
 
static void MakeNewGameDone()
 
{
 
	SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
 

	
 
	/* In a dedicated server, the server does not play */
 
	if (!_video_driver->HasGUI()) {
 
	if (!VideoDriver::GetInstance()->HasGUI()) {
 
		SetLocalCompany(COMPANY_SPECTATOR);
 
		if (_settings_client.gui.pause_on_newgame) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
 
		IConsoleCmdExec("exec scripts/game_start.scr 0");
 
		return;
 
	}
 

	
 
@@ -1506,9 +1491,9 @@ void GameLoop()
 
	if (!_pause_mode && HasBit(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations();
 

	
 
	if (!_pause_mode || _game_mode == GM_EDITOR || _settings_game.construction.command_pause_level > CMDPL_NO_CONSTRUCTION) MoveAllTextEffects();
 

	
 
	InputLoop();
 

	
 
	_sound_driver->MainLoop();
 
	SoundDriver::GetInstance()->MainLoop();
 
	MusicLoop();
 
}
src/os/windows/crashlog_win.cpp
Show inline comments
 
@@ -520,13 +520,13 @@ static LONG WINAPI ExceptionHandler(EXCE
 
	log->WriteCrashLog(log->crashlog, log->crashlog_filename, lastof(log->crashlog_filename));
 
	log->WriteScreenshot(log->screenshot_filename, lastof(log->screenshot_filename));
 

	
 
	/* Close any possible log files */
 
	CloseConsoleLogIfActive();
 

	
 
	if ((_video_driver == NULL || _video_driver->HasGUI()) && _safe_esp != NULL) {
 
	if ((VideoDriver::GetInstance() == NULL || VideoDriver::GetInstance()->HasGUI()) && _safe_esp != NULL) {
 
#ifdef _M_AMD64
 
		ep->ContextRecord->Rip = (DWORD64)ShowCrashlogWindow;
 
		ep->ContextRecord->Rsp = (DWORD64)_safe_esp;
 
#else
 
		ep->ContextRecord->Eip = (DWORD)ShowCrashlogWindow;
 
		ep->ContextRecord->Esp = (DWORD)_safe_esp;
src/osk_gui.cpp
Show inline comments
 
@@ -205,13 +205,13 @@ struct OskWindow : public Window {
 
		this->SetWidgetDirty(WID_OSK_TEXT);
 
		this->parent->SetWidgetDirty(this->text_btn);
 
	}
 

	
 
	virtual void OnFocusLost()
 
	{
 
		_video_driver->EditBoxLostFocus();
 
		VideoDriver::GetInstance()->EditBoxLostFocus();
 
		delete this;
 
	}
 
};
 

	
 
static const int HALF_KEY_WIDTH = 7;  // Width of 1/2 key in pixels.
 
static const int INTER_KEY_SPACE = 2; // Number of pixels between two keys.
src/sound/sound_driver.hpp
Show inline comments
 
@@ -16,12 +16,18 @@
 

	
 
/** Base for all sound drivers. */
 
class SoundDriver : public Driver {
 
public:
 
	/** Called once every tick */
 
	virtual void MainLoop() {}
 

	
 
	/**
 
	 * Get the currently active instance of the sound driver.
 
	 */
 
	static SoundDriver *GetInstance() {
 
		return static_cast<SoundDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_SOUND));
 
	}
 
};
 

	
 
extern SoundDriver *_sound_driver;
 
extern char *_ini_sounddriver;
 

	
 
#endif /* SOUND_SOUND_DRIVER_HPP */
src/video/cocoa/cocoa_v.mm
Show inline comments
 
@@ -594,22 +594,22 @@ void VideoDriver_Cocoa::EditBoxLostFocus
 
 */
 
void CocoaDialog(const char *title, const char *message, const char *buttonLabel)
 
{
 
	_cocoa_video_dialog = true;
 

	
 
	bool wasstarted = _cocoa_video_started;
 
	if (_video_driver == NULL) {
 
	if (VideoDriver::GetInstance() == NULL) {
 
		setupApplication(); // Setup application before showing dialog
 
	} else if (!_cocoa_video_started && _video_driver->Start(NULL) != NULL) {
 
	} else if (!_cocoa_video_started && VideoDriver::GetInstance()->Start(NULL) != NULL) {
 
		fprintf(stderr, "%s: %s\n", title, message);
 
		return;
 
	}
 

	
 
	NSRunAlertPanel([ NSString stringWithUTF8String:title ], [ NSString stringWithUTF8String:message ], [ NSString stringWithUTF8String:buttonLabel ], nil, nil);
 

	
 
	if (!wasstarted && _video_driver != NULL) _video_driver->Stop();
 
	if (!wasstarted && VideoDriver::GetInstance() != NULL) VideoDriver::GetInstance()->Stop();
 

	
 
	_cocoa_video_dialog = false;
 
}
 

	
 
/** Set the application's bundle directory.
 
 *
src/video/cocoa/event.mm
Show inline comments
 
@@ -284,13 +284,13 @@ static bool QZ_KeyEvent(unsigned short k
 

	
 
		case QZ_TAB: _tab_is_down = down; break;
 

	
 
		case QZ_RETURN:
 
		case QZ_f:
 
			if (down && (_current_mods & NSCommandKeyMask)) {
 
				_video_driver->ToggleFullscreen(!_fullscreen);
 
				VideoDriver::GetInstance()->ToggleFullscreen(!_fullscreen);
 
			}
 
			break;
 
	}
 

	
 
	if (down) {
 
		uint32 pressed_key = QZ_MapKey(keycode);
src/video/sdl_v.cpp
Show inline comments
 
@@ -408,13 +408,13 @@ bool VideoDriver_SDL::CreateMainSurface(
 
		case Blitter::PALETTE_ANIMATION_NONE:
 
		case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND:
 
			UpdatePalette();
 
			break;
 

	
 
		case Blitter::PALETTE_ANIMATION_BLITTER:
 
			if (_video_driver != NULL) blitter->PaletteAnimate(_local_palette);
 
			if (VideoDriver::GetInstance() != NULL) blitter->PaletteAnimate(_local_palette);
 
			break;
 

	
 
		default:
 
			NOT_REACHED();
 
	}
 

	
src/video/video_driver.hpp
Show inline comments
 
@@ -75,15 +75,21 @@ public:
 
	}
 

	
 
	/**
 
	 * An edit box lost the input focus. Abort character compositing if necessary.
 
	 */
 
	virtual void EditBoxLostFocus() {}
 

	
 
	/**
 
	 * Get the currently active instance of the video driver.
 
	 */
 
	static VideoDriver *GetInstance() {
 
		return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO));
 
	}
 
};
 

	
 
extern VideoDriver *_video_driver;
 
extern char *_ini_videodriver;
 
extern int _num_resolutions;
 
extern Dimension _resolutions[32];
 
extern Dimension _cur_resolution;
 
extern bool _rightclick_emulate;
 

	
src/video/win32_v.cpp
Show inline comments
 
@@ -999,13 +999,13 @@ static LRESULT CALLBACK WndProcGdi(HWND 
 
			bool active = (LOWORD(wParam) != WA_INACTIVE);
 
			bool minimized = (HIWORD(wParam) != 0);
 
			if (_wnd.fullscreen) {
 
				if (active && minimized) {
 
					/* Restore the game window */
 
					ShowWindow(hwnd, SW_RESTORE);
 
					static_cast<VideoDriver_Win32 *>(_video_driver)->MakeWindow(true);
 
					static_cast<VideoDriver_Win32 *>(VideoDriver::GetInstance())->MakeWindow(true);
 
				} else if (!active && !minimized) {
 
					/* Minimise the window and restore desktop */
 
					ShowWindow(hwnd, SW_MINIMIZE);
 
					ChangeDisplaySettings(NULL, 0);
 
				}
 
			}
src/window.cpp
Show inline comments
 
@@ -445,13 +445,13 @@ bool EditBoxInGlobalFocus()
 
/**
 
 * Makes no widget on this window have focus. The function however doesn't change which window has focus.
 
 */
 
void Window::UnfocusFocusedWidget()
 
{
 
	if (this->nested_focus != NULL) {
 
		if (this->nested_focus->type == WWT_EDITBOX) _video_driver->EditBoxLostFocus();
 
		if (this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus();
 

	
 
		/* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
 
		this->nested_focus->SetDirty(this);
 
		this->nested_focus = NULL;
 
	}
 
}
 
@@ -469,24 +469,24 @@ bool Window::SetFocusedWidget(int widget
 
	assert(this->nested_array[widget_index] != NULL); // Setting focus to a non-existing widget is a bad idea.
 
	if (this->nested_focus != NULL) {
 
		if (this->GetWidget<NWidgetCore>(widget_index) == this->nested_focus) return false;
 

	
 
		/* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
 
		this->nested_focus->SetDirty(this);
 
		if (this->nested_focus->type == WWT_EDITBOX) _video_driver->EditBoxLostFocus();
 
		if (this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus();
 
	}
 
	this->nested_focus = this->GetWidget<NWidgetCore>(widget_index);
 
	return true;
 
}
 

	
 
/**
 
 * Called when window looses focus
 
 */
 
void Window::OnFocusLost()
 
{
 
	if (this->nested_focus != NULL && this->nested_focus->type == WWT_EDITBOX) _video_driver->EditBoxLostFocus();
 
	if (this->nested_focus != NULL && this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus();
 
}
 

	
 
/**
 
 * Sets the enabled/disabled status of a list of widgets.
 
 * By default, widgets are enabled.
 
 * On certain conditions, they have to be disabled.
0 comments (0 inline, 0 general)