Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getGameDir()方法有错误 #71

Open
wants to merge 2 commits into
base: new-ui
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 38 additions & 8 deletions src/main/java/cn/tealc/wutheringwavestool/ui/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.SnapshotParameters;
import javafx.scene.control.*;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.WritableImage;
import javafx.scene.layout.*;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
Expand Down Expand Up @@ -108,6 +110,10 @@ public class MainView implements Initializable,FxmlView<MainViewModel> {

@FXML
private HBox titlebar;

//防止每次执行startNavAnim(),都创造一次,而不能stop()
private Timeline my_timeline = null;

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {

Expand Down Expand Up @@ -571,7 +577,24 @@ private Message createMessage(MessageInfo messageInfo){

public void startNavAnim() {

var t = new Timeline(
//将animation执行的内容改成图片,而不是整个ui
SnapshotParameters params = new SnapshotParameters();
params.setFill(javafx.scene.paint.Color.TRANSPARENT);

WritableImage image = child.snapshot(params, null);
ImageView imageView = new ImageView(image);

Node oldNode = child.getChildren().get(0);
child.getChildren().setAll(imageView);

//中断之前未播放完的动画
if (my_timeline != null) {
if (my_timeline.getStatus() == Animation.Status.RUNNING) {
my_timeline.stop();
}
};

my_timeline = new Timeline(
new KeyFrame(Duration.ZERO,
new KeyValue(child.scaleXProperty(), 0.9, Animations.EASE),
new KeyValue(child.scaleYProperty(), 0.9, Animations.EASE)
Expand All @@ -582,14 +605,21 @@ public void startNavAnim() {
)
);

t.statusProperty().addListener((obs, old, val) -> {
if (val == Animation.Status.STOPPED) {
child.setScaleX(1);
child.setScaleY(1);
}
// t.statusProperty().addListener((obs, old, val) -> {
// if (val == Animation.Status.STOPPED) {
// child.setScaleX(1);
// child.setScaleY(1);
// }
// });

//不使用.addListener()可能会有更好的性能
my_timeline.setOnFinished(event -> {
child.setScaleX(1);
child.setScaleY(1);
child.getChildren().setAll(oldNode);
});

t.play();
my_timeline.play();
}


Expand All @@ -609,4 +639,4 @@ public Button getCloseBtn() {
public HBox getTitlebar() {
return titlebar;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ public class GameResourcesManager {
private static final Logger LOG = LoggerFactory.getLogger(GameResourcesManager.class);

public static File getGameDir(){
File dir = new File(Config.setting.getGameRootDir());
if (!dir.exists()) {
return null;
if (Config.setting.getGameRootDir() != null) {
File dir = new File(Config.setting.getGameRootDir());
if (!dir.exists()) {
return null;
}
return dir;
}
return dir;
return null;
}

public static File getGameDB(){
Expand Down Expand Up @@ -143,4 +146,4 @@ public static File getGameLogFile() {
}
return file;
}
}
}