-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.lua
73 lines (60 loc) · 1.71 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
-- Test bed Lovr app
local letters = require('letters')
-- state
local font = lovr.graphics.newFont(24)
local app = {}
-- global
function lovr.load()
letters.load()
lovr.graphics.setBackgroundColor(0.95, 0.98, 0.98)
local x = -0.3
for name, keeb in pairs(letters.Keyboards) do
keeb.button = letters.root:addChild(letters.Button:new{
transform = lovr.math.newMat4():translate(x, 2.0, -2),
onPressed = function()
letters.defaultKeyboard = keeb
if letters.currentKeyboard ~= nil then
letters.hideKeyboard()
letters.displayKeyboard()
end
for _, keeb2 in pairs(letters.Keyboards) do
if keeb2 ~= keeb then
keeb2.button:setSelected(false)
end
end
end,
label = name,
size = lovr.math.newVec3(0.4, 0.2, 0.1),
isToggle = true
})
x = x + 0.6
end
-- Sample UI to test keyboards
local foodField = letters.root:addChild(letters.TextField:new{
transform = lovr.math.newMat4():translate(-3, 4.3, -7),
font = font,
placeholder = "Favorite food"
})
local nameField = letters.root:addChild(letters.TextField:new{
transform = lovr.math.newMat4():translate(-3, 5, -7),
font = font,
onReturn = function() foodField:makeKey(); return false; end,
placeholder = "Name"
})
letters.Keyboards.Tap.button:deselect()
nameField:makeKey()
for i, hand in ipairs(letters.hands) do
letters.root:addChild(hand)
end
end
function lovr.update()
letters.update()
end
function lovr.draw()
lovr.graphics.setCullingEnabled(true)
lovr.graphics.setDepthTest('lequal', true)
lovr.graphics.clear()
lovr.graphics.setShader()
lovr.graphics.setFont(font)
letters.draw()
end