Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally preload assets from sharedlibs #286

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sharedlibs/magical-glass-redux/lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"version": "v2.25.23",
"engineVer": "v0.10.0-dev",

// In DPR: Load assets once when the engine starts.
"preload_assets": true,

"config": {

///// Default Battle System
Expand Down
10 changes: 10 additions & 0 deletions src/engine/loadstate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ function Loading:beginLoad()
self.load_complete = false

Kristal.loadAssets("", "all", "")
local paths = {}
for _, name in ipairs(love.filesystem.getDirectoryItems("sharedlibs")) do
local lib_full_path = "sharedlibs/"..name
if love.filesystem.getInfo(lib_full_path .. "/lib.json") then
local data = JSON.decode(love.filesystem.read(lib_full_path.."/lib.json"))
if data.preload_assets then
Kristal.loadAssets(lib_full_path, "all", "")
end
end
end
Kristal.loadAssets("", "plugins", "")
Kristal.loadAssets("", "mods", "", function ()
self.loading = false
Expand Down
6 changes: 5 additions & 1 deletion src/kristal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,11 @@ function Kristal.loadModAssets(id, asset_type, asset_paths, after)

-- Finally load all assets (libraries first)
for _, lib_id in ipairs(mod.lib_order) do
Kristal.loadAssets(mod.libs[lib_id].path, asset_type or "all", asset_paths or "", finishLoadStep)
if not mod.libs[lib_id].preload_assets then
Kristal.loadAssets(mod.libs[lib_id].path, asset_type or "all", asset_paths or "", finishLoadStep)
else
finishLoadStep()
end
end
Kristal.loadAssets(mod.path, asset_type or "all", asset_paths or "", finishLoadStep)
for plugin in Kristal.PluginLoader.iterPlugins(true) do
Expand Down