Merge text0

This commit is contained in:
Kartik K. Agaram 2023-04-19 19:47:42 -07:00
commit 5561486cb6
3 changed files with 29 additions and 3 deletions

View File

@ -11,6 +11,7 @@
-- --
-- Scroll below this function for more details. -- Scroll below this function for more details.
function love.run() function love.run()
App.version_check()
App.snapshot_love() App.snapshot_love()
-- have LÖVE delegate all handlers to App if they exist -- have LÖVE delegate all handlers to App if they exist
for name in pairs(love.handlers) do for name in pairs(love.handlers) do

View File

@ -1,3 +0,0 @@
function love.conf(t)
t.version = '11.4'
end

View File

@ -12,6 +12,16 @@ require 'button'
require 'edit' require 'edit'
Editor_state = {} 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 -- called both in tests and real run
function App.initialize_globals() function App.initialize_globals()
-- tests currently mostly clear their own state -- tests currently mostly clear their own state
@ -128,10 +138,18 @@ function App.filedropped(file)
end end
function App.draw() 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 if on.draw then on.draw() end
end end
function App.update(dt) function App.update(dt)
if Mode == 'version_check' then return end
Current_time = Current_time + dt Current_time = Current_time + dt
-- some hysteresis while resizing -- some hysteresis while resizing
if Current_time < Last_resize_time + 0.1 then if Current_time < Last_resize_time + 0.1 then
@ -143,21 +161,25 @@ function App.update(dt)
end end
function App.mousepressed(x,y, mouse_button) 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 Cursor_time = 0 -- ensure cursor is visible immediately after it moves
if on.mouse_press then on.mouse_press(x,y, mouse_button) end if on.mouse_press then on.mouse_press(x,y, mouse_button) end
end end
function App.mousereleased(x,y, mouse_button) 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 Cursor_time = 0 -- ensure cursor is visible immediately after it moves
if on.mouse_release then on.mouse_release(x,y, mouse_button) end if on.mouse_release then on.mouse_release(x,y, mouse_button) end
end end
function App.wheelmoved(dx,dy) function App.wheelmoved(dx,dy)
if Mode == 'version_check' then return end
Cursor_time = 0 -- ensure cursor is visible immediately after it moves Cursor_time = 0 -- ensure cursor is visible immediately after it moves
if on.mouse_wheel_move then on.mouse_wheel_move(dx,dy) end if on.mouse_wheel_move then on.mouse_wheel_move(dx,dy) end
end end
function App.focus(in_focus) function App.focus(in_focus)
if Mode == 'version_check' then return end
if in_focus then if in_focus then
Last_focus_time = Current_time Last_focus_time = Current_time
end end
@ -172,6 +194,7 @@ end
-- App.keypressed is defined in keychord.lua -- App.keypressed is defined in keychord.lua
function App.keychord_press(chord, key) 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) -- ignore events for some time after window in focus (mostly alt-tab)
if Current_time < Last_focus_time + 0.01 then if Current_time < Last_focus_time + 0.01 then
return return
@ -181,6 +204,7 @@ function App.keychord_press(chord, key)
end end
function App.textinput(t) function App.textinput(t)
if Mode == 'version_check' then return end
-- ignore events for some time after window in focus (mostly alt-tab) -- ignore events for some time after window in focus (mostly alt-tab)
if Current_time < Last_focus_time + 0.01 then if Current_time < Last_focus_time + 0.01 then
return return
@ -190,6 +214,10 @@ function App.textinput(t)
end end
function App.keyreleased(key, scancode) 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) -- ignore events for some time after window in focus (mostly alt-tab)
if Current_time < Last_focus_time + 0.01 then if Current_time < Last_focus_time + 0.01 then
return return