MCPcopy Create free account
hub / github.com/TheCyaniteProject/exit_code_java / mainMenu

Method mainMenu

src/main/java/exitcode/Main.java:43–221  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41 public static ArrayList<String> fonts = new ArrayList<String>();
42
43 public static void mainMenu() {
44 Main.main_primaryStage.getScene().setRoot(Main.main_root); //Best line of code EVER
45
46 Main.preStartupCheck();
47
48 final BorderPane root_menu = new BorderPane();
49 Main.page_open = true;
50 main_root.setPrefSize(800, 600); // Set default size of the window: (Width, height)
51 main_root.setMinSize(800, 600);
52 main_root.getChildren().add(root_menu);
53 root_menu.prefWidthProperty().bind(main_root.widthProperty()); // Fit root_menu to main_root (yes, both Pane's are required.)
54 root_menu.prefHeightProperty().bind(main_root.heightProperty());
55 root_menu.setBackground(Background.EMPTY); // Makes the background color transparent, else the background fills with WHITE color.
56 main_root.setBackground(Background.EMPTY);
57 //Wallpaper
58 Image backgroundImage = new Image(Main.class.getResourceAsStream(Main.backgroundImage));
59 ImageView imageView = new ImageView(backgroundImage);
60 imageView.fitWidthProperty().bind(main_root.widthProperty());
61 imageView.fitHeightProperty().bind(main_root.heightProperty());
62 //Darken Effect
63 Lighting lighting = new Lighting();
64 lighting.setDiffuseConstant(1.0);
65 lighting.setSpecularConstant(0.0);
66 lighting.setSpecularExponent(0.0);
67 lighting.setSurfaceScale(0.0);
68 lighting.setLight(new Light.Distant(45, 45, Color.GRAY)); //Note to future self: Don't ever use Color.BLACK here. It doesn't work.
69 //Blur Effect
70 GaussianBlur gaussianBlur = new GaussianBlur();
71 gaussianBlur.setInput(lighting); //To set multiple effects
72 imageView.setEffect(gaussianBlur);
73 //then you set to your node
74 main_root.getChildren().add(imageView);
75
76
77 //Main Menu
78 BorderPane mainMenu = new BorderPane();
79 mainMenu.getStylesheets().add("login.css");
80 mainMenu.setStyle("-fx-background-color: rgba(100, 100, 100, .1);");
81 mainMenu.setPrefWidth(350); //Size (Width)
82 // position the mainMenu
83 mainMenu.layoutXProperty().bind(main_root.widthProperty().subtract(mainMenu.widthProperty().multiply(2)).divide(3));
84 mainMenu.layoutYProperty().bind(main_root.heightProperty().subtract(mainMenu.heightProperty()).divide(2));
85 main_root.getChildren().add(mainMenu);
86
87 //Main Content
88 VBox mainContent = new VBox();
89 mainMenu.setCenter(mainContent);
90 //gameLogo
91 ImageView gameLogo = new ImageView();
92 gameLogo.setPreserveRatio(true);
93 gameLogo.setFitWidth(290); //Image Size
94 Image logoSource = new Image(Main.class.getResourceAsStream("images/Logo.png"));
95 gameLogo.setImage(logoSource);
96 HBox logoFrame = new HBox();
97 logoFrame.getChildren().add(gameLogo);
98 logoFrame.setPadding(new Insets(30, 30, 30, 30)); //Top, Right, Bottom, Left
99 mainMenu.setTop(logoFrame);
100

Callers 3

loadTasksMethod · 0.95
startMethod · 0.95
loadMethod · 0.95

Calls 9

preStartupCheckMethod · 0.95
loadFontMethod · 0.95
loadMethod · 0.95
closeGameMethod · 0.95
setPrefSizeMethod · 0.80
setFontMethod · 0.80
setTextMethod · 0.80
getMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected