Сохранение опциональных модов

This commit is contained in:
Gravit 2018-11-12 22:27:44 +07:00
parent 4300aafc38
commit aa91d12d27
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
3 changed files with 43 additions and 2 deletions

View file

@ -198,6 +198,7 @@ function verifyLauncher(e) {
} }
overlay.swap(0, processing.overlay, function(event) makeProfilesRequest(function(result) { overlay.swap(0, processing.overlay, function(event) makeProfilesRequest(function(result) {
settings.lastProfiles = result.profiles; settings.lastProfiles = result.profiles;
options.load();
// Update profiles list and hide overlay // Update profiles list and hide overlay
updateProfilesList(result.profiles); updateProfilesList(result.profiles);
overlay.hide(0, function() { overlay.hide(0, function() {

View file

@ -2,7 +2,7 @@ var options = {
file: DirBridge.dir.resolve("options.bin"), // options file file: DirBridge.dir.resolve("options.bin"), // options file
/* options and overlay functions */ /* options and overlay functions */
load: function() { load: function(profiles) {
LogHelper.debug("Loading options file"); LogHelper.debug("Loading options file");
try { try {
tryWithResources(new HInput(IOHelper.newInput(options.file)), options.read); tryWithResources(new HInput(IOHelper.newInput(options.file)), options.read);
@ -27,10 +27,51 @@ var options = {
if (magic != config.settingsMagic) { if (magic != config.settingsMagic) {
throw new java.io.IOException("options magic mismatch: " + java.lang.Integer.toString(magic, 16)); throw new java.io.IOException("options magic mismatch: " + java.lang.Integer.toString(magic, 16));
} }
var profilesCount = input.readInt();
LogHelper.debug("Load options. ProfilesCount %d",profilesCount);
for(var i = 0;i<profilesCount;i++)
{
var listSize = input.readInt();
var sortIndex = input.readInt();
var profile = null;
settings.lastProfiles.forEach(function(hprofile,i,arr) {
if(hprofile.object.getSortIndex() == sortIndex)
{
profile = hprofile.object;
}
});
for(var j = 0; j < listSize; j++)
{
var mark = input.readBoolean();
var modfile = input.readString(0);
if(mark)
{
profile.markOptional(modfile);
LogHelper.debug("Load options %s marked",modfile);
}
else
{
profile.unmarkOptional(modfile);
LogHelper.debug("Load options %s unmarked",modfile);
}
}
}
}, },
write: function(output) { write: function(output) {
output.writeInt(config.settingsMagic); output.writeInt(config.settingsMagic);
output.writeInt(settings.lastProfiles.length);
settings.lastProfiles.forEach(function(hprofile,i,arr) {
var profile = hprofile.object;
LogHelper.debug("Save options %s",profile.getTitle());
var list = profile.getOptional();
output.writeInt(list.size());
output.writeInt(profile.getSortIndex());
list.forEach(function(modfile,j,arr2) {
output.writeBoolean(modfile.mark);
output.writeString(modfile.string, 0);
});
});
}, },
/* ===================== OVERLAY ===================== */ /* ===================== OVERLAY ===================== */

View file

@ -7,7 +7,6 @@ var LauncherApp = Java.extend(JSApplication, {
app = JSApplication.getInstance(); app = JSApplication.getInstance();
cliParams.init(app.getParameters()); cliParams.init(app.getParameters());
settings.load(); settings.load();
options.load();
cliParams.applySettings(); cliParams.applySettings();
}, start: function(primaryStage) { }, start: function(primaryStage) {
stage = primaryStage; stage = primaryStage;