Skip to content

Commit

Permalink
add hovered nps to til death chart preview chord density graph
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Aug 5, 2021
1 parent 99fbff1 commit e71b19f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
27 changes: 20 additions & 7 deletions Themes/Til Death/BGAnimations/_chartpreview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ if not yPos then yPos = 55 end
if not yPosReverse then yPosReverse = 208 end

local translated_info = {
Paused = THEME:GetString("ChartPreview", "Paused")
Paused = THEME:GetString("ChartPreview", "Paused"),
NPS = THEME:GetString("ChordDensityGraph", "NPS"),
}

local function UpdatePreviewPos(self)
Expand Down Expand Up @@ -168,12 +169,24 @@ local t = Def.ActorFrame {
end,
HighlightCommand = function(self) -- use the bg for detection but move the seek pointer -mina
if isOver(self) then
self:GetParent():GetChild("Seek"):visible(true)
self:GetParent():GetChild("Seektext"):visible(true)
self:GetParent():GetChild("Seek"):x(INPUTFILTER:GetMouseX() - self:GetParent():GetX())
self:GetParent():GetChild("Seektext"):x(INPUTFILTER:GetMouseX() - self:GetParent():GetX() - 4) -- todo: refactor this lmao -mina
self:GetParent():GetChild("Seektext"):y(INPUTFILTER:GetMouseY() - self:GetParent():GetY())
self:GetParent():GetChild("Seektext"):settextf("%0.2f", self:GetParent():GetChild("Seek"):GetX() * musicratio / getCurRateValue())
local seek = self:GetParent():GetChild("Seek")
local seektext = self:GetParent():GetChild("Seektext")
local cdg = self:GetParent():GetChild("ChordDensityGraph")

seek:visible(true)
seektext:visible(true)
seek:x(INPUTFILTER:GetMouseX() - self:GetParent():GetX())
seektext:x(INPUTFILTER:GetMouseX() - self:GetParent():GetX() - 4) -- todo: refactor this lmao -mina
seektext:y(INPUTFILTER:GetMouseY() - self:GetParent():GetY())
if cdg.npsVector ~= nil and #cdg.npsVector > 0 then
local percent = clamp((INPUTFILTER:GetMouseX() - self:GetParent():GetX()) / wodth, 0, 1)
local hoveredindex = clamp(math.ceil(#cdg.npsVector * percent), math.min(1, #cdg.npsVector), #cdg.npsVector)
local hoverednps = cdg.npsVector[hoveredindex]
seektext:settextf("%0.2f - %d %s", seek:GetX() * musicratio / getCurRateValue(), hoverednps, translated_info["NPS"])
else
seektext:settextf("%0.2f", seek:GetX() * musicratio / getCurRateValue())
end

updateCalcInfoDisplays(self)
else
self:GetParent():GetChild("Seektext"):visible(false)
Expand Down
1 change: 1 addition & 0 deletions Themes/Til Death/BGAnimations/_chorddensitygraph.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ local function updateGraphMultiVertex(parent, realgraph)
end

local npsVector = graphVectors[1] -- refers to the cps vector for 1 (tap notes)
parent.npsVector = npsVector
local numberOfColumns = #npsVector
local columnWidth = wodth/numberOfColumns * rate

Expand Down

0 comments on commit e71b19f

Please sign in to comment.