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

New mod type: asset pack (.assetpack) #3129

Merged
merged 2 commits into from Feb 21, 2024

Conversation

ohlidalp
Copy link
Member

@ohlidalp ohlidalp commented Feb 19, 2024

Quick 2hr draft - BUILDS, NOT TESTED. Tested, added example mods.

A new file type "*.assetpack" was added to modcache with all the usual treatment:

  • the file is recorded to the cache file (/cache/cache.json),
  • it's searchable and selectable via UI (LT_AssetPack)
  • can have a thumbnail (filename format '{}-mini.*'' where {} is the assetpack file name without extension)
  • The file itself can be empty, recognized entries are assetpack_name (display name), assetpack_description (for display in selector UI) and assetpack_author (same syntax as in .truck file).
  • When requested, the game loads the entire containing ZIP/directory (called 'bundle' by jargon).

Assetpacks are referenced by the file name (standard approach) and can be used for both terrains and actors:

  • Terrains: in .terrn2 file, add section [AssetPacks] followed by list of filenames (with extension, each on separate line) ending with = token, same as in [Objects/Scripts] sections - this is a quirk of the game.
  • Actors: in the .truck file, use section assetpacks followed by list of filenames (with extension, each on separate line)

Note that, unlike any other mod, assetpacks aren't loaded to their own resource group but rather to the resoruce group of the mod which requested them. Therefore try to name all resources in an unique way to avoid clashes.

Test mods - a wacky mini terrain I created for future tests, and one mesh (with multiple .ODEFs) I extracted from it:

@cryham
Copy link
Contributor

cryham commented Feb 19, 2024

Great.

Note that, unlike any other mod, assetpacks aren't loaded to their own resource group but rather to the resoruce group of the mod which requested them. Therefore try to name all resources in an unique way to avoid clashes.

One thing I have in mind is version. What if I someday decide to make a newer version of e.g. SR_Terrain asset pack? E.g. fixing some texures or adding some more.
IMO version should also be a part of a pack identifier. But with logic that would let us replace older version of same asset pack.
Do you agree or do you have a different approach to such case?

Also I understand that this other resource group is just name, but game will look into it just like for other resources, right? So terrain etc will search it too in case some assets are for it?

BTW. we need to name resources inside also uniquely right? E.g. grass2.png, palm.png etc are already in paged.zip, so for SR assets I need to rename such cases to something not present in RoR already.

@ohlidalp
Copy link
Member Author

Assetpacks are referenced exclusively by filename of the .assetpack, same as all other mods in the game. For a different version or any customized edition, just use new filename. Anything more would be excess complexity.

My goal is to use explicit RGs everywhere but former OGRE versions defaulted to searching everything and former RoR Devs didn't care. IIRC paged is hardcoded to use the default RG.

Yes, resources must be named to avoid clashes with any prepacked media.

@cryham
Copy link
Contributor

cryham commented Feb 19, 2024

Allright. So e.g. I'll have a SR_objects_v1 pack and in future will do a SR_objects_v2 and users will just get that instead and disable the v1. Sounds fair.

A new file type "*.assetpack" was added to modcache with all the usual treatment:
- the file is recorded to the cache file (/cache/cache.json),
- it's searchable and selectable via UI (`LT_AssetPack`)
- can have a thumbnail (filename format '{}-mini.*'' where {} is the assetpack file name without extension)
- The file itself can be empty, recognized entries are `assetpack_name` (display name), `assetpack_description` (for display in selector UI) and `assetpack_author` (same syntax as in rig-def (aka .truck) file).

Assetpacks are referenced by the file name (standard approach) and can be used for both terrains and actors:
- Terrains: in .terrn2 file, add section `[AssetPacks]` followed by list of filenames (with extension, each on separate line) ending with `=` token, same as in `[Objects/Scripts]` sections - this is a quirk of the game.
- Actors: in the .truck file, use section `assetpacks` followed by list of filenames (with extension, each on separate line)

Note that, unlike any other mod, assetpacks aren't loaded to their own resource group but rather to the resoruce group of the mod which requested them. Therefore try to name all resources in an unique way to avoid clashes.
@ohlidalp ohlidalp marked this pull request as ready for review February 20, 2024 01:41
@ohlidalp
Copy link
Member Author

@cryham Have you tested it yet? You can download the github-actions devbuild below.

@cryham
Copy link
Contributor

cryham commented Feb 21, 2024

Not yet, I'll test later today.

@cryham
Copy link
Contributor

cryham commented Feb 21, 2024

Allright this works well.

@ohlidalp ohlidalp merged commit 7c1cffb into RigsOfRods:master Feb 21, 2024
2 checks passed
@ohlidalp ohlidalp deleted the CryHam_assetpack branch February 21, 2024 19:28
@cryham
Copy link
Contributor

cryham commented Feb 21, 2024

So how small should I make these? I think with smaller I'd have more work but maybe less download for users.
Is e.g. one sr-terrain-v1 with say 300 MB of png data okay? and other with 200 MB called sr-terrain-extra-v1? Or should I even make each scenery textures separate?
Other packs e.g.: sr-grasses, sr-trees, sr-trees_old, sr-trees_ch, sr-objects0ad, sr-objectsCity etc? I think this is good so right? This way less upload size for me and download (on changes) for users, but more maintenance to keep track of it all..
I think I'll put all materials and checkpoints into separate packs too, not sure yet.

BTW can I call all SR tracks with prefix: ^Grc2-Coast or +Grc2-Coast or so in RoR? It's easier since they're on top of list.
Or will there be a new group? Still would be mixed in list when all visible.

Also how will this work for users? E.g. someone gets from repo in game a track Grc2-Coast, then will RoR auto download all needed packs for it if not present?

@ohlidalp
Copy link
Member Author

That sounds perfectly fine. I don't know the assets so I'll leave it to you to partition them so that it makes sense - I skimmed through the online map viewer at stuntrally website and I see you've got maps categorized by theme with prefixes. We have nothing like that as every map was individual. But I like it, go ahead.

@CuriousMike56 Any opinions on this?

@CuriousMike56
Copy link
Collaborator

Tested demo files, works fine. No issues with the file format 👍

Also how will this work for users? E.g. someone gets from repo in game a track Grc2-Coast, then will RoR auto download all needed packs for it if not present?

Best solution IMO would be to add a "required files/dependencies" prompt when downloading from the in-game repo. Not sure how this would work on the website side.

@ohlidalp
Copy link
Member Author

ohlidalp commented Feb 22, 2024

As a matter of fact, the Tuning branch #3096 internally modified modcache and enabled background updates. It was needed to save tuneups which must be modcache entries and must be created during simulation. This means:

  • The repo UI can be used anytime, even during simulation
  • There's no reason to download with a modal dialog - we can introduce a background download indicator/menu like web browsers have.
  • Once the mod is installed, modcache knows the declared assetpacks, so as long as each assetpack has a repo page, we can just search and download like for any other mod. We can do it after prompting user or even automatically if allowed by config.

I just realized a similar mechanism would be useful to recommend downloading mods which are preloaded in terrain (for example locos and railcars in TrainValley). No special syntax is needed actually, modcache can pick it up directly from the .tobj files and just prompt and then search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants