settings menu update + UINode 'enabled' property
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
<panel size='400' color='0' interval='1' context='menu'>
|
||||
<panel id='settings_panel' color='0'>
|
||||
<container size='658,404' color='#20202020' context='menu'>
|
||||
<panel pos='2' size='250' color='0' interval='1'>
|
||||
<button onclick='menu.page="languages"' id='langs_btn'>-</button>
|
||||
<button id='s_aud' onclick='set_page("s_aud", "settings_audio")'>@Audio</button>
|
||||
<button id='s_gfx' onclick='set_page("s_gfx", "settings_graphics")'>@Graphics</button>
|
||||
<button id='s_ctl' onclick='set_page("s_ctl", "settings_controls")'>@Controls</button>
|
||||
<button onclick='menu:back()'>@Back</button>
|
||||
</panel>
|
||||
<button onclick='menu.page="languages"' id='langs_btn'>-</button>
|
||||
<button onclick='menu.page="settings_audio"'>@Audio</button>
|
||||
<button onclick='menu.page="controls"'>@Controls</button>
|
||||
<button onclick='menu:back()'>@Back</button>
|
||||
</panel>
|
||||
<pagebox id='menu' pos='254,0' size='400'>
|
||||
</pagebox>
|
||||
</container>
|
||||
|
||||
@@ -1,43 +1,15 @@
|
||||
function create_setting(id, name, step, postfix)
|
||||
local info = core.get_setting_info(id)
|
||||
document.settings_panel:add(gui.template("track_setting", {
|
||||
id=id,
|
||||
name=gui.str(name, "settings"),
|
||||
value=core.get_setting(id),
|
||||
min=info.min,
|
||||
max=info.max,
|
||||
step=step,
|
||||
postfix=postfix or ""
|
||||
}))
|
||||
end
|
||||
|
||||
function update_setting(x, id, name, postfix)
|
||||
core.set_setting(id, x)
|
||||
-- updating label
|
||||
document[id..".L"].text = string.format(
|
||||
"%s: %s%s", name, core.str_setting(id), postfix
|
||||
)
|
||||
end
|
||||
|
||||
function create_checkbox(id, name)
|
||||
document.settings_panel:add(string.format(
|
||||
"<checkbox consumer='function(x) core.set_setting(\"%s\", x) end' checked='%s'>%s</checkbox>",
|
||||
id, core.str_setting(id), gui.str(name, "settings")
|
||||
))
|
||||
end
|
||||
|
||||
function on_open()
|
||||
create_setting("chunks.load-distance", "Load Distance", 1)
|
||||
create_setting("chunks.load-speed", "Load Speed", 1)
|
||||
create_setting("graphics.fog-curve", "Fog Curve", 0.1)
|
||||
create_setting("graphics.gamma", "Gamma", 0.05)
|
||||
create_setting("camera.fov", "FOV", 1, "°")
|
||||
create_checkbox("display.fullscreen", "Fullscreen")
|
||||
create_checkbox("display.vsync", "V-Sync")
|
||||
create_checkbox("graphics.backlight", "Backlight")
|
||||
create_checkbox("camera.shaking", "Camera Shaking")
|
||||
document.langs_btn.text = string.format(
|
||||
"%s: %s", gui.str("Language", "settings"),
|
||||
gui.get_locales_info()[core.get_setting("ui.language")].name
|
||||
)
|
||||
set_page("s_gfx", "settings_graphics")
|
||||
end
|
||||
|
||||
function set_page(btn, page)
|
||||
document.s_aud.enabled = true
|
||||
document.s_gfx.enabled = true
|
||||
document.s_ctl.enabled = true
|
||||
document[btn].enabled = false
|
||||
document.menu.page = page
|
||||
end
|
||||
|
||||
@@ -1,6 +1,2 @@
|
||||
<panel size='400' color='0' interval='1'>
|
||||
<panel id='tracks_panel' size='400' color='0' interval='1'>
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
<button onclick='menu:back()'>@Back</button>
|
||||
</panel>
|
||||
|
||||
@@ -1,34 +1,33 @@
|
||||
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")
|
||||
function create_setting(id, name, step, postfix)
|
||||
local info = core.get_setting_info(id)
|
||||
postfix = postfix or ""
|
||||
document.root:add(gui.template("track_setting", {
|
||||
id=id,
|
||||
name=gui.str(name, "settings"),
|
||||
value=core.get_setting(id),
|
||||
min=info.min,
|
||||
max=info.max,
|
||||
step=step,
|
||||
postfix=postfix
|
||||
}))
|
||||
update_setting(core.get_setting(id), id, name, postfix)
|
||||
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='%s' step='0.01' "..
|
||||
" consumer='function(x) on_volume_change(%q, %q, %q, x) end'/>"
|
||||
, id, core.get_setting(setting), 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)
|
||||
function update_setting(x, id, name, postfix)
|
||||
core.set_setting(id, x)
|
||||
-- updating label
|
||||
document[id..".L"].text = string.format(
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
core.str_setting(id),
|
||||
postfix
|
||||
)
|
||||
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)
|
||||
function on_open()
|
||||
create_setting("audio.volume-master", "Master Volume", 0.01)
|
||||
create_setting("audio.volume-regular", "Regular Sounds", 0.01)
|
||||
create_setting("audio.volume-ui", "UI Sounds", 0.01)
|
||||
create_setting("audio.volume-ambient", "Ambient", 0.01)
|
||||
create_setting("audio.volume-music", "Music", 0.01)
|
||||
end
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<panel size='400' color='0' padding='8'>
|
||||
<panel size='400' color='0'>
|
||||
<label id='sensitivity_label'>-</label>
|
||||
<trackbar id='sensitivity_track'
|
||||
min='0.1' max='10' value='2' step='0.1'
|
||||
consumer='change_sensitivity'>
|
||||
</trackbar>
|
||||
<panel id='bindings_panel' size='380,200' padding='2' interval='1' max-length='400' color='#0000004C'>
|
||||
<panel id='bindings_panel' size='380,200' padding='2' interval='1' max-length='350' color='#0000004C'>
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
<button onclick='menu:back()'>@Back</button>
|
||||
</panel>
|
||||
@@ -0,0 +1,2 @@
|
||||
<panel size='400' color='0' interval='1' context='menu'>
|
||||
</panel>
|
||||
@@ -0,0 +1,44 @@
|
||||
function create_setting(id, name, step, postfix)
|
||||
local info = core.get_setting_info(id)
|
||||
postfix = postfix or ""
|
||||
document.root:add(gui.template("track_setting", {
|
||||
id=id,
|
||||
name=gui.str(name, "settings"),
|
||||
value=core.get_setting(id),
|
||||
min=info.min,
|
||||
max=info.max,
|
||||
step=step,
|
||||
postfix=postfix
|
||||
}))
|
||||
update_setting(core.get_setting(id), id, name, postfix)
|
||||
end
|
||||
|
||||
function update_setting(x, id, name, postfix)
|
||||
core.set_setting(id, x)
|
||||
-- updating label
|
||||
document[id..".L"].text = string.format(
|
||||
"%s: %s%s",
|
||||
gui.str(name, "settings"),
|
||||
core.str_setting(id),
|
||||
postfix
|
||||
)
|
||||
end
|
||||
|
||||
function create_checkbox(id, name)
|
||||
document.root:add(string.format(
|
||||
"<checkbox consumer='function(x) core.set_setting(\"%s\", x) end' checked='%s'>%s</checkbox>",
|
||||
id, core.str_setting(id), gui.str(name, "settings")
|
||||
))
|
||||
end
|
||||
|
||||
function on_open()
|
||||
create_setting("chunks.load-distance", "Load Distance", 1)
|
||||
create_setting("chunks.load-speed", "Load Speed", 1)
|
||||
create_setting("graphics.fog-curve", "Fog Curve", 0.1)
|
||||
create_setting("graphics.gamma", "Gamma", 0.05)
|
||||
create_setting("camera.fov", "FOV", 1, "°")
|
||||
create_checkbox("display.fullscreen", "Fullscreen")
|
||||
create_checkbox("display.vsync", "V-Sync")
|
||||
create_checkbox("graphics.backlight", "Backlight")
|
||||
create_checkbox("camera.shaking", "Camera Shaking")
|
||||
end
|
||||
@@ -21,6 +21,7 @@ menu.missing-content=Отсутствует Контент!
|
||||
menu.Page does not exists=Страница не существует
|
||||
menu.Content Error=Ошибка Контента
|
||||
menu.Controls=Управление
|
||||
menu.Graphics=Графика
|
||||
menu.Back to Main Menu=Вернуться в Меню
|
||||
menu.Settings=Настройки
|
||||
menu.Content=Контент
|
||||
|
||||
Reference in New Issue
Block a user