display list of players and allows view of details
This commit is contained in:
parent
b6116e0aa0
commit
4517718d1c
|
|
@ -1,20 +1,84 @@
|
|||
package com.r0r5chach;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import com.r0r5chach.r6.R6Player;
|
||||
import com.r0r5chach.valorant.ValorantPlayer;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
public class MainController {
|
||||
public class MainController implements Initializable {
|
||||
private CompetitorList competitors;
|
||||
private ArrayList<Integer> competitorIds;
|
||||
|
||||
@FXML
|
||||
private ListView<Competitor> competitorsList;
|
||||
public MainController() {
|
||||
ListView<Integer> competitorsList;
|
||||
|
||||
@FXML
|
||||
TextField playerNumber;
|
||||
|
||||
@FXML
|
||||
TextField playerName;
|
||||
|
||||
@FXML
|
||||
TextField playerLevel;
|
||||
|
||||
@FXML
|
||||
Text favoriteCharacters;
|
||||
|
||||
@FXML
|
||||
TextField favoriteAttacker;
|
||||
|
||||
@FXML
|
||||
TextField favoriteDefender;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
loadCompetitors();
|
||||
loadView();
|
||||
}
|
||||
|
||||
private void loadCompetitors(){
|
||||
this.competitors = new Manager().getCompetitors();
|
||||
this.competitorsList = new ListView<Competitor>(FXCollections.observableList(this.competitors.getCompetitors()));
|
||||
this.competitorIds = new ArrayList<Integer>();
|
||||
for (Competitor player : this.competitors.getCompetitors()) {
|
||||
this.competitorIds.add(player.getPlayerNumber());
|
||||
}
|
||||
}
|
||||
|
||||
private void loadView() {
|
||||
competitorsList.setItems(FXCollections.observableArrayList(this.competitorIds));
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void getCompetitor() {
|
||||
Competitor player = this.competitors.getCompetitors().get(this.competitorIds.indexOf(this.competitorsList.getSelectionModel().getSelectedItem()));
|
||||
loadPlayer(player);
|
||||
}
|
||||
|
||||
private void loadPlayer(Competitor player) {
|
||||
this.playerNumber.setText(String.valueOf(player.getPlayerNumber()));
|
||||
this.playerName.setText(player.getPlayerName().getFullName());
|
||||
this.playerLevel.setText(player.getPlayerLevel().getRank());
|
||||
|
||||
if (player instanceof R6Player) {
|
||||
this.favoriteAttacker.setText(((R6Player) player).getFavoriteAttacker().getAttacker());
|
||||
this.favoriteDefender.setText(((R6Player) player).getFavoriteDefender().getDefender());
|
||||
this.favoriteDefender.visibleProperty().set(true);
|
||||
this.favoriteCharacters.setText("Favorite Operators");
|
||||
}
|
||||
else if (player instanceof ValorantPlayer) {
|
||||
this.favoriteAttacker.setText(((ValorantPlayer) player).getFavoriteAgent().getAgent());
|
||||
this.favoriteDefender.visibleProperty().set(false);
|
||||
this.favoriteCharacters.setText("Favorite Agent");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,88 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.SplitPane?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
|
||||
<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">
|
||||
<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.29797979797979796" prefHeight="452.0" prefWidth="600.0">
|
||||
<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="competitors" prefHeight="398.0" prefWidth="175.0" />
|
||||
<ListView fx:id="competitorsList" onMouseClicked="#getCompetitor" prefHeight="398.0" prefWidth="175.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" />
|
||||
<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>
|
||||
</children>
|
||||
|
|
|
|||
Loading…
Reference in New Issue