From c1cad55d6bd0864b0d098ce91143f7a60cfefc85 Mon Sep 17 00:00:00 2001 From: Barinade Date: Thu, 5 Aug 2021 00:37:41 -0500 Subject: [PATCH] let click dragging musicwheel outside of bounds be possible also dont loop the bottom of the wheel when dragging --- Themes/Til Death/Graphics/ScrollBar TickThumb.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Themes/Til Death/Graphics/ScrollBar TickThumb.lua b/Themes/Til Death/Graphics/ScrollBar TickThumb.lua index dcad7ce359..84d14a97f8 100644 --- a/Themes/Til Death/Graphics/ScrollBar TickThumb.lua +++ b/Themes/Til Death/Graphics/ScrollBar TickThumb.lua @@ -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) @@ -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 @@ -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