forked from We-are-Trying-Our-Best/Final-Project
/
GUI: StartScreen
110 lines (91 loc) · 3.71 KB
/
GUI: StartScreen
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class StartScreen extends Application {
Stage window;
GridPane grid;
Scene startScene;
Label numPlayers;
Button onePlayer, twoPlayer;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Scanner input = new Scanner(System.in);
window = primaryStage;
window.setTitle("Trivia Game");
grid = new GridPane();
grid.setPadding(new Insets(10, 10, 10, 10));
grid.setVgap(10);
grid.setHgap(10);
//Label numPlayers: 1 or 2 player
numPlayers = new Label("Select the number of players: ");
numPlayers.setFont(Font.font("Verdana", FontWeight.BOLD, 12));
numPlayers.setTextFill(Color.WHITE);
GridPane.setConstraints(numPlayers, 0, 0);
//Button onePlayer & twoPlayer: creates buttons and assigns actions
onePlayer = new Button("1 Player");
final String IDLE_BUTTON_STYLE = "-fx-background-color: black;" +
"-fx-text-fill: white;" +
"-fx-border-style: solid inside;" +
"-fx-border-width: 2;" +
"-fx-border-insets: 0;" +
"-fx-border-radius: 5;" +
"-fx-border-color: #87CEFA;";
final String HOVERED_BUTTON_STYLE = "-fx-background-color: black;" +
"-fx-shadow-highlight-color: black;" +
"-fx-text-fill: white;" +
"-fx-border-style: solid inside;" +
"-fx-border-width: 2;" +
"-fx-border-insets: 0;" +
"-fx-border-radius: 5;" +
"-fx-border-color: #7CFC00";
onePlayer.setStyle(IDLE_BUTTON_STYLE);
onePlayer.setOnMouseEntered(e -> onePlayer.setStyle(HOVERED_BUTTON_STYLE));
onePlayer.setOnMouseExited(e -> onePlayer.setStyle(IDLE_BUTTON_STYLE));
onePlayer.setOnAction(e -> {
window.hide();
OnePlayerName.Display("Trivia Game: Names", "Enter name of player1: ");
});
twoPlayer = new Button("2 Player");
twoPlayer.setStyle(IDLE_BUTTON_STYLE);
twoPlayer.setOnMouseEntered(e -> twoPlayer.setStyle(HOVERED_BUTTON_STYLE));
twoPlayer.setOnMouseExited(e -> twoPlayer.setStyle(IDLE_BUTTON_STYLE));
twoPlayer.setOnAction(e -> {
window.hide();
TwoPlayerName.Display("Trivia Game: Names", "Enter name of player1: ", "Enter name of player2: ");
});
GridPane.setConstraints(onePlayer, 0, 1);
GridPane.setConstraints(twoPlayer, 1, 1);
grid.getChildren().addAll(numPlayers, onePlayer, twoPlayer);
//Scene startScene: sets beginning scene
grid.setStyle("-fx-background-color: linear-gradient(to bottom, black, #191970);");
startScene = new Scene(grid, 300, 200);
window.setScene(startScene);
window.show();
}
public static ArrayList<Integer> QuestionOrder() {
ArrayList<Integer> questions = new ArrayList<Integer>();
//int number = (int) (Math.random() * 10);
for (int i = 0; i < 10; i++) {
questions.add(i);
}
Collections.shuffle(questions);
int number;
for (int i = 0; i < 10; i++) {
number = questions.get(i);
}
return questions;
}
}