Skip to content

Commit

Permalink
let click dragging musicwheel outside of bounds be possible
Browse files Browse the repository at this point in the history
also dont loop the bottom of the wheel when dragging
  • Loading branch information
poco0317 committed Aug 5, 2021
1 parent 1355068 commit c1cad55
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Themes/Til Death/Graphics/ScrollBar TickThumb.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local t = Def.ActorFrame {}
local screname
local whee
local mdown = false -- mouse down mouse up
local moving = false -- allow dragging while not over the required space
local prev = 0 -- previous wheel index moved to to prevent holding the mouse down causing a lot of clicky noises
t[#t + 1] = Def.ActorFrame {
BeginCommand = function(self)
Expand All @@ -13,12 +14,14 @@ t[#t + 1] = Def.ActorFrame {
self:SetUpdateFunction(function(self)
local mx = SCREEN_WIDTH - INPUTFILTER:GetMouseX()
local my = SCREEN_HEIGHT - INPUTFILTER:GetMouseY()
if mx < 32 and mx > 0 and my < 440 and my > 48 then
if moving or mx < 32 and mx > 0 and my < 440 and my > 48 then
moving = true
self:playcommand("ClickingMusicWheelScroller")
end
end)
else
mdown = false
moving = false
self:SetUpdateFunction(nil)
end
end
Expand All @@ -38,12 +41,15 @@ t[#t + 1] = Def.ActorFrame {
if whee then
local idx = whee:GetCurrentIndex()
local num = whee:GetNumItems()
local dum = (INPUTFILTER:GetMouseY() - 45) / (SCREEN_HEIGHT - 103)
local dum = math.min(math.max(0, INPUTFILTER:GetMouseY() - 45) / (SCREEN_HEIGHT - 103), 1)
local newmove = notShit.round(num * dum) - idx
if newmove ~= prev then
prev = notShit.round(num * dum) - idx
whee:Move(prev)
whee:Move(0)
-- prevent looping around at the bottom
if prev - num ~= idx and num - prev ~= idx then
whee:Move(prev)
whee:Move(0)
end
end
end
end
Expand Down

0 comments on commit c1cad55

Please sign in to comment.