diff --git a/modules/client/client.lua b/modules/client/client.lua index eb7a81af..2a55da79 100644 --- a/modules/client/client.lua +++ b/modules/client/client.lua @@ -1,5 +1,8 @@ local musicFilename = "/sounds/startup" -local musicChannel = g_sounds.getChannel(1) +local musicChannel = nil +if g_sounds then + musicChannel = g_sounds.getChannel(SoundChannels.Music) +end function setMusic(filename) musicFilename = filename @@ -27,12 +30,14 @@ end function startup() -- Play startup music (The Silver Tree, by Mattias Westlund) - musicChannel:enqueue(musicFilename, 3) - connect(g_game, { onGameStart = function() musicChannel:stop(3) end }) - connect(g_game, { onGameEnd = function() - g_sounds.stopAll() - musicChannel:enqueue(musicFilename, 3) - end }) + if musicChannel then + musicChannel:enqueue(musicFilename, 3) + connect(g_game, { onGameStart = function() musicChannel:stop(3) end }) + connect(g_game, { onGameEnd = function() + g_sounds.stopAll() + musicChannel:enqueue(musicFilename, 3) + end }) + end -- Check for startup errors local errtitle = nil @@ -57,7 +62,9 @@ function init() onExit = exit }) g_window.setMinimumSize({ width = 600, height = 480 }) - g_sounds.preload(musicFilename) + if musicChannel then + g_sounds.preload(musicFilename) + end -- initialize in fullscreen mode on mobile devices if g_window.getPlatformType() == "X11-EGL" then diff --git a/modules/client_options/options.lua b/modules/client_options/options.lua index 6a2d6582..2cf5df4d 100644 --- a/modules/client_options/options.lua +++ b/modules/client_options/options.lua @@ -109,8 +109,8 @@ function init() graphicsPanel = g_ui.loadUI('graphics') optionsTabBar:addTab(tr('Graphics'), graphicsPanel, '/images/optionstab/graphics') - audioPanel = g_ui.loadUI('audio') - optionsTabBar:addTab(tr('Audio'), audioPanel, '/images/optionstab/audio') + soundPanel = g_ui.loadUI('audio') + optionsTabBar:addTab(tr('Audio'), soundPanel, '/images/optionstab/audio') optionsButton = modules.client_topmenu.addLeftButton('optionsButton', tr('Options'), '/images/topbuttons/options', toggle) audioButton = modules.client_topmenu.addLeftButton('audioButton', tr('Audio'), '/images/topbuttons/audio', function() toggleOption('enableAudio') end) @@ -190,17 +190,23 @@ function setOption(key, value, force) elseif key == 'fullscreen' then g_window.setFullscreen(value) elseif key == 'enableAudio' then - g_sounds.setAudioEnabled(value) + if g_sounds then + g_sounds.setAudioEnabled(value) + end if value then audioButton:setIcon('/images/topbuttons/audio') else audioButton:setIcon('/images/topbuttons/audio_mute') end elseif key == 'enableMusicSound' then - g_sounds.getChannel(SoundChannels.Music):setEnabled(value) + if g_sounds then + g_sounds.getChannel(SoundChannels.Music):setEnabled(value) + end elseif key == 'musicSoundVolume' then - g_sounds.getChannel(SoundChannels.Music):setGain(value/100) - audioPanel:getChildById('musicSoundVolumeLabel'):setText(tr('Music volume: %d', value)) + if g_sounds then + g_sounds.getChannel(SoundChannels.Music):setGain(value/100) + end + soundPanel:getChildById('musicSoundVolumeLabel'):setText(tr('Music volume: %d', value)) elseif key == 'showLeftPanel' then modules.game_interface.getLeftPanel():setOn(value) elseif key == 'backgroundFrameRate' then