diff --git a/Launcher/runtime/dialog/overlay/options/options.js b/Launcher/runtime/dialog/overlay/options/options.js index 282a63fa..6c443423 100644 --- a/Launcher/runtime/dialog/overlay/options/options.js +++ b/Launcher/runtime/dialog/overlay/options/options.js @@ -43,15 +43,16 @@ var options = { for(var j = 0; j < listSize; j++) { var mark = input.readBoolean(); + var modType = OptionalFile.readType(input); var modFile = input.readString(0); if(mark) { - profile.markOptional(modFile); + profile.markOptional(modFile,modType); LogHelper.debug("Load options %s marked",modFile); } else { - profile.unmarkOptional(modFile); + profile.unmarkOptional(modFile,modType); LogHelper.debug("Load options %s unmarked",modFile); } } @@ -69,7 +70,8 @@ var options = { output.writeInt(profile.getSortIndex()); list.forEach(function(modFile,j,arr2) { output.writeBoolean(modFile.mark); - output.writeString(modFile.file, 0); + modFile.writeType(output); + output.writeString(modFile.name, 0); }); }); }, @@ -101,11 +103,9 @@ var options = { list.forEach(function(modFile) { dModsIds.push(modFile.string); - var modName = modFile.file, modDescription = "", subLevel = 1; - if(modFile.isAdminOnly && !loginData.permissions.canAdmin) + var modName = modFile.name, modDescription = "", subLevel = 1; + if(!modFile.isVisible || !((loginData.permissions & modFile.permissions) != 0)) return; - if(modFile.name != null)//Есть ли у модификации имя? - modName = modFile.name; if(modFile.info != null) //Есть ли описание? modDescription = modFile.info; if(modFile.subTreeLevel != null && modFile.subTreeLevel > 1)//Это суб-модификация? @@ -121,18 +121,17 @@ var options = { var isSelected = event.getSource().isSelected(); if(isSelected) { - profile.markOptional(modFile.file); - LogHelper.debug("Selected mod %s", modFile.file); + profile.markOptional(modFile); + LogHelper.debug("Selected mod %s", modFile.name); } else { - profile.unmarkOptional(modFile.file); - LogHelper.debug("Unselected mod %s", modFile.file); + profile.unmarkOptional(modFile); + LogHelper.debug("Unselected mod %s", modFile.name); } options.update(); }); checkBoxList.add(testMod); - if(modDescription != "") { //Добавляем описание? textDescr = new javafx.scene.text.Text(modDescription); if(subLevel > 1) { diff --git a/Launcher/runtime/engine/api.js b/Launcher/runtime/engine/api.js index f423687d..d7cbcae5 100644 --- a/Launcher/runtime/engine/api.js +++ b/Launcher/runtime/engine/api.js @@ -44,6 +44,7 @@ var StreamObjectAdapter = StreamObjectAdapterClass.static; var SignedBytesHolder = SignedBytesHolderClass.static; var SignedObjectHolder = SignedObjectHolderClass.static; var EnumSerializer = EnumSerializerClass.static; +var OptionalFile = OptionalFileClass.static; // Helper class API imports var CommonHelper = CommonHelperClass.static; diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java b/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java index bf8ec25f..fc99a3c0 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java +++ b/Launcher/src/main/java/ru/gravit/launcher/gui/JSRuntimeProvider.java @@ -18,6 +18,7 @@ import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.profiles.Texture; +import ru.gravit.launcher.profiles.optional.OptionalFile; import ru.gravit.launcher.request.*; import ru.gravit.launcher.request.auth.AuthRequest; import ru.gravit.launcher.request.auth.CheckServerRequest; @@ -95,6 +96,7 @@ public static void addLauncherClassBindings(Map bindings) { bindings.put("SignedBytesHolderClass", SignedBytesHolder.class); bindings.put("SignedObjectHolderClass", SignedObjectHolder.class); bindings.put("EnumSerializerClass", EnumSerializer.class); + bindings.put("OptionalFileClass", OptionalFile.class); // Set helper class bindings bindings.put("CommonHelperClass", CommonHelper.class); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/profiles/optional/OptionalFile.java b/libLauncher/src/main/java/ru/gravit/launcher/profiles/optional/OptionalFile.java index ee041d08..35e8a9f7 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/profiles/optional/OptionalFile.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/profiles/optional/OptionalFile.java @@ -92,9 +92,10 @@ public void writeType(HOutput output) throws IOException } } @LauncherAPI - public void readType(HInput input) throws IOException + public static OptionalType readType(HInput input) throws IOException { int t = input.readInt(); + OptionalType type; switch(t) { case 1: @@ -111,7 +112,9 @@ public void readType(HInput input) throws IOException break; default: LogHelper.error("readType failed. Read int %d",t); + type = OptionalType.FILE; break; } + return type; } }