Skip to content

Commit

Permalink
make slightly less rough playlist frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed May 8, 2017
1 parent 2f94614 commit aa727d7
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 130 deletions.
229 changes: 122 additions & 107 deletions Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/playlists.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local t = Def.ActorFrame{
self:queuecommand("Off")
update = false
end
MESSAGEMAN:Broadcast("DisplayAll")
end,
TabChangedMessageCommand=cmd(queuecommand,"Set"),
PlayerJoinedMessageCommand=cmd(queuecommand,"Set"),
Expand All @@ -28,7 +29,6 @@ local scoreYspacing = 10
local distY = 15
local offsetX = -10
local offsetY = 20
local rankingSkillset=1
local rankingPage=1
local numrankingpages = 10
local rankingWidth = frameWidth-capWideScale(15,50)
Expand All @@ -38,17 +38,19 @@ local rankingTitleSpacing = (rankingWidth/(#ms.SkillSets))
local buttondiffuse = 0.4
local whee

local PlaylistYspacing = 30
local playliststodisplay = 10

local row2Yoffset = 12

local pl
local keylist
local ratelist
local songlist = {}
local stepslist = {}


if GAMESTATE:IsPlayerEnabled(PLAYER_1) then
profile = GetPlayerOrMachineProfile(PLAYER_1)
end

local allplaylists
local playlistnames

t[#t+1] = Def.Quad{InitCommand=cmd(xy,frameX,frameY;zoomto,frameWidth,frameHeight;halign,0;valign,0;diffuse,color("#333333CC"))}
t[#t+1] = Def.Quad{InitCommand=cmd(xy,frameX,frameY;zoomto,frameWidth,offsetY;halign,0;valign,0;diffuse,getMainColor('frames');diffusealpha,0.5)}
Expand All @@ -64,7 +66,6 @@ local function ButtonActive(self,scale)
return isOverScaled(self,scale) and update
end


local function makesimpletextbutton(buttontext, leftcmd, rightcmd)
local o = Def.ActorFrame{
OnCommand=function(self)
Expand Down Expand Up @@ -102,13 +103,12 @@ local r = Def.ActorFrame{
OnCommand=function(self)
whee = SCREENMAN:GetTopScreen():GetMusicWheel()
end,
UpdateRankingMessageCommand=function(self)
DisplayPlaylistMessageCommand=function(self)
if update then
pl = SONGMAN:GetActivePlaylist()
if pl then
keylist = pl:GetChartlist()
ratelist = pl:GetRatelist()

for j=1,#keylist do
songlist[j] = SONGMAN:GetSongByChartKey(keylist[j])
stepslist[j] = SONGMAN:GetStepsByChartKey(keylist[j])
Expand All @@ -117,7 +117,7 @@ local r = Def.ActorFrame{
--songlist = pl:GetSonglist()
--stepslist = pl:GetStepslist()
self:visible(true)
self:RunCommandsOnChildren(cmd(queuecommand, "Display"))
self:RunCommandsOnChildren(cmd(queuecommand, "DisplayPP"))
end
else
self:visible(false)
Expand All @@ -131,7 +131,6 @@ local r = Def.ActorFrame{
}
}

r[#r+1] = makesimpletextbutton("Add Chart", function() pl:AddChart(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey()) end)

local function RateDisplayButton(i)
local o = Def.ActorFrame{
Expand All @@ -141,7 +140,7 @@ local function RateDisplayButton(i)
end,
LoadFont("Common Large") .. {
Name="Text",
DisplayCommand=function(self)
DisplayPlaylistCommand=function(self)
local ratestring = string.format("%.2f", ratelist[i]):gsub("%.?0+$", "").."x"
self:settext(ratestring)
self:GetParent():queuecommand("Resize")
Expand All @@ -153,13 +152,13 @@ local function RateDisplayButton(i)
MouseLeftClickMessageCommand=function(self)
if ButtonActive(self,fontScale) then
pl:ChangeRateAtIndex(i,0.1)
BroadcastIfActive("UpdateRanking")
BroadcastIfActive("DisplayPlaylist")
end
end,
MouseRightClickMessageCommand=function(self)
if ButtonActive(self,fontScale) then
pl:ChangeRateAtIndex(i,-0.1)
BroadcastIfActive("UpdateRanking")
BroadcastIfActive("DisplayPlaylist")
end
end
}
Expand All @@ -176,7 +175,7 @@ local function TitleDisplayButton(i)
LoadFont("Common Large") .. {
Name="Text",
InitCommand=cmd(halign,0),
DisplayCommand=function(self)
DisplayPlaylistCommand=function(self)
self:settext(songlist[i]:GetDisplayMainTitle())
self:GetParent():queuecommand("Resize")
end
Expand All @@ -201,49 +200,42 @@ local function rankingLabel(i)
self:RunCommandsOnChildren(cmd(halign,0;zoom,fontScale))
self:visible(false)
end,
UpdateRankingMessageCommand=function(self)
if rankingSkillset > 1 and update then
pl = SONGMAN:GetActivePlaylist()
keylist = pl:GetChartlist()
ratelist = pl:GetRatelist()

for j=1,#keylist do
songlist[j] = SONGMAN:GetSongByChartKey(keylist[j])
stepslist[j] = SONGMAN:GetStepsByChartKey(keylist[j])
DisplayAllMessageCommand=cmd(visible,false),
DisplayPPMessageCommand=function(self)
if update then
if songlist[i] then
self:visible(true)
self:RunCommandsOnChildren(cmd(queuecommand, "DisplayPlaylist",visible,true))
end
--songlist = pl:GetSonglist()
--stepslist = pl:GetStepslist()
self:visible(true)
self:RunCommandsOnChildren(cmd(queuecommand, "Display"))
else
self:visible(false)
end
end,
LoadFont("Common Large") .. {
InitCommand=cmd(maxwidth,100),
DisplayCommand=function(self)
DisplayPlaylistCommand=function(self)
self:halign(0.5)
self:diffuse(getMainColor("positive"))
self:settext(((rankingPage-1)*25)+i..".")
end
},
LoadFont("Common Large") .. { -- pack mouseover for later
InitCommand=cmd(x,15;maxwidth,580),
DisplayCommand=function(self)
DisplayPlaylistCommand=function(self)
--self:settext(songlist[i]:GetGroupName())
end
},
LoadFont("Common Large") .. {
InitCommand=cmd(x,256;maxwidth,160),
DisplayCommand=function(self)
DisplayPlaylistCommand=function(self)
local rating = stepslist[i]:GetMSD(1,ratelist[i])
self:settextf("%.2f", rating)
self:diffuse(ByMSD(rating))
end
},
LoadFont("Common Large") .. {
InitCommand=cmd(x,300),
DisplayCommand=function(self)
DisplayPlaylistCommand=function(self)
local diff = stepslist[i]:GetDifficulty()
self:halign(0.5)
self:diffuse(byDifficulty(diff))
Expand All @@ -256,102 +248,125 @@ local function rankingLabel(i)
return t
end

local function rankingButton(i)
local t = Def.ActorFrame{
InitCommand=function(self)
self:xy(rankingX + (i-1)*rankingTitleSpacing, rankingY)

local b2 = Def.ActorFrame{
InitCommand=cmd(xy,260,40;zoom,0.3),
DisplayAllMessageCommand=cmd(visible,false),
DisplayPlaylistMessageCommand=cmd(visible,true)
}

b2[#b2+1] = makesimpletextbutton("Add Chart", function() pl:AddChart(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey()) end)
r[#r+1] = b2




local function PlaylistTitleDisplayButton(i)
local o = Def.ActorFrame{
InitCommand=cmd(x,15),
ResizeCommand=function(self)
self:GetChild("Button"):zoomto(self:GetChild("Text"):GetZoomedWidth(),self:GetChild("Text"):GetZoomedHeight())
end,
Def.Quad{
InitCommand=cmd(zoomto,rankingTitleSpacing,30;diffuse,getMainColor('frames');diffusealpha,0.35),
SetCommand=function(self)
if i == rankingSkillset then
self:diffusealpha(1)
else
self:diffusealpha(0.35)
LoadFont("Common Large") .. {
Name="Text",
InitCommand=cmd(halign,0),
AllDisplayCommand=function(self)
if allplaylists[i] then
self:settext(allplaylists[i]:GetName())
self:GetParent():queuecommand("Resize")
end
end,
end
},
Def.Quad{
Name="Button",
InitCommand=cmd(diffusealpha,buttondiffuse;halign,0),
MouseLeftClickMessageCommand=function(self)
if ButtonActive(self) then
rankingSkillset = i
rankingPage = 1
SCOREMAN:SortSSRs(ms.SkillSets[rankingSkillset])
BroadcastIfActive("UpdateRanking")
if ButtonActive(self,fontScale) then
SONGMAN:SetActivePlaylist(allplaylists[i]:GetName())
pl = allplaylists[i]
MESSAGEMAN:Broadcast("DisplayPlaylist")
end
end,
UpdateRankingMessageCommand=cmd(queuecommand,"Set")
},
LoadFont("Common Large") .. {
InitCommand=cmd(diffuse,getMainColor('positive');maxwidth,rankingTitleSpacing;maxheight,25;zoom,0.85),
BeginCommand=function(self)
self:settext(ms.SkillSets[i])
end
}
}
return t
return o
end

-- prev/next page
r[#r+1] = Def.ActorFrame{
InitCommand=cmd(xy, 10, frameHeight - offsetY;visible,false),
UpdateRankingMessageCommand=function(self)
if rankingSkillset > 1 then
local function PlaylistSelectLabel(i)
local t = Def.ActorFrame{
InitCommand=function(self)
self:xy(rankingX + offsetX, rankingY + offsetY + 10 + (i-1)*PlaylistYspacing)
self:RunCommandsOnChildren(cmd(halign,0;zoom,fontScale))
self:visible(true)
self:RunCommandsOnChildren(cmd(queuecommand, "Display"))
else
self:visible(false)
end
end,
Def.Quad{
InitCommand=cmd(xy,300,-8;zoomto,40,20;halign,0;valign,0;diffuse,getMainColor('frames');diffusealpha,buttondiffuse),
MouseLeftClickMessageCommand=function(self)
if isOver(self) then
if rankingPage < numrankingpages then
rankingPage = rankingPage + 1
else
rankingPage = 1
end
BroadcastIfActive("UpdateRanking")
end,
DisplayPlaylistMessageCommand=cmd(visible,false),
DisplayAllMessageCommand=function(self)
if update and allplaylists[i] then
self:visible(true)
self:RunCommandsOnChildren(cmd(queuecommand, "AllDisplay"))
else
self:visible(false)
end
end
},
LoadFont("Common Large") .. {
InitCommand=cmd(x,300;halign,0;zoom,0.3;diffuse,getMainColor('positive');settext,"Next"),
},
Def.Quad{
InitCommand=cmd(y,-8;zoomto,65,20;halign,0;valign,0;diffuse,getMainColor('frames');diffusealpha,buttondiffuse),
MouseLeftClickMessageCommand=function(self)
if isOver(self) then
if rankingPage > 1 then
rankingPage = rankingPage - 1
else
rankingPage = numrankingpages
end
BroadcastIfActive("UpdateRanking")
end,
LoadFont("Common Large") .. {
InitCommand=cmd(maxwidth,100),
AllDisplayCommand=function(self)
self:halign(0.5)
self:diffuse(getMainColor("positive"))
self:settext(((rankingPage-1)*25)+i..".")
end
end
},
LoadFont("Common Large") .. {
InitCommand=cmd(halign,0;zoom,0.3;diffuse,getMainColor('positive');settext,"Previous"),
},
LoadFont("Common Large") .. {
InitCommand=cmd(x,175;halign,0.5;zoom,0.3;diffuse,getMainColor('positive')),
DisplayCommand=function(self)
self:settextf("%i-%i", ((rankingPage-1)*25)+1, rankingPage*25)
end
},
LoadFont("Common Large") .. {
InitCommand=cmd(xy,15,row2Yoffset),
AllDisplayCommand=function(self)
self:diffuse(getMainColor("positive"))
self:settextf("Number of charts: %d", allplaylists[i]:GetNumCharts())
end
},
LoadFont("Common Large") .. {
InitCommand=cmd(xy,200,row2Yoffset),
AllDisplayCommand=function(self)
local rating = 0
self:settextf("Average Rating:%5.2f", rating)
self:diffuse(getMainColor("positive"))
end
},
}
t[#t+1] = PlaylistTitleDisplayButton(i)
return t
end

local playlists = Def.ActorFrame{
OnCommand=function(self)
allplaylists = SONGMAN:GetPlaylists()
end,
DisplayAllMessageCommand=function(self)
self:visible(true)
allplaylists = SONGMAN:GetPlaylists()
self:RunCommandsOnChildren(cmd(queuecommand, "Display"))
end
}

local b = Def.ActorFrame{
InitCommand=cmd(xy,100,frameHeight+20;zoom,0.3),
DisplayPlaylistMessageCommand=cmd(visible,false),
DisplayAllMessageCommand=cmd(visible,true)
}

for i=1,scoresperpage do
b[#b+1] = makesimpletextbutton("New Playlist", function() SONGMAN:NewPlaylist() end)
playlists[#playlists+1] = b

for i=1,scoresperpage do
r[#r+1] = rankingLabel(i)
end

-- Technically the "overall" skillset is used for single value display during music select/eval and isn't factored in to the profile rating
-- Only the specific skillsets are, and so overall should be used to display the specific skillset breakdowns separately - mina
for i=1,#ms.SkillSets do
r[#r+1] = rankingButton(i)
for i=1,playliststodisplay do
playlists[#playlists+1] = PlaylistSelectLabel(i)
end




t[#t+1] = playlists
t[#t+1] = r
return t
2 changes: 1 addition & 1 deletion src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,7 @@ XNode* Profile::SaveScoreGoalsCreateNode() const {
XNode* Profile::SavePlaylistsCreateNode() const {
XNode* playlists = new XNode("Playlists");
auto& pls = SONGMAN->allplaylists;
FOREACHUM(string, Playlist, pls, i)
FOREACHM(string, Playlist, pls, i)
playlists->AppendChild(i->second.CreateNode());
return playlists;
}
Expand Down
Loading

0 comments on commit aa727d7

Please sign in to comment.