[FEATURE] Поддержка дизайном новых опц модов

This commit is contained in:
Gravit 2019-01-22 12:02:58 +07:00
parent 4d7fca7b2a
commit 8e2e9d4aee
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
4 changed files with 18 additions and 13 deletions

View file

@ -43,15 +43,16 @@ var options = {
for(var j = 0; j < listSize; j++) for(var j = 0; j < listSize; j++)
{ {
var mark = input.readBoolean(); var mark = input.readBoolean();
var modType = OptionalFile.readType(input);
var modFile = input.readString(0); var modFile = input.readString(0);
if(mark) if(mark)
{ {
profile.markOptional(modFile); profile.markOptional(modFile,modType);
LogHelper.debug("Load options %s marked",modFile); LogHelper.debug("Load options %s marked",modFile);
} }
else else
{ {
profile.unmarkOptional(modFile); profile.unmarkOptional(modFile,modType);
LogHelper.debug("Load options %s unmarked",modFile); LogHelper.debug("Load options %s unmarked",modFile);
} }
} }
@ -69,7 +70,8 @@ var options = {
output.writeInt(profile.getSortIndex()); output.writeInt(profile.getSortIndex());
list.forEach(function(modFile,j,arr2) { list.forEach(function(modFile,j,arr2) {
output.writeBoolean(modFile.mark); 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) { list.forEach(function(modFile) {
dModsIds.push(modFile.string); dModsIds.push(modFile.string);
var modName = modFile.file, modDescription = "", subLevel = 1; var modName = modFile.name, modDescription = "", subLevel = 1;
if(modFile.isAdminOnly && !loginData.permissions.canAdmin) if(!modFile.isVisible || !((loginData.permissions & modFile.permissions) != 0))
return; return;
if(modFile.name != null)//Есть ли у модификации имя?
modName = modFile.name;
if(modFile.info != null) //Есть ли описание? if(modFile.info != null) //Есть ли описание?
modDescription = modFile.info; modDescription = modFile.info;
if(modFile.subTreeLevel != null && modFile.subTreeLevel > 1)//Это суб-модификация? if(modFile.subTreeLevel != null && modFile.subTreeLevel > 1)//Это суб-модификация?
@ -121,18 +121,17 @@ var options = {
var isSelected = event.getSource().isSelected(); var isSelected = event.getSource().isSelected();
if(isSelected) if(isSelected)
{ {
profile.markOptional(modFile.file); profile.markOptional(modFile);
LogHelper.debug("Selected mod %s", modFile.file); LogHelper.debug("Selected mod %s", modFile.name);
} }
else else
{ {
profile.unmarkOptional(modFile.file); profile.unmarkOptional(modFile);
LogHelper.debug("Unselected mod %s", modFile.file); LogHelper.debug("Unselected mod %s", modFile.name);
} }
options.update(); options.update();
}); });
checkBoxList.add(testMod); checkBoxList.add(testMod);
if(modDescription != "") { //Добавляем описание? if(modDescription != "") { //Добавляем описание?
textDescr = new javafx.scene.text.Text(modDescription); textDescr = new javafx.scene.text.Text(modDescription);
if(subLevel > 1) { if(subLevel > 1) {

View file

@ -44,6 +44,7 @@ var StreamObjectAdapter = StreamObjectAdapterClass.static;
var SignedBytesHolder = SignedBytesHolderClass.static; var SignedBytesHolder = SignedBytesHolderClass.static;
var SignedObjectHolder = SignedObjectHolderClass.static; var SignedObjectHolder = SignedObjectHolderClass.static;
var EnumSerializer = EnumSerializerClass.static; var EnumSerializer = EnumSerializerClass.static;
var OptionalFile = OptionalFileClass.static;
// Helper class API imports // Helper class API imports
var CommonHelper = CommonHelperClass.static; var CommonHelper = CommonHelperClass.static;

View file

@ -18,6 +18,7 @@
import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.ClientProfile;
import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.profiles.PlayerProfile;
import ru.gravit.launcher.profiles.Texture; import ru.gravit.launcher.profiles.Texture;
import ru.gravit.launcher.profiles.optional.OptionalFile;
import ru.gravit.launcher.request.*; import ru.gravit.launcher.request.*;
import ru.gravit.launcher.request.auth.AuthRequest; import ru.gravit.launcher.request.auth.AuthRequest;
import ru.gravit.launcher.request.auth.CheckServerRequest; import ru.gravit.launcher.request.auth.CheckServerRequest;
@ -95,6 +96,7 @@ public static void addLauncherClassBindings(Map<String, Object> bindings) {
bindings.put("SignedBytesHolderClass", SignedBytesHolder.class); bindings.put("SignedBytesHolderClass", SignedBytesHolder.class);
bindings.put("SignedObjectHolderClass", SignedObjectHolder.class); bindings.put("SignedObjectHolderClass", SignedObjectHolder.class);
bindings.put("EnumSerializerClass", EnumSerializer.class); bindings.put("EnumSerializerClass", EnumSerializer.class);
bindings.put("OptionalFileClass", OptionalFile.class);
// Set helper class bindings // Set helper class bindings
bindings.put("CommonHelperClass", CommonHelper.class); bindings.put("CommonHelperClass", CommonHelper.class);

View file

@ -92,9 +92,10 @@ public void writeType(HOutput output) throws IOException
} }
} }
@LauncherAPI @LauncherAPI
public void readType(HInput input) throws IOException public static OptionalType readType(HInput input) throws IOException
{ {
int t = input.readInt(); int t = input.readInt();
OptionalType type;
switch(t) switch(t)
{ {
case 1: case 1:
@ -111,7 +112,9 @@ public void readType(HInput input) throws IOException
break; break;
default: default:
LogHelper.error("readType failed. Read int %d",t); LogHelper.error("readType failed. Read int %d",t);
type = OptionalType.FILE;
break; break;
} }
return type;
} }
} }