From 108caf7ffdc32ca4bee40d256f96fbcf856cf817 Mon Sep 17 00:00:00 2001 From: Gregor Klevze Date: Wed, 10 Dec 2025 19:40:43 +0100 Subject: [PATCH] fox fonts on macc --- src/core/assets/AssetManager.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/core/assets/AssetManager.cpp b/src/core/assets/AssetManager.cpp index 2ad7be8..dc1d23d 100644 --- a/src/core/assets/AssetManager.cpp +++ b/src/core/assets/AssetManager.cpp @@ -131,14 +131,15 @@ bool AssetManager::loadFont(const std::string& id, const std::string& filepath, } // Create new font + std::string resolvedPath = AssetPath::resolveWithBase(filepath); auto font = std::make_unique(); - if (!font->init(filepath, baseSize)) { - setError("Failed to initialize font: " + filepath); + if (!font->init(resolvedPath, baseSize)) { + setError("Failed to initialize font: " + resolvedPath); return false; } m_fonts[id] = std::move(font); - logInfo("Loaded font: " + id + " from " + filepath + " (size: " + std::to_string(baseSize) + ")"); + logInfo("Loaded font: " + id + " from " + resolvedPath + " (size: " + std::to_string(baseSize) + ")"); return true; } @@ -167,14 +168,16 @@ bool AssetManager::loadMusicTrack(const std::string& filepath) { return false; } - if (!fileExists(filepath)) { - setError("Music file not found: " + filepath); + std::string resolvedPath = AssetPath::resolveWithBase(filepath); + + if (!fileExists(resolvedPath)) { + setError("Music file not found: " + resolvedPath); return false; } try { - m_audioSystem->addTrackAsync(filepath); - logInfo("Added music track for loading: " + filepath); + m_audioSystem->addTrackAsync(resolvedPath); + logInfo("Added music track for loading: " + resolvedPath); return true; } catch (const std::exception& e) { setError("Failed to add music track: " + std::string(e.what())); @@ -188,16 +191,18 @@ bool AssetManager::loadSoundEffect(const std::string& id, const std::string& fil return false; } - if (!fileExists(filepath)) { - setError("Sound effect file not found: " + filepath); + std::string resolvedPath = AssetPath::resolveWithBase(filepath); + + if (!fileExists(resolvedPath)) { + setError("Sound effect file not found: " + resolvedPath); return false; } - if (m_soundSystem->loadSound(id, filepath)) { - logInfo("Loaded sound effect: " + id + " from " + filepath); + if (m_soundSystem->loadSound(id, resolvedPath)) { + logInfo("Loaded sound effect: " + id + " from " + resolvedPath); return true; } else { - setError("Failed to load sound effect: " + id + " from " + filepath); + setError("Failed to load sound effect: " + id + " from " + resolvedPath); return false; } } @@ -354,8 +359,9 @@ std::string AssetManager::getAssetPath(const std::string& relativePath) { } bool AssetManager::fileExists(const std::string& filepath) { + std::string resolved = AssetPath::resolveWithBase(filepath); // Use SDL file I/O for consistency with main.cpp pattern - SDL_IOStream* file = SDL_IOFromFile(filepath.c_str(), "rb"); + SDL_IOStream* file = SDL_IOFromFile(resolved.c_str(), "rb"); if (file) { SDL_CloseIO(file); return true;