Schematic import
This commit is contained in:
@@ -28,7 +28,10 @@ load.mod = Mods
|
|||||||
schematic = Schematic
|
schematic = Schematic
|
||||||
schematic.add = Save Schematic...
|
schematic.add = Save Schematic...
|
||||||
schematics = Schematics
|
schematics = Schematics
|
||||||
|
schematic.import = Import Schematic...
|
||||||
schematic.exportfile = Export File
|
schematic.exportfile = Export File
|
||||||
|
schematic.importfile = Import File
|
||||||
|
schematic.browseworkshop = Browse Workshop
|
||||||
schematic.copy = Copy to Clipboard
|
schematic.copy = Copy to 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
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ public class Vars implements Loadable{
|
|||||||
public static final int maxBrokenBlocks = 256;
|
public static final int maxBrokenBlocks = 256;
|
||||||
/** Maximum schematic size.*/
|
/** Maximum schematic size.*/
|
||||||
public static final int maxSchematicSize = 32;
|
public static final int maxSchematicSize = 32;
|
||||||
|
/** All schematic base64 starts with this string.*/
|
||||||
|
public static final String schematicBaseStart ="bXNjaAB";
|
||||||
/** IO buffer size. */
|
/** IO buffer size. */
|
||||||
public static final int bufferSize = 8192;
|
public static final int bufferSize = 8192;
|
||||||
/** global charset, since Android doesn't support the Charsets class */
|
/** global charset, since Android doesn't support the Charsets class */
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
lastSchematic.tags.put("name", text);
|
lastSchematic.tags.put("name", text);
|
||||||
schematics.add(lastSchematic);
|
schematics.add(lastSchematic);
|
||||||
ui.showInfoFade("$schematic.saved");
|
ui.showInfoFade("$schematic.saved");
|
||||||
//ui.schematics.showInfo(lastSchematic);
|
ui.schematics.showInfo(lastSchematic);
|
||||||
});
|
});
|
||||||
}).colspan(2).size(250f, 50f);
|
}).colspan(2).size(250f, 50f);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public class FloatingDialog extends Dialog{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCloseButton(){
|
public void addCloseButton(){
|
||||||
|
buttons.defaults().size(210f, 64f);
|
||||||
buttons.addImageTextButton("$back", Icon.arrowLeft, this::hide).size(210f, 64f);
|
buttons.addImageTextButton("$back", Icon.arrowLeft, this::hide).size(210f, 64f);
|
||||||
|
|
||||||
keyDown(key -> {
|
keyDown(key -> {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class SchematicsDialog extends FloatingDialog{
|
|||||||
|
|
||||||
shouldPause = true;
|
shouldPause = true;
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
|
buttons.addImageTextButton("$schematic.import", Icon.loadMapSmall, this::showImport);
|
||||||
shown(this::setup);
|
shown(this::setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,11 +81,9 @@ public class SchematicsDialog extends FloatingDialog{
|
|||||||
showInfo(s);
|
showInfo(s);
|
||||||
});
|
});
|
||||||
|
|
||||||
//if(s.isWorkshop()){
|
|
||||||
buttons.addImageButton(Icon.loadMapSmall, style, () -> {
|
buttons.addImageButton(Icon.loadMapSmall, style, () -> {
|
||||||
showExport(s);
|
showExport(s);
|
||||||
});
|
});
|
||||||
//}
|
|
||||||
|
|
||||||
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 -> {
|
||||||
@@ -131,6 +130,49 @@ public class SchematicsDialog extends FloatingDialog{
|
|||||||
info.show(schematic);
|
info.show(schematic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showImport(){
|
||||||
|
FloatingDialog dialog = new FloatingDialog("$editor.export");
|
||||||
|
dialog.cont.pane(p -> {
|
||||||
|
p.margin(10f);
|
||||||
|
p.table(Tex.button, t -> {
|
||||||
|
TextButtonStyle style = Styles.cleart;
|
||||||
|
t.defaults().size(280f, 60f).left();
|
||||||
|
t.row();
|
||||||
|
t.addImageTextButton("$schematic.copy", Icon.copySmall, style, () -> {
|
||||||
|
dialog.hide();
|
||||||
|
try{
|
||||||
|
schematics.add(schematics.readBase64(Core.app.getClipboardText()));
|
||||||
|
ui.showInfoFade("$schematic.saved");
|
||||||
|
}catch(Exception e){
|
||||||
|
ui.showException(e);
|
||||||
|
}
|
||||||
|
}).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();
|
||||||
|
|
||||||
|
try{
|
||||||
|
Schematic s = Schematics.read(file);
|
||||||
|
schematics.add(s);
|
||||||
|
showInfo(s);
|
||||||
|
}catch(Exception e){
|
||||||
|
ui.showException(e);
|
||||||
|
}
|
||||||
|
})).marginLeft(12f);
|
||||||
|
t.row();
|
||||||
|
if(steam){
|
||||||
|
t.addImageTextButton("$schematic.browseworkshop", Icon.wikiSmall, style, () -> {
|
||||||
|
dialog.hide();
|
||||||
|
platform.openWorkshop();
|
||||||
|
}).marginLeft(12f);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.addCloseButton();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
public void showExport(Schematic s){
|
public void showExport(Schematic s){
|
||||||
FloatingDialog dialog = new FloatingDialog("$editor.export");
|
FloatingDialog dialog = new FloatingDialog("$editor.export");
|
||||||
dialog.cont.pane(p -> {
|
dialog.cont.pane(p -> {
|
||||||
@@ -138,10 +180,12 @@ public class SchematicsDialog extends FloatingDialog{
|
|||||||
p.table(Tex.button, t -> {
|
p.table(Tex.button, t -> {
|
||||||
TextButtonStyle style = Styles.cleart;
|
TextButtonStyle style = Styles.cleart;
|
||||||
t.defaults().size(280f, 60f).left();
|
t.defaults().size(280f, 60f).left();
|
||||||
t.addImageTextButton("$schematic.shareworkshop", Icon.wikiSmall, style, () -> {
|
if(steam){
|
||||||
|
t.addImageTextButton("$schematic.shareworkshop", Icon.wikiSmall, style, () -> {
|
||||||
|
|
||||||
}).marginLeft(12f);
|
}).marginLeft(12f);
|
||||||
t.row();
|
t.row();
|
||||||
|
}
|
||||||
t.addImageTextButton("$schematic.copy", Icon.copySmall, style, () -> {
|
t.addImageTextButton("$schematic.copy", Icon.copySmall, style, () -> {
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
ui.showInfoFade("$copied");
|
ui.showInfoFade("$copied");
|
||||||
|
|||||||
@@ -92,6 +92,10 @@ public class SWorkshop implements SteamUGCCallback{
|
|||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void publishSchematic(Schematic schematic){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void viewMapListingInfo(Map map){
|
public void viewMapListingInfo(Map map){
|
||||||
String id = map.tags.get("steamid");
|
String id = map.tags.get("steamid");
|
||||||
long handle = Strings.parseLong(id, -1);
|
long handle = Strings.parseLong(id, -1);
|
||||||
|
|||||||
Reference in New Issue
Block a user