diff --git a/app/path.cpp b/app/path.cpp index 49a48298..71502961 100644 --- a/app/path.cpp +++ b/app/path.cpp @@ -8,7 +8,6 @@ QString Path::s_LogDir; QString Path::s_BoxArtCacheDir; -const QString Path::k_GameControllerMappingFile("gamecontrollerdb.txt"); QString Path::getLogDir() { @@ -22,24 +21,24 @@ QString Path::getBoxArtCacheDir() return s_BoxArtCacheDir; } -QString Path::getGamepadMappingFile() +QString Path::getDataFilePath(QString fileName) { QString candidatePath; // Check the current directory first - candidatePath = QDir(QDir::currentPath()).absoluteFilePath(k_GameControllerMappingFile); + candidatePath = QDir(QDir::currentPath()).absoluteFilePath(fileName); if (QFile::exists(candidatePath)) { return candidatePath; } // Now check the data directories (for Linux, in particular) - candidatePath = QStandardPaths::locate(QStandardPaths::DataLocation, k_GameControllerMappingFile); + candidatePath = QStandardPaths::locate(QStandardPaths::DataLocation, fileName); if (!candidatePath.isEmpty() && QFile::exists(candidatePath)) { return candidatePath; } // Now try the directory of our app installation (for Windows, if current dir doesn't find it) - candidatePath = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(k_GameControllerMappingFile); + candidatePath = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(fileName); if (QFile::exists(candidatePath)) { return candidatePath; } @@ -48,8 +47,8 @@ QString Path::getGamepadMappingFile() QDir dir = QDir(QCoreApplication::applicationDirPath()); dir.cdUp(); dir.cd("Resources"); - dir.filePath(k_GameControllerMappingFile); - candidatePath = dir.absoluteFilePath(k_GameControllerMappingFile); + dir.filePath(fileName); + candidatePath = dir.absoluteFilePath(fileName); if (QFile::exists(candidatePath)) { return candidatePath; } diff --git a/app/path.h b/app/path.h index 1d65123b..ab17e720 100644 --- a/app/path.h +++ b/app/path.h @@ -9,12 +9,11 @@ public: static QString getBoxArtCacheDir(); - static QString getGamepadMappingFile(); + static QString getDataFilePath(QString fileName); static void initialize(bool portable); private: static QString s_LogDir; static QString s_BoxArtCacheDir; - static const QString k_GameControllerMappingFile; }; diff --git a/app/settings/mappingmanager.cpp b/app/settings/mappingmanager.cpp index a0bc31cb..0fc2efee 100644 --- a/app/settings/mappingmanager.cpp +++ b/app/settings/mappingmanager.cpp @@ -54,7 +54,7 @@ void MappingManager::save() void MappingManager::applyMappings() { - QString mappingFile = Path::getGamepadMappingFile(); + QString mappingFile = Path::getDataFilePath("gamecontrollerdb.txt"); if (!mappingFile.isEmpty()) { std::string mappingFileNative = QDir::toNativeSeparators(mappingFile).toStdString(); diff --git a/app/streaming/video/ffmpeg-renderers/sdlvid.cpp b/app/streaming/video/ffmpeg-renderers/sdlvid.cpp index b48c5062..9e6324d6 100644 --- a/app/streaming/video/ffmpeg-renderers/sdlvid.cpp +++ b/app/streaming/video/ffmpeg-renderers/sdlvid.cpp @@ -1,6 +1,9 @@ #include "sdlvid.h" #include "streaming/session.h" +#include "path.h" + +#include #include @@ -78,7 +81,14 @@ void SdlRenderer::notifyOverlayUpdated(Overlay::OverlayType type) { if (type == Overlay::OverlayDebug) { if (m_DebugOverlayFont == nullptr) { - m_DebugOverlayFont = TTF_OpenFont("ModeSeven.ttf", + QByteArray fontPath = QDir::toNativeSeparators(Path::getDataFilePath("ModeSeven.ttf")).toUtf8(); + if (fontPath.isEmpty()) { + SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, + "Unable to locate SDL overlay font"); + return; + } + + m_DebugOverlayFont = TTF_OpenFont(fontPath.data(), Session::get()->getOverlayManager().getOverlayFontSize(Overlay::OverlayDebug)); if (m_DebugOverlayFont == nullptr) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,