Skip to content

Commit

Permalink
Create a common function for directing input back to the engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
teejusb committed Jun 12, 2022
1 parent 7134656 commit 05ba3fc
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions BGAnimations/ScreenSelectMusic overlay/SortMenu/default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,24 @@ local SongSearchSettings = {
end,
}

-- General purpose function to redirect input back to the engine.
-- "self" here should refer to the SortMenu ActorFrame.
local DirectInputToEngine = function(self)
local screen = SCREENMAN:GetTopScreen()
local overlay = self:GetParent()

screen:RemoveInputCallback(sortmenu_input)
screen:RemoveInputCallback(testinput_input)
screen:RemoveInputCallback(leaderboard_input)

for player in ivalues(PlayerNumber) do
SCREENMAN:set_input_redirected(player, false)
end
self:playcommand("HideSortMenu")
overlay:playcommand("HideTestInput")
overlay:playcommand("HideLeaderboard")
end

------------------------------------------------------------

local t = Def.ActorFrame {
Expand Down Expand Up @@ -213,32 +231,10 @@ local t = Def.ActorFrame {
end,
-- this returns input back to the engine and its ScreenSelectMusic
DirectInputToEngineCommand=function(self)
local screen = SCREENMAN:GetTopScreen()
local overlay = self:GetParent()
screen:RemoveInputCallback(sortmenu_input)
screen:RemoveInputCallback(testinput_input)
screen:RemoveInputCallback(leaderboard_input)
for player in ivalues(PlayerNumber) do
SCREENMAN:set_input_redirected(player, false)
end
self:playcommand("HideSortMenu")
overlay:playcommand("HideTestInput")
overlay:playcommand("HideLeaderboard")
DirectInputToEngine(self)
end,
DirectInputToEngineForSongSearchCommand=function(self)
local screen = SCREENMAN:GetTopScreen()
local overlay = self:GetParent()

screen:RemoveInputCallback(sortmenu_input)
screen:RemoveInputCallback(testinput_input)
screen:RemoveInputCallback(leaderboard_input)

for player in ivalues(PlayerNumber) do
SCREENMAN:set_input_redirected(player, false)
end
self:playcommand("HideSortMenu")
overlay:playcommand("HideTestInput")
overlay:playcommand("HideLeaderboard")
DirectInputToEngine(self)

-- Then add the ScreenTextEntry on top.
SCREENMAN:AddNewScreenToTop("ScreenTextEntry")
Expand Down

0 comments on commit 05ba3fc

Please sign in to comment.