From b2341bf75ca84b39dfc56759b6ecba42aa700790 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 13 May 2019 11:31:25 -0400 Subject: [PATCH] Added map default rule editing --- core/assets/bundles/bundle.properties | 1 + .../anuke/mindustry/editor/MapEditorDialog.java | 5 +++++ .../io/anuke/mindustry/editor/MapInfoDialog.java | 15 +++++++++------ .../io/anuke/mindustry/server/ServerLauncher.java | 2 -- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 649d55e624..3c8f51da08 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -199,6 +199,7 @@ editor.mapinfo = Map Info editor.author = Author: editor.description = Description: editor.waves = Waves: +editor.rules = Rules: waves.title = Waves waves.remove = Remove waves.never = diff --git a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java index 0e66c97632..b8788df589 100644 --- a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java @@ -42,6 +42,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ private MapGenerateDialog generateDialog; private ScrollPane pane; private FloatingDialog menu; + private Rules lastSavedRules; private boolean saved = false; private boolean shownWithMap = false; private Array blocksOut = new Array<>(); @@ -193,6 +194,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ editor.clearOp(); Core.scene.setScrollFocus(view); if(!shownWithMap){ + state.rules = new Rules(); editor.beginEdit(200, 200); } shownWithMap = false; @@ -216,12 +218,15 @@ public class MapEditorDialog extends Dialog implements Disposable{ state.set(State.menu); shownWithMap = true; show(); + state.rules = (lastSavedRules == null ? new Rules() : lastSavedRules); + lastSavedRules = null; editor.renderer().updateAll(); } private void playtest(){ menu.hide(); ui.loadAnd(() -> { + lastSavedRules = state.rules; hide(); //only reset the player; logic.reset() will clear entities, which we do not want player.reset(); diff --git a/core/src/io/anuke/mindustry/editor/MapInfoDialog.java b/core/src/io/anuke/mindustry/editor/MapInfoDialog.java index a422552312..dbe9ed3cbf 100644 --- a/core/src/io/anuke/mindustry/editor/MapInfoDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapInfoDialog.java @@ -4,12 +4,16 @@ import io.anuke.arc.Core; import io.anuke.arc.collection.ObjectMap; import io.anuke.arc.scene.ui.TextArea; import io.anuke.arc.scene.ui.TextField; +import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.Platform; +import io.anuke.mindustry.game.Rules; +import io.anuke.mindustry.ui.dialogs.CustomRulesDialog; import io.anuke.mindustry.ui.dialogs.FloatingDialog; public class MapInfoDialog extends FloatingDialog{ private final MapEditor editor; private final WaveInfoDialog waveinfo; + private final CustomRulesDialog ruleinfo = new CustomRulesDialog(); public MapInfoDialog(MapEditor editor){ super("$editor.mapinfo"); @@ -54,14 +58,13 @@ public class MapInfoDialog extends FloatingDialog{ }).size(400, 55f).get(); author.setMessageText("$unknown"); + cont.row(); + cont.add("$editor.rules").padRight(8).left(); + cont.addButton("$edit", () -> ruleinfo.show(Vars.state.rules, () -> Vars.state.rules = new Rules())).left().width(200f);; + cont.row(); cont.add("$editor.waves").padRight(8).left(); - cont.table(t -> { - t.add().growX(); - t.label(() -> tags.containsKey("waves") ? "" : Core.bundle.get("editor.default")).left(); - t.add().growX(); - t.addButton("$edit", waveinfo::show).growY().width(200f); - }).size(400, 55f); + cont.addButton("$edit", waveinfo::show).left().width(200f); name.change(); description.change(); diff --git a/server/src/io/anuke/mindustry/server/ServerLauncher.java b/server/src/io/anuke/mindustry/server/ServerLauncher.java index fcad8b324e..06f842c418 100644 --- a/server/src/io/anuke/mindustry/server/ServerLauncher.java +++ b/server/src/io/anuke/mindustry/server/ServerLauncher.java @@ -8,10 +8,8 @@ public class ServerLauncher{ public static void main(String[] args){ try{ - Net.setClientProvider(new ArcNetClient()); Net.setServerProvider(new ArcNetServer()); - new HeadlessApplication(new MindustryServer(args), null, throwable -> CrashSender.send(throwable, f -> {})); }catch(Throwable t){ CrashSender.send(t, f -> {});