Skip to content

Commit 31fe5b2

Browse files
committed
[settings] Make Lobby Music Volume trackbar update periodically
1 parent d5a23c7 commit 31fe5b2

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

LuaMenu/widgets/gui_settings_window.lua

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ local TEXT_OFFSET = 6
3838

3939
local settingsWindowHandler
4040

41+
local trackbarLobbyMusicVolume
42+
4143
--------------------------------------------------------------------------------
4244
--------------------------------------------------------------------------------
4345
-- Utilities
@@ -728,8 +730,7 @@ local function GetLobbyTabControls()
728730
}
729731
offset = offset + ITEM_OFFSET
730732

731-
children[#children + 1] = AddLabel(offset, "Menu Music Volume")
732-
children[#children + 1] = Trackbar:New {
733+
trackbarLobbyMusicVolume = Trackbar:New {
733734
x = COMBO_X,
734735
y = offset,
735736
width = COMBO_WIDTH,
@@ -747,6 +748,8 @@ local function GetLobbyTabControls()
747748
end
748749
}
749750
}
751+
children[#children + 1] = AddLabel(offset, "Menu Music Volume")
752+
children[#children + 1] = trackbarLobbyMusicVolume
750753
offset = offset + ITEM_OFFSET
751754

752755
children[#children + 1] = AddLabel(offset, "Notification Volume")
@@ -1523,6 +1526,7 @@ local function MakeTab(name, children)
15231526
}
15241527
end
15251528

1529+
local initialized = false
15261530
local function InitializeControls(window)
15271531
window.OnParent = nil
15281532

@@ -1576,6 +1580,7 @@ local function InitializeControls(window)
15761580
tabPanel.tabBar:Select(tabName)
15771581
end
15781582

1583+
initialized = true
15791584
return externalFunctions
15801585
end
15811586

@@ -1739,6 +1744,21 @@ function widget:ActivateMenu()
17391744
SetLobbyFullscreenMode(WG.Chobby.Configuration.lobby_fullscreen)
17401745
end
17411746

1747+
local dLastSync = 0
1748+
function widget:Update()
1749+
dLastSync = dLastSync + 1
1750+
if dLastSync < 10 then -- Only run this stuff every 10 updates
1751+
return
1752+
end
1753+
dLastSync = 0
1754+
1755+
if not (initialized and WG.Chobby and WG.Chobby.Configuration) then
1756+
return
1757+
end
1758+
1759+
trackbarLobbyMusicVolume.value = WG.Chobby.Configuration.menuMusicVolume
1760+
end
1761+
17421762
--local oldWidth, oldHeight, oldX, oldY
17431763
--function widget:Update()
17441764
-- if not ((currentMode == 2 or not currentMode) and lobbyFullscreen == 2) then

0 commit comments

Comments
 (0)