Compare commits
192 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7fb128499 | ||
|
|
c2d619cb7f | ||
|
|
78176cca90 | ||
|
|
dbc49649c0 | ||
|
|
49ee821029 | ||
|
|
e1499330bc | ||
|
|
222175e005 | ||
|
|
388927715e | ||
|
|
ac9e1febfb | ||
|
|
e47836cc64 | ||
|
|
f8f48f1c88 | ||
|
|
95e8a603a5 | ||
|
|
c400fd88f3 | ||
|
|
095d90fd22 | ||
|
|
797be92ddd | ||
|
|
7f23bd694c | ||
|
|
1cbf8b960a | ||
|
|
c8ce195522 | ||
|
|
4458ae042e | ||
|
|
1c3d7c1c73 | ||
|
|
cb3bbd169f | ||
|
|
ab107bfc0d | ||
|
|
d0b5b49bf8 | ||
|
|
1b4b1d5c9f | ||
|
|
aee800ab7a | ||
|
|
895b46307a | ||
|
|
d300d45f22 | ||
|
|
dd05f5278c | ||
|
|
1897008c72 | ||
|
|
328cdac60f | ||
|
|
3942c6cd55 | ||
|
|
f0f7b5aaf7 | ||
|
|
3ad9e44891 | ||
|
|
80bdaa1edc | ||
|
|
39acb224d1 | ||
|
|
f51d565db8 | ||
|
|
d608cf6536 | ||
|
|
0b49bd1985 | ||
|
|
fce69005a9 | ||
|
|
b73420b156 | ||
|
|
fb863cb39b | ||
|
|
8247ff15ed | ||
|
|
af8db9062c | ||
|
|
9039d52817 | ||
|
|
88d5e1cca8 | ||
|
|
57544e615f | ||
|
|
61a92d55ae | ||
|
|
940965f03d | ||
|
|
30a254e9be | ||
|
|
581782af28 | ||
|
|
72cad1409f | ||
|
|
e7e4985761 | ||
|
|
cdb3d29767 | ||
|
|
90fe5329e3 | ||
|
|
22e20cb2da | ||
|
|
a3454e50d7 | ||
|
|
75b8f5e543 | ||
|
|
1a0b22ef15 | ||
|
|
bc78d1a561 | ||
|
|
00b953a04e | ||
|
|
aa0ef529f5 | ||
|
|
bd134bf9c9 | ||
|
|
752267c521 | ||
|
|
34635e3460 | ||
|
|
ba0b4513f1 | ||
|
|
4764808450 | ||
|
|
c66fd67510 | ||
|
|
3997ca6454 | ||
|
|
4242100c53 | ||
|
|
32adcc3676 | ||
|
|
80c26606f0 | ||
|
|
a7852098f1 | ||
|
|
72638fc215 | ||
|
|
65418529cd | ||
|
|
ceea0d1730 | ||
|
|
764ea699b1 | ||
|
|
bdb7f522fb | ||
|
|
2461331e32 | ||
|
|
3464f40da3 | ||
|
|
3b2b79d539 | ||
|
|
8616fc6b05 | ||
|
|
9e9c001422 | ||
|
|
93bbd34055 | ||
|
|
cac953e812 | ||
|
|
aeb3662414 | ||
|
|
1687ce3182 | ||
|
|
2888e87bb8 | ||
|
|
094ebb8020 | ||
|
|
54ad52edc2 | ||
|
|
0e869f3cb5 | ||
|
|
4d40af6ac0 | ||
|
|
79a2f31056 | ||
|
|
b2341bf75c | ||
|
|
c4c4b473e5 | ||
|
|
6e26ccf25d | ||
|
|
83bfad3546 | ||
|
|
90f6fff1ae | ||
|
|
52f2b52990 | ||
|
|
48ed4b0e49 | ||
|
|
c3c609e7b9 | ||
|
|
6cd8fa6b0c | ||
|
|
ffb6d398d7 | ||
|
|
52674b4668 | ||
|
|
4ae2370137 | ||
|
|
cee55afa5c | ||
|
|
f998bbbe4c | ||
|
|
e5d19a9819 | ||
|
|
dd75d88d2f | ||
|
|
65ea01218a | ||
|
|
7a2234cd25 | ||
|
|
11ede2756e | ||
|
|
3e51fab387 | ||
|
|
962f413421 | ||
|
|
ae6c938abb | ||
|
|
68faae69c5 | ||
|
|
08edce7906 | ||
|
|
55eb493d1f | ||
|
|
d6be07f1b8 | ||
|
|
064a012b25 | ||
|
|
df26148e7c | ||
|
|
d26f533111 | ||
|
|
69575dbab3 | ||
|
|
9f4a430412 | ||
|
|
23843be981 | ||
|
|
486e3ffc0a | ||
|
|
8127e5a66f | ||
|
|
53167a3b52 | ||
|
|
1b77247c40 | ||
|
|
24374cf7e3 | ||
|
|
88de54ec90 | ||
|
|
3035d569cc | ||
|
|
51f9ad5a2c | ||
|
|
bb322f1bff | ||
|
|
72843e9c92 | ||
|
|
20fbe2fbbe | ||
|
|
bf073a84c8 | ||
|
|
35b158dba7 | ||
|
|
465c0e7dc3 | ||
|
|
eb4f6f2e9f | ||
|
|
0ff56e3a68 | ||
|
|
e4e2b6ab00 | ||
|
|
af67690e75 | ||
|
|
b37ae484c0 | ||
|
|
18f1b5f9d2 | ||
|
|
96a92fd85f | ||
|
|
e5175d6309 | ||
|
|
b5ceee3336 | ||
|
|
c97826ed29 | ||
|
|
9c653a46bc | ||
|
|
9f5a183793 | ||
|
|
c2a6690d24 | ||
|
|
5e5b719704 | ||
|
|
bb5e454b91 | ||
|
|
ffb12f9c0b | ||
|
|
a89786d079 | ||
|
|
271d01dc9d | ||
|
|
d3ffaea042 | ||
|
|
a2fa65330d | ||
|
|
d3af66b7ed | ||
|
|
4a7960d64b | ||
|
|
c5226c9e59 | ||
|
|
3bad95b389 | ||
|
|
54ef7760b9 | ||
|
|
2ed5d34192 | ||
|
|
9336a2b4c5 | ||
|
|
eb92ca8cd7 | ||
|
|
f5866d7f72 | ||
|
|
dbbc72d00f | ||
|
|
2b4bcf0b0a | ||
|
|
0851f2d0e2 | ||
|
|
ea9ed841ee | ||
|
|
567f3fd3cd | ||
|
|
9dcd8dc419 | ||
|
|
e19bd9d434 | ||
|
|
35ecd26634 | ||
|
|
ac3bb37c36 | ||
|
|
17b8b285a3 | ||
|
|
788bf383aa | ||
|
|
8d0b889f3c | ||
|
|
d250fb655d | ||
|
|
74eb79de17 | ||
|
|
e2eabfc141 | ||
|
|
a3ee43b31c | ||
|
|
12dd16d4bf | ||
|
|
a5b9e57576 | ||
|
|
6c194d257c | ||
|
|
09598e0ced | ||
|
|
6af2696f6a | ||
|
|
69dac77932 | ||
|
|
2764e0e5fa | ||
|
|
fa5cdc3afa | ||
|
|
8dae5ec47a |
@@ -8,7 +8,7 @@ buildscript{
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
classpath 'com.android.tools.build:gradle:3.4.0'
|
classpath 'com.android.tools.build:gradle:3.4.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,26 +167,3 @@ task run(type: Exec){
|
|||||||
def adb = path + "/platform-tools/adb"
|
def adb = path + "/platform-tools/adb"
|
||||||
commandLine "$adb", 'shell', 'am', 'start', '-n', 'io.anuke.mindustry/io.anuke.mindustry.AndroidLauncher'
|
commandLine "$adb", 'shell', 'am', 'start', '-n', 'io.anuke.mindustry/io.anuke.mindustry.AndroidLauncher'
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets up the Android Idea project, using the old Ant based build.
|
|
||||||
idea{
|
|
||||||
module{
|
|
||||||
sourceDirs += file("src")
|
|
||||||
scopes = [COMPILE: [plus: [project.configurations.compile]]]
|
|
||||||
|
|
||||||
iml{
|
|
||||||
withXml{
|
|
||||||
def node = it.asNode()
|
|
||||||
def builder = NodeBuilder.newInstance()
|
|
||||||
builder.current = node
|
|
||||||
builder.component(name: "FacetManager"){
|
|
||||||
facet(type: "android", name: "Android"){
|
|
||||||
configuration{
|
|
||||||
option(name: "UPDATE_PROPERTY_FILES", value: "true")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,16 +15,15 @@ import io.anuke.arc.backends.android.surfaceview.AndroidApplication;
|
|||||||
import io.anuke.arc.backends.android.surfaceview.AndroidApplicationConfiguration;
|
import io.anuke.arc.backends.android.surfaceview.AndroidApplicationConfiguration;
|
||||||
import io.anuke.arc.files.FileHandle;
|
import io.anuke.arc.files.FileHandle;
|
||||||
import io.anuke.arc.function.Consumer;
|
import io.anuke.arc.function.Consumer;
|
||||||
|
import io.anuke.arc.function.Predicate;
|
||||||
import io.anuke.arc.scene.ui.layout.Unit;
|
import io.anuke.arc.scene.ui.layout.Unit;
|
||||||
import io.anuke.arc.util.Strings;
|
import io.anuke.arc.util.Strings;
|
||||||
import io.anuke.arc.util.serialization.Base64Coder;
|
import io.anuke.arc.util.serialization.Base64Coder;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.Platform;
|
||||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
import io.anuke.mindustry.game.Saves.SaveSlot;
|
||||||
import io.anuke.mindustry.io.SaveIO;
|
import io.anuke.mindustry.io.SaveIO;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.*;
|
||||||
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
||||||
import io.anuke.mindustry.net.ArcNetClient;
|
|
||||||
import io.anuke.mindustry.net.ArcNetServer;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -72,10 +71,10 @@ public class AndroidLauncher extends AndroidApplication{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, String filetype){
|
public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, Predicate<String> filetype){
|
||||||
chooser = new FileChooser(text, file -> file.extension().equalsIgnoreCase(filetype), open, cons);
|
chooser = new FileChooser(text, file -> filetype.test(file.extension().toLowerCase()), open, cons);
|
||||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M || (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
|
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M || (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
|
||||||
checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){
|
checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){
|
||||||
chooser.show();
|
chooser.show();
|
||||||
chooser = null;
|
chooser = null;
|
||||||
}else{
|
}else{
|
||||||
@@ -157,7 +156,7 @@ public class AndroidLauncher extends AndroidApplication{
|
|||||||
SaveSlot slot = control.saves.importSave(file);
|
SaveSlot slot = control.saves.importSave(file);
|
||||||
ui.load.runLoadSave(slot);
|
ui.load.runLoadSave(slot);
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
ui.showError(Core.bundle.format("save.import.fail", Strings.parseException(e, false)));
|
ui.showError(Core.bundle.format("save.import.fail", Strings.parseException(e, true)));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
ui.showError("$save.import.invalid");
|
ui.showError("$save.import.invalid");
|
||||||
|
|||||||
@@ -4,12 +4,27 @@ import java.lang.annotation.*;
|
|||||||
|
|
||||||
public class Annotations{
|
public class Annotations{
|
||||||
|
|
||||||
@Target({ElementType.METHOD, ElementType.FIELD})
|
/** Indicates that a method should always call its super version. */
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface CallSuper{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Annotation that allows overriding CallSuper annotation. To be used on method that overrides method with CallSuper annotation from parent class.*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface OverrideCallSuper {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Indicates that a method return or field can be null.*/
|
||||||
|
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface Nullable{
|
public @interface Nullable{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Indicates that a method return or field cannot be null.*/
|
||||||
@Target({ElementType.METHOD, ElementType.FIELD})
|
@Target({ElementType.METHOD, ElementType.FIELD})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface NonNull{
|
public @interface NonNull{
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package io.anuke.annotations;
|
||||||
|
|
||||||
|
import com.sun.source.util.TreePath;
|
||||||
|
import com.sun.source.util.Trees;
|
||||||
|
import com.sun.tools.javac.tree.JCTree;
|
||||||
|
import com.sun.tools.javac.tree.JCTree.JCExpressionStatement;
|
||||||
|
import io.anuke.annotations.Annotations.OverrideCallSuper;
|
||||||
|
|
||||||
|
import javax.annotation.processing.*;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
import javax.lang.model.element.Element;
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
import javax.tools.Diagnostic.Kind;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@SupportedAnnotationTypes("java.lang.Override")
|
||||||
|
public class CallSuperAnnotationProcessor extends AbstractProcessor{
|
||||||
|
private Trees trees;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init (ProcessingEnvironment pe) {
|
||||||
|
super.init(pe);
|
||||||
|
trees = Trees.instance(pe);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean process (Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||||
|
for (Element e : roundEnv.getElementsAnnotatedWith(Override.class)) {
|
||||||
|
if (e.getAnnotation(OverrideCallSuper.class) != null) return false;
|
||||||
|
|
||||||
|
CodeAnalyzerTreeScanner codeScanner = new CodeAnalyzerTreeScanner();
|
||||||
|
codeScanner.setMethodName(e.getSimpleName().toString());
|
||||||
|
|
||||||
|
TreePath tp = trees.getPath(e.getEnclosingElement());
|
||||||
|
codeScanner.scan(tp, trees);
|
||||||
|
|
||||||
|
if (codeScanner.isCallSuperUsed()) {
|
||||||
|
List list = codeScanner.getMethod().getBody().getStatements();
|
||||||
|
|
||||||
|
if (!doesCallSuper(list, codeScanner.getMethodName())) {
|
||||||
|
processingEnv.getMessager().printMessage(Kind.ERROR, "Overriding method '" + codeScanner.getMethodName() + "' must explicitly call super method from its parent class.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean doesCallSuper (List list, String methodName) {
|
||||||
|
for (Object object : list) {
|
||||||
|
if (object instanceof JCTree.JCExpressionStatement) {
|
||||||
|
JCTree.JCExpressionStatement expr = (JCExpressionStatement) object;
|
||||||
|
String exprString = expr.toString();
|
||||||
|
if (exprString.startsWith("super." + methodName) && exprString.endsWith(");")) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SourceVersion getSupportedSourceVersion () {
|
||||||
|
return SourceVersion.RELEASE_8;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package io.anuke.annotations;
|
||||||
|
|
||||||
|
import com.sun.source.tree.*;
|
||||||
|
import com.sun.source.util.TreePathScanner;
|
||||||
|
import com.sun.source.util.Trees;
|
||||||
|
import com.sun.tools.javac.code.Scope;
|
||||||
|
import com.sun.tools.javac.code.Symbol;
|
||||||
|
import com.sun.tools.javac.code.Symbol.MethodSymbol;
|
||||||
|
import com.sun.tools.javac.code.Type.ClassType;
|
||||||
|
import com.sun.tools.javac.tree.JCTree.JCIdent;
|
||||||
|
import com.sun.tools.javac.tree.JCTree.JCTypeApply;
|
||||||
|
import io.anuke.annotations.Annotations.CallSuper;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
|
class CodeAnalyzerTreeScanner extends TreePathScanner<Object, Trees> {
|
||||||
|
private String methodName;
|
||||||
|
private MethodTree method;
|
||||||
|
private boolean callSuperUsed;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object visitClass (ClassTree classTree, Trees trees) {
|
||||||
|
Tree extendTree = classTree.getExtendsClause();
|
||||||
|
|
||||||
|
if (extendTree instanceof JCTypeApply) { //generic classes case
|
||||||
|
JCTypeApply generic = (JCTypeApply) extendTree;
|
||||||
|
extendTree = generic.clazz;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extendTree instanceof JCIdent) {
|
||||||
|
JCIdent tree = (JCIdent) extendTree;
|
||||||
|
Scope members = tree.sym.members();
|
||||||
|
|
||||||
|
if (checkScope(members))
|
||||||
|
return super.visitClass(classTree, trees);
|
||||||
|
|
||||||
|
if (checkSuperTypes((ClassType) tree.type))
|
||||||
|
return super.visitClass(classTree, trees);
|
||||||
|
|
||||||
|
}
|
||||||
|
callSuperUsed = false;
|
||||||
|
|
||||||
|
return super.visitClass(classTree, trees);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkSuperTypes (ClassType type) {
|
||||||
|
if (type.supertype_field != null && type.supertype_field.tsym != null) {
|
||||||
|
if (checkScope(type.supertype_field.tsym.members()))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return checkSuperTypes((ClassType) type.supertype_field);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkScope (Scope members) {
|
||||||
|
for (Symbol s : members.getElements()) {
|
||||||
|
if (s instanceof MethodSymbol) {
|
||||||
|
MethodSymbol ms = (MethodSymbol) s;
|
||||||
|
|
||||||
|
if (ms.getSimpleName().toString().equals(methodName)) {
|
||||||
|
Annotation annotation = ms.getAnnotation(CallSuper.class);
|
||||||
|
if (annotation != null) {
|
||||||
|
callSuperUsed = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object visitMethod (MethodTree methodTree, Trees trees) {
|
||||||
|
if (methodTree.getName().toString().equals(methodName))
|
||||||
|
method = methodTree;
|
||||||
|
|
||||||
|
return super.visitMethod(methodTree, trees);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMethodName (String methodName) {
|
||||||
|
this.methodName = methodName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMethodName () {
|
||||||
|
return methodName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodTree getMethod () {
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCallSuperUsed () {
|
||||||
|
return callSuperUsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,9 +13,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||||
@SupportedAnnotationTypes({
|
@SupportedAnnotationTypes("io.anuke.annotations.Annotations.Serialize")
|
||||||
"io.anuke.annotations.Annotations.Serialize"
|
|
||||||
})
|
|
||||||
public class SerializeAnnotationProcessor extends AbstractProcessor{
|
public class SerializeAnnotationProcessor extends AbstractProcessor{
|
||||||
/** Target class name. */
|
/** Target class name. */
|
||||||
private static final String className = "Serialization";
|
private static final String className = "Serialization";
|
||||||
@@ -44,20 +42,10 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC);
|
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC);
|
||||||
classBuilder.addAnnotation(AnnotationSpec.builder(SuppressWarnings.class).addMember("value", "\"unchecked\"").build());
|
classBuilder.addAnnotation(AnnotationSpec.builder(SuppressWarnings.class).addMember("value", "\"unchecked\"").build());
|
||||||
classBuilder.addJavadoc(RemoteMethodAnnotationProcessor.autogenWarning);
|
classBuilder.addJavadoc(RemoteMethodAnnotationProcessor.autogenWarning);
|
||||||
|
|
||||||
|
|
||||||
MethodSpec.Builder method = MethodSpec.methodBuilder("init").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
MethodSpec.Builder method = MethodSpec.methodBuilder("init").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
||||||
|
|
||||||
TypeName jsonType = ClassName.bestGuess("io.anuke.arc.util.serialization.Json");
|
|
||||||
TypeName jsonValueType = ClassName.bestGuess("io.anuke.arc.util.serialization.JsonValue");
|
|
||||||
TypeName ubJsonWriterType = ClassName.bestGuess("io.anuke.arc.util.serialization.UBJsonWriter");
|
|
||||||
TypeName ubJsonReaderType = ClassName.bestGuess("io.anuke.arc.util.serialization.UBJsonReader");
|
|
||||||
|
|
||||||
classBuilder.addField(jsonType, "bjson", Modifier.STATIC, Modifier.PRIVATE);
|
|
||||||
classBuilder.addField(ubJsonReaderType, "bjsonReader", Modifier.STATIC, Modifier.PRIVATE);
|
|
||||||
classBuilder.addStaticBlock(CodeBlock.builder()
|
|
||||||
.addStatement("bjson = new " + jsonType + "()")
|
|
||||||
.addStatement("bjsonReader = new " + ubJsonReaderType + "()")
|
|
||||||
.build());
|
|
||||||
|
|
||||||
for(TypeElement elem : elements){
|
for(TypeElement elem : elements){
|
||||||
TypeName type = TypeName.get(elem.asType());
|
TypeName type = TypeName.get(elem.asType());
|
||||||
String simpleTypeName = type.toString().substring(type.toString().lastIndexOf('.') + 1);
|
String simpleTypeName = type.toString().substring(type.toString().lastIndexOf('.') + 1);
|
||||||
@@ -79,19 +67,7 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
.addException(IOException.class)
|
.addException(IOException.class)
|
||||||
.addModifiers(Modifier.PUBLIC);
|
.addModifiers(Modifier.PUBLIC);
|
||||||
|
|
||||||
MethodSpec.Builder jsonWriteMethod = MethodSpec.methodBuilder("write" + simpleTypeName + "Json")
|
|
||||||
.returns(void.class)
|
|
||||||
.addParameter(jsonType, "json")
|
|
||||||
.addParameter(type, "object")
|
|
||||||
.addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
|
||||||
|
|
||||||
MethodSpec.Builder jsonReadMethod = MethodSpec.methodBuilder("read" + simpleTypeName + "Json")
|
|
||||||
.returns(type)
|
|
||||||
.addParameter(jsonValueType, "value")
|
|
||||||
.addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
|
||||||
|
|
||||||
readMethod.addStatement("$L object = new $L()", type, type);
|
readMethod.addStatement("$L object = new $L()", type, type);
|
||||||
jsonReadMethod.addStatement("$L object = new $L()", type, type);
|
|
||||||
|
|
||||||
List<VariableElement> fields = ElementFilter.fieldsIn(Utils.elementUtils.getAllMembers(elem));
|
List<VariableElement> fields = ElementFilter.fieldsIn(Utils.elementUtils.getAllMembers(elem));
|
||||||
for(VariableElement field : fields){
|
for(VariableElement field : fields){
|
||||||
@@ -105,9 +81,6 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
if(field.asType().getKind().isPrimitive()){
|
if(field.asType().getKind().isPrimitive()){
|
||||||
writeMethod.addStatement("stream.write" + capName + "(object." + name + ")");
|
writeMethod.addStatement("stream.write" + capName + "(object." + name + ")");
|
||||||
readMethod.addStatement("object." + name + "= stream.read" + capName + "()");
|
readMethod.addStatement("object." + name + "= stream.read" + capName + "()");
|
||||||
|
|
||||||
jsonWriteMethod.addStatement("json.writeValue(\"" + name + "\", object." + name + ")");
|
|
||||||
jsonReadMethod.addStatement("if(value.has(\"" + name + "\")) object." + name + "= value.get" + capName + "(\"" + name + "\")");
|
|
||||||
}else{
|
}else{
|
||||||
writeMethod.addStatement("io.anuke.arc.Core.settings.getSerializer(" + typeName + ".class).write(stream, object." + name + ")");
|
writeMethod.addStatement("io.anuke.arc.Core.settings.getSerializer(" + typeName + ".class).write(stream, object." + name + ")");
|
||||||
readMethod.addStatement("object." + name + " = (" + typeName + ")io.anuke.arc.Core.settings.getSerializer(" + typeName + ".class).read(stream)");
|
readMethod.addStatement("object." + name + " = (" + typeName + ")io.anuke.arc.Core.settings.getSerializer(" + typeName + ".class).read(stream)");
|
||||||
@@ -115,7 +88,6 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
readMethod.addStatement("return object");
|
readMethod.addStatement("return object");
|
||||||
jsonReadMethod.addStatement("return object");
|
|
||||||
|
|
||||||
serializer.addMethod(writeMethod.build());
|
serializer.addMethod(writeMethod.build());
|
||||||
serializer.addMethod(readMethod.build());
|
serializer.addMethod(readMethod.build());
|
||||||
@@ -130,32 +102,6 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
|
|
||||||
classBuilder.addMethod(writeMethod.build());
|
classBuilder.addMethod(writeMethod.build());
|
||||||
classBuilder.addMethod(readMethod.build());
|
classBuilder.addMethod(readMethod.build());
|
||||||
|
|
||||||
classBuilder.addMethod(jsonWriteMethod.build());
|
|
||||||
classBuilder.addMethod(jsonReadMethod.build());
|
|
||||||
|
|
||||||
MethodSpec.Builder binaryJsonWriteMethod = MethodSpec.methodBuilder("write" + simpleTypeName + "StreamJson")
|
|
||||||
.returns(void.class)
|
|
||||||
.addParameter(DataOutput.class, "stream")
|
|
||||||
.addParameter(type, "object")
|
|
||||||
.addException(IOException.class)
|
|
||||||
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
|
|
||||||
.addStatement("java.io.StringWriter output = new java.io.StringWriter()")
|
|
||||||
.addStatement("bjson.setWriter(output)")
|
|
||||||
.addStatement("bjson.writeObjectStart(" + type + ".class, " + type + ".class)")
|
|
||||||
.addStatement("write" + simpleTypeName + "Json(bjson, object)")
|
|
||||||
.addStatement("bjson.writeObjectEnd()")
|
|
||||||
.addStatement("stream.writeUTF(output.toString())");
|
|
||||||
|
|
||||||
MethodSpec.Builder binaryJsonReadMethod = MethodSpec.methodBuilder("read" + simpleTypeName + "StreamJson")
|
|
||||||
.returns(type)
|
|
||||||
.addParameter(DataInput.class, "stream")
|
|
||||||
.addException(IOException.class)
|
|
||||||
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
|
|
||||||
.addStatement("return read" + simpleTypeName + "Json(bjson.fromJson(null, stream.readUTF()))");
|
|
||||||
|
|
||||||
classBuilder.addMethod(binaryJsonWriteMethod.build());
|
|
||||||
classBuilder.addMethod(binaryJsonReadMethod.build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
classBuilder.addMethod(method.build());
|
classBuilder.addMethod(method.build());
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
io.anuke.annotations.RemoteMethodAnnotationProcessor
|
io.anuke.annotations.RemoteMethodAnnotationProcessor
|
||||||
io.anuke.annotations.SerializeAnnotationProcessor
|
io.anuke.annotations.SerializeAnnotationProcessor
|
||||||
io.anuke.annotations.StructAnnotationProcessor
|
io.anuke.annotations.StructAnnotationProcessor
|
||||||
|
io.anuke.annotations.CallSuperAnnotationProcessor
|
||||||
30
build.gradle
@@ -15,8 +15,6 @@ buildscript{
|
|||||||
}
|
}
|
||||||
|
|
||||||
allprojects{
|
allprojects{
|
||||||
apply plugin: "idea"
|
|
||||||
|
|
||||||
version = 'release'
|
version = 'release'
|
||||||
|
|
||||||
ext{
|
ext{
|
||||||
@@ -29,7 +27,7 @@ allprojects{
|
|||||||
arcHash = null
|
arcHash = null
|
||||||
|
|
||||||
debugged = {
|
debugged = {
|
||||||
return new File(projectDir.parent, '../debug').exists() && !project.hasProperty("release")
|
return new File(projectDir.parent, '../debug').exists() && !project.hasProperty("release") && project.hasProperty("args")
|
||||||
}
|
}
|
||||||
|
|
||||||
localArc = {
|
localArc = {
|
||||||
@@ -177,6 +175,31 @@ project(":core"){
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
|
if(System.properties["user.name"] == "anuke"){
|
||||||
|
task cleanGen{
|
||||||
|
doFirst{
|
||||||
|
delete{
|
||||||
|
delete "../core/src/io/anuke/mindustry/gen/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task copyGen{
|
||||||
|
doLast{
|
||||||
|
copy{
|
||||||
|
from("../core/build/generated/sources/annotationProcessor/java/main/io/anuke/mindustry/gen"){
|
||||||
|
include "**/*.java"
|
||||||
|
}
|
||||||
|
|
||||||
|
into "../core/src/io/anuke/mindustry/gen"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava.dependsOn(cleanGen)
|
||||||
|
compileJava.finalizedBy(copyGen)
|
||||||
|
}
|
||||||
|
|
||||||
compile arcModule("arc-core")
|
compile arcModule("arc-core")
|
||||||
compile arcModule("extensions:freetype")
|
compile arcModule("extensions:freetype")
|
||||||
compile arcModule("extensions:arcnet")
|
compile arcModule("extensions:arcnet")
|
||||||
@@ -227,6 +250,7 @@ project(":annotations"){
|
|||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
compile 'com.squareup:javapoet:1.11.0'
|
compile 'com.squareup:javapoet:1.11.0'
|
||||||
|
compile files("${System.getProperty('java.home')}/../lib/tools.jar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 312 B After Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 1018 B After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 401 B |
BIN
core/assets-raw/sprites/blocks/distribution/center.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 97 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 127 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 133 B After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 163 B After Width: | Height: | Size: 411 B |
|
Before Width: | Height: | Size: 115 B After Width: | Height: | Size: 381 B |
|
Before Width: | Height: | Size: 273 B After Width: | Height: | Size: 852 B |
|
Before Width: | Height: | Size: 405 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 125 B |
|
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 78 B After Width: | Height: | Size: 101 B |
|
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 219 B |
|
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 198 B |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 253 B After Width: | Height: | Size: 920 B |
|
Before Width: | Height: | Size: 206 B After Width: | Height: | Size: 606 B |
|
Before Width: | Height: | Size: 172 B After Width: | Height: | Size: 454 B |
|
Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 298 B |
|
Before Width: | Height: | Size: 168 B After Width: | Height: | Size: 455 B |
|
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 385 B |
|
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 811 B |
|
Before Width: | Height: | Size: 135 B After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 177 B After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 329 B |
|
Before Width: | Height: | Size: 175 B After Width: | Height: | Size: 475 B |
|
Before Width: | Height: | Size: 170 B After Width: | Height: | Size: 436 B |
|
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 850 B |
|
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 352 B |
|
Before Width: | Height: | Size: 121 B After Width: | Height: | Size: 295 B |
|
Before Width: | Height: | Size: 157 B After Width: | Height: | Size: 372 B |
|
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 199 B |
|
Before Width: | Height: | Size: 132 B After Width: | Height: | Size: 292 B |
|
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 404 B |
|
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 219 B |
|
Before Width: | Height: | Size: 115 B After Width: | Height: | Size: 243 B |
|
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 265 B |
|
Before Width: | Height: | Size: 133 B After Width: | Height: | Size: 2.0 KiB |