Merge text.love
This commit is contained in:
commit
23eb55f634
|
@ -12,7 +12,8 @@ Initializing settings:
|
||||||
- run with a filename on commandline, scroll around, quit; restart with new filename; window opens new filename with cursor up top
|
- run with a filename on commandline, scroll around, quit; restart with new filename; window opens new filename with cursor up top
|
||||||
- run editor, scroll around, move cursor to end of some line, quit; restart with new filename; window opens in same position+dimensions
|
- run editor, scroll around, move cursor to end of some line, quit; restart with new filename; window opens in same position+dimensions
|
||||||
|
|
||||||
- run with an unsupported version. Error message pops up and waits for a key. The app attempts to continue, and doesn't receive the key.
|
- run with an untested version. Error message pops up and waits for a key. The app attempts to continue, and doesn't receive the key.
|
||||||
|
- run with a LÖVE v12 release candidate. No errors; it is a supported version. All tests pass.
|
||||||
|
|
||||||
Code loading:
|
Code loading:
|
||||||
* run love with directory; text editor runs
|
* run love with directory; text editor runs
|
||||||
|
|
15
app.lua
15
app.lua
|
@ -7,16 +7,21 @@
|
||||||
-- and a source editor, while giving each the illusion of complete
|
-- and a source editor, while giving each the illusion of complete
|
||||||
-- control.
|
-- control.
|
||||||
function love.run()
|
function love.run()
|
||||||
|
Version, Major_version = App.love_version()
|
||||||
App.snapshot_love()
|
App.snapshot_love()
|
||||||
-- Tests always run at the start.
|
-- Tests always run at the start.
|
||||||
Test_errors = {}
|
Test_errors = {}
|
||||||
App.run_tests()
|
App.run_tests()
|
||||||
if #Test_errors > 0 then
|
if #Test_errors > 0 then
|
||||||
error('There were test failures:\n\n'..table.concat(Test_errors))
|
local error_message = ''
|
||||||
|
if Warning_before_tests then
|
||||||
|
error_message = Warning_before_tests..'\n\n'
|
||||||
|
end
|
||||||
|
error_message = error_message .. ('There were %d test failures:\n%s'):format(#Test_errors, table.concat(Test_errors))
|
||||||
|
error(error_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
--? print('==')
|
--? print('==')
|
||||||
App.version_check()
|
|
||||||
App.disable_tests()
|
App.disable_tests()
|
||||||
App.initialize_globals()
|
App.initialize_globals()
|
||||||
App.initialize(love.arg.parseGameArguments(arg), arg)
|
App.initialize(love.arg.parseGameArguments(arg), arg)
|
||||||
|
@ -58,6 +63,12 @@ end
|
||||||
|
|
||||||
App = {}
|
App = {}
|
||||||
|
|
||||||
|
function App.love_version()
|
||||||
|
local major_version, minor_version = love.getVersion()
|
||||||
|
local version = major_version..'.'..minor_version
|
||||||
|
return version, major_version
|
||||||
|
end
|
||||||
|
|
||||||
-- save/restore various framework globals we care about -- only on very first load
|
-- save/restore various framework globals we care about -- only on very first load
|
||||||
function App.snapshot_love()
|
function App.snapshot_love()
|
||||||
if Love_snapshot then return end
|
if Love_snapshot then return end
|
||||||
|
|
32
main.lua
32
main.lua
|
@ -13,19 +13,11 @@ require 'main_tests'
|
||||||
require 'edit'
|
require 'edit'
|
||||||
Editor_state = {}
|
Editor_state = {}
|
||||||
|
|
||||||
function App.version_check()
|
|
||||||
Mode = 'version_check'
|
|
||||||
Supported_versions = {'11.5', '11.4', '11.3', '11.2', '11.1', '11.0', '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) 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()
|
||||||
|
Supported_versions = {'11.5', '11.4', '12.0'} -- put the recommended version first
|
||||||
|
check_love_version_for_tests()
|
||||||
|
|
||||||
-- tests currently mostly clear their own state
|
-- tests currently mostly clear their own state
|
||||||
|
|
||||||
-- blinking cursor
|
-- blinking cursor
|
||||||
|
@ -37,6 +29,13 @@ function App.initialize_globals()
|
||||||
Last_resize_time = 0
|
Last_resize_time = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function check_love_version_for_tests()
|
||||||
|
if array.find(Supported_versions, Version) == nil then
|
||||||
|
-- warning to include in an error message if any tests failed
|
||||||
|
Warning_before_tests = ("This app hasn't been tested with LÖVE version %s."):format(Version)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- called only for real run
|
-- called only for real run
|
||||||
function App.initialize(arg)
|
function App.initialize(arg)
|
||||||
love.keyboard.setTextInput(true) -- bring up keyboard on touch screen
|
love.keyboard.setTextInput(true) -- bring up keyboard on touch screen
|
||||||
|
@ -77,6 +76,15 @@ function App.initialize(arg)
|
||||||
jit.off()
|
jit.off()
|
||||||
jit.flush()
|
jit.flush()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
check_love_version()
|
||||||
|
end
|
||||||
|
|
||||||
|
function check_love_version()
|
||||||
|
if array.find(Supported_versions, Version) == nil then
|
||||||
|
Mode = 'version_check'
|
||||||
|
-- continue initializing everything; hopefully we won't have errors during initialization
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function print_and_log(s)
|
function print_and_log(s)
|
||||||
|
@ -173,7 +181,7 @@ function App.draw()
|
||||||
love.graphics.setColor(1,1,0)
|
love.graphics.setColor(1,1,0)
|
||||||
love.graphics.rectangle('fill', 30,30, 400,400)
|
love.graphics.rectangle('fill', 30,30, 400,400)
|
||||||
love.graphics.setColor(0,0,0)
|
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)
|
love.graphics.printf(("This app hasn't been tested with LÖVE version %s; please switch to version %s if you run into issues. Press any key to continue."):format(Version, Supported_versions[1]), 40,40, 400)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
edit.draw(Editor_state)
|
edit.draw(Editor_state)
|
||||||
|
|
|
@ -11,6 +11,9 @@ automatically called for you as appropriate.
|
||||||
* `flags` -- some properties of the app window. See [`flags` in `love.graphics.getMode`](https://love2d.org/wiki/love.window.getMode)
|
* `flags` -- some properties of the app window. See [`flags` in `love.graphics.getMode`](https://love2d.org/wiki/love.window.getMode)
|
||||||
for details.
|
for details.
|
||||||
|
|
||||||
|
* `Version` -- the running version of LÖVE as a string, e.g. '11.4'.
|
||||||
|
* `Major_version` -- just the part before the period as an int, e.g. 11.
|
||||||
|
|
||||||
## Functions that get automatically called
|
## Functions that get automatically called
|
||||||
|
|
||||||
* `App.initialize_globals()` -- called before running each test and also
|
* `App.initialize_globals()` -- called before running each test and also
|
||||||
|
|
Loading…
Reference in New Issue