love 0.9.2 support

This commit is contained in:
airstruck
2015-10-28 05:37:42 -04:00
parent 18f51c2ac3
commit 31b77234f5
4 changed files with 34 additions and 6 deletions

View File

@@ -1,3 +1,5 @@
love.filesystem.setSymlinksEnabled(true) -- for older love versions
local Layout = require 'luigi.layout'
local style = {

View File

@@ -52,9 +52,18 @@ function Font:getAdvance (text)
return (self.font:getWidth(text))
end
function Font:getWrappedHeight (text)
local _, lines = self.font:getWrap(text, self.layout.width)
return #lines * self.font:getHeight()
local major, minor, revision, codename = love.getVersion()
if minor < 10 then
function Font:getWrappedHeight (text)
local _, lines = self.font:getWrap(text, self.layout.width)
return lines * self.font:getHeight()
end
else
function Font:getWrappedHeight (text)
local _, lines = self.font:getWrap(text, self.layout.width)
return #lines * self.font:getHeight()
end
end
return Font

View File

@@ -126,7 +126,8 @@ function Input:handlePressStart (button, x, y)
self.passedWidgets[button] = widget
self:bubbleEvent('PressStart', widget, {
target = widget,
button = button, x = x, y = y
button = button,
x = x, y = y
})
end

View File

@@ -101,6 +101,22 @@ function Layout:unhook ()
self.hooks = {}
end
local getMouseButtonId
local major, minor, revision, codename = love.getVersion()
if minor < 10 then
getMouseButtonId = function (value)
return value == 'l' and 1
or value == 'r' and 2
or value == 'm' and 3
end
else
getMouseButtonId = function (value)
return value
end
end
function Layout:manageInput (input)
if self.isManagingInput then
return
@@ -115,11 +131,11 @@ function Layout:manageInput (input)
end)
self:hook('mousepressed', function (x, y, button)
self.isMousePressed = true
return input:handlePressStart(button, x, y)
return input:handlePressStart(getMouseButtonId(button), x, y)
end)
self:hook('mousereleased', function (x, y, button)
self.isMousePressed = false
return input:handlePressEnd(button, x, y)
return input:handlePressEnd(getMouseButtonId(button), x, y)
end)
self:hook('mousemoved', function (x, y, dx, dy)
if self.isMousePressed then