Skip to content

Commit

Permalink
Merge pull request #286 from Hyperboid/dpr/preload-sharedlib-assets
Browse files Browse the repository at this point in the history
Optionally preload assets from sharedlibs
  • Loading branch information
BrendaK7200 authored Feb 6, 2025
2 parents b49cefe + ccfca2c commit 964f69c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
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

0 comments on commit 964f69c

Please sign in to comment.