From 5ec495987e3e541b18a7d4cdf9f90cba9c8a5d49 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 28 Jun 2018 13:25:29 -0400 Subject: [PATCH] Un-broke editor block icons --- .../blocks/distribution/conveyor-arrow.png | Bin 199 -> 0 bytes core/assets/bundles/bundle.properties | 1 + core/src/io/anuke/mindustry/core/UI.java | 6 +++++- .../mindustry/editor/MapEditorDialog.java | 3 ++- .../io/anuke/mindustry/editor/MapRenderer.java | 4 ++-- .../anuke/mindustry/ui/dialogs/SaveDialog.java | 6 ++++-- core/src/io/anuke/mindustry/world/Block.java | 17 ++++++++++++++--- .../anuke/mindustry/world/blocks/OreBlock.java | 9 +++++++++ .../world/blocks/defense/turrets/Turret.java | 8 ++++++++ 9 files changed, 45 insertions(+), 9 deletions(-) delete mode 100644 core/assets-raw/sprites/blocks/distribution/conveyor-arrow.png diff --git a/core/assets-raw/sprites/blocks/distribution/conveyor-arrow.png b/core/assets-raw/sprites/blocks/distribution/conveyor-arrow.png deleted file mode 100644 index fa67ae25f8cd3cf9341cc6a2890b57f893a25619..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqoCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#5u2z0GpofuH;|BIiEBiObAE1aYF-J0b5UwyNotBhd1gt5g1e`0KzJjcI8c$J zr;B5V#O2mA2YDF`IG7wtn2sk|Ur*FA&)DC)OxOPK!c?`mkDn)OS?6%6tD|v`zEx3; nkwa+X5?+T(RhD*Ngc!_tSBmddOEiBDG>pO1)z4*}Q$iB}3+FhS diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 0808e1ffb4..3b7ee3085c 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -154,6 +154,7 @@ text.changelog.error=[scarlet]Error getting changelog!\nCheck your internet conn text.changelog.current=[yellow][[Current version] text.changelog.latest=[orange][[Latest version] text.loading=[accent]Loading... +text.saving=[accent]Saving... text.wave=[orange]Wave {0} text.wave.waiting=Wave in {0} text.waiting=Waiting... diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index 342a3eafc3..20c4499e1d 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -213,7 +213,11 @@ public class UI extends SceneModule{ } public void loadAnd(Callable call){ - loadfrag.show(); + loadAnd("$text.loading", call); + } + + public void loadAnd(String text, Callable call){ + loadfrag.show(text); Timers.run(6f, () -> { call.run(); loadfrag.hide(); diff --git a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java index 8563e01eee..5f57422139 100644 --- a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java @@ -23,6 +23,7 @@ import io.anuke.ucore.core.Inputs; import io.anuke.ucore.core.Timers; import io.anuke.ucore.function.Consumer; import io.anuke.ucore.function.Listenable; +import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Pixmaps; import io.anuke.ucore.input.Input; import io.anuke.ucore.scene.actions.Actions; @@ -582,7 +583,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ for(Block block : Block.all()){ TextureRegion[] regions = block.getCompactIcon(); - if(regions.length == 0) continue; + if(regions.length == 0 || regions[0] == Draw.region("jjfgj")) continue; Stack stack = new Stack(); diff --git a/core/src/io/anuke/mindustry/editor/MapRenderer.java b/core/src/io/anuke/mindustry/editor/MapRenderer.java index 3b6870bb1a..e16d4339f6 100644 --- a/core/src/io/anuke/mindustry/editor/MapRenderer.java +++ b/core/src/io/anuke/mindustry/editor/MapRenderer.java @@ -117,7 +117,7 @@ public class MapRenderer implements Disposable{ TextureRegion region; if(bw != 0) { - region = Draw.region("block-icon-" + wall.name, Draw.region("clear")); + region = wall.getEditorIcon(); if (wall.rotate) { mesh.draw((wx % chunksize) + (wy % chunksize) * chunksize, region, @@ -129,7 +129,7 @@ public class MapRenderer implements Disposable{ region.getRegionWidth(), region.getRegionHeight()); } }else{ - region = Draw.region("block-icon-" + floor.name, Draw.region("clear")); + region = floor.getEditorIcon(); mesh.draw((wx % chunksize) + (wy % chunksize)*chunksize, region, wx * tilesize, wy * tilesize, 8, 8); } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/SaveDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/SaveDialog.java index 082d7751f6..ed686e4239 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/SaveDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/SaveDialog.java @@ -29,8 +29,10 @@ public class SaveDialog extends LoadDialog{ slots.row(); slots.addImageTextButton("$text.save.new", "icon-add", "clear", 14*3, () -> ui.showTextInput("$text.save", "$text.save.newslot", "", text -> { - control.getSaves().addSave(text); - setup(); + ui.loadAnd("$text.saving", () -> { + control.getSaves().addSave(text); + setup(); + }); }) ).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4); } diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 1783f26a25..f0c5c37998 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -45,6 +45,7 @@ public class Block extends BaseBlock implements UnlockableContent{ protected TextureRegion[] blockIcon; protected TextureRegion[] icon; protected TextureRegion[] compactIcon; + protected TextureRegion editorIcon; /**internal name*/ public final String name; @@ -349,6 +350,13 @@ public class Block extends BaseBlock implements UnlockableContent{ } } + public TextureRegion getEditorIcon(){ + if(editorIcon == null){ + editorIcon = Draw.region("block-icon-" + name, Draw.region("clear")); + } + return editorIcon; + } + /**Returns the icon used for displaying this block in the place menu*/ public TextureRegion[] getIcon(){ if(icon == null) { @@ -373,9 +381,12 @@ public class Block extends BaseBlock implements UnlockableContent{ /**Returns a list of icon regions that have been cropped to 8x8*/ public TextureRegion[] getCompactIcon(){ - if(compactIcon == null) { - compactIcon = new TextureRegion[]{iconRegion(Draw.region("block-icon-" + name))}; - } + if(compactIcon == null) { + compactIcon = new TextureRegion[getIcon().length]; + for (int i = 0; i < compactIcon.length; i++) { + compactIcon[i] = iconRegion(getIcon()[i]); + } + } return compactIcon; } diff --git a/core/src/io/anuke/mindustry/world/blocks/OreBlock.java b/core/src/io/anuke/mindustry/world/blocks/OreBlock.java index 15f6ee790d..18fcd86711 100644 --- a/core/src/io/anuke/mindustry/world/blocks/OreBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/OreBlock.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.world.blocks; +import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.MathUtils; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.ItemStack; @@ -21,6 +22,14 @@ public class OreBlock extends Floor { this.edge = base.name; } + @Override + public TextureRegion getEditorIcon(){ + if(editorIcon == null){ + editorIcon = variantRegions[0]; + } + return editorIcon; + } + @Override public void draw(Tile tile){ Draw.rect(variantRegions[Mathf.randomSeed(tile.id(), 0, Math.max(0, variantRegions.length-1))], tile.worldx(), tile.worldy()); diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java index 364210a969..aca15e8733 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java @@ -141,6 +141,14 @@ public abstract class Turret extends Block{ return blockIcon; } + @Override + public TextureRegion[] getCompactIcon(){ + if(compactIcon == null) { + compactIcon = new TextureRegion[]{iconRegion(Draw.region("block-icon-" + name))}; + } + return compactIcon; + } + @Override public void drawSelect(Tile tile){ Draw.color(tile.getTeam().color);