Skip to content

Commit

Permalink
dynamic update bg with showbackgrounds pref
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Oct 22, 2021
1 parent 265bd82 commit c9fbe3c
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions Themes/Rebirth/BGAnimations/ScreenSelectMusic underlay/default.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
local showbg = function() return themeConfig:get_data().global.ShowBackgrounds end
local t = Def.ActorFrame {
Name = "UnderlayFile",
WheelSettledMessageCommand = function(self, params)
-- cascade visual update to everything
self:playcommand("Set", {song = params.song, group = params.group, hovered = params.hovered, steps = params.steps})
end
self:playcommand("Set", {
song = params.song,
group = params.group,
hovered = params.hovered,
steps = params.steps
})
end,
}

local function loadbg(self)
self:finishtweening()
self:visible(true)
if self.bgpath == self.loadedpath then return end
self:LoadBackground(self.bgpath)
self.loadedpath = self.bgpath
self:scale_or_crop_background()
self:smooth(0.5)
self:diffusealpha(0.3)
end

-- reset context manager as early as possible in the selectmusic init process
-- this should be a safe place to do it, between all context manager registrations
CONTEXTMAN:Reset()
Expand All @@ -17,16 +34,27 @@ t[#t+1] = Def.Sprite {
end,
SetCommand = function(self, params)
self:finishtweening()
self.bgpath = nil
if params.song and params.song:GetBackgroundPath() then
self:visible(true)
self:LoadBackground(params.song:GetBackgroundPath())
self:scale_or_crop_background()
self:smooth(0.5)
self:diffusealpha(0.3)
self.bgpath = params.song:GetBackgroundPath()
if not showbg() then self:visible(false) return end
loadbg(self)
else
self:visible(false)
end
end
end,
OptionUpdatedMessageCommand = function(self, params)
if params and params.name == "Show Backgrounds" then
if self.bgpath then
if showbg() then
self:visible(true)
loadbg(self)
else
self:visible(false)
end
end
end
end,
}

t[#t+1] = Def.Quad {
Expand Down Expand Up @@ -54,7 +82,7 @@ t[#t+1] = Def.Quad {
else
self:visible(false)
end
end
end,
}

return t

0 comments on commit c9fbe3c

Please sign in to comment.