Gradle update / Block inventory improved / Crash fixes
This commit is contained in:
@@ -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";
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.*/
|
||||
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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user