mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Compare commits
10 Commits
289-server
...
TimerSongD
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da27399dda | ||
|
|
c98edc37a6 | ||
|
|
c21f254234 | ||
|
|
fd85a73608 | ||
|
|
ea7a5e11ba | ||
|
|
164708dcf5 | ||
|
|
eb5e69a59c | ||
|
|
b3c9f89f99 | ||
|
|
6b619604ec | ||
|
|
1ec1c0d13d |
@@ -47,8 +47,7 @@ public final class Primitive {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageView image(File file) {
|
public static ImageView image(ImageAsset imageAsset) {
|
||||||
ImageAsset imageAsset = new ImageAsset(file);
|
|
||||||
ImageView imageView = new ImageView(imageAsset.getImage());
|
ImageView imageView = new ImageView(imageAsset.getImage());
|
||||||
imageView.getStyleClass().add("image");
|
imageView.getStyleClass().add("image");
|
||||||
imageView.setPreserveRatio(true);
|
imageView.setPreserveRatio(true);
|
||||||
|
|||||||
5
app/src/main/java/org/toop/app/widget/Updatable.java
Normal file
5
app/src/main/java/org/toop/app/widget/Updatable.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package org.toop.app.widget;
|
||||||
|
|
||||||
|
public interface Updatable {
|
||||||
|
void update();
|
||||||
|
}
|
||||||
@@ -1,7 +1,21 @@
|
|||||||
package org.toop.app.widget.complex;
|
package org.toop.app.widget.complex;
|
||||||
|
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
|
||||||
public abstract class PopupWidget extends StackWidget {
|
public abstract class PopupWidget extends StackWidget {
|
||||||
|
private final Button popButton;
|
||||||
|
|
||||||
public PopupWidget() {
|
public PopupWidget() {
|
||||||
super("bg-popup");
|
super("bg-popup");
|
||||||
|
|
||||||
|
popButton = new Button("X");
|
||||||
|
popButton.setOnAction(_ -> hide());
|
||||||
|
|
||||||
|
add(Pos.TOP_RIGHT, popButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setOnPop(Runnable onPop) {
|
||||||
|
popButton.setOnAction(_ -> onPop.run());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
package org.toop.app.widget.display;
|
package org.toop.app.widget.display;
|
||||||
|
|
||||||
|
import javafx.animation.KeyFrame;
|
||||||
|
import javafx.animation.Timeline;
|
||||||
|
import javafx.util.Duration;
|
||||||
import org.toop.app.widget.Widget;
|
import org.toop.app.widget.Widget;
|
||||||
import org.toop.framework.audio.events.AudioEvents;
|
import org.toop.framework.audio.events.AudioEvents;
|
||||||
import org.toop.framework.eventbus.EventFlow;
|
import org.toop.framework.eventbus.EventFlow;
|
||||||
@@ -15,10 +18,13 @@ import javafx.scene.layout.Region;
|
|||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
|
|
||||||
|
import java.util.Timer;
|
||||||
|
|
||||||
public class SongDisplay extends VBox implements Widget {
|
public class SongDisplay extends VBox implements Widget {
|
||||||
private final Text songTitle;
|
private final Text songTitle;
|
||||||
private final ProgressBar progressBar;
|
private final ProgressBar progressBar;
|
||||||
private final Text progressText;
|
private final Text progressText;
|
||||||
|
private boolean canClick = true;
|
||||||
|
|
||||||
public SongDisplay() {
|
public SongDisplay() {
|
||||||
new EventFlow()
|
new EventFlow()
|
||||||
@@ -49,10 +55,13 @@ public class SongDisplay extends VBox implements Widget {
|
|||||||
previousButton.getStyleClass().setAll("previous-button");
|
previousButton.getStyleClass().setAll("previous-button");
|
||||||
|
|
||||||
skipButton.setOnAction( event -> {
|
skipButton.setOnAction( event -> {
|
||||||
|
if (!canClick) { return; }
|
||||||
GlobalEventBus.post(new AudioEvents.SkipMusic());
|
GlobalEventBus.post(new AudioEvents.SkipMusic());
|
||||||
|
doCooldown();
|
||||||
});
|
});
|
||||||
|
|
||||||
pauseButton.setOnAction(event -> {
|
pauseButton.setOnAction(event -> {
|
||||||
|
if (!canClick) { return; }
|
||||||
GlobalEventBus.post(new AudioEvents.PauseMusic());
|
GlobalEventBus.post(new AudioEvents.PauseMusic());
|
||||||
if (pauseButton.getText().equals("⏸")) {
|
if (pauseButton.getText().equals("⏸")) {
|
||||||
pauseButton.setText("▶");
|
pauseButton.setText("▶");
|
||||||
@@ -60,10 +69,13 @@ public class SongDisplay extends VBox implements Widget {
|
|||||||
else if (pauseButton.getText().equals("▶")) {
|
else if (pauseButton.getText().equals("▶")) {
|
||||||
pauseButton.setText("⏸");
|
pauseButton.setText("⏸");
|
||||||
}
|
}
|
||||||
|
doCooldown();
|
||||||
});
|
});
|
||||||
|
|
||||||
previousButton.setOnAction( event -> {
|
previousButton.setOnAction( event -> {
|
||||||
|
if (!canClick) { return; }
|
||||||
GlobalEventBus.post(new AudioEvents.PreviousMusic());
|
GlobalEventBus.post(new AudioEvents.PreviousMusic());
|
||||||
|
doCooldown();
|
||||||
});
|
});
|
||||||
|
|
||||||
HBox control = new HBox(10, previousButton, pauseButton, skipButton);
|
HBox control = new HBox(10, previousButton, pauseButton, skipButton);
|
||||||
@@ -110,6 +122,16 @@ public class SongDisplay extends VBox implements Widget {
|
|||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doCooldown() {
|
||||||
|
canClick = false;
|
||||||
|
Timeline cooldown = new Timeline(
|
||||||
|
new KeyFrame(Duration.millis(300), event -> canClick = true)
|
||||||
|
);
|
||||||
|
cooldown.setCycleCount(1);
|
||||||
|
cooldown.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Node getNode() {
|
public Node getNode() {
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -20,5 +20,10 @@ public class QuitPopup extends PopupWidget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
add(Pos.CENTER, confirmWidget);
|
add(Pos.CENTER, confirmWidget);
|
||||||
|
|
||||||
|
setOnPop(() -> {
|
||||||
|
App.stopQuit();
|
||||||
|
hide();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,60 +1,116 @@
|
|||||||
package org.toop.app.widget.tutorial;
|
package org.toop.app.widget.tutorial;
|
||||||
|
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
|
import org.apache.maven.surefire.shared.lang3.tuple.ImmutablePair;
|
||||||
import org.toop.app.widget.Primitive;
|
import org.toop.app.widget.Primitive;
|
||||||
import org.toop.app.widget.complex.ViewWidget;
|
import org.toop.app.widget.Updatable;
|
||||||
|
import org.toop.app.widget.WidgetContainer;
|
||||||
|
import org.toop.app.widget.complex.PopupWidget;
|
||||||
|
|
||||||
import javafx.scene.control.Button;
|
import org.toop.framework.resource.resources.ImageAsset;
|
||||||
import org.toop.local.AppContext;
|
import org.toop.local.AppContext;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.List;
|
||||||
|
|
||||||
public class BaseTutorialWidget extends ViewWidget {
|
/**
|
||||||
|
* A widget base for all the tutorial widgets.
|
||||||
|
*
|
||||||
|
* <p>Usage example:
|
||||||
|
*
|
||||||
|
* <pre>{@code
|
||||||
|
* public class Connect4TutorialWidget extends BaseTutorialWidget {
|
||||||
|
* public Connect4TutorialWidget(Runnable nextScreen) {
|
||||||
|
* super(List.of(
|
||||||
|
* new ImmutablePair<>("connect4.1", ResourceManager.get("connect41.png")),
|
||||||
|
* new ImmutablePair<>("connect4.2", ResourceManager.get("connect42.png"))
|
||||||
|
* ), nextScreen);
|
||||||
|
* }
|
||||||
|
* }</pre>
|
||||||
|
*/
|
||||||
|
public class BaseTutorialWidget extends PopupWidget implements Updatable {
|
||||||
|
|
||||||
private TState state;
|
private final Text tutorialText;
|
||||||
private Text tutorialText;
|
private final ImageView imagery;
|
||||||
private Button previousButton;
|
private final Button previousButton;
|
||||||
private Button nextButton;
|
private final Button nextButton;
|
||||||
private Button noButton;
|
private final List<ImmutablePair<String, ImageAsset>> pages;
|
||||||
private Button yesButton;
|
private final Runnable nextScreen;
|
||||||
private Button neverButton;
|
|
||||||
private ImageView imagery;
|
|
||||||
|
|
||||||
public BaseTutorialWidget(String key, Runnable onNo, Runnable onYes, Runnable onNever) {
|
private int pageIndex = 0;
|
||||||
System.out.println("Trying to initialize...");
|
|
||||||
this.tutorialText = Primitive.text(key);
|
|
||||||
this.yesButton = Primitive.button("ok", () -> onYes.run());
|
|
||||||
this.noButton = Primitive.button("no", () -> onNo.run());
|
|
||||||
this.neverButton = Primitive.button("never", () -> onNever.run());
|
|
||||||
var a = Primitive.hbox(yesButton, noButton, neverButton);
|
|
||||||
add(Pos.CENTER, Primitive.vbox(tutorialText, a));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseTutorialWidget(TState state, String key, Runnable onPrevious, Runnable onNext) {
|
public BaseTutorialWidget(List<ImmutablePair<String, ImageAsset>> pages, Runnable nextScreen) {
|
||||||
this.state = state;
|
this.tutorialText = Primitive.text(pages.getFirst().getKey());
|
||||||
this.tutorialText = Primitive.text(key);
|
this.imagery = Primitive.image(pages.getFirst().getValue());
|
||||||
this.previousButton = Primitive.button("<", () -> onPrevious.run());
|
|
||||||
this.nextButton = Primitive.button(">", () -> onNext.run());
|
this.pages = pages;
|
||||||
var w = Primitive.hbox(previousButton, nextButton);
|
this.nextScreen = nextScreen;
|
||||||
add(Pos.CENTER, Primitive.vbox(tutorialText, w));
|
|
||||||
}
|
previousButton = Primitive.button("goback", () -> { update(false); this.hide(); });
|
||||||
|
nextButton = Primitive.button(">", () -> update(true));
|
||||||
|
|
||||||
|
var w = Primitive.hbox(
|
||||||
|
previousButton,
|
||||||
|
nextButton
|
||||||
|
);
|
||||||
|
|
||||||
|
var x = Primitive.vbox(imagery, tutorialText);
|
||||||
|
|
||||||
public BaseTutorialWidget(TState state, String key, File image, Runnable onPrevious, Runnable onNext) {
|
|
||||||
this.state = state;
|
|
||||||
this.imagery = Primitive.image(image);
|
|
||||||
this.tutorialText = Primitive.text(key);
|
|
||||||
this.previousButton = Primitive.button("<", () -> onPrevious.run());
|
|
||||||
this.nextButton = Primitive.button(">", () -> onNext.run());
|
|
||||||
var w = Primitive.hbox(previousButton, nextButton);
|
|
||||||
var x = Primitive.vbox(imagery, tutorialText);
|
|
||||||
add(Pos.CENTER, Primitive.vbox(x, w));
|
add(Pos.CENTER, Primitive.vbox(x, w));
|
||||||
|
|
||||||
|
WidgetContainer.add(Pos.CENTER, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(String key, File image) {
|
@Override
|
||||||
|
public void update() {
|
||||||
|
update(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Refactor if statements to make code easier to read.
|
||||||
|
public void update(boolean next) {
|
||||||
|
pageIndex = next ? pageIndex + 1 : pageIndex - 1;
|
||||||
|
|
||||||
|
if (pageIndex >= pages.size()) {
|
||||||
|
pageIndex--;
|
||||||
|
return;
|
||||||
|
} else if (pageIndex < 0) {
|
||||||
|
pageIndex++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageIndex == pages.size()-1) {
|
||||||
|
nextButton.textProperty().unbind();
|
||||||
|
nextButton.setText(AppContext.getString("startgame"));
|
||||||
|
nextButton.setOnAction((_) -> {
|
||||||
|
this.hide();
|
||||||
|
nextScreen.run();
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
nextButton.textProperty().unbind();
|
||||||
|
nextButton.setText(AppContext.getString(">"));
|
||||||
|
nextButton.setOnAction((_) -> this.update(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageIndex == 0) {
|
||||||
|
previousButton.textProperty().unbind();
|
||||||
|
previousButton.setText(AppContext.getString("goback"));
|
||||||
|
previousButton.setOnAction((_) -> this.hide());
|
||||||
|
} else {
|
||||||
|
previousButton.textProperty().unbind();
|
||||||
|
previousButton.setText(AppContext.getString("<"));
|
||||||
|
previousButton.setOnAction((_) -> this.update(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentPage = pages.get(pageIndex);
|
||||||
|
|
||||||
|
var text = currentPage.getKey();
|
||||||
|
var image = currentPage.getValue();
|
||||||
|
|
||||||
tutorialText.textProperty().unbind();
|
tutorialText.textProperty().unbind();
|
||||||
tutorialText.setText(AppContext.getString(key));
|
tutorialText.setText(AppContext.getString(text));
|
||||||
imagery.setImage(Primitive.image(image).getImage());
|
imagery.setImage(Primitive.image(image).getImage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,15 @@
|
|||||||
package org.toop.app.widget.tutorial;
|
package org.toop.app.widget.tutorial;
|
||||||
|
|
||||||
import javafx.geometry.Pos;
|
import org.apache.maven.surefire.shared.lang3.tuple.ImmutablePair;
|
||||||
import org.toop.app.widget.complex.ViewWidget;
|
import org.toop.framework.resource.ResourceManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.List;
|
||||||
|
|
||||||
public class Connect4TutorialWidget extends ViewWidget {
|
public class Connect4TutorialWidget extends BaseTutorialWidget {
|
||||||
private TState state;
|
public Connect4TutorialWidget(Runnable nextScreen) {
|
||||||
private String[] keys = {"connect4.1", "connect4.2"};
|
super(List.of(
|
||||||
private File[] images = {new File("app/src/main/resources/assets/images/connect41.png"), new File("app/src/main/resources/assets/images/connect42.png")};
|
new ImmutablePair<>("connect4.1", ResourceManager.get("connect41.png")),
|
||||||
private BaseTutorialWidget tutorialWidget;
|
new ImmutablePair<>("connect4.2", ResourceManager.get("connect42.png"))
|
||||||
|
), nextScreen);
|
||||||
public Connect4TutorialWidget() {
|
|
||||||
this.state = new TState(keys.length);
|
|
||||||
tutorialWidget = new BaseTutorialWidget(
|
|
||||||
state,
|
|
||||||
keys[state.getCurrent()],
|
|
||||||
images[state.getCurrent()],
|
|
||||||
() -> {
|
|
||||||
if (state.hasPrevious()) {
|
|
||||||
state.previous();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
() -> {
|
|
||||||
if (state.hasNext()) {
|
|
||||||
state.next();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
add(Pos.CENTER, tutorialWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void update() {
|
|
||||||
tutorialWidget.update(keys[state.getCurrent()], images[state.getCurrent()]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,17 @@
|
|||||||
package org.toop.app.widget.tutorial;
|
package org.toop.app.widget.tutorial;
|
||||||
|
|
||||||
import javafx.geometry.Pos;
|
import org.apache.maven.surefire.shared.lang3.tuple.ImmutablePair;
|
||||||
import org.toop.app.widget.complex.ViewWidget;
|
import org.toop.framework.resource.ResourceManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.List;
|
||||||
|
|
||||||
public class ReversiTutorialWidget extends ViewWidget {
|
public class ReversiTutorialWidget extends BaseTutorialWidget {
|
||||||
private TState state;
|
public ReversiTutorialWidget(Runnable nextScreen) {
|
||||||
private String[] keys = {"reversi1", "reversi2", "reversi3", "reversi4"};
|
super(List.of(
|
||||||
private File[] images = {new File("app/src/main/resources/assets/images/reversi1.png"), new File("app/src/main/resources/assets/images/reversi2.png"), new File("app/src/main/resources/assets/images/cat.jpg"), new File("app/src/main/resources/assets/images/cat.jpg")};
|
new ImmutablePair<>("reversi1", ResourceManager.get("reversi1.png")),
|
||||||
private BaseTutorialWidget tutorialWidget;
|
new ImmutablePair<>("reversi2", ResourceManager.get("reversi2.png")),
|
||||||
|
new ImmutablePair<>("reversi3", ResourceManager.get("cat.jpg")),
|
||||||
public ReversiTutorialWidget() {
|
new ImmutablePair<>("reversi4", ResourceManager.get("cat.jpg"))
|
||||||
this.state = new TState(keys.length);
|
), nextScreen);
|
||||||
tutorialWidget = new BaseTutorialWidget(
|
|
||||||
state,
|
|
||||||
keys[state.getCurrent()],
|
|
||||||
images[state.getCurrent()],
|
|
||||||
() -> {
|
|
||||||
if (state.hasPrevious()) {
|
|
||||||
state.previous();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
() -> {
|
|
||||||
if (state.hasNext()) {
|
|
||||||
state.next();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
add(Pos.CENTER, tutorialWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void update() {
|
|
||||||
tutorialWidget.update(keys[state.getCurrent()], images[state.getCurrent()]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package org.toop.app.widget.tutorial;
|
||||||
|
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import org.toop.app.widget.Primitive;
|
||||||
|
import org.toop.app.widget.WidgetContainer;
|
||||||
|
import org.toop.app.widget.complex.PopupWidget;
|
||||||
|
import org.toop.local.AppSettings;
|
||||||
|
|
||||||
|
public class ShowEnableTutorialWidget extends PopupWidget {
|
||||||
|
|
||||||
|
public ShowEnableTutorialWidget(Runnable tutorial, Runnable nextScreen, Runnable appSettingsSetter) {
|
||||||
|
var a = Primitive.hbox(
|
||||||
|
Primitive.button("ok", () -> { appSettingsSetter.run(); tutorial.run(); this.hide(); }),
|
||||||
|
Primitive.button("no", () -> { appSettingsSetter.run(); nextScreen.run(); this.hide(); }),
|
||||||
|
Primitive.button("never", () -> { AppSettings.getSettings().setTutorialFlag(false); nextScreen.run(); this.hide(); })
|
||||||
|
);
|
||||||
|
|
||||||
|
var txt = Primitive.text("tutorial");
|
||||||
|
add(Pos.CENTER, Primitive.vbox(txt, a));
|
||||||
|
WidgetContainer.add(Pos.CENTER, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package org.toop.app.widget.tutorial;
|
|
||||||
|
|
||||||
public class TState {
|
|
||||||
|
|
||||||
private int current;
|
|
||||||
private int total;
|
|
||||||
|
|
||||||
public TState(int total) {
|
|
||||||
this.total = total;
|
|
||||||
this.current = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCurrent() {
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrent(int current) {
|
|
||||||
this.current = current;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotal() {
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotal(int total) {
|
|
||||||
this.total = total;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void next() {
|
|
||||||
current = current + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void previous() {
|
|
||||||
current = current - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasNext() {
|
|
||||||
return current < total - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasPrevious() {
|
|
||||||
return current > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +1,16 @@
|
|||||||
package org.toop.app.widget.tutorial;
|
package org.toop.app.widget.tutorial;
|
||||||
|
|
||||||
import javafx.geometry.Pos;
|
import org.apache.maven.surefire.shared.lang3.tuple.ImmutablePair;
|
||||||
import org.toop.app.widget.complex.ViewWidget;
|
import org.toop.framework.resource.ResourceManager;
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class TicTacToeTutorialWidget extends ViewWidget {
|
import java.util.List;
|
||||||
|
|
||||||
private TState state;
|
public class TicTacToeTutorialWidget extends BaseTutorialWidget {
|
||||||
private String[] keys = {"tictactoe1", "tictactoe2"};
|
public TicTacToeTutorialWidget(Runnable nextScreen) {
|
||||||
private File[] images = {
|
super(List.of(
|
||||||
new File("app/src/main/resources/assets/images/tictactoe1.png"),
|
new ImmutablePair<>("tictactoe1", ResourceManager.get("tictactoe1.png")),
|
||||||
new File("app/src/main/resources/assets/images/tictactoe2.png")
|
new ImmutablePair<>("tictactoe2", ResourceManager.get("tictactoe2.png"))
|
||||||
};
|
), nextScreen);
|
||||||
private BaseTutorialWidget tutorialWidget;
|
|
||||||
|
|
||||||
public TicTacToeTutorialWidget() {
|
|
||||||
this.state = new TState(keys.length);
|
|
||||||
tutorialWidget = new BaseTutorialWidget(
|
|
||||||
state,
|
|
||||||
keys[state.getCurrent()],
|
|
||||||
images[state.getCurrent()],
|
|
||||||
() -> {
|
|
||||||
if (state.hasPrevious()) {
|
|
||||||
state.previous();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
() -> {
|
|
||||||
if (state.hasNext()) {
|
|
||||||
state.next();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
add(Pos.CENTER, tutorialWidget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
|
||||||
tutorialWidget.update(keys[state.getCurrent()], images[state.getCurrent()]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,23 +53,13 @@ public final class GameView extends ViewWidget {
|
|||||||
|
|
||||||
switch(gameType) {
|
switch(gameType) {
|
||||||
case "TicTacToe":
|
case "TicTacToe":
|
||||||
this.tutorialButton = Primitive.button("tutorialstring", () -> {
|
this.tutorialButton = Primitive.button("tutorialstring", () -> new TicTacToeTutorialWidget(() -> {})); break;
|
||||||
transitionNext(new TicTacToeTutorialWidget());
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "Reversi":
|
case "Reversi":
|
||||||
this.tutorialButton = Primitive.button("tutorialstring", () -> {
|
this.tutorialButton = Primitive.button("tutorialstring", () -> new ReversiTutorialWidget(() -> {})); break;
|
||||||
transitionNext(new ReversiTutorialWidget());
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "Connect4":
|
case "Connect4":
|
||||||
this.tutorialButton = Primitive.button("tutorialstring", () -> {
|
this.tutorialButton = Primitive.button("tutorialstring", () -> new Connect4TutorialWidget(() -> {})); break;
|
||||||
transitionNext(new Connect4TutorialWidget());
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
this.tutorialButton = null;
|
this.tutorialButton = null; break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setupLayout();
|
setupLayout();
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ import org.toop.app.widget.WidgetContainer;
|
|||||||
import org.toop.app.widget.complex.PlayerInfoWidget;
|
import org.toop.app.widget.complex.PlayerInfoWidget;
|
||||||
import org.toop.app.widget.complex.ViewWidget;
|
import org.toop.app.widget.complex.ViewWidget;
|
||||||
import org.toop.app.widget.popup.ErrorPopup;
|
import org.toop.app.widget.popup.ErrorPopup;
|
||||||
import org.toop.app.widget.tutorial.BaseTutorialWidget;
|
import org.toop.app.widget.tutorial.*;
|
||||||
import org.toop.app.widget.tutorial.Connect4TutorialWidget;
|
|
||||||
import org.toop.app.widget.tutorial.ReversiTutorialWidget;
|
|
||||||
import org.toop.app.widget.tutorial.TicTacToeTutorialWidget;
|
|
||||||
import org.toop.local.AppContext;
|
import org.toop.local.AppContext;
|
||||||
|
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
@@ -40,91 +37,40 @@ public class LocalMultiplayerView extends ViewWidget {
|
|||||||
switch (information.type) {
|
switch (information.type) {
|
||||||
case TICTACTOE:
|
case TICTACTOE:
|
||||||
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstTTT()) {
|
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstTTT()) {
|
||||||
BaseTutorialWidget a = new BaseTutorialWidget(
|
new ShowEnableTutorialWidget(
|
||||||
"tutorial",
|
() -> new TicTacToeTutorialWidget(() -> new TicTacToeGameThread(information)),
|
||||||
() -> {
|
() -> Platform.runLater(() -> new TicTacToeGameThread(information)),
|
||||||
AppSettings.getSettings().setFirstTTT(false);
|
() -> AppSettings.getSettings().setFirstTTT(false)
|
||||||
Platform.runLater(() -> {
|
);
|
||||||
new TicTacToeGameThread(information);
|
} else {
|
||||||
});
|
new TicTacToeGameThread(information);
|
||||||
},
|
|
||||||
() -> {
|
|
||||||
ViewWidget c = new TicTacToeTutorialWidget();
|
|
||||||
transitionNext(c);
|
|
||||||
WidgetContainer.setCurrentView(c);
|
|
||||||
AppSettings.getSettings().setFirstTTT(false);
|
|
||||||
},
|
|
||||||
() -> {
|
|
||||||
AppSettings.getSettings().setTutorialFlag(false);
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
new TicTacToeGameThread(information);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
transitionNext(a);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
new TicTacToeGameThread(information);
|
|
||||||
break;
|
break;
|
||||||
case REVERSI:
|
case REVERSI:
|
||||||
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstReversi()) {
|
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstReversi()) {
|
||||||
BaseTutorialWidget a = new BaseTutorialWidget(
|
new ShowEnableTutorialWidget(
|
||||||
"tutorial",
|
() -> new ReversiTutorialWidget(() -> new ReversiGame(information)),
|
||||||
() -> { Platform.runLater(() -> {
|
() -> Platform.runLater(() -> new ReversiGame(information)),
|
||||||
AppSettings.getSettings().setFirstReversi(false);
|
() -> AppSettings.getSettings().setFirstReversi(false)
|
||||||
new ReversiGame(information);
|
);
|
||||||
});
|
} else {
|
||||||
},
|
new ReversiGame(information);
|
||||||
() -> {
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
ViewWidget c = new ReversiTutorialWidget();
|
|
||||||
transitionNext(c);
|
|
||||||
WidgetContainer.setCurrentView(c);
|
|
||||||
AppSettings.getSettings().setFirstReversi(false);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
() -> {
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
AppSettings.getSettings().setTutorialFlag(false);
|
|
||||||
new ReversiGame(information);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
transitionNext(a);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
new ReversiGame(information);
|
|
||||||
break;
|
break;
|
||||||
case CONNECT4:
|
case CONNECT4:
|
||||||
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstConnect4()) {
|
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstConnect4()) {
|
||||||
BaseTutorialWidget a = new BaseTutorialWidget(
|
new ShowEnableTutorialWidget(
|
||||||
"tutorial",
|
() -> new Connect4TutorialWidget(() -> new Connect4Game(information)),
|
||||||
() -> { Platform.runLater(() -> {
|
() -> Platform.runLater(() -> new Connect4Game(information)),
|
||||||
AppSettings.getSettings().setFirstConnect4(false);
|
() -> AppSettings.getSettings().setFirstConnect4(false)
|
||||||
new Connect4Game(information);
|
);
|
||||||
});
|
} else {
|
||||||
},
|
new Connect4Game(information);
|
||||||
() -> {
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
ViewWidget c = new Connect4TutorialWidget();
|
|
||||||
transitionNext(c);
|
|
||||||
WidgetContainer.setCurrentView(c);
|
|
||||||
AppSettings.getSettings().setFirstConnect4(false);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
() -> {
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
AppSettings.getSettings().setTutorialFlag(false);
|
|
||||||
new Connect4Game(information);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
transitionNext(a);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
new Connect4Game(information);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// case BATTLESHIP -> new BattleshipGame(information);
|
// case BATTLESHIP -> new BattleshipGame(information);
|
||||||
});
|
});
|
||||||
|
|
||||||
var playerSection = setupPlayerSections();
|
var playerSection = setupPlayerSections();
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ reversi2=Clicking on a dot will flip all the moves between where you place the d
|
|||||||
reversi3=Your turn may be skipped if there is no legal move. This will let your opponent play again until you get an opportunity at a legal move.
|
reversi3=Your turn may be skipped if there is no legal move. This will let your opponent play again until you get an opportunity at a legal move.
|
||||||
reversi4=The player who wins at the end of the game is the one who has the most pieces on the board.
|
reversi4=The player who wins at the end of the game is the one who has the most pieces on the board.
|
||||||
tutorialstring=Tutorial
|
tutorialstring=Tutorial
|
||||||
|
startgame=Start game!
|
||||||
|
goback=Go back
|
||||||
|
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabic)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabic)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import org.toop.framework.resource.types.LoadableResource;
|
|||||||
|
|
||||||
@FileExtension({"png", "jpg", "jpeg"})
|
@FileExtension({"png", "jpg", "jpeg"})
|
||||||
public class ImageAsset extends BaseResource implements LoadableResource {
|
public class ImageAsset extends BaseResource implements LoadableResource {
|
||||||
private Image image;
|
private Image image = null;
|
||||||
|
|
||||||
public ImageAsset(final File file) {
|
public ImageAsset(final File file) {
|
||||||
super(file);
|
super(file);
|
||||||
@@ -40,8 +40,7 @@ public class ImageAsset extends BaseResource implements LoadableResource {
|
|||||||
public Image getImage() {
|
public Image getImage() {
|
||||||
if (!this.isLoaded) {
|
if (!this.isLoaded) {
|
||||||
this.load();
|
this.load();
|
||||||
return image;
|
|
||||||
}
|
}
|
||||||
return null;
|
return image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user