Skip to content

Commit

Permalink
refactor: change visibility of root stack pane
Browse files Browse the repository at this point in the history
  • Loading branch information
isHarryh committed Sep 4, 2024
1 parent 14ceaa6 commit c9dc457
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions desktop/src/cn/harryh/arkpets/ArkHomeFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.Window;
import javafx.util.Duration;

import java.util.Objects;
Expand All @@ -36,7 +37,6 @@ public class ArkHomeFX extends Application {
public Stage stage;
public ArkConfig config;
public ModelsDataset modelsDataset;
public StackPane root;
public StackPane body;

public RootModule rootModule;
Expand All @@ -57,13 +57,12 @@ public void start(Stage stage) throws Exception {
// Load FXML for root node.
LoadFXMLResult<ArkHomeFX> fxml0 = FXMLHelper.loadFXML(getClass().getResource("/UI/RootModule.fxml"));
fxml0.initializeWith(this);
root = (StackPane)fxml0.content();
rootModule = (RootModule)fxml0.controller();
body = rootModule.body;

// Setup scene and primary stage.
Logger.info("Launcher", "Creating main scene");
Scene scene = new Scene(root);
Scene scene = new Scene(rootModule.root);
scene.getStylesheets().setAll(Objects.requireNonNull(getClass().getResource("/UI/Main.css")).toExternalForm());
stage.getIcons().setAll(new Image(Objects.requireNonNull(getClass().getResource(iconFilePng)).toExternalForm()));
stage.initStyle(StageStyle.UNDECORATED);
Expand Down Expand Up @@ -139,4 +138,8 @@ public void stop() {
public void popLoading(EventHandler<ActionEvent> handler) {
rootModule.popLoading(handler);
}

public Window getWindow() {
return rootModule.root.getScene().getWindow();
}
}
4 changes: 2 additions & 2 deletions desktop/src/cn/harryh/arkpets/controllers/ModelsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ protected void onSucceeded(boolean result) {
fileChooser.getExtensionFilters().addAll(extensionFilter1, extensionFilter2);
fileChooser.setSelectedExtensionFilter(extensionFilter2);
// Handle the chosen file
File zipFile = fileChooser.showOpenDialog(app.root.getScene().getWindow());
File zipFile = fileChooser.showOpenDialog(app.getWindow());
if (zipFile != null && zipFile.isFile()) {
Logger.info("ModelManager", "Importing zip file: " + zipFile);
// Go to [Step 1/2]:
Expand All @@ -366,7 +366,7 @@ protected void onSucceeded(boolean result) {
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Archives", "*.zip"));
fileChooser.setInitialFileName(fileModelsZipName + ".zip");
// Handle the chosen file
File zipFile = fileChooser.showSaveDialog(app.root.getScene().getWindow());
File zipFile = fileChooser.showSaveDialog(app.getWindow());
if (zipFile != null) {
Logger.info("ModelManager", "Exporting zip file: " + zipFile);
HashMap<String, String> contents = new java.util.HashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/cn/harryh/arkpets/controllers/RootModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public final class RootModule implements Controller<ArkHomeFX> {
public GuiPrefabs.PeerNodeComposer moduleWrapperComposer;

@FXML
private StackPane root;
public StackPane root;
@FXML
public StackPane body;
@FXML
Expand Down

0 comments on commit c9dc457

Please sign in to comment.