Skip to content

Commit

Permalink
overhaul offsetplot lua files
Browse files Browse the repository at this point in the history
- screenscoretaboffsetplot loads offsetplot.lua now instead of being self contained (aka redundant) and the cases for loading from scores vs pss and display changes are handled explicitly

- this includes custom scoring window code so the scoretab offsets can now make use of that (probably i haven't tested it)

- various internally redundant code was removed

- killed init commands since most of the params are no longer static; everything just updates to judgedisplay message commands

- mp evaluation stuff wasn't touched and is probably very very broken, screenonlinescoretab is also very redundant with this and should be replaced but i'll let nick handle that case
  • Loading branch information
MinaciousGrace committed Jul 16, 2018
1 parent 8d21265 commit 938f296
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 137 deletions.
108 changes: 5 additions & 103 deletions Themes/Til Death/BGAnimations/ScreenScoreTabOffsetPlot overlay.lua
Original file line number Diff line number Diff line change
@@ -1,110 +1,12 @@
-- if score is ever nil we done goofed way before this screen is ever loaded -mina
local score = getScoreForPlot()
local nrt = score:GetNoteRowVector()
-- generalized code to reduce redundancy, load general code instead

local tst = { 1.50,1.33,1.16,1.00,0.84,0.66,0.50,0.33,0.20 }
local plotWidth, plotHeight = SCREEN_WIDTH,SCREEN_WIDTH*0.3
local plotX, plotY = SCREEN_CENTER_X, SCREEN_CENTER_Y
local dotDims, plotMargin = 2, 4
local judge = GetTimingDifficulty()
local maxOffset = math.max(180, 180*tst[judge])

local o = Def.ActorFrame{
InitCommand=function(self)
self:xy(plotX,plotY)
end,
local t = Def.ActorFrame {
CodeMessageCommand=function(self,params)
if params.Name == "PlotCancel" or params.Name == "PlotExit" or params.Name == "PlotThickens" or params.Name == "PlotTwist" or params.Name == "StarPlot64" or params.Name == "SheriffOfPlottingham" then
SCREENMAN:GetTopScreen():Cancel()
end
if params.Name == "PrevJudge" and judge > 1 then
judge = judge - 1
elseif params.Name == "NextJudge" and judge < 9 then
judge = judge + 1
SCREENMAN:GetTopScreen():Cancel() -- need this so we can leave
end
maxOffset = math.max(180, 180*tst[judge])
MESSAGEMAN:Broadcast("JudgeDisplayChanged")
end
}

local dvt = score:GetOffsetVector()
local wuab = {}
local td = GAMESTATE:GetCurrentSteps(PLAYER_1):GetTimingData()
local finalSecond = GAMESTATE:GetCurrentSong(PLAYER_1):GetLastSecond()

local function fitX(x) -- Scale time values to fit within plot width.
return x/finalSecond*plotWidth - plotWidth/2
end

local function fitY(y) -- Scale offset values to fit within plot height
return -1*y/maxOffset*plotHeight/2
end

local function plotOffset(nr,dv)
if dv == 1000 then -- 1000 denotes a miss for which we use a different marker
return Def.Quad{
InitCommand=function(self)
self:xy(fitX(nr),fitY(math.max(184, tst[judge]*184))):zoomto(dotDims,dotDims):diffuse(offsetToJudgeColor(dv/1000)):valign(0)
end
}
end
return Def.Quad{
InitCommand=function(self)
self:xy(fitX(nr),fitY(dv)):zoomto(dotDims,dotDims):diffuse(offsetToJudgeColor(dv/1000))
end,
JudgeDisplayChangedMessageCommand=function(self)
local pos = fitY(dv)
if math.abs(pos) > plotHeight/2 then
self:y(fitY(math.max(184, tst[judge]*184)))
else
self:y(pos)
end
self:diffuse(offsetToJudgeColor(dv/1000, tst[judge]))
end
}
end

-- Center Bar
o[#o+1] = Def.Quad{InitCommand=function(self)
self:zoomto(plotWidth+plotMargin,1):diffuse(byJudgment("TapNoteScore_W1"))
end}
local fantabars = {22.5, 45, 90, 135}
local bantafars = {"TapNoteScore_W2", "TapNoteScore_W3", "TapNoteScore_W4", "TapNoteScore_W5"}
for i=1, #fantabars do
o[#o+1] = Def.Quad{InitCommand=function(self)
self:y( fitY(tst[judge]*fantabars[i])): zoomto(plotWidth+plotMargin,1):diffuse(byJudgment(bantafars[i]))
end}
o[#o+1] = Def.Quad{InitCommand=function(self)
self:y( fitY(-tst[judge]*fantabars[i])): zoomto(plotWidth+plotMargin,1):diffuse(byJudgment(bantafars[i]))
end}
end
-- Background
o[#o+1] = Def.Quad{InitCommand=function(self)
self:zoomto(plotWidth+plotMargin,plotHeight+plotMargin):diffuse(color("0.05,0.05,0.05,0.05")):diffusealpha(0.95)
end}
-- Convert noterows to timestamps and plot dots
local wuab = {}
for i=1,#nrt do
wuab[i] = td:GetElapsedTimeFromNoteRow(nrt[i])
o[#o+1] = plotOffset(wuab[i], dvt[i])
end

-- Early/Late markers
o[#o+1] = LoadFont("Common Normal")..{
InitCommand=function(self)
self:xy(-plotWidth/2,-plotHeight/2+2):settextf("Late (+%ims)", maxOffset):zoom(0.35):halign(0):valign(0)
end,
JudgeDisplayChangedMessageCommand=function(self)
self:settextf("Late (+%ims)", maxOffset)
end
}
o[#o+1] = LoadFont("Common Normal")..{
InitCommand=function(self)
self:xy(-plotWidth/2,plotHeight/2-2):settextf("Early (-%ims)", maxOffset):zoom(0.35):halign(0):valign(1)
end,
JudgeDisplayChangedMessageCommand=function(self)
self:settextf("Early (-%ims)", maxOffset)
end
}

return o
t[#t+1] = LoadActor("offsetplot")
return t
87 changes: 53 additions & 34 deletions Themes/Til Death/BGAnimations/offsetplot.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
-- Note this file is different from the scoretaboffsetplot because it takes values from pss and not a highscore object
-- this diffrentiation should probably be handled in a single file to reduce code redundancy -mina
-- updated to handle both immediate evaluation when pulling data from pss (doesnt require invoking calls to loadreplay data) and scoretab plot construction (does) -mina

local judges = { "marv", "perf", "great", "good", "boo", "miss" }
local tst = { 1.50,1.33,1.16,1.00,0.84,0.66,0.50,0.33,0.20 }
Expand All @@ -16,15 +15,16 @@ local plotWidth, plotHeight = 400,120
local plotX, plotY = SCREEN_WIDTH - 9 - plotWidth/2, SCREEN_HEIGHT - 56 - plotHeight/2
local dotDims, plotMargin = 2, 4
local maxOffset = math.max(180, 180*tso)
local bgalpha = 0.8

local pss = STATSMAN:GetCurStageStats():GetPlayerStageStats(PLAYER_1)
local dvt = pss:GetOffsetVector()
local nrt = pss:GetNoteRowVector()
local ctt = pss:GetTrackVector() -- column information for each offset
local ntt = pss:GetTapNoteTypeVector() -- notetype information (we use this to handle mine hits differently- currently that means not displaying them)
local td = GAMESTATE:GetCurrentSteps(PLAYER_1):GetTimingData()
-- initialize tables we need for replay data here, we don't know where we'll be loading from yet
local dvt = {}
local nrt = {}
local ctt = {}
local ntt = {}
local wuab = {}
local finalSecond = GAMESTATE:GetCurrentSong(PLAYER_1):GetLastSecond()
local td = GAMESTATE:GetCurrentSteps(PLAYER_1):GetTimingData()

local function fitX(x) -- Scale time values to fit within plot width.
return x/finalSecond*plotWidth - plotWidth/2
Expand All @@ -35,9 +35,37 @@ local function fitY(y) -- Scale offset values to fit within plot height
end

local o = Def.ActorFrame{
InitCommand=function(self)
OnCommand=function(self)
self:xy(plotX,plotY)
MESSAGEMAN:Broadcast("JudgeDisplayChanged") -- prim really handled all this much more elegantly

-- being explicit about the logic since atm these are the only 2 cases we handle
if SCREENMAN:GetTopScreen():GetName() == "ScreenEvaluationNormal" then -- default case, all data is in pss and no disk load is required
local pss = STATSMAN:GetCurStageStats():GetPlayerStageStats(PLAYER_1)
dvt = pss:GetOffsetVector()
nrt = pss:GetNoteRowVector()
ctt = pss:GetTrackVector() -- column information for each offset
ntt = pss:GetTapNoteTypeVector() -- notetype information (we use this to handle mine hits differently- currently that means not displaying them)
pss:UnloadReplayData() -- force unload replaydata in memory after loading it (not sure if i should allow this but i don't trust deconstructors) -mina
end

if SCREENMAN:GetTopScreen():GetName() == "ScreenScoreTabOffsetPlot" then -- loaded from scoretab not eval so we need to read from disk and adjust plot display
plotWidth, plotHeight = SCREEN_WIDTH,SCREEN_WIDTH*0.3
self:xy(SCREEN_CENTER_X, SCREEN_CENTER_Y)
bgalpha = 1

-- the internals here are really inefficient this should be handled better (internally) -mina
local score = getScoreForPlot()
dvt = score:GetOffsetVector()
nrt = score:GetNoteRowVector()
ctt = score:GetTrackVector()
ntt = score:GetTapNoteTypeVector()
end

-- Convert noterows to timestamps and plot dots (this is important it determines plot x values!!!)
for i=1,#nrt do
wuab[i] = td:GetElapsedTimeFromNoteRow(nrt[i])
end
MESSAGEMAN:Broadcast("JudgeDisplayChanged") -- prim really handled all this much more elegantly
end,
CodeMessageCommand=function(self,params)
if enabledCustomWindows then
Expand All @@ -62,7 +90,7 @@ local o = Def.ActorFrame{
maxOffset = (enabledCustomWindows and judge ~= 0) and customWindow.judgeWindows.boo or math.max(180, 180*tso)
MESSAGEMAN:Broadcast("JudgeDisplayChanged")
end,
UpdateNetEvalStatsMessageCommand = function(self)
UpdateNetEvalStatsMessageCommand = function(self) -- i haven't updated or tested neteval during last round of work -mina
local s = SCREENMAN:GetTopScreen():GetHighScore()
if s then
score = s
Expand All @@ -77,40 +105,32 @@ local o = Def.ActorFrame{
}
-- Center Bar
o[#o+1] = Def.Quad{
InitCommand=function(self)
JudgeDisplayChangedMessageCommand=function(self)
self:zoomto(plotWidth+plotMargin,1):diffuse(byJudgment("TapNoteScore_W1"))
end
}
local fantabars = {22.5, 45, 90, 135}
local bantafars = {"TapNoteScore_W2", "TapNoteScore_W3", "TapNoteScore_W4", "TapNoteScore_W5"}
for i=1, #fantabars do
o[#o+1] = Def.Quad{
InitCommand=function(self)
self:y( fitY(tso*fantabars[i])):zoomto(plotWidth+plotMargin,1):diffuse(byJudgment(bantafars[i]))
end,
JudgeDisplayChangedMessageCommand=function(self)
self:zoomto(plotWidth+plotMargin,1):diffuse(byJudgment(bantafars[i]))
local fit = (enabledCustomWindows and judge ~= 0) and customWindow.judgeWindows[judges[i]] or tso*fantabars[i]
self:y( fitY(fit))
end,
end
}
o[#o+1] = Def.Quad{
InitCommand=function(self)
self:y( fitY(-tso*fantabars[i])):zoomto(plotWidth+plotMargin,1):diffuse(byJudgment(bantafars[i]))
end,
JudgeDisplayChangedMessageCommand=function(self)
self:zoomto(plotWidth+plotMargin,1):diffuse(byJudgment(bantafars[i]))
local fit = (enabledCustomWindows and judge ~= 0) and customWindow.judgeWindows[judges[i]] or tso*fantabars[i]
self:y( fitY(-fit))
end,
end
}
end
-- Background
o[#o+1] = Def.Quad{InitCommand=function(self)
self:zoomto(plotWidth+plotMargin,plotHeight+plotMargin):diffuse(color("0.05,0.05,0.05,0.05")):diffusealpha(0.8)
o[#o+1] = Def.Quad{JudgeDisplayChangedMessageCommand=function(self)
self:zoomto(plotWidth+plotMargin,plotHeight+plotMargin):diffuse(color("0.05,0.05,0.05,0.05")):diffusealpha(bgalpha)
end}
-- Convert noterows to timestamps and plot dots
for i=1,#nrt do
wuab[i] = td:GetElapsedTimeFromNoteRow(nrt[i])
end

local dotWidth = dotDims / 2
o[#o+1] = Def.ActorMultiVertex{
Expand All @@ -120,11 +140,14 @@ o[#o+1] = Def.ActorMultiVertex{
local x = fitX(wuab[i])
local y = fitY(dvt[i])
local fit = (enabledCustomWindows and judge ~= 0) and customWindow.judgeWindows.boo + 3 or math.max(183, 183*tso)
local color = (enabledCustomWindows and judge ~= 0) and customOffsetToJudgeColor(dvt[i], customWindow.judgeWindows) or offsetToJudgeColor(dvt[i]/1000, tst[judge])
local color = (enabledCustomWindows and judge ~= 0) and customOffsetToJudgeColor(dvt[i], customWindow.judgeWindows) or offsetToJudgeColor(dvt[i], tst[judge])
if math.abs(y) > plotHeight/2 then
y = fitY(fit)
end
if ntt[i] ~= "TapNoteType_Mine" then -- screen out mines for now, we can maybe use a separate graphic or display later -mina

-- screen out mines for now, we can maybe use a separate graphic or display later -mina
-- i would have thought this would vomit errors for files without taptype data but i guess not?
if ntt[i] ~= "TapNoteType_Mine" then
verts[#verts+1] = {{x-dotWidth,y+dotWidth,0}, color}
verts[#verts+1] = {{x+dotWidth,y+dotWidth,0}, color}
verts[#verts+1] = {{x+dotWidth,y-dotWidth,0}, color}
Expand All @@ -138,18 +161,14 @@ o[#o+1] = Def.ActorMultiVertex{

-- Early/Late markers
o[#o+1] = LoadFont("Common Normal")..{
InitCommand=function(self)
self:xy(-plotWidth/2,-plotHeight/2+2):settextf("Late (+%ims)", maxOffset):zoom(0.35):halign(0):valign(0)
end,
JudgeDisplayChangedMessageCommand=function(self)
self:xy(-plotWidth/2,-plotHeight/2+2):settextf("Late (+%ims)", maxOffset):zoom(0.35):halign(0):valign(0)
self:settextf("Late (+%ims)", maxOffset)
end
}
o[#o+1] = LoadFont("Common Normal")..{
InitCommand=function(self)
self:xy(-plotWidth/2,plotHeight/2-2):settextf("Early (-%ims)", maxOffset):zoom(0.35):halign(0):valign(1)
end,
JudgeDisplayChangedMessageCommand=function(self)
self:xy(-plotWidth/2,plotHeight/2-2):settextf("Early (-%ims)", maxOffset):zoom(0.35):halign(0):valign(1)
self:settextf("Early (-%ims)", maxOffset)
end
}
Expand Down

0 comments on commit 938f296

Please sign in to comment.