Merge remote-tracking branch 'upstream/master'
# Conflicts: # core/assets/bundles/bundle_ja.properties
6
.gitignore
vendored
@@ -1,5 +1,3 @@
|
|||||||
##Packr, build stuff
|
|
||||||
|
|
||||||
logs/
|
logs/
|
||||||
/core/assets/mindustry-saves/
|
/core/assets/mindustry-saves/
|
||||||
/core/assets/mindustry-maps/
|
/core/assets/mindustry-maps/
|
||||||
@@ -13,8 +11,10 @@ logs/
|
|||||||
/desktop/gifexport/
|
/desktop/gifexport/
|
||||||
/core/lib/
|
/core/lib/
|
||||||
/core/assets-raw/sprites/generated/
|
/core/assets-raw/sprites/generated/
|
||||||
|
/core/assets-raw/sprites_out/
|
||||||
/annotations/build/
|
/annotations/build/
|
||||||
/kryonet/build/
|
/annotations/out/
|
||||||
|
/net/build/
|
||||||
/tools/build/
|
/tools/build/
|
||||||
/tests/build/
|
/tests/build/
|
||||||
/server/build/
|
/server/build/
|
||||||
|
|||||||
@@ -3,25 +3,24 @@
|
|||||||
[](https://travis-ci.org/Anuken/Mindustry)
|
[](https://travis-ci.org/Anuken/Mindustry)
|
||||||
[](https://discord.gg/mindustry)
|
[](https://discord.gg/mindustry)
|
||||||
|
|
||||||
A pixelated sandbox tower defense game made using [LibGDX](https://libgdx.badlogicgames.com/). Winner of the [GDL Metal Monstrosity Jam](https://itch.io/jam/gdl---metal-monstrosity-jam).
|
A sandbox tower defense game written in Java.
|
||||||
|
|
||||||
_[Trello Board](https://trello.com/b/aE2tcUwF/mindustry-40-plans)_
|
_[Trello Board](https://trello.com/b/aE2tcUwF/mindustry-40-plans)_
|
||||||
_[Wiki](http://mindustry.wikia.com/wiki/Mindustry_Wiki)_
|
_[Wiki](http://mindustry.wikia.com/wiki/Mindustry_Wiki)_
|
||||||
_[Discord](https://discord.gg/r8BkXNd)_
|
|
||||||
|
|
||||||
### Building
|
### Building
|
||||||
|
|
||||||
Bleeding-edge live builds are generated automatically for every commit. You can see them [here](https://jenkins.hellomouse.net/job/mindustry/).
|
Bleeding-edge live builds are generated automatically for every commit. You can see them [here](https://jenkins.hellomouse.net/job/mindustry/).
|
||||||
|
|
||||||
If you'd rather compile on your own, follow these instructions.
|
If you'd rather compile on your own, follow these instructions.
|
||||||
First, make sure you have Java 8 and JDK 8 installed. Open a terminal in the root directory, and run the following commands:
|
First, make sure you have Java 8 and JDK 8 installed. Open a terminal in the root directory, `cd` to the Mindustry folder and run the following commands:
|
||||||
|
|
||||||
#### Windows
|
#### Windows
|
||||||
|
|
||||||
_Running:_ `gradlew desktop:run`
|
_Running:_ `gradlew desktop:run`
|
||||||
_Building:_ `gradlew desktop:dist`
|
_Building:_ `gradlew desktop:dist`
|
||||||
|
|
||||||
#### Linux
|
#### Linux/Mac OS
|
||||||
|
|
||||||
_Running:_ `./gradlew desktop:run`
|
_Running:_ `./gradlew desktop:run`
|
||||||
_Building:_ `./gradlew desktop:dist`
|
_Building:_ `./gradlew desktop:dist`
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
android:appCategory="game"
|
android:appCategory="game"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/GdxTheme" android:fullBackupContent="@xml/backup_rules">
|
android:theme="@style/GdxTheme" android:fullBackupContent="@xml/backup_rules">
|
||||||
|
<meta-data android:name="android.max_aspect" android:value="2.1" />
|
||||||
<activity
|
<activity
|
||||||
android:name="io.anuke.mindustry.AndroidLauncher"
|
android:name="io.anuke.mindustry.AndroidLauncher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
classpath 'com.android.tools.build:gradle:3.3.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,24 +26,22 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(":core")
|
implementation project(":core")
|
||||||
implementation project(":kryonet")
|
implementation project(":net")
|
||||||
implementation 'com.android.support:support-v4:28.0.0'
|
implementation 'com.android.support:support-v4:28.0.0'
|
||||||
implementation 'org.sufficientlysecure:donations:2.5'
|
implementation 'org.sufficientlysecure:donations:2.5'
|
||||||
implementation 'com.google.android.gms:play-services-auth:16.0.1'
|
implementation 'com.google.android.gms:play-services-auth:16.0.1'
|
||||||
|
|
||||||
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
|
implementation arcModule("backends:backend-android")
|
||||||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
|
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
|
||||||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
|
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
|
||||||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
|
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
|
||||||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
|
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
|
||||||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
|
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
|
||||||
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
|
|
||||||
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
|
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
|
||||||
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
|
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
|
||||||
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
|
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
|
||||||
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
|
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
|
||||||
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
|
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
|
||||||
implementation "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task deploy(type: Copy){
|
task deploy(type: Copy){
|
||||||
|
|||||||
@@ -20,26 +20,10 @@
|
|||||||
#}
|
#}
|
||||||
|
|
||||||
-verbose
|
-verbose
|
||||||
|
-verbose
|
||||||
-dontwarn android.support.**
|
-ignorewarnings
|
||||||
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
|
-keep class io.anuke.mindustry.game.Rules
|
||||||
-dontwarn com.badlogic.gdx.utils.GdxBuild
|
-keep class io.anuke.mindustry.desktop.DesktopLauncher
|
||||||
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
|
-keepclasseswithmembers public class * {
|
||||||
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
|
public static void main(java.lang.String[]);
|
||||||
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild
|
|
||||||
|
|
||||||
-keep class com.badlogic.gdx.controllers.android.AndroidControllers
|
|
||||||
|
|
||||||
-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
|
|
||||||
<init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
-keepclassmembers class com.badlogic.gdx.physics.box2d.World {
|
|
||||||
boolean contactFilter(long, long);
|
|
||||||
void beginContact(long);
|
|
||||||
void endContact(long);
|
|
||||||
void preSolve(long, long);
|
|
||||||
void postSolve(long, long);
|
|
||||||
boolean reportFixture(long);
|
|
||||||
float reportRayFixture(long, float, float, float, float, float);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<string-array name="donation_google_catalog_values">
|
<string-array name="donation_google_catalog_values">
|
||||||
<item>1 Доллар</item>
|
<item>1 Доллар</item>
|
||||||
<item>2 Доллара</item>
|
<item>2 Доллара</item>
|
||||||
<item>5 Доллара</item>
|
<item>5 Долларов</item>
|
||||||
<item>10 Долларов</item>
|
<item>10 Долларов</item>
|
||||||
<item>15 Долларов</item>
|
<item>15 Долларов</item>
|
||||||
<item>25 Долларов</item>
|
<item>25 Долларов</item>
|
||||||
|
|||||||
15
android/res/values-uk/strings.xml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?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>
|
||||||
@@ -11,25 +11,25 @@ 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 android.util.Log;
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
|
||||||
import com.badlogic.gdx.utils.Base64Coder;
|
|
||||||
import com.google.android.gms.common.GoogleApiAvailability;
|
import com.google.android.gms.common.GoogleApiAvailability;
|
||||||
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
|
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
|
||||||
import com.google.android.gms.common.GooglePlayServicesRepairableException;
|
import com.google.android.gms.common.GooglePlayServicesRepairableException;
|
||||||
import com.google.android.gms.security.ProviderInstaller;
|
import com.google.android.gms.security.ProviderInstaller;
|
||||||
import io.anuke.kryonet.KryoClient;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.kryonet.KryoServer;
|
import io.anuke.arc.backends.android.surfaceview.AndroidApplication;
|
||||||
|
import io.anuke.arc.backends.android.surfaceview.AndroidApplicationConfiguration;
|
||||||
|
import io.anuke.arc.files.FileHandle;
|
||||||
|
import io.anuke.arc.function.Consumer;
|
||||||
|
import io.anuke.arc.scene.ui.layout.Unit;
|
||||||
|
import io.anuke.arc.util.Strings;
|
||||||
|
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.ucore.function.Consumer;
|
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
|
||||||
import io.anuke.ucore.util.Bundles;
|
|
||||||
import io.anuke.ucore.util.Strings;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -39,7 +39,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class AndroidLauncher extends PatchedAndroidApplication{
|
public class AndroidLauncher extends AndroidApplication{
|
||||||
public static final int PERMISSION_REQUEST_CODE = 1;
|
public static final int PERMISSION_REQUEST_CODE = 1;
|
||||||
boolean doubleScaleTablets = true;
|
boolean doubleScaleTablets = true;
|
||||||
FileChooser chooser;
|
FileChooser chooser;
|
||||||
@@ -49,6 +49,7 @@ public class AndroidLauncher extends PatchedAndroidApplication{
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
|
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
|
||||||
config.useImmersiveMode = true;
|
config.useImmersiveMode = true;
|
||||||
|
config.depth = 0;
|
||||||
Platform.instance = new Platform(){
|
Platform.instance = new Platform(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -161,23 +162,23 @@ public class AndroidLauncher extends PatchedAndroidApplication{
|
|||||||
InputStream inStream;
|
InputStream inStream;
|
||||||
if(myFile != null) inStream = new FileInputStream(myFile);
|
if(myFile != null) inStream = new FileInputStream(myFile);
|
||||||
else inStream = getContentResolver().openInputStream(uri);
|
else inStream = getContentResolver().openInputStream(uri);
|
||||||
Gdx.app.postRunnable(() -> {
|
Core.app.post(() -> {
|
||||||
if(save){ //open save
|
if(save){ //open save
|
||||||
System.out.println("Opening save.");
|
System.out.println("Opening save.");
|
||||||
FileHandle file = Gdx.files.local("temp-save." + saveExtension);
|
FileHandle file = Core.files.local("temp-save." + saveExtension);
|
||||||
file.write(inStream, false);
|
file.write(inStream, false);
|
||||||
if(SaveIO.isSaveValid(file)){
|
if(SaveIO.isSaveValid(file)){
|
||||||
try{
|
try{
|
||||||
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(Bundles.format("text.save.import.fail", Strings.parseException(e, false)));
|
ui.showError(Core.bundle.format("text.save.import.fail", Strings.parseException(e, false)));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
ui.showError("$text.save.import.invalid");
|
ui.showError("$text.save.import.invalid");
|
||||||
}
|
}
|
||||||
}else if(map){ //open map
|
}else if(map){ //open map
|
||||||
Gdx.app.postRunnable(() -> {
|
Core.app.post(() -> {
|
||||||
System.out.println("Opening map.");
|
System.out.println("Opening map.");
|
||||||
if(!ui.editor.isShown()){
|
if(!ui.editor.isShown()){
|
||||||
ui.editor.show();
|
ui.editor.show();
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package io.anuke.mindustry;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
public class PatchedAndroidApplication extends AndroidApplication {
|
|
||||||
private final ExecutorService exec = Executors.newSingleThreadExecutor();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause () {
|
|
||||||
if(useImmersiveMode) {
|
|
||||||
exec.submit(() -> {
|
|
||||||
try {Thread.sleep(100);} catch (InterruptedException ignored) {}
|
|
||||||
graphics.onDrawFrame(null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,6 +14,21 @@ public class Annotations{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Marks a class as a special value type struct. Class name must end in 'Struct'.*/
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface Struct{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**Marks a field of a struct. Optional.*/
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface StructField{
|
||||||
|
/**Size of a struct field in bits. Not valid on booleans or floating point numbers.*/
|
||||||
|
int value();
|
||||||
|
}
|
||||||
|
|
||||||
public enum PacketPriority{
|
public enum PacketPriority{
|
||||||
/** Gets put in a queue and processed if not connected. */
|
/** Gets put in a queue and processed if not connected. */
|
||||||
normal,
|
normal,
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import java.util.stream.Collectors;
|
|||||||
public class RemoteMethodAnnotationProcessor extends AbstractProcessor{
|
public class RemoteMethodAnnotationProcessor extends AbstractProcessor{
|
||||||
/** Maximum size of each event packet. */
|
/** Maximum size of each event packet. */
|
||||||
public static final int maxPacketSize = 4096;
|
public static final int maxPacketSize = 4096;
|
||||||
|
/** Warning on top of each autogenerated file.*/
|
||||||
|
public static final String autogenWarning = "Autogenerated file. Do not modify!\n";
|
||||||
/** Name of the base package to put all the generated classes. */
|
/** Name of the base package to put all the generated classes. */
|
||||||
private static final String packageName = "io.anuke.mindustry.gen";
|
private static final String packageName = "io.anuke.mindustry.gen";
|
||||||
|
|
||||||
@@ -136,6 +138,7 @@ public class RemoteMethodAnnotationProcessor extends AbstractProcessor{
|
|||||||
|
|
||||||
//create class for storing unique method hash
|
//create class for storing unique method hash
|
||||||
TypeSpec.Builder hashBuilder = TypeSpec.classBuilder("MethodHash").addModifiers(Modifier.PUBLIC);
|
TypeSpec.Builder hashBuilder = TypeSpec.classBuilder("MethodHash").addModifiers(Modifier.PUBLIC);
|
||||||
|
hashBuilder.addJavadoc(autogenWarning);
|
||||||
hashBuilder.addField(FieldSpec.builder(int.class, "HASH", Modifier.STATIC, Modifier.PUBLIC, Modifier.FINAL)
|
hashBuilder.addField(FieldSpec.builder(int.class, "HASH", Modifier.STATIC, Modifier.PUBLIC, Modifier.FINAL)
|
||||||
.initializer("$1L", Objects.hash(methods)).build());
|
.initializer("$1L", Objects.hash(methods)).build());
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ 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 io.anuke.annotations.MethodEntry;
|
|
||||||
import io.anuke.annotations.Utils;
|
|
||||||
|
|
||||||
import javax.lang.model.element.Modifier;
|
import javax.lang.model.element.Modifier;
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
@@ -28,7 +26,7 @@ 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.
|
||||||
* @param needsPlayer Whether this read method requires a reference to the player sender.
|
* @param needsPlayer Whether this read method requires a reference to the player sender.
|
||||||
@@ -37,6 +35,7 @@ public class RemoteReadGenerator{
|
|||||||
throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, IOException{
|
throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, IOException{
|
||||||
|
|
||||||
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC);
|
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC);
|
||||||
|
classBuilder.addJavadoc(RemoteMethodAnnotationProcessor.autogenWarning);
|
||||||
|
|
||||||
//create main method builder
|
//create main method builder
|
||||||
MethodSpec.Builder readMethod = MethodSpec.methodBuilder("readPacket")
|
MethodSpec.Builder readMethod = MethodSpec.methodBuilder("readPacket")
|
||||||
@@ -51,7 +50,7 @@ public class RemoteReadGenerator{
|
|||||||
Constructor<TypeName> cons = TypeName.class.getDeclaredConstructor(String.class);
|
Constructor<TypeName> cons = TypeName.class.getDeclaredConstructor(String.class);
|
||||||
cons.setAccessible(true);
|
cons.setAccessible(true);
|
||||||
|
|
||||||
TypeName playerType = cons.newInstance("io.anuke.mindustry.entities.Player");
|
TypeName playerType = cons.newInstance("io.anuke.mindustry.entities.type.Player");
|
||||||
//add player parameter
|
//add player parameter
|
||||||
readMethod.addParameter(playerType, "player");
|
readMethod.addParameter(playerType, "player");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public class RemoteWriteGenerator{
|
|||||||
for(ClassEntry entry : entries){
|
for(ClassEntry entry : entries){
|
||||||
//create builder
|
//create builder
|
||||||
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(entry.name).addModifiers(Modifier.PUBLIC);
|
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(entry.name).addModifiers(Modifier.PUBLIC);
|
||||||
|
classBuilder.addJavadoc(RemoteMethodAnnotationProcessor.autogenWarning);
|
||||||
|
|
||||||
//add temporary write buffer
|
//add temporary write buffer
|
||||||
classBuilder.addField(FieldSpec.builder(ByteBuffer.class, "TEMP_BUFFER", Modifier.STATIC, Modifier.PRIVATE, Modifier.FINAL)
|
classBuilder.addField(FieldSpec.builder(ByteBuffer.class, "TEMP_BUFFER", Modifier.STATIC, Modifier.PRIVATE, Modifier.FINAL)
|
||||||
@@ -79,7 +80,7 @@ public class RemoteWriteGenerator{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!elem.getParameters().get(0).asType().toString().equals("io.anuke.mindustry.entities.Player")){
|
if(!elem.getParameters().get(0).asType().toString().equals("io.anuke.mindustry.entities.type.Player")){
|
||||||
Utils.messager.printMessage(Kind.ERROR, "Client invoke methods should have a first parameter of type Player.", elem);
|
Utils.messager.printMessage(Kind.ERROR, "Client invoke methods should have a first parameter of type Player.", elem);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -129,7 +130,7 @@ public class RemoteWriteGenerator{
|
|||||||
method.beginControlFlow("if(" + getCheckString(methodEntry.where) + ")");
|
method.beginControlFlow("if(" + getCheckString(methodEntry.where) + ")");
|
||||||
|
|
||||||
//add statement to create packet from pool
|
//add statement to create packet from pool
|
||||||
method.addStatement("$1N packet = $2N.obtain($1N.class, $1N::new)", "io.anuke.mindustry.net.Packets.InvokePacket", "io.anuke.ucore.util.Pooling");
|
method.addStatement("$1N packet = $2N.obtain($1N.class, $1N::new)", "io.anuke.mindustry.net.Packets.InvokePacket", "io.anuke.arc.util.pooling.Pools");
|
||||||
//assign buffer
|
//assign buffer
|
||||||
method.addStatement("packet.writeBuffer = TEMP_BUFFER");
|
method.addStatement("packet.writeBuffer = TEMP_BUFFER");
|
||||||
//assign priority
|
//assign priority
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import javax.lang.model.util.ElementFilter;
|
|||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ 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);
|
||||||
MethodSpec.Builder method = MethodSpec.methodBuilder("init").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
MethodSpec.Builder method = MethodSpec.methodBuilder("init").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
||||||
|
|
||||||
for(TypeElement elem : elements){
|
for(TypeElement elem : elements){
|
||||||
@@ -53,20 +55,18 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
|
|
||||||
TypeSpec.Builder serializer = TypeSpec.anonymousClassBuilder("")
|
TypeSpec.Builder serializer = TypeSpec.anonymousClassBuilder("")
|
||||||
.addSuperinterface(ParameterizedTypeName.get(
|
.addSuperinterface(ParameterizedTypeName.get(
|
||||||
ClassName.bestGuess("io.anuke.ucore.io.TypeSerializer"), type));
|
ClassName.bestGuess("io.anuke.arc.Settings.TypeSerializer"), type));
|
||||||
|
|
||||||
MethodSpec.Builder writeMethod = MethodSpec.methodBuilder("write")
|
MethodSpec.Builder writeMethod = MethodSpec.methodBuilder("write")
|
||||||
.returns(void.class)
|
.returns(void.class)
|
||||||
.addParameter(DataOutput.class, "stream")
|
.addParameter(DataOutput.class, "stream")
|
||||||
.addParameter(type, "object")
|
.addParameter(type, "object")
|
||||||
.addAnnotation(Override.class)
|
|
||||||
.addException(IOException.class)
|
.addException(IOException.class)
|
||||||
.addModifiers(Modifier.PUBLIC);
|
.addModifiers(Modifier.PUBLIC);
|
||||||
|
|
||||||
MethodSpec.Builder readMethod = MethodSpec.methodBuilder("read")
|
MethodSpec.Builder readMethod = MethodSpec.methodBuilder("read")
|
||||||
.returns(type)
|
.returns(type)
|
||||||
.addParameter(DataInput.class, "stream")
|
.addParameter(DataInput.class, "stream")
|
||||||
.addAnnotation(Override.class)
|
|
||||||
.addException(IOException.class)
|
.addException(IOException.class)
|
||||||
.addModifiers(Modifier.PUBLIC);
|
.addModifiers(Modifier.PUBLIC);
|
||||||
|
|
||||||
@@ -84,8 +84,8 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
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 + "()");
|
||||||
}else{
|
}else{
|
||||||
writeMethod.addStatement("io.anuke.ucore.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.ucore.core.Settings.getSerializer(" + typeName+ ".class).read(stream)");
|
readMethod.addStatement("object." + name + " = (" +typeName+")io.anuke.arc.Core.settings.getSerializer(" + typeName+ ".class).read(stream)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,18 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
serializer.addMethod(writeMethod.build());
|
serializer.addMethod(writeMethod.build());
|
||||||
serializer.addMethod(readMethod.build());
|
serializer.addMethod(readMethod.build());
|
||||||
|
|
||||||
method.addStatement("io.anuke.ucore.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" + sname);
|
||||||
|
name(readMethod, "read" + sname);
|
||||||
|
|
||||||
|
writeMethod.addModifiers(Modifier.STATIC);
|
||||||
|
readMethod.addModifiers(Modifier.STATIC);
|
||||||
|
|
||||||
|
classBuilder.addMethod(writeMethod.build());
|
||||||
|
classBuilder.addMethod(readMethod.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
classBuilder.addMethod(method.build());
|
classBuilder.addMethod(method.build());
|
||||||
@@ -108,4 +119,14 @@ public class SerializeAnnotationProcessor extends AbstractProcessor{
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void name(MethodSpec.Builder builder, String name){
|
||||||
|
try{
|
||||||
|
Field field = builder.getClass().getDeclaredField("name");
|
||||||
|
field.setAccessible(true);
|
||||||
|
field.set(builder, name);
|
||||||
|
}catch(Exception e){
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,229 @@
|
|||||||
|
package io.anuke.annotations;
|
||||||
|
|
||||||
|
import com.squareup.javapoet.JavaFile;
|
||||||
|
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.StructField;
|
||||||
|
|
||||||
|
import javax.annotation.processing.*;
|
||||||
|
import javax.lang.model.SourceVersion;
|
||||||
|
import javax.lang.model.element.Modifier;
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
import javax.lang.model.element.VariableElement;
|
||||||
|
import javax.lang.model.type.TypeKind;
|
||||||
|
import javax.lang.model.util.ElementFilter;
|
||||||
|
import javax.tools.Diagnostic.Kind;
|
||||||
|
import java.util.List;
|
||||||
|
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.*/
|
||||||
|
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||||
|
@SupportedAnnotationTypes({
|
||||||
|
"io.anuke.annotations.Annotations.Struct"
|
||||||
|
})
|
||||||
|
public class StructAnnotationProcessor extends AbstractProcessor{
|
||||||
|
/** Name of the base package to put all the generated classes. */
|
||||||
|
private static final String packageName = "io.anuke.mindustry.gen";
|
||||||
|
private int round;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void init(ProcessingEnvironment processingEnv){
|
||||||
|
super.init(processingEnv);
|
||||||
|
//put all relevant utils into utils class
|
||||||
|
Utils.typeUtils = processingEnv.getTypeUtils();
|
||||||
|
Utils.elementUtils = processingEnv.getElementUtils();
|
||||||
|
Utils.filer = processingEnv.getFiler();
|
||||||
|
Utils.messager = processingEnv.getMessager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv){
|
||||||
|
if(round++ != 0) return false; //only process 1 round
|
||||||
|
|
||||||
|
try{
|
||||||
|
Set<TypeElement> elements = ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(Struct.class));
|
||||||
|
|
||||||
|
for(TypeElement elem : elements){
|
||||||
|
|
||||||
|
if(!elem.getSimpleName().toString().endsWith("Struct")){
|
||||||
|
Utils.messager.printMessage(Kind.ERROR, "All classes annotated with @Struct must have their class names end in 'Struct'.", elem);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String structName = elem.getSimpleName().toString().substring(0, elem.getSimpleName().toString().length() - "Struct".length());
|
||||||
|
String structParam = structName.toLowerCase();
|
||||||
|
|
||||||
|
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(structName)
|
||||||
|
.addModifiers(Modifier.FINAL, Modifier.PUBLIC);
|
||||||
|
|
||||||
|
try{
|
||||||
|
List<VariableElement> variables = ElementFilter.fieldsIn(elem.getEnclosedElements());
|
||||||
|
int structSize = variables.stream().mapToInt(StructAnnotationProcessor::varSize).sum();
|
||||||
|
int structTotalSize = (structSize <= 8 ? 8 : structSize <= 16 ? 16 : structSize <= 32 ? 32 : 64);
|
||||||
|
|
||||||
|
if(variables.size() == 0){
|
||||||
|
Utils.messager.printMessage(Kind.ERROR, "making a struct with no fields is utterly pointles.", elem);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//obtain type which will be stored
|
||||||
|
Class<?> structType = typeForSize(structSize);
|
||||||
|
|
||||||
|
//[constructor] get(fields...) : structType
|
||||||
|
MethodSpec.Builder constructor = MethodSpec.methodBuilder("get")
|
||||||
|
.addModifiers(Modifier.STATIC, Modifier.PUBLIC)
|
||||||
|
.returns(structType);
|
||||||
|
|
||||||
|
StringBuilder cons = new StringBuilder();
|
||||||
|
StringBuilder doc = new StringBuilder();
|
||||||
|
doc.append("Bits used: ").append(structSize).append(" / ").append(structTotalSize).append("\n");
|
||||||
|
|
||||||
|
int offset = 0;
|
||||||
|
for(VariableElement var : variables){
|
||||||
|
int size = varSize(var);
|
||||||
|
TypeName varType = TypeName.get(var.asType());
|
||||||
|
String varName = var.getSimpleName().toString();
|
||||||
|
|
||||||
|
//add val param to constructor
|
||||||
|
constructor.addParameter(varType, varName);
|
||||||
|
|
||||||
|
//[get] field(structType) : fieldType
|
||||||
|
MethodSpec.Builder getter = MethodSpec.methodBuilder(var.getSimpleName().toString())
|
||||||
|
.addModifiers(Modifier.STATIC, Modifier.PUBLIC)
|
||||||
|
.returns(varType)
|
||||||
|
.addParameter(structType, structParam);
|
||||||
|
//[set] field(structType, fieldType) : structType
|
||||||
|
MethodSpec.Builder setter = MethodSpec.methodBuilder(var.getSimpleName().toString())
|
||||||
|
.addModifiers(Modifier.STATIC, Modifier.PUBLIC)
|
||||||
|
.returns(structType)
|
||||||
|
.addParameter(structType, structParam).addParameter(varType, "value");
|
||||||
|
|
||||||
|
//[getter]
|
||||||
|
if(varType == TypeName.BOOLEAN){
|
||||||
|
//bools: single bit, is simplified
|
||||||
|
getter.addStatement("return ($L & (1L << $L)) != 0", structParam, offset);
|
||||||
|
}else if(varType == TypeName.FLOAT){
|
||||||
|
//floats: need conversion
|
||||||
|
getter.addStatement("return Float.intBitsToFloat((int)(($L >>> $L) & $L))", structParam, offset, bitString(size, structTotalSize));
|
||||||
|
}else{
|
||||||
|
//bytes, shorts, chars, ints
|
||||||
|
getter.addStatement("return ($T)(($L >>> $L) & $L)", varType, structParam, offset, bitString(size, structTotalSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
//[setter] + [constructor building]
|
||||||
|
if(varType == TypeName.BOOLEAN){
|
||||||
|
cons.append(" | (").append(varName).append(" ? ").append("1L << ").append(offset).append("L : 0)");
|
||||||
|
|
||||||
|
//bools: single bit, needs special case to clear things
|
||||||
|
setter.beginControlFlow("if(value)");
|
||||||
|
setter.addStatement("return ($T)(($L & ~(1L << $LL)))", structType, structParam, offset);
|
||||||
|
setter.nextControlFlow("else");
|
||||||
|
setter.addStatement("return ($T)(($L & ~(1L << $LL)) | (1L << $LL))", structType, structParam, offset, offset);
|
||||||
|
setter.endControlFlow();
|
||||||
|
}else if(varType == TypeName.FLOAT){
|
||||||
|
cons.append(" | (").append("(").append(structType).append(")").append("Float.floatToIntBits(").append(varName).append(") << ").append(offset).append("L)");
|
||||||
|
|
||||||
|
//floats: need conversion
|
||||||
|
setter.addStatement("return ($T)(($L & $L) | (($T)Float.floatToIntBits(value) << $LL))", structType, structParam, bitString(offset, size, structTotalSize), structType, offset);
|
||||||
|
}else{
|
||||||
|
cons.append(" | (").append("(").append(structType).append(")").append(varName).append(" << ").append(offset).append("L)");
|
||||||
|
|
||||||
|
//bytes, shorts, chars, ints
|
||||||
|
setter.addStatement("return ($T)(($L & $L) | (($T)value << $LL))", structType, structParam, bitString(offset, size, structTotalSize), structType, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.append("<br> ").append(varName).append(" [").append(offset).append("..").append(size + offset).append("]\n");
|
||||||
|
|
||||||
|
//add finished methods
|
||||||
|
classBuilder.addMethod(getter.build());
|
||||||
|
classBuilder.addMethod(setter.build());
|
||||||
|
|
||||||
|
offset += size;
|
||||||
|
}
|
||||||
|
|
||||||
|
classBuilder.addJavadoc(doc.toString());
|
||||||
|
|
||||||
|
//add constructor final statement + add to class and build
|
||||||
|
constructor.addStatement("return ($T)($L)", structType, cons.toString().substring(3));
|
||||||
|
classBuilder.addMethod(constructor.build());
|
||||||
|
|
||||||
|
JavaFile.builder(packageName, classBuilder.build()).build().writeTo(Utils.filer);
|
||||||
|
}catch(IllegalArgumentException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
Utils.messager.printMessage(Kind.ERROR, e.getMessage(), elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static String bitString(int offset, int size, int totalSize){
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for(int i = 0; i < offset; i++) builder.append('0');
|
||||||
|
for(int i = 0; i < size; i++) builder.append('1');
|
||||||
|
for(int i = 0; i < totalSize - size - offset; i++) builder.append('0');
|
||||||
|
return "0b" + builder.reverse().toString() + "L";
|
||||||
|
}
|
||||||
|
|
||||||
|
static String bitString(int size, int totalSize){
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for(int i = 0; i < size; i++) builder.append('1');
|
||||||
|
for(int i = 0; i < totalSize - size; i++) builder.append('0');
|
||||||
|
return "0b" + builder.reverse().toString() + "L";
|
||||||
|
}
|
||||||
|
|
||||||
|
static int varSize(VariableElement var) throws IllegalArgumentException{
|
||||||
|
if(!var.asType().getKind().isPrimitive()){
|
||||||
|
throw new IllegalArgumentException("All struct fields must be primitives: " + var);
|
||||||
|
}
|
||||||
|
|
||||||
|
StructField an = var.getAnnotation(StructField.class);
|
||||||
|
if(var.asType().getKind() == TypeKind.BOOLEAN && an != null && an.value() != 1){
|
||||||
|
throw new IllegalArgumentException("Booleans can only be one bit long... why would you do this?");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(var.asType().getKind() == TypeKind.FLOAT && an != null && an.value() != 32){
|
||||||
|
throw new IllegalArgumentException("Float size can't be changed. Very sad.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return an == null ? typeSize(var.asType().getKind()) : an.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Class<?> typeForSize(int size) throws IllegalArgumentException{
|
||||||
|
if(size <= 8){
|
||||||
|
return byte.class;
|
||||||
|
}else if(size <= 16){
|
||||||
|
return short.class;
|
||||||
|
}else if(size <= 32){
|
||||||
|
return int.class;
|
||||||
|
}else if(size <= 64){
|
||||||
|
return long.class;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Too many fields, must fit in 64 bits. Curent size: " + size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**returns a type's element size in bits.*/
|
||||||
|
static int typeSize(TypeKind kind) throws IllegalArgumentException{
|
||||||
|
switch(kind){
|
||||||
|
case BOOLEAN:
|
||||||
|
return 1;
|
||||||
|
case BYTE:
|
||||||
|
return 8;
|
||||||
|
case SHORT:
|
||||||
|
return 16;
|
||||||
|
case FLOAT:
|
||||||
|
case CHAR:
|
||||||
|
case INT:
|
||||||
|
return 32;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid type kind: " + kind + ". Note that doubles and longs are not supported.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
io.anuke.annotations.RemoteMethodAnnotationProcessor
|
io.anuke.annotations.RemoteMethodAnnotationProcessor
|
||||||
io.anuke.annotations.SerializeAnnotationProcessor
|
io.anuke.annotations.SerializeAnnotationProcessor
|
||||||
|
io.anuke.annotations.StructAnnotationProcessor
|
||||||
|
|||||||
140
build.gradle
@@ -6,6 +6,7 @@ buildscript{
|
|||||||
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
maven{ url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.5'
|
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.5'
|
||||||
classpath "com.badlogicgames.gdx:gdx-tools:1.9.9"
|
classpath "com.badlogicgames.gdx:gdx-tools:1.9.9"
|
||||||
@@ -24,7 +25,38 @@ allprojects{
|
|||||||
appName = 'Mindustry'
|
appName = 'Mindustry'
|
||||||
gdxVersion = '1.9.9'
|
gdxVersion = '1.9.9'
|
||||||
roboVMVersion = '2.3.0'
|
roboVMVersion = '2.3.0'
|
||||||
uCoreVersion = '7ffeb2a9c754f4d31ca13e02dd857876b0707dc5'
|
arcHash = null
|
||||||
|
|
||||||
|
debugged = {
|
||||||
|
return new File(projectDir.parent, '../debug').exists() && System.properties["release"] == null
|
||||||
|
}
|
||||||
|
|
||||||
|
localArc = {
|
||||||
|
return (System.properties["release"] == null || System.properties["release"] == "false") && new File(projectDir.parent, '../Arc').exists()
|
||||||
|
}
|
||||||
|
|
||||||
|
getArcHash = {
|
||||||
|
//get latest commit hash from gtihub since JITPack's '-snapshot' version doesn't work correctly
|
||||||
|
if(arcHash == null){
|
||||||
|
try{
|
||||||
|
arcHash = 'git ls-remote https://github.com/Anuken/Arc.git'.execute().text.split("\t")[0]
|
||||||
|
}catch(e){
|
||||||
|
e.printStackTrace()
|
||||||
|
arcHash = "-SNAPSHOT";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arcHash
|
||||||
|
}
|
||||||
|
|
||||||
|
arcModule = { String name ->
|
||||||
|
if(localArc()){
|
||||||
|
return project(":Arc:$name")
|
||||||
|
}else{
|
||||||
|
//skip to last submodule
|
||||||
|
if(name.contains(':')) name = name.split(':').last()
|
||||||
|
return "com.github.Anuken.Arc:$name:${getArcHash()}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getVersionString = {
|
getVersionString = {
|
||||||
String buildVersion = getBuildVersion()
|
String buildVersion = getBuildVersion()
|
||||||
@@ -59,7 +91,6 @@ allprojects{
|
|||||||
}catch(Exception ignored){}
|
}catch(Exception ignored){}
|
||||||
|
|
||||||
if(pfile.exists()){
|
if(pfile.exists()){
|
||||||
|
|
||||||
props.load(new FileInputStream(pfile))
|
props.load(new FileInputStream(pfile))
|
||||||
|
|
||||||
String buildid = getBuildVersion()
|
String buildid = getBuildVersion()
|
||||||
@@ -88,13 +119,14 @@ project(":desktop"){
|
|||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
compile project(":core")
|
compile project(":core")
|
||||||
compile project(":kryonet")
|
compile project(":net")
|
||||||
if(new File(projectDir.parent, '../debug').exists() && System.properties["release"] == null) compile project(":debug")
|
|
||||||
|
if(debugged()) compile project(":debug")
|
||||||
|
|
||||||
compile "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
|
|
||||||
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
||||||
compile "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion"
|
|
||||||
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 'com.github.MinnDevelopment:java-discord-rpc:v2.0.0'
|
compile 'com.github.MinnDevelopment:java-discord-rpc:v2.0.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,24 +135,6 @@ project(":ios"){
|
|||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
apply plugin: "robovm"
|
apply plugin: "robovm"
|
||||||
|
|
||||||
task copyGen{
|
|
||||||
doLast{
|
|
||||||
copy{
|
|
||||||
from("../core/build/classes/java/main/io/anuke/mindustry/gen/"){
|
|
||||||
include "**/*.java"
|
|
||||||
}
|
|
||||||
|
|
||||||
into "../core/src/io/anuke/mindustry/gen"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
doFirst{
|
|
||||||
delete{
|
|
||||||
delete "../core/src/io/anuke/mindustry/gen/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task incrementConfig{
|
task incrementConfig{
|
||||||
def vfile = file('robovm.properties')
|
def vfile = file('robovm.properties')
|
||||||
|
|
||||||
@@ -138,18 +152,14 @@ project(":ios"){
|
|||||||
props.store(vfile.newWriter(), null)
|
props.store(vfile.newWriter(), null)
|
||||||
}
|
}
|
||||||
|
|
||||||
build.dependsOn(incrementConfig)
|
|
||||||
if(file('robovm.properties').exists()){
|
|
||||||
build.dependsOn(copyGen)
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
compile project(":core")
|
compile project(":core")
|
||||||
implementation project(":kryonet")
|
compile project(":net")
|
||||||
|
|
||||||
|
compile arcModule("backends:backend-robovm")
|
||||||
|
|
||||||
compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
|
compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
|
||||||
compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
|
compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
|
||||||
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
|
|
||||||
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
|
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
|
||||||
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
|
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
|
||||||
}
|
}
|
||||||
@@ -162,25 +172,33 @@ project(":core"){
|
|||||||
generateLocales()
|
generateLocales()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task cleanGen{
|
||||||
|
doFirst{
|
||||||
|
delete{
|
||||||
|
delete "../core/src/io/anuke/mindustry/gen/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task copyGen{
|
||||||
|
doLast{
|
||||||
|
copy{
|
||||||
|
from("../core/build/classes/java/main/io/anuke/mindustry/gen/"){
|
||||||
|
include "**/*.java"
|
||||||
|
}
|
||||||
|
|
||||||
|
into "../core/src/io/anuke/mindustry/gen"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
build.finalizedBy(finish)
|
compileJava.dependsOn(cleanGen)
|
||||||
|
compileJava.finalizedBy(copyGen)
|
||||||
|
|
||||||
def comp = System.properties["release"] == null || System.properties["release"] == "false"
|
compile arcModule("arc-core")
|
||||||
if(!comp) println("Note: Compiling release build.")
|
compile arcModule("extensions:freetype")
|
||||||
|
if(localArc() && debugged()) compile arcModule("extensions:recorder")
|
||||||
if(new File(projectDir.parent, '../uCore').exists() && comp){
|
|
||||||
compile project(":uCore")
|
|
||||||
}else{
|
|
||||||
compile "com.github.anuken:ucore:$uCoreVersion"
|
|
||||||
}
|
|
||||||
|
|
||||||
if(new File(projectDir.parent, '../GDXGifRecorder').exists() && comp){
|
|
||||||
compile project(":GDXGifRecorder")
|
|
||||||
}
|
|
||||||
|
|
||||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
|
||||||
compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
|
|
||||||
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
|
|
||||||
|
|
||||||
compileOnly project(":annotations")
|
compileOnly project(":annotations")
|
||||||
annotationProcessor project(":annotations")
|
annotationProcessor project(":annotations")
|
||||||
@@ -190,18 +208,10 @@ project(":core"){
|
|||||||
project(":server"){
|
project(":server"){
|
||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
configurations{
|
|
||||||
if(findProject(":android") != null){
|
|
||||||
compile.exclude module: android
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
|
|
||||||
compile project(":core")
|
compile project(":core")
|
||||||
compile project(":kryonet")
|
compile project(":net")
|
||||||
compile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
|
compile arcModule("backends:backend-headless")
|
||||||
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,10 +220,10 @@ project(":tests"){
|
|||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
testImplementation project(":core")
|
testImplementation project(":core")
|
||||||
testImplementation('org.junit.jupiter:junit-jupiter-api:5.1.0')
|
testImplementation "org.junit.jupiter:junit-jupiter-params:5.3.1"
|
||||||
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.1.0')
|
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.1"
|
||||||
testImplementation "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.3.1"
|
||||||
testImplementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
|
compile arcModule("backends:backend-headless")
|
||||||
}
|
}
|
||||||
|
|
||||||
test{
|
test{
|
||||||
@@ -238,13 +248,13 @@ project(":annotations"){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
project(":kryonet"){
|
project(":net"){
|
||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
compile project(":core")
|
compile project(":core")
|
||||||
compile "org.lz4:lz4-java:1.4.1"
|
compile "org.lz4:lz4-java:1.4.1"
|
||||||
compile 'com.github.Anuken:kryonet:53b10247b1'
|
compile 'com.github.Anuken:kryonet:a64d2280880e80566ca1bdaffa55de43e51cad38'
|
||||||
compile 'com.github.Anuken:WaifUPnP:05eb46bc577fd7674596946ba288c96c0cedd893'
|
compile 'com.github.Anuken:WaifUPnP:05eb46bc577fd7674596946ba288c96c0cedd893'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 273 B After Width: | Height: | Size: 273 B |
|
Before Width: | Height: | Size: 216 B |
|
Before Width: | Height: | Size: 271 B |
|
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 253 B |
|
Before Width: | Height: | Size: 168 B After Width: | Height: | Size: 206 B |
|
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 172 B |
|
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 3.3 KiB |
BIN
core/assets-raw/sprites/blocks/drills/laser-drill-rim.png
Normal file
|
After Width: | Height: | Size: 119 B |
|
Before Width: | Height: | Size: 136 B After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 170 B After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 253 B |
|
Before Width: | Height: | Size: 206 B |
|
Before Width: | Height: | Size: 172 B |
|
Before Width: | Height: | Size: 362 B |
|
Before Width: | Height: | Size: 128 B |
|
Before Width: | Height: | Size: 133 B |
|
Before Width: | Height: | Size: 98 B |
|
Before Width: | Height: | Size: 101 B |
|
Before Width: | Height: | Size: 102 B |
|
Before Width: | Height: | Size: 116 B |
BIN
core/assets-raw/sprites/blocks/environment/char1.png
Normal file
|
After Width: | Height: | Size: 113 B |
BIN
core/assets-raw/sprites/blocks/environment/char2.png
Normal file
|
After Width: | Height: | Size: 109 B |
BIN
core/assets-raw/sprites/blocks/environment/char3.png
Normal file
|
After Width: | Height: | Size: 115 B |
BIN
core/assets-raw/sprites/blocks/environment/cliffs1.png
Normal file
|
After Width: | Height: | Size: 130 B |
BIN
core/assets-raw/sprites/blocks/environment/craters1.png
Normal file
|
After Width: | Height: | Size: 111 B |
BIN
core/assets-raw/sprites/blocks/environment/craters2.png
Normal file
|
After Width: | Height: | Size: 115 B |
BIN
core/assets-raw/sprites/blocks/environment/craters3.png
Normal file
|
After Width: | Height: | Size: 105 B |
BIN
core/assets-raw/sprites/blocks/environment/craters4.png
Normal file
|
After Width: | Height: | Size: 106 B |
BIN
core/assets-raw/sprites/blocks/environment/craters5.png
Normal file
|
After Width: | Height: | Size: 93 B |
BIN
core/assets-raw/sprites/blocks/environment/craters6.png
Normal file
|
After Width: | Height: | Size: 98 B |
|
Before Width: | Height: | Size: 75 B After Width: | Height: | Size: 113 B |
|
After Width: | Height: | Size: 195 B |
|
After Width: | Height: | Size: 578 B |
|
Before Width: | Height: | Size: 103 B |
|
Before Width: | Height: | Size: 94 B |
|
Before Width: | Height: | Size: 101 B |
|
Before Width: | Height: | Size: 116 B |
BIN
core/assets-raw/sprites/blocks/environment/dunerocks-large.png
Normal file
|
After Width: | Height: | Size: 189 B |
BIN
core/assets-raw/sprites/blocks/environment/dunerocks1.png
Normal file
|
After Width: | Height: | Size: 121 B |
BIN
core/assets-raw/sprites/blocks/environment/dunerocks2.png
Normal file
|
After Width: | Height: | Size: 118 B |
|
After Width: | Height: | Size: 354 B |
|
After Width: | Height: | Size: 336 B |
|
Before Width: | Height: | Size: 100 B |
|
Before Width: | Height: | Size: 93 B |
|
Before Width: | Height: | Size: 95 B |
|
Before Width: | Height: | Size: 96 B |
|
Before Width: | Height: | Size: 119 B |
|
Before Width: | Height: | Size: 103 B |
|
Before Width: | Height: | Size: 108 B |
|
Before Width: | Height: | Size: 106 B |
|
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 102 B |
|
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 95 B |
|
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 99 B |
|
Before Width: | Height: | Size: 124 B |
BIN
core/assets-raw/sprites/blocks/environment/holostone1.png
Normal file
|
After Width: | Height: | Size: 108 B |
BIN
core/assets-raw/sprites/blocks/environment/holostone2.png
Normal file
|
After Width: | Height: | Size: 108 B |
BIN
core/assets-raw/sprites/blocks/environment/holostone3.png
Normal file
|
After Width: | Height: | Size: 106 B |
BIN
core/assets-raw/sprites/blocks/environment/hotrock1.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets-raw/sprites/blocks/environment/hotrock2.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets-raw/sprites/blocks/environment/hotrock3.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
core/assets-raw/sprites/blocks/environment/ice-edge.png
Normal file
|
After Width: | Height: | Size: 390 B |
BIN
core/assets-raw/sprites/blocks/environment/ice-snow1.png
Normal file
|
After Width: | Height: | Size: 132 B |
BIN
core/assets-raw/sprites/blocks/environment/ice-snow2.png
Normal file
|
After Width: | Height: | Size: 131 B |
BIN
core/assets-raw/sprites/blocks/environment/ice-snow3.png
Normal file
|
After Width: | Height: | Size: 120 B |
|
Before Width: | Height: | Size: 87 B After Width: | Height: | Size: 105 B |
|
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 108 B |
|
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 109 B |
|
Before Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 130 B |
|
Before Width: | Height: | Size: 130 B |
BIN
core/assets-raw/sprites/blocks/environment/icerocks-large.png
Normal file
|
After Width: | Height: | Size: 180 B |
BIN
core/assets-raw/sprites/blocks/environment/icerocks1.png
Normal file
|
After Width: | Height: | Size: 120 B |
BIN
core/assets-raw/sprites/blocks/environment/icerocks2.png
Normal file
|
After Width: | Height: | Size: 119 B |
|
Before Width: | Height: | Size: 128 B |
|
Before Width: | Height: | Size: 126 B |
BIN
core/assets-raw/sprites/blocks/environment/ignarock1.png
Normal file
|
After Width: | Height: | Size: 1005 B |
BIN
core/assets-raw/sprites/blocks/environment/ignarock2.png
Normal file
|
After Width: | Height: | Size: 999 B |
BIN
core/assets-raw/sprites/blocks/environment/ignarock3.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 75 B |
|
Before Width: | Height: | Size: 119 B |
BIN
core/assets-raw/sprites/blocks/environment/magmarock1.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
core/assets-raw/sprites/blocks/environment/magmarock2.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |