Merge text0
This commit is contained in:
commit
5561486cb6
1
app.lua
1
app.lua
|
@ -11,6 +11,7 @@
|
|||
--
|
||||
-- Scroll below this function for more details.
|
||||
function love.run()
|
||||
App.version_check()
|
||||
App.snapshot_love()
|
||||
-- have LÖVE delegate all handlers to App if they exist
|
||||
for name in pairs(love.handlers) do
|
||||
|
|
28
main.lua
28
main.lua
|
@ -12,6 +12,16 @@ require 'button'
|
|||
require 'edit'
|
||||
Editor_state = {}
|
||||
|
||||
function App.version_check()
|
||||
Mode = 'version_check'
|
||||
Supported_versions = {'11.4', '11.3', '11.2', '11.1', '11.0'} -- keep these sorted in descending order
|
||||
local major, minor = love.getVersion()
|
||||
Version = major..'.'..minor
|
||||
if array.find(Supported_versions, Version) then
|
||||
Mode = 'run'
|
||||
end
|
||||
end
|
||||
|
||||
-- called both in tests and real run
|
||||
function App.initialize_globals()
|
||||
-- tests currently mostly clear their own state
|
||||
|
@ -128,10 +138,18 @@ function App.filedropped(file)
|
|||
end
|
||||
|
||||
function App.draw()
|
||||
if Mode == 'version_check' then
|
||||
love.graphics.setColor(1,1,0)
|
||||
love.graphics.rectangle('fill', 30,30, 400,400)
|
||||
love.graphics.setColor(0,0,0)
|
||||
love.graphics.printf(("This app doesn't support version %s; please use version %s. Press any key to try it with this version anyway."):format(Version, Supported_versions[1]), 40,40, 400)
|
||||
return
|
||||
end
|
||||
if on.draw then on.draw() end
|
||||
end
|
||||
|
||||
function App.update(dt)
|
||||
if Mode == 'version_check' then return end
|
||||
Current_time = Current_time + dt
|
||||
-- some hysteresis while resizing
|
||||
if Current_time < Last_resize_time + 0.1 then
|
||||
|
@ -143,21 +161,25 @@ function App.update(dt)
|
|||
end
|
||||
|
||||
function App.mousepressed(x,y, mouse_button)
|
||||
if Mode == 'version_check' then return end
|
||||
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
||||
if on.mouse_press then on.mouse_press(x,y, mouse_button) end
|
||||
end
|
||||
|
||||
function App.mousereleased(x,y, mouse_button)
|
||||
if Mode == 'version_check' then return end
|
||||
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
||||
if on.mouse_release then on.mouse_release(x,y, mouse_button) end
|
||||
end
|
||||
|
||||
function App.wheelmoved(dx,dy)
|
||||
if Mode == 'version_check' then return end
|
||||
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
|
||||
if on.mouse_wheel_move then on.mouse_wheel_move(dx,dy) end
|
||||
end
|
||||
|
||||
function App.focus(in_focus)
|
||||
if Mode == 'version_check' then return end
|
||||
if in_focus then
|
||||
Last_focus_time = Current_time
|
||||
end
|
||||
|
@ -172,6 +194,7 @@ end
|
|||
-- App.keypressed is defined in keychord.lua
|
||||
|
||||
function App.keychord_press(chord, key)
|
||||
if Mode == 'version_check' then return end
|
||||
-- ignore events for some time after window in focus (mostly alt-tab)
|
||||
if Current_time < Last_focus_time + 0.01 then
|
||||
return
|
||||
|
@ -181,6 +204,7 @@ function App.keychord_press(chord, key)
|
|||
end
|
||||
|
||||
function App.textinput(t)
|
||||
if Mode == 'version_check' then return end
|
||||
-- ignore events for some time after window in focus (mostly alt-tab)
|
||||
if Current_time < Last_focus_time + 0.01 then
|
||||
return
|
||||
|
@ -190,6 +214,10 @@ function App.textinput(t)
|
|||
end
|
||||
|
||||
function App.keyreleased(key, scancode)
|
||||
if Mode == 'version_check' then
|
||||
Mode = 'run'
|
||||
return
|
||||
end
|
||||
-- ignore events for some time after window in focus (mostly alt-tab)
|
||||
if Current_time < Last_focus_time + 0.01 then
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue