Merge remote-tracking branch 'upstream/master'

# Conflicts:
#	core/assets/bundles/bundle_ja.properties
This commit is contained in:
beito123
2019-04-16 19:10:18 +09:00
734 changed files with 23080 additions and 9474 deletions
-1
View File
@@ -1,4 +1,3 @@
jdk: jdk:
- openjdk8 - openjdk8
script: script:
-1
View File
@@ -3,7 +3,6 @@
package="io.anuke.mindustry"> package="io.anuke.mindustry">
<uses-feature android:glEsVersion="0x00020000" android:required="true"/> <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
+2 -11
View File
@@ -27,9 +27,6 @@ repositories {
dependencies{ dependencies{
implementation project(":core") implementation project(":core")
implementation project(":net") implementation project(":net")
implementation 'com.android.support:support-v4:28.0.0'
implementation 'org.sufficientlysecure:donations:2.5'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation arcModule("backends:backend-android") implementation arcModule("backends:backend-android")
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
@@ -47,9 +44,9 @@ dependencies {
task deploy(type: Copy){ task deploy(type: Copy){
dependsOn "assembleRelease" dependsOn "assembleRelease"
from "build/outputs/apk/google/release/android-google-release.apk" from "build/outputs/apk/release/android-release.apk"
into "../deploy/" into "../deploy/"
rename ("android-google-release.apk", appName + "-android-" + getVersionString() + ".apk") rename("android-release.apk", appName + "-android-" + getVersionString() + ".apk")
} }
android{ android{
@@ -103,12 +100,6 @@ android {
flavorDimensions "google" flavorDimensions "google"
productFlavors {
google {
buildConfigField "boolean", "DONATIONS_GOOGLE", "true"
}
}
signingConfigs{ signingConfigs{
release{ release{
if(project.hasProperty("RELEASE_STORE_FILE")){ if(project.hasProperty("RELEASE_STORE_FILE")){
Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 76 KiB

-1
View File
@@ -9,6 +9,5 @@
# #
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target. # Project target.
target=android-19 target=android-19
Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 911 B

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 23 KiB

-32
View File
@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#000">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:adjustViewBounds="false"
android:contentDescription="background"
android:cropToPadding="false"
android:scaleType="centerCrop"
android:src="@drawable/background" />
<LinearLayout
android:id="@+id/donations_activity_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 553 B

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 28 KiB

-15
View File
@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Mindustry</string>
<string-array name="donation_google_catalog_values">
<item>1 달러</item>
<item>2 달러</item>
<item>5 달러</item>
<item>10 달러</item>
<item>15 달러</item>
<item>25 달러</item>
<item>50 달러</item>
</string-array>
</resources>
-15
View File
@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Mindustry</string>
<string-array name="donation_google_catalog_values">
<item>1 Доллар</item>
<item>2 Доллара</item>
<item>5 Долларов</item>
<item>10 Долларов</item>
<item>15 Долларов</item>
<item>25 Долларов</item>
<item>50 Долларов</item>
</string-array>
</resources>
-15
View File
@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Mindustry</string>
<string-array name="donation_google_catalog_values">
<item>1 Доллар</item>
<item>2 Доллара</item>
<item>5 Долларів</item>
<item>10 Долларів</item>
<item>15 Долларів</item>
<item>25 Долларів</item>
<item>50 Долларів</item>
</string-array>
</resources>
-9
View File
@@ -2,14 +2,5 @@
<resources> <resources>
<string name="app_name">Mindustry</string> <string name="app_name">Mindustry</string>
<string-array name="donation_google_catalog_values">
<item>1 Dollar</item>
<item>2 Dollars</item>
<item>5 Dollars</item>
<item>10 Dollars</item>
<item>15 Dollars</item>
<item>25 Dollars</item>
<item>50 Dollars</item>
</string-array>
</resources> </resources>
@@ -10,11 +10,6 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings.Secure; import android.provider.Settings.Secure;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.security.ProviderInstaller;
import io.anuke.arc.Core; import io.anuke.arc.Core;
import io.anuke.arc.backends.android.surfaceview.AndroidApplication; import io.anuke.arc.backends.android.surfaceview.AndroidApplication;
import io.anuke.arc.backends.android.surfaceview.AndroidApplicationConfiguration; import io.anuke.arc.backends.android.surfaceview.AndroidApplicationConfiguration;
@@ -23,18 +18,15 @@ import io.anuke.arc.function.Consumer;
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.net.KryoClient;
import io.anuke.net.KryoServer;
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.Net;
import io.anuke.mindustry.ui.dialogs.FileChooser; import io.anuke.mindustry.ui.dialogs.FileChooser;
import io.anuke.net.KryoClient;
import io.anuke.net.KryoServer;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.Vars.*;
@@ -53,8 +45,8 @@ public class AndroidLauncher extends AndroidApplication{
Platform.instance = new Platform(){ Platform.instance = new Platform(){
@Override @Override
public void openDonations(){ public void hide(){
showDonations(); moveTaskToBack(true);
} }
@Override @Override
@@ -94,7 +86,7 @@ public class AndroidLauncher extends AndroidApplication{
if(checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){ if(checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
perms.add(Manifest.permission.READ_EXTERNAL_STORAGE); perms.add(Manifest.permission.READ_EXTERNAL_STORAGE);
} }
requestPermissions(perms.toArray(new String[perms.size()]), PERMISSION_REQUEST_CODE); requestPermissions(perms.toArray(new String[0]), PERMISSION_REQUEST_CODE);
} }
} }
@@ -114,17 +106,10 @@ public class AndroidLauncher extends AndroidApplication{
} }
}; };
try{
ProviderInstaller.installIfNeeded(this);
}catch(GooglePlayServicesRepairableException e){
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
apiAvailability.getErrorDialog(this, e.getConnectionStatusCode(), 0).show();
}catch(GooglePlayServicesNotAvailableException e){
Log.e("SecurityException", "Google Play Services not available.");
}
if(doubleScaleTablets && isTablet(this.getContext())){ if(doubleScaleTablets && isTablet(this.getContext())){
Unit.dp.addition = 0.5f; Unit.dp.addition = 0.5f;
} }
config.hideStatusBar = true; config.hideStatusBar = true;
Net.setClientProvider(new KryoClient()); Net.setClientProvider(new KryoClient());
Net.setServerProvider(new KryoServer()); Net.setServerProvider(new KryoServer());
@@ -133,7 +118,7 @@ public class AndroidLauncher extends AndroidApplication{
} }
@Override @Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults){ public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults){
if(requestCode == PERMISSION_REQUEST_CODE){ if(requestCode == PERMISSION_REQUEST_CODE){
for(int i : grantResults){ for(int i : grantResults){
if(i != PackageManager.PERMISSION_GRANTED) return; if(i != PackageManager.PERMISSION_GRANTED) return;
@@ -195,22 +180,8 @@ public class AndroidLauncher extends AndroidApplication{
} }
} }
private boolean isPackageInstalled(String packagename){
try{
getPackageManager().getPackageInfo(packagename, 0);
return true;
}catch(Exception e){
return false;
}
}
private boolean isTablet(Context context){ private boolean isTablet(Context context){
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
return manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE; return manager != null && manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE;
}
private void showDonations(){
Intent intent = new Intent(this, DonationsActivity.class);
startActivity(intent);
} }
} }
@@ -1,73 +0,0 @@
package io.anuke.mindustry;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.Button;
import org.sufficientlysecure.donations.DonationsFragment;
public class DonationsActivity extends FragmentActivity{
/**
* Google
*/
private static final String GOOGLE_PUBKEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzG93KhpfBPKTo2jF0yxbWkkmMKwsPNM4SsMj1aDq7vv6n3R+mqJVfprOJxFfJh7JchXTflLIgiaKXFAiU70gJbMTniEWnEaFSxAeF09a7U0RjOwN+7rFwjCG91c2CpYxPanBTQP4zasc1ODPVzq4q6/4ByjhenN71V4WmR08NFIAodcfFPrOkDPil7i8y7cgcd1Ky53U0TS+LLYJttAK3XdTK4s7VE3I5IKoeNa4uwCmIM59R67q2k3cXjLk/nP6MP+y++EzHN/PTiR1sVg4dMP8K31RPw/1QNLPQwJz6Wc872oWwb7xo5gkoXbDc5WPPydsi8F3SyKNaYwzN6CDFQIDAQAB";
private static final String[] GOOGLE_CATALOG = new String[]{
"mindustry.donation.1", "mindustry.donation.2", "mindustry.donation.5",
"mindustry.donation.10", "mindustry.donation.15",
"mindustry.donation.25", "mindustry.donation.50"};
DonationsFragment donationsFragment;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setTheme(R.style.GdxTheme);
setContentView(R.layout.donations_activity);
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
if(BuildConfig.DONATIONS_GOOGLE){
donationsFragment = DonationsFragment.newInstance(BuildConfig.DEBUG, true, GOOGLE_PUBKEY, GOOGLE_CATALOG,
getResources().getStringArray(R.array.donation_google_catalog_values), false, null, null,
null, false, null, null, false, null);
}
ft.replace(R.id.donations_activity_container, donationsFragment, "donationsFragment");
ft.commit();
}
public void onStart(){
super.onStart();
Button b = findViewById(org.sufficientlysecure.donations.R.id.donations__google_android_market_donate_button);
b.setOnClickListener(view -> {
donationsFragment.donateGoogleOnClick(donationsFragment.getView());
b.setEnabled(false);
});
}
/**
* Needed for Google Play In-app Billing. It uses startIntentSenderForResult(). The result is not propagated to
* the Fragment like in startActivityForResult(). Thus we need to propagate manually to our Fragment.
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
Button b = findViewById(org.sufficientlysecure.donations.R.id.donations__google_android_market_donate_button);
b.setEnabled(true);
FragmentManager fragmentManager = getSupportFragmentManager();
Fragment fragment = fragmentManager.findFragmentByTag("donationsFragment");
if(fragment != null){
fragment.onActivityResult(requestCode, resultCode, data);
}
}
}
@@ -1,12 +1,21 @@
package io.anuke.annotations; package io.anuke.annotations;
import java.lang.annotation.ElementType; import java.lang.annotation.*;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
public class Annotations{ public class Annotations{
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.SOURCE)
public @interface Nullable{
}
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.SOURCE)
public @interface NonNull{
}
/** Marks a class as serializable. */ /** Marks a class as serializable. */
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@@ -1,7 +1,5 @@
package io.anuke.annotations; package io.anuke.annotations;
import io.anuke.annotations.MethodEntry;
import java.util.ArrayList; import java.util.ArrayList;
/** Represents a class witha list method entries to include in it. */ /** Represents a class witha list method entries to include in it. */
@@ -1,8 +1,6 @@
package io.anuke.annotations; package io.anuke.annotations;
import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.*;
import io.anuke.annotations.Annotations.PacketPriority;
import io.anuke.annotations.Annotations.Variant;
import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.ExecutableElement;
@@ -1,18 +1,13 @@
package io.anuke.annotations; package io.anuke.annotations;
import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.*;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.TypeSpec;
import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote; import io.anuke.annotations.Annotations.Remote;
import io.anuke.annotations.IOFinder.ClassSerializer; import io.anuke.annotations.IOFinder.ClassSerializer;
import javax.annotation.processing.*; import javax.annotation.processing.*;
import javax.lang.model.SourceVersion; import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element; import javax.lang.model.element.*;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic.Kind; import javax.tools.Diagnostic.Kind;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -3,9 +3,7 @@ package io.anuke.annotations;
import com.squareup.javapoet.*; import com.squareup.javapoet.*;
import io.anuke.annotations.IOFinder.ClassSerializer; import io.anuke.annotations.IOFinder.ClassSerializer;
import javax.lang.model.element.Modifier; import javax.lang.model.element.*;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.tools.Diagnostic.Kind; import javax.tools.Diagnostic.Kind;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
@@ -25,7 +23,6 @@ public class RemoteReadGenerator{
/** /**
* Generates a class for reading remote invoke packets. * Generates a class for reading remote invoke packets.
*
* @param entries List of methods to use. * @param entries List of methods to use.
* @param className Simple target class name. * @param className Simple target class name.
* @param packageName Full target package name. * @param packageName Full target package name.
@@ -4,10 +4,7 @@ import com.squareup.javapoet.*;
import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.IOFinder.ClassSerializer; import io.anuke.annotations.IOFinder.ClassSerializer;
import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.*;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.tools.Diagnostic.Kind; import javax.tools.Diagnostic.Kind;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@@ -109,7 +106,7 @@ public class RemoteWriteGenerator{
for(VariableElement var : elem.getParameters()){ for(VariableElement var : elem.getParameters()){
//special case: calling local-only methods uses the local player //special case: calling local-only methods uses the local player
if(index == 0 && methodEntry.where == Loc.client){ if(index == 0 && methodEntry.where == Loc.client){
results.append("io.anuke.mindustry.Vars.players[0]"); results.append("io.anuke.mindustry.Vars.player");
}else{ }else{
results.append(var.getSimpleName()); results.append(var.getSimpleName());
} }
@@ -5,13 +5,9 @@ import io.anuke.annotations.Annotations.Serialize;
import javax.annotation.processing.*; import javax.annotation.processing.*;
import javax.lang.model.SourceVersion; import javax.lang.model.SourceVersion;
import javax.lang.model.element.Modifier; import javax.lang.model.element.*;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.ElementFilter; import javax.lang.model.util.ElementFilter;
import java.io.DataInput; import java.io.*;
import java.io.DataOutput;
import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -50,8 +46,21 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
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);
TypeSpec.Builder serializer = TypeSpec.anonymousClassBuilder("") TypeSpec.Builder serializer = TypeSpec.anonymousClassBuilder("")
.addSuperinterface(ParameterizedTypeName.get( .addSuperinterface(ParameterizedTypeName.get(
@@ -70,11 +79,24 @@ 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){
if(field.getModifiers().contains(Modifier.STATIC) || field.getModifiers().contains(Modifier.TRANSIENT) || field.getModifiers().contains(Modifier.PRIVATE)) continue; if(field.getModifiers().contains(Modifier.STATIC) || field.getModifiers().contains(Modifier.TRANSIENT) || field.getModifiers().contains(Modifier.PRIVATE))
continue;
String name = field.getSimpleName().toString(); String name = field.getSimpleName().toString();
String typeName = Utils.typeUtils.erasure(field.asType()).toString().replace('$', '.'); String typeName = Utils.typeUtils.erasure(field.asType()).toString().replace('$', '.');
@@ -83,6 +105,9 @@ 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)");
@@ -90,22 +115,47 @@ 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());
method.addStatement("io.anuke.arc.Core.settings.setSerializer($N, $L)", Utils.elementUtils.getBinaryName(elem).toString().replace('$', '.') + ".class", serializer.build()); method.addStatement("io.anuke.arc.Core.settings.setSerializer($N, $L)", Utils.elementUtils.getBinaryName(elem).toString().replace('$', '.') + ".class", serializer.build());
String sname = type.toString().substring(type.toString().lastIndexOf('.') + 1); name(writeMethod, "write" + simpleTypeName);
name(readMethod, "read" + simpleTypeName);
name(writeMethod, "write" + sname);
name(readMethod, "read" + sname);
writeMethod.addModifiers(Modifier.STATIC); writeMethod.addModifiers(Modifier.STATIC);
readMethod.addModifiers(Modifier.STATIC); readMethod.addModifiers(Modifier.STATIC);
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,25 +1,22 @@
package io.anuke.annotations; package io.anuke.annotations;
import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.*;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import io.anuke.annotations.Annotations.Struct; import io.anuke.annotations.Annotations.Struct;
import io.anuke.annotations.Annotations.StructField; import io.anuke.annotations.Annotations.StructField;
import javax.annotation.processing.*; import javax.annotation.processing.*;
import javax.lang.model.SourceVersion; import javax.lang.model.SourceVersion;
import javax.lang.model.element.Modifier; import javax.lang.model.element.*;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeKind;
import javax.lang.model.util.ElementFilter; import javax.lang.model.util.ElementFilter;
import javax.tools.Diagnostic.Kind; import javax.tools.Diagnostic.Kind;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
/**Generates ""value types"" classes that are packed into integer primitives of the most aproppriate size. /**
* It would be nice if Java didn't make crazy hacks like this necessary.*/ * Generates ""value types"" classes that are packed into integer primitives of the most aproppriate size.
* It would be nice if Java didn't make crazy hacks like this necessary.
*/
@SupportedSourceVersion(SourceVersion.RELEASE_8) @SupportedSourceVersion(SourceVersion.RELEASE_8)
@SupportedAnnotationTypes({ @SupportedAnnotationTypes({
"io.anuke.annotations.Annotations.Struct" "io.anuke.annotations.Annotations.Struct"
@@ -129,7 +126,7 @@ public class StructAnnotationProcessor extends AbstractProcessor{
//floats: need conversion //floats: need conversion
setter.addStatement("return ($T)(($L & $L) | (($T)Float.floatToIntBits(value) << $LL))", structType, structParam, bitString(offset, size, structTotalSize), structType, offset); setter.addStatement("return ($T)(($L & $L) | (($T)Float.floatToIntBits(value) << $LL))", structType, structParam, bitString(offset, size, structTotalSize), structType, offset);
}else{ }else{
cons.append(" | (").append("(").append(structType).append(")").append(varName).append(" << ").append(offset).append("L)"); cons.append(" | (((").append(structType).append(")").append(varName).append(" << ").append(offset).append("L)").append(" & ").append(bitString(offset, size, structTotalSize)).append(")");
//bytes, shorts, chars, ints //bytes, shorts, chars, ints
setter.addStatement("return ($T)(($L & $L) | (($T)value << $LL))", structType, structParam, bitString(offset, size, structTotalSize), structType, offset); setter.addStatement("return ($T)(($L & $L) | (($T)value << $LL))", structType, structParam, bitString(offset, size, structTotalSize), structType, offset);
+11 -7
View File
@@ -8,7 +8,7 @@ buildscript{
} }
dependencies{ dependencies{
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.5' classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.6'
classpath "com.badlogicgames.gdx:gdx-tools:1.9.9" classpath "com.badlogicgames.gdx:gdx-tools:1.9.9"
classpath "com.badlogicgames.packr:packr:2.1-SNAPSHOT" classpath "com.badlogicgames.packr:packr:2.1-SNAPSHOT"
} }
@@ -25,15 +25,15 @@ allprojects{
if(!project.hasProperty("versionType")) versionType = 'official' if(!project.hasProperty("versionType")) versionType = 'official'
appName = 'Mindustry' appName = 'Mindustry'
gdxVersion = '1.9.9' gdxVersion = '1.9.9'
roboVMVersion = '2.3.0' roboVMVersion = '2.3.6'
arcHash = null arcHash = null
debugged = { debugged = {
return new File(projectDir.parent, '../debug').exists() && System.properties["release"] == null return new File(projectDir.parent, '../debug').exists() && !project.hasProperty("release")
} }
localArc = { localArc = {
return (System.properties["release"] == null || System.properties["release"] == "false") && new File(projectDir.parent, '../Arc').exists() return (!project.hasProperty("release")) && new File(projectDir.parent, '../Arc').exists()
} }
getArcHash = { getArcHash = {
@@ -43,7 +43,7 @@ allprojects{
arcHash = 'git ls-remote https://github.com/Anuken/Arc.git'.execute().text.split("\t")[0] arcHash = 'git ls-remote https://github.com/Anuken/Arc.git'.execute().text.split("\t")[0]
}catch(e){ }catch(e){
e.printStackTrace() e.printStackTrace()
arcHash = "-SNAPSHOT"; arcHash = "-SNAPSHOT"
} }
} }
return arcHash return arcHash
@@ -89,7 +89,8 @@ allprojects{
try{ try{
pfile.createNewFile() pfile.createNewFile()
}catch(Exception ignored){} }catch(Exception ignored){
}
if(pfile.exists()){ if(pfile.exists()){
props.load(new FileInputStream(pfile)) props.load(new FileInputStream(pfile))
@@ -112,6 +113,7 @@ allprojects{
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" } maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven{ url "https://oss.sonatype.org/content/repositories/releases/" } maven{ url "https://oss.sonatype.org/content/repositories/releases/" }
maven{ url 'https://jitpack.io' } maven{ url 'https://jitpack.io' }
jcenter()
} }
} }
@@ -128,7 +130,7 @@ project(":desktop"){
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile arcModule("backends:backend-lwjgl3") compile arcModule("backends:backend-lwjgl3")
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.0' compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.2'
} }
} }
@@ -156,6 +158,7 @@ project(":ios"){
dependencies{ dependencies{
compile project(":core") compile project(":core")
compile project(":net") compile project(":net")
compileOnly project(":annotations")
compile arcModule("backends:backend-robovm") compile arcModule("backends:backend-robovm")
@@ -199,6 +202,7 @@ project(":core"){
compile arcModule("arc-core") compile arcModule("arc-core")
compile arcModule("extensions:freetype") compile arcModule("extensions:freetype")
//compile arcModule("extensions:postprocessing")
if(localArc() && debugged()) compile arcModule("extensions:recorder") if(localArc() && debugged()) compile arcModule("extensions:recorder")
compileOnly project(":annotations") compileOnly project(":annotations")
Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 B

After

Width:  |  Height:  |  Size: 121 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 B

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1005 B

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 999 B

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1015 B

After

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1018 B

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 121 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1011 B

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1018 B

After

Width:  |  Height:  |  Size: 104 B

@@ -4,5 +4,5 @@
flattenPaths: true, flattenPaths: true,
maxWidth: 2048, maxWidth: 2048,
maxHeight: 2048, maxHeight: 2048,
fast: true, fast: true
} }
@@ -0,0 +1,8 @@
{
duplicatePadding: true,
combineSubdirectories: true,
flattenPaths: true,
maxWidth: 1024,
maxHeight: 1024,
fast: true
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Some files were not shown because too many files have changed in this diff Show More