Browse Source

add Color and Type to CardController

main
fdai7736 12 months ago
parent
commit
73a69a4e6c
  1. 30
      src/main/java/de/hsfulda/onses/controllers/CardController.java
  2. 4
      src/main/resources/de/hsfulda/onses/views/card.fxml

30
src/main/java/de/hsfulda/onses/controllers/CardController.java

@ -20,12 +20,32 @@ public class CardController implements Controller {
@Override
public Parent render() throws IOException {
final Parent parent = FXMLLoader.load(Objects.requireNonNull(Main.class.getResource("views/card.fxml")));
Pane mainPane = (Pane) parent.lookup("#cardPane");
mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: red"));
final Pane mainPane = (Pane) parent.lookup("#cardPane");
final Label cardName = (Label) parent.lookup("#labelName");
cardName.setText(this.card.getValue().name());
switch(card.getColor()) {
case RED -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: red"));
case BLUE -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: blue"));
case GREEN -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: green"));
case YELLOW -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: yellow"));
default -> mainPane.setStyle(addStyle(mainPane.getStyle(), "-fx-background-color: black"));
}
switch(card.getValue()) {
case ONE -> cardName.setText("1");
case TWO -> cardName.setText("2");
case THREE -> cardName.setText("3");
case FOUR -> cardName.setText("4");
case FIVE -> cardName.setText("5");
case SIX -> cardName.setText("6");
case SEVEN -> cardName.setText("7");
case EIGHT -> cardName.setText("8");
case NINE -> cardName.setText("9");
case SKIP -> cardName.setText("skip player");
case CHOOSE -> cardName.setText("wish card");
case DRAWTWO -> cardName.setText("+2");
case REVERSE -> cardName.setText("reverse");
}
return parent;

4
src/main/resources/de/hsfulda/onses/views/card.fxml

@ -7,9 +7,9 @@
<AnchorPane fx:id="cardPane" prefHeight="200.0" prefWidth="130.0" style="-fx-border-color: black; -fx-border-width: 3px;" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label fx:id="labelName" alignment="CENTER" layoutX="45.0" layoutY="91.0" text="1" textAlignment="CENTER" wrapText="true" AnchorPane.bottomAnchor="80.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="80.0">
<Label fx:id="labelName" alignment="CENTER" layoutX="45.0" layoutY="91.0" text="1" textAlignment="CENTER" textFill="#da36d2" wrapText="true" AnchorPane.bottomAnchor="80.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="80.0">
<font>
<Font size="15.0" />
<Font name="System Bold" size="19.0" />
</font>
</Label>
</children>

Loading…
Cancel
Save