Skip to content

Commit

Permalink
Update copyright, remove redudant current playing file check, allow f…
Browse files Browse the repository at this point in the history
…or full paths for menu music
  • Loading branch information
ExeVirus committed Sep 24, 2021
1 parent 805e419 commit 9b67399
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
17 changes: 9 additions & 8 deletions builtin/mainmenu/music_player.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--Minetest
--Copyright (C) 2014 sapier
--Copyright (C) 2021 ExeVirus
--
--This program is free software; you can redistribute it and/or modify
--it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -21,12 +21,13 @@ local current_music_handle = nil

-- Stops current music, if not the same as the requested file, then plays the new file on repeat
function menu_music_play(file)
if file ~= current_file then
if current_music_handle ~= nil then
core.sound_stop(current_music_handle)
end
minetest.log("playing: " .. file)
current_music_handle = core.sound_play(file, true)
current_file = file
if file == current_file then
return
end
if current_music_handle ~= nil then
core.sound_stop(current_music_handle)
end
minetest.log("playing: " .. file)
current_music_handle = core.sound_play(file, true)
current_file = file
end
4 changes: 1 addition & 3 deletions builtin/mainmenu/tab_local.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ if enable_gamebar then
mm_texture.update("singleplayer", pkgmgr.games[j])
core.set_topleft_text(pkgmgr.games[j].name)
-- Switch game theme, if found, and current game theme is not already playing
if pkgmgr.games[j].id ~= core.settings:get("menu_last_game") then
menu_music_play(pkgmgr.games[j].path .. DIR_DELIM .. "menu" .. DIR_DELIM .. "theme")
end
menu_music_play(pkgmgr.games[j].path .. DIR_DELIM .. "menu" .. DIR_DELIM .. "theme")
core.settings:set("menu_last_game",pkgmgr.games[j].id)
menudata.worldlist:set_filtercriteria(pkgmgr.games[j].id)
local index = filterlist.get_current_index(menudata.worldlist,
Expand Down
15 changes: 9 additions & 6 deletions src/gui/guiEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,15 @@ void MenuMusicFetcher::fetchSounds(const std::string &name,
dst_paths.insert(base + name + "." + itos(i) +
".ogg");
};
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);
// Allow for absolute paths
add_paths(name);
// Allow full paths
if (name.find(DIR_DELIM) != 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);
}
}

/******************************************************************************/
Expand Down

0 comments on commit 9b67399

Please sign in to comment.