mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 15:26:09 +00:00
Use the Path class to lookup ModeSeven.ttf
This commit is contained in:
parent
f8e693a060
commit
b1799009b3
13
app/path.cpp
13
app/path.cpp
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
QString Path::s_LogDir;
|
QString Path::s_LogDir;
|
||||||
QString Path::s_BoxArtCacheDir;
|
QString Path::s_BoxArtCacheDir;
|
||||||
const QString Path::k_GameControllerMappingFile("gamecontrollerdb.txt");
|
|
||||||
|
|
||||||
QString Path::getLogDir()
|
QString Path::getLogDir()
|
||||||
{
|
{
|
||||||
@ -22,24 +21,24 @@ QString Path::getBoxArtCacheDir()
|
|||||||
return s_BoxArtCacheDir;
|
return s_BoxArtCacheDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Path::getGamepadMappingFile()
|
QString Path::getDataFilePath(QString fileName)
|
||||||
{
|
{
|
||||||
QString candidatePath;
|
QString candidatePath;
|
||||||
|
|
||||||
// Check the current directory first
|
// Check the current directory first
|
||||||
candidatePath = QDir(QDir::currentPath()).absoluteFilePath(k_GameControllerMappingFile);
|
candidatePath = QDir(QDir::currentPath()).absoluteFilePath(fileName);
|
||||||
if (QFile::exists(candidatePath)) {
|
if (QFile::exists(candidatePath)) {
|
||||||
return candidatePath;
|
return candidatePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now check the data directories (for Linux, in particular)
|
// 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)) {
|
if (!candidatePath.isEmpty() && QFile::exists(candidatePath)) {
|
||||||
return candidatePath;
|
return candidatePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now try the directory of our app installation (for Windows, if current dir doesn't find it)
|
// 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)) {
|
if (QFile::exists(candidatePath)) {
|
||||||
return candidatePath;
|
return candidatePath;
|
||||||
}
|
}
|
||||||
@ -48,8 +47,8 @@ QString Path::getGamepadMappingFile()
|
|||||||
QDir dir = QDir(QCoreApplication::applicationDirPath());
|
QDir dir = QDir(QCoreApplication::applicationDirPath());
|
||||||
dir.cdUp();
|
dir.cdUp();
|
||||||
dir.cd("Resources");
|
dir.cd("Resources");
|
||||||
dir.filePath(k_GameControllerMappingFile);
|
dir.filePath(fileName);
|
||||||
candidatePath = dir.absoluteFilePath(k_GameControllerMappingFile);
|
candidatePath = dir.absoluteFilePath(fileName);
|
||||||
if (QFile::exists(candidatePath)) {
|
if (QFile::exists(candidatePath)) {
|
||||||
return candidatePath;
|
return candidatePath;
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,11 @@ public:
|
|||||||
|
|
||||||
static QString getBoxArtCacheDir();
|
static QString getBoxArtCacheDir();
|
||||||
|
|
||||||
static QString getGamepadMappingFile();
|
static QString getDataFilePath(QString fileName);
|
||||||
|
|
||||||
static void initialize(bool portable);
|
static void initialize(bool portable);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString s_LogDir;
|
static QString s_LogDir;
|
||||||
static QString s_BoxArtCacheDir;
|
static QString s_BoxArtCacheDir;
|
||||||
static const QString k_GameControllerMappingFile;
|
|
||||||
};
|
};
|
||||||
|
@ -54,7 +54,7 @@ void MappingManager::save()
|
|||||||
|
|
||||||
void MappingManager::applyMappings()
|
void MappingManager::applyMappings()
|
||||||
{
|
{
|
||||||
QString mappingFile = Path::getGamepadMappingFile();
|
QString mappingFile = Path::getDataFilePath("gamecontrollerdb.txt");
|
||||||
if (!mappingFile.isEmpty()) {
|
if (!mappingFile.isEmpty()) {
|
||||||
std::string mappingFileNative = QDir::toNativeSeparators(mappingFile).toStdString();
|
std::string mappingFileNative = QDir::toNativeSeparators(mappingFile).toStdString();
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include "sdlvid.h"
|
#include "sdlvid.h"
|
||||||
|
|
||||||
#include "streaming/session.h"
|
#include "streaming/session.h"
|
||||||
|
#include "path.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
#include <Limelight.h>
|
#include <Limelight.h>
|
||||||
|
|
||||||
@ -78,7 +81,14 @@ void SdlRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
|||||||
{
|
{
|
||||||
if (type == Overlay::OverlayDebug) {
|
if (type == Overlay::OverlayDebug) {
|
||||||
if (m_DebugOverlayFont == nullptr) {
|
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));
|
Session::get()->getOverlayManager().getOverlayFontSize(Overlay::OverlayDebug));
|
||||||
if (m_DebugOverlayFont == nullptr) {
|
if (m_DebugOverlayFont == nullptr) {
|
||||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user