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
+18 -8
View File
@@ -9,14 +9,14 @@
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<application <application
android:resizeableActivity="false" android:resizeableActivity="false"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:isGame="true" android:isGame="true"
android:appCategory="game" android:appCategory="game"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/GdxTheme" > android:theme="@style/GdxTheme" android:fullBackupContent="@xml/backup_rules">
<activity <activity
android:name="io.anuke.mindustry.AndroidLauncher" android:name="io.anuke.mindustry.AndroidLauncher"
android:label="@string/app_name" android:label="@string/app_name"
@@ -33,8 +33,18 @@
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/> <category android:name="android.intent.category.BROWSABLE"/>
<data android:mimeType="application/octet-stream"/> <data android:mimeType="application/octet-stream"/>
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.mmap" />
</intent-filter> </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" <intent-filter android:icon="@mipmap/ic_launcher"
android:label="Mindustry Map" android:label="Mindustry Map"
android:priority="1"> android:priority="1">
+17 -2
View File
@@ -1,4 +1,8 @@
apply plugin: "com.android.application"
configurations { natives }
repositories { repositories {
mavenCentral() mavenCentral()
jcenter() jcenter()
@@ -8,9 +12,20 @@ repositories {
} }
dependencies { 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 'org.sufficientlysecure:donations:2.5'
implementation 'com.google.android.gms:play-services-auth:11.8.0' 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){ task deploy(type: Copy){
@@ -35,7 +50,7 @@ android {
jniLibs.srcDirs = ['libs'] jniLibs.srcDirs = ['libs']
} }
instrumentTest.setRoot('tests') androidTest.setRoot('tests')
} }
packagingOptions { packagingOptions {
exclude 'META-INF/robovm/ios/robovm.xml' 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

@@ -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>
@@ -6,27 +6,6 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="10dp" > 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 <EditText
android:id="@+id/gdxDialogsEditTextInput" android:id="@+id/gdxDialogsEditTextInput"
android:layout_width="match_parent" android:layout_width="match_parent"
-8
View File
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="GdxTheme" parent="android:Theme.Material.NoActionBar"> <style name="GdxTheme" parent="android:Theme.Material.NoActionBar">
<item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item> <item name="android:colorBackgroundCacheHint">@null</item>
@@ -9,11 +8,4 @@
<item name="android:windowContentOverlay">@null</item> <item name="android:windowContentOverlay">@null</item>
<item name="android:windowFullscreen">true</item> <item name="android:windowFullscreen">true</item>
</style> </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> </resources>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
</full-backup-content>
@@ -25,7 +25,6 @@ public class AndroidTextFieldDialog{
public AndroidTextFieldDialog show() { public AndroidTextFieldDialog show() {
activity.runOnUiThread(() -> { activity.runOnUiThread(() -> {
Gdx.app.error("Android Dialogs", AndroidTextFieldDialog.class.getSimpleName() + " now shown.");
AlertDialog dialog = builder.create(); AlertDialog dialog = builder.create();
dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
@@ -48,7 +47,7 @@ public class AndroidTextFieldDialog{
alertDialogBuilder.setView(promptsView); alertDialogBuilder.setView(promptsView);
userInput = (EditText) promptsView.findViewById(getResourceId("gdxDialogsEditTextInput", "id")); userInput = promptsView.findViewById(getResourceId("gdxDialogsEditTextInput", "id"));
alertDialogBuilder.setCancelable(false); alertDialogBuilder.setCancelable(false);
builder = alertDialogBuilder; builder = alertDialogBuilder;
+2 -21
View File
@@ -9,7 +9,7 @@ buildscript {
dependencies { dependencies {
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.0' classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.0'
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6' 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" classpath "com.badlogicgames.gdx:gdx-tools:1.9.8"
} }
} }
@@ -27,7 +27,7 @@ allprojects {
gdxVersion = '1.9.8' gdxVersion = '1.9.8'
roboVMVersion = '2.3.0' roboVMVersion = '2.3.0'
aiVersion = '1.8.1' aiVersion = '1.8.1'
uCoreVersion = '6d1ef60c46' uCoreVersion = 'd28a0e7969'
getVersionString = { getVersionString = {
String buildVersion = getBuildVersion() 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") { project(":ios") {
apply plugin: "java" apply plugin: "java"
apply plugin: "robovm" 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

+1 -1
View File
@@ -71,7 +71,7 @@ io.anuke.ucore.scene.ui.ImageButton$ImageButtonStyle: {
io.anuke.ucore.scene.ui.ScrollPane$ScrollPaneStyle: { io.anuke.ucore.scene.ui.ScrollPane$ScrollPaneStyle: {
default: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical-black}, 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}, 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: {vScroll: scroll, vScrollKnob: scroll-knob-vertical},
clear-black: {vScroll: scroll, vScrollKnob: scroll-knob-vertical-black} clear-black: {vScroll: scroll, vScrollKnob: scroll-knob-vertical-black}
}, },
+2 -1
View File
@@ -42,7 +42,8 @@ public class Vars{
//waves can last no longer than 3 minutes, otherwise the next one spawns //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 maxwavespace = 60*60*4f;
public static final float coreBuildRange = 800f; //set ridiculously high for now
public static final float coreBuildRange = 800999f;
//discord group URL //discord group URL
public static final String discordURL = "https://discord.gg/BKADYds"; public static final String discordURL = "https://discord.gg/BKADYds";
@@ -377,7 +377,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
} }
public void build(){ 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)) : float size = mobile ? (int)(Gdx.graphics.getHeight() / amount / Unit.dp.scl(1f)) :
Math.min(Gdx.graphics.getDisplayMode().height / amount, baseSize); Math.min(Gdx.graphics.getDisplayMode().height / amount, baseSize);
@@ -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;
});
}
}
@@ -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.*/ /**Draw all current build requests. Does not draw the beam effect, only the positions.*/
public void drawBuildRequests(){ public void drawBuildRequests(){
for (BuildRequest request : getPlaceQueue()) { synchronized (getPlaceQueue()) {
for (BuildRequest request : getPlaceQueue()) {
if(request.remove){ if (request.remove) {
Block block = world.tile(request.x, request.y).target().block(); Block block = world.tile(request.x, request.y).target().block();
//draw removal request //draw removal request
Draw.color(Palette.remove); Draw.color(Palette.remove);
Lines.stroke((1f-request.progress)); Lines.stroke((1f - request.progress));
Lines.poly(request.x * tilesize + block.offset(), Lines.poly(request.x * tilesize + block.offset(),
request.y * tilesize + block.offset(), request.y * tilesize + block.offset(),
4, block.size * tilesize /2f, 45 + 15); 4, block.size * tilesize / 2f, 45 + 15);
}else{ } else {
//draw place request //draw place request
Draw.color(Palette.accent); Draw.color(Palette.accent);
Lines.stroke((1f-request.progress)); Lines.stroke((1f - request.progress));
Lines.poly(request.x * tilesize + request.recipe.result.offset(), Lines.poly(request.x * tilesize + request.recipe.result.offset(),
request.y * tilesize + request.recipe.result.offset(), request.y * tilesize + request.recipe.result.offset(),
4, request.recipe.result.size * tilesize /2f, 45 + 15); 4, request.recipe.result.size * tilesize / 2f, 45 + 15);
}
} }
}
Draw.reset(); Draw.reset();
}
} }
//endregion //endregion
@@ -65,11 +65,13 @@ public interface BuilderTrait {
/**If a place request matching this signature is present, it is removed. /**If a place request matching this signature is present, it is removed.
* Otherwise, a new place request is added to the queue.*/ * Otherwise, a new place request is added to the queue.*/
default void replaceBuilding(int x, int y, int rotation, Recipe recipe){ default void replaceBuilding(int x, int y, int rotation, Recipe recipe){
for(BuildRequest request : getPlaceQueue()){ synchronized (getPlaceQueue()) {
if(request.x == x && request.y == y){ for (BuildRequest request : getPlaceQueue()) {
clearBuilding(); if (request.x == x && request.y == y) {
addBuildRequest(request); clearBuilding();
return; 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){ default void addBuildRequest(BuildRequest place){
for(BuildRequest request : getPlaceQueue()){ synchronized (getPlaceQueue()) {
if(request.x == place.x && request.y == place.y){ for (BuildRequest request : getPlaceQueue()) {
return; 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. /**Return the build requests currently active, or the one at the top of the queue.
@@ -198,7 +198,7 @@ public class AndroidInput extends InputHandler implements GestureListener{
defaults().size(60f); defaults().size(60f);
//Add a 'cancel building' button. //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); visible(() -> player.getPlaceQueue().size > 0);
}}.left().colspan(2).end(); }}.left().colspan(2).end();
@@ -7,15 +7,16 @@ import io.anuke.ucore.function.Supplier;
import io.anuke.ucore.scene.ui.Image; import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.layout.Stack; import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
public class ItemImage extends Stack { public class ItemImage extends Stack {
public ItemImage(TextureRegion region, Supplier<CharSequence> text) { public ItemImage(TextureRegion region, Supplier<CharSequence> text) {
Table t = new Table().left().bottom(); 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.row();
t.label(text).get().setFontScale(0.5f); t.label(text).get().setFontScale(Unit.dp.scl(0.5f));
Image image = new Image(region); Image image = new Image(region);
@@ -26,9 +27,9 @@ public class ItemImage extends Stack {
public ItemImage(ItemStack stack) { public ItemImage(ItemStack stack) {
Table t = new Table().left().bottom(); 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.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); Image image = new Image(stack.item.region);
@@ -1,5 +1,6 @@
package io.anuke.mindustry.ui.fragments; package io.anuke.mindustry.ui.fragments;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.IntSet; 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.core.Timers;
import io.anuke.ucore.function.BooleanProvider; import io.anuke.ucore.function.BooleanProvider;
import io.anuke.ucore.scene.Group; 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.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.event.Touchable;
import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings; 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.state;
import static io.anuke.mindustry.Vars.tilesize; import static io.anuke.mindustry.Vars.tilesize;
public class BlockInventoryFragment implements Fragment { public class BlockInventoryFragment implements Fragment {
private final static float holdWithdraw = 40f;
private Table table; private Table table;
private boolean shown;
private Tile tile; private Tile tile;
private InputHandler input; private InputHandler input;
private float holdTime = 0f;
private boolean holding;
private Item lastItem;
public BlockInventoryFragment(InputHandler input){ public BlockInventoryFragment(InputHandler input){
this.input = input; this.input = input;
@@ -41,7 +50,9 @@ public class BlockInventoryFragment implements Fragment {
@Override @Override
public void build(Group parent) { public void build(Group parent) {
table = new Table(); 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); parent.addChild(table);
} }
@@ -52,26 +63,37 @@ public class BlockInventoryFragment implements Fragment {
} }
public void hide(){ public void hide(){
shown = false; table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interpolation.pow3Out), Actions.visible(false), Actions.run(() -> {
table.clear(); table.clear();
table.update(null);
}));
table.setTouchable(Touchable.disabled); table.setTouchable(Touchable.disabled);
table.update(() -> {});
tile = null; tile = null;
} }
private void rebuild(){ private void rebuild(){
Player player = input.player; Player player = input.player;
shown = true;
IntSet container = new IntSet(); IntSet container = new IntSet();
table.clear(); table.clear();
table.background("clear"); table.background("inventory");
table.setTouchable(Touchable.enabled); table.setTouchable(Touchable.enabled);
table.update(() -> { table.update(() -> {
if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items.totalItems() == 0){ if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items.totalItems() == 0){
hide(); 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(); updateTablePosition();
if(tile.block().hasItems) { if(tile.block().hasItems) {
int[] items = tile.entity.items.items; int[] items = tile.entity.items.items;
@@ -87,8 +109,8 @@ public class BlockInventoryFragment implements Fragment {
int cols = 3; int cols = 3;
int row = 0; int row = 0;
table.margin(3f); table.margin(6f);
table.defaults().size(16*2).space(6f); table.defaults().size(mobile ? 16*3 : 16*2).space(6f);
if(tile.block().hasItems) { if(tile.block().hasItems) {
int[] items = tile.entity.items.items; int[] items = tile.entity.items.items;
@@ -107,10 +129,24 @@ public class BlockInventoryFragment implements Fragment {
ItemImage image = new ItemImage(item.region, () -> round(items[f])); ItemImage image = new ItemImage(item.region, () -> round(items[f]));
image.addListener(l); image.addListener(l);
image.tapped(() -> {
if(!canPick.get() || items[f] == 0) return; image.addListener(new InputListener(){
int amount = Math.min(Inputs.keyDown("item_withdraw") ? items[f] : 1, player.inventory.itemCapacityUsed(item)); @Override
CallBlocks.requestItem(player, tile, item, amount); 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); table.add(image);
@@ -123,6 +159,9 @@ public class BlockInventoryFragment implements Fragment {
} }
updateTablePosition(); updateTablePosition();
table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true),
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
} }
private String round(float f){ private String round(float f){
+1 -1
View File
@@ -1,6 +1,6 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms512m -Xmx1536m org.gradle.jvmargs=-Xms512m -Xmx1536m
org.gradle.configureondemand=true org.gradle.configureondemand=true
android.enableAapt2=false android.enableAapt2=true
android.injected.build.model.only.versioned=3 android.injected.build.model.only.versioned=3
android.enableD8=true android.enableD8=true
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists