Skip to content

Commit

Permalink
legacy options menu volume control is now more granular
Browse files Browse the repository at this point in the history
feel free to change the 0.05 to a 0.01 yourself
  • Loading branch information
poco0317 committed Aug 25, 2023
1 parent 2bdc825 commit e2c5288
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
51 changes: 51 additions & 0 deletions Themes/_fallback/Scripts/02 ThemePrefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,57 @@ function GranularSuddenOffset()
return t
end

function SoundVolumeControl()
local numlist = {}
do
local start = 0
local upper = 1
local increment = 0.05
while start <= upper do
-- these rounds should force it to be milliseconds only
numlist[#numlist+1] = tostring(notShit.round(start * 100)) .. "%"
start = notShit.round(start + increment, 3)
end
end

local t = {
Name = "SoundVolume",
LayoutType = "ShowAllInRow",
SelectType = "SelectOne",
OneChoiceForAllPlayers = true,
ExportOnChange = true,
Choices = numlist,
LoadSelections = function(self, list, pn)
local rateindex = 1
local rate = notShit.round(PREFSMAN:GetPreference("SoundVolume"), 4)
local acceptable_delta = 0.0005
for i = 1, #numlist do
local r = tonumber(numlist[i]:sub(1, -2)) / 100
if r == rate or (rate - acceptable_delta <= r and rate + acceptable_delta >= r) then
rateindex = i
break
end
end
list[rateindex] = true
end,
SaveSelections = function(self, list, pn)
for i, v in ipairs(list) do
if v == true then
local r = notShit.round(tonumber(numlist[i]:sub(1, -2)) / 100, 3)
PREFSMAN:SetPreference("SoundVolume", r)
SOUND:SetVolume(r)
break
end
end
end,
NotifyOfSelection = function(self, pn, choice)
MESSAGEMAN:Broadcast("SoundVolumeOptionChanged", {value = PREFSMAN:GetPreference("SoundVolume")})
end
}
setmetatable(t, t)
return t
end

function DisableWindowsKeyInGameplay()
local effectsMask = 2^OE["OptEffect_SavePreferences"]
effectsMask = effectsMask + 2^OE["OptEffect_ApplyGraphics"]
Expand Down
2 changes: 1 addition & 1 deletion Themes/_fallback/metrics.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,7 @@ Line13="conf,Vsync"
LineFNR="conf,FastNoteRendering"
Line14="conf,ShowStats"
Line16="conf,AttractSoundFrequency"
Line17="conf,SoundVolume"
Line17="lua,SoundVolumeControl()"
Line19="conf,EnableMineHitSound"
LineFRGlobal="lua,FrameLimitGlobal()"
LineFRGameplay="lua,FrameLimitGameplay()"
Expand Down

0 comments on commit e2c5288

Please sign in to comment.