@Override protected Node createVersionView(String version) { Text view = FXGL.getUIFactory().newText(version); view.setTranslateY(app.getHeight() - 2); return view; }
@Override protected Node createTitleView(String title) { Text titleView = FXGL.getUIFactory().newText(app.getSettings().getTitle(), 18); titleView.setTranslateY(30); return titleView; }
@Override protected Node createTitleView(String title) { Text titleView = FXGL.getUIFactory().newText(app.getSettings().getTitle(), 18); titleView.setTranslateY(30); return titleView; }
@Override protected Node createVersionView(String version) { Text view = FXGL.getUIFactory().newText(version, 16); view.setTranslateX(app.getWidth() - view.getLayoutBounds().getWidth()); view.setTranslateY(20); return view; }
@Override protected Node createVersionView(String version) { Text view = FXGL.getUIFactory().newText(version, 16); view.setTranslateX(app.getWidth() - view.getLayoutBounds().getWidth()); view.setTranslateY(20); return view; }
@Override protected Node createProfileView(String profileName) { Text view = FXGL.getUIFactory().newText(profileName, 24); view.setTranslateX(app.getWidth() - view.getLayoutBounds().getWidth()); view.setTranslateY(50); return view; }
@Override protected Node createProfileView(String profileName) { Text view = FXGL.getUIFactory().newText(profileName, 24); view.setTranslateX(app.getWidth() - view.getLayoutBounds().getWidth()); view.setTranslateY(50); return view; }
@Override protected Node createProfileView(String profileName) { Text view = FXGL.getUIFactory().newText(profileName); view.setTranslateY(app.getHeight() - 2); view.setTranslateX(app.getWidth() - view.getLayoutBounds().getWidth()); return view; }
/** * @return menu content containing a list of credits */ protected final MenuContent createContentCredits() { log.debug("createContentCredits()"); ScrollPane pane = new FXGLScrollPane(); pane.setPrefWidth(app.getWidth() * 3 / 5); pane.setPrefHeight(app.getHeight() / 2); pane.setStyle("-fx-background:black;"); VBox vbox = new VBox(); vbox.setAlignment(Pos.CENTER); vbox.setPrefWidth(pane.getPrefWidth() - 15); List<String> credits = new ArrayList<>(getSettings().getCredits().getList()); credits.add(""); credits.add("Powered by FXGL " + FXGL.getVersion()); credits.add("Author: Almas Baimagambetov"); credits.add("https://github.com/AlmasB/FXGL"); credits.add(""); for (String credit : credits) { vbox.getChildren().add(getUIFactory().newText(credit)); } pane.setContent(vbox); return new MenuContent(pane); }
/** * @return menu content containing music and sound volume sliders */ protected final MenuContent createContentAudio() { log.debug("createContentAudio()"); Slider sliderMusic = new Slider(0, 1, 1); sliderMusic.valueProperty().bindBidirectional(app.getAudioPlayer().globalMusicVolumeProperty()); Text textMusic = getUIFactory().newText(localizedStringProperty("menu.music.volume").concat(": ")); Text percentMusic = getUIFactory().newText(""); percentMusic.textProperty().bind(sliderMusic.valueProperty().multiply(100).asString("%.0f")); Slider sliderSound = new Slider(0, 1, 1); sliderSound.valueProperty().bindBidirectional(app.getAudioPlayer().globalSoundVolumeProperty()); Text textSound = getUIFactory().newText(localizedStringProperty("menu.sound.volume").concat(": ")); Text percentSound = getUIFactory().newText(""); percentSound.textProperty().bind(sliderSound.valueProperty().multiply(100).asString("%.0f")); HBox hboxMusic = new HBox(15, textMusic, sliderMusic, percentMusic); HBox hboxSound = new HBox(15, textSound, sliderSound, percentSound); hboxMusic.setAlignment(Pos.CENTER_RIGHT); hboxSound.setAlignment(Pos.CENTER_RIGHT); return new MenuContent(hboxMusic, hboxSound); }
/** * @return menu content with difficulty and playtime */ protected final MenuContent createContentGameplay() { log.debug("createContentGameplay()"); Spinner<GameDifficulty> difficultySpinner = new FXGLSpinner<>(FXCollections.observableArrayList(GameDifficulty.values())); difficultySpinner.increment(); app.getGameState().gameDifficultyProperty().bind(difficultySpinner.valueProperty()); String playtime = app.getGameplay().getStats().getPlaytimeHours() + "H " + app.getGameplay().getStats().getPlaytimeMinutes() + "M " + app.getGameplay().getStats().getPlaytimeSeconds() + "S"; return new MenuContent( new HBox(25, getUIFactory().newText(localizedStringProperty("menu.difficulty").concat(":")), difficultySpinner), new HBox(25, getUIFactory().newText(localizedStringProperty("menu.playtime").concat(":")), getUIFactory().newText(playtime)) ); }
private void addNewInputBinding(UserAction action, Trigger trigger, GridPane grid) { Text actionName = getUIFactory().newText(action.getName(), Color.WHITE, 18.0); TriggerView triggerView = new TriggerView(trigger); triggerView.triggerProperty().bind(app.getInput().triggerProperty(action)); triggerView.setOnMouseClicked(event -> { pressAnyKeyState.actionContext = action; FXGL.getStateMachine().pushState(pressAnyKeyState); }); HBox hBox = new HBox(); hBox.setPrefWidth(100); hBox.setAlignment(Pos.CENTER); hBox.getChildren().add(triggerView); int controlsRow = (int) grid.getUserData(); grid.addRow(controlsRow++, actionName, hBox); grid.setUserData(controlsRow); }
/** * @return menu content containing a list of achievements */ protected final MenuContent createContentAchievements() { log.debug("createContentAchievements()"); MenuContent content = new MenuContent(); for (Achievement a : app.getGameplay().getAchievementManager().getAchievements()) { CheckBox checkBox = new CheckBox(); checkBox.setDisable(true); checkBox.selectedProperty().bind(a.achievedProperty()); Text text = getUIFactory().newText(a.getName()); Tooltip.install(text, new Tooltip(a.getDescription())); HBox box = new HBox(25, text, checkBox); box.setAlignment(Pos.CENTER_RIGHT); content.getChildren().add(box); } return content; }
/** * https://github.com/AlmasB/FXGL/issues/493 * * @return menu content with video settings */ protected final MenuContent createContentVideo() { log.debug("createContentVideo()"); ChoiceBox<Language> languageBox = getUIFactory().newChoiceBox(FXCollections.observableArrayList(Language.values())); languageBox.setValue(Language.ENGLISH); getSettings().getLanguage().bind(languageBox.valueProperty()); VBox vbox = new VBox(); if (getSettings().isManualResizeEnabled()) { Button btnFixRatio = getUIFactory().newButton(localizedStringProperty("menu.fixRatio")); btnFixRatio.setOnAction(e -> { listener.fixAspectRatio(); }); vbox.getChildren().add(btnFixRatio); } if (getSettings().isFullScreenAllowed()) { CheckBox cbFullScreen = getUIFactory().newCheckBox(); cbFullScreen.setSelected(false); cbFullScreen.selectedProperty().bindBidirectional(getSettings().getFullScreen()); vbox.getChildren().add(new HBox(25, getUIFactory().newText(getLocalizedString("menu.fullscreen")+": "), cbFullScreen)); } return new MenuContent( new HBox(25, getUIFactory().newText(localizedStringProperty("menu.language").concat(":")), languageBox), vbox ); }
/** * @return menu content containing feedback options */ protected final MenuContent createContentFeedback() { log.debug("createContentFeedback()"); // url is a string key defined in system.properties Consumer<String> openBrowser = url -> { getNet() .openBrowserTask(url) .onFailure(error -> log.warning("Error opening browser: " + error)) .run(); }; Button btnGoogle = new Button("Google Forms"); btnGoogle.setOnAction(e -> openBrowser.accept(FXGL.getSettings().getUrlGoogleForms())); Button btnSurveyMonkey = new Button("Survey Monkey"); btnSurveyMonkey.setOnAction(e -> openBrowser.accept(FXGL.getSettings().getUrlGoogleForms())); VBox vbox = new VBox(15, getUIFactory().newText(getLocalizedString("menu.chooseFeedback"), Color.WHEAT, 18), btnGoogle, btnSurveyMonkey); vbox.setAlignment(Pos.CENTER); return new MenuContent(vbox); }
titleColor = new SimpleObjectProperty<>(Color.WHITE); Text text = FXGL.getUIFactory().newText(title.substring(0, 1), 50); text.setFill(null); text.strokeProperty().bind(titleColor); text.setStrokeWidth(1.5); Text text2 = FXGL.getUIFactory().newText(title.substring(1, title.length()), 50); text2.setFill(null); text2.setStroke(titleColor.getValue());
PressAnyKeyState() { getInput().addEventHandler(KeyEvent.KEY_PRESSED, e -> { if (Input.isIllegal(e.getCode())) return; boolean rebound = FXGL.getInput().rebind(actionContext, e.getCode(), InputModifier.from(e)); if (rebound) FXGL.getStateMachine().popState(); }); getInput().addEventHandler(MouseEvent.MOUSE_PRESSED, e -> { boolean rebound = FXGL.getInput().rebind(actionContext, e.getButton(), InputModifier.from(e)); if (rebound) FXGL.getStateMachine().popState(); }); Rectangle rect = new Rectangle(250, 100); rect.setStroke(Color.color(0.85, 0.9, 0.9, 0.95)); rect.setStrokeWidth(10); rect.setArcWidth(15); rect.setArcHeight(15); Text text = getUIFactory().newText(getLocalizedString("menu.pressAnyKey"), 24); StackPane pane = new StackPane(rect, text); pane.setTranslateX(FXGL.getAppWidth() / 2 - 125); pane.setTranslateY(FXGL.getAppHeight() / 2 - 50); getChildren().add(pane); } }