mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
Сохранение опциональных модов
This commit is contained in:
parent
4300aafc38
commit
aa91d12d27
3 changed files with 43 additions and 2 deletions
|
@ -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() {
|
||||
|
|
|
@ -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 ===================== */
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue