Permalink
Browse files

continue loading music after loading instead of switching it

  • Loading branch information...
Damgam committed Sep 13, 2018
1 parent 611b690 commit 09f7f6b5d2378850c7cf296752ee8edf82cede2d
Showing with 19 additions and 13 deletions.
  1. +1 −1 LuaIntro/Addons/music.lua
  2. +18 −12 LuaUI/Widgets_Evo/gui_musicPlayer_Dynamic_Advanced.lua
@@ -19,7 +19,7 @@ Spring.SetSoundStreamVolume(0.5)
local musicfiles = VFS.DirList("LuaUI/Widgets_Evo/Music/loading", "*.ogg")
if (#musicfiles > 0) then
Spring.PlaySoundStream(musicfiles[math.random(1,#musicfiles)], 0.5)
Spring.SetSoundStreamVolume(1)
Spring.SetSoundStreamVolume(0.5)
end
@@ -44,6 +44,7 @@ local warCutTracks = VFS.DirList('luaui/Widgets_Evo/Music/warcut', '*.ogg')
local silenceTracks = VFS.DirList('luaui/Widgets_Evo/Music/silence', '*.ogg')
local loadingTracks = VFS.DirList('luaui/Widgets_Evo/Music/loading', '*.ogg')
--We check to make sure that we can function properly without crashing due to missing music tracks
local next = next
if next(peaceTracks) == nil then
@@ -60,7 +61,8 @@ if next(warCutTracks) == nil then
warCutTracks = warTracks
end
local tracks = peaceTracks
--local tracks = peaceTracks
local tracks = loadingTracks
local firstTime = false
local wasPaused = false
@@ -108,7 +110,7 @@ local volume
local warMeter = 0
local buildMeter = false
local buildTimer = 0
local fadelvl = Spring.GetConfigInt("snd_volmusic", 20) * 0.01
local fadelvl = 0.5
local fadeOut = false
local fadeIn = false
local endFade = false
@@ -481,7 +483,7 @@ end
function widget:GameFrame(n)
--Spring.Echo([[Warmeter: ]] ..warMeter)
--This is a little messy, but we need to be able to update these values on the fly so I see no better way
if n%120 == 0 then
if n%120 == 0 and tracks ~= loadingTracks then
music_volume_set = Spring.GetConfigInt("snd_volmusic", 20) * 0.01
music_volume_target = music_volume_set
end
@@ -504,6 +506,10 @@ function widget:GameFrame(n)
else
music_volume_target = music_volume_set
end
elseif gameOver then
music_volume_target = music_volume_set
elseif tracks == loadingTracks then
music_volume_target = 0
end
--BuildMeter
@@ -618,9 +624,9 @@ function PlayNewTrack()
fadelvl = music_volume_set
warMeter = 0
buildTimer = 450
elseif Spring.GetGameFrame() == 0 then
tracks = warTracks
fadelvl = 0.15
--elseif Spring.GetGameFrame() == 0 then
--tracks = warTracks
--fadelvl = 0.15
elseif warMeter <= 0 then
if buildTimer > 10 then
tracks = peaceTracks
@@ -673,19 +679,19 @@ function widget:Update(dt)
if Spring.GetGameFrame() >= 1 then
fadelvl = 0.02
end
if Spring.GetGameFrame() == 0 then
PlayNewTrack()
end
--if Spring.GetGameFrame() == 0 then
--PlayNewTrack()
--end
firstTime = true -- pop this cherry
end
if playedTime >= totalTime then -- both zero means track stopped in 8
if Spring.GetGameFrame() >= 1 then
fadelvl = 0
end
if Spring.GetGameFrame() == 0 then
PlayNewTrack()
end
--if Spring.GetGameFrame() == 0 then
--PlayNewTrack()
--end
if gameOver then
PlayNewTrack()
end

0 comments on commit 09f7f6b

Please sign in to comment.