mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
languages menu moved to xml + minor refactor
This commit is contained in:
parent
f525d82ca8
commit
657b09da9e
12 changed files with 71 additions and 48 deletions
3
res/layouts/pages/languages.xml
Normal file
3
res/layouts/pages/languages.xml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<panel size='400' color='#00000080' padding='8'>
|
||||
<!-- content is generated in script -->
|
||||
</panel>
|
||||
19
res/layouts/pages/languages.xml.lua
Normal file
19
res/layouts/pages/languages.xml.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
function on_open()
|
||||
local locales = gui.get_locales_info()
|
||||
local invlocales = {}
|
||||
local names = {}
|
||||
for k, v in pairs(locales) do
|
||||
table.insert(names, v.name)
|
||||
invlocales[v.name] = k
|
||||
end
|
||||
table.sort(names)
|
||||
|
||||
local panel = document.root
|
||||
for _,k in ipairs(names) do
|
||||
panel:add(string.format(
|
||||
"<button onclick=%q padding='10'>%s</button>",
|
||||
string.format("gui.set_locale(%q) menu:back()", invlocales[k]), k
|
||||
))
|
||||
end
|
||||
panel:add("<button padding='10' onclick='menu:back()'>@Back</button>")
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue