aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net/sowgro/npehero/editor/ErrorDisplay.java
blob: b3ec75140889c3fd35864f4895d7922ffcc7f5cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package net.sowgro.npehero.editor;

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import net.sowgro.npehero.Driver;
import net.sowgro.npehero.main.Page;
import net.sowgro.npehero.main.Sound;

public class ErrorDisplay extends Page {

    private HBox content = new HBox();

    /**
     * Error display with a message and Back button
     * @param message The message to display
     * @param prev The destination of the close button
     */
    public ErrorDisplay(String message, Page prev) {
        Label main = new Label(message);
        main.getStyleClass().add("box");

        Button exit = new Button();
        exit.setText("Back");
        exit.setOnAction(e -> {
            Sound.playSfx(Sound.BACKWARD);
            Driver.setMenu(prev);
        });

        VBox centerBox = new VBox();
        centerBox.getChildren().addAll(main, exit);
        centerBox.setSpacing(10);
        centerBox.setAlignment(Pos.CENTER);

        content.getChildren().add(centerBox);
        content.setAlignment(Pos.CENTER);
    }

    /**
     * Error display with a message and Cancel and Proceed buttons
     * @param message The message to display
     * @param prev The destination of the Cancel button
     * @param next The destination of the Proceed button
     */
    public ErrorDisplay(String message, Page prev, Page next) {
        Label main = new Label(message);
        main.getStyleClass().add("box");
        main.setPadding(new Insets(10));

        Button exit = new Button();
        exit.setText("Cancel");
        exit.setOnAction(_ -> {
            Sound.playSfx(Sound.BACKWARD);
            Driver.setMenu(prev);
        });

        Button nextButton = new Button();
        nextButton.setText("Proceed");
        nextButton.setOnAction(_ -> {
            Sound.playSfx(Sound.FORWARD);
            Driver.setMenu(next);
        });

        HBox bottom = new HBox(exit, nextButton);
        bottom.setAlignment(Pos.CENTER);
        bottom.setSpacing(10);

        VBox centerBox = new VBox();
        centerBox.getChildren().addAll(main, bottom);
        centerBox.setSpacing(10);
        centerBox.setAlignment(Pos.CENTER);

        content.getChildren().add(centerBox);
        content.setAlignment(Pos.CENTER);
    }

    @Override
    public Pane getContent() {
        return content;
    }
}