if my app is launched without options, the generic settings screen is shown before starting (as in a default SimpleApplication)
if my app is launched with some options (–nosettings), is it started directly, with the last used/saved settings
I know settings chosen on the settings screen are saved somewhere, because options are remembered between runs, but I could not retrieve them, or have the settings screen interact with my own instance of AppSettings.
a) if (args.contains("--nosettings") setShowSettings(false);
b) On my Devices the Settings aren’t saved automatically, but:
You can use appSettings.save() and appSettings.load() to load them from a file, the Engine will then auto-care about serialization
(Though I would prefer a manual-xml-file, because then the Users can change the resolution in the config aswell)
Sorry maybe I should have given more details:
setShowSetting(false) seems to use some “default” settings freshly created, but definitely not the ones chosen the last time the settings screen was used.
So this doesn’t work:
if (args.contain("--nosettings") {
app.setShowSettings(false)
}
app.start()
I would need something like:
if (args.contain("--nosettings") {
AppSettings s = retrieveThemSomehow()
app.setSettings(s)
app.setShowSettings(false)
}
app.start()
// possibly save settings here, but there's no getSettings() to access what settings were created
So I would need either getSettings() or retrieveThemSomehow(). I noticed that in ~/.java/.userPrefs I have a very strange folder (named literally: _!'o!^@“v!'4!aw"l!(k!)!”&!'4!~w"p!'4!~@!g!$:!.g!w) that contains the saved preferences, but I’d rather not hardcode the loading of something named so.
This will create/use some default settings. I don’t want 2 completely independent operation modes, I want interaction between them: the settings a user chooses when the setting dialog pops are the ones that have to be used later, when launching with --nosettings.
Ok, so… AppSettings is a pretty ridiculous class and counterintuitive in like 50 different ways.
If you create a new AppSettings(false) then it will automatically load your last values… but it leaves a bunch of things unset. If you try to run your app this way without showing the settings dialog then it will be missing a bunch of stuff and probably crash.
However, if you create a new AppSettings(true) then it will load defaults for everything but otherwise ignore any settings that you had saved before.
So, the trick is some counterintuitive funky combination of loading defaults as well as loading the settings.
First, this presumes that you’ve given yourself an app title because I think that’s what’s used for saving the settings.
AppSettings settings = new AppSettings(true); // ← so things will get set and the app won’t crash
settings.load(titleOfYourApp);
settings.setTitle(titleOfYourApp);
app.setSettings(settings);
…then setShowSettings() as you wish. If the user selected settings previously they will be loaded with the load(titleOfYourApp) above.
Ok I tested your “funky combination” and it works as I want, thanks !
The secret (for me) link was the title used as save name (and funky default title !).
For what it’s worth, and if you can change things easily, I would have found handy to have a method to create settings via a dialog, but outside of an app run. For example in AppSettings: