Which works when the dlc is actually present. However, if the dlc is missing I get the exception
com.jme3.asset.AssetLoadException: Failed to open zip file: dlc/dlc.zip
so I think that before registering the location I should verify that the dlc is actually present. How should I do this test? The assetManager does not have a suitable API for that… and direct File access is not reccommended.
Since my name was invoked… if you already know your content will be a file on the disk then it’s ok to use java.io.File to see if it’s there.
The general issue is when people think that their assets will be files on the disk and try to access them directly. Then they are disappointed when their load fails when the assets are not files on the disk.
Indeed. When I ‘liked’ your answer from 4 days ago I also implied that I was going to follow this route. The try/catch (plus loading) is slightly more verbose and convoluted, but that’s a matter of personal taste.
The try/catch is much worse because the error has already happened by the time it’s detected. If it happened when you registered the locator then that would be one thing… but if it waits until you load some asset then it’s too far removed.
Personal taste is preferring to query state rather than force an exception (expected exceptions are not exceptional to me)… and so I’d strongly agree there. But this particular case goes beyond that into creating fragile and confusing code.
Maybe let them download a setup that extracts the files in user.dir/assets or so? Or you might choose a game specific folder such as Documents/My Games under windows (I don’t know about Mac OS and linux though).
Or you could even have a DLC browser inside your game and when they download / buy one, the game downloads it and puts it automatically inside the correct folder.
To the dev team: if I were to add an optional “Add DLC…” button wizard in the splash screen, and make a PR would you consider adding it to the master?
It would work like this: the AppSettings would contain another property (browse_dlc_enable with default false) that when enabled shows the “Add DLC…” button. When pressed, you see a file browser where you select your downloaded DLC which then gets moved in the right place.
No, I don’t think so because any solution you could provide would be extremely specific to your particular use-case. It wouldn’t work for Mythruna. It wouldn’t work for any game using normal DLC updates as part of their regular patch updates (for example getdown based projects and the like). Those are just off the top of my head.
It only handles the one tiny use case of “I’m going to make my users do this manually”… which I hope is the smallest percent of the cases, personally.
Besides, you’ve just implied that they don’t know how to use a file browser and then you want them to use a file browser and somehow find where they stored the DLC? I’m not sure that makes sense but maybe I’ve missed something.