Skip to content

Commit

Permalink
restliche KOmmentare
Browse files Browse the repository at this point in the history
  • Loading branch information
aspecialkey committed Jan 28, 2017
1 parent 8e02ab5 commit a6f3e6e
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</ImageView>
</children>
</HBox>
<!--score tableview -->
<!--highscore tableview -->
<TableView fx:id="crudTable" layoutY="83.0" maxWidth="-Infinity" prefHeight="415.0" prefWidth="1024.0">
<columns>
<TableColumn fx:id="idColumn" prefWidth="75.0" text="#" />
Expand All @@ -40,7 +40,7 @@
<TableColumn fx:id="dateColumn" prefWidth="100.0" text="Datum" />
</columns>
</TableView>
<!--pagination for score tableview -->
<!--pagination for highscore tableview -->
<HBox alignment="CENTER" layoutY="500.0" prefHeight="40.0" prefWidth="1024.0">
<children>
<Pagination fx:id="pagination" prefHeight="38.0" prefWidth="500.0" styleClass="pagination" />
Expand All @@ -52,7 +52,7 @@
<Label fx:id="messageLabel" />
</children>
</HBox>
<!-- inputs to save in score -->
<!-- inputs to save in highscore -->
<HBox fx:id="hbox_input" alignment="CENTER" layoutY="540.0" prefHeight="50.0" prefWidth="1024.0" visible="false">
<children>
<TextField fx:id="nameField" alignment="CENTER" promptText="Name (min 4)" styleClass="inputField">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
public class HighscoreViewController implements Initializable {

@FXML
private TableView<Score> crudTable;
private TableView<Highscore> crudTable;
@FXML
private TableColumn<Score, String> nameColumn;
private TableColumn<Highscore, String> nameColumn;
@FXML
private TableColumn<Score, Integer> idColumn;
private TableColumn<Highscore, Integer> idColumn;
@FXML
private TableColumn<Score, Integer> punkteColumn;
private TableColumn<Highscore, Integer> punkteColumn;
@FXML
private TableColumn<Score, String> dateColumn;
private TableColumn<Highscore, String> dateColumn;
@FXML
private TextField nameField;
@FXML
Expand Down Expand Up @@ -76,6 +76,7 @@ public void initialize(URL url, ResourceBundle rb) {
}

highscoreDB.setOrderBy("punkte DESC");
highscoreDB.setFrom(0);

highscoreDB.setItemsPerPage(itemsPerPage);

Expand Down Expand Up @@ -109,7 +110,7 @@ public void initialize(URL url, ResourceBundle rb) {

messageLabel.textProperty().bind(
new SimpleStringProperty("Sie haben " + scoreProperty.intValue() + " Punkte erreicht und damit Platz ")
.concat(highscoreDB.rankingProperty().asString().concat(" in der Score belegt! Bitte geben Sie Ihren Namen ein."))
.concat(highscoreDB.rankingProperty().asString().concat(" in der Highscore belegt! Bitte geben Sie Ihren Namen ein."))
);

hbox_mainmenuBtn.visibleProperty().bind(
Expand Down Expand Up @@ -210,9 +211,9 @@ public void onEventOccured(ActionEvent event) {
*/
private void addScore(int punkte) {

Score score = new Score(0 , nameField.getText(), punkte, "");
Highscore highscore = new Highscore(0 , nameField.getText(), punkte, "");

highscoreDB.addHighscore(score);
highscoreDB.addHighscore(highscore);

Game.getInstance().reset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public ScreenController() {
super();
}


public Node getScreen() {
return screen;
}

/**
* Lädt die View
* @param resource Name der FXML Datei (ohne Endung)
* @return hat geklappt?
*/
public boolean loadScreen(String resource) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(resource));
Expand All @@ -49,10 +49,10 @@ public boolean loadScreen(String resource) {
}
}

//This method tries to displayed the screen with a predefined name.
//First it makes sure the screen has been already loaded. Then if there is more than
//one screen the new screen is been added second, and then the current screen is removed.
// If there isn't any screen being displayed, the new screen is just added to the root.
/**
* Setzt die View
* @param resource Name der FXML Datei (ohne Endung)
*/
public boolean setScreen(final String resource) {
if (!loadScreen(resource)) {
System.out.println("ScreenController: view konnte nicht geladen werden - " + resource);
Expand All @@ -63,49 +63,7 @@ public boolean setScreen(final String resource) {
} else {
getChildren().add(screen);
}
// final DoubleProperty opacity = opacityProperty();
// if (!getChildren().isEmpty()) { //if there is more than one screen
// Timeline fade = new Timeline(
// new KeyFrame(Duration.ZERO, new KeyValue(opacity, 1.0)),
// new KeyFrame(new Duration(1000), new EventHandler<ActionEvent>() {
// @Override
// public void handle(ActionEvent t) {
// getChildren().remove(0); //remove the displayed screen
// getChildren().add(0, screens.get(name)); //add the screen
// Timeline fadeIn = new Timeline(
// new KeyFrame(Duration.ZERO, new KeyValue(opacity, 0.0)),
// new KeyFrame(new Duration(800), new KeyValue(opacity, 1.0)));
// fadeIn.play();
// }
// }, new KeyValue(opacity, 0.0)));
// fade.play();
//
// } else {
// setOpacity(0.0);
// getChildren().add(screens.get(name)); //no one else been displayed, then just show
// Timeline fadeIn = new Timeline(
// new KeyFrame(Duration.ZERO, new KeyValue(opacity, 0.0)),
// new KeyFrame(new Duration(2500), new KeyValue(opacity, 1.0)));
// fadeIn.play();
// }
return true;



/*Node screenToRemove;
if(screens.get(name) != null){ //screen loaded
if(!getChildren().isEmpty()){ //if there is more than one screen
getChildren().add(0, screens.get(name)); //add the screen
screenToRemove = getChildren().get(1);
getChildren().remove(1); //remove the displayed screen
}else{
getChildren().add(screens.get(name)); //no one else been displayed, then just show
}
return true;
}else {
System.out.println("screen hasn't been loaded!!! \n");
return false;
}*/
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void goToScreenGameplayView(ActionEvent event) {
}

/**
* Wechselt zur Score-View.
* Wechselt zur Highscore-View.
* @param event
*/
@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void addSpriteToPane(ISprite sprite){

/**
* Konstruiert den Spielplatz für alle Elemente
* bindet die spiellogikrelevanten Elemente (Score, Leben) an die View
* bindet die spiellogikrelevanten Elemente (Highscore, Leben) an die View
* @param pane Entrynode in der View
*/
public void constructGame(AnchorPane pane) {
Expand Down
Loading

0 comments on commit a6f3e6e

Please sign in to comment.