From 7289c1080ca9f97e395eb96f56bd38c310cadfff Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 26 Jul 2018 13:34:20 -0400 Subject: [PATCH] Cleaned up custom game dialog / Disabled saving in sectors --- core/src/io/anuke/mindustry/core/UI.java | 4 +-- ...LevelDialog.java => CustomGameDialog.java} | 33 +++---------------- .../mindustry/ui/dialogs/PausedDialog.java | 11 ++----- 3 files changed, 9 insertions(+), 39 deletions(-) rename core/src/io/anuke/mindustry/ui/dialogs/{LevelDialog.java => CustomGameDialog.java} (81%) diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index fc6d38fd0e..4ce8d6328e 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -43,7 +43,7 @@ public class UI extends SceneModule{ public AboutDialog about; public RestartDialog restart; - public LevelDialog levels; + public CustomGameDialog levels; public MapsDialog maps; public LoadDialog load; public DiscordDialog discord; @@ -154,7 +154,7 @@ public class UI extends SceneModule{ join = new JoinDialog(); discord = new DiscordDialog(); load = new LoadDialog(); - levels = new LevelDialog(); + levels = new CustomGameDialog(); language = new LanguageDialog(); settings = new SettingsMenuDialog(); host = new HostDialog(); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/CustomGameDialog.java similarity index 81% rename from core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java rename to core/src/io/anuke/mindustry/ui/dialogs/CustomGameDialog.java index e8bbfdd562..8e887439be 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/CustomGameDialog.java @@ -8,7 +8,6 @@ import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.maps.Map; import io.anuke.mindustry.ui.BorderImage; import io.anuke.ucore.core.Settings; -import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.scene.event.Touchable; import io.anuke.ucore.scene.ui.ButtonGroup; import io.anuke.ucore.scene.ui.ImageButton; @@ -21,9 +20,9 @@ import io.anuke.ucore.util.Mathf; import static io.anuke.mindustry.Vars.*; -public class LevelDialog extends FloatingDialog{ +public class CustomGameDialog extends FloatingDialog{ - public LevelDialog(){ + public CustomGameDialog(){ super("$text.level.select"); addCloseButton(); shown(this::setup); @@ -115,31 +114,9 @@ public class LevelDialog extends FloatingDialog{ i++; } - ImageButton genb = maps.addImageButton("icon-editor", "clear", 16 * 3, () -> { - hide(); - //TODO - - /* - ui.loadfrag.show(); - - Timers.run(5f, () -> { - Cursors.restoreCursor(); - threads.run(() -> { - world.loadSector(0, 0); - logic.play(); - Gdx.app.postRunnable(ui.loadfrag::hide); - }); - });*/ - }).width(170).fillY().pad(4f).get(); - - genb.top(); - genb.margin(5); - genb.clearChildren(); - genb.add(new BorderImage(Draw.region("icon-generated"), 3f)).size(images); - genb.row(); - genb.add("$text.map.random").growX().wrap().pad(3f).get().setAlignment(Align.center, Align.center); - genb.row(); - genb.add("").pad(3f); + if(world.maps().all().size == 0){ + maps.add("$text.maps.none").pad(50); + } content().add(pane).uniformX(); } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java index 01aab615e1..ae1b598569 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java @@ -43,20 +43,13 @@ public class PausedDialog extends FloatingDialog{ content().row(); content().addButton("$text.savegame", () -> { save.show(); - }); + }).disabled(s -> world.getSector() != null); content().row(); content().addButton("$text.loadgame", () -> { load.show(); }).disabled(b -> Net.active()); - //Local multiplayer is currently functional, but disabled. - /* - content().row(); - content().addButton("$text.addplayers", () -> { - ui.localplayers.show(); - }).disabled(b -> Net.active());*/ - content().row(); content().addButton("$text.hostserver", () -> { @@ -88,7 +81,7 @@ public class PausedDialog extends FloatingDialog{ state.set(State.playing); }); content().addRowImageTextButton("$text.settings", "icon-tools", isize, ui.settings::show); - content().addRowImageTextButton("$text.save", "icon-save", isize, save::show); + content().addRowImageTextButton("$text.save", "icon-save", isize, save::show).disabled(b -> world.getSector() != null); content().row();