Initial commit, reusable code for my nvgt based games.
This commit is contained in:
25
audio_paths.nvgt
Normal file
25
audio_paths.nvgt
Normal file
@@ -0,0 +1,25 @@
|
||||
// Audio path helpers for reusable modules.
|
||||
|
||||
// Resolves an audio path with optional extension fallback.
|
||||
// Checks exact path first, then ".ogg", then ".wav".
|
||||
string resolve_audio_path(const string audioPath) {
|
||||
if (audioPath == "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (file_exists(audioPath)) {
|
||||
return audioPath;
|
||||
}
|
||||
|
||||
string oggPath = audioPath + ".ogg";
|
||||
if (file_exists(oggPath)) {
|
||||
return oggPath;
|
||||
}
|
||||
|
||||
string wavPath = audioPath + ".wav";
|
||||
if (file_exists(wavPath)) {
|
||||
return wavPath;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
Reference in New Issue
Block a user