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.importfile = Import File
schematic.browseworkshop = Browse Workshop schematic.browseworkshop = Browse Workshop
schematic.copy = Copy to Clipboard schematic.copy = Copy to Clipboard
schematic.copy.import = Import from Clipboard
schematic.shareworkshop = Share on Workshop schematic.shareworkshop = Share on Workshop
schematic.flip = [accent][[{0}][]/[accent][[{1}][]: Flip Schematic schematic.flip = [accent][[{0}][]/[accent][[{1}][]: Flip Schematic
schematic.saved = Schematic saved. schematic.saved = Schematic saved.
@ -647,7 +648,8 @@ keybind.press.axis = Press an axis or key...
keybind.screenshot.name = Map Screenshot keybind.screenshot.name = Map Screenshot
keybind.move_x.name = Move x keybind.move_x.name = Move x
keybind.move_y.name = Move y 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_x.name = Flip Schematic X
keybind.schematic_flip_y.name = Flip Schematic Y keybind.schematic_flip_y.name = Flip Schematic Y
keybind.fullscreen.name = Toggle Fullscreen 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. */ /** 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){ 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.*/ /** 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), rotateplaced(KeyCode.R),
diagonal_placement(KeyCode.CONTROL_LEFT), diagonal_placement(KeyCode.CONTROL_LEFT),
pick(KeyCode.MOUSE_MIDDLE), pick(KeyCode.MOUSE_MIDDLE),
schematic(KeyCode.F), schematic_select(KeyCode.F),
schematic_flip_x(KeyCode.Z), schematic_flip_x(KeyCode.Z),
schematic_flip_y(KeyCode.X), schematic_flip_y(KeyCode.X),
schematic_menu(KeyCode.T),
dash(KeyCode.SHIFT_LEFT), dash(KeyCode.SHIFT_LEFT),
gridMode(KeyCode.BACKTICK), gridMode(KeyCode.BACKTICK),
gridModeShift(KeyCode.ALT_LEFT), gridModeShift(KeyCode.ALT_LEFT),

View File

@ -51,7 +51,7 @@ public class DesktopInput extends InputHandler{
b.row(); b.row();
b.add(Core.bundle.format("cancelbuilding", Core.keybinds.get(Binding.clear_building).key.name())).style(Styles.outlineLabel); b.add(Core.bundle.format("cancelbuilding", Core.keybinds.get(Binding.clear_building).key.name())).style(Styles.outlineLabel);
b.row(); 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); }).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); 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); drawSelection(schemX, schemY, cursorX, cursorY, Vars.maxSchematicSize);
} }
@ -289,17 +289,21 @@ public class DesktopInput extends InputHandler{
player.clearBuilding(); player.clearBuilding();
} }
if(Core.input.keyTap(Binding.schematic)){ if(Core.input.keyTap(Binding.schematic_select)){
schemX = rawCursorX; schemX = rawCursorX;
schemY = rawCursorY; schemY = rawCursorY;
} }
if(Core.input.keyTap(Binding.schematic_menu)){
ui.schematics.show();
}
if(Core.input.keyTap(Binding.clear_building)){ if(Core.input.keyTap(Binding.clear_building)){
lastSchematic = null; lastSchematic = null;
selectRequests.clear(); selectRequests.clear();
} }
if(Core.input.keyRelease(Binding.schematic)){ if(Core.input.keyRelease(Binding.schematic_select)){
lastSchematic = schematics.create(schemX, schemY, rawCursorX, rawCursorY); lastSchematic = schematics.create(schemX, schemY, rawCursorX, rawCursorY);
useSchematic(lastSchematic); useSchematic(lastSchematic);
if(selectRequests.isEmpty()){ if(selectRequests.isEmpty()){

View File

@ -88,6 +88,8 @@ public class SchematicsDialog extends FloatingDialog{
buttons.addImageButton(Icon.pencilSmall, style, () -> { buttons.addImageButton(Icon.pencilSmall, style, () -> {
ui.showTextInput("$schematic.rename", "$name", s.name(), res -> { ui.showTextInput("$schematic.rename", "$name", s.name(), res -> {
s.tags.put("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; TextButtonStyle style = Styles.cleart;
t.defaults().size(280f, 60f).left(); t.defaults().size(280f, 60f).left();
t.row(); t.row();
t.addImageTextButton("$schematic.copy", Icon.copySmall, style, () -> { t.addImageTextButton("$schematic.copy.import", Icon.copySmall, style, () -> {
dialog.hide(); dialog.hide();
try{ try{
schematics.add(schematics.readBase64(Core.app.getClipboardText())); Schematic s = schematics.readBase64(Core.app.getClipboardText());
schematics.add(s);
setup();
ui.showInfoFade("$schematic.saved"); ui.showInfoFade("$schematic.saved");
showInfo(s);
}catch(Exception e){ }catch(Exception e){
ui.showException(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.row();
t.addImageTextButton("$schematic.importfile", Icon.saveMapSmall, style, () -> platform.showFileChooser(true, schematicExtension, file -> { t.addImageTextButton("$schematic.importfile", Icon.saveMapSmall, style, () -> platform.showFileChooser(true, schematicExtension, file -> {
dialog.hide(); dialog.hide();
@ -158,6 +163,7 @@ public class SchematicsDialog extends FloatingDialog{
try{ try{
Schematic s = Schematics.read(file); Schematic s = Schematics.read(file);
schematics.add(s); schematics.add(s);
setup();
showInfo(s); showInfo(s);
}catch(Exception e){ }catch(Exception e){
ui.showException(e); ui.showException(e);