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

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) {
settings.lastProfiles = result.profiles;
options.load();
// Update profiles list and hide overlay
updateProfilesList(result.profiles);
overlay.hide(0, function() {

View file

@ -2,7 +2,7 @@ var options = {
file: DirBridge.dir.resolve("options.bin"), // options file
/* options and overlay functions */
load: function() {
load: function(profiles) {
LogHelper.debug("Loading options file");
try {
tryWithResources(new HInput(IOHelper.newInput(options.file)), options.read);
@ -27,10 +27,51 @@ var options = {
if (magic != config.settingsMagic) {
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) {
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 ===================== */

View file

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