mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-30 22:49:06 +07:00
Attempts to improve the loading system
This commit is contained in:
@ -63,6 +63,9 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
|
||||
MethodSpec.Builder load = MethodSpec.methodBuilder("load").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
||||
MethodSpec.Builder dispose = MethodSpec.methodBuilder("dispose").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
||||
|
||||
MethodSpec.Builder loadBegin = MethodSpec.methodBuilder("loadBegin").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
||||
|
||||
|
||||
HashSet<String> names = new HashSet<>();
|
||||
Files.list(Paths.get(path)).forEach(p -> {
|
||||
String fname = p.getFileName().toString();
|
||||
@ -81,6 +84,13 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
|
||||
|
||||
load.addStatement(name + " = io.anuke.arc.Core.audio."+loadMethod+"(io.anuke.arc.Core.files.internal(io.anuke.arc.Core.app.getType() != io.anuke.arc.Application.ApplicationType.iOS ? $S : $S))",
|
||||
path.substring(path.lastIndexOf("/") + 1) + "/" + fname, (path.substring(path.lastIndexOf("/") + 1) + "/" + fname).replace(".ogg", ".mp3"));
|
||||
|
||||
|
||||
loadBegin.addStatement("io.anuke.arc.Core.assets.load(io.anuke.arc.Core.app.getType() != io.anuke.arc.Application.ApplicationType.iOS ? $S : $S, "+rtype+".class)",
|
||||
path.substring(path.lastIndexOf("/") + 1) + "/" + fname,
|
||||
(path.substring(path.lastIndexOf("/") + 1) + "/" + fname).replace(".ogg", ".mp3"));
|
||||
|
||||
|
||||
dispose.addStatement(name + ".dispose()");
|
||||
dispose.addStatement(name + " = null");
|
||||
type.addField(FieldSpec.builder(ClassName.bestGuess(rtype), name, Modifier.STATIC, Modifier.PUBLIC).initializer("new io.anuke.arc.audio.mock.Mock" + rtype.substring(rtype.lastIndexOf(".") + 1)+ "()").build());
|
||||
@ -92,6 +102,7 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
|
||||
}
|
||||
|
||||
type.addMethod(load.build());
|
||||
type.addMethod(loadBegin.build());
|
||||
type.addMethod(dispose.build());
|
||||
JavaFile.builder(packageName, type.build()).build().writeTo(Utils.filer);
|
||||
}
|
||||
|
Reference in New Issue
Block a user