Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -10,9 +10,9 @@ import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.Waves;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
import io.anuke.ucore.util.GridBits;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
|
||||
@@ -92,8 +92,11 @@ public class DebugBlocks extends BlockList implements ContentList{
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
SorterEntity entity = tile.entity();
|
||||
if(entity.sortItem == null) return;
|
||||
|
||||
entity.items.set(entity.sortItem, 1);
|
||||
tryDump(tile, entity.sortItem);
|
||||
entity.items.set(entity.sortItem, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -602,7 +602,8 @@ public class NetServer extends Module{
|
||||
try{
|
||||
|
||||
//iterate through each player
|
||||
for(Player player : playerGroup.all()){
|
||||
for(int i = 0; i < playerGroup.size(); i ++){
|
||||
Player player = playerGroup.all().get(i);
|
||||
if(player.isLocal) continue;
|
||||
|
||||
NetConnection connection = player.con;
|
||||
|
||||
@@ -30,8 +30,8 @@ public class World extends Module{
|
||||
public final Sectors sectors = new Sectors();
|
||||
public final WorldGenerator generator = new WorldGenerator();
|
||||
public final BlockIndexer indexer = new BlockIndexer();
|
||||
public final Pathfinder pathfinder = new Pathfinder();
|
||||
public final WaveSpawner spawner = new WaveSpawner();
|
||||
public final Pathfinder pathfinder = new Pathfinder();
|
||||
|
||||
private Map currentMap;
|
||||
private Sector currentSector;
|
||||
|
||||
@@ -242,8 +242,10 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
if(tile != null){
|
||||
if(!request.remove){
|
||||
rotation = request.rotation;
|
||||
Recipe before = recipe;
|
||||
recipe = request.recipe;
|
||||
tryPlaceBlock(tile.x, tile.y);
|
||||
recipe = before;
|
||||
}else{
|
||||
tryBreakBlock(tile.x, tile.y);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class JoinDialog extends FloatingDialog{
|
||||
versionString = Bundles.get("text.server.outdated");
|
||||
}else if(host.version < Version.build && Version.build != -1){
|
||||
versionString = Bundles.get("text.server.outdated") + "\n" +
|
||||
Bundles.format("text.server.version", host.version);
|
||||
Bundles.format("text.server.version", host.version, "");
|
||||
}else if(host.version > Version.build && Version.build != -1){
|
||||
versionString = Bundles.get("text.server.outdated.client") + "\n" +
|
||||
Bundles.format("text.server.version", host.version, "");
|
||||
@@ -273,7 +273,7 @@ public class JoinDialog extends FloatingDialog{
|
||||
|
||||
local.row();
|
||||
|
||||
TextButton button = local.addButton("[accent]" + host.name, () -> connect(host.address, port))
|
||||
TextButton button = local.addButton("[accent]" + host.name, "clear", () -> connect(host.address, port))
|
||||
.width(w).height(80f).pad(4f).get();
|
||||
button.left();
|
||||
button.row();
|
||||
|
||||
@@ -351,7 +351,7 @@ public class HudFragment extends Fragment{
|
||||
if(shown){
|
||||
shown = false;
|
||||
blockfrag.toggle(dur, in);
|
||||
wavetable.actions(Actions.translateBy(0, (wavetable.getHeight() + dsize + Unit.dp.scl(6)) - wavetable.getTranslation().y, dur, in));
|
||||
wavetable.actions(Actions.translateBy(0, (wavetable.getHeight() + Unit.dp.scl(dsize) + Unit.dp.scl(6)) - wavetable.getTranslation().y, dur, in));
|
||||
infolabel.actions(Actions.translateBy(0, (wavetable.getHeight()) - wavetable.getTranslation().y, dur, in));
|
||||
}else{
|
||||
shown = true;
|
||||
|
||||
@@ -4,43 +4,32 @@ import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.function.Supplier;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
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 static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
|
||||
public interface SelectionTrait{
|
||||
|
||||
default void buildItemTable(Table table, Supplier<Item> holder, Consumer<Item> consumer){
|
||||
buildItemTable(table, false, holder, consumer);
|
||||
}
|
||||
|
||||
default void buildItemTable(Table table, boolean nullItem, Supplier<Item> holder, Consumer<Item> consumer){
|
||||
|
||||
Array<Item> items = content.items();
|
||||
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
group.setMinCheckCount(0);
|
||||
Table cont = new Table();
|
||||
cont.defaults().size(38);
|
||||
|
||||
int i = 0;
|
||||
|
||||
if(nullItem){
|
||||
ImageButton button = cont.addImageButton("white", "clear-toggle", 24, () -> consumer.accept(null)).group(group).get();
|
||||
button.getStyle().imageUp = new TextureRegionDrawable(Draw.region("icon-nullitem"));
|
||||
button.setChecked(holder.get() == null);
|
||||
|
||||
i ++;
|
||||
}
|
||||
|
||||
for(Item item : items){
|
||||
if(!control.unlocks.isUnlocked(item)) continue;
|
||||
|
||||
ImageButton button = cont.addImageButton("white", "clear-toggle", 24, () -> consumer.accept(item))
|
||||
.group(group).get();
|
||||
ImageButton button = cont.addImageButton("white", "clear-toggle", 24, () -> {}).group(group).get();
|
||||
button.changed(() -> consumer.accept(button.isChecked() ? item : null));
|
||||
button.getStyle().imageUp = new TextureRegionDrawable(item.region);
|
||||
button.setChecked(holder.get() == item);
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ public class Sorter extends Block implements SelectionTrait{
|
||||
@Remote(targets = Loc.both, called = Loc.both, forward = true)
|
||||
public static void setSorterItem(Player player, Tile tile, Item item){
|
||||
SorterEntity entity = tile.entity();
|
||||
if(entity != null) entity.sortItem = item;
|
||||
if(entity != null){
|
||||
entity.sortItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,6 +58,7 @@ public class Sorter extends Block implements SelectionTrait{
|
||||
super.draw(tile);
|
||||
|
||||
SorterEntity entity = tile.entity();
|
||||
if(entity.sortItem == null) return;
|
||||
|
||||
Draw.color(entity.sortItem.color);
|
||||
Draw.rect("blank", tile.worldx(), tile.worldy(), 4f, 4f);
|
||||
@@ -130,16 +133,17 @@ public class Sorter extends Block implements SelectionTrait{
|
||||
}
|
||||
|
||||
public static class SorterEntity extends TileEntity{
|
||||
public Item sortItem = content.item(0);
|
||||
public Item sortItem;
|
||||
|
||||
@Override
|
||||
public void writeConfig(DataOutput stream) throws IOException{
|
||||
stream.writeByte(sortItem.id);
|
||||
stream.writeByte(sortItem == null ? -1 : sortItem.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfig(DataInput stream) throws IOException{
|
||||
sortItem = content.items().get(stream.readByte());
|
||||
byte b = stream.readByte();
|
||||
sortItem = b == -1 ? null : content.items().get(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
@Remote(targets = Loc.both, called = Loc.server, forward = true)
|
||||
public static void unlinkPowerNodes(Player player, Tile tile, Tile other){
|
||||
if(tile.entity.power == null) return;
|
||||
if(tile.entity.power == null || other.entity == null || other.entity.power == null) return;
|
||||
|
||||
TileEntity entity = tile.entity();
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SortedUnloader extends Unloader implements SelectionTrait{
|
||||
@Override
|
||||
public void buildTable(Tile tile, Table table){
|
||||
SortedUnloaderEntity entity = tile.entity();
|
||||
buildItemTable(table, true, () -> entity.sortItem, item -> Call.setSortedUnloaderItem(null, tile, item));
|
||||
buildItemTable(table, () -> entity.sortItem, item -> Call.setSortedUnloaderItem(null, tile, item));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user