
It's totally functional but a little bare-bones.

Code: Select all
myform =
{
fadein = 0.1, fadeout = 0.1, -- (to understand if feasible modulating pen alpha)
{ type = "image", x = 10, y = 20, image = "..." },
{ type = "label", id = "xxx", x = 50, y = 50 },
{ type = "button", id = "yyy", x = 10, y = 10, w = 20, h = 10 },
{ type = "portrait" ... },
}
function yyy_click()
... auto called do something
end
gui.showDialog(myform, self)
-- or
gui.addWidget(myform, self)
They are coming (about the same time) when the OS/X version will be released.is there an update to Grimrock coming soon that will have the GUI stuff?
Code: Select all
cloneObject{
name='party'
...
onDrawGui = function(g)
gui.draw(g)
end
}
Code: Select all
elements = {}
addElement(element)
elements[element.id] = element
end
removeElement(id)
element[id] = nil
end
draw(g)
for i=1,#elements do
elements[i]:draw(g)
end
end
Code: Select all
createDialog(id,text)
local e = {}
e.id = id
e.draw = function(self,g)
g.color(30,30,30,150)
g.drawRect(30, 50, 345, 300
g.drawText(text, 200, 80)
-- draw button with text
g.color(128, 128, 128)
g.drawRect(200, 120, 115, 20)
g.color(255, 255, 255)
g.drawText("Ok", 210, 135)
-- close dialog when the button is pressed
if g.button("button1", 200, 120, 115, 20) then
gui.removeElement(self.id)
end
end
return e
end
local dialog = createDialog('hello_dialog_1','Hello grimrockers!')
gui.addElement(dialog)
Code: Select all
function shopMenu()
local x = 100
local y = 100
-- draws a dialog frame
gui.dialog(x, y, 150, 50)
x = x + 10
y = y + 10
-- draws a button and returns true if the button was pressed
if gui.button("shop_buy", "Buy", x, y, 100, 20) then
-- TODO: enter buy dialog
end
y = y + 25
if gui.button("shop_sell", "Sell", x, y, 100, 20) then
-- TODO: enter sell dialog
end
y = y + 25
if gui.button("shop_exit", "Bye!", x, y, 100, 20) then
-- TODO: exit shop
end
y = y + 25
end