MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / Launch

Class Launch

src/main/java/fielded/plugins/Launch.kt:23–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21import java.io.IOException
22import java.util.zip.ZipInputStream
23import java.util.zip.ZipEntry
24import java.io.FileInputStream
25import java.util.function.Supplier
26
27class Launch(val root: Box) : Box() {
28
29 init {
30 properties.put(Commands.commands, Supplier<Map<field.utility.Pair<String, String>, Runnable>> {
31
32 val m = LinkedHashMap<field.utility.Pair<String, String>, Runnable>()
33
34 m.put(field.utility.Pair("Open", "Open a `.field2` file in a new Field"), Runnable {
35 if (openField2File())
36 {
37 Drawing.notify("Opening...", root, 200);
38 }
39 })
40
41 m
42 })
43 }
44
45
46 fun openField2File(): Boolean {
47 return stackPush().use {
48 val aFilterPatterns = it.mallocPointer(1)
49
50// aFilterPatterns.put(it.UTF8("*.field2"))
51 aFilterPatterns.flip()
52 var fn = TinyFileDialogs.tinyfd_openFileDialog("Open File(s)", FieldBox.workspace + "/", aFilterPatterns, ".field2 files", false)
53 if (fn != null) {
54 val ff = File(fn)
55 if (ff.exists()) {
56 openInNewProcess(ff.name, ff.parentFile.absolutePath + "/")
57 return@use true
58 }
59 }
60 false
61 }
62 }
63
64 fun getSaveFile(): String? {
65 return stackPush().use {
66 val aFilterPatterns = it.mallocPointer(1)
67
68// aFilterPatterns.put(it.UTF8("*.zip"))
69
70 aFilterPatterns.flip()
71 val fn = TinyFileDialogs.tinyfd_saveFileDialog("Save Bundle", System.getProperty("user.home"), aFilterPatterns, ".field2.zip bundle file")
72 fn
73 }
74 }
75
76 fun downloadDecompressAndOpen(name: String, url: String): Boolean {
77
78 val workspace = FieldBox.workspace
79 val targetName = if (File(workspace, name).exists()) {
80 var index = 0

Callers 2

bundleNowMethod · 0.85
loadedMethod · 0.85

Calls 3

PairMethod · 0.80
putMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected