started gui

This commit is contained in:
Joshua Perry 2023-01-31 17:19:32 +00:00
parent 0ae6adc481
commit 6efc71e646
26 changed files with 163 additions and 67 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>assignment_2</name>
<name>app</name>
<comment></comment>
<projects>
</projects>
@ -22,7 +22,7 @@
</natures>
<filteredResources>
<filter>
<id>1675021093357</id>
<id>1675085397960</id>
<name></name>
<type>30</type>
<matcher>

53
pom.xml
View File

@ -1,20 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.r0r5chach</groupId>
<artifactId>assignment_2</artifactId>
<groupId>com.r0r5chach</groupId>
<artifactId>app</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17.0.0.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
@ -27,5 +32,29 @@
<scope>test</scope>
</dependency>
</dependencies>
</project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<mainClass>com.r0r5chach.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,4 +1,4 @@
package org.r0r5chach;
package com.r0r5chach;
import java.text.DecimalFormat;
/**

View File

@ -1,4 +1,4 @@
package org.r0r5chach;
package com.r0r5chach;
import java.io.File;
import java.io.FileNotFoundException;
@ -11,11 +11,11 @@ import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import org.r0r5chach.r6.R6Attacker;
import org.r0r5chach.r6.R6Defender;
import org.r0r5chach.r6.R6Player;
import org.r0r5chach.valorant.ValorantAgent;
import org.r0r5chach.valorant.ValorantPlayer;
import com.r0r5chach.r6.R6Attacker;
import com.r0r5chach.r6.R6Defender;
import com.r0r5chach.r6.R6Player;
import com.r0r5chach.valorant.ValorantAgent;
import com.r0r5chach.valorant.ValorantPlayer;
public class CompetitorList {
@ -164,7 +164,7 @@ public class CompetitorList {
FileWriter report = null;
do {
path = Path.of("src/main/resources/report"+count+ ".txt");
path = Path.of("src/main/resources/com/r0r5chach/report"+count+ ".txt");
exists = Files.exists(path);
if(exists) {
@ -201,7 +201,7 @@ public class CompetitorList {
}
private String reportTemplate() throws IOException {
return Files.readString(Path.of("src/main/resources/report.template"));
return Files.readString(Path.of("src/main/resources/com/r0r5chach/report.template"));
}

View File

@ -0,0 +1,33 @@
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();
}
}

View File

@ -0,0 +1,20 @@
package com.r0r5chach;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
public class MainController {
private CompetitorList competitors;
@FXML
private ListView<Competitor> competitorsList;
public MainController() {
loadCompetitors();
}
private void loadCompetitors(){
this.competitors = new Manager().getCompetitors();
this.competitorsList = new ListView<Competitor>(FXCollections.observableList(this.competitors.getCompetitors()));
}
}

View File

@ -1,7 +1,7 @@
package org.r0r5chach;
package com.r0r5chach;
import java.io.File;
import static org.r0r5chach.CompetitorList.createErrorLog;
import static com.r0r5chach.CompetitorList.createErrorLog;
public class Manager {
@ -23,14 +23,14 @@ public class Manager {
report = competitors.createReportFile();
}
catch (Exception e) {
report = new File(createErrorLog(e, "src/main/resource/log.txt"));
report = new File(createErrorLog(e, "src/main/resource/com/r0r5chach/log.txt"));
}
return report;
}
private void init() {
File valorantPlayers = new File("src/main/resources/valorantPlayers.txt");
File r6Players = new File("src/main/resources/r6Players.txt");
File valorantPlayers = new File("src/main/resources/com/r0r5chach/valorantPlayers.txt");
File r6Players = new File("src/main/resources/com/r0r5chach/r6Players.txt");
try {
competitors = new CompetitorList();
competitors.readCompetitors(valorantPlayers);

View File

@ -1,4 +1,4 @@
package org.r0r5chach;
package com.r0r5chach;
/**
* Class that defines a name and it's parts

View File

@ -1,4 +1,4 @@
package org.r0r5chach;
package com.r0r5chach;
import java.util.Locale;

View File

@ -1,4 +1,4 @@
package org.r0r5chach.r6;
package com.r0r5chach.r6;
import java.util.Locale;

View File

@ -1,4 +1,4 @@
package org.r0r5chach.r6;
package com.r0r5chach.r6;
import java.util.Locale;

View File

@ -1,10 +1,10 @@
package org.r0r5chach.r6;
package com.r0r5chach.r6;
import java.util.Arrays;
import org.r0r5chach.Competitor;
import org.r0r5chach.Name;
import org.r0r5chach.Rank;
import com.r0r5chach.Competitor;
import com.r0r5chach.Name;
import com.r0r5chach.Rank;
public class R6Player extends Competitor{
private R6Attacker favoriteAttacker;

View File

@ -1,4 +1,4 @@
package org.r0r5chach.valorant;
package com.r0r5chach.valorant;
import java.util.Locale;

View File

@ -1,10 +1,10 @@
package org.r0r5chach.valorant;
package com.r0r5chach.valorant;
import java.util.Arrays;
import org.r0r5chach.Competitor;
import org.r0r5chach.Name;
import org.r0r5chach.Rank;
import com.r0r5chach.Competitor;
import com.r0r5chach.Name;
import com.r0r5chach.Rank;
/**
* Class that defines the various attributes and methods associated with a Valorant Player
* @author r0r5chach

View File

@ -0,0 +1,9 @@
module com.r0r5chach {
requires transitive javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
opens com.r0r5chach to javafx.fxml;
exports com.r0r5chach;
}

View File

@ -1,17 +0,0 @@
package org.r0r5chach;
import java.io.IOException;
import java.nio.file.Files;
public class Main {
public static void main(String[] args) {
Manager manager = new Manager();
try {
System.out.println(Files.readString(manager.getReport().toPath()));
}
catch (IOException e) {
System.out.println("reading error");
}
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1">
<children>
<SplitPane dividerPositions="0.29797979797979796" prefHeight="452.0" prefWidth="600.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<ListView fx:id="competitors" prefHeight="398.0" prefWidth="175.0" />
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" />
</items>
</SplitPane>
</children>
</VBox>

View File

@ -1,6 +1,6 @@
package com.r0r5chach;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.r0r5chach.Main;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

View File

@ -1,6 +1,6 @@
package com.r0r5chach;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.r0r5chach.Manager;
import java.io.IOException;
import java.nio.file.Files;

View File

@ -1,5 +1,5 @@
package com.r0r5chach;
import org.junit.jupiter.api.Test;
import org.r0r5chach.Name;
import static org.junit.jupiter.api.Assertions.assertEquals;

View File

@ -1,6 +1,6 @@
package com.r0r5chach;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.r0r5chach.Rank;
public class RankTest {

View File

@ -1,6 +1,7 @@
package com.r0r5chach;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.r0r5chach.valorant.ValorantAgent;
import com.r0r5chach.valorant.ValorantAgent;
public class ValorantAgentTest {
@Test

View File

@ -1,9 +1,8 @@
package com.r0r5chach;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.r0r5chach.Name;
import org.r0r5chach.Rank;
import org.r0r5chach.valorant.ValorantAgent;
import org.r0r5chach.valorant.ValorantPlayer;
import com.r0r5chach.valorant.ValorantAgent;
import com.r0r5chach.valorant.ValorantPlayer;
public class ValorantPlayerTest {
@Test
public void valorantPlayerTest() {