Compare commits
13 Commits
v147.1
...
async-ping
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63b92e6dd6 | ||
|
|
3be67aa52a | ||
|
|
a73b783d98 | ||
|
|
db4c861dde | ||
|
|
c7a35ae789 | ||
|
|
3e5ad07e8c | ||
|
|
584b22300d | ||
|
|
6eb049c419 | ||
|
|
6be497878c | ||
|
|
8e9b409b63 | ||
|
|
b496e8457c | ||
|
|
41b87b9345 | ||
|
|
84e52bdee3 |
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -72,5 +72,3 @@ body:
|
|||||||
required: true
|
required: true
|
||||||
- label: I have searched the closed and open issues to make sure that this problem has not already been reported.
|
- label: I have searched the closed and open issues to make sure that this problem has not already been reported.
|
||||||
required: true
|
required: true
|
||||||
- label: "I am not using Foo's Client, and have made sure the bug is not caused by mods I have installed."
|
|
||||||
required: true
|
|
||||||
|
|||||||
10
.github/workflows/gradle-wrapper-validation.yml
vendored
@@ -1,10 +0,0 @@
|
|||||||
name: "Validate Gradle Wrapper"
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
validation:
|
|
||||||
name: "Validation"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: gradle/wrapper-validation-action@v2
|
|
||||||
4
.github/workflows/pr.yml
vendored
@@ -18,11 +18,11 @@ jobs:
|
|||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/gradle-build-action@v2
|
uses: gradle/gradle-build-action@v2
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: ./gradlew tests:test --stacktrace --rerun
|
run: ./gradlew clean cleanTest test --stacktrace
|
||||||
- name: Run unit tests and build JAR
|
- name: Run unit tests and build JAR
|
||||||
run: ./gradlew desktop:dist
|
run: ./gradlew desktop:dist
|
||||||
- name: Upload desktop JAR for testing
|
- name: Upload desktop JAR for testing
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: Desktop JAR (zipped)
|
name: Desktop JAR (zipped)
|
||||||
path: desktop/build/libs/Mindustry.jar
|
path: desktop/build/libs/Mindustry.jar
|
||||||
|
|||||||
5
.github/workflows/push.yml
vendored
@@ -34,7 +34,6 @@ jobs:
|
|||||||
|
|
||||||
if [ -n "$(git status --porcelain)" ]; then
|
if [ -n "$(git status --porcelain)" ]; then
|
||||||
git config --global user.name "Github Actions"
|
git config --global user.name "Github Actions"
|
||||||
git config --global user.email "actions@github.com"
|
|
||||||
git add core/assets/bundles/*
|
git add core/assets/bundles/*
|
||||||
git commit -m "Automatic bundle update"
|
git commit -m "Automatic bundle update"
|
||||||
git push
|
git push
|
||||||
@@ -43,7 +42,7 @@ jobs:
|
|||||||
if: ${{ github.repository == 'Anuken/Mindustry' }}
|
if: ${{ github.repository == 'Anuken/Mindustry' }}
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name "Github Actions"
|
git config --global user.name "Github Actions"
|
||||||
git config --global user.email "actions@github.com"
|
git config --global user.email "cli@github.com"
|
||||||
cd ../
|
cd ../
|
||||||
cp -r ./Mindustry ./MindustryJitpack
|
cp -r ./Mindustry ./MindustryJitpack
|
||||||
cd MindustryJitpack
|
cd MindustryJitpack
|
||||||
@@ -58,4 +57,4 @@ jobs:
|
|||||||
git push https://Anuken:${{ secrets.API_TOKEN_GITHUB }}@github.com/Anuken/MindustryJitpack
|
git push https://Anuken:${{ secrets.API_TOKEN_GITHUB }}@github.com/Anuken/MindustryJitpack
|
||||||
cd ../Mindustry
|
cd ../Mindustry
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: ./gradlew tests:test --rerun --stacktrace
|
run: ./gradlew clean cleanTest test --stacktrace
|
||||||
|
|||||||
4
.gitignore
vendored
@@ -23,7 +23,6 @@ ios/libs/
|
|||||||
/tools/build/
|
/tools/build/
|
||||||
/tests/build/
|
/tests/build/
|
||||||
/server/build/
|
/server/build/
|
||||||
ios/libs/
|
|
||||||
changelog
|
changelog
|
||||||
saves/
|
saves/
|
||||||
/core/assets-raw/fontgen/out/
|
/core/assets-raw/fontgen/out/
|
||||||
@@ -168,6 +167,3 @@ android/libs/
|
|||||||
|
|
||||||
# ignored due to frequent branch conflicts.
|
# ignored due to frequent branch conflicts.
|
||||||
core/assets/logicids.dat
|
core/assets/logicids.dat
|
||||||
|
|
||||||
# project files for the sectors
|
|
||||||
core/assets-raw/sprites/ui/sectors/*.json
|
|
||||||
@@ -13,13 +13,11 @@ If you are submitting a new block, make sure it has a name and description, and
|
|||||||
|
|
||||||
### Do not make large changes before discussing them first.
|
### Do not make large changes before discussing them first.
|
||||||
If you are interested in adding a large mechanic/feature or changing large amounts of code, first contact me (Anuken) via [Discord](https://discord.gg/mindustry) - either via PM or by posting in the `#pulls` channel.
|
If you are interested in adding a large mechanic/feature or changing large amounts of code, first contact me (Anuken) via [Discord](https://discord.gg/mindustry) - either via PM or by posting in the `#pulls` channel.
|
||||||
For most changes, this should not be necessary. I just want to know if you're doing something big, so I can offer advice and/or make sure you're not wasting your time on it.
|
For most changes, this should not be necessary. I just want to know if you're doing something big so I can offer advice and/or make sure you're not wasting your time on it.
|
||||||
|
|
||||||
### Do not make formatting or "cleanup" PRs.
|
### Do not make formatting PRs.
|
||||||
Yes, there are occurrences of trailing spaces, extra newlines, empty indents, and other tiny errors. No, I don't want to merge, view, or get notified by your 1-line PR fixing it. If you're implementing a PR with modification of *actual code*, feel free to fix formatting in the general vicinity of your changes, but please don't waste everyone's time with pointless changes.
|
Yes, there are occurrences of trailing spaces, extra newlines, empty indents, and other tiny errors. No, I don't want to merge, view, or get notified by your 1-line PR fixing it. If you're implementing a PR with modification of *actual code*, feel free to fix formatting in the general vicinity of your changes, but please don't waste everyone's time with pointless changes.
|
||||||
|
|
||||||
I **especially** do not want to see PRs that apply any kind of automated analysis to the source code to "optimize" anything - my IDE can do that already. If the PR doesn't actually change anything useful, I'm not going to review or merge it.
|
|
||||||
|
|
||||||
## Style Guidelines
|
## Style Guidelines
|
||||||
|
|
||||||
### Follow the formatting guidelines.
|
### Follow the formatting guidelines.
|
||||||
@@ -36,7 +34,7 @@ This means:
|
|||||||
|
|
||||||
Import [this style file](.github/Mindustry-CodeStyle-IJ.xml) into IntelliJ to get correct formatting when developing Mindustry.
|
Import [this style file](.github/Mindustry-CodeStyle-IJ.xml) into IntelliJ to get correct formatting when developing Mindustry.
|
||||||
|
|
||||||
### Do not use incompatible Java features (java.util.function, java.awt, java.lang.Objects).
|
### Do not use incompatible Java features (java.util.function, java.awt).
|
||||||
Android and RoboVM (iOS) do not support many of Java 8's features, such as the packages `java.util.function`, `java.util.stream` or `forEach` in collections. Do not use these in your code.
|
Android and RoboVM (iOS) do not support many of Java 8's features, such as the packages `java.util.function`, `java.util.stream` or `forEach` in collections. Do not use these in your code.
|
||||||
If you need to use functional interfaces, use the ones in `arc.func`, which are more or less the same with different naming schemes.
|
If you need to use functional interfaces, use the ones in `arc.func`, which are more or less the same with different naming schemes.
|
||||||
|
|
||||||
@@ -68,7 +66,7 @@ Otherwise, use the `Tmp` variables for things like vector/shape operations, or c
|
|||||||
If using a list, make it a static variable and clear it every time it is used. Re-use as much as possible.
|
If using a list, make it a static variable and clear it every time it is used. Re-use as much as possible.
|
||||||
|
|
||||||
### Avoid bloated code and unnecessary getters/setters.
|
### Avoid bloated code and unnecessary getters/setters.
|
||||||
This is situational, but in essence, what it means is to avoid using any sort of getters and setters unless absolutely necessary. Public or protected fields should suffice for most things.
|
This is situational, but in essence what it means is to avoid using any sort of getters and setters unless absolutely necessary. Public or protected fields should suffice for most things.
|
||||||
If something needs to be encapsulated in the future, IntelliJ can handle it with a few clicks.
|
If something needs to be encapsulated in the future, IntelliJ can handle it with a few clicks.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
12
README.md
@@ -18,7 +18,7 @@ See [CONTRIBUTING](CONTRIBUTING.md).
|
|||||||
Bleeding-edge builds are generated automatically for every commit. You can see them [here](https://github.com/Anuken/MindustryBuilds/releases).
|
Bleeding-edge builds are generated automatically for every commit. You can see them [here](https://github.com/Anuken/MindustryBuilds/releases).
|
||||||
|
|
||||||
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 [JDK 17](https://adoptium.net/archive.html?variant=openjdk17&jvmVariant=hotspot) installed. **Other JDK versions will not work.** Open a terminal in the Mindustry directory and run the following commands:
|
First, make sure you have [JDK 16-17](https://adoptium.net/archive.html?variant=openjdk17&jvmVariant=hotspot) installed. **Other JDK versions will not work.** Open a terminal in the Mindustry directory and run the following commands:
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
@@ -53,16 +53,6 @@ To debug the application on a connected device/emulator, run `gradlew android:in
|
|||||||
|
|
||||||
If the terminal returns `Permission denied` or `Command not found` on Mac/Linux, run `chmod +x ./gradlew` before running `./gradlew`. *This is a one-time procedure.*
|
If the terminal returns `Permission denied` or `Command not found` on Mac/Linux, run `chmod +x ./gradlew` before running `./gradlew`. *This is a one-time procedure.*
|
||||||
|
|
||||||
#### Where is the `mindustry.gen` package?
|
|
||||||
|
|
||||||
As the name implies, `mindustry.gen` is generated *at build time* based on other code. You will not find source code for this package in the repository, and it should not be edited by hand.
|
|
||||||
|
|
||||||
The following is a non-exhaustive list of the "source" of generated code in `mindustry.gen`:
|
|
||||||
|
|
||||||
- `Call`, `*Packet` classes: Generated from methods marked with `@Remote`.
|
|
||||||
- All entity classes (`Unit`, `EffectState`, `Posc`, etc): Generated from component classes in the `mindustry.entities.comp` package, and combined using definitions in `mindustry.content.UnitTypes`.
|
|
||||||
- `Sounds`, `Musics`, `Tex`, `Icon`, etc: Generated based on files in the respective asset folders.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Gradle may take up to several minutes to download files. Be patient. <br>
|
Gradle may take up to several minutes to download files. Be patient. <br>
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
# Note: The v7 server list is frozen. No new servers will be accepted. All v8 server PRs should be made [here](https://github.com/Anuken/MindustryServerList/blob/main/servers_v8.json).
|
|
||||||
|
|
||||||
*PRs to edit addresses of existing servers will still be accepted, although very infrequently.*
|
|
||||||
|
|
||||||
### Adding a server to the list
|
### Adding a server to the list
|
||||||
|
|
||||||
Mindustry now has a public list of servers that everyone can see and connect to.
|
Mindustry now has a public list of servers that everyone can see and connect to.
|
||||||
@@ -22,16 +18,13 @@ You'll need to either hire some moderators, or make use of (currently non-existe
|
|||||||
4. **Get some good maps.** *(optional, but highly recommended)*. Add some maps to your server and set the map rotation to custom-only. You can get maps from the Steam workshop by subscribing and exporting them; using the `#maps` channel on Discord is also an option.
|
4. **Get some good maps.** *(optional, but highly recommended)*. Add some maps to your server and set the map rotation to custom-only. You can get maps from the Steam workshop by subscribing and exporting them; using the `#maps` channel on Discord is also an option.
|
||||||
5. **Check your server configuration.** *(optional)* I would recommend adding a message rate limit of 1 second (`config messageRateLimit 1`), and disabling connect/disconnect messages to reduce spam (`config showConnectMessages false`).
|
5. **Check your server configuration.** *(optional)* I would recommend adding a message rate limit of 1 second (`config messageRateLimit 1`), and disabling connect/disconnect messages to reduce spam (`config showConnectMessages false`).
|
||||||
6. Finally, **submit a pull request** to add your server's IP to the list.
|
6. Finally, **submit a pull request** to add your server's IP to the list.
|
||||||
This should be fairly straightforward: Press the edit button on the [server file](https://github.com/Anuken/Mindustry/blob/master/servers_v7.json), then add a JSON object with the following format:
|
This should be fairly straightforward: Press the edit button on the [server file](https://github.com/Anuken/Mindustry/blob/master/servers_v7.json), then add a JSON object with a single key, indicating your server address.
|
||||||
|
For example, if your server address is `example.com:6000`, you would add a comma after the last entry and insert:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"name": "Your Server Group Name",
|
"address": "example.com:6000"
|
||||||
"address": ["your.server.address"]
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
If your group has multiple servers, simply add extra addresses inside the square brackets, separated by commas. For example: `["address1", "address2"]`
|
|
||||||
|
|
||||||
> Note that Mindustry also support SRV records. This allows you to use a subdomain for your server address instead of specifying the port. For example, if you want to use `play.example.com` instead of `example.com:6000`, in the dns settings of your domain, add an SRV record with `_mindustry` as the service, `tcp` as the protocol, `play` as the target and `6000` as the port. You can also setup fallback servers by modifying the weight or priority of the record. Although SRV records are very convenient, keep in mind they are slower than regular addresses. Avoid using them in the server list, but rather as an easy way to share your server address.
|
> Note that Mindustry also support SRV records. This allows you to use a subdomain for your server address instead of specifying the port. For example, if you want to use `play.example.com` instead of `example.com:6000`, in the dns settings of your domain, add an SRV record with `_mindustry` as the service, `tcp` as the protocol, `play` as the target and `6000` as the port. You can also setup fallback servers by modifying the weight or priority of the record. Although SRV records are very convenient, keep in mind they are slower than regular addresses. Avoid using them in the server list, but rather as an easy way to share your server address.
|
||||||
|
|
||||||
Then, press the *'submit pull request'* button and I'll take a look at your server. If I have any issues with it, I'll let you know in the PR comments.
|
Then, press the *'submit pull request'* button and I'll take a look at your server. If I have any issues with it, I'll let you know in the PR comments.
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="io.anuke.mindustry">
|
||||||
|
|
||||||
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
|
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
|
||||||
<uses-feature android:name="android.hardware.type.pc" android:required="false" />
|
<uses-feature android:name="android.hardware.type.pc" android:required="false" />
|
||||||
@@ -17,8 +18,7 @@
|
|||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
android:appCategory="game"
|
android:appCategory="game"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules">
|
||||||
android:largeHeap="true">
|
|
||||||
<meta-data android:name="android.max_aspect" android:value="2.1"/>
|
<meta-data android:name="android.max_aspect" android:value="2.1"/>
|
||||||
<activity
|
<activity
|
||||||
android:name="mindustry.android.AndroidLauncher"
|
android:name="mindustry.android.AndroidLauncher"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ buildscript{
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies{
|
dependencies{
|
||||||
classpath 'com.android.tools.build:gradle:8.2.2'
|
classpath 'com.android.tools.build:gradle:7.2.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,9 +29,8 @@ task deploy(type: Copy){
|
|||||||
}
|
}
|
||||||
|
|
||||||
android{
|
android{
|
||||||
namespace = "io.anuke.mindustry"
|
buildToolsVersion '33.0.2'
|
||||||
buildToolsVersion = '34.0.0'
|
compileSdkVersion 33
|
||||||
compileSdk = 34
|
|
||||||
sourceSets{
|
sourceSets{
|
||||||
main{
|
main{
|
||||||
manifest.srcFile 'AndroidManifest.xml'
|
manifest.srcFile 'AndroidManifest.xml'
|
||||||
@@ -57,7 +56,7 @@ android{
|
|||||||
|
|
||||||
applicationId "io.anuke.mindustry"
|
applicationId "io.anuke.mindustry"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 34
|
targetSdkVersion 33
|
||||||
|
|
||||||
versionName versionNameResult
|
versionName versionNameResult
|
||||||
versionCode = vcode
|
versionCode = vcode
|
||||||
@@ -66,8 +65,6 @@ android{
|
|||||||
props['androidBuildCode'] = (vcode + 1).toString()
|
props['androidBuildCode'] = (vcode + 1).toString()
|
||||||
}
|
}
|
||||||
props.store(file('../core/assets/version.properties').newWriter(), null)
|
props.store(file('../core/assets/version.properties').newWriter(), null)
|
||||||
|
|
||||||
multiDexEnabled true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions{
|
compileOptions{
|
||||||
@@ -75,7 +72,7 @@ android{
|
|||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
flavorDimensions = ["google"]
|
flavorDimensions "google"
|
||||||
|
|
||||||
signingConfigs{
|
signingConfigs{
|
||||||
release{
|
release{
|
||||||
|
|||||||
5
android/proguard-rules.pro
vendored
@@ -1,12 +1,11 @@
|
|||||||
-dontobfuscate
|
-dontobfuscate
|
||||||
|
|
||||||
|
#these are essential packages that should not be "optimized" in any way
|
||||||
|
#the main purpose of d8 here is to shrink the absurdly-large google play games libraries
|
||||||
-keep class mindustry.** { *; }
|
-keep class mindustry.** { *; }
|
||||||
-keep class arc.** { *; }
|
-keep class arc.** { *; }
|
||||||
-keep class net.jpountz.** { *; }
|
-keep class net.jpountz.** { *; }
|
||||||
-keep class rhino.** { *; }
|
-keep class rhino.** { *; }
|
||||||
-keep class com.android.dex.** { *; }
|
-keep class com.android.dex.** { *; }
|
||||||
-keepattributes Signature,*Annotation*,InnerClasses,EnclosingMethod
|
|
||||||
|
|
||||||
-dontwarn javax.naming.**
|
|
||||||
|
|
||||||
#-printusage out.txt
|
#-printusage out.txt
|
||||||
@@ -38,7 +38,7 @@ public class AndroidLauncher extends AndroidApplication{
|
|||||||
UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
|
UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
|
||||||
|
|
||||||
Thread.setDefaultUncaughtExceptionHandler((thread, error) -> {
|
Thread.setDefaultUncaughtExceptionHandler((thread, error) -> {
|
||||||
CrashHandler.log(error);
|
CrashSender.log(error);
|
||||||
|
|
||||||
//try to forward exception to system handler
|
//try to forward exception to system handler
|
||||||
if(handler != null){
|
if(handler != null){
|
||||||
@@ -72,8 +72,6 @@ public class AndroidLauncher extends AndroidApplication{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassLoader loadJar(Fi jar, ClassLoader parent) throws Exception{
|
public ClassLoader loadJar(Fi jar, ClassLoader parent) throws Exception{
|
||||||
//Required to load jar files in Android 14: https://developer.android.com/about/versions/14/behavior-changes-14#safer-dynamic-code-loading
|
|
||||||
jar.file().setReadOnly();
|
|
||||||
return new DexClassLoader(jar.file().getPath(), getFilesDir().getPath(), null, parent){
|
return new DexClassLoader(jar.file().getPath(), getFilesDir().getPath(), null, parent){
|
||||||
@Override
|
@Override
|
||||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException{
|
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException{
|
||||||
@@ -103,69 +101,64 @@ public class AndroidLauncher extends AndroidApplication{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showFileChooser(boolean open, String title, Cons<Fi> cons, String... extensions){
|
void showFileChooser(boolean open, String title, Cons<Fi> cons, String... extensions){
|
||||||
try{
|
String extension = extensions[0];
|
||||||
String extension = extensions[0];
|
|
||||||
|
|
||||||
if(VERSION.SDK_INT >= VERSION_CODES.Q){
|
if(VERSION.SDK_INT >= VERSION_CODES.Q){
|
||||||
Intent intent = new Intent(open ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_CREATE_DOCUMENT);
|
Intent intent = new Intent(open ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_CREATE_DOCUMENT);
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
intent.setType(extension.equals("zip") && !open && extensions.length == 1 ? "application/zip" : "*/*");
|
intent.setType(extension.equals("zip") && !open && extensions.length == 1 ? "application/zip" : "*/*");
|
||||||
intent.putExtra(Intent.EXTRA_TITLE, "export." + extension);
|
|
||||||
|
|
||||||
addResultListener(i -> startActivityForResult(intent, i), (code, in) -> {
|
addResultListener(i -> startActivityForResult(intent, i), (code, in) -> {
|
||||||
if(code == Activity.RESULT_OK && in != null && in.getData() != null){
|
if(code == Activity.RESULT_OK && in != null && in.getData() != null){
|
||||||
Uri uri = in.getData();
|
Uri uri = in.getData();
|
||||||
|
|
||||||
if(uri.getPath().contains("(invalid)")) return;
|
if(uri.getPath().contains("(invalid)")) return;
|
||||||
|
|
||||||
Core.app.post(() -> Core.app.post(() -> cons.get(new Fi(uri.getPath()){
|
Core.app.post(() -> Core.app.post(() -> cons.get(new Fi(uri.getPath()){
|
||||||
@Override
|
@Override
|
||||||
public InputStream read(){
|
public InputStream read(){
|
||||||
try{
|
try{
|
||||||
return getContentResolver().openInputStream(uri);
|
return getContentResolver().openInputStream(uri);
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
throw new ArcRuntimeException(e);
|
throw new ArcRuntimeException(e);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OutputStream write(boolean append){
|
public OutputStream write(boolean append){
|
||||||
try{
|
try{
|
||||||
return getContentResolver().openOutputStream(uri);
|
return getContentResolver().openOutputStream(uri);
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
throw new ArcRuntimeException(e);
|
throw new ArcRuntimeException(e);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})));
|
}
|
||||||
}
|
})));
|
||||||
});
|
}
|
||||||
}else if(VERSION.SDK_INT >= VERSION_CODES.M && !(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
|
});
|
||||||
|
}else if(VERSION.SDK_INT >= VERSION_CODES.M && !(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
|
||||||
checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){
|
checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){
|
||||||
chooser = new FileChooser(title, file -> Structs.contains(extensions, file.extension().toLowerCase()), open, file -> {
|
chooser = new FileChooser(title, file -> Structs.contains(extensions, file.extension().toLowerCase()), open, file -> {
|
||||||
if(!open){
|
if(!open){
|
||||||
cons.get(file.parent().child(file.nameWithoutExtension() + "." + extension));
|
cons.get(file.parent().child(file.nameWithoutExtension() + "." + extension));
|
||||||
}else{
|
|
||||||
cons.get(file);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ArrayList<String> perms = new ArrayList<>();
|
|
||||||
if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
|
|
||||||
perms.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
|
||||||
}
|
|
||||||
if(checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
|
|
||||||
perms.add(Manifest.permission.READ_EXTERNAL_STORAGE);
|
|
||||||
}
|
|
||||||
requestPermissions(perms.toArray(new String[0]), PERMISSION_REQUEST_CODE);
|
|
||||||
}else{
|
|
||||||
if(open){
|
|
||||||
new FileChooser(title, file -> Structs.contains(extensions, file.extension().toLowerCase()), true, cons).show();
|
|
||||||
}else{
|
}else{
|
||||||
super.showFileChooser(open, "@open", extension, cons);
|
cons.get(file);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ArrayList<String> perms = new ArrayList<>();
|
||||||
|
if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
|
||||||
|
perms.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
|
}
|
||||||
|
if(checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
|
||||||
|
perms.add(Manifest.permission.READ_EXTERNAL_STORAGE);
|
||||||
|
}
|
||||||
|
requestPermissions(perms.toArray(new String[0]), PERMISSION_REQUEST_CODE);
|
||||||
|
}else{
|
||||||
|
if(open){
|
||||||
|
new FileChooser(title, file -> Structs.contains(extensions, file.extension().toLowerCase()), true, cons).show();
|
||||||
|
}else{
|
||||||
|
super.showFileChooser(open, "@open", extension, cons);
|
||||||
}
|
}
|
||||||
}catch(Throwable error){
|
|
||||||
Core.app.post(() -> Vars.ui.showException(error));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +180,6 @@ public class AndroidLauncher extends AndroidApplication{
|
|||||||
}, new AndroidApplicationConfiguration(){{
|
}, new AndroidApplicationConfiguration(){{
|
||||||
useImmersiveMode = true;
|
useImmersiveMode = true;
|
||||||
hideStatusBar = true;
|
hideStatusBar = true;
|
||||||
useGL30 = true;
|
|
||||||
}});
|
}});
|
||||||
checkFiles(getIntent());
|
checkFiles(getIntent());
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ public class Annotations{
|
|||||||
/** Whether to generate a base class for this components.
|
/** Whether to generate a base class for this components.
|
||||||
* An entity cannot have two base classes, so only one component can have base be true. */
|
* An entity cannot have two base classes, so only one component can have base be true. */
|
||||||
boolean base() default false;
|
boolean base() default false;
|
||||||
/** Whether to generate a proper interface for this component class. */
|
|
||||||
boolean genInterface() default true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Indicates that a method is implemented by the annotation processor. */
|
/** Indicates that a method is implemented by the annotation processor. */
|
||||||
@@ -184,16 +182,18 @@ public class Annotations{
|
|||||||
|
|
||||||
/** A set of two booleans, one specifying server and one specifying client. */
|
/** A set of two booleans, one specifying server and one specifying client. */
|
||||||
public enum Loc{
|
public enum Loc{
|
||||||
/** Server only. */
|
/** Method can only be invoked on the client from the server. */
|
||||||
server(true, false),
|
server(true, false),
|
||||||
/** Client only. */
|
/** Method can only be invoked on the server from the client. */
|
||||||
client(false, true),
|
client(false, true),
|
||||||
/** Both server and client. */
|
/** Method can be invoked from anywhere */
|
||||||
both(true, true),
|
both(true, true),
|
||||||
/** Neither server nor client. */
|
/** Neither server nor client. */
|
||||||
none(false, false);
|
none(false, false);
|
||||||
|
|
||||||
|
/** If true, this method can be invoked ON clients FROM servers. */
|
||||||
public final boolean isServer;
|
public final boolean isServer;
|
||||||
|
/** If true, this method can be invoked ON servers FROM clients. */
|
||||||
public final boolean isClient;
|
public final boolean isClient;
|
||||||
|
|
||||||
Loc(boolean server, boolean client){
|
Loc(boolean server, boolean client){
|
||||||
@@ -222,16 +222,16 @@ public class Annotations{
|
|||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface Remote{
|
public @interface Remote{
|
||||||
/** Specifies the locations from which this method can cause remote invocations (This -> Remote) [Default: Server -> Client]. */
|
/** Specifies the locations from which this method can be invoked. */
|
||||||
Loc targets() default Loc.server;
|
Loc targets() default Loc.server;
|
||||||
|
|
||||||
/** Specifies which methods are generated. Only affects server-to-client methods (Server -> Client(s)) [Default: Server -> Client & Server -> All Clients]. */
|
/** Specifies which methods are generated. Only affects server-to-client methods. */
|
||||||
Variant variants() default Variant.all;
|
Variant variants() default Variant.all;
|
||||||
|
|
||||||
/** The locations where this method is called locally, when invoked locally (This -> This) [Default: No local invocations]. */
|
/** The local locations where this method is called locally, when invoked. */
|
||||||
Loc called() default Loc.none;
|
Loc called() default Loc.none;
|
||||||
|
|
||||||
/** Whether the server should forward this packet to all other clients upon receival from a client (Client -> Server -> Other Clients). [Default: Don't Forward Client Invocations] */
|
/** Whether to forward this packet to all other clients upon receival. Client only. */
|
||||||
boolean forward() default false;
|
boolean forward() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import javax.annotation.processing.*;
|
|||||||
import javax.lang.model.element.*;
|
import javax.lang.model.element.*;
|
||||||
import javax.lang.model.type.*;
|
import javax.lang.model.type.*;
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@SupportedAnnotationTypes({
|
@SupportedAnnotationTypes({
|
||||||
"mindustry.annotations.Annotations.EntityDef",
|
"mindustry.annotations.Annotations.EntityDef",
|
||||||
@@ -98,8 +97,6 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
|
|
||||||
//create component interfaces
|
//create component interfaces
|
||||||
for(Stype component : allComponents){
|
for(Stype component : allComponents){
|
||||||
|
|
||||||
|
|
||||||
TypeSpec.Builder inter = TypeSpec.interfaceBuilder(interfaceName(component))
|
TypeSpec.Builder inter = TypeSpec.interfaceBuilder(interfaceName(component))
|
||||||
.addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
|
.addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
|
||||||
|
|
||||||
@@ -119,47 +116,45 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
inter.addSuperinterface(ClassName.get(packageName, interfaceName(type)));
|
inter.addSuperinterface(ClassName.get(packageName, interfaceName(type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(component.annotation(Component.class).genInterface()){
|
ObjectSet<String> signatures = new ObjectSet<>();
|
||||||
ObjectSet<String> signatures = new ObjectSet<>();
|
|
||||||
|
|
||||||
//add utility methods to interface
|
//add utility methods to interface
|
||||||
for(Smethod method : component.methods()){
|
for(Smethod method : component.methods()){
|
||||||
//skip private methods, those are for internal use.
|
//skip private methods, those are for internal use.
|
||||||
if(method.isAny(Modifier.PRIVATE, Modifier.STATIC)) continue;
|
if(method.isAny(Modifier.PRIVATE, Modifier.STATIC)) continue;
|
||||||
|
|
||||||
//keep track of signatures used to prevent dupes
|
//keep track of signatures used to prevent dupes
|
||||||
signatures.add(method.e.toString());
|
signatures.add(method.e.toString());
|
||||||
|
|
||||||
inter.addMethod(MethodSpec.methodBuilder(method.name())
|
inter.addMethod(MethodSpec.methodBuilder(method.name())
|
||||||
.addJavadoc(method.doc() == null ? "" : method.doc())
|
.addJavadoc(method.doc() == null ? "" : method.doc())
|
||||||
.addExceptions(method.thrownt())
|
.addExceptions(method.thrownt())
|
||||||
.addTypeVariables(method.typeVariables().map(TypeVariableName::get))
|
.addTypeVariables(method.typeVariables().map(TypeVariableName::get))
|
||||||
.returns(method.ret().toString().equals("void") ? TypeName.VOID : method.retn())
|
.returns(method.ret().toString().equals("void") ? TypeName.VOID : method.retn())
|
||||||
.addParameters(method.params().map(v -> ParameterSpec.builder(v.tname(), v.name())
|
.addParameters(method.params().map(v -> ParameterSpec.builder(v.tname(), v.name())
|
||||||
.build())).addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT).build());
|
.build())).addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
//generate interface getters and setters for all "standard" fields
|
||||||
|
for(Svar field : component.fields().select(e -> !e.is(Modifier.STATIC) && !e.is(Modifier.PRIVATE) && !e.has(Import.class))){
|
||||||
|
String cname = field.name();
|
||||||
|
|
||||||
|
//getter
|
||||||
|
if(!signatures.contains(cname + "()")){
|
||||||
|
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
|
||||||
|
.addAnnotations(Seq.with(field.annotations()).select(a -> a.toString().contains("Null") || a.toString().contains("Deprecated")).map(AnnotationSpec::get))
|
||||||
|
.addJavadoc(field.doc() == null ? "" : field.doc())
|
||||||
|
.returns(field.tname()).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
//generate interface getters and setters for all "standard" fields
|
//setter
|
||||||
for(Svar field : component.fields().select(e -> !e.is(Modifier.STATIC) && !e.is(Modifier.PRIVATE) && !e.has(Import.class))){
|
if(!field.is(Modifier.FINAL) && !signatures.contains(cname + "(" + field.mirror().toString() + ")") &&
|
||||||
String cname = field.name();
|
!field.annotations().contains(f -> f.toString().equals("@mindustry.annotations.Annotations.ReadOnly"))){
|
||||||
|
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
|
||||||
//getter
|
.addJavadoc(field.doc() == null ? "" : field.doc())
|
||||||
if(!signatures.contains(cname + "()")){
|
.addParameter(ParameterSpec.builder(field.tname(), field.name())
|
||||||
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
|
.addAnnotations(Seq.with(field.annotations())
|
||||||
.addAnnotations(Seq.with(field.annotations()).select(a -> a.toString().contains("Null") || a.toString().contains("Deprecated")).map(AnnotationSpec::get))
|
.select(a -> a.toString().contains("Null") || a.toString().contains("Deprecated")).map(AnnotationSpec::get)).build()).build());
|
||||||
.addJavadoc(field.doc() == null ? "" : field.doc())
|
|
||||||
.returns(field.tname()).build());
|
|
||||||
}
|
|
||||||
|
|
||||||
//setter
|
|
||||||
if(!field.is(Modifier.FINAL) && !signatures.contains(cname + "(" + field.mirror().toString() + ")") &&
|
|
||||||
!field.annotations().contains(f -> f.toString().equals("@mindustry.annotations.Annotations.ReadOnly"))){
|
|
||||||
inter.addMethod(MethodSpec.methodBuilder(cname).addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
|
|
||||||
.addJavadoc(field.doc() == null ? "" : field.doc())
|
|
||||||
.addParameter(ParameterSpec.builder(field.tname(), field.name())
|
|
||||||
.addAnnotations(Seq.with(field.annotations())
|
|
||||||
.select(a -> a.toString().contains("Null") || a.toString().contains("Deprecated")).map(AnnotationSpec::get)).build()).build());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,34 +416,19 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
|
|
||||||
//add all methods from components
|
//add all methods from components
|
||||||
for(ObjectMap.Entry<String, Seq<Smethod>> entry : methods){
|
for(ObjectMap.Entry<String, Seq<Smethod>> entry : methods){
|
||||||
|
if(entry.value.contains(m -> m.has(Replace.class))){
|
||||||
//there are multiple @Replace implementations, or multiple non-void implementations.
|
//check replacements
|
||||||
if(entry.value.size > 1 && (entry.value.contains(m -> m.has(Replace.class)) || entry.value.count(m -> !m.isAny(Modifier.NATIVE, Modifier.ABSTRACT) && !m.isVoid()) > 1)){
|
if(entry.value.count(m -> m.has(Replace.class)) > 1){
|
||||||
|
err("Type " + type + " has multiple components replacing method " + entry.key + ".");
|
||||||
//remove clutter
|
|
||||||
entry.value.removeAll(s -> s.is(Modifier.ABSTRACT));
|
|
||||||
|
|
||||||
Comparator<Smethod> comp = Structs.comps(
|
|
||||||
Structs.comps(
|
|
||||||
//highest priority first
|
|
||||||
Structs.comparingFloat(m -> m.has(MethodPriority.class) ? m.annotation(MethodPriority.class).value() : 0f),
|
|
||||||
//replacement means priority
|
|
||||||
Structs.comparingBool(m -> m.has(Replace.class))
|
|
||||||
),
|
|
||||||
|
|
||||||
//otherwise, the 'highest' subclass (most dependencies)
|
|
||||||
Structs.comparingInt(m -> getDependencies(m.type()).size)
|
|
||||||
);
|
|
||||||
|
|
||||||
Smethod best = entry.value.max(comp);
|
|
||||||
|
|
||||||
if(entry.value.contains(s -> best != s && comp.compare(s, best) == 0)){
|
|
||||||
err("Type " + type + " has multiple components implementing method " + entry.value.first() + " in an ambiguous way. Use MethodPriority to designate which one should be used. Implementations: " +
|
|
||||||
entry.value.map(s -> s.descString()));
|
|
||||||
}
|
}
|
||||||
|
Smethod base = entry.value.find(m -> m.has(Replace.class));
|
||||||
entry.value.clear();
|
entry.value.clear();
|
||||||
entry.value.add(best);
|
entry.value.add(base);
|
||||||
|
}
|
||||||
|
|
||||||
|
//check multi return
|
||||||
|
if(entry.value.count(m -> !m.isAny(Modifier.NATIVE, Modifier.ABSTRACT) && !m.isVoid()) > 1){
|
||||||
|
err("Type " + type + " has multiple components implementing non-void method " + entry.key + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.value.sort(Structs.comps(Structs.comparingFloat(m -> m.has(MethodPriority.class) ? m.annotation(MethodPriority.class).value() : 0), Structs.comparing(s -> s.up().getSimpleName().toString())));
|
entry.value.sort(Structs.comps(Structs.comparingFloat(m -> m.has(MethodPriority.class) ? m.annotation(MethodPriority.class).value() : 0), Structs.comparing(s -> s.up().getSimpleName().toString())));
|
||||||
@@ -465,7 +445,6 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
MethodSpec.Builder mbuilder = MethodSpec.methodBuilder(first.name()).addModifiers(first.is(Modifier.PRIVATE) ? Modifier.PRIVATE : Modifier.PUBLIC);
|
MethodSpec.Builder mbuilder = MethodSpec.methodBuilder(first.name()).addModifiers(first.is(Modifier.PRIVATE) ? Modifier.PRIVATE : Modifier.PUBLIC);
|
||||||
//if(isFinal || entry.value.contains(s -> s.has(Final.class))) mbuilder.addModifiers(Modifier.FINAL);
|
//if(isFinal || entry.value.contains(s -> s.has(Final.class))) mbuilder.addModifiers(Modifier.FINAL);
|
||||||
if(entry.value.contains(s -> s.has(CallSuper.class))) mbuilder.addAnnotation(CallSuper.class); //add callSuper here if necessary
|
if(entry.value.contains(s -> s.has(CallSuper.class))) mbuilder.addAnnotation(CallSuper.class); //add callSuper here if necessary
|
||||||
if(first.has(Nullable.class)) mbuilder.addAnnotation(Nullable.class);
|
|
||||||
if(first.is(Modifier.STATIC)) mbuilder.addModifiers(Modifier.STATIC);
|
if(first.is(Modifier.STATIC)) mbuilder.addModifiers(Modifier.STATIC);
|
||||||
mbuilder.addTypeVariables(first.typeVariables().map(TypeVariableName::get));
|
mbuilder.addTypeVariables(first.typeVariables().map(TypeVariableName::get));
|
||||||
mbuilder.returns(first.retn());
|
mbuilder.returns(first.retn());
|
||||||
@@ -872,6 +851,89 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
for(TypeSpec.Builder b : baseClasses){
|
for(TypeSpec.Builder b : baseClasses){
|
||||||
write(b, imports.toSeq());
|
write(b, imports.toSeq());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO nulls were an awful idea
|
||||||
|
//store nulls
|
||||||
|
TypeSpec.Builder nullsBuilder = TypeSpec.classBuilder("Nulls").addModifiers(Modifier.PUBLIC).addModifiers(Modifier.FINAL);
|
||||||
|
//TODO should be dynamic
|
||||||
|
ObjectSet<String> nullList = ObjectSet.with("unit");
|
||||||
|
|
||||||
|
//create mock types of all components
|
||||||
|
for(Stype interf : allInterfaces){
|
||||||
|
//indirect interfaces to implement methods for
|
||||||
|
Seq<Stype> dependencies = interf.allInterfaces().add(interf);
|
||||||
|
Seq<Smethod> methods = dependencies.flatMap(Stype::methods);
|
||||||
|
methods.sortComparing(Object::toString);
|
||||||
|
|
||||||
|
//optionally add superclass
|
||||||
|
Stype superclass = dependencies.map(this::interfaceToComp).find(s -> s != null && s.annotation(Component.class).base());
|
||||||
|
//use the base type when the interface being emulated has a base
|
||||||
|
TypeName type = superclass != null && interfaceToComp(interf).annotation(Component.class).base() ? tname(baseName(superclass)) : interf.tname();
|
||||||
|
|
||||||
|
//used method signatures
|
||||||
|
ObjectSet<String> signatures = new ObjectSet<>();
|
||||||
|
|
||||||
|
//create null builder
|
||||||
|
String baseName = interf.name().substring(0, interf.name().length() - 1);
|
||||||
|
|
||||||
|
//prevent Nulls bloat
|
||||||
|
if(!nullList.contains(Strings.camelize(baseName))){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String className = "Null" + baseName;
|
||||||
|
TypeSpec.Builder nullBuilder = TypeSpec.classBuilder(className)
|
||||||
|
.addModifiers(Modifier.FINAL);
|
||||||
|
|
||||||
|
skipDeprecated(nullBuilder);
|
||||||
|
|
||||||
|
nullBuilder.addSuperinterface(interf.tname());
|
||||||
|
if(superclass != null) nullBuilder.superclass(tname(baseName(superclass)));
|
||||||
|
|
||||||
|
for(Smethod method : methods){
|
||||||
|
String signature = method.toString();
|
||||||
|
if(!signatures.add(signature)) continue;
|
||||||
|
|
||||||
|
Stype compType = interfaceToComp(method.type());
|
||||||
|
MethodSpec.Builder builder = MethodSpec.overriding(method.e).addModifiers(Modifier.PUBLIC, Modifier.FINAL);
|
||||||
|
int index = 0;
|
||||||
|
for(ParameterSpec spec : builder.parameters){
|
||||||
|
Reflect.set(spec, "name", "arg" + index++);
|
||||||
|
}
|
||||||
|
builder.addAnnotation(OverrideCallSuper.class); //just in case
|
||||||
|
|
||||||
|
if(!method.isVoid()){
|
||||||
|
String methodName = method.name();
|
||||||
|
switch(methodName){
|
||||||
|
case "isNull":
|
||||||
|
builder.addStatement("return true");
|
||||||
|
break;
|
||||||
|
case "id":
|
||||||
|
builder.addStatement("return -1");
|
||||||
|
break;
|
||||||
|
case "toString":
|
||||||
|
builder.addStatement("return $S", className);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Svar variable = compType == null || method.params().size > 0 ? null : compType.fields().find(v -> v.name().equals(methodName));
|
||||||
|
String desc = variable == null ? null : variable.descString();
|
||||||
|
if(variable == null || !varInitializers.containsKey(desc)){
|
||||||
|
builder.addStatement("return " + getDefault(method.ret().toString()));
|
||||||
|
}else{
|
||||||
|
String init = varInitializers.get(desc);
|
||||||
|
builder.addStatement("return " + (init.equals("{}") ? "new " + variable.mirror().toString() : "") + init);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nullBuilder.addMethod(builder.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
nullsBuilder.addField(FieldSpec.builder(type, Strings.camelize(baseName)).initializer("new " + className + "()").addModifiers(Modifier.FINAL, Modifier.STATIC, Modifier.PUBLIC).build());
|
||||||
|
|
||||||
|
write(nullBuilder, imports.toSeq());
|
||||||
|
}
|
||||||
|
|
||||||
|
write(nullsBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,9 +57,6 @@ public class AssetsProcess extends BaseProcessor{
|
|||||||
ichtype.addField(FieldSpec.builder(ParameterizedTypeName.get(ObjectIntMap.class, String.class),
|
ichtype.addField(FieldSpec.builder(ParameterizedTypeName.get(ObjectIntMap.class, String.class),
|
||||||
"codes", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).initializer("new ObjectIntMap<>()").build());
|
"codes", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).initializer("new ObjectIntMap<>()").build());
|
||||||
|
|
||||||
ichtype.addField(FieldSpec.builder(ParameterizedTypeName.get(IntMap.class, String.class),
|
|
||||||
"codeToName", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).initializer("new IntMap<>()").build());
|
|
||||||
|
|
||||||
ObjectSet<String> used = new ObjectSet<>();
|
ObjectSet<String> used = new ObjectSet<>();
|
||||||
|
|
||||||
for(Jval val : icons.get("glyphs").asArray()){
|
for(Jval val : icons.get("glyphs").asArray()){
|
||||||
@@ -70,9 +67,7 @@ public class AssetsProcess extends BaseProcessor{
|
|||||||
int code = val.getInt("code", 0);
|
int code = val.getInt("code", 0);
|
||||||
iconcAll.append((char)code);
|
iconcAll.append((char)code);
|
||||||
ichtype.addField(FieldSpec.builder(char.class, name, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).addJavadoc(String.format("\\u%04x", code)).initializer("'" + ((char)code) + "'").build());
|
ichtype.addField(FieldSpec.builder(char.class, name, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).addJavadoc(String.format("\\u%04x", code)).initializer("'" + ((char)code) + "'").build());
|
||||||
|
|
||||||
ichinit.addStatement("codes.put($S, $L)", name, code);
|
ichinit.addStatement("codes.put($S, $L)", name, code);
|
||||||
ichinit.addStatement("codeToName.put($L, $S)", code, name);
|
|
||||||
|
|
||||||
ictype.addField(TextureRegionDrawable.class, name + "Small", Modifier.PUBLIC, Modifier.STATIC);
|
ictype.addField(TextureRegionDrawable.class, name + "Small", Modifier.PUBLIC, Modifier.STATIC);
|
||||||
icload.addStatement(name + "Small = mindustry.ui.Fonts.getGlyph(mindustry.ui.Fonts.def, (char)" + code + ")");
|
icload.addStatement(name + "Small = mindustry.ui.Fonts.getGlyph(mindustry.ui.Fonts.def, (char)" + code + ")");
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class StructProcess extends BaseProcessor{
|
|||||||
|
|
||||||
//bools: single bit, needs special case to clear things
|
//bools: single bit, needs special case to clear things
|
||||||
setter.beginControlFlow("if(value)");
|
setter.beginControlFlow("if(value)");
|
||||||
setter.addStatement("return ($T)($L | (1L << $LL))", structType, structParam, offset);
|
setter.addStatement("return ($T)(($L & ~(1L << $LL)) | (1L << $LL))", structType, structParam, offset, offset);
|
||||||
setter.nextControlFlow("else");
|
setter.nextControlFlow("else");
|
||||||
setter.addStatement("return ($T)(($L & ~(1L << $LL)))", structType, structParam, offset);
|
setter.addStatement("return ($T)(($L & ~(1L << $LL)))", structType, structParam, offset);
|
||||||
setter.endControlFlow();
|
setter.endControlFlow();
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ public class Stype extends Selement<TypeElement>{
|
|||||||
return interfaces().flatMap(s -> s.allInterfaces().add(s)).distinct();
|
return interfaces().flatMap(s -> s.allInterfaces().add(s)).distinct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInterface(){
|
|
||||||
return e.getKind() == ElementKind.INTERFACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Seq<Stype> superclasses(){
|
public Seq<Stype> superclasses(){
|
||||||
return Seq.with(BaseProcessor.typeu.directSupertypes(mirror())).map(Stype::of);
|
return Seq.with(BaseProcessor.typeu.directSupertypes(mirror())).map(Stype::of);
|
||||||
}
|
}
|
||||||
|
|||||||
30
build.gradle
@@ -26,8 +26,8 @@ buildscript{
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins{
|
plugins{
|
||||||
id "org.jetbrains.kotlin.jvm" version "2.1.10"
|
id "org.jetbrains.kotlin.jvm" version "1.6.0"
|
||||||
id "org.jetbrains.kotlin.kapt" version "2.1.10"
|
id "org.jetbrains.kotlin.kapt" version "1.6.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects{
|
allprojects{
|
||||||
@@ -37,8 +37,8 @@ allprojects{
|
|||||||
group = 'com.github.Anuken'
|
group = 'com.github.Anuken'
|
||||||
|
|
||||||
ext{
|
ext{
|
||||||
versionNumber = '8'
|
versionNumber = '7'
|
||||||
if(!project.hasProperty("versionModifier")) versionModifier = 'beta'
|
if(!project.hasProperty("versionModifier")) versionModifier = 'release'
|
||||||
if(!project.hasProperty("versionType")) versionType = 'official'
|
if(!project.hasProperty("versionType")) versionType = 'official'
|
||||||
appName = 'Mindustry'
|
appName = 'Mindustry'
|
||||||
steamworksVersion = '0b86023401880bb5e586bc404bedbaae9b1f1c94'
|
steamworksVersion = '0b86023401880bb5e586bc404bedbaae9b1f1c94'
|
||||||
@@ -89,10 +89,6 @@ allprojects{
|
|||||||
return project.getProperties()["buildversion"]
|
return project.getProperties()["buildversion"]
|
||||||
}
|
}
|
||||||
|
|
||||||
getCommitHash = {
|
|
||||||
return 'git rev-parse --verify --short HEAD'.execute().text.trim()
|
|
||||||
}
|
|
||||||
|
|
||||||
getPackage = {
|
getPackage = {
|
||||||
return project.ext.mainClassName.substring(0, project.ext.mainClassName.indexOf("desktop") - 1)
|
return project.ext.mainClassName.substring(0, project.ext.mainClassName.indexOf("desktop") - 1)
|
||||||
}
|
}
|
||||||
@@ -137,10 +133,6 @@ allprojects{
|
|||||||
props["number"] = versionNumber
|
props["number"] = versionNumber
|
||||||
props["modifier"] = versionModifier
|
props["modifier"] = versionModifier
|
||||||
props["build"] = buildid
|
props["build"] = buildid
|
||||||
props["commitHash"] = "unknown"
|
|
||||||
if(project.hasProperty("showCommitHash")){
|
|
||||||
props["commitHash"] = getCommitHash()
|
|
||||||
}
|
|
||||||
|
|
||||||
props.store(pfile.newWriter(), "Autogenerated file. Do not modify.")
|
props.store(pfile.newWriter(), "Autogenerated file. Do not modify.")
|
||||||
}
|
}
|
||||||
@@ -228,7 +220,7 @@ configure(subprojects - project(":annotations")){
|
|||||||
tasks.withType(Javadoc){
|
tasks.withType(Javadoc){
|
||||||
options{
|
options{
|
||||||
addStringOption('Xdoclint:none', '-quiet')
|
addStringOption('Xdoclint:none', '-quiet')
|
||||||
addStringOption('-release', '17')
|
addStringOption('-release', '16')
|
||||||
encoding('UTF-8')
|
encoding('UTF-8')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,7 +234,6 @@ project(":desktop"){
|
|||||||
dependencies{
|
dependencies{
|
||||||
implementation project(":core")
|
implementation project(":core")
|
||||||
implementation arcModule("extensions:discord")
|
implementation arcModule("extensions:discord")
|
||||||
implementation arcModule("natives:natives-filedialogs")
|
|
||||||
implementation arcModule("natives:natives-desktop")
|
implementation arcModule("natives:natives-desktop")
|
||||||
implementation arcModule("natives:natives-freetype-desktop")
|
implementation arcModule("natives:natives-freetype-desktop")
|
||||||
|
|
||||||
@@ -251,7 +242,6 @@ project(":desktop"){
|
|||||||
implementation "com.github.Anuken:steamworks4j:$steamworksVersion"
|
implementation "com.github.Anuken:steamworks4j:$steamworksVersion"
|
||||||
|
|
||||||
implementation arcModule("backends:backend-sdl")
|
implementation arcModule("backends:backend-sdl")
|
||||||
annotationProcessor 'com.github.Anuken:jabel:0.9.0'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +252,7 @@ project(":core"){
|
|||||||
|
|
||||||
kapt{
|
kapt{
|
||||||
javacOptions{
|
javacOptions{
|
||||||
option("-source", "17")
|
option("-source", "16")
|
||||||
option("-target", "1.8")
|
option("-target", "1.8")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,7 +299,7 @@ project(":core"){
|
|||||||
task assetsJar(type: Jar, dependsOn: ":tools:pack"){
|
task assetsJar(type: Jar, dependsOn: ":tools:pack"){
|
||||||
archiveClassifier = 'assets'
|
archiveClassifier = 'assets'
|
||||||
from files("assets"){
|
from files("assets"){
|
||||||
exclude "config", "cache", "music", "sounds", "sprites/fallback"
|
exclude "config", "cache", "music", "sounds"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +320,6 @@ project(":core"){
|
|||||||
api arcModule("extensions:g3d")
|
api arcModule("extensions:g3d")
|
||||||
api arcModule("extensions:fx")
|
api arcModule("extensions:fx")
|
||||||
api arcModule("extensions:arcnet")
|
api arcModule("extensions:arcnet")
|
||||||
implementation arcModule("extensions:filedialogs")
|
|
||||||
api "com.github.Anuken:rhino:$rhinoVersion"
|
api "com.github.Anuken:rhino:$rhinoVersion"
|
||||||
if(localArc && debugged()) api arcModule("extensions:recorder")
|
if(localArc && debugged()) api arcModule("extensions:recorder")
|
||||||
if(localArc) api arcModule(":extensions:packer")
|
if(localArc) api arcModule(":extensions:packer")
|
||||||
@@ -366,6 +355,7 @@ project(":core"){
|
|||||||
//these are completely unnecessary
|
//these are completely unnecessary
|
||||||
tasks.kaptGenerateStubsKotlin.onlyIf{ false }
|
tasks.kaptGenerateStubsKotlin.onlyIf{ false }
|
||||||
tasks.compileKotlin.onlyIf{ false }
|
tasks.compileKotlin.onlyIf{ false }
|
||||||
|
tasks.inspectClassesForKotlinIC.onlyIf{ false }
|
||||||
}
|
}
|
||||||
|
|
||||||
//comp** classes are only used for code generation
|
//comp** classes are only used for code generation
|
||||||
@@ -380,7 +370,6 @@ project(":server"){
|
|||||||
dependencies{
|
dependencies{
|
||||||
implementation project(":core")
|
implementation project(":core")
|
||||||
implementation arcModule("backends:backend-headless")
|
implementation arcModule("backends:backend-headless")
|
||||||
annotationProcessor 'com.github.Anuken:jabel:0.9.0'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,9 +406,6 @@ project(":tools"){
|
|||||||
implementation arcModule("natives:natives-desktop")
|
implementation arcModule("natives:natives-desktop")
|
||||||
implementation arcModule("natives:natives-freetype-desktop")
|
implementation arcModule("natives:natives-freetype-desktop")
|
||||||
implementation arcModule("backends:backend-headless")
|
implementation arcModule("backends:backend-headless")
|
||||||
|
|
||||||
implementation("com.google.guava:guava:33.3.1-jre")
|
|
||||||
annotationProcessor 'com.github.Anuken:jabel:0.9.0'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 187 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 510 B |
|
Before Width: | Height: | Size: 360 B After Width: | Height: | Size: 352 B |
|
Before Width: | Height: | Size: 230 B |
|
Before Width: | Height: | Size: 338 B |
|
Before Width: | Height: | Size: 435 B |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 496 B |
|
Before Width: | Height: | Size: 253 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 981 B |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 429 B |
|
Before Width: | Height: | Size: 434 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 193 B |
|
Before Width: | Height: | Size: 81 B After Width: | Height: | Size: 71 B |
|
Before Width: | Height: | Size: 398 B After Width: | Height: | Size: 525 B |
|
Before Width: | Height: | Size: 335 B After Width: | Height: | Size: 508 B |
|
Before Width: | Height: | Size: 378 B After Width: | Height: | Size: 483 B |
|
Before Width: | Height: | Size: 604 B |
|
Before Width: | Height: | Size: 509 B |
|
Before Width: | Height: | Size: 701 B |
|
Before Width: | Height: | Size: 660 B |
|
Before Width: | Height: | Size: 652 B |
|
Before Width: | Height: | Size: 660 B |
|
Before Width: | Height: | Size: 759 B |
|
Before Width: | Height: | Size: 660 B |
|
Before Width: | Height: | Size: 637 B |
|
Before Width: | Height: | Size: 535 B |
|
Before Width: | Height: | Size: 695 B |
|
Before Width: | Height: | Size: 529 B |
|
Before Width: | Height: | Size: 676 B |
|
Before Width: | Height: | Size: 676 B |
|
Before Width: | Height: | Size: 616 B |
|
Before Width: | Height: | Size: 702 B |
|
Before Width: | Height: | Size: 497 B |
|
Before Width: | Height: | Size: 774 B |
|
Before Width: | Height: | Size: 640 B |
|
Before Width: | Height: | Size: 626 B |
|
Before Width: | Height: | Size: 714 B |
|
Before Width: | Height: | Size: 618 B |
|
Before Width: | Height: | Size: 654 B |
|
Before Width: | Height: | Size: 469 B |
|
Before Width: | Height: | Size: 666 B |
|
Before Width: | Height: | Size: 629 B |
|
Before Width: | Height: | Size: 848 B |
|
Before Width: | Height: | Size: 661 B |
|
Before Width: | Height: | Size: 631 B |
|
Before Width: | Height: | Size: 887 B |
|
Before Width: | Height: | Size: 732 B |
|
Before Width: | Height: | Size: 608 B |
|
Before Width: | Height: | Size: 831 B |
|
Before Width: | Height: | Size: 636 B |
|
Before Width: | Height: | Size: 633 B |
|
Before Width: | Height: | Size: 597 B |
|
Before Width: | Height: | Size: 808 B |
|
Before Width: | Height: | Size: 722 B |
|
Before Width: | Height: | Size: 631 B |
|
Before Width: | Height: | Size: 611 B |
|
Before Width: | Height: | Size: 648 B |
|
Before Width: | Height: | Size: 842 B |
|
Before Width: | Height: | Size: 750 B |
|
Before Width: | Height: | Size: 711 B |
|
Before Width: | Height: | Size: 675 B |
|
Before Width: | Height: | Size: 774 B |
|
Before Width: | Height: | Size: 301 B |
|
Before Width: | Height: | Size: 230 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 236 B |
|
Before Width: | Height: | Size: 789 B |
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -1,3 +1,2 @@
|
|||||||
mschxœE<C593>Á
|
mschxœE<C593><EFBFBD>
|
||||||
ƒ0DÇ$FA(úù¢Òê‹
|
ƒ0„¯¦þÀ`{Ž>T¦Aµ–*Œ½ûÀõg°@øÂå.<2E>Æ =o‚n)Õãv쎣 ìÅA¯lºMü,ý“ÏSâã&ÓÊÞNìÌs¸/‘ÃjO1!Êq`ûK¢ñû,&<26>[ÀÿR Œ¤(O€®»6EÖ *?»Ê».¡šëº>hRSÉ–-êTQBTP5PýAÙù–Ø(¢
|
||||||
1Jb)ý÷R›J÷ò–™a–…B- -=žm©c n÷MX-y³‘c5Ñl¡v{Tí;ûÚ…û‰ÜÜ“5ƒŸÅeô´MóÎfóÚm}²7nØÄº‘ÑDs1a}øž\ñŸ"CäMžTË$œQ$¡H‘”<E28098>žŽÐñ!q¼<71>ãøDGüÊJ䲌"ã¼!ó
|
|
||||||
BIN
core/assets/baseparts/772862221297909760.msch
Normal file
@@ -1,2 +0,0 @@
|
|||||||
mschxœËA
|
|
||||||
€ Fá_‹Ú´m7ðDÑÂraRÑ ë—¾õ÷ ¡ŒÑÞŒÍR
|
|
||||||