Fixes UI runtime errors properly

This reverts commit 11287c053a.
This commit is contained in:
duncathan 2019-09-11 16:26:29 -06:00
parent 0b2e76305c
commit 32c080d84d
4 changed files with 35 additions and 37 deletions

View file

@ -21,9 +21,7 @@ function love.conf(t)
t.modules.joystick = false
t.modules.physics = false
t.modules.sound = false
t.modules.system = false
t.modules.thread = false
t.modules.timer = false
t.modules.touch = false
t.modules.video = false

View file

@ -5,9 +5,9 @@ local Hooker = require(ROOT .. 'hooker')
local Backend = {}
--Backend.isMac = function ()
-- return love.system.getOS() == 'OS X'
--end
Backend.isMac = function ()
return love.system.getOS() == 'OS X'
end
Backend.run = function () end
@ -35,9 +35,9 @@ Backend.drawRectangle = love.graphics.rectangle
Backend.print = love.graphics.print
--Backend.getClipboardText = love.system.getClipboardText
Backend.getClipboardText = love.system.getClipboardText
--Backend.setClipboardText = love.system.setClipboardText
Backend.setClipboardText = love.system.setClipboardText
Backend.getMousePosition = love.mouse.getPosition
@ -49,7 +49,7 @@ Backend.getWindowSize = function ()
return love.graphics.getWidth(), love.graphics.getHeight()
end
--Backend.getTime = love.timer.getTime
Backend.getTime = love.timer.getTime
Backend.isKeyDown = love.keyboard.isDown

View file

@ -8,7 +8,7 @@ local Backend = require(ROOT .. 'backend')
local Shortcut = {}
--local isMac = Backend.isMac()
local isMac = Backend.isMac()
local ALT = 1
local CTRL = 2
@ -16,10 +16,10 @@ local SHIFT = 4
local GUI = 8
function Shortcut.appliesToPlatform (value)
--if isMac and value:match '%f[%a]win%-'
--or not isMac and value:match '%f[%a]mac%-' then
-- return false
--end
if isMac and value:match '%f[%a]win%-'
or not isMac and value:match '%f[%a]mac%-' then
return false
end
return true
end

View file

@ -199,14 +199,14 @@ local function copyRangeToClipboard (self)
local text = self.value
local first, last = getRange(self)
if last >= first + 1 then
--Backend.setClipboardText(text:sub(first + 1, last))
Backend.setClipboardText(text:sub(first + 1, last))
end
end
local function pasteFromClipboard (self)
trimRange(self)
local text = self.value
local pasted = '' --or Backend.getClipboardText()
local pasted = Backend.getClipboardText() or ''
local first, last = getRange(self)
local left = text:sub(1, first) .. pasted
local index = #left
@ -230,39 +230,39 @@ end
-- check command (gui) key, only on Mac.
local isCommandPressed
--if Backend.isMac() then
-- isCommandPressed = function ()
-- return Backend.isKeyDown('lgui', 'rgui')
-- end
--else
if Backend.isMac() then
isCommandPressed = function ()
return Backend.isKeyDown('lgui', 'rgui')
end
else
isCommandPressed = function ()
return false
end
--end
end
-- check command (gui) key on Mac and ctrl key everywhere else.
local isCommandOrCtrlPressed
--if Backend.isMac() then
-- isCommandOrCtrlPressed = function ()
-- return Backend.isKeyDown('lgui', 'rgui')
-- end
--else
if Backend.isMac() then
isCommandOrCtrlPressed = function ()
return Backend.isKeyDown('lgui', 'rgui')
end
else
isCommandOrCtrlPressed = function ()
return Backend.isKeyDown('lctrl', 'rctrl')
end
--end
end
-- check option (alt) key on Mac and ctrl key everywhere else.
local isOptionOrCtrlPressed
--if Backend.isMac() then
-- isOptionOrCtrlPressed = function ()
-- return Backend.isKeyDown('lalt', 'ralt')
-- end
--else
if Backend.isMac() then
isOptionOrCtrlPressed = function ()
return Backend.isKeyDown('lalt', 'ralt')
end
else
isOptionOrCtrlPressed = function ()
return Backend.isKeyDown('lctrl', 'rctrl')
end
--end
end
-- Special keys.
local function createDefaultKeyActions (self)
@ -418,10 +418,10 @@ This color is used to indicate the selected range of text.
Backend.setColor(self.highlight or defaultHighlight)
Backend.drawRectangle('fill', startX, y, width, height)
-- draw cursor selection
--if Backend.getTime() % 2 < 1.75 then
-- Backend.setColor(color)
-- Backend.drawRectangle('fill', endX, y, 1, height)
--end
if Backend.getTime() % 2 < 1.75 then
Backend.setColor(color)
Backend.drawRectangle('fill', endX, y, 1, height)
end
else
Backend.setColor { color[1], color[2], color[3],
(color[4] or 256) / 8 }