Save and open worlds in Local Storage #2
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Save worlds into Local Storage as
.resonitepackagefiles and open them again. Only needs to work with the mod installed: vanilla's package importer refuses non-object packages.Design
RecordType = "world"with name, description, tags and the world thumbnail embedded; main asset is the world graph fromWorld.SaveWorld(), assets collected into the package the same way as items.InventoryBrowser.AddItem(Slot, bool, RecordDirectory)for local directories whose item is aWorldOrbSaver. Vanilla would callUserspace.SaveWorld, which throws on theL-owner id.CorrespondingRecordwhoseAssetURIis its package, so "Save" rewrites that package. Hooks:Userspace.CanSave(also gives the host the Owner role) andUserspace.SaveWorldTaskIntern.world_orb+world_url:<package uri>, so the inventory shows "Open World"; spawning it creates a world orb pointing at the package.Userspace.LoadWorldrecognisesresolocalstorage:///URIs, imports the package assets into the local DB (asPackageImporterdoes) and starts a session from the graph.Userspace.OpenWorldgets a no-opInitWorldfor these URIs to pass its URL-scheme guard.resrec:///L-…: a world orb with a record URL fetches it from the cloud on touch and destroys itself on 404.Plan
PackageImporter's remap loop)LoadWorldItemPackageLimits
Implemented in
dc78250and hot-loaded into the running game (Resonite 2026.9.18.82). v1 unloaded cleanly (Harmony UnpatchAll) and the new build loaded with no errors. 27 unit tests pass. The in-game check (save a world, open it, edit, Save, reopen) is still open. Side note from the logs: Resdb Tools throws 'Invalid owner type: L-ResoLocalStorage' when it tries to fetch a selected local item from the cloud. That is harmless and comes from that mod.In-game testing found two issues, both fixed in
4992a44(v0.2.1):Uri.ToString(), which unescapes, and vanilla drops links that failUri.IsWellFormedUriString. Non-ASCII paths never pass that check, soInventoryBrowser.OnOpenWorldis now patched for local links. Spawning and clicking the orb already worked.ItemHelper.SaveItem, stored as an extraR-Inventoryrecord.Also: all skip-the-original prefixes now respect
__runOriginal(Restrainite's world-switch block was bypassed), and local orbs no longer ask the cloud about their link. Worlds saved with 0.2.0 still show the flat thumbnail until saved again.Bug from testing, fixed in
e911172(v0.2.2): while a big world saved, the desktop cursor stayed unlocked. 0.2.1 deactivated the saver's slot while its context menu was still closing.ContextMenuonly releases its cursor-unlock registration inOnChangesonce it's fully closed, so the frozen menu kept the cursor free until the saver was destroyed. The saver now stays active, and the orb render happens at the end of the package write.Testing a 1.2 GB world (Compact Cloud Home) showed the saver orb staying in the user's face for the whole two-minute write. Since
e9c4f02, saving follows vanilla again: the saver shows "Saving..." only during the capture, turns into the orb, is rendered and animates away, and the package is written in the background with progress in the dash (#3). Destroying the saver also removes its context menu, so the cursor is released.