From 00054e2c61c2bf5446a4fb8e92978f3970086e23 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 19 Oct 2019 21:09:59 -0400 Subject: [PATCH] Bugfixes --- core/assets/bundles/bundle.properties | 4 +++- core/src/io/anuke/mindustry/game/Schematics.java | 2 +- core/src/io/anuke/mindustry/input/Binding.java | 3 ++- core/src/io/anuke/mindustry/input/DesktopInput.java | 12 ++++++++---- .../anuke/mindustry/ui/dialogs/SchematicsDialog.java | 12 +++++++++--- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 9cc6fd0b5a..226fbf326f 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -33,6 +33,7 @@ schematic.exportfile = Export File schematic.importfile = Import File schematic.browseworkshop = Browse Workshop schematic.copy = Copy to Clipboard +schematic.copy.import = Import from Clipboard schematic.shareworkshop = Share on Workshop schematic.flip = [accent][[{0}][]/[accent][[{1}][]: Flip Schematic schematic.saved = Schematic saved. @@ -647,7 +648,8 @@ keybind.press.axis = Press an axis or key... keybind.screenshot.name = Map Screenshot keybind.move_x.name = Move x keybind.move_y.name = Move y -keybind.schematic.name = Select Region +keybind.schematic_select.name = Select Region +keybind.schematic_menu.name = Schematic Menu keybind.schematic_flip_x.name = Flip Schematic X keybind.schematic_flip_y.name = Flip Schematic Y keybind.fullscreen.name = Toggle Fullscreen diff --git a/core/src/io/anuke/mindustry/game/Schematics.java b/core/src/io/anuke/mindustry/game/Schematics.java index 14e28f5cc4..9cadd1e090 100644 --- a/core/src/io/anuke/mindustry/game/Schematics.java +++ b/core/src/io/anuke/mindustry/game/Schematics.java @@ -179,7 +179,7 @@ public class Schematics implements Loadable{ /** Creates an array of build requests from a schematic's data, centered on the provided x+y coordinates. */ public Array toRequests(Schematic schem, int x, int y){ - return schem.tiles.map(t -> new BuildRequest(t.x + x - schem.width/2, t.y + y - schem.height/2, t.rotation, t.block).original(t.x, t.y, schem.width, schem.height).configure(t.config)); + return schem.tiles.map(t -> new BuildRequest(t.x + x - schem.width/2, t.y + y - schem.height/2, t.rotation, t.block).original(t.x, t.y, schem.width, schem.height).configure(t.config)).removeAll(s -> !s.block.isVisible()); } /** Adds a schematic to the list, also copying it into the files.*/ diff --git a/core/src/io/anuke/mindustry/input/Binding.java b/core/src/io/anuke/mindustry/input/Binding.java index cc5e0d3145..bd7cc9b4ac 100644 --- a/core/src/io/anuke/mindustry/input/Binding.java +++ b/core/src/io/anuke/mindustry/input/Binding.java @@ -18,9 +18,10 @@ public enum Binding implements KeyBind{ rotateplaced(KeyCode.R), diagonal_placement(KeyCode.CONTROL_LEFT), pick(KeyCode.MOUSE_MIDDLE), - schematic(KeyCode.F), + schematic_select(KeyCode.F), schematic_flip_x(KeyCode.Z), schematic_flip_y(KeyCode.X), + schematic_menu(KeyCode.T), dash(KeyCode.SHIFT_LEFT), gridMode(KeyCode.BACKTICK), gridModeShift(KeyCode.ALT_LEFT), diff --git a/core/src/io/anuke/mindustry/input/DesktopInput.java b/core/src/io/anuke/mindustry/input/DesktopInput.java index a773ac6812..b705551709 100644 --- a/core/src/io/anuke/mindustry/input/DesktopInput.java +++ b/core/src/io/anuke/mindustry/input/DesktopInput.java @@ -51,7 +51,7 @@ public class DesktopInput extends InputHandler{ b.row(); b.add(Core.bundle.format("cancelbuilding", Core.keybinds.get(Binding.clear_building).key.name())).style(Styles.outlineLabel); b.row(); - b.add(Core.bundle.format("selectschematic", Core.keybinds.get(Binding.schematic).key.name())).style(Styles.outlineLabel); + b.add(Core.bundle.format("selectschematic", Core.keybinds.get(Binding.schematic_select).key.name())).style(Styles.outlineLabel); }).margin(10f); }); @@ -129,7 +129,7 @@ public class DesktopInput extends InputHandler{ drawSelected(sreq.x, sreq.y, sreq.block, getRequest(sreq.x, sreq.y, sreq.block.size, sreq) != null ? Pal.remove : Pal.accent); } - if(Core.input.keyDown(Binding.schematic)){ + if(Core.input.keyDown(Binding.schematic_select)){ drawSelection(schemX, schemY, cursorX, cursorY, Vars.maxSchematicSize); } @@ -289,17 +289,21 @@ public class DesktopInput extends InputHandler{ player.clearBuilding(); } - if(Core.input.keyTap(Binding.schematic)){ + if(Core.input.keyTap(Binding.schematic_select)){ schemX = rawCursorX; schemY = rawCursorY; } + if(Core.input.keyTap(Binding.schematic_menu)){ + ui.schematics.show(); + } + if(Core.input.keyTap(Binding.clear_building)){ lastSchematic = null; selectRequests.clear(); } - if(Core.input.keyRelease(Binding.schematic)){ + if(Core.input.keyRelease(Binding.schematic_select)){ lastSchematic = schematics.create(schemX, schemY, rawCursorX, rawCursorY); useSchematic(lastSchematic); if(selectRequests.isEmpty()){ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/SchematicsDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/SchematicsDialog.java index 539f314c45..c5e9541930 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/SchematicsDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/SchematicsDialog.java @@ -88,6 +88,8 @@ public class SchematicsDialog extends FloatingDialog{ buttons.addImageButton(Icon.pencilSmall, style, () -> { ui.showTextInput("$schematic.rename", "$name", s.name(), res -> { s.tags.put("name", res); + s.save(); + rebuildPane[0].run(); }); }); @@ -142,15 +144,18 @@ public class SchematicsDialog extends FloatingDialog{ TextButtonStyle style = Styles.cleart; t.defaults().size(280f, 60f).left(); t.row(); - t.addImageTextButton("$schematic.copy", Icon.copySmall, style, () -> { + t.addImageTextButton("$schematic.copy.import", Icon.copySmall, style, () -> { dialog.hide(); try{ - schematics.add(schematics.readBase64(Core.app.getClipboardText())); + Schematic s = schematics.readBase64(Core.app.getClipboardText()); + schematics.add(s); + setup(); ui.showInfoFade("$schematic.saved"); + showInfo(s); }catch(Exception e){ ui.showException(e); } - }).marginLeft(12f).disabled(b -> Core.app.getClipboardText() == null || !Core.app.getClipboardText().startsWith("schematicBaseStart")); + }).marginLeft(12f).disabled(b -> Core.app.getClipboardText() == null || !Core.app.getClipboardText().startsWith(schematicBaseStart)); t.row(); t.addImageTextButton("$schematic.importfile", Icon.saveMapSmall, style, () -> platform.showFileChooser(true, schematicExtension, file -> { dialog.hide(); @@ -158,6 +163,7 @@ public class SchematicsDialog extends FloatingDialog{ try{ Schematic s = Schematics.read(file); schematics.add(s); + setup(); showInfo(s); }catch(Exception e){ ui.showException(e);