diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/playlists.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/playlists.lua index 897d795948..dd68b93a5a 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/playlists.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/playlists.lua @@ -1,3 +1,30 @@ +local function genericHighlight(self, highlight, base, clickaction) + local highlight = highlight or 0.6 + local base = base or 1 + self:SetUpdateFunction(function(self) + if self:IsVisible() then + self:RunCommandsOnChildren( + function(self) + if isOver(self) then + self:diffusealpha(highlight) + else + self:diffusealpha(base) + end + end + ) + end + end + ) + self:SetUpdateFunctionInterval(0.025) + if clickaction then + self:RunCommandsOnChildren( + function(self) + self:addcommand("LeftClickMessage", clickaction) + end + ) + end +end + local update = false local t = Def.ActorFrame { @@ -42,7 +69,6 @@ local rankingWidth = frameWidth - capWideScale(15, 50) local rankingX = capWideScale(30, 50) local rankingY = capWideScale(40, 40) local rankingTitleSpacing = (rankingWidth / (#ms.SkillSets)) -local buttondiffuse = 0 local whee local singleplaylistactive = false @@ -109,7 +135,7 @@ local function BroadcastIfActive(msg) end end -local function ButtonActive(self, scale) +local function ButtonActive(self) return isOver(self) and update end @@ -169,11 +195,9 @@ local function RateDisplayButton(i) Def.ActorFrame { Name = "RateDisplay", InitCommand = function(self) + genericHighlight(self) self:x(220) end, - ResizeCommand = function(self) - self:GetChild("Button"):zoomto(self:GetChild("Text"):GetWidth(), self:GetChild("Text"):GetHeight()) - end, LoadFont("Common Large") .. { Name = "Text", @@ -183,27 +207,20 @@ local function RateDisplayButton(i) "x" self:settext(ratestring) self:zoom(fontScale) - self:GetParent():queuecommand("Resize") - end - }, - Def.Quad { - Name = "Button", - InitCommand = function(self) - self:diffusealpha(buttondiffuse) - end, - MouseLeftClickMessageCommand = function(self) - if ButtonActive(self, fontScale) and singleplaylistactive then - chartlist[i + ((currentchartpage - 1) * chartsperplaylist)]:ChangeRate(0.1) - BroadcastIfActive("DisplaySinglePlaylist") - end - end, - MouseRightClickMessageCommand = function(self) - if ButtonActive(self, fontScale) and singleplaylistactive then - chartlist[i + ((currentchartpage - 1) * chartsperplaylist)]:ChangeRate(-0.1) - BroadcastIfActive("DisplaySinglePlaylist") + end, + MouseLeftClickMessageCommand = function(self) + if ButtonActive(self) and singleplaylistactive then + chartlist[i + ((currentchartpage - 1) * chartsperplaylist)]:ChangeRate(0.1) + BroadcastIfActive("DisplaySinglePlaylist") + end + end, + MouseRightClickMessageCommand = function(self) + if ButtonActive(self) and singleplaylistactive then + chartlist[i + ((currentchartpage - 1) * chartsperplaylist)]:ChangeRate(-0.1) + BroadcastIfActive("DisplaySinglePlaylist") + end end - end - } + } } return o end @@ -213,11 +230,9 @@ local function TitleDisplayButton(i) Def.ActorFrame { Name = "TitleDisplay", InitCommand = function(self) + genericHighlight(self) self:x(15) end, - ResizeCommand = function(self) - self:GetChild("Button"):zoomto(self:GetChild("Text"):GetWidth(), self:GetChild("Text"):GetHeight()) - end, LoadFont("Common Large") .. { Name = "Text", @@ -228,29 +243,22 @@ local function TitleDisplayButton(i) self:zoom(fontScale) self:maxwidth(480) self:settext(chartlist[i + ((currentchartpage - 1) * chartsperplaylist)]:GetSongTitle()) - self:GetParent():queuecommand("Resize") if chartlist[i + ((currentchartpage - 1) * chartsperplaylist)]:IsLoaded() then self:diffuse(getMainColor("positive")) else self:diffuse(byJudgment("TapNoteScore_Miss")) end + end, + MouseLeftClickMessageCommand = function(self) + if + ButtonActive(self) and chartlist[i + ((currentchartpage - 1) * chartsperplaylist)] and + chartlist[i + ((currentchartpage - 1) * chartsperplaylist)]:IsLoaded() and + singleplaylistactive + then + whee:SelectSong(songlist[i + ((currentchartpage - 1) * chartsperplaylist)]) + end end - }, - Def.Quad { - Name = "Button", - InitCommand = function(self) - self:diffusealpha(buttondiffuse):halign(0) - end, - MouseLeftClickMessageCommand = function(self) - if - ButtonActive(self, fontScale) and chartlist[i + ((currentchartpage - 1) * chartsperplaylist)] and - chartlist[i + ((currentchartpage - 1) * chartsperplaylist)]:IsLoaded() and - singleplaylistactive - then - whee:SelectSong(songlist[i + ((currentchartpage - 1) * chartsperplaylist)]) - end - end - } + } } return o end @@ -260,11 +268,9 @@ local function DeleteChartButton(i) Def.ActorFrame { Name = "DeleteButton", InitCommand = function(self) + genericHighlight(self) self:x(315) end, - ResizeCommand = function(self) - self:GetChild("Button"):zoomto(self:GetChild("Text"):GetWidth(), self:GetChild("Text"):GetHeight()) - end, LoadFont("Common Large") .. { Name = "Text", @@ -274,23 +280,16 @@ local function DeleteChartButton(i) DisplaySinglePlaylistLevel2Command = function(self) self:zoom(fontScale) self:settext("Del") - self:GetParent():queuecommand("Resize") self:diffuse(byJudgment("TapNoteScore_Miss")) + end, + MouseLeftClickMessageCommand = function(self) + if ButtonActive(self) and singleplaylistactive then + pl:DeleteChart(i + ((currentchartpage - 1) * chartsperplaylist)) + MESSAGEMAN:Broadcast("DisplayAll") + MESSAGEMAN:Broadcast("DisplaySinglePlaylist") + end end - }, - Def.Quad { - Name = "Button", - InitCommand = function(self) - self:diffusealpha(buttondiffuse):halign(0) - end, - MouseLeftClickMessageCommand = function(self) - if ButtonActive(self, fontScale) and singleplaylistactive then - pl:DeleteChart(i + ((currentchartpage - 1) * chartsperplaylist)) - MESSAGEMAN:Broadcast("DisplayAll") - MESSAGEMAN:Broadcast("DisplaySinglePlaylist") - end - end - } + } } return o end @@ -319,10 +318,12 @@ local function rankingLabel(i) self:GetChild("DeleteButton"):visible(true) self:GetChild("TitleDisplay"):visible(true) self:GetChild("RateDisplay"):visible(true) + self:GetChild("PackMouseOver"):visible(true) else self:GetChild("DeleteButton"):visible(false) self:GetChild("TitleDisplay"):visible(false) self:GetChild("RateDisplay"):visible(false) + self:GetChild("PackMouseOver"):visible(false) end else self:visible(true) @@ -340,16 +341,41 @@ local function rankingLabel(i) self:settext(((rankingPage - 1) * 25) + i + ((currentchartpage - 1) * chartsperplaylist) .. ".") end }, - LoadFont("Common Large") .. - { - -- pack mouseover for later + Def.ActorFrame { + Name = "PackMouseOver", InitCommand = function(self) - self:x(15):maxwidth(580) - self:halign(0):zoom(fontScale) + self:SetUpdateFunction(function(self) + if self:IsVisible() then + self:queuecommand("PackMouseover") + end + end) end, - DisplaySinglePlaylistLevel2MessageCommand = function(self) - --self:settext(songlist[i]:GetGroupName()) - end + Def.Quad { + InitCommand = function(self) + Name = "mouseover", + self:x(15):zoomto(180, 8):halign(0):diffusealpha(0) + end, + PackMouseoverMessageCommand = function(self) + if isOver(self) then + self:GetParent():queuecommand("DisplayPack") + end + end + }, + LoadFont("Common Large") .. { + Name = "text", + InitCommand = function(self) + self:xy(15, -10):maxwidth(580):halign(0):zoom(fontScale) + end, + DisplayPackCommand = function(self) + if songlist[i + ((currentchartpage - 1) * chartsperplaylist)] then + self:settext(songlist[i + ((currentchartpage - 1) * chartsperplaylist)]:GetGroupName()) + self:finishtweening() + self:diffusealpha(1) + self:linear(0.25) + self:diffusealpha(0) + end + end + } }, LoadFont("Common Large") .. { @@ -399,6 +425,7 @@ end local b2 = Def.ActorFrame { InitCommand = function(self) + genericHighlight(self) self:xy(215, rankingY) end, DisplayAllMessageCommand = function(self) @@ -414,19 +441,13 @@ b2[#b2 + 1] = { InitCommand = function(self) self:zoom(0.3):x(85):settext("Play As Course") + end, + MouseLeftClickMessageCommand = function(self) + if ButtonActive(self) and singleplaylistactive then + SCREENMAN:GetTopScreen():StartPlaylistAsCourse(pl:GetName()) + end end } -b2[#b2 + 1] = - Def.Quad { - InitCommand = function(self) - self:x(85):diffusealpha(buttondiffuse):zoomto(110, 20) - end, - MouseLeftClickMessageCommand = function(self) - if ButtonActive(self, 0.3) and singleplaylistactive then - SCREENMAN:GetTopScreen():StartPlaylistAsCourse(pl:GetName()) - end - end -} -- Back button b2[#b2 + 1] = @@ -434,39 +455,23 @@ b2[#b2 + 1] = { InitCommand = function(self) self:zoom(0.3):settext("Back") + end, + MouseLeftClickMessageCommand = function(self) + if ButtonActive(self) and singleplaylistactive then + MESSAGEMAN:Broadcast("DisplayAll") + end end } -b2[#b2 + 1] = - Def.Quad { - InitCommand = function(self) - self:diffusealpha(buttondiffuse):zoomto(110, 20) - end, - MouseLeftClickMessageCommand = function(self) - if ButtonActive(self, 0.3) and singleplaylistactive then - MESSAGEMAN:Broadcast("DisplayAll") - end - end -} + r[#r + 1] = b2 -- next/prev pages for individual playlists, i guess these could be merged with the allplaylists buttons for efficiency but meh r[#r + 1] = Def.ActorFrame { InitCommand = function(self) + genericHighlight(self) self:xy(frameX + 10, frameY + rankingY + 250) end, - Def.Quad { - InitCommand = function(self) - self:xy(300, -8):zoomto(40, 20):halign(0):valign(0):diffuse(getMainColor("frames")):diffusealpha(buttondiffuse) - end, - MouseLeftClickMessageCommand = function(self) - if isOver(self) and currentchartpage < numplaylistpages and singleplaylistactive then - currentchartpage = currentchartpage + 1 - MESSAGEMAN:Broadcast("DisplaySinglePlaylist") - MESSAGEMAN:Broadcast("DisplayPP") - end - end - }, LoadFont("Common Large") .. { InitCommand = function(self) @@ -478,19 +483,14 @@ r[#r + 1] = DisplaySinglePlaylistMessageCommand = function(self) self:visible(true) end - }, - Def.Quad { - InitCommand = function(self) - self:y(-8):zoomto(65, 20):halign(0):valign(0):diffuse(getMainColor("frames")):diffusealpha(buttondiffuse) - end, - MouseLeftClickMessageCommand = function(self) - if isOver(self) and currentchartpage > 1 and singleplaylistactive then - currentchartpage = currentchartpage - 1 - MESSAGEMAN:Broadcast("DisplaySinglePlaylist") - MESSAGEMAN:Broadcast("DisplayPP") + ,MouseLeftClickMessageCommand = function(self) + if isOver(self) and currentchartpage < numplaylistpages and singleplaylistactive then + currentchartpage = currentchartpage + 1 + MESSAGEMAN:Broadcast("DisplaySinglePlaylist") + MESSAGEMAN:Broadcast("DisplayPP") + end end - end - }, + }, LoadFont("Common Large") .. { InitCommand = function(self) @@ -501,6 +501,13 @@ r[#r + 1] = end, DisplaySinglePlaylistMessageCommand = function(self) self:visible(true) + end, + MouseLeftClickMessageCommand = function(self) + if isOver(self) and currentchartpage > 1 and singleplaylistactive then + currentchartpage = currentchartpage - 1 + MESSAGEMAN:Broadcast("DisplaySinglePlaylist") + MESSAGEMAN:Broadcast("DisplayPP") + end end }, LoadFont("Common Large") .. @@ -529,11 +536,9 @@ local function PlaylistTitleDisplayButton(i) local o = Def.ActorFrame { InitCommand = function(self) + genericHighlight(self) self:x(15) end, - ResizeCommand = function(self) - self:GetChild("Button"):zoomto(self:GetChild("Text"):GetWidth(), self:GetChild("Text"):GetHeight()) - end, LoadFont("Common Large") .. { Name = "Text", @@ -544,24 +549,17 @@ local function PlaylistTitleDisplayButton(i) self:zoom(fontScale) if allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)] then self:settext(allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetName()) - self:GetParent():queuecommand("Resize") + end + end, + MouseLeftClickMessageCommand = function(self) + if ButtonActive(self) and allplaylistsactive then + SONGMAN:SetActivePlaylist(allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetName()) + pl = allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)] + MESSAGEMAN:Broadcast("DisplaySinglePlaylist") end end - }, - Def.Quad { - Name = "Button", - InitCommand = function(self) - self:diffusealpha(buttondiffuse):halign(0) - end, - MouseLeftClickMessageCommand = function(self) - if ButtonActive(self, fontScale) and allplaylistsactive then - SONGMAN:SetActivePlaylist(allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetName()) - pl = allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)] - MESSAGEMAN:Broadcast("DisplaySinglePlaylist") - end - end + } } - } return o end @@ -569,11 +567,9 @@ local function DeletePlaylistButton(i) local o = Def.ActorFrame { InitCommand = function(self) + genericHighlight(self) self:x(315) end, - ResizeCommand = function(self) - self:GetChild("Button"):zoomto(self:GetChild("Text"):GetWidth(), self:GetChild("Text"):GetHeight()) - end, LoadFont("Common Large") .. { Name = "Text", @@ -584,23 +580,16 @@ local function DeletePlaylistButton(i) if allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)] then self:settext("Del") self:zoom(fontScale) - self:GetParent():queuecommand("Resize") self:diffuse(byJudgment("TapNoteScore_Miss")) end + end, + MouseLeftClickMessageCommand = function(self) + if ButtonActive(self) and allplaylistsactive then + SONGMAN:DeletePlaylist(allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetName()) + MESSAGEMAN:Broadcast("DisplayAll") + end end - }, - Def.Quad { - Name = "Button", - InitCommand = function(self) - self:diffusealpha(buttondiffuse):halign(0) - end, - MouseLeftClickMessageCommand = function(self) - if ButtonActive(self, fontScale) and allplaylistsactive then - SONGMAN:DeletePlaylist(allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetName()) - MESSAGEMAN:Broadcast("DisplayAll") - end - end - } + } } return o end @@ -631,7 +620,6 @@ local function PlaylistSelectLabel(i) end, AllDisplayMessageCommand = function(self) self:halign(0.5) - self:diffuse(getMainColor("positive")) self:settext(((rankingPage - 1) * 25) + i + ((currentplaylistpage - 1) * playlistsperpage) .. ".") end }, @@ -640,10 +628,10 @@ local function PlaylistSelectLabel(i) InitCommand = function(self) self:halign(0):zoom(fontScale) self:xy(15, row2Yoffset) + self:diffuse(getMainColor("positive")) end, AllDisplayMessageCommand = function(self) if allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)] then - self:diffuse(getMainColor("positive")) self:settextf( "Number of charts: %d", allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetNumCharts() @@ -656,10 +644,10 @@ local function PlaylistSelectLabel(i) InitCommand = function(self) self:halign(0):zoom(fontScale) self:xy(200, row2Yoffset) + self:diffuse(getMainColor("positive")) end, AllDisplayMessageCommand = function(self) self:settextf("Average Rating:") - self:diffuse(getMainColor("positive")) end }, LoadFont("Common Large") .. @@ -723,19 +711,9 @@ end r[#r + 1] = Def.ActorFrame { InitCommand = function(self) + genericHighlight(self) self:xy(frameX + 10, frameY + rankingY + 250) end, - Def.Quad { - InitCommand = function(self) - self:xy(300, -8):zoomto(40, 20):halign(0):valign(0):diffuse(getMainColor("frames")):diffusealpha(buttondiffuse) - end, - MouseLeftClickMessageCommand = function(self) - if isOver(self) and currentplaylistpage < numplaylistpages and allplaylistsactive then - currentplaylistpage = currentplaylistpage + 1 - MESSAGEMAN:Broadcast("DisplayAll") - end - end - }, LoadFont("Common Large") .. { InitCommand = function(self) @@ -746,19 +724,14 @@ r[#r + 1] = end, DisplayAllMessageCommand = function(self) self:visible(true) + end, + MouseLeftClickMessageCommand = function(self) + if isOver(self) and currentplaylistpage < numplaylistpages and allplaylistsactive then + currentplaylistpage = currentplaylistpage + 1 + MESSAGEMAN:Broadcast("DisplayAll") + end end }, - Def.Quad { - InitCommand = function(self) - self:y(-8):zoomto(65, 20):halign(0):valign(0):diffuse(getMainColor("frames")):diffusealpha(buttondiffuse) - end, - MouseLeftClickMessageCommand = function(self) - if isOver(self) and currentplaylistpage > 1 and allplaylistsactive then - currentplaylistpage = currentplaylistpage - 1 - MESSAGEMAN:Broadcast("DisplayAll") - end - end - }, LoadFont("Common Large") .. { InitCommand = function(self) @@ -769,6 +742,12 @@ r[#r + 1] = end, DisplayAllMessageCommand = function(self) self:visible(true) + end, + MouseLeftClickMessageCommand = function(self) + if isOver(self) and currentplaylistpage > 1 and allplaylistsactive then + currentplaylistpage = currentplaylistpage - 1 + MESSAGEMAN:Broadcast("DisplayAll") + end end }, LoadFont("Common Large") ..