Skip to content

Commit e421468

Browse files
committed
Disable ingame volume adjustment (Incomplete feature)
1 parent 069fefa commit e421468

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

source/music.lua

+13-9
Original file line numberDiff line numberDiff line change
@@ -215,34 +215,38 @@ end
215215
local LOADED = false
216216
local IGNORE_CHANGE = false
217217

218+
local ALLOW_INGAME_VOLUME = false
219+
218220
memory.hook("OnGameClosed", "Set state unloaded", function(gid, version)
219221
LOADED = false
220222
end)
221223

222224
memory.hook("menu_major", "Load Initial Volume", function(menu)
223-
if not LOADED and menu == MENU_MAIN_MENU then
225+
if memory.isMelee() and ALLOW_INGAME_VOLUME and not LOADED and menu == MENU_MAIN_MENU then
224226
LOADED = true
225227
-- Set the games music value to our value
226228
music.setVolume(music.getVolume())
227229
end
228230
end)
229231

230232
memory.hook("volume.slider", "Ingame Volume Adjust", function(volume)
231-
if LOADED then
233+
if memory.isMelee() and ALLOW_INGAME_VOLUME and LOADED then
232234
PANEL_SETTINGS:SetVolume(100-volume)
233235
end
234236
end)
235237

236238
function music.setVolume(vol)
237-
-- Melee's slider goes in increments of 5
238-
-- It seems to add +5 or -5 no matter what, but it can actually take numbers in between and still work
239-
--local nearest5 = math.round((100-vol) / 5)*5
239+
if ALLOW_INGAME_VOLUME and memory.isMelee() then
240+
-- Melee's slider goes in increments of 5
241+
-- It seems to add +5 or -5 no matter what, but it can actually take numbers in between and still work
242+
--local nearest5 = math.round((100-vol) / 5)*5
240243

241-
-- volume.slider adjust (0-100)
242-
memory.writeByte(0x8045C384, math.round(100-vol))
244+
-- volume.slider adjust (0-100)
245+
memory.writeByte(0x8045C384, math.round(100-vol))
243246

244-
-- volume.music adjust (0-127)
245-
memory.writeByte(0x804D3887, (vol/100) * 127)
247+
-- volume.music adjust (0-127)
248+
memory.writeByte(0x804D3887, (vol/100) * 127)
249+
end
246250

247251
if PLAYING_SONG and PLAYING_SONG:isPlaying() then
248252
PLAYING_SONG:setVolume((vol/100) * (memory.match.paused and 0.35 or 1))

0 commit comments

Comments
 (0)