From 708a829309ecf0a90b0494a2259c3fe39ae159dd Mon Sep 17 00:00:00 2001 From: MinaciousGrace Date: Sat, 29 Apr 2017 18:13:20 -0400 Subject: [PATCH] setup date sorting for goals so the most recently added appear first by default --- .../goaltracker.lua | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua index d2aff8d667..a58b51a56d 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic decorations/goaltracker.lua @@ -77,6 +77,17 @@ local function filterDisplay (playergoals) return index end +local function datetimetonumber(x) + x = x:gsub(" ", ""):gsub("-", ""):gsub(":", "") + return tonumber(x) +end + +local function sgDateComparator(sgA,sgB) + local a = datetimetonumber(sgA:WhenAssigned()) + local b = datetimetonumber(sgB:WhenAssigned()) + return a > b +end + local function byAchieved(scoregoal) if not scoregoal or scoregoal:IsAchieved() then return getMainColor('positive') @@ -92,12 +103,12 @@ end local r = Def.ActorFrame{ UpdateGoalsMessageCommand=function(self) playergoals = profile:GetAllGoals() + table.sort(playergoals,sgDateComparator) displayindex = filterDisplay(playergoals) numgoalpages = notShit.ceil(#displayindex/goalsperpage) end } - -- need to handle visibility toggle better... cba now -mina local function makescoregoal(i) local sg -- scoregoal object -mina @@ -245,8 +256,8 @@ local function makescoregoal(i) LoadFont("Common Large") .. { InitCommand=cmd(x,200;halign,0;zoom,0.2;diffuse,getMainColor('positive');maxwidth,800), SetCommand=function(self) - if update then - if sg then + if update then + if sg then self:settext("Assigned: "..datetimetodate(sg:WhenAssigned())) self:visible(true) else @@ -395,16 +406,4 @@ end t[#t+1] = r -t[#t+1] = LoadFont("Common Large") .. { - InitCommand=cmd(xy,frameX+80,frameY+rankingY+275;halign,0.5;zoom,0.3;diffuse,getMainColor('positive');settext,"Save Profile"), - SetCommand=function(self) - if rankingSkillset == 0 then - self:visible(true) - else - self:visible(false) - end - end, - UpdateRankingMessageCommand=cmd(queuecommand,"Set") - } - return t \ No newline at end of file