Gradle update / Block inventory improved / Crash fixes

This commit is contained in:
Anuken
2018-07-02 11:04:24 -04:00
parent 37ba95f8b3
commit e9436426b7
29 changed files with 832 additions and 912 deletions

View File

@@ -9,14 +9,14 @@
<uses-permission android:name="android.permission.INTERNET" />
<application
android:resizeableActivity="false"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:isGame="true"
android:appCategory="game"
android:label="@string/app_name"
android:theme="@style/GdxTheme" >
android:resizeableActivity="false"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:isGame="true"
android:appCategory="game"
android:label="@string/app_name"
android:theme="@style/GdxTheme" android:fullBackupContent="@xml/backup_rules">
<activity
android:name="io.anuke.mindustry.AndroidLauncher"
android:label="@string/app_name"
@@ -33,8 +33,18 @@
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:mimeType="application/octet-stream"/>
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.mmap" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:mimeType="application/octet-stream"/>
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.msav" />
</intent-filter>
<intent-filter android:icon="@mipmap/ic_launcher"
android:label="Mindustry Map"
android:priority="1">

View File

@@ -1,4 +1,8 @@
apply plugin: "com.android.application"
configurations { natives }
repositories {
mavenCentral()
jcenter()
@@ -8,9 +12,20 @@ repositories {
}
dependencies {
implementation 'com.android.support:support-v4:22.1.1'
implementation project(":core")
implementation project(":kryonet")
implementation 'com.android.support:support-v4:25.3.1'
implementation 'org.sufficientlysecure:donations:2.5'
implementation 'com.google.android.gms:play-services-auth:11.8.0'
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
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-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-ai:$aiVersion"
implementation "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
}
task deploy(type: Copy){
@@ -35,7 +50,7 @@ android {
jniLibs.srcDirs = ['libs']
}
instrumentTest.setRoot('tests')
androidTest.setRoot('tests')
}
packagingOptions {
exclude 'META-INF/robovm/ios/robovm.xml'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dp" >
<EditText
android:id="@+id/gdxDialogsEditTextInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:maxLines="1"
android:maxLength="15"
>
<requestFocus />
</EditText>
</LinearLayout>

View File

@@ -5,28 +5,7 @@
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="@+id/gdxDialogsEnterTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
<TextView
android:id="@+id/gdxDialogsEnterMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<EditText
android:id="@+id/gdxDialogsEditTextInput"
android:layout_width="match_parent"

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="GdxTheme" parent="android:Theme.Material.NoActionBar">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
@@ -9,11 +8,4 @@
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowFullscreen">true</item>
</style>
<style name="LightBackground" parent="android:Theme.Material.Light" >
<item name="android:colorBackground">@android:color/black</item>
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:textColorSecondary">@android:color/white</item>
<item name="android:textColorSecondaryInverse">@android:color/white</item>
</style>
</resources>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
</full-backup-content>

View File

@@ -25,7 +25,6 @@ public class AndroidTextFieldDialog{
public AndroidTextFieldDialog show() {
activity.runOnUiThread(() -> {
Gdx.app.error("Android Dialogs", AndroidTextFieldDialog.class.getSimpleName() + " now shown.");
AlertDialog dialog = builder.create();
dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
@@ -48,7 +47,7 @@ public class AndroidTextFieldDialog{
alertDialogBuilder.setView(promptsView);
userInput = (EditText) promptsView.findViewById(getResourceId("gdxDialogsEditTextInput", "id"));
userInput = promptsView.findViewById(getResourceId("gdxDialogsEditTextInput", "id"));
alertDialogBuilder.setCancelable(false);
builder = alertDialogBuilder;

View File

@@ -9,7 +9,7 @@ buildscript {
dependencies {
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.0'
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "com.badlogicgames.gdx:gdx-tools:1.9.8"
}
}
@@ -27,7 +27,7 @@ allprojects {
gdxVersion = '1.9.8'
roboVMVersion = '2.3.0'
aiVersion = '1.8.1'
uCoreVersion = '6d1ef60c46'
uCoreVersion = 'd28a0e7969'
getVersionString = {
String buildVersion = getBuildVersion()
@@ -116,25 +116,6 @@ project(":html") {
]
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
implementation project(":core")
implementation project(":kryonet")
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
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-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-ai:$aiVersion"
implementation "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 129 KiB

View File

@@ -71,7 +71,7 @@ io.anuke.ucore.scene.ui.ImageButton$ImageButtonStyle: {
io.anuke.ucore.scene.ui.ScrollPane$ScrollPaneStyle: {
default: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical-black},
horizontal: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical, hScroll: scroll-horizontal, hScrollKnob: scroll-knob-horizontal},
volume: {background: button-map, vScroll: scroll, vScrollKnob: scroll-knob-vertical},
volume: {background: button-map, vScroll: scroll, vScrollKnob: scroll-knob-vertical-black},
clear: {vScroll: scroll, vScrollKnob: scroll-knob-vertical},
clear-black: {vScroll: scroll, vScrollKnob: scroll-knob-vertical-black}
},

View File

@@ -42,7 +42,8 @@ public class Vars{
//waves can last no longer than 3 minutes, otherwise the next one spawns
public static final float maxwavespace = 60*60*4f;
public static final float coreBuildRange = 800f;
//set ridiculously high for now
public static final float coreBuildRange = 800999f;
//discord group URL
public static final String discordURL = "https://discord.gg/BKADYds";

View File

@@ -377,7 +377,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
}
public void build(){
float amount = 9.5f, baseSize = 60f;
float amount = 10f, baseSize = 60f;
float size = mobile ? (int)(Gdx.graphics.getHeight() / amount / Unit.dp.scl(1f)) :
Math.min(Gdx.graphics.getDisplayMode().height / amount, baseSize);

View File

@@ -1,93 +0,0 @@
package io.anuke.mindustry.editor;
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.ui.Image;
public class MapGenerateDialog extends FloatingDialog{
private MapEditor editor;
private Image image;
private boolean loading;
public MapGenerateDialog(MapEditor editor) {
super("$text.editor.generate");
this.editor = editor;
//TODO implement!
/*
Stack stack = new Stack();
stack.add(image = new BorderImage());
Image loadImage = new Image("icon-loading");
loadImage.setScaling(Scaling.none);
loadImage.setScale(3f);
loadImage.update(() -> loadImage.setOrigin(Align.center));
loadImage.setVisible(() -> loading);
Image next = new Image("white");
next.setScaling(Scaling.fit);
next.setColor(0, 0, 0, 0.6f);
next.setVisible(() -> loading);
stack.add(next);
stack.add(loadImage);
content().add(stack).grow();
image.setScaling(Scaling.fit);
Table preft = new Table();
preft.left();
preft.margin(4f).marginRight(25f);
for(GenPref pref : editor.getFilter().getPrefs().values()){
CheckBox box = new CheckBox(pref.name);
box.setChecked(pref.enabled);
box.changed(() -> pref.enabled = box.isChecked());
preft.add(box).pad(4f).left();
preft.row();
}
ScrollPane pane = new ScrollPane(preft, "volume");
pane.setFadeScrollBars(false);
pane.setScrollingDisabled(true, false);
content().add(pane).fillY();
buttons().defaults().size(170f, 50f).pad(4f);
buttons().addButton("$text.back", this::hide);
buttons().addButton("$text.randomize", () ->{
editor.getFilter().randomize();
apply();
});
buttons().addButton("$text.update", this::apply);
buttons().addButton("$text.apply", () ->{
ui.loadfrag.show();
Timers.run(3f, () ->{
Pixmap copy = Pixmaps.copy(editor.pixmap());
editor.applyFilter();
ui.editor.getView().push(copy, Pixmaps.copy(editor.pixmap()));
ui.loadfrag.hide();
ui.editor.resetSaved();
hide();
});
});
shown(() ->{
loading = true;
Timers.run(30f, () -> {
editor.applyFilterPreview();
image.setDrawable(new TextureRegionDrawable(new TextureRegion(editor.getFilterTexture())));
loading = false;
});
});*/
}
private void apply(){
loading = true;
Timers.run(3f, () -> {
//editor.applyFilterPreview();
loading = false;
});
}
}

View File

@@ -392,32 +392,34 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
/**Draw all current build requests. Does not draw the beam effect, only the positions.*/
public void drawBuildRequests(){
for (BuildRequest request : getPlaceQueue()) {
synchronized (getPlaceQueue()) {
for (BuildRequest request : getPlaceQueue()) {
if(request.remove){
Block block = world.tile(request.x, request.y).target().block();
if (request.remove) {
Block block = world.tile(request.x, request.y).target().block();
//draw removal request
Draw.color(Palette.remove);
//draw removal request
Draw.color(Palette.remove);
Lines.stroke((1f-request.progress));
Lines.stroke((1f - request.progress));
Lines.poly(request.x * tilesize + block.offset(),
request.y * tilesize + block.offset(),
4, block.size * tilesize /2f, 45 + 15);
}else{
//draw place request
Draw.color(Palette.accent);
Lines.poly(request.x * tilesize + block.offset(),
request.y * tilesize + block.offset(),
4, block.size * tilesize / 2f, 45 + 15);
} else {
//draw place request
Draw.color(Palette.accent);
Lines.stroke((1f-request.progress));
Lines.stroke((1f - request.progress));
Lines.poly(request.x * tilesize + request.recipe.result.offset(),
request.y * tilesize + request.recipe.result.offset(),
4, request.recipe.result.size * tilesize /2f, 45 + 15);
Lines.poly(request.x * tilesize + request.recipe.result.offset(),
request.y * tilesize + request.recipe.result.offset(),
4, request.recipe.result.size * tilesize / 2f, 45 + 15);
}
}
}
Draw.reset();
Draw.reset();
}
}
//endregion

View File

@@ -65,11 +65,13 @@ public interface BuilderTrait {
/**If a place request matching this signature is present, it is removed.
* Otherwise, a new place request is added to the queue.*/
default void replaceBuilding(int x, int y, int rotation, Recipe recipe){
for(BuildRequest request : getPlaceQueue()){
if(request.x == x && request.y == y){
clearBuilding();
addBuildRequest(request);
return;
synchronized (getPlaceQueue()) {
for (BuildRequest request : getPlaceQueue()) {
if (request.x == x && request.y == y) {
clearBuilding();
addBuildRequest(request);
return;
}
}
}
@@ -85,14 +87,16 @@ public interface BuilderTrait {
}
}
/**Add another build requests to the tail of the queue.*/
/**Add another build requests to the tail of the queue, if it doesn't exist there yet.*/
default void addBuildRequest(BuildRequest place){
for(BuildRequest request : getPlaceQueue()){
if(request.x == place.x && request.y == place.y){
return;
synchronized (getPlaceQueue()) {
for (BuildRequest request : getPlaceQueue()) {
if (request.x == place.x && request.y == place.y) {
return;
}
}
getPlaceQueue().addLast(place);
}
getPlaceQueue().addLast(place);
}
/**Return the build requests currently active, or the one at the top of the queue.

View File

@@ -198,7 +198,7 @@ public class AndroidInput extends InputHandler implements GestureListener{
defaults().size(60f);
//Add a 'cancel building' button.
new imagebutton("icon-cancel", "toggle", 16 * 2f, () -> player.clearBuilding());
new imagebutton("icon-cancel", 16 * 2f, player::clearBuilding);
visible(() -> player.getPlaceQueue().size > 0);
}}.left().colspan(2).end();

View File

@@ -7,15 +7,16 @@ import io.anuke.ucore.function.Supplier;
import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
public class ItemImage extends Stack {
public ItemImage(TextureRegion region, Supplier<CharSequence> text) {
Table t = new Table().left().bottom();
t.label(text).color(Color.DARK_GRAY).padBottom(-22).get().setFontScale(0.5f);
t.label(text).color(Color.DARK_GRAY).padBottom(-22).get().setFontScale(Unit.dp.scl(0.5f));
t.row();
t.label(text).get().setFontScale(0.5f);
t.label(text).get().setFontScale(Unit.dp.scl(0.5f));
Image image = new Image(region);
@@ -26,9 +27,9 @@ public class ItemImage extends Stack {
public ItemImage(ItemStack stack) {
Table t = new Table().left().bottom();
t.add(stack.amount + "").color(Color.DARK_GRAY).padBottom(-22).get().setFontScale(0.5f);
t.add(stack.amount + "").color(Color.DARK_GRAY).padBottom(-22).get().setFontScale(Unit.dp.scl(0.5f));
t.row();
t.add(stack.amount + "").get().setFontScale(0.5f);
t.add(stack.amount + "").get().setFontScale(Unit.dp.scl(0.5f));
Image image = new Image(stack.item.region);

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.ui.fragments;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.IntSet;
@@ -19,20 +20,28 @@ import io.anuke.ucore.core.Inputs;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.function.BooleanProvider;
import io.anuke.ucore.scene.Group;
import io.anuke.ucore.scene.actions.Actions;
import io.anuke.ucore.scene.event.HandCursorListener;
import io.anuke.ucore.scene.event.InputEvent;
import io.anuke.ucore.scene.event.InputListener;
import io.anuke.ucore.scene.event.Touchable;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings;
import static io.anuke.mindustry.Vars.mobile;
import static io.anuke.mindustry.Vars.state;
import static io.anuke.mindustry.Vars.tilesize;
public class BlockInventoryFragment implements Fragment {
private final static float holdWithdraw = 40f;
private Table table;
private boolean shown;
private Tile tile;
private InputHandler input;
private float holdTime = 0f;
private boolean holding;
private Item lastItem;
public BlockInventoryFragment(InputHandler input){
this.input = input;
@@ -41,7 +50,9 @@ public class BlockInventoryFragment implements Fragment {
@Override
public void build(Group parent) {
table = new Table();
table.setVisible(() -> !state.is(State.menu) && shown);
table.setVisible(() -> !state.is(State.menu));
table.setTransform(true);
parent.setTransform(true);
parent.addChild(table);
}
@@ -52,26 +63,37 @@ public class BlockInventoryFragment implements Fragment {
}
public void hide(){
shown = false;
table.clear();
table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interpolation.pow3Out), Actions.visible(false), Actions.run(() -> {
table.clear();
table.update(null);
}));
table.setTouchable(Touchable.disabled);
table.update(() -> {});
tile = null;
}
private void rebuild(){
Player player = input.player;
shown = true;
IntSet container = new IntSet();
table.clear();
table.background("clear");
table.background("inventory");
table.setTouchable(Touchable.enabled);
table.update(() -> {
if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items.totalItems() == 0){
hide();
}else {
}else{
if(holding && lastItem != null){
holdTime += Timers.delta();
if(holdTime >= holdWithdraw){
int amount = Math.min(tile.entity.items.getItem(lastItem), player.inventory.itemCapacityUsed(lastItem));
CallBlocks.requestItem(player, tile, lastItem, amount);
holding = false;
holdTime = 0f;
}
}
updateTablePosition();
if(tile.block().hasItems) {
int[] items = tile.entity.items.items;
@@ -87,8 +109,8 @@ public class BlockInventoryFragment implements Fragment {
int cols = 3;
int row = 0;
table.margin(3f);
table.defaults().size(16*2).space(6f);
table.margin(6f);
table.defaults().size(mobile ? 16*3 : 16*2).space(6f);
if(tile.block().hasItems) {
int[] items = tile.entity.items.items;
@@ -107,10 +129,24 @@ public class BlockInventoryFragment implements Fragment {
ItemImage image = new ItemImage(item.region, () -> round(items[f]));
image.addListener(l);
image.tapped(() -> {
if(!canPick.get() || items[f] == 0) return;
int amount = Math.min(Inputs.keyDown("item_withdraw") ? items[f] : 1, player.inventory.itemCapacityUsed(item));
CallBlocks.requestItem(player, tile, item, amount);
image.addListener(new InputListener(){
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if(!canPick.get() || items[f] == 0) return false;
int amount = Math.min(Inputs.keyDown("item_withdraw") ? items[f] : 1, player.inventory.itemCapacityUsed(item));
CallBlocks.requestItem(player, tile, item, amount);
lastItem = item;
holding = true;
holdTime = 0f;
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
holding = false;
lastItem = null;
}
});
table.add(image);
@@ -123,6 +159,9 @@ public class BlockInventoryFragment implements Fragment {
}
updateTablePosition();
table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true),
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
}
private String round(float f){

View File

@@ -1,6 +1,6 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms512m -Xmx1536m
org.gradle.configureondemand=true
android.enableAapt2=false
android.enableAapt2=true
android.injected.build.model.only.versioned=3
android.enableD8=true

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists