Fix compilation when using SDL < 2.0.14 (needed for SDL_OpenURL).

Abstract SDL functionality into SDL-specific class, away from Dialog class.
This commit is contained in:
Stephen Anthony 2021-04-17 13:18:10 -02:30
parent a91aea1b22
commit 690b21f482
3 changed files with 21 additions and 7 deletions

View File

@ -181,6 +181,15 @@ class MediaFactory
#endif
}
static bool openURL(const string& url)
{
#if defined(SDL_SUPPORT)
return SDLOpenURL(url);
#else
return false;
#endif
}
private:
// Following constructors and assignment operators not supported
MediaFactory() = delete;

View File

@ -54,4 +54,13 @@ static inline string SDLVersion()
return buf.str();
}
static inline bool SDLOpenURL(const string& url)
{
#if SDL_VERSION_ATLEAST(2,0,14)
return SDL_OpenURL(url.c_str()) == 0;
#else
return false;
#endif
}
#endif // SDL_LIB_HXX

View File

@ -36,6 +36,7 @@
#include "Vec.hxx"
#include "TIA.hxx"
#include "MediaFactory.hxx"
/*
* TODO list
@ -183,13 +184,8 @@ const string Dialog::getHelpURL()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::openHelp()
{
if(hasHelp())
{
if(SDL_OpenURL(getHelpURL().c_str()))
{
cerr << "error opening URL " << getHelpURL() << endl;
}
}
if(hasHelp() && !MediaFactory::openURL(getHelpURL()))
cerr << "error opening URL " << getHelpURL() << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -