mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 21:41:50 +00:00
controls panel moved to xml
This commit is contained in:
parent
0e69db13be
commit
7cb5b2eb70
8 changed files with 62 additions and 48 deletions
11
res/layouts/pages/controls.xml
Normal file
11
res/layouts/pages/controls.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<panel size='400' color='0' padding='8'>
|
||||
<label id='sensitivity_label'>-</label>
|
||||
<trackbar id='sensitivity_track'
|
||||
min='0.1' max='10' value='2' step='0.1' track-width='4'
|
||||
consumer='change_sensitivity'>
|
||||
</trackbar>
|
||||
<panel id='bindings_panel' size='380,200' padding='2' interval='1' max-length='400' color='#0000004C'>
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
<button padding='10' onclick='menu:back()'>@Back</button>
|
||||
</panel>
|
||||
25
res/layouts/pages/controls.xml.lua
Normal file
25
res/layouts/pages/controls.xml.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
function refresh_sensitivity()
|
||||
document.sensitivity_label.text = string.format(
|
||||
"%s: %s",
|
||||
gui.str("Mouse Sensitivity", "settings"),
|
||||
core.str_setting("camera.sensitivity")
|
||||
)
|
||||
end
|
||||
|
||||
function change_sensitivity(val)
|
||||
core.set_setting("camera.sensitivity", val)
|
||||
refresh_sensitivity()
|
||||
end
|
||||
|
||||
function on_open()
|
||||
document.sensitivity_track.value = core.get_setting("camera.sensitivity")
|
||||
refresh_sensitivity()
|
||||
|
||||
local panel = document.bindings_panel
|
||||
local bindings = core.get_bindings()
|
||||
for i,name in ipairs(bindings) do
|
||||
panel:add(gui.template("binding", {
|
||||
id=name, name=gui.str(name)
|
||||
}))
|
||||
end
|
||||
end
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
<panel size='400' color='#00000080' padding='8'>
|
||||
<panel size='400' color='#00000080' padding='8' context='settings'>
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
|
|
|
|||
4
res/layouts/templates/binding.xml
Normal file
4
res/layouts/templates/binding.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<panel size='400,40' padding='4' color='0' orientation='horizontal'>
|
||||
<bindbox binding='%{id}'/>
|
||||
<label margin='6'>%{name}</label>
|
||||
</panel>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<container onclick='%{callback}' size='540,80' color='#0F1E2DB2'>
|
||||
<container onclick='%{callback}' size='540,80' color='#0F1E2DB2' hover-color='#0F1E2DF0'>
|
||||
<label color='#FFFFFF80' size='300,25' align='right' gravity='top-right'>
|
||||
[%{id}]
|
||||
</label>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
</label>
|
||||
<button if='%{remover}' onclick='%{remover}' color='0' hover-color='#FFFFFF2B'
|
||||
gravity='center-right' margin='10'>
|
||||
<image src='gui/cross' size='32,32'/>
|
||||
<image src='gui/cross' size='32,32' color='#FFFFFF80'/>
|
||||
</button>
|
||||
<image pos='8,8' src='%{icon}' size='64'></image>
|
||||
</container>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue