2016-02-23 06:10:13 +00:00
|
|
|
local lg = love.graphics
|
2016-04-04 19:47:02 +00:00
|
|
|
local pop, inspect
|
2016-02-23 06:10:13 +00:00
|
|
|
|
2016-03-30 21:38:46 +00:00
|
|
|
local debugDraw = false
|
2016-04-18 03:37:55 +00:00
|
|
|
local videoFile = lg.newVideo("test.ogv") -- so we can loop playback
|
2016-03-30 21:38:46 +00:00
|
|
|
|
2016-02-23 06:10:13 +00:00
|
|
|
function love.load()
|
2016-04-03 06:33:18 +00:00
|
|
|
print(love.getVersion())
|
|
|
|
|
2016-04-04 19:47:02 +00:00
|
|
|
inspect = require "debug-lib/inspect"
|
2016-03-29 00:59:12 +00:00
|
|
|
pop = require "pop"
|
2016-03-31 23:19:52 +00:00
|
|
|
---[[
|
2016-03-29 00:59:12 +00:00
|
|
|
local c = pop.box():align("center", "center"):setSize(300, 300)
|
|
|
|
pop.box(c, {255, 0, 0, 255}):setSize(100, 50)
|
|
|
|
pop.box(c, {0, 255, 0, 255}):align("center"):setSize(100, 100)
|
|
|
|
pop.box(c, {0, 0, 255, 255}):align("right"):setSize(50, 100)
|
|
|
|
pop.box(c, {100, 100, 100, 255}):align("center", "center"):setSize(500, 100)
|
|
|
|
pop.box(c):align("center"):setSize(50, 500):move(0, -100)
|
|
|
|
pop.box(c, {255, 255, 0, 255}):align(false, "bottom"):setSize(100, 100)
|
|
|
|
pop.box(c, {255, 150, 0, 255}):align("center", "bottom"):setSize(100, 50)
|
|
|
|
pop.box(c, {0, 255, 255}):align("right", "bottom"):setSize(50, 100):move(-50)
|
|
|
|
pop.text(nil, "Here's some test text\n(with newlines)\nin the top left corner!")
|
|
|
|
pop.text(nil, "Here's some test text in the bottom right corner!"):align("right", "bottom")
|
2016-04-03 07:22:49 +00:00
|
|
|
pop.skin(pop.text("Here's easier-to-code test text in the center!"):align("center", "center", true)) -- 'true' means align to pixel!
|
2016-03-29 00:59:12 +00:00
|
|
|
w = pop.box(nil, {255, 255, 255, 255}):align(false, "bottom"):setSize(150, 150)
|
|
|
|
b = pop.box(w, {0, 0, 0, 255}):setMargin(5):setSize(100, 100)
|
2016-03-31 23:19:52 +00:00
|
|
|
--]]
|
2016-03-30 21:01:15 +00:00
|
|
|
|
2016-03-30 21:38:46 +00:00
|
|
|
--c:move(100)
|
2016-04-02 03:45:43 +00:00
|
|
|
pop.box({255, 0, 0, 255}):position(50, 500) -- testing streamlined_get_set extension & optional parents
|
|
|
|
--b:margin(2) -- testing streamlined_get_set extension
|
|
|
|
b:fill() -- testing fill!
|
2016-03-30 21:01:15 +00:00
|
|
|
|
|
|
|
w2 = pop.window(nil, "Window")
|
|
|
|
w2:move(100, 100)
|
|
|
|
w2:setWidth(500)
|
|
|
|
w2:move(-50, 80)
|
|
|
|
w2:setHeight(500)
|
|
|
|
w2:move(0, -175)
|
2016-04-03 07:22:49 +00:00
|
|
|
w2.title:align("center")
|
2016-04-03 07:47:07 +00:00
|
|
|
w2:position(0, 0)
|
|
|
|
w2:size(200, 120):position(90, 70)
|
2016-04-18 03:37:55 +00:00
|
|
|
w2:setClose(false)
|
|
|
|
local t2 = pop.text("Click here to toggle close\nbutton on this window."):setMargin(10):setColor(0,0,0)
|
|
|
|
t2.clicked = function()
|
|
|
|
w2:setClose(not w2:hasClose())
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
w2:addChild(t2)
|
2016-03-30 21:38:46 +00:00
|
|
|
|
|
|
|
local test = lg.newImage("test.png")
|
|
|
|
G = pop.element():align("right"):move(-2, 2)
|
2016-03-31 23:19:52 +00:00
|
|
|
a = pop.box(G, test):align("right")
|
|
|
|
b = pop.box(G, test):align("right"):move(-25):setWidth(40)
|
|
|
|
c = pop.box(G, test):align("right"):move(0, 25):setHeight(40)
|
|
|
|
|
|
|
|
print(a.horizontal, a.vertical)
|
|
|
|
print(b.horizontal, b.vertical)
|
|
|
|
print(c.horizontal, c.vertical)
|
2016-03-30 21:01:15 +00:00
|
|
|
|
2016-04-18 03:37:55 +00:00
|
|
|
local window = pop.window():align("center", "center"):setTitle("Welcome! This title is far too big!")
|
2016-04-03 19:11:27 +00:00
|
|
|
--window:addChild(pop.text("Welcome to Pop.Box()!"))
|
|
|
|
|
2016-04-18 03:37:55 +00:00
|
|
|
pop.window():setClose(false):setClose(true)
|
|
|
|
|
|
|
|
local video = pop.box():align("right", "bottom"):setBackground(videoFile):setSize(320/2, 240/2):move(-20, -20)
|
|
|
|
videoFile:play()
|
|
|
|
|
2016-03-30 21:38:46 +00:00
|
|
|
--TODO make debugDraw better
|
2016-02-23 06:10:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.update(dt)
|
2016-02-25 01:02:56 +00:00
|
|
|
pop.update(dt)
|
2016-04-18 03:37:55 +00:00
|
|
|
|
|
|
|
if not videoFile:isPlaying() then
|
|
|
|
videoFile:rewind()
|
|
|
|
end
|
2016-02-23 06:10:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.draw()
|
2016-02-25 01:02:56 +00:00
|
|
|
pop.draw()
|
2016-03-30 21:38:46 +00:00
|
|
|
|
|
|
|
if debugDraw then
|
|
|
|
pop.debugDraw()
|
|
|
|
--w2:debugDraw()
|
|
|
|
end
|
2016-02-23 06:10:13 +00:00
|
|
|
end
|
|
|
|
|
2016-04-02 03:45:43 +00:00
|
|
|
function love.mousemoved(x, y, dx, dy)
|
|
|
|
pop.mousemoved(x, y, dx, dy)
|
|
|
|
end
|
|
|
|
|
2016-03-29 00:59:12 +00:00
|
|
|
function love.mousepressed(x, y, button)
|
|
|
|
pop.mousepressed(x, y, button)
|
2016-02-23 06:10:13 +00:00
|
|
|
end
|
|
|
|
|
2016-03-29 00:59:12 +00:00
|
|
|
function love.mousereleased(x, y, button)
|
|
|
|
pop.mousereleased(x, y, button)
|
2016-02-23 06:10:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.keypressed(key)
|
2016-03-29 00:59:12 +00:00
|
|
|
local handled = pop.keypressed(key)
|
2016-02-23 06:10:13 +00:00
|
|
|
|
2016-03-30 21:38:46 +00:00
|
|
|
if (key == "d") and (not handled) then
|
|
|
|
debugDraw = not debugDraw
|
|
|
|
end
|
|
|
|
|
2016-04-18 03:52:39 +00:00
|
|
|
if (key == "w") and (not handled) then
|
|
|
|
local w = pop.window()
|
|
|
|
w.title:align("center")
|
|
|
|
end
|
|
|
|
|
2016-03-29 00:59:12 +00:00
|
|
|
if (key == "escape") and (not handled) then
|
|
|
|
love.event.quit()
|
2016-02-23 06:10:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function love.keyreleased(key)
|
2016-02-25 01:02:56 +00:00
|
|
|
pop.keyreleased(key)
|
2016-02-23 06:10:13 +00:00
|
|
|
end
|
2016-03-29 00:59:12 +00:00
|
|
|
|
|
|
|
function love.textinput(text)
|
|
|
|
pop.textinput(text)
|
|
|
|
end
|