Re-added sand, better teleporter/sorter UI
This commit is contained in:
@@ -331,13 +331,16 @@ public class UI extends SceneModule{
|
||||
|
||||
public void showConfig(Tile tile){
|
||||
configTile = tile;
|
||||
|
||||
configtable.setVisible(true);
|
||||
|
||||
configtable.clear();
|
||||
((Configurable)tile.block()).buildTable(tile, configtable);
|
||||
configtable.pack();
|
||||
configtable.setTransform(true);
|
||||
configtable.actions(Actions.scaleTo(0f, 1f), Actions.visible(true),
|
||||
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
|
||||
|
||||
configtable.update(()->{
|
||||
configtable.setOrigin(Align.center);
|
||||
Vector2 pos = Graphics.screen(tile.worldx(), tile.worldy());
|
||||
configtable.setPosition(pos.x, pos.y, Align.center);
|
||||
if(configTile == null || configTile.block() == Blocks.air){
|
||||
@@ -352,7 +355,7 @@ public class UI extends SceneModule{
|
||||
}
|
||||
|
||||
public void hideConfig(){
|
||||
configtable.setVisible(false);
|
||||
configtable.actions(Actions.scaleTo(0f, 1f, 0.06f, Interpolation.pow3Out), Actions.visible(false));
|
||||
}
|
||||
|
||||
public void showTextInput(String title, String text, String def, TextFieldFilter filter, Consumer<String> confirmed){
|
||||
|
||||
@@ -236,16 +236,20 @@ public class SaveIO{
|
||||
//--ENEMIES--
|
||||
|
||||
int totalEnemies = 0;
|
||||
|
||||
Array<Enemy> enemies = Vars.control.enemyGroup.all();
|
||||
|
||||
for(Enemy entity : Vars.control.enemyGroup.all()){
|
||||
if(idEnemies.containsKey(entity.getClass())){
|
||||
for(int i = 0; i < enemies.size; i ++){
|
||||
Enemy enemy = enemies.get(i);
|
||||
if(idEnemies.containsKey(enemy.getClass())){
|
||||
totalEnemies ++;
|
||||
}
|
||||
}
|
||||
|
||||
stream.writeInt(totalEnemies); //enemy amount
|
||||
|
||||
for(Enemy enemy : Vars.control.enemyGroup.all()){
|
||||
for(int i = 0; i < enemies.size; i ++){
|
||||
Enemy enemy = enemies.get(i);
|
||||
if(idEnemies.containsKey(enemy.getClass())){
|
||||
stream.writeByte(idEnemies.get(enemy.getClass())); //type
|
||||
stream.writeByte(enemy.lane); //lane
|
||||
|
||||
@@ -108,4 +108,9 @@ public class Packets {
|
||||
public static class BlockUpdatePacket{
|
||||
public int health, position;
|
||||
}
|
||||
|
||||
public static class ChatPacket{
|
||||
public String name;
|
||||
public String text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public class Registrator {
|
||||
BlockDestroyPacket.class,
|
||||
ConnectPacket.class,
|
||||
DisconnectPacket.class,
|
||||
ChatPacket.class,
|
||||
|
||||
Class.class,
|
||||
byte[].class,
|
||||
|
||||
@@ -13,9 +13,9 @@ public class Item{
|
||||
steel = new Item("steel"),
|
||||
titanium = new Item("titanium"),
|
||||
dirium = new Item("dirium"),
|
||||
uranium = new Item("uranium");
|
||||
/*sand = new Item("sand"),
|
||||
glass = new Item("glass"),
|
||||
uranium = new Item("uranium"),
|
||||
sand = new Item("sand");
|
||||
/*glass = new Item("glass"),
|
||||
silicon = new Item("silicon");*/
|
||||
|
||||
public final int id;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
content().row();
|
||||
content().addButton("$text.loadgame", () -> {
|
||||
load.show();
|
||||
});
|
||||
}).disabled(Net.active());
|
||||
|
||||
content().row();
|
||||
|
||||
@@ -89,7 +89,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
|
||||
content().row();
|
||||
|
||||
new imagebutton("icon-load", isize, () -> load.show()).text("$text.load").padTop(4f);
|
||||
new imagebutton("icon-load", isize, () -> load.show()).text("$text.load").padTop(4f).disabled(Net.active());
|
||||
|
||||
new imagebutton("icon-host", isize, () -> ui.showHostServer()).text("$text.host").padTop(4f);
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
public class ChatFragment implements Fragment {
|
||||
//TODO
|
||||
@Override
|
||||
public void build() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class MenuFragment implements Fragment{
|
||||
get().margin(16);
|
||||
}}.end();
|
||||
|
||||
visible(()->GameState.is(State.menu));
|
||||
visible(()-> GameState.is(State.menu));
|
||||
}}.end();
|
||||
}else{
|
||||
new table(){{
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
package io.anuke.mindustry.world.blocks.types.distribution;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Sorter extends Junction implements Configurable{
|
||||
|
||||
public Sorter(String name) {
|
||||
@@ -91,27 +94,31 @@ public class Sorter extends Junction implements Configurable{
|
||||
@Override
|
||||
public void buildTable(Tile tile, Table table){
|
||||
SorterEntity entity = tile.entity();
|
||||
|
||||
table.addIButton("icon-arrow-left", 10*3, ()->{
|
||||
int color = entity.sortItem.id;
|
||||
|
||||
color --;
|
||||
if(color < 0)
|
||||
color += Item.getAllItems().size;
|
||||
|
||||
entity.sortItem = Item.getAllItems().get(color);
|
||||
});
|
||||
|
||||
table.add().size(40f);
|
||||
|
||||
table.addIButton("icon-arrow-right", 10*3, ()->{
|
||||
int color = entity.sortItem.id;
|
||||
|
||||
color ++;
|
||||
color %= Item.getAllItems().size;
|
||||
|
||||
entity.sortItem = Item.getAllItems().get(color);
|
||||
});
|
||||
|
||||
Array<Item> items = Item.getAllItems();
|
||||
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
Table cont = new Table();
|
||||
cont.margin(4);
|
||||
cont.marginBottom(5);
|
||||
|
||||
cont.add().colspan(4).height(105f);
|
||||
cont.row();
|
||||
|
||||
for(int i = 0; i < items.size; i ++){
|
||||
final int f = i;
|
||||
ImageButton button = cont.addIButton("white", "toggle", 24, () -> {
|
||||
entity.sortItem = items.get(f);
|
||||
}).size(38, 42).padBottom(-5.1f).group(group).get();
|
||||
button.getStyle().imageUp = new TextureRegionDrawable(new TextureRegion(Draw.region("icon-"+items.get(i).name)));
|
||||
button.setChecked(entity.sortItem.id == f);
|
||||
|
||||
if(i%4 == 3){
|
||||
cont.row();
|
||||
}
|
||||
}
|
||||
|
||||
table.add(cont);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
package io.anuke.mindustry.world.blocks.types.distribution;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
@@ -15,11 +10,17 @@ import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Teleporter extends Block implements Configurable{
|
||||
public static final Color[] colorArray = {Color.ROYAL, Color.ORANGE, Color.SCARLET, Color.FOREST, Color.PURPLE, Color.GOLD, Color.PINK};
|
||||
public static final Color[] colorArray = {Color.ROYAL, Color.ORANGE, Color.SCARLET, Color.FOREST, Color.PURPLE, Color.GOLD, Color.PINK, Color.BLACK};
|
||||
public static final int colors = colorArray.length;
|
||||
|
||||
private static ObjectSet<Tile>[] teleporters = new ObjectSet[colors];
|
||||
@@ -74,18 +75,30 @@ public class Teleporter extends Block implements Configurable{
|
||||
@Override
|
||||
public void buildTable(Tile tile, Table table){
|
||||
TeleporterEntity entity = tile.entity();
|
||||
|
||||
table.addIButton("icon-arrow-left", 10*3, ()->{
|
||||
entity.color = (byte)Mathf.mod(entity.color - 1, colors);
|
||||
lastColor = entity.color;
|
||||
});
|
||||
|
||||
table.add().size(40f);
|
||||
|
||||
table.addIButton("icon-arrow-right", 10*3, ()->{
|
||||
entity.color = (byte)Mathf.mod(entity.color + 1, colors);
|
||||
lastColor = entity.color;
|
||||
});
|
||||
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
Table cont = new Table();
|
||||
cont.margin(4);
|
||||
cont.marginBottom(5);
|
||||
|
||||
cont.add().colspan(4).height(105f);
|
||||
cont.row();
|
||||
|
||||
for(int i = 0; i < colors; i ++){
|
||||
final int f = i;
|
||||
ImageButton button = cont.addIButton("white", "toggle", 24, () -> {
|
||||
entity.color = (byte)f;
|
||||
lastColor = (byte)f;
|
||||
}).size(34, 38).padBottom(-5.1f).group(group).get();
|
||||
button.getStyle().imageUpColor = colorArray[f];
|
||||
button.setChecked(entity.color == f);
|
||||
|
||||
if(i%4 == 3){
|
||||
cont.row();
|
||||
}
|
||||
}
|
||||
|
||||
table.add(cont);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user