fixes for löve 11.0 (#60)

Changed all color values to be in the range 0-1, rather than 0-255
This commit is contained in:
Bernhard Liebl
2018-04-17 21:22:16 +02:00
committed by airstruck
parent 3aa71d750b
commit 03ad922a65
2 changed files with 16 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
local ROOT = (...):gsub('[^.]*$', '')
local Backend
if _G.love and _G.love._version_minor > 8 then
if _G.love and (_G.love._version_major or _G.love._version_minor) then
Backend = require(ROOT .. 'backend.love')
else
Backend = require(ROOT .. 'backend.ffisdl')

18
luigi/backend/love.lua Normal file → Executable file
View File

@@ -67,7 +67,19 @@ Backend.quit = function ()
love.event.quit()
end
Backend.setColor = love.graphics.setColor
if _G.love._version_major >= 11 then
Backend.setColor = function(r, g, b, a)
if type(r) == "table" then
r, g, b, a = unpack(r)
end
if a == nil then
a = 255
end
love.graphics.setColor(r / 255, g / 255, b / 255, a / 255)
end
else
Backend.setColor = love.graphics.setColor
end
Backend.setCursor = love.mouse.setCursor
@@ -94,7 +106,7 @@ end
local getMouseButtonId, isMouseDown
if love._version_minor < 10 then
if love._version_major == 0 and love._version_minor < 10 then
getMouseButtonId = function (value)
return value == 'l' and 'left'
or value == 'r' and 'right'
@@ -155,7 +167,7 @@ function Backend.show (layout)
hook(layout, 'textinput', function (text)
return input:handleTextInput(layout, text, Backend.getMousePosition())
end)
if love._version_minor > 9 then
if (love._version_major == 0 and love._version_minor > 9) or love._version_major >= 11 then
hook(layout, 'wheelmoved', function (x, y)
return input:handleWheelMove(layout, x, y)
end)