refactored so manager is entrypoint
This commit is contained in:
parent
c53c3ed173
commit
3129206188
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Integer>();
|
||||
for (Competitor player : this.competitors.getCompetitors()) {
|
||||
this.competitorIds.add(player.getPlayerNumber());
|
||||
|
|
|
|||
|
|
@ -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.<MainController>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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue