Added tile selection view
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 157 B |
@@ -504,16 +504,16 @@ block.deepwater.name = deepwater
|
|||||||
block.water.name = water
|
block.water.name = water
|
||||||
block.lava.name = lava
|
block.lava.name = lava
|
||||||
block.tar.name = Tar
|
block.tar.name = Tar
|
||||||
block.blackstone.name = blackstone
|
block.blackstone.name = Black Stone
|
||||||
block.stone.name = stone
|
block.stone.name = Stone
|
||||||
block.dirt.name = dirt
|
block.dirt.name = Dirt
|
||||||
block.sand.name = sand
|
block.sand.name = Sand
|
||||||
block.ice.name = ice
|
block.ice.name = Ice
|
||||||
block.snow.name = snow
|
block.snow.name = Snow
|
||||||
block.grass.name = grass
|
block.grass.name = Grass
|
||||||
block.shrub.name = shrub
|
block.shrub.name = Shrub
|
||||||
block.rock.name = rock
|
block.rock.name = Rock
|
||||||
block.blackrock.name = blackrock
|
block.blackrock.name = Black Rock
|
||||||
block.icerock.name = icerock
|
block.icerock.name = icerock
|
||||||
block.copper-wall.name = Copper Wall
|
block.copper-wall.name = Copper Wall
|
||||||
block.copper-wall-large.name = Large Copper Wall
|
block.copper-wall-large.name = Large Copper Wall
|
||||||
|
|||||||
49
core/src/io/anuke/mindustry/ui/SelectionTable.java
Normal file
49
core/src/io/anuke/mindustry/ui/SelectionTable.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||||
|
import io.anuke.ucore.core.Graphics;
|
||||||
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
||||||
|
import io.anuke.ucore.scene.ui.Image;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
|
public class SelectionTable extends Table{
|
||||||
|
Block selected = Blocks.air;
|
||||||
|
|
||||||
|
public SelectionTable(){
|
||||||
|
super("clear");
|
||||||
|
|
||||||
|
margin(4f);
|
||||||
|
|
||||||
|
update(() -> {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ import io.anuke.mindustry.net.Packets.AdminAction;
|
|||||||
import io.anuke.mindustry.type.Recipe;
|
import io.anuke.mindustry.type.Recipe;
|
||||||
import io.anuke.mindustry.ui.IntFormat;
|
import io.anuke.mindustry.ui.IntFormat;
|
||||||
import io.anuke.mindustry.ui.Minimap;
|
import io.anuke.mindustry.ui.Minimap;
|
||||||
|
import io.anuke.mindustry.ui.SelectionTable;
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.graphics.Hue;
|
import io.anuke.ucore.graphics.Hue;
|
||||||
@@ -198,6 +199,12 @@ public class HudFragment extends Fragment{
|
|||||||
t.add("$text.saveload");
|
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());
|
blockfrag.build(Core.scene.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user