Skip to content

Commit

Permalink
optimize noteskin preview loading to make screen entry not take forever
Browse files Browse the repository at this point in the history
i have over 60 noteskins loaded which makes this take several seconds every time i open rebirth selectmusic or any playeroptions screen. this reduces loading down to only one noteskin and it loads them on demand with little stutter for most noteskins. this is preferable to me
  • Loading branch information
poco0317 committed Jan 9, 2023
1 parent 8b43403 commit bfbccfb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Themes/Rebirth/BGAnimations/playerInfoFrame/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,10 @@ local function leftFrame()
local c = self:GetChild("N"..i)
if i == ind then
c:diffusealpha(1)
c:playcommand("Activate")
else
c:diffusealpha(0)
c:playcommand("Deactivate")
end
end
end
Expand Down Expand Up @@ -1097,8 +1099,10 @@ local function leftFrame()
local c = self:GetChild("N"..i)
if i == ind then
c:diffusealpha(1)
c:playcommand("Activate")
else
c:diffusealpha(0)
c:playcommand("Deactivate")
end
end
end
Expand Down
15 changes: 12 additions & 3 deletions Themes/_fallback/Scripts/09 SimNSkinPreview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
local function NSkinPreviewChange(Container, Player)
return function(event)
for i, n in pairs(NOTESKIN:GetNoteSkinNames()) do
Container:GetChild("N" .. i):visible(false)
Container:GetChild("N" .. i):playcommand("Deactivate")
end
for i = 1, SCREENMAN:GetTopScreen():GetNumRows() - 1 do
if SCREENMAN:GetTopScreen():GetOptionRow(i):GetName() == "NoteSkins" then
local nSkin =
Container:GetChild("N" .. SCREENMAN:GetTopScreen():GetOptionRow(i):GetChoiceInRowWithFocus(Player) + 1)
nSkin:visible(true)
nSkin:playcommand("Activate")
end
end
end
Expand Down Expand Up @@ -159,7 +159,16 @@ function LoadNSkinPreview(Noteskin, Button, Element, UseInputCallback)
end
end
end,
NOTESKIN:LoadActorForNoteSkin(Button, Element, n)
DeactivateCommand = function(self)
self:visible(false)
end,
ActivateCommand = function(self)
self:visible(true)
if self.activated then return end
self.activated = true

NOTESKIN:AddChildActorForNoteSkin(Button, Element, n, self)
end,
}
end
return t
Expand Down

0 comments on commit bfbccfb

Please sign in to comment.