lua: gui library (WIP)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user