Search in sources :

Example 1 with Game

use of capslock.game_info.Game in project CapsLock by chrootRISCassembler.

the class MainFormController method onPanelClicked.

void onPanelClicked(MouseEvent event) {
    // 右クリックじゃない
    if (!event.getButton().equals(MouseButton.PRIMARY))
        return;
    // クリックされたパネルの取得
    final ImageView view = (ImageView) event.getSource();
    // パネルが示すゲーム
    final Game NextGame = (Game) view.getUserData();
    if (game != NextGame) {
        PanelTilePane.getChildren().stream().peek(panel -> panel.setScaleX(1)).peek(panel -> panel.setScaleY(1)).forEach(panel -> panel.setEffect(null));
        {
            // 選択されたパネルにエフェクトを適応
            view.setScaleX(1.15);
            view.setScaleY(1.15);
            // 影つけて
            final DropShadow effect = new DropShadow(20, Color.BLUE);
            // 光らせる
            effect.setInput(new Glow(0.5));
            view.setEffect(effect);
        }
        game = NextGame;
        Logger.INST.debug("ContentsAreaController#setGame() call");
        contentsAreaController.setGame(game);
        {
            final String name = NextGame.getName();
            NameLabel.setText("[P-" + NextGame.getGameID() + "]" + name);
        }
        if (NextGame.getDesc() == null) {
            Logger.INST.debug("No desc!");
        }
        DescriptionLabel.setText(NextGame.getDesc());
        DescriptionLabel.setPadding(Insets.EMPTY);
        DescriptionLabel.autosize();
    }
    // ダブルクリックじゃない
    if (event.getClickCount() != 2)
        return;
    handler.launch(game);
}
Also used : Button(javafx.scene.control.Button) MouseButton(javafx.scene.input.MouseButton) Glow(javafx.scene.effect.Glow) MouseEvent(javafx.scene.input.MouseEvent) StackPane(javafx.scene.layout.StackPane) VBox(javafx.scene.layout.VBox) MediaView(javafx.scene.media.MediaView) Insets(javafx.geometry.Insets) ScrollPane(javafx.scene.control.ScrollPane) Logger(methg.commonlib.trivial_logger.Logger) Tooltip(javafx.scene.control.Tooltip) Path(java.nio.file.Path) Color(javafx.scene.paint.Color) Rectangle2D(javafx.geometry.Rectangle2D) Label(javafx.scene.control.Label) Node(javafx.scene.Node) Font(javafx.scene.text.Font) Screen(javafx.stage.Screen) DropShadow(javafx.scene.effect.DropShadow) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) ActionEvent(javafx.event.ActionEvent) List(java.util.List) Game(capslock.game_info.Game) TilePane(javafx.scene.layout.TilePane) ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image) Collections(java.util.Collections) Game(capslock.game_info.Game) ImageView(javafx.scene.image.ImageView) Glow(javafx.scene.effect.Glow) DropShadow(javafx.scene.effect.DropShadow)

Example 2 with Game

use of capslock.game_info.Game in project CapsLock by chrootRISCassembler.

the class MainFormController method onCreated.

void onCreated(MainHandler handler) {
    this.handler = handler;
    final double PanelImageSideLength;
    Logger.INST.debug("Start calculation of dynamic UI.");
    {
        final Rectangle2D ScreenRect = Screen.getPrimary().getVisualBounds();
        final double FullScreenWidth = ScreenRect.getWidth();
        final double FullScreenHeight = ScreenRect.getHeight();
        final double LeftSize = FullScreenWidth / 5 * 2;
        LeftScrollPane.setPrefViewportWidth(LeftSize);
        LeftScrollPane.setMinViewportWidth(LeftSize);
        PanelImageSideLength = LeftSize * PANEL_RATIO;
        final double Gap = LeftSize * PANEL_GAP_RATIO;
        PanelTilePane.setPadding(new Insets(LeftSize / 12));
        PanelTilePane.setVgap(Gap);
        PanelTilePane.setHgap(Gap);
        final double RightContentPadding = (FullScreenWidth - LeftSize) / 20;
        RightVBox.setPadding(new Insets(RightContentPadding));
        RightVBox.setMaxWidth(FullScreenWidth - LeftSize);
        NameLabel.setFont(Font.font(FullScreenHeight / 20));
        DescriptionLabel.setFont(Font.font(FullScreenHeight / 40));
    }
    Logger.INST.debug("Finished calculation of dynamic UI.");
    final ColorSequencer sequencer = new ColorSequencer();
    final Tooltip tooltip = new Tooltip("ダブルクリックでゲーム起動");
    for (final Game game : handler.getGameList()) {
        final Image panelImage;
        final Path panelPath = game.getPanel();
        if (panelPath == null) {
            panelImage = CharPanelGenerator.generate(game.getName().charAt(0), sequencer.get());
        } else {
            panelImage = new Image(panelPath.toUri().toString());
        }
        final ImageView view = new ImageView(panelImage);
        view.setPreserveRatio(false);
        view.setFitWidth(PanelImageSideLength);
        view.setFitHeight(PanelImageSideLength);
        view.setOnMouseClicked(eve -> onPanelClicked(eve));
        Tooltip.install(view, tooltip);
        view.setUserData(game);
        PanelTilePane.getChildren().add(view);
    }
    contentsAreaController = new ContentsAreaController(ViewStackPane, StackedMediaView, StackedImageView);
    Logger.INST.debug("MainForm window is displayed.");
    System.gc();
}
Also used : Path(java.nio.file.Path) Insets(javafx.geometry.Insets) Game(capslock.game_info.Game) Tooltip(javafx.scene.control.Tooltip) Rectangle2D(javafx.geometry.Rectangle2D) ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image)

Aggregations

Game (capslock.game_info.Game)2 Path (java.nio.file.Path)2 Insets (javafx.geometry.Insets)2 Rectangle2D (javafx.geometry.Rectangle2D)2 Tooltip (javafx.scene.control.Tooltip)2 Image (javafx.scene.image.Image)2 ImageView (javafx.scene.image.ImageView)2 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ActionEvent (javafx.event.ActionEvent)1 FXML (javafx.fxml.FXML)1 Node (javafx.scene.Node)1 Button (javafx.scene.control.Button)1 Label (javafx.scene.control.Label)1 ScrollPane (javafx.scene.control.ScrollPane)1 DropShadow (javafx.scene.effect.DropShadow)1 Glow (javafx.scene.effect.Glow)1 MouseButton (javafx.scene.input.MouseButton)1 MouseEvent (javafx.scene.input.MouseEvent)1