diff --git a/Themes/Til Death/BGAnimations/ScreenGameplay overlay/default.lua b/Themes/Til Death/BGAnimations/ScreenGameplay overlay/default.lua index ca0fc95cd2..285961a1d5 100644 --- a/Themes/Til Death/BGAnimations/ScreenGameplay overlay/default.lua +++ b/Themes/Til Death/BGAnimations/ScreenGameplay overlay/default.lua @@ -2,6 +2,7 @@ local t = Def.ActorFrame {} t[#t + 1] = LoadActor("WifeJudgmentSpotting") t[#t + 1] = LoadActor("titlesplash") +t[#t + 1] = LoadActor("leaderboard") if GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerController() == "PlayerController_Replay" then t[#t + 1] = LoadActor("replayscrolling") end diff --git a/Themes/Til Death/BGAnimations/ScreenGameplay overlay/leaderboard.lua b/Themes/Til Death/BGAnimations/ScreenGameplay overlay/leaderboard.lua new file mode 100644 index 0000000000..8bfada4d60 --- /dev/null +++ b/Themes/Til Death/BGAnimations/ScreenGameplay overlay/leaderboard.lua @@ -0,0 +1,154 @@ +local t = + Widg.Container { + y = SCREEN_HEIGHT / 10 +} +local leaderboardEnabled = playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).leaderboardEnabled +if not leaderboardEnabled then + return t +end +local CRITERIA = "GetWifeScore" +local NUM_ENTRIES = 5 +local ENTRY_HEIGHT = 35 +local WIDTH = SCREEN_WIDTH * 0.3 + +if not DLMAN:GetCurrentRateFilter() then + DLMAN:ToggleRateFilter() +end +local onlineScores = DLMAN:RequestChartLeaderBoard(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey()) +local sortFunction = function(h1, h2) + return h1[CRITERIA](h1) > h2[CRITERIA](h2) +end +table.sort(onlineScores, sortFunction) +local curScore +curScore = { + GetDisplayName = function() + return DLMAN:GetUsername() + end, + GetWifeGrade = function() + return curScore.curGrade + end, + GetWifeScore = function() + return curScore.curWifeScore + end, + GetSkillsetSSR = function() + return -1 + end, + GetJudgmentString = function() + return "" + end +} +curScore.curWifeScore = 0 +curScore.curGrade = "Grade_Tier02" +local scoreboard = {} +for i = 1, NUM_ENTRIES do + scoreboard[i] = i == NUM_ENTRIES and curScore or onlineScores[i] +end + +local entryActors = {} +for i = 1, NUM_ENTRIES do + entryActors[i] = {} +end +function scoreEntry(i) + local entryActor + local entry = + Widg.Container { + x = 20, + y = (i - 1) * ENTRY_HEIGHT * 1.3, + onInit = function(self) + entryActor = self + end + } + entry:add( + Widg.Rectangle { + width = WIDTH, + height = ENTRY_HEIGHT, + color = getLeaderboardColor("background"), + halign = 0.5 + } + ) + local labelContainer = + Widg.Container { + x = 60 + } + entry:add(labelContainer) + local y + local addLabel = function(name, fn, x, y, valign, halign) + valign = valign or 1 + halign = halign or 1 + y = y or 0 + labelContainer:add( + Widg.Label { + onInit = function(self) + entryActors[i][name] = self + self.updateLabel = function(hs) + fn(self, hs) + end + fn(self, scoreboard[i]) + end, + halign = 0, + scale = 0.4, + x = (x - WIDTH / 2) * 0.4, + y = 10 + y, + color = getLeaderboardColor("text") + } + ) + end + addLabel( + "rank", + function(self, hs) + self:settext(tostring(i)) + end, + 5, + ENTRY_HEIGHT / 2 - 10 + ) + addLabel( + "ssr", + function(self, hs) + local ssr = hs:GetSkillsetSSR("Overall") + if ssr < 0 then + self:settext("") + else + self:settextf("%.2f", ssr):diffuse(byMSD(ssr)) + end + end, + 40 + ) + addLabel( + "name", + function(self, hs) + self:settext(hs:GetDisplayName()) + end, + 140 + ) + --WIDTH - 84 + addLabel( + "wife", + function(self, hs) + self:settextf("%05.2f%%", hs:GetWifeScore() * 100):diffuse(byGrade(hs:GetWifeGrade())) + end, + 2 * WIDTH - 20 + ) + addLabel( + "judges", + function(self, hs) + self:settext(hs:GetJudgmentString()) + end, + WIDTH, + ENTRY_HEIGHT / 2 + ) + return entry +end +for i = 1, NUM_ENTRIES do + t[#t + 1] = scoreEntry(i) +end + +t.JudgmentMessageCommand = function(self, params) + table.sort(scoreboard, sortFunction) + for i, entry in ipairs(entryActors) do + for name, label in pairs(entry) do + label.updateLabel(scoreboard[i]) + end + end +end + +return t diff --git a/Themes/Til Death/BGAnimations/superscoreboard.lua b/Themes/Til Death/BGAnimations/superscoreboard.lua index 7126a19dfc..e177002aa2 100644 --- a/Themes/Til Death/BGAnimations/superscoreboard.lua +++ b/Themes/Til Death/BGAnimations/superscoreboard.lua @@ -92,6 +92,10 @@ local filts = {"All Rates", "Current Rate"} local topornah = {"Top Scores", "All Scores"} local scoretable +local scoretablegetter = function() + return scoretable +end + local o = Def.ActorFrame { Name = "ScoreDisplay", @@ -107,7 +111,7 @@ local o = self:queuecommand("ChartLeaderboardUpdate") end, ChartLeaderboardUpdateMessageCommand = function(self) - scoretable = DLMAN:RequestChartLeaderBoard(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey(),getIsGlobalRanking()) + scoretable = DLMAN:RequestChartLeaderBoard(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey(), getIsGlobalRanking()) ind = 0 self:playcommand("Update") end, @@ -154,7 +158,8 @@ local o = collapsed = true self:diffusealpha(0.8) - if -- a generic bounds check function that snaps an actor onto the screen or within specified coordinates should be added as an actor member, ie, not this -mina + if + -- a generic bounds check function that snaps an actor onto the screen or within specified coordinates should be added as an actor member, ie, not this -mina FILTERMAN:grabposx("ScoreDisplay") <= 10 or FILTERMAN:grabposy("ScoreDisplay") <= 45 or FILTERMAN:grabposx("ScoreDisplay") >= SCREEN_WIDTH - 60 or FILTERMAN:grabposy("ScoreDisplay") >= SCREEN_HEIGHT - 45 @@ -234,7 +239,7 @@ local o = self:diffusealpha(0):zoomto(400, 400) local nx = INPUTFILTER:GetMouseX() - width / 2 local ny = INPUTFILTER:GetMouseY() - self:GetY() - self:GetParent():SaveXY(nx, ny) -- this can probably be wrapped for convenience -mina + self:GetParent():SaveXY(nx, ny) -- this can probably be wrapped for convenience -mina self:GetParent():LoadXY() else self:zoomto(dwidth / 2, pdh / 2) @@ -298,181 +303,8 @@ local o = } } -local function makeScoreDisplay(i) - local hs - - local o = - Def.ActorFrame { - InitCommand = function(self) - self:y(packspaceY * i + headeroff) - if i > numscores then - self:visible(false) - end - end, - UpdateCommand = function(self) - hs = scoretable[(i + ind)] - if hs and i <= numscores then - self:queuecommand("Display") - self:visible(true) - else - self:visible(false) - end - end, - Def.Quad { - InitCommand = function(self) - self:x(offx):zoomto(dwidth, pdh):halign(0) - end, - DisplayCommand = function(self) - self:diffuse(color("#111111CC")) - end, - HighlightCommand = function(self) - if isOver(self) and collapsed then - self:diffusealpha(1) - else - self:diffusealpha(0.6) - end - end - }, - LoadFont("Common normal") .. - { - --rank - InitCommand = function(self) - self:x(c0x):zoom(tzoom):halign(0):valign(0) - if collapsed then - self:x(c0x):zoom(tzoom):halign(0):valign(0.5) - end - end, - DisplayCommand = function(self) - self:settextf("%i.", i + ind) - end - }, - LoadFont("Common normal") .. - { - --ssr - InitCommand = function(self) - self:x(c2x - c1x + offx):zoom(tzoom + 0.05):halign(0.5):valign(1) - if collapsed then - self:x(46):zoom(tzoom + 0.15):halign(0.5):valign(0.5):maxwidth(20 / tzoom) - end - end, - DisplayCommand = function(self) - local ssr = hs:GetSkillsetSSR("Overall") - self:settextf("%.2f", ssr):diffuse(byMSD(ssr)) - end - }, - LoadFont("Common normal") .. - { - --rate - InitCommand = function(self) - self:x(c2x - c1x + offx):zoom(tzoom - 0.05):halign(0.5):valign(0):addy(row2yoff) - if collapsed then - self:x(c4x - 14):zoom(tzoom):halign(1):valign(0.5):addy(-row2yoff):maxwidth(30 / tzoom) - end - end, - DisplayCommand = function(self) - local ratestring = string.format("%.2f", hs:GetMusicRate()):gsub("%.?0$", "") .. "x" - self:settext(ratestring) - end, - ExpandCommand = function(self) - self:addy(-row2yoff) - end - }, - LoadFont("Common normal") .. - { - --name - InitCommand = function(self) - self:x(c2x):zoom(tzoom + 0.1):maxwidth((c3x - c2x - capWideScale(10, 40)) / tzoom):halign(0):valign(1) - if collapsed then - self:x(c2x + 10):maxwidth(60 / tzoom):zoom(tzoom + 0.2):valign(0.5) - end - end, - DisplayCommand = function(self) - self:settext(hs:GetDisplayName()) - if hs:GetChordCohesion() then - self:diffuse(color("#F0EEA6")) - else - self:diffuse(getMainColor("positive")) - end - end, - HighlightCommand = function(self) - highlightIfOver(self) - end, - MouseLeftClickMessageCommand = function(self) - if isOver(self) then - local urlstringyo = "https://etternaonline.com/user/" .. hs:GetDisplayName() - GAMESTATE:ApplyGameCommand("urlnoexit," .. urlstringyo) - end - end - }, - LoadFont("Common normal") .. - { - --judgments - InitCommand = function(self) - if not collapsed then - self:x(c2x):zoom(tzoom - 0.05):halign(0):valign(0):maxwidth(width / 2 / tzoom):addy(row2yoff) - end - end, - DisplayCommand = function(self) - self:settext(hs:GetJudgmentString()) - if hs:GetChordCohesion() then - self:diffuse(color("#F0EEA6")) - else - self:diffuse(getMainColor("positive")) - end - end, - HighlightCommand = function(self) - highlightIfOver(self) - end, - MouseLeftClickMessageCommand = function(self) - if isOver(self) then - local urlstringyo = "https://etternaonline.com/score/view/" .. hs:GetScoreid() .. hs:GetUserid() - GAMESTATE:ApplyGameCommand("urlnoexit," .. urlstringyo) - end - end, - CollapseCommand = function(self) - self:visible(false) - end, - ExpandCommand = function(self) - self:visible(true):addy(-row2yoff) - end - }, - LoadFont("Common normal") .. - { - --percent - InitCommand = function(self) - self:x(c5x):zoom(tzoom + 0.15):halign(1):valign(1) - if collapsed then - self:x(c5x):zoom(tzoom + 0.15):halign(1):valign(0.5):maxwidth(30 / tzoom) - end - end, - DisplayCommand = function(self) - self:settextf("%05.2f%%", hs:GetWifeScore() * 10000 / 100):diffuse(byGrade(hs:GetWifeGrade())) - end - }, - LoadFont("Common normal") .. - { - --date - InitCommand = function(self) - if not collapsed then - self:x(c5x):zoom(tzoom - 0.05):halign(1):valign(0):maxwidth(width / 4 / tzoom):addy(row2yoff) - end - end, - DisplayCommand = function(self) - self:settext(hs:GetDate()) - end, - CollapseCommand = function(self) - self:visible(false) - end, - ExpandCommand = function(self) - self:visible(true):addy(-row2yoff) - end - } - } - return o -end - for i = 1, numscores do - o[#o + 1] = makeScoreDisplay(i) + o[#o + 1] = Scores.makeDisplay(i, scoretablegetter) end return o diff --git a/Themes/Til Death/Languages/en.ini b/Themes/Til Death/Languages/en.ini index 9c7b3125a6..8ad0c35e27 100644 --- a/Themes/Til Death/Languages/en.ini +++ b/Themes/Til Death/Languages/en.ini @@ -116,6 +116,7 @@ ErrorBar=Error Bar ErrorBarLoc=Error Bar Position PlayerInfo = Player Info FullProgressBar = Full Progressbar +Leaderboard = Leaderboard MiniProgressBar = Mini Progressbar BackgroundType = Background Type AvgScoreType = Avg. Scoretype @@ -155,6 +156,7 @@ JudgeCounter = Enable Judge Counter. Displays your currently obtained judgment c ErrorBar = Enable Error Bar. Visual representation of your judgments' deviation from the intended mark. This is about as taxing as the judge counter performance-wise, though more useful. EWMA mode uses the Exponential Weighted Moving Average for its display. ErrorBarLoc = Set the positioning of the error bar to center or bottom. PlayerInfo = Enable the player info display in the bottom left. This is the most taxing gameplay screen element. Expect a 20% or higher drop in average fps. It's also useless for non-streamers. Advised to disable. +Leaderboard = Displays the top 4 global scores against your current one FullProgressBar = Displays your progress through the song as well as song title. MiniProgressBar = Display a smaller, less intrusive, more accessible version of the progress bar placed above the combo text. BackgroundType = Set the type of background during gameplay. Static backgrounds will disable background movies. diff --git a/Themes/Til Death/Scripts/01 color_config.lua b/Themes/Til Death/Scripts/01 color_config.lua index 6f78268869..89d43e68c1 100644 --- a/Themes/Til Death/Scripts/01 color_config.lua +++ b/Themes/Til Death/Scripts/01 color_config.lua @@ -7,6 +7,11 @@ local defaultConfig = { negative = "#FF9999", positive = "#9654FD" }, + leaderboard = { + background = "#111111CC", + border = "#000111", + text = "#9654FD" + }, clearType = { MFC = "#66ccff", WF = "#dddddd", @@ -99,7 +104,7 @@ local defaultConfig = { } colorConfig = create_setting("colorConfig", "colorConfig.lua", defaultConfig, -1) -colorConfig:load() +--colorConfig:load() --keys to current table. Assumes a depth of 2. local curColor = {"", ""} @@ -116,6 +121,10 @@ function getMainColor(type) return color(colorConfig:get_data().main[type]) end +function getLeaderboardColor(type) + return color(colorConfig:get_data().leaderboard[type]) +end + function getGradeColor(grade) return color(colorConfig:get_data().grade[grade]) or color(colorConfig:get_data().grade["Grade_None"]) end diff --git a/Themes/Til Death/Scripts/01 player_config.lua b/Themes/Til Death/Scripts/01 player_config.lua index 3ce4707c9e..147fa7f285 100644 --- a/Themes/Til Death/Scripts/01 player_config.lua +++ b/Themes/Til Death/Scripts/01 player_config.lua @@ -9,6 +9,7 @@ local defaultConfig = { TargetTrackerMode = 0, JudgeCounter = true, ErrorBar = 1, + leaderboardEnabled = 1, PlayerInfo = true, FullProgressBar = true, MiniProgressBar = true, diff --git a/Themes/Til Death/Scripts/02 ThemePrefs.lua b/Themes/Til Death/Scripts/02 ThemePrefs.lua index a63d0f0e5c..f6b56abf93 100644 --- a/Themes/Til Death/Scripts/02 ThemePrefs.lua +++ b/Themes/Til Death/Scripts/02 ThemePrefs.lua @@ -381,6 +381,34 @@ function ErrorBar() return t end +function LeaderBoard() + local t = { + Name = "Leaderboard", + LayoutType = "ShowAllInRow", + SelectType = "SelectOne", + OneChoiceForAllPlayers = false, + ExportOnChange = true, + Choices = {THEME:GetString("OptionNames", "Off"), "On"}, + LoadSelections = function(self, list, pn) + local pref = playerConfig:get_data(pn_to_profile_slot(pn)).leaderboardEnabled + if pref then + list[2] = true + else + list[1] = true + end + end, + SaveSelections = function(self, list, pn) + local value + value = list[2] + playerConfig:get_data(pn_to_profile_slot(pn)).leaderboardEnabled = value + playerConfig:set_dirty(pn_to_profile_slot(pn)) + playerConfig:save(pn_to_profile_slot(pn)) + end + } + setmetatable(t, t) + return t +end + function FullProgressBar() local t = { Name = "FullProgressBar", diff --git a/Themes/Til Death/Scripts/10 Widgets.lua b/Themes/Til Death/Scripts/10 Widgets.lua index 365cc330b2..098fd063b9 100644 --- a/Themes/Til Death/Scripts/10 Widgets.lua +++ b/Themes/Til Death/Scripts/10 Widgets.lua @@ -28,6 +28,7 @@ Widg.defaults.label = { width = false, color = color("#FFFFFF"), halign = 0.5, + valign = 0.5, onInit = false } Widg.Label = function(params) @@ -37,16 +38,14 @@ Widg.Label = function(params) { Name = "Label", InitCommand = function(self) - self:xy(params.x, params.y):zoom(params.scale):halign(params.halign) + self:xy(params.x, params.y):zoom(params.scale):halign(params.halign):valign(params.valign) if type(params.width) == "number" then self:maxwidth(params.width / params.scale) end + self:settext(params.text):diffuse(params.color) if params.onInit then params.onInit(self) end - end, - BeginCommand = function(self) - self:settext(params.text):diffuse(params.color) end } end @@ -648,3 +647,43 @@ Widg.ComboBox = function(params, updateActor) frame:add(choices) return frame end + +Widg.defaults.borderedrect = { + x = 0, + y = 0, + color = "FFFFFF", + border = { + color = "000000", + width = 2 + }, + width = 100, + height = 100, + onInit = false, + alpha = 1.0, + visible = true +} +Widg.BorderedRect = function(params) + fillNilTableFieldsFrom(params, Widg.defaults.borderedrect) + params.color = checkColor(params.color) + params.border.color = checkColor(params.border.color) + return Widg.Container { + x = params.x, + y = params.y, + visible = params.visible, + onInit = params.onInit, + content = { + Widg.Borders { + width = params.width, + height = params.height, + alpha = params.alpha, + color = params.border.color + }, + Widg.Rectangle { + width = params.width, + height = params.height, + color = params.color, + borderWidth = params.border.width + } + } + } +end diff --git a/Themes/Til Death/metrics.ini b/Themes/Til Death/metrics.ini index ee11725a59..caaeb4279a 100644 --- a/Themes/Til Death/metrics.ini +++ b/Themes/Til Death/metrics.ini @@ -427,7 +427,7 @@ StepsTypeSetCommand=%function(self,param) \ end; \ [ScreenPlayerOptions] -LineNames="1,Rate,8,4,CG,RS,14,5,7,10,13,JT,DP,TT,TG,TTM,JC,EB,PI,FBP,FB,MB,SF,LC,NPS,16,BG,Life,Judge,CW,Background,Fail,Center,Score" +LineNames="1,Rate,8,4,CG,RS,14,5,7,10,13,JT,DP,TT,TG,TTM,JC,EB,PI,FBP,LEADB,FB,MB,SF,LC,NPS,16,BG,Life,Judge,CW,Background,Fail,Center,Score" LineCenter="conf,Center1Player" LineCG="lua,CustomizeGameplay()" LineRS="lua,ReceptorSize()" @@ -441,6 +441,7 @@ LineEB="lua,ErrorBar()" LinePI="lua,PlayerInfo()" LineFBP="lua,ProgressBar()" LineFB="lua,FullProgressBar()" +LineLEADB="lua,LeaderBoard()" LineMB="lua,MiniProgressBar()" LineSF="lua,OptionRowScreenFilter()" LineLC="lua,LaneCover()"