diff --git a/src/hanoi/FoablakController.java b/src/hanoi/FoablakController.java index b3f217a..5c3ad14 100644 --- a/src/hanoi/FoablakController.java +++ b/src/hanoi/FoablakController.java @@ -1,13 +1,20 @@ package hanoi; +import java.io.IOException; import java.net.URL; import java.util.ResourceBundle; import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; +import javafx.scene.Parent; +import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Spinner; import javafx.scene.control.SpinnerValueFactory; import javafx.scene.control.TextField; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; public class FoablakController { @@ -27,8 +34,24 @@ public class FoablakController { private Button playGomb; @FXML - void playGombAction(ActionEvent event) { - + void playGombAction(ActionEvent event) throws IOException { + String fnev = (nevMezo.getText()==null || nevMezo.getText().isEmpty()) ? "anonymous" : nevMezo.getText(); + Felhasznalo fh = new Felhasznalo(fnev); + + FXMLLoader fl = new FXMLLoader(getClass().getResource("hanoi_form2.fxml")); + VBox root = (VBox)fl.load(); + + + + Scene sc = new Scene(root); + Node n = (Node) event.getSource(); + Stage st = (Stage) n.getScene().getWindow(); + st.setScene(sc); + st.show(); + // a felhasználó és korongszám átadása a hanoi ablaknak + HanoiFormController hfc = fl.getController(); + hfc.setFh(fh); + hfc.setKorongokSzama(kspin.getValue()); } @FXML diff --git a/src/hanoi/HanoiFormController.java b/src/hanoi/HanoiFormController.java index 0167f92..5094fc2 100644 --- a/src/hanoi/HanoiFormController.java +++ b/src/hanoi/HanoiFormController.java @@ -4,13 +4,20 @@ import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.FXML; import javafx.scene.input.MouseEvent; +import javafx.scene.layout.AnchorPane; import javafx.scene.layout.Pane; +import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; public class HanoiFormController { + + @FXML private ResourceBundle resources; + + @FXML + private AnchorPane jatekTerulet; @FXML private URL location; @@ -29,7 +36,7 @@ public class HanoiFormController { @FXML void elsoRudClick(MouseEvent event) { - + } @FXML @@ -48,6 +55,44 @@ public class HanoiFormController { assert masodikRudRect != null : "fx:id=\"masodikRudRect\" was not injected: check your FXML file 'hanoi_form2.fxml'."; assert harmadikRudRect != null : "fx:id=\"harmadikRudRect\" was not injected: check your FXML file 'hanoi_form2.fxml'."; assert felvettPane != null : "fx:id=\"felvettPane\" was not injected: check your FXML file 'hanoi_form2.fxml'."; - + r1 = new Rud(elsoRudRect); + r2 = new Rud(masodikRudRect); + r3 = new Rud(harmadikRudRect); + //fh = new Felhasznalo(null); + + } + + private void korongGeneralas() { + //System.out.println(jatekTerulet.widthProperty()); + korongSzelMax = jatekTerulet.getWidth()/3-2*KDIFF; + for (int i = 0; i < korongokSzama; i++) { + + } + } + + + + public void setFh(Felhasznalo fh) { + this.fh = fh; + System.out.println(fh.getNev()); + } + + + + public void setKorongokSzama(int korongokSzama) { + this.korongokSzama = korongokSzama; + korongGeneralas(); + } + + + + private Rud r1; + private Rud r2; + private Rud r3; + private Felhasznalo fh; + private int korongokSzama; + private double korongSzelMax; + final private double KDIFF = 30; + private Color[] szinek = {}; } diff --git a/src/hanoi/hanoi_form2.fxml b/src/hanoi/hanoi_form2.fxml index 1932931..a2ef735 100644 --- a/src/hanoi/hanoi_form2.fxml +++ b/src/hanoi/hanoi_form2.fxml @@ -69,7 +69,7 @@ - + diff --git a/src/module-info.java b/src/module-info.java index 667bdc6..9f7b5b3 100644 --- a/src/module-info.java +++ b/src/module-info.java @@ -1,6 +1,7 @@ module HanoiTornyai { requires javafx.controls; requires javafx.fxml; + requires javafx.graphics; opens hanoi to javafx.graphics, javafx.fxml; }