fox fonts on macc
This commit is contained in:
@ -131,14 +131,15 @@ bool AssetManager::loadFont(const std::string& id, const std::string& filepath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create new font
|
// Create new font
|
||||||
|
std::string resolvedPath = AssetPath::resolveWithBase(filepath);
|
||||||
auto font = std::make_unique<FontAtlas>();
|
auto font = std::make_unique<FontAtlas>();
|
||||||
if (!font->init(filepath, baseSize)) {
|
if (!font->init(resolvedPath, baseSize)) {
|
||||||
setError("Failed to initialize font: " + filepath);
|
setError("Failed to initialize font: " + resolvedPath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fonts[id] = std::move(font);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,14 +168,16 @@ bool AssetManager::loadMusicTrack(const std::string& filepath) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fileExists(filepath)) {
|
std::string resolvedPath = AssetPath::resolveWithBase(filepath);
|
||||||
setError("Music file not found: " + filepath);
|
|
||||||
|
if (!fileExists(resolvedPath)) {
|
||||||
|
setError("Music file not found: " + resolvedPath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m_audioSystem->addTrackAsync(filepath);
|
m_audioSystem->addTrackAsync(resolvedPath);
|
||||||
logInfo("Added music track for loading: " + filepath);
|
logInfo("Added music track for loading: " + resolvedPath);
|
||||||
return true;
|
return true;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
setError("Failed to add music track: " + std::string(e.what()));
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fileExists(filepath)) {
|
std::string resolvedPath = AssetPath::resolveWithBase(filepath);
|
||||||
setError("Sound effect file not found: " + filepath);
|
|
||||||
|
if (!fileExists(resolvedPath)) {
|
||||||
|
setError("Sound effect file not found: " + resolvedPath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_soundSystem->loadSound(id, filepath)) {
|
if (m_soundSystem->loadSound(id, resolvedPath)) {
|
||||||
logInfo("Loaded sound effect: " + id + " from " + filepath);
|
logInfo("Loaded sound effect: " + id + " from " + resolvedPath);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
setError("Failed to load sound effect: " + id + " from " + filepath);
|
setError("Failed to load sound effect: " + id + " from " + resolvedPath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -354,8 +359,9 @@ std::string AssetManager::getAssetPath(const std::string& relativePath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AssetManager::fileExists(const std::string& filepath) {
|
bool AssetManager::fileExists(const std::string& filepath) {
|
||||||
|
std::string resolved = AssetPath::resolveWithBase(filepath);
|
||||||
// Use SDL file I/O for consistency with main.cpp pattern
|
// 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) {
|
if (file) {
|
||||||
SDL_CloseIO(file);
|
SDL_CloseIO(file);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user