basic table added
This commit is contained in:
parent
c3e01cb98e
commit
0b5131b891
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.r0r5chach;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.r0r5chach.r6.R6Attacker;
|
||||||
|
import com.r0r5chach.r6.R6Defender;
|
||||||
|
import com.r0r5chach.valorant.ValorantAgent;
|
||||||
|
|
||||||
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
||||||
|
public class CompetitorRow {
|
||||||
|
private SimpleIntegerProperty playerNumber;
|
||||||
|
private SimpleStringProperty playerName;
|
||||||
|
private SimpleObjectProperty<Rank> playerLevel;
|
||||||
|
private SimpleStringProperty scores;
|
||||||
|
private SimpleObjectProperty<ValorantAgent> favoriteAgent;
|
||||||
|
private SimpleObjectProperty<R6Attacker> favoriteAttacker;
|
||||||
|
private SimpleObjectProperty<R6Defender> favoriteDefender;
|
||||||
|
|
||||||
|
public CompetitorRow(int playerNumber, Name playerName, Rank playerLevel, int[] scores) {
|
||||||
|
this.playerNumber = new SimpleIntegerProperty(playerNumber);
|
||||||
|
this.playerName = new SimpleStringProperty(playerName.getFullName());
|
||||||
|
this.playerLevel = new SimpleObjectProperty<Rank>(playerLevel);
|
||||||
|
this.scores = new SimpleStringProperty(Arrays.toString(scores).replace("[", "").replace("]", ""));
|
||||||
|
this.favoriteAgent = null;
|
||||||
|
this.favoriteAttacker = null;
|
||||||
|
this.favoriteDefender = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompetitorRow(int playerNumber, Name playerName, Rank playerLevel, int[] scores, ValorantAgent favoriteAgent) {
|
||||||
|
this.playerNumber = new SimpleIntegerProperty(playerNumber);
|
||||||
|
this.playerName = new SimpleStringProperty(playerName.getFullName());
|
||||||
|
this.scores = new SimpleStringProperty(Arrays.toString(scores).replace("[", "").replace("]", ""));
|
||||||
|
this.playerLevel = new SimpleObjectProperty<Rank>(playerLevel);
|
||||||
|
this.favoriteAgent = new SimpleObjectProperty<ValorantAgent>(favoriteAgent);
|
||||||
|
this.favoriteAttacker = null;
|
||||||
|
this.favoriteDefender = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompetitorRow(int playerNumber, Name playerName, Rank playerLevel, int[] scores, R6Attacker favoriteAttacker, R6Defender favoriteDefender) {
|
||||||
|
this.playerName = new SimpleStringProperty(playerName.getFullName());
|
||||||
|
this.playerNumber = new SimpleIntegerProperty(playerNumber);
|
||||||
|
this.scores = new SimpleStringProperty(Arrays.toString(scores).replace("[", "").replace("]", ""));
|
||||||
|
this.playerLevel = new SimpleObjectProperty<Rank>(playerLevel);
|
||||||
|
this.favoriteAgent = null;
|
||||||
|
this.favoriteAttacker = new SimpleObjectProperty<R6Attacker>(favoriteAttacker);
|
||||||
|
this.favoriteDefender = new SimpleObjectProperty<R6Defender>(favoriteDefender);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerNumber(int newValue) {
|
||||||
|
this.playerNumber.set(newValue);
|
||||||
|
}
|
||||||
|
public void setPlayerName(String newValue) {
|
||||||
|
this.playerName.set(newValue);
|
||||||
|
}
|
||||||
|
public void setPlayerLevel(Rank newValue) {
|
||||||
|
this.playerLevel.set(newValue);
|
||||||
|
}
|
||||||
|
public void setScores(String newValue) {
|
||||||
|
this.scores.set(newValue);
|
||||||
|
}
|
||||||
|
public void setFavoriteAgent(ValorantAgent newValue) {
|
||||||
|
this.favoriteAgent.set(newValue);
|
||||||
|
}
|
||||||
|
public void setFavoriteAttacker(R6Attacker newValue) {
|
||||||
|
this.favoriteAttacker.set(newValue);
|
||||||
|
}
|
||||||
|
public void setFavoriteDefender(R6Defender newValue) {
|
||||||
|
this.favoriteDefender.set(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayerNumber() {
|
||||||
|
return this.playerNumber.get();
|
||||||
|
}
|
||||||
|
public String getPlayerName() {
|
||||||
|
return this.playerName.get();
|
||||||
|
}
|
||||||
|
public Rank getPlayerLevel() {
|
||||||
|
return this.playerLevel.get();
|
||||||
|
}
|
||||||
|
public String getScores() {
|
||||||
|
return this.scores.get();
|
||||||
|
}
|
||||||
|
public ValorantAgent getFavoriteAgent() {
|
||||||
|
return this.favoriteAgent.get();
|
||||||
|
}
|
||||||
|
public R6Attacker getFavoriteAttacker() {
|
||||||
|
return this.favoriteAttacker.get();
|
||||||
|
}
|
||||||
|
public R6Defender getFavoriteDefender() {
|
||||||
|
return this.favoriteDefender.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,12 +13,16 @@ import com.r0r5chach.valorant.ValorantPlayer;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
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.control.cell.PropertyValueFactory;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
|
|
||||||
public class MainController implements Initializable {
|
public class MainController implements Initializable {
|
||||||
|
|
@ -75,6 +79,8 @@ public class MainController implements Initializable {
|
||||||
@FXML
|
@FXML
|
||||||
Button updateButton;
|
Button updateButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
TableView<CompetitorRow> competitorTable;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle rb) {
|
public void initialize(URL url, ResourceBundle rb) {
|
||||||
|
|
@ -124,7 +130,20 @@ public class MainController implements Initializable {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void loadView() {
|
private void loadView() {
|
||||||
//TODO: Display all data from competitors
|
TableColumn<CompetitorRow,Integer> playerNumCol = new TableColumn<CompetitorRow,Integer>("Player Number");
|
||||||
|
TableColumn<CompetitorRow,String> playerNameCol = new TableColumn<CompetitorRow,String>("Player Name");
|
||||||
|
TableColumn<CompetitorRow,Rank> playerLevelCol = new TableColumn<CompetitorRow,Rank>("Player Level");
|
||||||
|
TableColumn<CompetitorRow,int[]> scoresCol = new TableColumn<CompetitorRow,int[]>("Player Scores");
|
||||||
|
playerNumCol.setCellValueFactory(new PropertyValueFactory<CompetitorRow,Integer>("playerNumber"));
|
||||||
|
playerNameCol.setCellValueFactory(new PropertyValueFactory<CompetitorRow,String>("playerName"));
|
||||||
|
playerLevelCol.setCellValueFactory(new PropertyValueFactory<CompetitorRow,Rank>("playerLevel"));
|
||||||
|
scoresCol.setCellValueFactory(new PropertyValueFactory<CompetitorRow,int[]>("scores"));
|
||||||
|
competitorTable.getColumns().add(playerNumCol);
|
||||||
|
competitorTable.getColumns().add(playerNameCol);
|
||||||
|
competitorTable.getColumns().add(playerLevelCol);
|
||||||
|
competitorTable.getColumns().add(scoresCol);
|
||||||
|
competitorTable.setItems(generateTable());
|
||||||
|
//TODO: Add favorite characters
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadPlayer(Competitor player) {
|
private void loadPlayer(Competitor player) {
|
||||||
|
|
@ -186,4 +205,20 @@ public class MainController implements Initializable {
|
||||||
}
|
}
|
||||||
player.setScores(newScores);
|
player.setScores(newScores);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ObservableList<CompetitorRow> generateTable() {
|
||||||
|
ArrayList<CompetitorRow> list = new ArrayList<>();
|
||||||
|
for(Competitor player: this.competitors.getCompetitors()) {
|
||||||
|
if (player instanceof ValorantPlayer) {
|
||||||
|
list.add(new CompetitorRow(player.getPlayerNumber(), player.getPlayerName(), player.getPlayerLevel(), player.getScores(), ((ValorantPlayer) player).getFavoriteAgent()));
|
||||||
|
}
|
||||||
|
else if (player instanceof R6Player) {
|
||||||
|
list.add(new CompetitorRow(player.getPlayerNumber(), player.getPlayerName(), player.getPlayerLevel(), player.getScores(), ((R6Player) player).getFavoriteAttacker(), ((R6Player) player).getFavoriteDefender()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
list.add(new CompetitorRow(player.getPlayerNumber(), player.getPlayerName(), player.getPlayerLevel(), player.getScores()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FXCollections.observableArrayList(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,4 +6,6 @@ module com.r0r5chach {
|
||||||
|
|
||||||
opens com.r0r5chach to javafx.fxml;
|
opens com.r0r5chach to javafx.fxml;
|
||||||
exports com.r0r5chach;
|
exports com.r0r5chach;
|
||||||
|
exports com.r0r5chach.r6;
|
||||||
|
exports com.r0r5chach.valorant;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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?>
|
||||||
|
|
@ -151,7 +152,10 @@
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab onSelectionChanged="#loadView" 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="371.0" prefWidth="600.0" />
|
||||||
|
</children></AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab text="Report">
|
<Tab text="Report">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue