Browse Source
Merge branch 'GameUI' into 'main'
Merge branch 'GameUI' into 'main'
add Game UI See merge request fdai7736/onses!30main
fdai7736
11 months ago
20 changed files with 429 additions and 191 deletions
-
3README.md
-
44src/main/java/de/hsfulda/onses/App.java
-
32src/main/java/de/hsfulda/onses/controllers/AppController.java
-
102src/main/java/de/hsfulda/onses/controllers/CardController.java
-
4src/main/java/de/hsfulda/onses/controllers/Controller.java
-
92src/main/java/de/hsfulda/onses/controllers/GameController.java
-
40src/main/java/de/hsfulda/onses/controllers/GameOverController.java
-
30src/main/java/de/hsfulda/onses/controllers/PlayerController.java
-
25src/main/java/de/hsfulda/onses/models/Card.java
-
3src/main/java/de/hsfulda/onses/models/Game.java
-
4src/main/java/de/hsfulda/onses/models/Player.java
-
54src/main/java/de/hsfulda/onses/services/GameService.java
-
32src/main/java/de/hsfulda/onses/services/PlayerService.java
-
6src/main/resources/de/hsfulda/onses/views/app.fxml
-
11src/main/resources/de/hsfulda/onses/views/game.fxml
-
22src/main/resources/de/hsfulda/onses/views/gameOver.fxml
-
10src/test/java/de/hsfulda/onses/CardTest.java
-
91src/test/java/de/hsfulda/onses/GameServiceTest.java
-
4src/test/java/de/hsfulda/onses/GuiTest.java
-
11src/test/java/de/hsfulda/onses/PlayerTest.java
@ -1,5 +1,8 @@ |
|||||
# Onses - Uno Game |
# Onses - Uno Game |
||||
|
|
||||
|
## Disclaimer for Tests |
||||
|
**!!Do not move the mouse while tests are running!!** |
||||
|
|
||||
## git setup after clone |
## git setup after clone |
||||
```shell |
```shell |
||||
git config user.name "<FD-Nummer>" |
git config user.name "<FD-Nummer>" |
||||
|
@ -1,18 +1,54 @@ |
|||||
package de.hsfulda.onses; |
package de.hsfulda.onses; |
||||
|
|
||||
import de.hsfulda.onses.controllers.AppController; |
import de.hsfulda.onses.controllers.AppController; |
||||
|
import de.hsfulda.onses.controllers.Controller; |
||||
import de.hsfulda.onses.services.GameService; |
import de.hsfulda.onses.services.GameService; |
||||
import javafx.application.Application; |
import javafx.application.Application; |
||||
|
import javafx.scene.Parent; |
||||
import javafx.scene.Scene; |
import javafx.scene.Scene; |
||||
|
import javafx.scene.control.Label; |
||||
import javafx.stage.Stage; |
import javafx.stage.Stage; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
|
||||
public class App extends Application { |
public class App extends Application { |
||||
|
|
||||
|
private Stage stage; |
||||
|
private Controller controller; |
||||
|
|
||||
|
private final GameService gameService; |
||||
|
|
||||
|
public App() { |
||||
|
this(new GameService()); |
||||
|
} |
||||
|
|
||||
|
public App(GameService gameService) { |
||||
|
this.gameService = gameService; |
||||
|
} |
||||
@Override |
@Override |
||||
public void start(Stage stage) throws Exception { |
|
||||
final AppController appController = new AppController(new GameService(), stage); |
|
||||
|
public void start(Stage stage) { |
||||
|
this.stage = stage; |
||||
|
final AppController appController = new AppController(this, this.gameService); |
||||
|
|
||||
|
stage.setScene(new Scene(new Label("Loading..."))); |
||||
|
stage.setOnCloseRequest(e -> controller.destroy()); |
||||
|
|
||||
stage.setTitle("Onses - Uno"); |
|
||||
stage.setScene(new Scene(appController.render())); |
|
||||
|
show(appController); |
||||
stage.show(); |
stage.show(); |
||||
} |
} |
||||
|
|
||||
|
public void show(Controller controller) { |
||||
|
try { |
||||
|
final Parent parent = controller.render(); |
||||
|
stage.getScene().setRoot(parent); |
||||
|
} catch (IOException e) { |
||||
|
throw new RuntimeException(e); |
||||
|
} |
||||
|
|
||||
|
if(this.controller != null) { |
||||
|
this.controller.destroy(); |
||||
|
} |
||||
|
this.controller = controller; |
||||
|
stage.setTitle(controller.getTitle()); |
||||
|
} |
||||
} |
} |
@ -0,0 +1,40 @@ |
|||||
|
package de.hsfulda.onses.controllers; |
||||
|
|
||||
|
import de.hsfulda.onses.App; |
||||
|
import de.hsfulda.onses.Main; |
||||
|
import de.hsfulda.onses.services.GameService; |
||||
|
import javafx.fxml.FXMLLoader; |
||||
|
import javafx.scene.Parent; |
||||
|
import javafx.scene.control.Button; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.util.Objects; |
||||
|
|
||||
|
public class GameOverController implements Controller { |
||||
|
|
||||
|
private final App app; |
||||
|
|
||||
|
public GameOverController(App app) { |
||||
|
this.app = app; |
||||
|
} |
||||
|
@Override |
||||
|
public Parent render() throws IOException { |
||||
|
final Parent parent = FXMLLoader.load(Objects.requireNonNull(Main.class.getResource("views/gameOver.fxml"))); |
||||
|
final Button newGameButton = (Button) parent.lookup("#newGameBtn"); |
||||
|
|
||||
|
newGameButton.setOnAction(e -> { |
||||
|
app.show(new GameController(app, new GameService())); |
||||
|
}); |
||||
|
return parent; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void destroy() { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String getTitle() { |
||||
|
return null; |
||||
|
} |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
|
||||
|
<?import javafx.scene.control.Button?> |
||||
|
<?import javafx.scene.control.Label?> |
||||
|
<?import javafx.scene.layout.AnchorPane?> |
||||
|
<?import javafx.scene.text.Font?> |
||||
|
|
||||
|
|
||||
|
<AnchorPane prefHeight="690.0" prefWidth="1254.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1"> |
||||
|
<children> |
||||
|
<Label layoutX="504.0" layoutY="158.0" text="Game Over" AnchorPane.leftAnchor="504.0" AnchorPane.topAnchor="158.0"> |
||||
|
<font> |
||||
|
<Font size="43.0" /> |
||||
|
</font> |
||||
|
</Label> |
||||
|
<Button fx:id="newGameBtn" layoutX="569.0" layoutY="329.0" mnemonicParsing="false" text="New Game" AnchorPane.leftAnchor="569.0" AnchorPane.topAnchor="329.0"> |
||||
|
<font> |
||||
|
<Font size="17.0" /> |
||||
|
</font> |
||||
|
</Button> |
||||
|
</children> |
||||
|
</AnchorPane> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue