diff options
author | ExeVirus <44562154+ExeVirus@users.noreply.github.com> | 2021-11-22 12:26:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 17:26:46 +0000 |
commit | 52bfbf6ed02e16d11f353c4066a0f4129d045e15 (patch) | |
tree | 67b71be5c3b2eda54d0ac05fa23231d6daaf19ba /src/gui/guiEngine.cpp | |
parent | e35cfa589a11bbfbdbe9c815553842b472da2b41 (diff) | |
download | minetest-52bfbf6ed02e16d11f353c4066a0f4129d045e15.tar.gz minetest-52bfbf6ed02e16d11f353c4066a0f4129d045e15.tar.bz2 minetest-52bfbf6ed02e16d11f353c4066a0f4129d045e15.zip |
Allow for Game-Specific Menu Music (#11241)
Diffstat (limited to 'src/gui/guiEngine.cpp')
-rw-r--r-- | src/gui/guiEngine.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/gui/guiEngine.cpp b/src/gui/guiEngine.cpp index c39c3ee0d..b65b31304 100644 --- a/src/gui/guiEngine.cpp +++ b/src/gui/guiEngine.cpp @@ -104,16 +104,22 @@ void MenuMusicFetcher::fetchSounds(const std::string &name, if(m_fetched.count(name)) return; m_fetched.insert(name); - std::string base; - base = porting::path_share + DIR_DELIM + "sounds"; - dst_paths.insert(base + DIR_DELIM + name + ".ogg"); - int i; - for(i=0; i<10; i++) - dst_paths.insert(base + DIR_DELIM + name + "."+itos(i)+".ogg"); - base = porting::path_user + DIR_DELIM + "sounds"; - dst_paths.insert(base + DIR_DELIM + name + ".ogg"); - for(i=0; i<10; i++) - dst_paths.insert(base + DIR_DELIM + name + "."+itos(i)+".ogg"); + std::vector<fs::DirListNode> list; + // Reusable local function + auto add_paths = [&dst_paths](const std::string name, const std::string base = "") { + dst_paths.insert(base + name + ".ogg"); + for (int i = 0; i < 10; i++) + dst_paths.insert(base + name + "." + itos(i) + ".ogg"); + }; + // Allow full paths + if (name.find(DIR_DELIM_CHAR) != std::string::npos) { + add_paths(name); + } else { + std::string share_prefix = porting::path_share + DIR_DELIM; + add_paths(name, share_prefix + "sounds" + DIR_DELIM); + std::string user_prefix = porting::path_user + DIR_DELIM; + add_paths(name, user_prefix + "sounds" + DIR_DELIM); + } } /******************************************************************************/ |