diff --git a/app.lua b/app.lua index 9552aef..6ed77f0 100644 --- a/app.lua +++ b/app.lua @@ -11,6 +11,7 @@ -- -- Scroll below this function for more details. function love.run() + App.version_check() App.snapshot_love() -- Tests always run at the start. Test_errors = {} diff --git a/conf.lua b/conf.lua deleted file mode 100644 index de8758a..0000000 --- a/conf.lua +++ /dev/null @@ -1,3 +0,0 @@ -function love.conf(t) - t.version = '11.4' -end diff --git a/main.lua b/main.lua index b6d1bce..1e19a6c 100644 --- a/main.lua +++ b/main.lua @@ -13,6 +13,16 @@ require 'main_tests' 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 @@ -154,10 +164,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 edit.draw(Editor_state) 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 @@ -168,6 +186,7 @@ function App.update(dt) end function love.quit() + if Mode == 'version_check' then return end edit.quit(Editor_state) -- save some important settings local x,y,displayindex = App.screen.position() @@ -185,27 +204,32 @@ function love.quit() 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 return edit.mouse_press(Editor_state, x,y, mouse_button) 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 return edit.mouse_release(Editor_state, x,y, mouse_button) end function App.wheelmoved(dx,dy) + if Mode == 'version_check' then return end Cursor_time = 0 -- ensure cursor is visible immediately after it moves return edit.mouse_wheel_move(Editor_state, dx,dy) end function App.focus(in_focus) + if Mode == 'version_check' then return end if in_focus then Last_focus_time = Current_time end end 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 @@ -215,6 +239,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 @@ -224,6 +249,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