From e353405db53a3a579cb04b1057704a71ac886905 Mon Sep 17 00:00:00 2001 From: SugoiFactory Date: Sat, 30 Mar 2024 23:28:36 -0700 Subject: [PATCH] Restart on song results screen Add Ctrl+R to restart the song during song results. --- .../Shared/RestartHandler.lua | 28 +++++++++++++++++++ .../ScreenEvaluation common/default.lua | 3 ++ 2 files changed, 31 insertions(+) create mode 100644 BGAnimations/ScreenEvaluation common/Shared/RestartHandler.lua diff --git a/BGAnimations/ScreenEvaluation common/Shared/RestartHandler.lua b/BGAnimations/ScreenEvaluation common/Shared/RestartHandler.lua new file mode 100644 index 000000000..60ee4ce2f --- /dev/null +++ b/BGAnimations/ScreenEvaluation common/Shared/RestartHandler.lua @@ -0,0 +1,28 @@ +local RestartHandler = function(event) + if not event then return end + + if event.type == "InputEventType_FirstPress" then + if event.DeviceInput.button == "DeviceButton_left ctrl" then + holdingCtrl = true + elseif event.DeviceInput.button == "DeviceButton_r" then + if holdingCtrl then + SM("Replaying Song") + SCREENMAN:GetTopScreen():SetNextScreenName("ScreenGameplay"):StartTransitioningScreen("SM_GoToNextScreen") + end + end + elseif event.type == "InputEventType_Release" then + if event.DeviceInput.button == "DeviceButton_left ctrl" then + holdingCtrl = false + end + end +end + +local t = Def.ActorFrame{ + OnCommand=function(self) + if ThemePrefs.Get("KeyboardFeatures") and PREFSMAN:GetPreference("EventMode") and not GAMESTATE:IsCourseMode() then + SCREENMAN:GetTopScreen():AddInputCallback(RestartHandler) + end + end +} + +return t \ No newline at end of file diff --git a/BGAnimations/ScreenEvaluation common/default.lua b/BGAnimations/ScreenEvaluation common/default.lua index 9875f5571..161b21cbb 100755 --- a/BGAnimations/ScreenEvaluation common/default.lua +++ b/BGAnimations/ScreenEvaluation common/default.lua @@ -48,6 +48,9 @@ end -- code for triggering a screenshot and animating a "screenshot" texture t[#t+1] = LoadActor("./Shared/ScreenshotHandler.lua") +-- code for immediately retrying the song that was just played +t[#t+1] = LoadActor("./Shared/RestartHandler.lua") + -- the title of the song and its graphical banner, if there is one t[#t+1] = LoadActor("./Shared/TitleAndBanner.lua")