Develope game branch #33

Merged
schrom01 merged 23 commits from develope_Game_branch into main 2022-05-12 13:44:47 +02:00
2 changed files with 27 additions and 31 deletions
Showing only changes of commit 5e88960c8a - Show all commits

View File

@ -3,6 +3,7 @@ package ch.zhaw.projekt2.turnierverwaltung;
import ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameController; import ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameController;
import ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameDecorator; import ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameDecorator;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
@ -75,10 +76,35 @@ public class FactoryDecorator implements IsObservable{
informListener(); informListener();
} }
public void loadGameTree(HBox hBoxCenter, TournamentDecorator tournamentDecorator) {
hBoxCenter.getChildren().clear();
List<List<Game>> gameList = tournamentDecorator.getTournament().getGameList();
List<GameDecorator> gameDecorators = new ArrayList<>();
for (int i = 0; i < gameList.size(); i++) {
List<GameDecorator> newGameDecorators = new ArrayList<>();
VBox vBox = new VBox();
for (int j = 0; j < gameList.get(i).size(); j++) {
GameDecorator gameDecorator = new GameDecorator(gameList.get(i).get(j));
newGameDecorators.add(gameDecorator);
GameController controller = openGameView(vBox,gameDecorator);
if(i>0){
controller.addListener(gameDecorators.get(j*2));
controller.addListener(gameDecorators.get(j*2+1));
}
controller.loadContent();
}
hBoxCenter.getChildren().add(vBox);
gameDecorators = newGameDecorators;
}
}
public GameController openGameView(VBox vBox, GameDecorator gameDecorator) { public GameController openGameView(VBox vBox, GameDecorator gameDecorator) {
return factory.loadGameView(vBox ,gameDecorator, this); return factory.loadGameView(vBox ,gameDecorator, this);
} }
public void informListener() { public void informListener() {
for(IsObserver observer : listener) { for(IsObserver observer : listener) {
observer.update(); observer.update();

View File

@ -1,20 +1,11 @@
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView; package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
import ch.zhaw.projekt2.turnierverwaltung.FXController; import ch.zhaw.projekt2.turnierverwaltung.FXController;
import ch.zhaw.projekt2.turnierverwaltung.Game;
import ch.zhaw.projekt2.turnierverwaltung.Tournament; import ch.zhaw.projekt2.turnierverwaltung.Tournament;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import org.checkerframework.checker.units.qual.C;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class GameScheduleController extends FXController { public class GameScheduleController extends FXController {
@ -52,28 +43,7 @@ public class GameScheduleController extends FXController {
@Override @Override
public void loadContent() { public void loadContent() {
hBoxCenter.getChildren().clear(); getFactoryDecorator().loadGameTree(hBoxCenter, getTournamentDecorator());
List<List<Game>> gameList = getTournamentDecorator().getTournament().getGameList();
List<GameDecorator> gameDecorators = new ArrayList<>();
for (int i = 0; i < gameList.size(); i++) {
List<GameDecorator> newGameDecorators = new ArrayList<>();
VBox vBox = new VBox();
for (int j = 0; j < gameList.get(i).size(); j++) {
GameDecorator gameDecorator = new GameDecorator(gameList.get(i).get(j));
newGameDecorators.add(gameDecorator);
GameController controller = getFactoryDecorator().openGameView(vBox,gameDecorator);
if(i>0){
controller.addListener(gameDecorators.get(j*2));
controller.addListener(gameDecorators.get(j*2+1));
}
controller.loadContent();
}
hBoxCenter.getChildren().add(vBox);
gameDecorators = newGameDecorators;
}
} }
} }