mirror of
https://github.com/airstruck/luigi.git
synced 2026-01-10 16:28:23 +00:00
love 0.9.2 support
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
love.filesystem.setSymlinksEnabled(true) -- for older love versions
|
||||||
|
|
||||||
local Layout = require 'luigi.layout'
|
local Layout = require 'luigi.layout'
|
||||||
|
|
||||||
local style = {
|
local style = {
|
||||||
|
|||||||
@@ -52,9 +52,18 @@ function Font:getAdvance (text)
|
|||||||
return (self.font:getWidth(text))
|
return (self.font:getWidth(text))
|
||||||
end
|
end
|
||||||
|
|
||||||
function Font:getWrappedHeight (text)
|
local major, minor, revision, codename = love.getVersion()
|
||||||
local _, lines = self.font:getWrap(text, self.layout.width)
|
|
||||||
return #lines * self.font:getHeight()
|
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
|
end
|
||||||
|
|
||||||
return Font
|
return Font
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ function Input:handlePressStart (button, x, y)
|
|||||||
self.passedWidgets[button] = widget
|
self.passedWidgets[button] = widget
|
||||||
self:bubbleEvent('PressStart', widget, {
|
self:bubbleEvent('PressStart', widget, {
|
||||||
target = widget,
|
target = widget,
|
||||||
button = button, x = x, y = y
|
button = button,
|
||||||
|
x = x, y = y
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,22 @@ function Layout:unhook ()
|
|||||||
self.hooks = {}
|
self.hooks = {}
|
||||||
end
|
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)
|
function Layout:manageInput (input)
|
||||||
if self.isManagingInput then
|
if self.isManagingInput then
|
||||||
return
|
return
|
||||||
@@ -115,11 +131,11 @@ function Layout:manageInput (input)
|
|||||||
end)
|
end)
|
||||||
self:hook('mousepressed', function (x, y, button)
|
self:hook('mousepressed', function (x, y, button)
|
||||||
self.isMousePressed = true
|
self.isMousePressed = true
|
||||||
return input:handlePressStart(button, x, y)
|
return input:handlePressStart(getMouseButtonId(button), x, y)
|
||||||
end)
|
end)
|
||||||
self:hook('mousereleased', function (x, y, button)
|
self:hook('mousereleased', function (x, y, button)
|
||||||
self.isMousePressed = false
|
self.isMousePressed = false
|
||||||
return input:handlePressEnd(button, x, y)
|
return input:handlePressEnd(getMouseButtonId(button), x, y)
|
||||||
end)
|
end)
|
||||||
self:hook('mousemoved', function (x, y, dx, dy)
|
self:hook('mousemoved', function (x, y, dx, dy)
|
||||||
if self.isMousePressed then
|
if self.isMousePressed then
|
||||||
|
|||||||
Reference in New Issue
Block a user