aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam NAILI2018-01-14 16:37:42 +0100
committerAdam NAILI2018-01-14 16:37:42 +0100
commit7978145be5557b26999766e24978735c1c701e2a (patch)
treeeefd413cdcbd24be917705dd4c84d2e2ebfdcadf
parenteeda506af16c3da6619e0a8a4941b41a640fe616 (diff)
downloadwallj-7978145be5557b26999766e24978735c1c701e2a.tar.gz
Implementing the beginning of parsing thing, call to application.run()
-rw-r--r--src/main/java/fr/umlv/java/wallj/Main.java49
1 files changed, 40 insertions, 9 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/Main.java b/src/main/java/fr/umlv/java/wallj/Main.java
index 7511980..4f35aab 100644
--- a/src/main/java/fr/umlv/java/wallj/Main.java
+++ b/src/main/java/fr/umlv/java/wallj/Main.java
@@ -1,20 +1,51 @@
1package fr.umlv.java.wallj; 1package fr.umlv.java.wallj;
2 2
3import fr.umlv.java.wallj.board.Board;
4import fr.umlv.java.wallj.board.BoardParser;
5import fr.umlv.java.wallj.viewer.Viewer;
3import fr.umlv.zen5.Application; 6import fr.umlv.zen5.Application;
4 7
5import java.awt.*; 8import java.awt.*;
9import java.io.IOException;
10import java.net.URISyntaxException;
11import java.nio.file.Path;
12import java.nio.file.Paths;
13import java.util.LinkedList;
14import java.util.List;
6 15
7public class Main { 16public class Main {
8 17
9 /** 18 private static Path getResourcePath(String str) throws URISyntaxException {
10 * Dummy entry point. 19 return Paths.get(Main.class.getResource(str).toURI());
11 * 20 }
12 * @param args no need to argue 21
13 */ 22 private static java.util.List<Path> getResourcePaths(String[] args) throws URISyntaxException {
14 public static void main(String[] args) { 23 LinkedList<Path> paths = new LinkedList<>();
15 System.out.println("Hello World!"); 24 if (args.length > 0) {
16 Application.run(Color.BLACK, (ac) -> { 25 for (String string : args) {
17 }); 26 paths.add(Paths.get(string));
27 }
28 } else {
29 paths.add(getResourcePath("/maps/smallvalid.txt"));
30 }
31 return paths;
18 } 32 }
19 33
34 public static void main(String[] args) {
35 java.util.List<Board> boards = new LinkedList<>();
36 try {
37 List<Path> boardPaths = Main.getResourcePaths(args);
38 for (Path path : boardPaths) {
39 boards.add(BoardParser.parse(path));
40 }
41 Viewer viewer = new Viewer(boards);
42 Application.run(Color.BLACK, viewer::eventLoop);
43 } catch (URISyntaxException e) {
44 System.err.println("Error in path syntax.");
45 System.exit(1);
46 } catch (IOException e) {
47 System.err.println("Something occurred while reading the files.");
48 System.exit(1);
49 }
50 }
20} 51}