mirror of https://github.com/OpenTTD/OpenTTD
(svn r26538) -Codechange: remove double accounting of the drivers
parent
3b634b628c
commit
b476086c39
|
@ -482,7 +482,7 @@ void Blitter_32bppAnim::PaletteAnimate(const Palette &palette)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the backend redraws the whole screen */
|
/* 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()
|
Blitter::PaletteAnimation Blitter_32bppAnim::UsePaletteAnimation()
|
||||||
|
|
|
@ -246,7 +246,7 @@ bool HandleBootstrap()
|
||||||
new BootstrapAskForDownloadWindow();
|
new BootstrapAskForDownloadWindow();
|
||||||
|
|
||||||
/* Process the user events. */
|
/* Process the user events. */
|
||||||
_video_driver->MainLoop();
|
VideoDriver::GetInstance()->MainLoop();
|
||||||
|
|
||||||
/* _exit_game is used to get out of the video driver's main loop.
|
/* _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
|
* In case GM_BOOTSTRAP is still set we did not exit it via the
|
||||||
|
|
|
@ -187,7 +187,7 @@ struct IConsoleWindow : Window
|
||||||
~IConsoleWindow()
|
~IConsoleWindow()
|
||||||
{
|
{
|
||||||
_iconsole_mode = ICONSOLE_CLOSED;
|
_iconsole_mode = ICONSOLE_CLOSED;
|
||||||
_video_driver->EditBoxLostFocus();
|
VideoDriver::GetInstance()->EditBoxLostFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -376,7 +376,7 @@ struct IConsoleWindow : Window
|
||||||
|
|
||||||
virtual void OnFocusLost()
|
virtual void OnFocusLost()
|
||||||
{
|
{
|
||||||
_video_driver->EditBoxLostFocus();
|
VideoDriver::GetInstance()->EditBoxLostFocus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -140,14 +140,14 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const
|
||||||
BaseGraphics::GetUsedSet() == NULL ? "none" : BaseGraphics::GetUsedSet()->name,
|
BaseGraphics::GetUsedSet() == NULL ? "none" : BaseGraphics::GetUsedSet()->name,
|
||||||
BaseGraphics::GetUsedSet() == NULL ? UINT32_MAX : BaseGraphics::GetUsedSet()->version,
|
BaseGraphics::GetUsedSet() == NULL ? UINT32_MAX : BaseGraphics::GetUsedSet()->version,
|
||||||
_current_language == NULL ? "none" : _current_language->file,
|
_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 ? "none" : BaseMusic::GetUsedSet()->name,
|
||||||
BaseMusic::GetUsedSet() == NULL ? UINT32_MAX : BaseMusic::GetUsedSet()->version,
|
BaseMusic::GetUsedSet() == NULL ? UINT32_MAX : BaseMusic::GetUsedSet()->version,
|
||||||
_networking ? (_network_server ? "server" : "client") : "no",
|
_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 ? "none" : BaseSounds::GetUsedSet()->name,
|
||||||
BaseSounds::GetUsedSet() == NULL ? UINT32_MAX : BaseSounds::GetUsedSet()->version,
|
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,
|
buffer += seprintf(buffer, last,
|
||||||
|
@ -484,7 +484,7 @@ bool CrashLog::MakeCrashLog() const
|
||||||
*/
|
*/
|
||||||
/* static */ void CrashLog::AfterCrashLogCleanup()
|
/* static */ void CrashLog::AfterCrashLogCleanup()
|
||||||
{
|
{
|
||||||
if (_music_driver != NULL) _music_driver->Stop();
|
if (MusicDriver::GetInstance() != NULL) MusicDriver::GetInstance()->Stop();
|
||||||
if (_sound_driver != NULL) _sound_driver->Stop();
|
if (SoundDriver::GetInstance() != NULL) SoundDriver::GetInstance()->Stop();
|
||||||
if (_video_driver != NULL) _video_driver->Stop();
|
if (VideoDriver::GetInstance() != NULL) VideoDriver::GetInstance()->Stop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,17 +18,14 @@
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
VideoDriver *_video_driver; ///< The currently active video driver.
|
|
||||||
char *_ini_videodriver; ///< The video driver a stored in the configuration file.
|
char *_ini_videodriver; ///< The video driver a stored in the configuration file.
|
||||||
int _num_resolutions; ///< The number of resolutions.
|
int _num_resolutions; ///< The number of resolutions.
|
||||||
Dimension _resolutions[32]; ///< List of resolutions.
|
Dimension _resolutions[32]; ///< List of resolutions.
|
||||||
Dimension _cur_resolution; ///< The current resolution.
|
Dimension _cur_resolution; ///< The current resolution.
|
||||||
bool _rightclick_emulate; ///< Whether right clicking is emulated.
|
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.
|
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_musicdriver; ///< The music driver a stored in the configuration file.
|
||||||
|
|
||||||
char *_ini_blitter; ///< The blitter as stored in the configuration file.
|
char *_ini_blitter; ///< The blitter as stored in the configuration file.
|
||||||
|
@ -88,9 +85,25 @@ int GetDriverParamInt(const char * const *parm, const char *name, int def)
|
||||||
* @param type the type of driver to select
|
* @param type the type of driver to select
|
||||||
* @post Sets the driver so GetCurrentDriver() returns it too.
|
* @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)) {
|
if (StrEmpty(name)) {
|
||||||
/* Probe for this driver, but do not fall back to dedicated/null! */
|
/* Probe for this driver, but do not fall back to dedicated/null! */
|
||||||
|
@ -109,7 +122,7 @@ Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
|
||||||
DEBUG(driver, 1, "Successfully probed %s driver '%s'", GetDriverTypeName(type), d->name);
|
DEBUG(driver, 1, "Successfully probed %s driver '%s'", GetDriverTypeName(type), d->name);
|
||||||
delete *GetActiveDriver(type);
|
delete *GetActiveDriver(type);
|
||||||
*GetActiveDriver(type) = newd;
|
*GetActiveDriver(type) = newd;
|
||||||
return newd;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", GetDriverTypeName(type), d->name, err);
|
DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", GetDriverTypeName(type), d->name, err);
|
||||||
|
@ -160,7 +173,7 @@ Driver *DriverFactoryBase::SelectDriver(const char *name, Driver::Type type)
|
||||||
DEBUG(driver, 1, "Successfully loaded %s driver '%s'", GetDriverTypeName(type), d->name);
|
DEBUG(driver, 1, "Successfully loaded %s driver '%s'", GetDriverTypeName(type), d->name);
|
||||||
delete *GetActiveDriver(type);
|
delete *GetActiveDriver(type);
|
||||||
*GetActiveDriver(type) = newd;
|
*GetActiveDriver(type) = newd;
|
||||||
return newd;
|
return true;
|
||||||
}
|
}
|
||||||
usererror("No such %s driver: %s\n", GetDriverTypeName(type), buffer);
|
usererror("No such %s driver: %s\n", GetDriverTypeName(type), buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,10 @@ DECLARE_POSTFIX_INCREMENT(Driver::Type)
|
||||||
/** Base for all driver factories. */
|
/** Base for all driver factories. */
|
||||||
class DriverFactoryBase {
|
class DriverFactoryBase {
|
||||||
private:
|
private:
|
||||||
|
friend class MusicDriver;
|
||||||
|
friend class SoundDriver;
|
||||||
|
friend class VideoDriver;
|
||||||
|
|
||||||
Driver::Type type; ///< The type of driver.
|
Driver::Type type; ///< The type of driver.
|
||||||
int priority; ///< The priority of this factory.
|
int priority; ///< The priority of this factory.
|
||||||
const char *name; ///< The name of the drivers of this factory.
|
const char *name; ///< The name of the drivers of this factory.
|
||||||
|
@ -97,6 +101,8 @@ private:
|
||||||
return driver_type_name[type];
|
return driver_type_name[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool SelectDriverImpl(const char *name, Driver::Type type);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description);
|
DriverFactoryBase(Driver::Type type, int priority, const char *name, const char *description);
|
||||||
|
|
||||||
|
@ -114,7 +120,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
static char *GetDriversInfo(char *p, const char *last);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -331,7 +331,7 @@ void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_setti
|
||||||
_gw.thread = NULL;
|
_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");
|
DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode");
|
||||||
_gw.threaded = false;
|
_gw.threaded = false;
|
||||||
_modal_progress_work_mutex->EndCritical();
|
_modal_progress_work_mutex->EndCritical();
|
||||||
|
|
12
src/gfx.cpp
12
src/gfx.cpp
|
@ -88,7 +88,7 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo)
|
||||||
|
|
||||||
blitter->ScrollBuffer(_screen.dst_ptr, left, top, width, height, xo, yo);
|
blitter->ScrollBuffer(_screen.dst_ptr, left, top, width, height, xo, yo);
|
||||||
/* This part of the screen is now dirty. */
|
/* This part of the screen is now dirty. */
|
||||||
_video_driver->MakeDirty(left, top, width, height);
|
VideoDriver::GetInstance()->MakeDirty(left, top, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1186,7 +1186,7 @@ void UndrawMouseCursor()
|
||||||
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
||||||
_cursor.visible = false;
|
_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);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1246,7 +1246,7 @@ void DrawMouseCursor()
|
||||||
_cur_dpi = &_screen;
|
_cur_dpi = &_screen;
|
||||||
DrawSprite(_cursor.sprite, _cursor.pal, _cursor.pos.x + _cursor.short_vehicle_offset, _cursor.pos.y);
|
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.visible = true;
|
||||||
_cursor.dirty = false;
|
_cursor.dirty = false;
|
||||||
|
@ -1270,7 +1270,7 @@ void RedrawScreenRect(int left, int top, int right, int bottom)
|
||||||
|
|
||||||
DrawOverlappedWindowForAll(left, top, right, bottom);
|
DrawOverlappedWindowForAll(left, top, right, bottom);
|
||||||
|
|
||||||
_video_driver->MakeDirty(left, top, right - left, bottom - top);
|
VideoDriver::GetInstance()->MakeDirty(left, top, right - left, bottom - top);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1579,12 +1579,12 @@ void SetAnimatedMouseCursor(const AnimCursor *table)
|
||||||
|
|
||||||
bool ChangeResInGame(int width, int height)
|
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 ToggleFullScreen(bool fs)
|
||||||
{
|
{
|
||||||
bool result = _video_driver->ToggleFullscreen(fs);
|
bool result = VideoDriver::GetInstance()->ToggleFullscreen(fs);
|
||||||
if (_fullscreen != fs && _num_resolutions == 0) {
|
if (_fullscreen != fs && _num_resolutions == 0) {
|
||||||
DEBUG(driver, 0, "Could not find a suitable fullscreen resolution");
|
DEBUG(driver, 0, "Could not find a suitable fullscreen resolution");
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,9 +289,9 @@ static bool SwitchNewGRFBlitter()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_video_driver->AfterBlitterChange()) {
|
if (!VideoDriver::GetInstance()->AfterBlitterChange()) {
|
||||||
/* Failed to switch blitter, let's hope we can return to the old one. */
|
/* 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;
|
return true;
|
||||||
|
|
|
@ -37,8 +37,8 @@ static FMusicDriver_ExtMidi iFMusicDriver_ExtMidi;
|
||||||
|
|
||||||
const char *MusicDriver_ExtMidi::Start(const char * const * parm)
|
const char *MusicDriver_ExtMidi::Start(const char * const * parm)
|
||||||
{
|
{
|
||||||
if (strcmp(_video_driver->GetName(), "allegro") == 0 ||
|
if (strcmp(VideoDriver::GetInstance()->GetName(), "allegro") == 0 ||
|
||||||
strcmp(_sound_driver->GetName(), "allegro") == 0) {
|
strcmp(SoundDriver::GetInstance()->GetName(), "allegro") == 0) {
|
||||||
return "the extmidi driver does not work when Allegro is loaded.";
|
return "the extmidi driver does not work when Allegro is loaded.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,15 @@ public:
|
||||||
* @param vol The new volume.
|
* @param vol The new volume.
|
||||||
*/
|
*/
|
||||||
virtual void SetVolume(byte vol) = 0;
|
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;
|
extern char *_ini_musicdriver;
|
||||||
|
|
||||||
#endif /* MUSIC_MUSIC_DRIVER_HPP */
|
#endif /* MUSIC_MUSIC_DRIVER_HPP */
|
||||||
|
|
|
@ -176,7 +176,7 @@ static void SkipToNextSong()
|
||||||
|
|
||||||
static void MusicVolumeChanged(byte new_vol)
|
static void MusicVolumeChanged(byte new_vol)
|
||||||
{
|
{
|
||||||
_music_driver->SetVolume(new_vol);
|
MusicDriver::GetInstance()->SetVolume(new_vol);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoPlaySong()
|
static void DoPlaySong()
|
||||||
|
@ -185,13 +185,13 @@ static void DoPlaySong()
|
||||||
if (FioFindFullPath(filename, lastof(filename), BASESET_DIR, BaseMusic::GetUsedSet()->files[_music_wnd_cursong - 1].filename) == NULL) {
|
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);
|
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);
|
SetWindowDirty(WC_MUSIC_WINDOW, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoStopMusic()
|
static void DoStopMusic()
|
||||||
{
|
{
|
||||||
_music_driver->StopSong();
|
MusicDriver::GetInstance()->StopSong();
|
||||||
SetWindowDirty(WC_MUSIC_WINDOW, 0);
|
SetWindowDirty(WC_MUSIC_WINDOW, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ void MusicLoop()
|
||||||
|
|
||||||
if (!_song_is_active) return;
|
if (!_song_is_active) return;
|
||||||
|
|
||||||
if (!_music_driver->IsSongPlaying()) {
|
if (!MusicDriver::GetInstance()->IsSongPlaying()) {
|
||||||
if (_game_mode != GM_MENU) {
|
if (_game_mode != GM_MENU) {
|
||||||
StopMusic();
|
StopMusic();
|
||||||
SkipToNextSong();
|
SkipToNextSong();
|
||||||
|
|
|
@ -169,7 +169,7 @@ void NetworkUndrawChatMessage()
|
||||||
/* Put our 'shot' back to the screen */
|
/* Put our 'shot' back to the screen */
|
||||||
blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height);
|
blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height);
|
||||||
/* And make sure it is updated next time */
|
/* 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;
|
_chatmessage_dirty = true;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ void NetworkDrawChatMessage()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the data is updated next flush */
|
/* 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_visible = true;
|
||||||
_chatmessage_dirty = false;
|
_chatmessage_dirty = false;
|
||||||
|
|
|
@ -775,7 +775,7 @@ void ScanNewGRFFiles(NewGRFScanCallback *callback)
|
||||||
/* Only then can we really start, especially by marking the whole screen dirty. Get those other windows hidden!. */
|
/* Only then can we really start, especially by marking the whole screen dirty. Get those other windows hidden!. */
|
||||||
MarkWholeScreenDirty();
|
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_work_mutex->EndCritical();
|
||||||
_modal_progress_paint_mutex->EndCritical();
|
_modal_progress_paint_mutex->EndCritical();
|
||||||
DoScanNewGRFFiles(callback);
|
DoScanNewGRFFiles(callback);
|
||||||
|
|
|
@ -97,7 +97,7 @@ void CDECL usererror(const char *s, ...)
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
ShowOSErrorBox(buf, false);
|
ShowOSErrorBox(buf, false);
|
||||||
if (_video_driver != NULL) _video_driver->Stop();
|
if (VideoDriver::GetInstance() != NULL) VideoDriver::GetInstance()->Stop();
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ static void LoadIntroGame(bool load_newgrfs = true)
|
||||||
CheckForMissingGlyphs();
|
CheckForMissingGlyphs();
|
||||||
|
|
||||||
/* Play main theme */
|
/* Play main theme */
|
||||||
if (_music_driver->IsSongPlaying()) ResetMusic();
|
if (MusicDriver::GetInstance()->IsSongPlaying()) ResetMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeNewgameSettingsLive()
|
void MakeNewgameSettingsLive()
|
||||||
|
@ -436,7 +436,7 @@ struct AfterNewGRFScan : NewGRFScanCallback {
|
||||||
*save_config_ptr = save_config;
|
*save_config_ptr = save_config;
|
||||||
|
|
||||||
/* restore saved music volume */
|
/* 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 (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 (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
|
||||||
|
@ -775,12 +775,7 @@ int openttd_main(int argc, char *argv[])
|
||||||
free(blitter);
|
free(blitter);
|
||||||
|
|
||||||
if (videodriver == NULL && _ini_videodriver != NULL) videodriver = stredup(_ini_videodriver);
|
if (videodriver == NULL && _ini_videodriver != NULL) videodriver = stredup(_ini_videodriver);
|
||||||
_video_driver = (VideoDriver*)DriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
|
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);
|
|
||||||
}
|
|
||||||
free(videodriver);
|
free(videodriver);
|
||||||
|
|
||||||
InitializeSpriteSorter();
|
InitializeSpriteSorter();
|
||||||
|
@ -811,7 +806,7 @@ int openttd_main(int argc, char *argv[])
|
||||||
goto exit_bootstrap;
|
goto exit_bootstrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
_video_driver->ClaimMousePointer();
|
VideoDriver::GetInstance()->ClaimMousePointer();
|
||||||
|
|
||||||
/* initialize screenshot formats */
|
/* initialize screenshot formats */
|
||||||
InitializeScreenshotFormats();
|
InitializeScreenshotFormats();
|
||||||
|
@ -843,21 +838,11 @@ int openttd_main(int argc, char *argv[])
|
||||||
free(music_set);
|
free(music_set);
|
||||||
|
|
||||||
if (sounddriver == NULL && _ini_sounddriver != NULL) sounddriver = stredup(_ini_sounddriver);
|
if (sounddriver == NULL && _ini_sounddriver != NULL) sounddriver = stredup(_ini_sounddriver);
|
||||||
_sound_driver = (SoundDriver*)DriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND);
|
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);
|
|
||||||
}
|
|
||||||
free(sounddriver);
|
free(sounddriver);
|
||||||
|
|
||||||
if (musicdriver == NULL && _ini_musicdriver != NULL) musicdriver = stredup(_ini_musicdriver);
|
if (musicdriver == NULL && _ini_musicdriver != NULL) musicdriver = stredup(_ini_musicdriver);
|
||||||
_music_driver = (MusicDriver*)DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
|
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);
|
|
||||||
}
|
|
||||||
free(musicdriver);
|
free(musicdriver);
|
||||||
|
|
||||||
/* Take our initial lock on whatever we might want to do! */
|
/* Take our initial lock on whatever we might want to do! */
|
||||||
|
@ -875,7 +860,7 @@ int openttd_main(int argc, char *argv[])
|
||||||
ScanNewGRFFiles(scanner);
|
ScanNewGRFFiles(scanner);
|
||||||
scanner = NULL;
|
scanner = NULL;
|
||||||
|
|
||||||
_video_driver->MainLoop();
|
VideoDriver::GetInstance()->MainLoop();
|
||||||
|
|
||||||
WaitTillSaved();
|
WaitTillSaved();
|
||||||
|
|
||||||
|
@ -943,7 +928,7 @@ static void MakeNewGameDone()
|
||||||
SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
|
SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
|
||||||
|
|
||||||
/* In a dedicated server, the server does not play */
|
/* In a dedicated server, the server does not play */
|
||||||
if (!_video_driver->HasGUI()) {
|
if (!VideoDriver::GetInstance()->HasGUI()) {
|
||||||
SetLocalCompany(COMPANY_SPECTATOR);
|
SetLocalCompany(COMPANY_SPECTATOR);
|
||||||
if (_settings_client.gui.pause_on_newgame) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
|
if (_settings_client.gui.pause_on_newgame) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
|
||||||
IConsoleCmdExec("exec scripts/game_start.scr 0");
|
IConsoleCmdExec("exec scripts/game_start.scr 0");
|
||||||
|
@ -1509,6 +1494,6 @@ void GameLoop()
|
||||||
|
|
||||||
InputLoop();
|
InputLoop();
|
||||||
|
|
||||||
_sound_driver->MainLoop();
|
SoundDriver::GetInstance()->MainLoop();
|
||||||
MusicLoop();
|
MusicLoop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,7 +523,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
|
||||||
/* Close any possible log files */
|
/* Close any possible log files */
|
||||||
CloseConsoleLogIfActive();
|
CloseConsoleLogIfActive();
|
||||||
|
|
||||||
if ((_video_driver == NULL || _video_driver->HasGUI()) && _safe_esp != NULL) {
|
if ((VideoDriver::GetInstance() == NULL || VideoDriver::GetInstance()->HasGUI()) && _safe_esp != NULL) {
|
||||||
#ifdef _M_AMD64
|
#ifdef _M_AMD64
|
||||||
ep->ContextRecord->Rip = (DWORD64)ShowCrashlogWindow;
|
ep->ContextRecord->Rip = (DWORD64)ShowCrashlogWindow;
|
||||||
ep->ContextRecord->Rsp = (DWORD64)_safe_esp;
|
ep->ContextRecord->Rsp = (DWORD64)_safe_esp;
|
||||||
|
|
|
@ -208,7 +208,7 @@ struct OskWindow : public Window {
|
||||||
|
|
||||||
virtual void OnFocusLost()
|
virtual void OnFocusLost()
|
||||||
{
|
{
|
||||||
_video_driver->EditBoxLostFocus();
|
VideoDriver::GetInstance()->EditBoxLostFocus();
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,9 +19,15 @@ class SoundDriver : public Driver {
|
||||||
public:
|
public:
|
||||||
/** Called once every tick */
|
/** Called once every tick */
|
||||||
virtual void MainLoop() {}
|
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;
|
extern char *_ini_sounddriver;
|
||||||
|
|
||||||
#endif /* SOUND_SOUND_DRIVER_HPP */
|
#endif /* SOUND_SOUND_DRIVER_HPP */
|
||||||
|
|
|
@ -597,16 +597,16 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
|
||||||
_cocoa_video_dialog = true;
|
_cocoa_video_dialog = true;
|
||||||
|
|
||||||
bool wasstarted = _cocoa_video_started;
|
bool wasstarted = _cocoa_video_started;
|
||||||
if (_video_driver == NULL) {
|
if (VideoDriver::GetInstance() == NULL) {
|
||||||
setupApplication(); // Setup application before showing dialog
|
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);
|
fprintf(stderr, "%s: %s\n", title, message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSRunAlertPanel([ NSString stringWithUTF8String:title ], [ NSString stringWithUTF8String:message ], [ NSString stringWithUTF8String:buttonLabel ], nil, nil);
|
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;
|
_cocoa_video_dialog = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,7 @@ static bool QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL dow
|
||||||
case QZ_RETURN:
|
case QZ_RETURN:
|
||||||
case QZ_f:
|
case QZ_f:
|
||||||
if (down && (_current_mods & NSCommandKeyMask)) {
|
if (down && (_current_mods & NSCommandKeyMask)) {
|
||||||
_video_driver->ToggleFullscreen(!_fullscreen);
|
VideoDriver::GetInstance()->ToggleFullscreen(!_fullscreen);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,7 +411,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Blitter::PALETTE_ANIMATION_BLITTER:
|
case Blitter::PALETTE_ANIMATION_BLITTER:
|
||||||
if (_video_driver != NULL) blitter->PaletteAnimate(_local_palette);
|
if (VideoDriver::GetInstance() != NULL) blitter->PaletteAnimate(_local_palette);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -78,9 +78,15 @@ public:
|
||||||
* An edit box lost the input focus. Abort character compositing if necessary.
|
* An edit box lost the input focus. Abort character compositing if necessary.
|
||||||
*/
|
*/
|
||||||
virtual void EditBoxLostFocus() {}
|
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 char *_ini_videodriver;
|
||||||
extern int _num_resolutions;
|
extern int _num_resolutions;
|
||||||
extern Dimension _resolutions[32];
|
extern Dimension _resolutions[32];
|
||||||
|
|
|
@ -1002,7 +1002,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
if (active && minimized) {
|
if (active && minimized) {
|
||||||
/* Restore the game window */
|
/* Restore the game window */
|
||||||
ShowWindow(hwnd, SW_RESTORE);
|
ShowWindow(hwnd, SW_RESTORE);
|
||||||
static_cast<VideoDriver_Win32 *>(_video_driver)->MakeWindow(true);
|
static_cast<VideoDriver_Win32 *>(VideoDriver::GetInstance())->MakeWindow(true);
|
||||||
} else if (!active && !minimized) {
|
} else if (!active && !minimized) {
|
||||||
/* Minimise the window and restore desktop */
|
/* Minimise the window and restore desktop */
|
||||||
ShowWindow(hwnd, SW_MINIMIZE);
|
ShowWindow(hwnd, SW_MINIMIZE);
|
||||||
|
|
|
@ -448,7 +448,7 @@ bool EditBoxInGlobalFocus()
|
||||||
void Window::UnfocusFocusedWidget()
|
void Window::UnfocusFocusedWidget()
|
||||||
{
|
{
|
||||||
if (this->nested_focus != NULL) {
|
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. */
|
/* 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->SetDirty(this);
|
||||||
|
@ -472,7 +472,7 @@ bool Window::SetFocusedWidget(int widget_index)
|
||||||
|
|
||||||
/* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */
|
/* 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->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);
|
this->nested_focus = this->GetWidget<NWidgetCore>(widget_index);
|
||||||
return true;
|
return true;
|
||||||
|
@ -483,7 +483,7 @@ bool Window::SetFocusedWidget(int widget_index)
|
||||||
*/
|
*/
|
||||||
void Window::OnFocusLost()
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue