Skip to content

Commit

Permalink
scale xmod options display with current ratemod
Browse files Browse the repository at this point in the history
simply love please stop silently changing things i beg you
  • Loading branch information
KyDash committed Apr 11, 2020
1 parent 2122c43 commit a26a512
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions Scripts/Mods.lua
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,8 @@ end
function DisplaySpeedMod(pn)
local s = ''
if modType[pn] == 'x' and tonumber(bpm[1]) then
s = math.floor(modSpeed[pn] / 100 * bpm[1] + 0.5)
if tonumber(bpm[2]) then s = s .. '-' .. math.floor(modSpeed[pn] / 100 * bpm[2] + 0.5) end
s = math.floor(modSpeed[pn] / 100 * bpm[1] * modRate + 0.5)
if tonumber(bpm[2]) then s = s .. '-' .. math.floor(modSpeed[pn] / 100 * bpm[2] * modRate + 0.5) end
s = ' (' .. s .. ')'
end
return SpeedString(pn) .. s
Expand Down Expand Up @@ -970,16 +970,31 @@ function SpeedNumber()
return SliderOption('Adjust Speed',move,display)
end

function RateMods( s )
local t = OptionRowBase('Music Rate',s and rateModsEdit or rateMods)
t.OneChoiceForAllPlayers = true
t.LoadSelections = function(self, list, pn) for i,m in ipairs(self.Choices) do if CheckMod(pn,m..'music') then list[i] = true; s = string.gsub(m,'x','') modRate = tonumber(s) end end end
t.SaveSelections = function(self, list, pn)
for i,m in ipairs(self.Choices) do if list[i] then s = string.gsub(m,'x',''); modRate = tonumber(s) end end
ApplyMod(s..'xmusic',pn+1)
MESSAGEMAN:Broadcast('RateModChanged')
do
local lastModRate = 1
local function AdjustXModFromRate()
for pn = 1, 2 do
if Player(pn) then
if modType[pn] == 'x' then

modSpeed[pn] = modSpeed[pn] * lastModRate / modRate
end
end
end
lastModRate = modRate
end

function RateMods( s )
local t = OptionRowBase('Music Rate',s and rateModsEdit or rateMods)
t.OneChoiceForAllPlayers = true
t.LoadSelections = function(self, list, pn) for i,m in ipairs(self.Choices) do if CheckMod(pn,m..'music') then list[i] = true; s = string.gsub(m,'x','') modRate = tonumber(s) end end end
t.SaveSelections = function(self, list, pn)
for i,m in ipairs(self.Choices) do if list[i] then s = string.gsub(m,'x',''); modRate = tonumber(s) AdjustXModFromRate() SetOptionRow('Adjust Speed',true) end end
ApplyMod(s..'xmusic',pn+1)
MESSAGEMAN:Broadcast('RateModChanged')
end
return t
end
return t
end

function NextScreenOption()
Expand Down Expand Up @@ -1061,13 +1076,17 @@ function CalculateSpeedMod()
end end
end

function SpeedString(pn,speed) local s = speed or modSpeed[pn] or ''; if modType[pn] == 'x' then return string.format('%g',s/100) .. 'x' else return modType[pn] .. s end end
function SpeedString(pn,speed) local s = speed or modSpeed[pn] or ''; if modType[pn] == 'x' then return string.format('%g',math.floor(s)/100) .. 'x' else return modType[pn] .. math.floor(s) end end
function SetSpeedMod(pn) ApplyMod('1x',pn) ApplyMod(SpeedString(pn),pn) BM('SpeedModChanged') end

function ApplyRateAdjust()
for pn=1,2 do
if Player(pn) and modSpeed then
ApplyMod(SpeedString(pn,math.ceil(modSpeed[pn]/modRate)),pn)
if modType[pn] == 'x' then
ApplyMod(SpeedString(pn,math.ceil(modSpeed[pn])),pn)
else
ApplyMod(SpeedString(pn,math.ceil(modSpeed[pn]/modRate)),pn)
end
end
end
end
Expand Down Expand Up @@ -1441,4 +1460,4 @@ function SaveProfile(self)
BM('SaveProfile')
self:queuecommand("SaveProfile")
end
end
end

0 comments on commit a26a512

Please sign in to comment.