Develope game branch #33

Merged
schrom01 merged 23 commits from develope_Game_branch into main 2022-05-12 13:44:47 +02:00
7 changed files with 41 additions and 17 deletions
Showing only changes of commit afab6dbee3 - Show all commits

View File

@ -7,24 +7,23 @@ public abstract class FXController {
FactoryDecorator factoryDecorator;
FileIO fileIO;
Pane pane;
IsObserver listener;
public FXController(){
listener = new IsObserver() {
@Override
public void update() {
loadContent();
}
};
}
public void setup(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, Pane pane){
this.tournamentDecorator = tournamentDecorator;
this.fileIO = fileIO;
this.factoryDecorator = factoryDecorator;
this.pane = pane;
tournamentDecorator.addListener(new IsObserver() {
@Override
public void update() {
loadContent();
}
});
factoryDecorator.addListener(new IsObserver() {
@Override
public void update() {
loadContent();
}
});
addListener();
}
public abstract void loadContent();
@ -33,6 +32,16 @@ public abstract class FXController {
this.tournamentDecorator = tournamentDecorator;
}
public void addListener(){
tournamentDecorator.addListener(listener);
factoryDecorator.addListener(listener);
}
protected void removeListener(){
tournamentDecorator.removeListener(listener);
factoryDecorator.removeListener(listener);
}
protected TournamentDecorator getTournamentDecorator() {
return tournamentDecorator;
}

View File

@ -55,6 +55,7 @@ public class GameDecorator implements IsObservable{
public void refreshParticipants(){
game.refreshParticipants();
informListener();
}
public Place getPlace() {

View File

@ -18,6 +18,9 @@ public class GameScheduleController extends FXController {
@FXML
private Button editParticipantBtn;
@FXML
private Button closeTournamentBtn;
@FXML
private HBox hBoxCenter;
@ -33,14 +36,22 @@ public class GameScheduleController extends FXController {
@FXML
void openPlacesFormular(ActionEvent event) {
removeListener();
getFactoryDecorator().openPlacesFormular();
}
@FXML
void openParticipantFormular(ActionEvent event) {
removeListener();
getFactoryDecorator().openParticipantFormular();
}
@FXML
void closeTournament(ActionEvent event) {
removeListener();
getFactoryDecorator().openTournamentList();
}
@Override
public void loadContent() {
getFactoryDecorator().loadGameTree(hBoxCenter, getTournamentDecorator());

View File

@ -89,6 +89,7 @@ public class ParticipantFormularController extends FXController {
@FXML
void close(ActionEvent event) {
removeListener();
getFactoryDecorator().openScheduleView();
}

View File

@ -68,6 +68,7 @@ public class PlacesFormularController extends FXController {
@FXML
void close(ActionEvent event) {
removeListener();
getFactoryDecorator().openScheduleView();
}

View File

@ -61,6 +61,7 @@ public class TournamentListController extends FXController {
@FXML
void openTournament(ActionEvent event) {
removeListener();
FileIO.TournamentFile tournamentFile = tournamentListView.getSelectionModel().getSelectedItems().get(0);
getFactoryDecorator().openTournament(tournamentFile);
}

View File

@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameScheduleController">
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.2" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameScheduleController">
<top>
<HBox alignment="TOP_RIGHT" prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
@ -24,6 +23,7 @@
<Insets right="40.0" />
</HBox.margin>
</Button>
<Button fx:id="closeTournamentBtn" layoutX="470.0" layoutY="10.0" mnemonicParsing="false" onAction="#closeTournament" text="Close Tournament" />
</children>
</HBox>
</top>