diff --git a/src/main/java/com/r0r5chach/Main.java b/src/main/java/com/r0r5chach/Main.java deleted file mode 100644 index 647d94a..0000000 --- a/src/main/java/com/r0r5chach/Main.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.r0r5chach; - - -import java.io.IOException; -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.stage.Stage; -import javafx.scene.Scene; - -public class Main extends Application { - private static Scene scene; - - @Override - public void start(Stage stage) throws IOException { - scene = new Scene(loadFXML("main"), 640, 480); - stage.setScene(scene); - stage.show(); - } - - public static void setRoot(String fxml) throws IOException { - scene.setRoot(loadFXML(fxml)); - } - - private static Parent loadFXML(String fxml) throws IOException { - FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource(fxml + ".fxml")); - return fxmlLoader.load(); - } - - public static void main(String[] args) { - launch(); - } -} \ No newline at end of file diff --git a/src/main/java/com/r0r5chach/MainController.java b/src/main/java/com/r0r5chach/MainController.java index b2c78df..4402a45 100644 --- a/src/main/java/com/r0r5chach/MainController.java +++ b/src/main/java/com/r0r5chach/MainController.java @@ -80,6 +80,10 @@ public class MainController implements Initializable { this.scores = new TextField[]{scores0, scores1, scores2, scores3, scores4, scores5}; loadView(); } + + public void setCompetitors(CompetitorList list) { + this.competitors = list; + } @FXML private void getCompetitor() { @@ -98,7 +102,6 @@ public class MainController implements Initializable { } private void loadCompetitors(){ - this.competitors = new Manager().getCompetitors(); this.competitorIds = new ArrayList(); for (Competitor player : this.competitors.getCompetitors()) { this.competitorIds.add(player.getPlayerNumber()); diff --git a/src/main/java/com/r0r5chach/Manager.java b/src/main/java/com/r0r5chach/Manager.java index 4efa8ab..0bfa867 100644 --- a/src/main/java/com/r0r5chach/Manager.java +++ b/src/main/java/com/r0r5chach/Manager.java @@ -1,34 +1,48 @@ package com.r0r5chach; import java.io.File; +import javafx.application.Application; +import java.io.IOException; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.stage.Stage; +import javafx.scene.Scene; import static com.r0r5chach.CompetitorList.createErrorLog; -public class Manager { +public class Manager extends Application { - private CompetitorList competitors; + private static Scene scene; - - public Manager() { - init(); + @Override + public void start(Stage stage) throws IOException { + scene = new Scene(loadFXML("main"), 640, 480); + stage.setScene(scene); + stage.show(); } - public CompetitorList getCompetitors() { - return competitors; + public static void setRoot(String fxml) throws IOException { + scene.setRoot(loadFXML(fxml)); } - - public File getReport() { - File report; - try { - report = competitors.createReportFile(); + private static Parent loadFXML(String fxml) throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(Manager.class.getResource(fxml + ".fxml")); + Parent root = fxmlLoader.load(); + switch(fxml) { + case "main": + MainController controller = fxmlLoader.getController(); + controller.setCompetitors(createList()); + break; } - catch (Exception e) { - report = new File(createErrorLog(e, "src/main/resource/com/r0r5chach/log.txt")); - } - return report; + + return root; } - private void init() { + public static void main(String[] args) { + launch(); + } + + private static CompetitorList createList() { + CompetitorList competitors = null; File valorantPlayers = new File("src/main/resources/com/r0r5chach/valorantPlayers.txt"); File r6Players = new File("src/main/resources/com/r0r5chach/r6Players.txt"); try { @@ -39,5 +53,6 @@ public class Manager { catch (Exception e) { createErrorLog(e, "src/main/resources/log.txt"); } + return competitors; } }