-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
147 lines (144 loc) · 5.9 KB
/
Main.java
File metadata and controls
147 lines (144 loc) · 5.9 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package finalProject;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Alert.AlertType;
import javafx.stage.Stage;
public class Main extends Application{
private int closeCounter=0;
private boolean canclose=true;
public static void main(String[] args){
System.out.println("project launch");
launch(args);
}
@Override
public void start(Stage m_stage)throws Exception{
Parent root= FXMLLoader.load(getClass().getResource("StartScene.fxml"));
m_stage.setTitle("Start manu");
m_stage.setResizable(false);
m_stage.setScene(new Scene(root, 600, 400));
m_stage.show();
m_stage.setOnCloseRequest(event->{
event.consume();
joke(m_stage);
});
}
public void joke(Stage stage){
Alert alert;
switch(closeCounter) {
case 0:
alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Plz don't go");
alert.setHeaderText("Are you sure you want to quit?");
alert.setResizable(false);
alert.setContentText("sure to quit");
if(alert.showAndWait().get()==ButtonType.CANCEL)return;
alert.setAlertType(AlertType.ERROR);
alert.setHeaderText("Just a few more steps");
alert.setContentText("Far way to go");
alert.show();
closeCounter++;
break;
case 1:
alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("really?");
alert.setHeaderText("Plz don't go");
alert.setResizable(false);
alert.setContentText("Something good might happend if you click cancel");
if(alert.showAndWait().get()==ButtonType.CANCEL){
closeCounter++;
return;
}
alert.setAlertType(AlertType.ERROR);
alert.setHeaderText("That's the wrong choise");
alert.setContentText("I'd never lie");
alert.show();
closeCounter=0;
break;
case 2:
alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("really?");
alert.setHeaderText("Some thing might happend if you click cancel?");
alert.setResizable(false);
alert.setContentText("Plz don't go");
if(alert.showAndWait().get()==ButtonType.CANCEL){
closeCounter++;
return;
}
alert.setAlertType(AlertType.ERROR);
alert.setHeaderText("That's a bad choise");
alert.setContentText("Be certain");
alert.show();
closeCounter=0;
break;
case 3:
alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("really?");
alert.setHeaderText("Some thing might happend if you click cancel?");
alert.setResizable(false);
alert.setContentText("Plz don't go");
if(alert.showAndWait().get()==ButtonType.CANCEL){
closeCounter++;
return;
}
alert.setAlertType(AlertType.ERROR);
alert.setHeaderText("What a shame");
alert.setContentText("You almost got there");
alert.show();
closeCounter=0;
break;
case 4:
alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("really?");
alert.setHeaderText("Are you sure you want to quit?");
alert.setResizable(false);
alert.setContentText("Plz don't go");
if(alert.showAndWait().get()==ButtonType.OK){
closeCounter++;
return;
}
alert.setAlertType(AlertType.ERROR);
alert.setHeaderText("Thank you");
alert.setContentText("You're so nice not to quit");
alert.show();
closeCounter=0;
break;
case 5:
alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("really?");
alert.setHeaderText("Are you sure you want to quit?");
alert.setResizable(false);
alert.setContentText("Click cancel to quit");
if(alert.showAndWait().get()==ButtonType.OK){
closeCounter=0;
return;
}
alert.setAlertType(AlertType.ERROR);
alert.setHeaderText("I never lie, try more times");
alert.setContentText("Almost there");
alert.show();
closeCounter++;
break;
case 6:
alert=new Alert(AlertType.CONFIRMATION, "",ButtonType.OK, ButtonType.CLOSE);
canclose=true;
alert.setTitle("seriously?");
alert.setHeaderText("Don't go plzzzz?");
alert.setResizable(false);
alert.setContentText("Don't close this window, this will immediately close the game");
ButtonType answer=alert.showAndWait().get();
if(answer==ButtonType.OK){
canclose=false;
closeCounter=0;
}
if(canclose){stage.close();return;}
alert.setAlertType(AlertType.INFORMATION);
alert.setHeaderText("What a shame");
alert.setContentText("Start it over again");
alert.showAndWait();
}
}
}