From d25fe028b861a9dc3367505264b84546fe1a07b5 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 29 Nov 2018 16:23:11 -0500 Subject: [PATCH 1/5] Fixed mobile recipe switching --- core/src/io/anuke/mindustry/input/MobileInput.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/io/anuke/mindustry/input/MobileInput.java b/core/src/io/anuke/mindustry/input/MobileInput.java index dba880f8c0..6187b738d9 100644 --- a/core/src/io/anuke/mindustry/input/MobileInput.java +++ b/core/src/io/anuke/mindustry/input/MobileInput.java @@ -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); } From 897c296fbe6d410227b2fd1b18719c6457daea77 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 29 Nov 2018 16:30:41 -0500 Subject: [PATCH 2/5] Fixed server crash --- core/src/io/anuke/mindustry/core/NetServer.java | 3 ++- core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 463eab9692..0f2028ebea 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -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; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java index 53044715b2..4cb355edef 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java @@ -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(); From be48ed5589d1b142d96a04befadf0883440b0817 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 29 Nov 2018 16:37:22 -0500 Subject: [PATCH 3/5] Fixed another boring layout issue --- core/src/io/anuke/mindustry/ui/fragments/HudFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index bc94461864..a0f3694477 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -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; From d56c041c4a98b737cd430a31e598ee75fa14d3db Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 29 Nov 2018 16:58:11 -0500 Subject: [PATCH 4/5] Fixed ground units always spawning in (-1, -1) --- core/src/io/anuke/mindustry/ai/WaveSpawner.java | 2 +- core/src/io/anuke/mindustry/core/World.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/io/anuke/mindustry/ai/WaveSpawner.java b/core/src/io/anuke/mindustry/ai/WaveSpawner.java index 44c39e1b59..a75eed644d 100644 --- a/core/src/io/anuke/mindustry/ai/WaveSpawner.java +++ b/core/src/io/anuke/mindustry/ai/WaveSpawner.java @@ -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; diff --git a/core/src/io/anuke/mindustry/core/World.java b/core/src/io/anuke/mindustry/core/World.java index cf72719411..742a8f8549 100644 --- a/core/src/io/anuke/mindustry/core/World.java +++ b/core/src/io/anuke/mindustry/core/World.java @@ -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; From 99fb1a4c5fc1d11dc4d7e27e05a49aede428a77d Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 30 Nov 2018 10:28:27 -0500 Subject: [PATCH 5/5] Implemented null-items for sorters and item sources --- build.gradle | 3 +-- .../mindustry/content/blocks/DebugBlocks.java | 3 +++ .../mindustry/ui/dialogs/JoinDialog.java | 2 +- .../world/blocks/SelectionTrait.java | 21 +++++-------------- .../world/blocks/distribution/Sorter.java | 12 +++++++---- .../world/blocks/power/PowerNode.java | 2 +- .../world/blocks/storage/SortedUnloader.java | 2 +- tools/build.gradle | 1 - 8 files changed, 20 insertions(+), 26 deletions(-) diff --git a/build.gradle b/build.gradle index 8e06fca630..562a981a97 100644 --- a/build.gradle +++ b/build.gradle @@ -8,12 +8,11 @@ buildscript { } dependencies { classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.0' - classpath "com.badlogicgames.gdx:gdx-tools:1.9.8" + classpath "com.badlogicgames.gdx:gdx-tools:1.9.9" } } allprojects { - apply plugin: "eclipse" apply plugin: "idea" version = 'release' diff --git a/core/src/io/anuke/mindustry/content/blocks/DebugBlocks.java b/core/src/io/anuke/mindustry/content/blocks/DebugBlocks.java index 9d6c8e1afc..53ac78afb1 100644 --- a/core/src/io/anuke/mindustry/content/blocks/DebugBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/DebugBlocks.java @@ -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 diff --git a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java index 4cb355edef..5e611b762f 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/JoinDialog.java @@ -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, ""); diff --git a/core/src/io/anuke/mindustry/world/blocks/SelectionTrait.java b/core/src/io/anuke/mindustry/world/blocks/SelectionTrait.java index 9c84856aac..8d31879965 100644 --- a/core/src/io/anuke/mindustry/world/blocks/SelectionTrait.java +++ b/core/src/io/anuke/mindustry/world/blocks/SelectionTrait.java @@ -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 holder, Consumer consumer){ - buildItemTable(table, false, holder, consumer); - } - - default void buildItemTable(Table table, boolean nullItem, Supplier holder, Consumer consumer){ Array items = content.items(); ButtonGroup 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); diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java index c7a5737e54..a04472a29f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java @@ -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); } } } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java index 21d50003f1..fdf1034604 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java @@ -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(); diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java b/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java index dd7374536a..222efc9c4b 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java @@ -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 diff --git a/tools/build.gradle b/tools/build.gradle index 876fa569c8..b7e87d5fb1 100644 --- a/tools/build.gradle +++ b/tools/build.gradle @@ -3,7 +3,6 @@ apply plugin: "java" sourceCompatibility = 1.8 sourceSets.main.java.srcDirs = [ "src/" ] - import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.tools.texturepacker.TexturePacker