mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Tutorial images now use ImageAsset.java
This commit is contained in:
@@ -47,8 +47,7 @@ public final class Primitive {
|
||||
return text;
|
||||
}
|
||||
|
||||
public static ImageView image(File file) {
|
||||
ImageAsset imageAsset = new ImageAsset(file);
|
||||
public static ImageView image(ImageAsset imageAsset) {
|
||||
ImageView imageView = new ImageView(imageAsset.getImage());
|
||||
imageView.getStyleClass().add("image");
|
||||
imageView.setPreserveRatio(true);
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.toop.app.widget.complex.PopupWidget;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import org.toop.framework.resource.resources.ImageAsset;
|
||||
import org.toop.local.AppContext;
|
||||
|
||||
import java.io.File;
|
||||
@@ -35,7 +36,7 @@ public class BaseTutorialWidget extends PopupWidget {
|
||||
this.nextButton = Primitive.button(">", onNext);
|
||||
}
|
||||
|
||||
public void setTutorial(File image, Runnable onPrevious, Runnable onNext) {
|
||||
public void setTutorial(ImageAsset image, Runnable onPrevious, Runnable onNext) {
|
||||
setOnPrevious(onPrevious);
|
||||
setOnNext(onNext);
|
||||
this.imagery = Primitive.image(image);
|
||||
@@ -44,7 +45,7 @@ public class BaseTutorialWidget extends PopupWidget {
|
||||
add(Pos.CENTER, Primitive.vbox(x, w));
|
||||
}
|
||||
|
||||
public void update(boolean next, String[] locKeys, File[] imgs) {
|
||||
public void update(boolean next, String[] locKeys, ImageAsset[] imgs) {
|
||||
currentTextIndex = next ? currentTextIndex + 1 : currentTextIndex - 1;
|
||||
|
||||
if (currentTextIndex >= locKeys.length) {
|
||||
|
||||
@@ -2,25 +2,29 @@ package org.toop.app.widget.tutorial;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
import org.toop.framework.resource.ResourceManager;
|
||||
import org.toop.framework.resource.resources.ImageAsset;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Connect4TutorialWidget extends BaseTutorialWidget {
|
||||
private final String[] keys;
|
||||
|
||||
private final File[] images = {
|
||||
new File("app/src/main/resources/assets/images/connect41.png"),
|
||||
new File("app/src/main/resources/assets/images/connect42.png")
|
||||
};
|
||||
private final ImageAsset[] images;
|
||||
|
||||
public Connect4TutorialWidget() {
|
||||
String[] newKeys = {
|
||||
"connect4.1", "connect4.2"
|
||||
};
|
||||
|
||||
ImageAsset[] newImages = {
|
||||
ResourceManager.get("connect41.png"),
|
||||
ResourceManager.get("connect42.png")
|
||||
};
|
||||
|
||||
super(newKeys[0]);
|
||||
|
||||
keys = newKeys;
|
||||
images = newImages;
|
||||
|
||||
setTutorial(
|
||||
images[0],
|
||||
@@ -33,7 +37,7 @@ public class Connect4TutorialWidget extends BaseTutorialWidget {
|
||||
return keys;
|
||||
}
|
||||
|
||||
public File[] getImages() {
|
||||
public ImageAsset[] getImages() {
|
||||
return images;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,28 @@ package org.toop.app.widget.tutorial;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
import org.toop.framework.resource.ResourceManager;
|
||||
import org.toop.framework.resource.resources.ImageAsset;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ReversiTutorialWidget extends BaseTutorialWidget {
|
||||
private final String[] keys;
|
||||
private final 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")};
|
||||
private final ImageAsset[] images;
|
||||
|
||||
public ReversiTutorialWidget() {
|
||||
String[] newKeys = {"reversi1", "reversi2", "reversi3", "reversi4"};
|
||||
ImageAsset[] newImages = {
|
||||
ResourceManager.get("reversi1.png"),
|
||||
ResourceManager.get("reversi2.png"),
|
||||
ResourceManager.get("cat.jpg"),
|
||||
ResourceManager.get("cat.jpg")
|
||||
};
|
||||
|
||||
super(newKeys[0]);
|
||||
|
||||
keys = newKeys;
|
||||
images = newImages;
|
||||
|
||||
setTutorial(
|
||||
images[0],
|
||||
@@ -27,7 +36,7 @@ public class ReversiTutorialWidget extends BaseTutorialWidget {
|
||||
return keys;
|
||||
}
|
||||
|
||||
public File[] getImages() {
|
||||
public ImageAsset[] getImages() {
|
||||
return images;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,22 +6,15 @@ import org.toop.app.widget.WidgetContainer;
|
||||
import org.toop.app.widget.complex.PopupWidget;
|
||||
|
||||
public class ShowEnableTutorialWidget extends PopupWidget {
|
||||
// private final Button yesButton;
|
||||
// private final Button noButton;
|
||||
// private final Button neverButton;
|
||||
|
||||
public ShowEnableTutorialWidget(String words, Runnable onYes, Runnable onNo, Runnable onNever) {
|
||||
// this.yesButton = Primitive.button("ok", onYes);
|
||||
// this.noButton = Primitive.button("no", onNo);
|
||||
// this.neverButton = Primitive.button("never", onNever);
|
||||
|
||||
public ShowEnableTutorialWidget(String text, Runnable onYes, Runnable onNo, Runnable onNever) {
|
||||
var a = Primitive.hbox(
|
||||
Primitive.button("ok", onYes),
|
||||
Primitive.button("no", onNo),
|
||||
Primitive.button("never", onNever)
|
||||
);
|
||||
|
||||
var txt = Primitive.text(words);
|
||||
var txt = Primitive.text(text);
|
||||
add(Pos.CENTER, Primitive.vbox(txt, a));
|
||||
WidgetContainer.add(Pos.CENTER, this);
|
||||
}
|
||||
|
||||
@@ -2,22 +2,27 @@ package org.toop.app.widget.tutorial;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import org.toop.app.widget.complex.ViewWidget;
|
||||
import org.toop.framework.resource.ResourceManager;
|
||||
import org.toop.framework.resource.resources.ImageAsset;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class TicTacToeTutorialWidget extends BaseTutorialWidget {
|
||||
|
||||
private final String[] keys;
|
||||
private final File[] images = {
|
||||
new File("app/src/main/resources/assets/images/tictactoe1.png"),
|
||||
new File("app/src/main/resources/assets/images/tictactoe2.png")
|
||||
};
|
||||
private final ImageAsset[] images;
|
||||
|
||||
public TicTacToeTutorialWidget() {
|
||||
String[] newKeys = {"tictactoe1", "tictactoe2"};
|
||||
ImageAsset[] newImages = {
|
||||
ResourceManager.get("tictactoe1.png"),
|
||||
ResourceManager.get("tictactoe2.png")
|
||||
};
|
||||
|
||||
super(newKeys[0]);
|
||||
|
||||
keys = newKeys;
|
||||
images = newImages;
|
||||
|
||||
setTutorial(
|
||||
images[0],
|
||||
@@ -30,7 +35,7 @@ public class TicTacToeTutorialWidget extends BaseTutorialWidget {
|
||||
return keys;
|
||||
}
|
||||
|
||||
public File[] getImages() {
|
||||
public ImageAsset[] getImages() {
|
||||
return images;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user