mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
settings panel moved to xml (WIP)
This commit is contained in:
parent
7cb5b2eb70
commit
9cdf3ff016
33 changed files with 254 additions and 143 deletions
34
res/layouts/pages/settings_audio.xml.lua
Normal file
34
res/layouts/pages/settings_audio.xml.lua
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
function on_open()
|
||||
new_volume_control("audio.volume-master", "master", "Master Volume")
|
||||
new_volume_control("audio.volume-regular", "regular", "Regular Sounds")
|
||||
new_volume_control("audio.volume-ui", "ui", "UI Sounds")
|
||||
new_volume_control("audio.volume-ambient", "ambient", "Ambient")
|
||||
new_volume_control("audio.volume-music", "music", "Music")
|
||||
end
|
||||
|
||||
function new_volume_control(setting, id, name)
|
||||
-- value text label
|
||||
document.tracks_panel:add("<label id='l_"..id.."'>-</label>")
|
||||
-- value track-bar
|
||||
document.tracks_panel:add(string.format(
|
||||
"<trackbar id='t_%s' min='0' max='1' value='1' step='0.01' track-width='5' "..
|
||||
" consumer='function(x) on_volume_change(%q, %q, %q, x) end'/>"
|
||||
, id, setting, id, name))
|
||||
refresh_label(setting, id, name)
|
||||
end
|
||||
|
||||
function refresh_label(setting, id, name)
|
||||
document["l_"..id].text = (
|
||||
gui.str(name, "settings")..": "..
|
||||
core.str_setting(setting)
|
||||
)
|
||||
end
|
||||
|
||||
function on_volume_change(setting, id, name, val)
|
||||
if val ~= nil then
|
||||
core.set_setting(setting, val)
|
||||
else
|
||||
document["t_"..id].value = core.get_setting(setting, val)
|
||||
end
|
||||
refresh_label(setting, id, name)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue