Automatic consume fragment view
This commit is contained in:
@@ -206,22 +206,12 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
consumed = true;
|
consumed = true;
|
||||||
showedInventory = true;
|
showedInventory = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tile.block().consumes.hasAny()){
|
|
||||||
frag.consume.show(tile);
|
|
||||||
consumed = true;
|
|
||||||
showedConsume = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!showedInventory){
|
if(!showedInventory){
|
||||||
frag.inv.hide();
|
frag.inv.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!showedConsume){
|
|
||||||
frag.consume.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!consumed && player.isBuilding()){
|
if(!consumed && player.isBuilding()){
|
||||||
player.clearBuilding();
|
player.clearBuilding();
|
||||||
recipe = null;
|
recipe = null;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import io.anuke.mindustry.world.Block;
|
|||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.consumers.Consume;
|
import io.anuke.mindustry.world.consumers.Consume;
|
||||||
import io.anuke.ucore.core.Graphics;
|
import io.anuke.ucore.core.Graphics;
|
||||||
|
import io.anuke.ucore.scene.Element;
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
|
|
||||||
public class BlockConsumeFragment extends Fragment{
|
public class BlockConsumeFragment extends Fragment{
|
||||||
private Table table;
|
private Table table;
|
||||||
|
private Tile lastTile;
|
||||||
private boolean visible;
|
private boolean visible;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -26,6 +28,24 @@ public class BlockConsumeFragment extends Fragment{
|
|||||||
table = new Table();
|
table = new Table();
|
||||||
table.visible(() -> !state.is(State.menu) && visible);
|
table.visible(() -> !state.is(State.menu) && visible);
|
||||||
table.setTransform(true);
|
table.setTransform(true);
|
||||||
|
|
||||||
|
parent.addChild(new Element(){{update(() -> {
|
||||||
|
if(!ui.hasMouse()){
|
||||||
|
Tile tile = world.tileWorld(Graphics.mouseWorld().x, Graphics.mouseWorld().y);
|
||||||
|
if(tile == null) return;
|
||||||
|
tile = tile.target();
|
||||||
|
|
||||||
|
if(tile != lastTile){
|
||||||
|
if(tile.block().consumes.hasAny()){
|
||||||
|
show(tile);
|
||||||
|
}else if(visible){
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
lastTile = tile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});}});
|
||||||
|
|
||||||
parent.setTransform(true);
|
parent.setTransform(true);
|
||||||
parent.addChild(table);
|
parent.addChild(table);
|
||||||
}
|
}
|
||||||
@@ -66,7 +86,7 @@ public class BlockConsumeFragment extends Fragment{
|
|||||||
rebuild(block, entity);
|
rebuild(block, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 v = Graphics.screen(tile.drawx() - tile.block().size * tilesize / 2f, tile.drawy() + tile.block().size * tilesize / 2f);
|
Vector2 v = Graphics.screen(tile.drawx() - tile.block().size * tilesize / 2f + 0.25f, tile.drawy() + tile.block().size * tilesize / 2f);
|
||||||
table.pack();
|
table.pack();
|
||||||
table.setPosition(v.x, v.y, Align.topRight);
|
table.setPosition(v.x, v.y, Align.topRight);
|
||||||
});
|
});
|
||||||
@@ -76,8 +96,7 @@ public class BlockConsumeFragment extends Fragment{
|
|||||||
|
|
||||||
public void hide(){
|
public void hide(){
|
||||||
table.clear();
|
table.clear();
|
||||||
table.update(() -> {
|
table.update(() -> {});
|
||||||
});
|
|
||||||
visible = false;
|
visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import java.text.NumberFormat;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
import static org.robovm.apple.foundation.NSPathUtilities.getDocumentsDirectory;
|
import static org.robovm.apple.foundation.NSPathUtilities.getDocumentsDirectory;
|
||||||
@@ -66,11 +65,6 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
|||||||
TextFieldDialogListener.add(field, maxLength);
|
TextFieldDialogListener.add(field, maxLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLocaleName(Locale locale) {
|
|
||||||
return locale.getDisplayName(locale);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shareFile(FileHandle file){
|
public void shareFile(FileHandle file){
|
||||||
FileHandle to = Gdx.files.absolute(getDocumentsDirectory()).child(file.name());
|
FileHandle to = Gdx.files.absolute(getDocumentsDirectory()).child(file.name());
|
||||||
|
|||||||
Reference in New Issue
Block a user