mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Refactored nextScreen runnable
This commit is contained in:
@@ -9,17 +9,10 @@ import org.toop.framework.resource.ResourceManager;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Connect4TutorialWidget extends BaseTutorialWidget {
|
public class Connect4TutorialWidget extends BaseTutorialWidget {
|
||||||
public Connect4TutorialWidget(GameInformation information) {
|
public Connect4TutorialWidget(Runnable nextScreen) {
|
||||||
super(List.of(
|
super(List.of(
|
||||||
new ImmutablePair<>("connect4.1", ResourceManager.get("connect41.png")),
|
new ImmutablePair<>("connect4.1", ResourceManager.get("connect41.png")),
|
||||||
new ImmutablePair<>("connect4.2", ResourceManager.get("connect42.png"))
|
new ImmutablePair<>("connect4.2", ResourceManager.get("connect42.png"))
|
||||||
), () -> Platform.runLater(() -> new Connect4Game(information)));
|
), nextScreen);
|
||||||
}
|
|
||||||
|
|
||||||
public Connect4TutorialWidget() {
|
|
||||||
super(List.of(
|
|
||||||
new ImmutablePair<>("connect4.1", ResourceManager.get("connect41.png")),
|
|
||||||
new ImmutablePair<>("connect4.2", ResourceManager.get("connect42.png"))
|
|
||||||
), () -> {});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,17 @@
|
|||||||
package org.toop.app.widget.tutorial;
|
package org.toop.app.widget.tutorial;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
|
||||||
import org.apache.maven.surefire.shared.lang3.tuple.ImmutablePair;
|
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 org.toop.framework.resource.ResourceManager;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ReversiTutorialWidget extends BaseTutorialWidget {
|
public class ReversiTutorialWidget extends BaseTutorialWidget {
|
||||||
public ReversiTutorialWidget(GameInformation gameInformation) {
|
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"))
|
|
||||||
), () -> Platform.runLater(() -> new ReversiGame(gameInformation)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReversiTutorialWidget() {
|
|
||||||
super(List.of(
|
super(List.of(
|
||||||
new ImmutablePair<>("reversi1", ResourceManager.get("reversi1.png")),
|
new ImmutablePair<>("reversi1", ResourceManager.get("reversi1.png")),
|
||||||
new ImmutablePair<>("reversi2", ResourceManager.get("reversi2.png")),
|
new ImmutablePair<>("reversi2", ResourceManager.get("reversi2.png")),
|
||||||
new ImmutablePair<>("reversi3", ResourceManager.get("cat.jpg")),
|
new ImmutablePair<>("reversi3", ResourceManager.get("cat.jpg")),
|
||||||
new ImmutablePair<>("reversi4", ResourceManager.get("cat.jpg"))
|
new ImmutablePair<>("reversi4", ResourceManager.get("cat.jpg"))
|
||||||
), () -> {});
|
), nextScreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,19 +14,11 @@ import java.io.File;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TicTacToeTutorialWidget extends BaseTutorialWidget {
|
public class TicTacToeTutorialWidget extends BaseTutorialWidget {
|
||||||
|
public TicTacToeTutorialWidget(Runnable nextScreen) {
|
||||||
public TicTacToeTutorialWidget(GameInformation gameInformation) {
|
|
||||||
super(List.of(
|
super(List.of(
|
||||||
new ImmutablePair<>("tictactoe1", ResourceManager.get("tictactoe1.png")),
|
new ImmutablePair<>("tictactoe1", ResourceManager.get("tictactoe1.png")),
|
||||||
new ImmutablePair<>("tictactoe2", ResourceManager.get("tictactoe2.png"))
|
new ImmutablePair<>("tictactoe2", ResourceManager.get("tictactoe2.png"))
|
||||||
), () -> Platform.runLater(() -> new TicTacToeGameThread(gameInformation)));
|
), nextScreen);
|
||||||
}
|
|
||||||
|
|
||||||
public TicTacToeTutorialWidget() {
|
|
||||||
super(List.of(
|
|
||||||
new ImmutablePair<>("tictactoe1", ResourceManager.get("tictactoe1.png")),
|
|
||||||
new ImmutablePair<>("tictactoe2", ResourceManager.get("tictactoe2.png"))
|
|
||||||
), () -> {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ public final class GameView extends ViewWidget {
|
|||||||
|
|
||||||
switch(gameType) {
|
switch(gameType) {
|
||||||
case "TicTacToe":
|
case "TicTacToe":
|
||||||
this.tutorialButton = Primitive.button("tutorialstring", TicTacToeTutorialWidget::new); break;
|
this.tutorialButton = Primitive.button("tutorialstring", () -> new TicTacToeTutorialWidget(() -> {})); break;
|
||||||
case "Reversi":
|
case "Reversi":
|
||||||
this.tutorialButton = Primitive.button("tutorialstring", ReversiTutorialWidget::new); break;
|
this.tutorialButton = Primitive.button("tutorialstring", () -> new ReversiTutorialWidget(() -> {})); break;
|
||||||
case "Connect4":
|
case "Connect4":
|
||||||
this.tutorialButton = Primitive.button("tutorialstring", Connect4TutorialWidget::new); break;
|
this.tutorialButton = Primitive.button("tutorialstring", () -> new Connect4TutorialWidget(() -> {})); break;
|
||||||
default:
|
default:
|
||||||
this.tutorialButton = null; break;
|
this.tutorialButton = null; break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class LocalMultiplayerView extends ViewWidget {
|
|||||||
"tutorial",
|
"tutorial",
|
||||||
() -> {
|
() -> {
|
||||||
AppSettings.getSettings().setFirstTTT(false);
|
AppSettings.getSettings().setFirstTTT(false);
|
||||||
new TicTacToeTutorialWidget(information);
|
new TicTacToeTutorialWidget(() -> new TicTacToeGameThread(information));
|
||||||
},
|
},
|
||||||
() -> {
|
() -> {
|
||||||
AppSettings.getSettings().setFirstTTT(false);
|
AppSettings.getSettings().setFirstTTT(false);
|
||||||
@@ -67,7 +67,7 @@ public class LocalMultiplayerView extends ViewWidget {
|
|||||||
"tutorial",
|
"tutorial",
|
||||||
() -> {
|
() -> {
|
||||||
AppSettings.getSettings().setFirstTTT(false);
|
AppSettings.getSettings().setFirstTTT(false);
|
||||||
new ReversiTutorialWidget(information);
|
new ReversiTutorialWidget(() -> new ReversiGame(information));
|
||||||
},
|
},
|
||||||
() -> {
|
() -> {
|
||||||
AppSettings.getSettings().setFirstTTT(false);
|
AppSettings.getSettings().setFirstTTT(false);
|
||||||
@@ -93,7 +93,7 @@ public class LocalMultiplayerView extends ViewWidget {
|
|||||||
"tutorial",
|
"tutorial",
|
||||||
() -> {
|
() -> {
|
||||||
AppSettings.getSettings().setFirstTTT(false);
|
AppSettings.getSettings().setFirstTTT(false);
|
||||||
new Connect4TutorialWidget(information);
|
new Connect4TutorialWidget(() -> new Connect4Game(information));
|
||||||
},
|
},
|
||||||
() -> {
|
() -> {
|
||||||
AppSettings.getSettings().setFirstTTT(false);
|
AppSettings.getSettings().setFirstTTT(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user