From 7978145be5557b26999766e24978735c1c701e2a Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 14 Jan 2018 16:37:42 +0100 Subject: Implementing the beginning of parsing thing, call to application.run() --- src/main/java/fr/umlv/java/wallj/Main.java | 49 ++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'src/main/java/fr/umlv') 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 @@ package fr.umlv.java.wallj; +import fr.umlv.java.wallj.board.Board; +import fr.umlv.java.wallj.board.BoardParser; +import fr.umlv.java.wallj.viewer.Viewer; import fr.umlv.zen5.Application; import java.awt.*; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.LinkedList; +import java.util.List; public class Main { - /** - * Dummy entry point. - * - * @param args no need to argue - */ - public static void main(String[] args) { - System.out.println("Hello World!"); - Application.run(Color.BLACK, (ac) -> { - }); + private static Path getResourcePath(String str) throws URISyntaxException { + return Paths.get(Main.class.getResource(str).toURI()); + } + + private static java.util.List getResourcePaths(String[] args) throws URISyntaxException { + LinkedList paths = new LinkedList<>(); + if (args.length > 0) { + for (String string : args) { + paths.add(Paths.get(string)); + } + } else { + paths.add(getResourcePath("/maps/smallvalid.txt")); + } + return paths; } + public static void main(String[] args) { + java.util.List boards = new LinkedList<>(); + try { + List boardPaths = Main.getResourcePaths(args); + for (Path path : boardPaths) { + boards.add(BoardParser.parse(path)); + } + Viewer viewer = new Viewer(boards); + Application.run(Color.BLACK, viewer::eventLoop); + } catch (URISyntaxException e) { + System.err.println("Error in path syntax."); + System.exit(1); + } catch (IOException e) { + System.err.println("Something occurred while reading the files."); + System.exit(1); + } + } } -- cgit v1.2.3