From 2a9f362e15748f42bac06091b523bf9c0aa50a1e Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 29 Nov 2020 13:59:09 -0500 Subject: [PATCH] Fixed #3654 --- core/src/mindustry/Vars.java | 2 ++ core/src/mindustry/ai/Pathfinder.java | 5 +++-- core/src/mindustry/core/UI.java | 2 +- core/src/mindustry/ui/dialogs/ModsDialog.java | 10 +++++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/src/mindustry/Vars.java b/core/src/mindustry/Vars.java index 8269c05b06..d5b9778f67 100644 --- a/core/src/mindustry/Vars.java +++ b/core/src/mindustry/Vars.java @@ -47,6 +47,8 @@ public class Vars implements Loadable{ public static final int bufferSize = 8192; /** global charset, since Android doesn't support the Charsets class */ public static final Charset charset = Charset.forName("UTF-8"); + /** mods suggested for import */ + public static final String[] suggestedMods = {""}; /** main application name, capitalized */ public static final String appName = "Mindustry"; /** URL for itch.io donations. */ diff --git a/core/src/mindustry/ai/Pathfinder.java b/core/src/mindustry/ai/Pathfinder.java index 392481b3ac..c5b03f40bd 100644 --- a/core/src/mindustry/ai/Pathfinder.java +++ b/core/src/mindustry/ai/Pathfinder.java @@ -13,6 +13,7 @@ import mindustry.game.EventType.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.world.*; +import mindustry.world.blocks.storage.*; import mindustry.world.meta.*; import static mindustry.Vars.*; @@ -115,7 +116,7 @@ public class Pathfinder implements Runnable{ } return PathTile.get( - tile.build == null || !tile.solid() ? 0 : Math.min((int)(tile.build.health / 40), 80), + tile.build == null || !tile.solid() || tile.block() instanceof CoreBlock ? 0 : Math.min((int)(tile.build.health / 40), 80), tile.getTeamID(), tile.solid(), tile.floor().isLiquid, @@ -458,7 +459,7 @@ public class Pathfinder implements Runnable{ /** costs of getting to a specific tile */ public int[][] weights; /** search IDs of each position - the highest, most recent search is prioritized and overwritten */ - int[][] searches; + public int[][] searches; /** search frontier, these are Pos objects */ IntQueue frontier = new IntQueue(); /** all target positions; these positions have a cost of 0, and must be synchronized on! */ diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index 4437bb4d48..3b7504be6d 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -258,11 +258,11 @@ public class UI implements ApplicationListener, Loadable{ TextField field = cont.field(def, t -> {}).size(330f, 50f).get(); field.setFilter((f, c) -> field.getText().length() < textLength && filter.acceptChar(f, c)); buttons.defaults().size(120, 54).pad(4); + buttons.button("@cancel", this::hide); buttons.button("@ok", () -> { confirmed.get(field.getText()); hide(); }).disabled(b -> field.getText().isEmpty()); - buttons.button("@cancel", this::hide); keyDown(KeyCode.enter, () -> { String text = field.getText(); if(!text.isEmpty()){ diff --git a/core/src/mindustry/ui/dialogs/ModsDialog.java b/core/src/mindustry/ui/dialogs/ModsDialog.java index 866c3460e4..63b94b277b 100644 --- a/core/src/mindustry/ui/dialogs/ModsDialog.java +++ b/core/src/mindustry/ui/dialogs/ModsDialog.java @@ -102,12 +102,16 @@ public class ModsDialog extends BaseDialog{ t.button("@mod.import.github", Icon.github, bstyle, () -> { dialog.hide(); + var modString = Core.settings.getString("lastmod", ""); + var suggested = Structs.random(suggestedMods); - ui.showTextInput("@mod.import.github", "", 64, Core.settings.getString("lastmod", "Anuken/ExampleMod"), text -> { - Core.settings.put("lastmod", text); + ui.showTextInput("@mod.import.github", "", 64, modString.isEmpty() ? suggested : modString, text -> { + if(!modString.isEmpty() || !Structs.eq(suggested, text)){ + Core.settings.put("lastmod", text); + } ui.loadfrag.show(); - //Try to download the 6.0 branch first, but if it doesn't exist try master. + //Try to download the 6.0 branch first, but if it doesn't exist, try master. githubImport("6.0", text, e1 -> { githubImport("master", text, e2 -> { githubImport("main", text, e3 -> {