Skip to content

Commit

Permalink
setup date sorting for goals so the most recently added appear first …
Browse files Browse the repository at this point in the history
…by default
  • Loading branch information
MinaciousGrace committed Apr 29, 2017
1 parent 5cbde03 commit 708a829
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 708a829

Please sign in to comment.