-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathApps.java
More file actions
296 lines (265 loc) · 10.8 KB
/
Copy pathApps.java
File metadata and controls
296 lines (265 loc) · 10.8 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
package application;
import javafx.stage.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.effect.*;
import javafx.beans.value.*;
import javafx.scene.paint.*;
import javafx.scene.input.*;
import javafx.scene.text.*;
import javafx.geometry.*;
import javafx.event.*;
import java.util.*;
public class Apps {
static String username = new String("root@NIX:~$ ");
public static void spawn_QuickPad_Window(Pane root, ArrayList<Pane> open_windows) {
// The Node Window (In-Game App)
DraggableNode node = new DraggableNode();
node.getStylesheets().add("config.css");
node.setPrefSize(300, 225); // Window Size
// define the style via css
node.setStyle("-fx-background-color: rgb(35, 35, 37);" + "-fx-border-color: rgb(39, 39, 40)");
// position the node
node.setLayoutX(10 + node.getPrefWidth());
//Shadows
DropShadow dropShadow = new DropShadow();
dropShadow.setRadius(5.0);
dropShadow.setColor(Color.color(0, 0, 0, 0.6));
node.setEffect(dropShadow);
//node.setEffect(null); //remove effect
//TitleBar
HBox title_bar = new HBox();
title_bar.setPrefHeight(10);
title_bar.setPadding(new Insets(0,0,0,5));
//title_bar.setStyle("-fx-background-color: rgb(0, 0, 0, 0.6)");
//Name
Label win_name = new Label("Quickpad");
win_name.setStyle("-fx-text-fill: white");
//Spacer
Region spacer = new Region();
HBox.setHgrow(spacer, Priority.ALWAYS);
//Quit
Button win_close = new Button("X");
win_close.setOnAction(close -> {
open_windows.remove(node);
root.getChildren().remove(node);
});
title_bar.getChildren().addAll(win_name, spacer, win_close);
title_bar.setAlignment(Pos.CENTER_RIGHT);
node.setTop(title_bar);
//App
TextArea textArea = new TextArea();
textArea.setStyle("-fx-text-fill: white");
textArea.setWrapText(true);
node.setCenter(textArea);
textArea.setText("Enter some text...");
// add the node to the root pane
root.getChildren().add(node);
open_windows.add(node);
}
public static void spawn_Terminal_Window(Pane root, ArrayList<Pane> open_windows) {
// The Node Window (In-Game App)
DraggableNode node = new DraggableNode();
node.getStylesheets().add("config.css");
node.setPrefSize(350, 225); // Window Size
// define the style via css
node.setStyle("-fx-background-color: rgb(35, 35, 37);" + "-fx-border-color: rgb(39, 39, 40)");
// position the node
node.setLayoutX(10 + node.getPrefWidth());
//Shadows
DropShadow dropShadow = new DropShadow();
dropShadow.setRadius(5.0);
dropShadow.setColor(Color.color(0, 0, 0, 0.6));
node.setEffect(dropShadow);
//node.setEffect(null); //remove effect
//TitleBar
HBox title_bar = new HBox();
title_bar.setPrefHeight(10);
title_bar.setPadding(new Insets(0,0,0,5));
//title_bar.setStyle("-fx-background-color: rgb(0, 0, 0, 0.6)");
//Name
Label win_name = new Label("Terminal");
win_name.setStyle("-fx-text-fill: white");
//Spacer
Region spacer = new Region();
HBox.setHgrow(spacer, Priority.ALWAYS);
//Quit
Button win_close = new Button("X");
win_close.setOnAction(close -> {
open_windows.remove(node);
root.getChildren().remove(node);
});
title_bar.getChildren().addAll(win_name, spacer, win_close);
title_bar.setAlignment(Pos.CENTER_RIGHT);
node.setTop(title_bar);
//App
ScrollPane termWindow = new ScrollPane();
termWindow.setFitToWidth(true);
node.setCenter(termWindow);
VBox terminalApp = new VBox();
termWindow.setContent(terminalApp);
Label termArea = new Label();
termArea.setStyle("-fx-text-fill: white");
termArea.setPrefWidth(node.getPrefWidth());
termArea.setWrapText(true);
terminalApp.getChildren().add(termArea);
termArea.setText(" This is a WIP, and has limited commands.\n");
TagArea termEntry = new TagArea();
termEntry.setWrapText(true);
termEntry.setStyle("-fx-text-fill: white");
terminalApp.getChildren().add(termEntry);
termEntry.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>()
{
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
ke.consume(); // necessary to prevent event handlers for this event
String output = new String(termEntry.getText().replace(username, ""));
System.out.println("[Console Command: " + output + "]");
Console.runCommand(output, username, termArea);
termEntry.setText(username);
termEntry.end();
}
}
});
// add the node to the root pane
root.getChildren().add(node);
open_windows.add(node);
}
public static void spawn_Settings_Window(Pane root, ArrayList<Pane> open_windows, Stage primaryStage) {
// The Node Window (In-Game App)
DraggableNode node = new DraggableNode();
node.getStylesheets().add("config.css");
node.setPrefSize(300, 225); // Window Size
// define the style via css
node.setStyle("-fx-background-color: rgb(35, 35, 37);" + "-fx-border-color: rgb(39, 39, 40)");
// position the node
node.setLayoutX(10 + node.getPrefWidth());
//ShadowTest
DropShadow dropShadow = new DropShadow();
dropShadow.setRadius(5.0);
dropShadow.setColor(Color.color(0, 0, 0, 0.6));
node.setEffect(dropShadow);
//node.setEffect(null); //remove effect
//TitleBar
HBox title_bar = new HBox();
title_bar.setPrefHeight(10);
title_bar.setPadding(new Insets(0,0,0,5));
//title_bar.setStyle("-fx-background-color: rgb(0, 0, 0, 0.6)");
//Name
Label win_name = new Label("System Settings");
win_name.setStyle("-fx-text-fill: white");
//Spacer
Region spacer = new Region();
HBox.setHgrow(spacer, Priority.ALWAYS);
//Quit
Button win_close = new Button("X");
win_close.setOnAction(close -> {
open_windows.remove(node);
root.getChildren().remove(node);
});
title_bar.getChildren().addAll(win_name, spacer, win_close);
title_bar.setAlignment(Pos.CENTER_RIGHT);
node.setTop(title_bar);
//App
VBox system_settings = new VBox();
node.setCenter(system_settings);
// Toggle Fullscreen
ToggleButton fullscreen_mode = new ToggleButton("Fullscreen On");
system_settings.getChildren().add(fullscreen_mode);
fullscreen_mode.setOnAction(toggle_fullscreen -> {
if (fullscreen_mode.isSelected()) {
System.out.println("[Fullscreen Toggle OFF]");
primaryStage.setFullScreen(false);
fullscreen_mode.setText("Fullscreen Off");
} else {
System.out.println("[Fullscreen Toggle ON]");
primaryStage.setFullScreen(true);
fullscreen_mode.setText("Fullscreen On");
}
});
ToggleButton shadow_mode = new ToggleButton("Shadows On");
system_settings.getChildren().add(shadow_mode);
shadow_mode.setOnAction(toggle_shadows -> {
if (shadow_mode.isSelected()) {
for (Pane winnode : open_windows) {
System.out.println("[ShadowEffect Toggle OFF]");
winnode.setEffect(null);
}
shadow_mode.setText("Shadows Off");
} else {
//DropShadow dropShadow = new DropShadow();
dropShadow.setRadius(5.0);
dropShadow.setColor(Color.color(0, 0, 0, 0.6));
for (Pane winnode : open_windows) {
System.out.println("[ShadowEffect Toggle ON]");
winnode.setEffect(dropShadow);
}
shadow_mode.setText("Shadows On");
}
});
// add the node to the root pane
root.getChildren().add(node);
open_windows.add(node);
}
public static void spawn_Start_Window(Pane root, ArrayList<Pane> open_windows) {
// The Node Window (In-Game App)
DraggableNode node = new DraggableNode();
node.setFocusTraversable(true);
node.getStylesheets().add("config.css");
node.setPrefSize(300, 225); // Window Size
// define the style via css
node.setStyle("-fx-background-color: rgb(35, 35, 37);" + "-fx-border-color: rgb(39, 39, 40)");
// position the node
node.setLayoutX(10 + node.getPrefWidth()); //stage.getWidth() stage.getX()
//ShadowTest
DropShadow dropShadow = new DropShadow();
dropShadow.setRadius(5.0);
dropShadow.setColor(Color.color(0, 0, 0, 0.6));
node.setEffect(dropShadow);
//node.setEffect(null); //remove effect
//TitleBar
//Listener
node.focusedProperty().addListener(new ChangeListener<Boolean>()
{
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue)
{
if (newPropertyValue)
{
System.out.println("Textfield on focus");
}
else
{
System.out.println("Textfield out focus");
}
}
});
//App
// add the node to the root pane
root.getChildren().add(node);
open_windows.add(node);
}
public static void main(String[] args) {
}
}
// This is an extra class for the Terminal
class TagArea extends TextArea{
String initTag;
String closeTag;
public TagArea(){
this.initTag = Apps.username;
setTagText(initTag);
super.textProperty().addListener(new ChangeListener<String>(){
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if(!newValue.contains(initTag)){
setTagText(oldValue);
}
}
});
}
public void setTagText(String text){
super.setText(text);
}
}