Merge template-live-editor-mobile

Lua Carousel now tested to load/save screens from/to save dir.
This commit is contained in:
Kartik K. Agaram 2023-12-18 07:39:37 -08:00
commit f9c2d7883f
4 changed files with 13 additions and 12 deletions

View File

@ -1,5 +1,5 @@
on.initialize = function()
App.mkdir(Directory)
love.filesystem.createDirectory(Directory)
populate_missing_handlers()
Font = love.graphics.newFont(Font_height)
love.graphics.setFont(Font)
@ -15,4 +15,4 @@ on.initialize = function()
end
Current_pane_index = 1
Current_pane = Panes[Current_pane_index]
end
end

View File

@ -1 +1 @@
Directory = love.filesystem.getSourceBaseDirectory()..'/carousel_data/'
Directory = 'screens/'

View File

@ -1,10 +1,11 @@
refresh_directory_contents = function()
Directory_contents = {}
local files_info = nativefs.getDirectoryItemsInfo(Directory)
for _,file_info in ipairs(files_info) do
local filenames = love.filesystem.getDirectoryItems(Directory)
for _,filename in ipairs(filenames) do
local file_info = love.filesystem.getInfo(Directory..filename)
if file_info.type == 'file' then
table.insert(Directory_contents, file_info.name)
table.insert(Directory_contents, filename)
end
end
table.sort(Directory_contents)
end
end

10
app.lua
View File

@ -84,7 +84,7 @@ function love.run()
App.screen.print = love.graphics.print
App.open_for_reading =
function(filename)
local result = nativefs.newFile(filename)
local result = love.filesystem.newFile(filename)
local ok, err = result:open('r')
if ok then
return result
@ -107,7 +107,7 @@ function love.run()
end
App.open_for_writing =
function(filename)
local result = nativefs.newFile(filename)
local result = love.filesystem.newFile(filename)
local ok, err = result:open('w')
if ok then
return result
@ -128,9 +128,9 @@ function love.run()
f:close()
return --[[status]] true
end
App.files = nativefs.getDirectoryItems
App.mkdir = nativefs.createDirectory
App.remove = nativefs.remove
App.files = love.filesystem.getDirectoryItems
App.mkdir = love.filesystem.createDirectory
App.remove = love.filesystem.remove
App.source_dir = love.filesystem.getSource()..'/' -- '/' should work even on Windows
App.current_dir = nativefs.getWorkingDirectory()..'/'
App.save_dir = love.filesystem.getSaveDirectory()..'/'