Skip to content

Commit

Permalink
move get display score to fallback scores script
Browse files Browse the repository at this point in the history
could these possibly leak/trap mem? they should probably be done directly in scoreman
  • Loading branch information
MinaciousGrace committed Nov 21, 2018
1 parent e01ab8a commit 5c9b126
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,113 +75,6 @@ t[#t + 1] =
end
}

-- Temporary update control tower; it would be nice if the basic song/step change commands were thorough and explicit and non-redundant
t[#t + 1] =
Def.Actor {
SetCommand = function(self)
if song and not alreadybroadcasted then -- if this is true it means we've just exited a pack's songlist into the packlist
song = GAMESTATE:GetCurrentSong() -- also apprently true if we're tabbing around within a songlist and then stop...
MESSAGEMAN:Broadcast("UpdateChart") -- ms.ok(whee:GetSelectedSection( )) -- use this later to detect pack changes
MESSAGEMAN:Broadcast("RefreshChartInfo")
else
alreadybroadcasted = false
end
end,
CurrentStepsP1ChangedMessageCommand = function(self)
song = GAMESTATE:GetCurrentSong()
MESSAGEMAN:Broadcast("UpdateChart")
end,
CurrentSongChangedMessageCommand = function(self)
-- This will disable mirror when switching songs if OneShotMirror is enabled or if permamirror is flagged on the chart (it is enabled if so in screengameplayunderlay/default)
if playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).OneShotMirror or profile:IsCurrentChartPermamirror() then
local modslevel = topscreen == "ScreenEditOptions" and "ModsLevel_Stage" or "ModsLevel_Preferred"
local playeroptions = GAMESTATE:GetPlayerState(PLAYER_1):GetPlayerOptions(modslevel)
playeroptions:Mirror(false)
end
if not GAMESTATE:GetCurrentSong() and noteField and mcbootlarder:GetVisible() then
mcbootlarder:visible(false)
MESSAGEMAN:Broadcast("ChartPreviewOff")
heyiwasusingthat = true
end
if heyiwasusingthat and GAMESTATE:GetCurrentSong() and noteField and getTabIndex() == 0 then
mcbootlarder:visible(true)
MESSAGEMAN:Broadcast("ChartPreviewOn")
heyiwasusingthat = false
end
self:queuecommand("Set")
end
}

local function GetBestScoreByFilter(perc, CurRate)
local rtTable = getRateTable()
if not rtTable then
return nil
end

local rates = tableKeys(rtTable)
local scores, score

if CurRate then
local tmp = getCurRateString()
if tmp == "1x" then
tmp = "1.0x"
end
if tmp == "2x" then
tmp = "2.0x"
end
rates = {tmp}
if not rtTable[rates[1]] then
return nil
end
end

table.sort(
rates,
function(a, b)
a = a:gsub("x", "")
b = b:gsub("x", "")
return a < b
end
)
for i = #rates, 1, -1 do
scores = rtTable[rates[i]]
local bestscore = 0
local index

for ii = 1, #scores do
score = scores[ii]
if score:ConvertDpToWife() > bestscore then
index = ii
bestscore = score:ConvertDpToWife()
end
end

if index and scores[index]:GetWifeScore() == 0 and GetPercentDP(scores[index]) > perc * 100 then
return scores[index]
end

if bestscore > perc then
return scores[index]
end
end
end

local function GetDisplayScore()
local score
score = GetBestScoreByFilter(0, true)

if not score then
score = GetBestScoreByFilter(0.9, false)
end
if not score then
score = GetBestScoreByFilter(0.5, false)
end
if not score then
score = GetBestScoreByFilter(0, false)
end
return score
end

local function toggleNoteField()
if song and not noteField then -- first time setup
noteField = true
Expand Down
70 changes: 70 additions & 0 deletions Themes/_fallback/Scripts/10 Scores.lua
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,73 @@ function getRescoredCustomPercentage(offsetVector, customWindows, totalHolds, ho
p = p / ((totalNotes * weights.marv) + (totalHolds * weights.holdHit))
return p * 100.0
end

function GetDisplayScoreByFilter(perc, CurRate) -- moved from wifetwirl, displays the score for the current rate if there is one,
local rtTable = getRateTable() -- if not it looks for what might plausibly be your best by going down each rate
if not rtTable then
return nil
end

local rates = tableKeys(rtTable)
local scores, score

if CurRate then
local tmp = getCurRateString()
if tmp == "1x" then
tmp = "1.0x"
end
if tmp == "2x" then
tmp = "2.0x"
end
rates = {tmp}
if not rtTable[rates[1]] then
return nil
end
end

table.sort(
rates,
function(a, b)
a = a:gsub("x", "")
b = b:gsub("x", "")
return a < b
end
)
for i = #rates, 1, -1 do
scores = rtTable[rates[i]]
local bestscore = 0
local index

for ii = 1, #scores do
score = scores[ii]
if score:ConvertDpToWife() > bestscore then
index = ii
bestscore = score:ConvertDpToWife()
end
end

if index and scores[index]:GetWifeScore() == 0 and GetPercentDP(scores[index]) > perc * 100 then
return scores[index]
end

if bestscore > perc then
return scores[index]
end
end
end

function GetDisplayScore() -- wrapper for above that prioritizes current rate's pb > any rate 90% > any rate 50% > any score any rate
local score
score = GetDisplayScoreByFilter(0, true)

if not score then
score = GetDisplayScoreByFilter(0.9, false)
end
if not score then
score = GetDisplayScoreByFilter(0.5, false)
end
if not score then
score = GetDisplayScoreByFilter(0, false)
end
return score
end

0 comments on commit 5c9b126

Please sign in to comment.