support loading from .zip/.love file
This commit is contained in:
parent
d88cb808ff
commit
fa3ca59059
11
conf.lua
11
conf.lua
@ -1,7 +1,8 @@
|
|||||||
function love.conf(t)
|
function love.conf(t)
|
||||||
t.window.width = 1024
|
t.identity = "love-demo2"
|
||||||
t.window.height = 1024
|
t.window.width = 1024
|
||||||
t.window.depth = true
|
t.window.height = 1024
|
||||||
t.window.resizable = true
|
t.window.depth = true
|
||||||
t.graphics.excluderenderers = {"vulkan", "metal"}
|
t.window.resizable = true
|
||||||
|
t.graphics.excluderenderers = {"vulkan", "metal"}
|
||||||
end
|
end
|
||||||
|
|||||||
20
main.lua
20
main.lua
@ -34,7 +34,25 @@ void update(float time);
|
|||||||
int x3, int y3, int x4, int y4);
|
int x3, int y3, int x4, int y4);
|
||||||
]]
|
]]
|
||||||
local source_path = love.filesystem.getSource()
|
local source_path = love.filesystem.getSource()
|
||||||
test = ffi.load(source_path .. "/test.so")
|
local is_zip = source_path:sub(-#".zip") == ".zip"
|
||||||
|
local is_love = source_path:sub(-#".love") == ".love"
|
||||||
|
|
||||||
|
if is_zip or is_love then
|
||||||
|
if love.filesystem.isFused() then
|
||||||
|
local archive = love.filesystem.getSourceBaseDirectory()
|
||||||
|
end
|
||||||
|
|
||||||
|
local contents, size = love.filesystem.read("data", "test.so")
|
||||||
|
assert(contents ~= nil, size)
|
||||||
|
local write_success, message = love.filesystem.write("test.so", contents, size)
|
||||||
|
local app_data = love.filesystem.getAppdataDirectory()
|
||||||
|
|
||||||
|
-- the love2d "filesystem" API is the worst possible design in the
|
||||||
|
-- entire history of computing
|
||||||
|
test = ffi.load(app_data .. "/love/love-demo2/test.so")
|
||||||
|
else
|
||||||
|
test = ffi.load("./test.so")
|
||||||
|
end
|
||||||
test.load(source_path)
|
test.load(source_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user