Develope game branch #33
|
@ -3,6 +3,7 @@ package ch.zhaw.projekt2.turnierverwaltung;
|
|||
import ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameController;
|
||||
import ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameDecorator;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
|
@ -75,10 +76,35 @@ public class FactoryDecorator implements IsObservable{
|
|||
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) {
|
||||
return factory.loadGameView(vBox ,gameDecorator, this);
|
||||
}
|
||||
|
||||
|
||||
public void informListener() {
|
||||
for(IsObserver observer : listener) {
|
||||
observer.update();
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
|
||||
|
||||
import ch.zhaw.projekt2.turnierverwaltung.FXController;
|
||||
import ch.zhaw.projekt2.turnierverwaltung.Game;
|
||||
import ch.zhaw.projekt2.turnierverwaltung.Tournament;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.Button;
|
||||
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 {
|
||||
|
||||
|
@ -52,28 +43,7 @@ public class GameScheduleController extends FXController {
|
|||
|
||||
@Override
|
||||
public void loadContent() {
|
||||
hBoxCenter.getChildren().clear();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
getFactoryDecorator().loadGameTree(hBoxCenter, getTournamentDecorator());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue