update
This commit is contained in:
parent
3129206188
commit
b667265472
|
|
@ -11,12 +11,15 @@ import com.r0r5chach.r6.R6Player;
|
||||||
import com.r0r5chach.valorant.ValorantAgent;
|
import com.r0r5chach.valorant.ValorantAgent;
|
||||||
import com.r0r5chach.valorant.ValorantPlayer;
|
import com.r0r5chach.valorant.ValorantPlayer;
|
||||||
|
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.ChoiceBox;
|
import javafx.scene.control.ChoiceBox;
|
||||||
import javafx.scene.control.ListView;
|
import javafx.scene.control.ListView;
|
||||||
|
import javafx.scene.control.TableColumn;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
|
|
||||||
|
|
@ -74,11 +77,17 @@ public class MainController implements Initializable {
|
||||||
@FXML
|
@FXML
|
||||||
Button updateButton;
|
Button updateButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
TableView<Competitor> competitorTable;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle rb) {
|
public void initialize(URL url, ResourceBundle rb) {
|
||||||
loadCompetitors();
|
Platform.runLater(() -> {
|
||||||
this.scores = new TextField[]{scores0, scores1, scores2, scores3, scores4, scores5};
|
this.scores = new TextField[]{scores0, scores1, scores2, scores3, scores4, scores5};
|
||||||
loadView();
|
loadCompetitors();
|
||||||
|
loadEdit();
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCompetitors(CompetitorList list) {
|
public void setCompetitors(CompetitorList list) {
|
||||||
|
|
@ -97,7 +106,7 @@ public class MainController implements Initializable {
|
||||||
Competitor player = this.competitors.getCompetitors().get(playerIndex);
|
Competitor player = this.competitors.getCompetitors().get(playerIndex);
|
||||||
updatePlayer(player);
|
updatePlayer(player);
|
||||||
competitorIds.set(playerIndex, player.getPlayerNumber());
|
competitorIds.set(playerIndex, player.getPlayerNumber());
|
||||||
loadView();
|
loadEdit();
|
||||||
loadPlayer(player);
|
loadPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,14 +117,23 @@ public class MainController implements Initializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadView() {
|
@FXML
|
||||||
competitorsList.setItems(FXCollections.observableArrayList(this.competitorIds));
|
private void loadEdit() {
|
||||||
|
competitorsList.setItems(FXCollections.observableList(this.competitorIds));
|
||||||
playerLevel.setItems(FXCollections.observableList(Arrays.asList(Rank.values())));
|
playerLevel.setItems(FXCollections.observableList(Arrays.asList(Rank.values())));
|
||||||
favoriteAttacker.setItems(FXCollections.observableList(Arrays.asList(R6Attacker.values())));
|
favoriteAttacker.setItems(FXCollections.observableList(Arrays.asList(R6Attacker.values())));
|
||||||
favoriteDefender.setItems(FXCollections.observableList(Arrays.asList(R6Defender.values())));
|
favoriteDefender.setItems(FXCollections.observableList(Arrays.asList(R6Defender.values())));
|
||||||
favoriteAgent.setItems(FXCollections.observableList(Arrays.asList(ValorantAgent.values())));
|
favoriteAgent.setItems(FXCollections.observableList(Arrays.asList(ValorantAgent.values())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void loadView() {
|
||||||
|
competitorTable.getColumns().add(new TableColumn<Competitor,Integer>("Player Number"));
|
||||||
|
competitorTable.getColumns().add(new TableColumn<Competitor,String>("Player Name"));
|
||||||
|
competitorTable.getColumns().add(new TableColumn<Competitor,Rank>("Player Rank"));
|
||||||
|
competitorTable.getColumns().add(new TableColumn<Competitor,int[]>("Player Scores"));
|
||||||
|
}
|
||||||
|
|
||||||
private void loadPlayer(Competitor player) {
|
private void loadPlayer(Competitor player) {
|
||||||
this.playerNumber.setText(String.valueOf(player.getPlayerNumber()));
|
this.playerNumber.setText(String.valueOf(player.getPlayerNumber()));
|
||||||
this.playerName.setText(player.getPlayerName().getFullName());
|
this.playerName.setText(player.getPlayerName().getFullName());
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,8 @@ public class Manager extends Application {
|
||||||
private static Parent loadFXML(String fxml) throws IOException {
|
private static Parent loadFXML(String fxml) throws IOException {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(Manager.class.getResource(fxml + ".fxml"));
|
FXMLLoader fxmlLoader = new FXMLLoader(Manager.class.getResource(fxml + ".fxml"));
|
||||||
Parent root = fxmlLoader.load();
|
Parent root = fxmlLoader.load();
|
||||||
switch(fxml) {
|
MainController controller = fxmlLoader.<MainController>getController();
|
||||||
case "main":
|
controller.setCompetitors(createList());
|
||||||
MainController controller = fxmlLoader.<MainController>getController();
|
|
||||||
controller.setCompetitors(createList());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
<?import javafx.scene.control.SplitPane?>
|
<?import javafx.scene.control.SplitPane?>
|
||||||
<?import javafx.scene.control.Tab?>
|
<?import javafx.scene.control.Tab?>
|
||||||
<?import javafx.scene.control.TabPane?>
|
<?import javafx.scene.control.TabPane?>
|
||||||
|
<?import javafx.scene.control.TableView?>
|
||||||
<?import javafx.scene.control.TextField?>
|
<?import javafx.scene.control.TextField?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
|
@ -19,15 +20,20 @@
|
||||||
<children>
|
<children>
|
||||||
<TabPane prefHeight="406.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE">
|
<TabPane prefHeight="406.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE">
|
||||||
<tabs>
|
<tabs>
|
||||||
<Tab text="Edit">
|
<Tab text="Home">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
|
<Tab onSelectionChanged="#loadEdit" text="Edit">
|
||||||
<content>
|
<content>
|
||||||
<SplitPane dividerPositions="0.29" prefHeight="254.0" prefWidth="600.0">
|
<SplitPane dividerPositions="0.3016666666666667" prefHeight="254.0" prefWidth="600.0">
|
||||||
<items>
|
<items>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
|
<VBox maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="371.0" prefWidth="212.0">
|
||||||
<children>
|
<children>
|
||||||
<ListView fx:id="competitorsList" onMouseClicked="#getCompetitor" prefHeight="398.0" prefWidth="175.0" />
|
<ListView fx:id="competitorsList" onMouseClicked="#getCompetitor" prefHeight="371.0" prefWidth="193.0" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</VBox>
|
||||||
<GridPane>
|
<GridPane>
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="204.0" minWidth="10.0" prefWidth="127.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="204.0" minWidth="10.0" prefWidth="127.0" />
|
||||||
|
|
@ -144,11 +150,19 @@
|
||||||
</SplitPane>
|
</SplitPane>
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab text="View">
|
<Tab onSelectionChanged="#loadView" text="View">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<TableView fx:id="competitorTable" prefHeight="373.0" prefWidth="600.0" />
|
||||||
|
</children></AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
<Tab text="Report">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</children>
|
</children>
|
||||||
|
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package com.r0r5chach;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
public class MainTest {
|
|
||||||
@Test
|
|
||||||
public void mainTest() {
|
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
||||||
ByteArrayOutputStream expected = new ByteArrayOutputStream();
|
|
||||||
System.setOut(new PrintStream(expected));
|
|
||||||
try {
|
|
||||||
System.out.println(Files.readString(Path.of("src/test/java/reportTest.txt")));
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
System.out.println("File doesn't exist");
|
|
||||||
}
|
|
||||||
System.setOut(new PrintStream(output));
|
|
||||||
Main.main(new String[0]);
|
|
||||||
assertEquals(expected.toString(), output.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +1,11 @@
|
||||||
package com.r0r5chach;
|
package com.r0r5chach;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
public class ManagerTest {
|
public class ManagerTest {
|
||||||
|
|
||||||
@Test
|
|
||||||
public void managerTest() {
|
|
||||||
Manager m = new Manager();
|
|
||||||
assertEquals("Joshua Luke Perry", m.getCompetitors().getCompetitors().get(1).getPlayerName().getFullName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void managerTestGetReport() {
|
|
||||||
try {
|
|
||||||
Manager m = new Manager();
|
|
||||||
assertEquals(Files.readString(Path.of("src/test/java/reportTest.txt")), Files.readString(m.getReport().toPath()));
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
System.out.println("File does not exist");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void managerTestGetCompetitors() {
|
public void managerTestGetCompetitors() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue