added viewing of scores

This commit is contained in:
Joshua Perry 2023-02-01 13:51:13 +00:00
parent 811eb582b8
commit 5e32a47e8e
2 changed files with 169 additions and 72 deletions

View File

@ -39,9 +39,33 @@ public class MainController implements Initializable {
@FXML
TextField favoriteDefender;
@FXML
TextField scores0;
@FXML
TextField scores1;
@FXML
TextField scores2;
@FXML
TextField scores3;
@FXML
TextField scores4;
@FXML
TextField scores5;
@FXML
TextField overallScore;
TextField[] scores;
@Override
public void initialize(URL url, ResourceBundle rb) {
loadCompetitors();
this.scores = new TextField[]{scores0, scores1, scores2, scores3, scores4, scores5};
loadView();
}
@ -67,7 +91,12 @@ public class MainController implements Initializable {
this.playerNumber.setText(String.valueOf(player.getPlayerNumber()));
this.playerName.setText(player.getPlayerName().getFullName());
this.playerLevel.setText(player.getPlayerLevel().getRank());
loadFavoriteCharacters(player);
loadScores(player);
this.overallScore.setText(String.valueOf(player.getOverallScore()));
}
private void loadFavoriteCharacters(Competitor player) {
if (player instanceof R6Player) {
this.favoriteAttacker.setText(((R6Player) player).getFavoriteAttacker().getAttacker());
this.favoriteDefender.setText(((R6Player) player).getFavoriteDefender().getDefender());
@ -79,6 +108,12 @@ public class MainController implements Initializable {
this.favoriteDefender.visibleProperty().set(false);
this.favoriteCharacters.setText("Favorite Agent");
}
}
private void loadScores(Competitor player) {
int[] playerScores = player.getScores();
for (int i = 0; i < playerScores.length; i++) {
this.scores[i].setText(String.valueOf(playerScores[i]));
}
}
}

View File

@ -3,6 +3,8 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
@ -13,77 +15,137 @@
<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" fx:controller="com.r0r5chach.MainController">
<children>
<SplitPane dividerPositions="0.2959866220735786" prefHeight="452.0" prefWidth="600.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<ListView fx:id="competitorsList" onMouseClicked="#getCompetitor" prefHeight="398.0" prefWidth="175.0" />
</children>
</AnchorPane>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="204.0" minWidth="10.0" prefWidth="127.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="326.0" minWidth="10.0" prefWidth="291.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField fx:id="playerNumber" prefHeight="25.0" prefWidth="160.0" GridPane.columnIndex="1">
<GridPane.margin>
<Insets right="100.0" />
</GridPane.margin>
</TextField>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Player Number" GridPane.halignment="RIGHT">
<GridPane.margin>
<Insets right="10.0" />
</GridPane.margin>
</Text>
<TextField fx:id="playerName" prefHeight="25.0" prefWidth="160.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
<GridPane.margin>
<Insets right="100.0" />
</GridPane.margin>
</TextField>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Name" GridPane.halignment="RIGHT" GridPane.rowIndex="1">
<GridPane.margin>
<Insets right="10.0" />
</GridPane.margin>
</Text>
<TextField fx:id="playerLevel" GridPane.columnIndex="1" GridPane.rowIndex="2">
<GridPane.margin>
<Insets right="100.0" />
</GridPane.margin>
</TextField>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Level" GridPane.halignment="RIGHT" GridPane.rowIndex="2">
<GridPane.margin>
<Insets right="10.0" />
</GridPane.margin>
</Text>
<Text fx:id="favoriteCharacters" strokeType="OUTSIDE" strokeWidth="0.0" text="Favorite Character(s)" GridPane.halignment="RIGHT" GridPane.rowIndex="3">
<GridPane.margin>
<Insets bottom="45.0" right="10.0" />
</GridPane.margin>
</Text>
<VBox prefHeight="0.0" prefWidth="291.0" GridPane.columnIndex="1" GridPane.rowIndex="3">
<children>
<TextField fx:id="favoriteAttacker">
<VBox.margin>
<Insets right="100.0" top="15.0" />
</VBox.margin>
</TextField>
<TextField fx:id="favoriteDefender">
<VBox.margin>
<Insets right="100.0" top="15.0" />
</VBox.margin>
</TextField>
</children>
</VBox>
</children>
</GridPane>
</items>
</SplitPane>
<TabPane prefHeight="406.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE">
<tabs>
<Tab text="Edit">
<content>
<SplitPane dividerPositions="0.29" prefHeight="254.0" prefWidth="600.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<ListView fx:id="competitorsList" onMouseClicked="#getCompetitor" prefHeight="398.0" prefWidth="175.0" />
</children>
</AnchorPane>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="204.0" minWidth="10.0" prefWidth="127.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="326.0" minWidth="10.0" prefWidth="291.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField fx:id="playerNumber" prefHeight="25.0" prefWidth="160.0" GridPane.columnIndex="1">
<GridPane.margin>
<Insets right="100.0" />
</GridPane.margin>
</TextField>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Player Number" GridPane.halignment="RIGHT">
<GridPane.margin>
<Insets right="10.0" />
</GridPane.margin>
</Text>
<TextField fx:id="playerName" prefHeight="25.0" prefWidth="160.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
<GridPane.margin>
<Insets right="100.0" />
</GridPane.margin>
</TextField>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Name" GridPane.halignment="RIGHT" GridPane.rowIndex="1">
<GridPane.margin>
<Insets right="10.0" />
</GridPane.margin>
</Text>
<TextField fx:id="playerLevel" GridPane.columnIndex="1" GridPane.rowIndex="2">
<GridPane.margin>
<Insets right="100.0" />
</GridPane.margin>
</TextField>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Level" GridPane.halignment="RIGHT" GridPane.rowIndex="2">
<GridPane.margin>
<Insets right="10.0" />
</GridPane.margin>
</Text>
<Text fx:id="favoriteCharacters" strokeType="OUTSIDE" strokeWidth="0.0" text="Favorite Character(s)" GridPane.halignment="RIGHT" GridPane.rowIndex="3">
<GridPane.margin>
<Insets bottom="45.0" right="10.0" />
</GridPane.margin>
</Text>
<VBox prefHeight="0.0" prefWidth="291.0" GridPane.columnIndex="1" GridPane.rowIndex="3">
<children>
<TextField fx:id="favoriteAttacker">
<VBox.margin>
<Insets right="100.0" top="15.0" />
</VBox.margin>
</TextField>
<TextField fx:id="favoriteDefender">
<VBox.margin>
<Insets right="100.0" top="15.0" />
</VBox.margin>
</TextField>
</children>
</VBox>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Scores" GridPane.halignment="RIGHT" GridPane.rowIndex="4">
<GridPane.margin>
<Insets right="10.0" />
</GridPane.margin>
</Text>
<TextField fx:id="scores0" GridPane.columnIndex="1" GridPane.rowIndex="4">
<GridPane.margin>
<Insets right="268.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="scores1" GridPane.columnIndex="1" GridPane.rowIndex="4">
<GridPane.margin>
<Insets left="40.0" right="228.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="scores2" GridPane.columnIndex="1" GridPane.rowIndex="4">
<GridPane.margin>
<Insets left="80.0" right="188.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="scores3" GridPane.columnIndex="1" GridPane.rowIndex="4">
<GridPane.margin>
<Insets left="120.0" right="148.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="scores4" GridPane.columnIndex="1" GridPane.rowIndex="4">
<GridPane.margin>
<Insets left="160.0" right="108.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="scores5" GridPane.columnIndex="1" GridPane.rowIndex="4">
<GridPane.margin>
<Insets left="200.0" right="68.0" />
</GridPane.margin>
</TextField>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Overall Score" GridPane.halignment="RIGHT" GridPane.rowIndex="5">
<GridPane.margin>
<Insets right="10.0" />
</GridPane.margin>
</Text>
<TextField fx:id="overallScore" GridPane.columnIndex="1" GridPane.rowIndex="5">
<GridPane.margin>
<Insets right="200.0" />
</GridPane.margin>
</TextField>
</children>
</GridPane>
</items>
</SplitPane>
</content>
</Tab>
<Tab text="View">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
</tabs>
</TabPane>
</children>
</VBox>