From 4f9e64588f35482d5d78899e39f4f8b7be190772 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 6 Feb 2019 13:20:15 -0500 Subject: [PATCH 1/2] Hid irrelevant entries in placement menu --- .../ui/fragments/PlacementFragment.java | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index d28a1aab30..9428fe510c 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -33,6 +33,8 @@ public class PlacementFragment extends Fragment{ final int rowWidth = 4; Array returnArray = new Array<>(); + Array returnCatArray = new Array<>(); + boolean[] categoryEmpty = new boolean[Category.values().length]; Category currentCategory = Category.distribution; Block hovered, lastDisplay; Tile lastHover; @@ -56,13 +58,18 @@ public class PlacementFragment extends Fragment{ public PlacementFragment(){ Events.on(WorldLoadEvent.class, event -> { - currentCategory = Category.turret; - Group group = toggler.getParent(); - toggler.remove(); - build(group); + control.input(0).block = null; + rebuild(); }); } + void rebuild(){ + currentCategory = Category.turret; + Group group = toggler.getParent(); + toggler.remove(); + build(group); + } + boolean gridUpdate(InputHandler input){ if(Core.input.keyDown(Binding.pick)){ //mouse eyedropper select Tile tile = world.tileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y); @@ -121,12 +128,14 @@ public class PlacementFragment extends Fragment{ group.setMinCheckCount(0); for(Block block : getByCategory(currentCategory)){ - if(index++ % rowWidth == 0){ blockTable.row(); } - boolean[] unlocked = {false}; + if(!data.isUnlocked(block)){ + blockTable.add().size(46); + continue; + } ImageButton button = blockTable.addImageButton("icon-locked", "select", 8 * 4, () -> { if(data.isUnlocked(block)){ @@ -134,21 +143,14 @@ public class PlacementFragment extends Fragment{ } }).size(46f).group(group).get(); + button.replaceImage(new Image(block.icon(Icon.medium))); + button.update(() -> { //color unplacable things gray boolean ulock = data.isUnlocked(block); TileEntity core = players[0].getClosestCore(); Color color = core != null && (core.items.has(block.buildRequirements) || state.rules.infiniteResources) ? Color.WHITE : ulock ? Color.GRAY : Color.WHITE; button.forEach(elem -> elem.setColor(color)); button.setChecked(input.block == block); - - if(ulock == unlocked[0]) return; - unlocked[0] = ulock; - - if(!ulock){ - button.replaceImage(new Image("icon-locked")); - }else{ - button.replaceImage(new Image(block.icon(Icon.medium))); - } }); button.hovered(() -> hovered = block); @@ -246,15 +248,25 @@ public class PlacementFragment extends Fragment{ ButtonGroup group = new ButtonGroup<>(); + //update category empty values for(Category cat : Category.values()){ - if(getByCategory(cat).isEmpty()) continue; + Array blocks = getByCategory(cat); + categoryEmpty[cat.ordinal()] = returnArray.isEmpty() || !returnArray.first().unlocked(); + } + + int f = 0; + for(Category cat : getCategories()){ + if(f++ % 2 == 0) categories.row(); + + if(categoryEmpty[cat.ordinal()]){ + categories.addImage("flat"); + continue; + } categories.addImageButton("icon-" + cat.name(), "clear-toggle", 16 * 2, () -> { currentCategory = cat; rebuildCategory.run(); }).group(group).update(i -> i.setChecked(currentCategory == cat)); - - if(cat.ordinal() % 2 == 1) categories.row(); } }).touchable(Touchable.enabled); @@ -265,6 +277,13 @@ public class PlacementFragment extends Fragment{ }); }); } + + Array getCategories(){ + returnCatArray.clear(); + returnCatArray.addAll(Category.values()); + returnCatArray.sort((c1, c2) -> Boolean.compare(categoryEmpty[c1.ordinal()], categoryEmpty[c2.ordinal()])); + return returnCatArray; + } Array getByCategory(Category cat){ returnArray.clear(); @@ -273,6 +292,7 @@ public class PlacementFragment extends Fragment{ returnArray.add(block); } } + returnArray.sort((b1, b2) -> -Boolean.compare(b1.unlocked(), b2.unlocked())); return returnArray; } From 25658f2a0aac1a5b30b59e6b4d06a149a9408cc1 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 6 Feb 2019 13:59:10 -0500 Subject: [PATCH 2/2] Fixed build shader / Server now displays map directory --- core/assets/shaders/blockbuild.fragment | 9 ++------- core/src/io/anuke/mindustry/content/Blocks.java | 3 ++- .../mindustry/ui/fragments/PlacementFragment.java | 2 +- .../src/io/anuke/mindustry/server/ServerControl.java | 11 ++++++++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/assets/shaders/blockbuild.fragment b/core/assets/shaders/blockbuild.fragment index e683997ba4..858018291f 100644 --- a/core/assets/shaders/blockbuild.fragment +++ b/core/assets/shaders/blockbuild.fragment @@ -22,7 +22,7 @@ bool id(vec2 coords, vec4 base){ } bool cont(vec2 T, vec2 v){ - float step = 1.0; + const float step = 3.0; vec4 base = texture2D(u_texture, T); return base.a > 0.1 && (id(T + vec2(0, step) * v, base) || id(T + vec2(0, -step) * v, base) || @@ -41,13 +41,8 @@ void main() { vec2 center = ((u_uv + u_uv2)/2.0 - u_uv) /v; float dst = (abs(center.x - coords.x) + abs(center.y - coords.y))/2.0; - float chance = 1.0; - if(u_progress > 0.8){ - chance = 1.0-(u_progress-0.8)*5.0; - } - - if((mod(u_time / 1.5 + value, 20.0) < 5.0 && cont(t, v))){ + if((mod(u_time / 1.5 + value, 20.0) < 15.0 && cont(t, v))){ gl_FragColor = u_color; }else if(dst > (1.0-u_progress) * (center.x)){ gl_FragColor = color; diff --git a/core/src/io/anuke/mindustry/content/Blocks.java b/core/src/io/anuke/mindustry/content/Blocks.java index 8a7dd65867..2e13592904 100644 --- a/core/src/io/anuke/mindustry/content/Blocks.java +++ b/core/src/io/anuke/mindustry/content/Blocks.java @@ -673,9 +673,10 @@ public class Blocks implements ContentList{ }}; junction = new Junction("junction"){{ - requirements(Category.distribution, ItemStack.with(Items.copper, 2)); + requirements(Category.distribution, ItemStack.with(Items.copper, 3)); speed = 26; capacity = 32; + health = 25; }}; itemBridge = new BufferedItemBridge("bridge-conveyor"){{ diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index 9428fe510c..6e96893412 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -251,7 +251,7 @@ public class PlacementFragment extends Fragment{ //update category empty values for(Category cat : Category.values()){ Array blocks = getByCategory(cat); - categoryEmpty[cat.ordinal()] = returnArray.isEmpty() || !returnArray.first().unlocked(); + categoryEmpty[cat.ordinal()] = blocks.isEmpty() || !blocks.first().unlocked(); } int f = 0; diff --git a/server/src/io/anuke/mindustry/server/ServerControl.java b/server/src/io/anuke/mindustry/server/ServerControl.java index a35e56cce4..55849d4765 100644 --- a/server/src/io/anuke/mindustry/server/ServerControl.java +++ b/server/src/io/anuke/mindustry/server/ServerControl.java @@ -244,10 +244,15 @@ public class ServerControl implements ApplicationListener{ }); handler.register("maps", "Display all available maps.", arg -> { - info("Maps:"); - for(Map map : world.maps.all()){ - info(" &ly{0}: &lb&fi{1} / {2}x{3}", map.name, map.custom ? "Custom" : "Default", map.meta.width, map.meta.height); + if(!world.maps.all().isEmpty()){ + info("Maps:"); + for(Map map : world.maps.all()){ + info(" &ly{0}: &lb&fi{1} / {2}x{3}", map.name, map.custom ? "Custom" : "Default", map.meta.width, map.meta.height); + } + }else{ + info("No maps found."); } + info("&lyMap directory: &lb&fi{0}", customMapDirectory.file().getAbsoluteFile().toString()); }); handler.register("status", "Display server status.", arg -> {