Skip to content

Commit

Permalink
update online scoreboard to use callbacks and add replay watch button
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Nov 28, 2018
1 parent 4509801 commit 272d516
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 32 deletions.
Expand Up @@ -71,11 +71,11 @@ local function updateLeaderBoardForCurrentChart()
DLMAN:RequestChartLeaderBoardFromOnline(
steps:GetChartKey(),
function(leaderboard)
moped:playcommand("SetFromLeaderboard", leaderboard)
end
)
moped:queuecommand("ChartLeaderboardUpdate")
else
moped:queuecommand("Bort")
moped:queuecommand("SetFromLeaderboard", {})
end
end
end
Expand Down Expand Up @@ -132,6 +132,10 @@ local ret =
self:queuecommand("Set")
updateLeaderBoardForCurrentChart()
end,
ChangeStepsMessageCommand = function(self)
self:queuecommand("Set")
updateLeaderBoardForCurrentChart()
end,
CollapseCommand = function(self)
collapsed = true
resetTabIndex()
Expand Down Expand Up @@ -189,7 +193,7 @@ local ret =
end,
CurrentRateChangedMessageCommand = function(self)
if ((getTabIndex() == 2 and nestedTab == 2) or collapsed) and DLMAN:GetCurrentRateFilter() then
moped:queuecommand("ChartLeaderboardUpdate")
moped:queuecommand("GetFilteredLeaderboard")
end
end
}
Expand Down
92 changes: 63 additions & 29 deletions Themes/Til Death/BGAnimations/superscoreboard.lua
Expand Up @@ -75,20 +75,23 @@ local o =
InitCommand = function(self)
cheese = self
self:SetUpdateFunction(highlight)
self:SetUpdateFunctionInterval(0.05)
end,
BeginCommand = function(self)
SCREENMAN:GetTopScreen():AddInputCallback(input)
self:playcommand("Update")
end,
ChartLeaderboardUpdateMessageCommand = function(self)
GetFilteredLeaderboardCommand = function(self)
if GAMESTATE:GetCurrentSong() then
scoretable = DLMAN:GetChartLeaderBoard(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey(), currentCountry)
ind = 0
self:playcommand("Update")
end
end,
BortCommand = function(self)
scoretable = {}
SetFromLeaderboardCommand = function(self, lb)
scoretable = lb
ind = 0
self:playcommand("GetFilteredLeaderboard") -- we can move all the filter stuff to lua so we're not being dumb hurr hur -mina
self:playcommand("Update")
end,
UpdateCommand = function(self)
Expand Down Expand Up @@ -236,19 +239,21 @@ local o =
Name = "RequestStatus",
InitCommand = function(self)
if collapsed then
self:xy(dwidth - 75, headeroff + 15):zoom(tzoom):halign(1)
self:xy(c1x, headeroff + 15):zoom(tzoom):halign(0)
else
self:xy(dwidth / 3, headeroff + 25):zoom(tzoom):halign(1)
self:xy(c1x, headeroff + 25):zoom(tzoom):halign(0)
end
end,
UpdateCommand = function(self)
local numberofscores = #scoretable
local online = DLMAN:IsLoggedIn()
if not online and #scoretable == 0 then
if not GAMESTATE:GetCurrentSong() then
self:settext("")
elseif not online and #scoretable == 0 then
self:settext("Login to view scores")
else
if #scoretable == 0 then
self:settext("Retrieving scores...")
self:settext("Online scores not tracked...")
else
self:settext("")
end
Expand All @@ -275,7 +280,7 @@ local o =
if isOver(self) then
DLMAN:ToggleRateFilter()
ind = 0
self:GetParent():queuecommand("ChartLeaderboardUpdate")
self:GetParent():queuecommand("GetFilteredLeaderboard")
end
end
},
Expand Down Expand Up @@ -303,7 +308,7 @@ local o =
if isOver(self) then
DLMAN:ToggleTopScoresOnlyFilter()
ind = 0
self:GetParent():queuecommand("ChartLeaderboardUpdate")
self:GetParent():queuecommand("GetFilteredLeaderboard")
end
end
}
Expand All @@ -320,11 +325,11 @@ local function makeScoreDisplay(i)
self:visible(false)
end
end,
UpdateCommand = function(self)
UpdateCommand = function(self)
hs = scoretable[(i + ind)]
if hs and i <= numscores then
self:queuecommand("Display")
self:visible(true)
self:playcommand("Display")
else
self:visible(false)
end
Expand All @@ -334,28 +339,14 @@ local function makeScoreDisplay(i)
self:x(offx):zoomto(dwidth, pdh):halign(0)
end,
DisplayCommand = function(self)
if hs:HasReplayData() then
self:diffuse(color("#555555CC"))
else
self:diffuse(color("#111111CC"))
end
self:diffuse(color("#111111CC"))
end,
HighlightCommand = function(self)
if isOver(self) and collapsed then
self:diffusealpha(1)
if isOver(self) then
self:diffusealpha(0.8)
else
self:diffusealpha(0.6)
end
end,
MouseLeftClickMessageCommand = function(self)
if isOver(self) and hs then
DLMAN:RequestOnlineScoreReplayData(
hs,
function()
SCREENMAN:GetTopScreen():PlayReplay(hs)
end
)
end
end
},
LoadFont("Common normal") ..
Expand Down Expand Up @@ -461,6 +452,45 @@ local function makeScoreDisplay(i)
self:visible(true):addy(-row2yoff)
end
},
LoadFont("Common normal") ..
{
Name = "Replay" .. i,
InitCommand = function(self)
if not collapsed then
self:x(capWideScale(c3x + 52, c3x) ):zoom(tzoom - 0.05):halign(1):valign(0):maxwidth(width / 2 / tzoom):addy(row2yoff):diffuse(getMainColor("enabled"))
end
end,
DisplayCommand = function(self)
DLMAN:RequestOnlineScoreReplayData(hs,
function(replay)
if #replay > 0 then
self:settext("Watch")
else
self:settext("")
end
end
)
end,
HighlightCommand = function(self)
highlightIfOver(self)
end,
MouseLeftClickMessageCommand = function(self)
if isOver(self) and hs then
DLMAN:RequestOnlineScoreReplayData(
hs,
function()
SCREENMAN:GetTopScreen():PlayReplay(hs)
end
)
end
end,
CollapseCommand = function(self)
self:visible(false)
end,
ExpandCommand = function(self)
self:visible(true):addy(-row2yoff)
end
},
LoadFont("Common normal") ..
{
--percent
Expand All @@ -483,7 +513,11 @@ local function makeScoreDisplay(i)
end
end,
DisplayCommand = function(self)
self:settext(hs:GetDate())
if IsUsingWideScreen() then
self:settext(hs:GetDate())
else
self:settext(hs:GetDate():sub(1, 10))
end
end,
CollapseCommand = function(self)
self:visible(false)
Expand Down

0 comments on commit 272d516

Please sign in to comment.