From efe93d011794f186bea98deb0aae52fab8b03ade Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 17 Nov 2018 14:45:29 -0500 Subject: [PATCH] Added tile selection view --- .../sprites/blocks/production/alloy-fuser.png | Bin 157 -> 0 bytes core/assets/bundles/bundle.properties | 20 +++---- .../io/anuke/mindustry/ui/SelectionTable.java | 49 ++++++++++++++++++ .../mindustry/ui/fragments/HudFragment.java | 7 +++ 4 files changed, 66 insertions(+), 10 deletions(-) delete mode 100644 core/assets-raw/sprites/blocks/production/alloy-fuser.png create mode 100644 core/src/io/anuke/mindustry/ui/SelectionTable.java diff --git a/core/assets-raw/sprites/blocks/production/alloy-fuser.png b/core/assets-raw/sprites/blocks/production/alloy-fuser.png deleted file mode 100644 index 19815de0ff973b42bcdce7193c4db8050ee64ea5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 157 zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|4mJh`h6m-gKNuJoQaoK8Ln>}1zj*obXFu=s z>C-2-6wW+sut(>|_MMD8%~wXhugxa=E`#kWs< z$GY5gCAKzHa2F(|a2JS9IedUAg)@b_ { + Block result; + Tile tile = world.tileWorld(Graphics.mouseWorld().x, Graphics.mouseWorld().y); + if(tile != null){ + tile = tile.target(); + result = tile.block().synthetic() ? tile.block() : tile.floor() instanceof OreBlock ? tile.floor() : null; + }else{ + result = null; + } + + if(result != null) selected = result; + + getTranslation().y = Mathf.lerp(getTranslation().y, result == null ? -getHeight() : 0f, 0.2f); + }); + + Image image = new Image(new TextureRegionDrawable(new TextureRegion(Draw.region("clear")))); + image.update(() -> ((TextureRegionDrawable)image.getDrawable()).setRegion(selected.getEditorIcon())); + + add(image).size(16*2); + label(() -> selected instanceof OreBlock ? selected.drops.item.localizedName() : selected.formalName).pad(4); + + pack(); + getTranslation().y = - getHeight(); + } +} diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 2da9f991a6..3da203e15a 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -16,6 +16,7 @@ import io.anuke.mindustry.net.Packets.AdminAction; import io.anuke.mindustry.type.Recipe; import io.anuke.mindustry.ui.IntFormat; import io.anuke.mindustry.ui.Minimap; +import io.anuke.mindustry.ui.SelectionTable; import io.anuke.mindustry.ui.dialogs.FloatingDialog; import io.anuke.ucore.core.*; import io.anuke.ucore.graphics.Hue; @@ -198,6 +199,12 @@ public class HudFragment extends Fragment{ t.add("$text.saveload"); }); + //tapped block indicator + parent.fill(t -> { + t.bottom().visible(() -> !state.is(State.menu)); + t.add(new SelectionTable()); + }); + blockfrag.build(Core.scene.getRoot()); }