mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +00:00
lua: gui library (WIP)
This commit is contained in:
parent
302b649634
commit
05589b721e
14 changed files with 262 additions and 25 deletions
|
|
@ -1,3 +1,10 @@
|
|||
<inventory color="#1F1F1FE0" size="400,0">
|
||||
<inventory color="#1F1F1FE0" size="0,400">
|
||||
<slots-grid rows="4" count="40" sharefunc="inventory_share_func"/>
|
||||
<button id="btn"
|
||||
coord="8,300"
|
||||
size="140,30"
|
||||
z-index="1"
|
||||
onclick="document.btn.text = tostring(time.uptime())">
|
||||
-----
|
||||
</button>
|
||||
</inventory>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
function on_open(inv)
|
||||
print("OPEN", inv)
|
||||
local Document = require("core:document")
|
||||
document = Document.new(DOC_NAME)
|
||||
|
||||
function on_open(invid)
|
||||
print("OPEN", invid)
|
||||
end
|
||||
|
||||
function on_close(inv)
|
||||
print("CLOSE", inv)
|
||||
function on_close(invid)
|
||||
print("CLOSE", invid)
|
||||
end
|
||||
|
||||
function inventory_share_func(invid, slotid)
|
||||
|
|
|
|||
22
res/modules/document.lua
Normal file
22
res/modules/document.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
local Element = {}
|
||||
function Element.new(docname, name)
|
||||
return setmetatable({docname=docname, name=name}, {
|
||||
__index=function(self, k)
|
||||
return gui.getattr(self.docname, self.name, k)
|
||||
end,
|
||||
__newindex=function(self, k, v)
|
||||
gui.setattr(self.docname, self.name, k, v)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
local Document = {}
|
||||
function Document.new(docname)
|
||||
return setmetatable({name=docname}, {
|
||||
__index=function(self, k)
|
||||
return Element.new(self.name, k)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
return Document
|
||||
|
|
@ -91,3 +91,23 @@ end
|
|||
function pack.is_installed(packid)
|
||||
return file.isfile(packid..":package.json")
|
||||
end
|
||||
|
||||
vec2_mt = {}
|
||||
function vec2_mt.__tostring(self)
|
||||
return "vec2("..self[1]..", "..self[2]..")"
|
||||
end
|
||||
|
||||
vec3_mt = {}
|
||||
function vec3_mt.__tostring(self)
|
||||
return "vec3("..self[1]..", "..self[2]..", "..self[3]..")"
|
||||
end
|
||||
|
||||
vec4_mt = {}
|
||||
function vec4_mt.__tostring(self)
|
||||
return "vec4("..self[1]..", "..self[2]..", "..self[3]..", "..self[4]..")"
|
||||
end
|
||||
|
||||
color_mt = {}
|
||||
function color_mt.__tostring(self)
|
||||
return "rgba("..self[1]..", "..self[2]..", "..self[3]..", "..self[4]..")"
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue