This commit is contained in:
Anuken 2019-10-19 21:09:59 -04:00
parent cc105e5029
commit 00054e2c61
5 changed files with 23 additions and 10 deletions

View File

@ -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

View File

@ -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<BuildRequest> 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.*/

View File

@ -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),

View File

@ -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()){

View File

@ -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);