diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-10-09 20:55:24 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-10-09 20:55:24 -0700 |
commit | b84cbf6d21fccdad85cb7963dd4689a8b497e729 (patch) | |
tree | f1d940f9cde81e58abbcb6420743e993db9b3874 /main.lua | |
parent | 3aec915559514e8294f80447fcac9c4b34df9dc4 (diff) | |
parent | 69d86cae5ba5672e7020243d0f78f0ea6355fd8f (diff) | |
download | view.love-b84cbf6d21fccdad85cb7963dd4689a8b497e729.tar.gz |
Merge lines.love
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/main.lua b/main.lua index 6ff69d6..b515b8e 100644 --- a/main.lua +++ b/main.lua @@ -69,6 +69,23 @@ function App.load() end end +function App.version_check() + -- available modes: run, error + Error_message = nil + Error_count = 0 + -- we'll reuse error mode on load for an initial version check + local supported_versions = {'11.4', '12.0'} -- put the recommended version first + local minor_version + Major_version, minor_version = love.getVersion() + Version = Major_version..'.'..minor_version + if array.find(supported_versions, Version) == nil then + Current_app = 'error' + Error_message = ("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]) + print(Error_message) + -- continue initializing everything; hopefully we won't have errors during initialization + end +end + function App.initialize_globals() if Current_app == 'run' then run.initialize_globals() @@ -134,7 +151,12 @@ function App.focus(in_focus) end function App.draw() - if Current_app == 'run' then + if Current_app == 'error' then + love.graphics.setColor(0,0,1) + love.graphics.rectangle('fill', 0,0, App.screen.width, App.screen.height) + love.graphics.setColor(1,1,1) + love.graphics.printf(Error_message, 40,40, 600) + elseif Current_app == 'run' then run.draw() elseif Current_app == 'source' then source.draw() @@ -165,6 +187,12 @@ function App.keychord_press(chord, key) return end -- + if Current_app == 'error' then + if chord == 'C-c' then + love.system.setClipboardText(Error_message) + end + return + end if chord == 'C-e' then -- carefully save settings if Current_app == 'run' then @@ -200,6 +228,7 @@ function App.keychord_press(chord, key) end function App.textinput(t) + if Current_app == 'error' 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 +244,7 @@ function App.textinput(t) end function App.keyreleased(key, scancode) + if Current_app == 'error' 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 @@ -230,6 +260,7 @@ function App.keyreleased(key, scancode) end function App.mousepressed(x,y, mouse_button) + if Current_app == 'error' then return end --? print('mouse press', x,y) if Current_app == 'run' then if run.mouse_press then run.mouse_press(x,y, mouse_button) end @@ -241,6 +272,7 @@ function App.mousepressed(x,y, mouse_button) end function App.mousereleased(x,y, mouse_button) + if Current_app == 'error' then return end if Current_app == 'run' then if run.mouse_release then run.mouse_release(x,y, mouse_button) end elseif Current_app == 'source' then @@ -251,6 +283,7 @@ function App.mousereleased(x,y, mouse_button) end function App.wheelmoved(dx,dy) + if Current_app == 'error' then return end if Current_app == 'run' then if run.mouse_wheel_move then run.mouse_wheel_move(dx,dy) end elseif Current_app == 'source' then @@ -261,6 +294,7 @@ function App.wheelmoved(dx,dy) end function love.quit() + if Current_app == 'error' then return end if Current_app == 'run' then local source_settings = Settings.source Settings = run.settings() |