Refactored nextScreen runnable

This commit is contained in:
lieght
2025-11-28 19:35:31 +01:00
parent 164708dcf5
commit ea7a5e11ba
5 changed files with 12 additions and 39 deletions

View File

@@ -9,17 +9,10 @@ import org.toop.framework.resource.ResourceManager;
import java.util.List;
public class Connect4TutorialWidget extends BaseTutorialWidget {
public Connect4TutorialWidget(GameInformation information) {
public Connect4TutorialWidget(Runnable nextScreen) {
super(List.of(
new ImmutablePair<>("connect4.1", ResourceManager.get("connect41.png")),
new ImmutablePair<>("connect4.2", ResourceManager.get("connect42.png"))
), () -> Platform.runLater(() -> new Connect4Game(information)));
}
public Connect4TutorialWidget() {
super(List.of(
new ImmutablePair<>("connect4.1", ResourceManager.get("connect41.png")),
new ImmutablePair<>("connect4.2", ResourceManager.get("connect42.png"))
), () -> {});
), nextScreen);
}
}

View File

@@ -1,29 +1,17 @@
package org.toop.app.widget.tutorial;
import javafx.application.Platform;
import org.apache.maven.surefire.shared.lang3.tuple.ImmutablePair;
import org.toop.app.GameInformation;
import org.toop.app.game.ReversiGame;
import org.toop.framework.resource.ResourceManager;
import java.util.List;
public class ReversiTutorialWidget extends BaseTutorialWidget {
public ReversiTutorialWidget(GameInformation gameInformation) {
super(List.of(
new ImmutablePair<>("reversi1", ResourceManager.get("reversi1.png")),
new ImmutablePair<>("reversi2", ResourceManager.get("reversi2.png")),
new ImmutablePair<>("reversi3", ResourceManager.get("cat.jpg")),
new ImmutablePair<>("reversi4", ResourceManager.get("cat.jpg"))
), () -> Platform.runLater(() -> new ReversiGame(gameInformation)));
}
public ReversiTutorialWidget() {
public ReversiTutorialWidget(Runnable nextScreen) {
super(List.of(
new ImmutablePair<>("reversi1", ResourceManager.get("reversi1.png")),
new ImmutablePair<>("reversi2", ResourceManager.get("reversi2.png")),
new ImmutablePair<>("reversi3", ResourceManager.get("cat.jpg")),
new ImmutablePair<>("reversi4", ResourceManager.get("cat.jpg"))
), () -> {});
), nextScreen);
}
}

View File

@@ -14,19 +14,11 @@ import java.io.File;
import java.util.List;
public class TicTacToeTutorialWidget extends BaseTutorialWidget {
public TicTacToeTutorialWidget(GameInformation gameInformation) {
public TicTacToeTutorialWidget(Runnable nextScreen) {
super(List.of(
new ImmutablePair<>("tictactoe1", ResourceManager.get("tictactoe1.png")),
new ImmutablePair<>("tictactoe2", ResourceManager.get("tictactoe2.png"))
), () -> Platform.runLater(() -> new TicTacToeGameThread(gameInformation)));
}
public TicTacToeTutorialWidget() {
super(List.of(
new ImmutablePair<>("tictactoe1", ResourceManager.get("tictactoe1.png")),
new ImmutablePair<>("tictactoe2", ResourceManager.get("tictactoe2.png"))
), () -> {});
), nextScreen);
}
}

View File

@@ -53,11 +53,11 @@ public final class GameView extends ViewWidget {
switch(gameType) {
case "TicTacToe":
this.tutorialButton = Primitive.button("tutorialstring", TicTacToeTutorialWidget::new); break;
this.tutorialButton = Primitive.button("tutorialstring", () -> new TicTacToeTutorialWidget(() -> {})); break;
case "Reversi":
this.tutorialButton = Primitive.button("tutorialstring", ReversiTutorialWidget::new); break;
this.tutorialButton = Primitive.button("tutorialstring", () -> new ReversiTutorialWidget(() -> {})); break;
case "Connect4":
this.tutorialButton = Primitive.button("tutorialstring", Connect4TutorialWidget::new); break;
this.tutorialButton = Primitive.button("tutorialstring", () -> new Connect4TutorialWidget(() -> {})); break;
default:
this.tutorialButton = null; break;
}

View File

@@ -41,7 +41,7 @@ public class LocalMultiplayerView extends ViewWidget {
"tutorial",
() -> {
AppSettings.getSettings().setFirstTTT(false);
new TicTacToeTutorialWidget(information);
new TicTacToeTutorialWidget(() -> new TicTacToeGameThread(information));
},
() -> {
AppSettings.getSettings().setFirstTTT(false);
@@ -67,7 +67,7 @@ public class LocalMultiplayerView extends ViewWidget {
"tutorial",
() -> {
AppSettings.getSettings().setFirstTTT(false);
new ReversiTutorialWidget(information);
new ReversiTutorialWidget(() -> new ReversiGame(information));
},
() -> {
AppSettings.getSettings().setFirstTTT(false);
@@ -93,7 +93,7 @@ public class LocalMultiplayerView extends ViewWidget {
"tutorial",
() -> {
AppSettings.getSettings().setFirstTTT(false);
new Connect4TutorialWidget(information);
new Connect4TutorialWidget(() -> new Connect4Game(information));
},
() -> {
AppSettings.getSettings().setFirstTTT(false);