aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam NAILI2018-02-01 23:28:43 +0100
committerAdam NAILI2018-02-01 23:28:43 +0100
commite6cad7f280c3e4c5ef1ad16d69fc341320777834 (patch)
tree81998f6047dcb1f07bf68388e70caeb3ab699b04
parent237606e9d76d3e65fe86e8be8b79d953f7c579fc (diff)
downloadwallj-e6cad7f280c3e4c5ef1ad16d69fc341320777834.tar.gz
Handling of -Dlevels option and default map when launching from a command line
-rw-r--r--src/main/java/fr/umlv/java/wallj/Main.java27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/Main.java b/src/main/java/fr/umlv/java/wallj/Main.java
index 5f0ca99..946a61c 100644
--- a/src/main/java/fr/umlv/java/wallj/Main.java
+++ b/src/main/java/fr/umlv/java/wallj/Main.java
@@ -8,26 +8,29 @@ import fr.umlv.zen5.Application;
8 8
9import java.awt.*; 9import java.awt.*;
10import java.io.IOException; 10import java.io.IOException;
11import java.net.URI;
11import java.net.URISyntaxException; 12import java.net.URISyntaxException;
12import java.nio.file.Path; 13import java.nio.file.*;
13import java.nio.file.Paths; 14import java.util.HashMap;
14import java.util.LinkedList; 15import java.util.LinkedList;
15import java.util.List; 16import java.util.List;
17import java.util.Map;
16 18
17public class Main { 19public class Main {
18 20
19 private static Path getResourcePath(String str) throws URISyntaxException { 21 private static final String DEFAULT_MAP_NAME = "/maps/level0.txt";
20 return Paths.get(Main.class.getResource(str).toURI()); 22 private static java.util.List<Path> getResourcePaths(String[] args) throws URISyntaxException,IOException {
21 }
22
23 private static java.util.List<Path> getResourcePaths(String[] args) throws URISyntaxException {
24 LinkedList<Path> paths = new LinkedList<>(); 23 LinkedList<Path> paths = new LinkedList<>();
25 if (args.length > 0) { 24 String strFolder = System.getProperty("levels");
26 for (String string : args) { 25 if (strFolder != null) {
27 paths.add(Paths.get(string)); 26 Path pathFolder = Paths.get(strFolder);
28 } 27 Files.newDirectoryStream(pathFolder).forEach(paths::add);
29 } else { 28 } else {
30 paths.add(getResourcePath("/maps/level0.txt")); 29 final URI uri = Main.class.getResource(DEFAULT_MAP_NAME).toURI();
30 Map<String, String> env = new HashMap<>();
31 env.put("create", "true");
32 FileSystem zipfs = FileSystems.newFileSystem(uri, env);
33 paths.add(Paths.get(uri));
31 } 34 }
32 return paths; 35 return paths;
33 } 36 }