From daaea591e4b58bb7055a6a9f012da59c9b7ea194 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 11 Dec 2020 11:48:20 -0500 Subject: [PATCH] Implemented #3486 with some minor changes --- core/assets/bundles/bundle.properties | 1 + core/src/mindustry/ui/Links.java | 47 ++++++++++++++----- core/src/mindustry/world/Block.java | 3 +- .../mindustry/world/blocks/defense/Wall.java | 6 --- .../world/blocks/distribution/Router.java | 6 --- .../world/blocks/storage/CoreBlock.java | 2 +- core/src/mindustry/world/meta/BlockGroup.java | 13 ++++- 7 files changed, 51 insertions(+), 27 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 28d9af3072..3446948712 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -13,6 +13,7 @@ link.google-play.description = Google Play store listing link.f-droid.description = F-Droid listing link.wiki.description = Official Mindustry wiki link.suggestions.description = Suggest new features +link.bug.description = Found one? Report it here linkfail = Failed to open link!\nThe URL has been copied to your clipboard. screenshot = Screenshot saved to {0} screenshot.invalid = Map too large, potentially not enough memory for screenshot. diff --git a/core/src/mindustry/ui/Links.java b/core/src/mindustry/ui/Links.java index dd12c675d5..6c5962d11c 100644 --- a/core/src/mindustry/ui/Links.java +++ b/core/src/mindustry/ui/Links.java @@ -4,25 +4,29 @@ import arc.*; import arc.graphics.*; import arc.scene.style.*; import arc.util.*; +import mindustry.*; +import mindustry.core.*; import mindustry.gen.*; import mindustry.graphics.*; +import mindustry.mod.Mods.*; public class Links{ private static LinkEntry[] links; private static void createLinks(){ links = new LinkEntry[]{ - new LinkEntry("discord", "https://discord.gg/mindustry", Icon.discord, Color.valueOf("7289da")), - new LinkEntry("changelog", "https://github.com/Anuken/Mindustry/releases", Icon.list, Pal.accent.cpy()), - new LinkEntry("trello", "https://trello.com/b/aE2tcUwF", Icon.trello, Color.valueOf("026aa7")), - new LinkEntry("wiki", "https://mindustrygame.github.io/wiki/", Icon.book, Color.valueOf("0f142f")), - new LinkEntry("suggestions", "https://github.com/Anuken/Mindustry-Suggestions/issues/new/choose/", Icon.add, Color.valueOf("ebebeb")), - new LinkEntry("reddit", "https://www.reddit.com/r/Mindustry/", Icon.redditAlien, Color.valueOf("ee593b")), - new LinkEntry("itch.io", "https://anuke.itch.io/mindustry", Icon.itchio, Color.valueOf("fa5c5c")), - new LinkEntry("google-play", "https://play.google.com/store/apps/details?id=io.anuke.mindustry", Icon.googleplay, Color.valueOf("689f38")), - new LinkEntry("f-droid", "https://f-droid.org/packages/io.anuke.mindustry/", Icon.android, Color.valueOf("026aa7")), - new LinkEntry("github", "https://github.com/Anuken/Mindustry/", Icon.github, Color.valueOf("24292e")), - new LinkEntry("dev-builds", "https://github.com/Anuken/MindustryBuilds", Icon.githubSquare, Color.valueOf("fafbfc")) + new LinkEntry("discord", "https://discord.gg/mindustry", Icon.discord, Color.valueOf("7289da")), + new LinkEntry("changelog", "https://github.com/Anuken/Mindustry/releases", Icon.list, Pal.accent.cpy()), + new LinkEntry("trello", "https://trello.com/b/aE2tcUwF", Icon.trello, Color.valueOf("026aa7")), + new LinkEntry("wiki", "https://mindustrygame.github.io/wiki/", Icon.book, Color.valueOf("0f142f")), + new LinkEntry("suggestions", "https://github.com/Anuken/Mindustry-Suggestions/issues/new/choose/", Icon.add, Color.valueOf("ebebeb")), + new LinkEntry("reddit", "https://www.reddit.com/r/Mindustry/", Icon.redditAlien, Color.valueOf("ee593b")), + new LinkEntry("itch.io", "https://anuke.itch.io/mindustry", Icon.itchio, Color.valueOf("fa5c5c")), + new LinkEntry("google-play", "https://play.google.com/store/apps/details?id=io.anuke.mindustry", Icon.googleplay, Color.valueOf("689f38")), + new LinkEntry("f-droid", "https://f-droid.org/packages/io.anuke.mindustry/", Icon.android, Color.valueOf("026aa7")), + new LinkEntry("github", "https://github.com/Anuken/Mindustry/", Icon.github, Color.valueOf("24292e")), + new LinkEntry("dev-builds", "https://github.com/Anuken/MindustryBuilds", Icon.githubSquare, Color.valueOf("fafbfc")), + new LinkEntry("bug", report(), Icon.wrench, Color.valueOf("cbd97f")) }; } @@ -48,4 +52,23 @@ public class Links{ this.title = Core.bundle.get("link." + name + ".title", Strings.capitalize(name.replace("-", " "))); } } -} + + private static String report(){ + return "https://github.com/Anuken/Mindustry/issues/new?assignees=&labels=bug&body=" + + Strings.encode(Strings.format( + "**Platform**: `@`\n" + + "\n**Build**: `@`\n" + + "\n**Issue**: *Explain your issue in detail.*\n" + + "\n**Steps to reproduce**: *How you happened across the issue, and what exactly you did to make the bug happen.*\n" + + "\n**Link(s) to mod(s) used**: `@`\n" + + "\n**Save file**: *The (zipped) save file you were playing on when the bug happened. THIS IS REQUIRED FOR ANY ISSUE HAPPENING IN-GAME, REGARDLESS OF WHETHER YOU THINK IT HAPPENS EVERYWHERE. DO NOT DELETE OR OMIT THIS LINE UNLESS YOU ARE SURE THAT THE ISSUE DOES NOT HAPPEN IN-GAME.*\n" + + "\n**Crash report**: *The contents of relevant crash report files. REQUIRED if you are reporting a crash.*\n" + + "\n---\n" + + "\n*Place an X (no spaces) between the brackets to confirm that you have read the line below.*" + + "\n- [ ] **I have updated to the latest release (https://github.com/Anuken/Mindustry/releases) to make sure my issue has not been fixed.**" + + "\n- [ ] **I have searched the closed and open issues to make sure that this problem has not already been reported.**", + OS.isAndroid ? "Android " + Core.app.getVersion() : (System.getProperty("os.name") + (OS.is64Bit ? " x64" : " x32")), + Version.combined(), + Vars.mods.list().any() ? Vars.mods.list().select(LoadedMod::enabled).map(l -> l.meta.author + "/" + l.name + ":" + l.meta.version) : "none")); + } +} \ No newline at end of file diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 0f3d60bd75..59a48777b4 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -377,7 +377,8 @@ public class Block extends UnlockableContent{ public boolean canReplace(Block other){ if(other.alwaysReplace) return true; - return (other != this || rotate) && this.group != BlockGroup.none && other.group == this.group && (size == other.size || (size >= other.size && subclass != null && subclass == other.subclass)); + return (other != this || rotate) && this.group != BlockGroup.none && other.group == this.group && + (size == other.size || (size >= other.size && ((subclass != null && subclass == other.subclass) || group.anyReplace))); } /** @return a possible replacement for this block when placed in a line by the player. */ diff --git a/core/src/mindustry/world/blocks/defense/Wall.java b/core/src/mindustry/world/blocks/defense/Wall.java index a23a2583cd..6f59fb8e34 100644 --- a/core/src/mindustry/world/blocks/defense/Wall.java +++ b/core/src/mindustry/world/blocks/defense/Wall.java @@ -69,12 +69,6 @@ public class Wall extends Block{ return new TextureRegion[]{Core.atlas.find(Core.atlas.has(name) ? name : name + "1")}; } - @Override - public boolean canReplace(Block other){ - if(other.alwaysReplace) return true; - return (other != this || rotate) && this.group != BlockGroup.none && other.group == this.group && other != this && size >= other.size; - } - public class WallBuild extends Building{ public float hit; diff --git a/core/src/mindustry/world/blocks/distribution/Router.java b/core/src/mindustry/world/blocks/distribution/Router.java index 169f3b4e60..141f188446 100644 --- a/core/src/mindustry/world/blocks/distribution/Router.java +++ b/core/src/mindustry/world/blocks/distribution/Router.java @@ -23,12 +23,6 @@ public class Router extends Block{ noUpdateDisabled = true; } - @Override - public boolean canReplace(Block other){ - if(other.alwaysReplace) return true; - return (other != this || rotate) && this.group != BlockGroup.none && other.group == this.group && size >= other.size; - } - public class RouterBuild extends Building implements ControlBlock{ public Item lastItem; public Tile lastInput; diff --git a/core/src/mindustry/world/blocks/storage/CoreBlock.java b/core/src/mindustry/world/blocks/storage/CoreBlock.java index c161236a6d..5ce949a03f 100644 --- a/core/src/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/mindustry/world/blocks/storage/CoreBlock.java @@ -254,7 +254,7 @@ public class CoreBlock extends StorageBlock{ for(Building other : state.teams.cores(team)){ if(other.tile() == tile) continue; - storageCapacity += other.block.itemCapacity + other.proximity().sum(e -> owns(e) && owns(other, e) ? e.block.itemCapacity : 0); + storageCapacity += other.block.itemCapacity + other.proximity().sum(e -> owns(other, e) ? e.block.itemCapacity : 0); } //Team.sharded.core().items.set(Items.surgeAlloy, 12000) diff --git a/core/src/mindustry/world/meta/BlockGroup.java b/core/src/mindustry/world/meta/BlockGroup.java index 8b73938ec8..690e181b64 100644 --- a/core/src/mindustry/world/meta/BlockGroup.java +++ b/core/src/mindustry/world/meta/BlockGroup.java @@ -1,5 +1,16 @@ package mindustry.world.meta; public enum BlockGroup{ - none, walls, projectors, turrets, transportation, power, liquids, drills, storage, units, logic + none, walls(true), projectors(true), turrets, transportation(true), power, liquids(true), drills, storage, units, logic(true); + + /** if true, any block in this category replaces any other block in this category. */ + public final boolean anyReplace; + + BlockGroup(boolean anyReplace){ + this.anyReplace = anyReplace; + } + + BlockGroup(){ + this(false); + } }