From 85cad9562c0b549fe6bd82ab9694875e61e38a2b Mon Sep 17 00:00:00 2001 From: FajsiEx Date: Sat, 20 Nov 2021 22:43:11 +0100 Subject: [PATCH] + better way of stopping the results music --- scripts/common/common.lua | 13 +++++++++++++ scripts/multiplayerscreen.lua | 3 +++ scripts/result.lua | 3 +-- scripts/songselect/songwheel.lua | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 scripts/common/common.lua diff --git a/scripts/common/common.lua b/scripts/common/common.lua new file mode 100644 index 0000000..91427a1 --- /dev/null +++ b/scripts/common/common.lua @@ -0,0 +1,13 @@ + + +local stopMusic = function () + local musicPlaying = game.GetSkinSetting('_musicPlaying'); + if musicPlaying and musicPlaying ~= '' then + game.StopSample(musicPlaying); + game.SetSkinSetting("_musicPlaying", "") + end +end + +return { + stopMusic = stopMusic +} \ No newline at end of file diff --git a/scripts/multiplayerscreen.lua b/scripts/multiplayerscreen.lua index ad6b066..3df4f8a 100644 --- a/scripts/multiplayerscreen.lua +++ b/scripts/multiplayerscreen.lua @@ -1,5 +1,7 @@ json = require "json" +local common = require('common.common'); + local resX,resY = game.GetResolution() local mposx = 0; @@ -742,6 +744,7 @@ render = function(deltaTime) mposx,mposy = game.GetMousePos(); portrait = resY > resX + common.stopMusic(); doffset = doffset * 0.9 ioffset = ioffset * 0.9 diff --git a/scripts/result.lua b/scripts/result.lua index dd02f34..cd656ce 100644 --- a/scripts/result.lua +++ b/scripts/result.lua @@ -169,9 +169,8 @@ local handleSfx = function() if not bgSfxPlayed then game.PlaySample("result", true) bgSfxPlayed = true + game.SetSkinSetting('_musicPlaying', 'result'); end - if game.GetButton(game.BUTTON_STA) then game.StopSample("result") end - if game.GetButton(game.BUTTON_BCK) then game.StopSample("result") end end function drawTimingBar(y, value, max, type) diff --git a/scripts/songselect/songwheel.lua b/scripts/songselect/songwheel.lua index 3888ea0..52c99f8 100644 --- a/scripts/songselect/songwheel.lua +++ b/scripts/songselect/songwheel.lua @@ -1,6 +1,7 @@ require('common') local Easing = require('common.easings') local Background = require('components.background'); +local common = require('common.common') local VolforceCalc = require('components.volforceCalc'); @@ -749,6 +750,8 @@ render = function (deltaTime) tickTransitions(deltaTime); gfx.Scale(scale, scale); + common.stopMusic(); + if not difficultyNumbers then difficultyNumbers = load_number_image('diff_num') end