Skip to content

Commit e95a4de

Browse files
Pre-Release 7
* Changed main source file from TestApp.Java to Main.Java + Added new in-game Terminal, and added a few commands! (WIP!) * The game is now Fullscreen by default - Removed NSA spyware
1 parent 54e1d59 commit e95a4de

13 files changed

Lines changed: 988 additions & 498 deletions

File tree

‎main/application/Apps.java‎

Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
package application;
2+
3+
import javafx.stage.*;
4+
import javafx.scene.control.*;
5+
import javafx.scene.layout.*;
6+
import javafx.scene.effect.*;
7+
import javafx.beans.value.*;
8+
import javafx.scene.paint.*;
9+
import javafx.scene.input.*;
10+
import javafx.scene.text.*;
11+
import javafx.geometry.*;
12+
import javafx.event.*;
13+
import java.util.*;
14+
15+
public class Apps {
16+
17+
static String username = new String("root@NIX:~$ ");
18+
19+
public static void spawn_QuickPad_Window(Pane root, ArrayList<Pane> open_windows) {
20+
// The Node Window (In-Game App)
21+
DraggableNode node = new DraggableNode();
22+
node.getStylesheets().add("config.css");
23+
node.setPrefSize(300, 225); // Window Size
24+
// define the style via css
25+
node.setStyle("-fx-background-color: rgb(35, 35, 37);" + "-fx-border-color: rgb(39, 39, 40)");
26+
// position the node
27+
node.setLayoutX(10 + node.getPrefWidth());
28+
29+
//Shadows
30+
DropShadow dropShadow = new DropShadow();
31+
dropShadow.setRadius(5.0);
32+
dropShadow.setColor(Color.color(0, 0, 0, 0.6));
33+
34+
node.setEffect(dropShadow);
35+
//node.setEffect(null); //remove effect
36+
37+
//TitleBar
38+
HBox title_bar = new HBox();
39+
title_bar.setPrefHeight(10);
40+
title_bar.setPadding(new Insets(0,0,0,5));
41+
//title_bar.setStyle("-fx-background-color: rgb(0, 0, 0, 0.6)");
42+
//Name
43+
Label win_name = new Label("Quickpad");
44+
win_name.setStyle("-fx-text-fill: white");
45+
//Spacer
46+
Region spacer = new Region();
47+
HBox.setHgrow(spacer, Priority.ALWAYS);
48+
//Quit
49+
Button win_close = new Button("X");
50+
win_close.setOnAction(close -> {
51+
open_windows.remove(node);
52+
root.getChildren().remove(node);
53+
});
54+
title_bar.getChildren().addAll(win_name, spacer, win_close);
55+
title_bar.setAlignment(Pos.CENTER_RIGHT);
56+
node.setTop(title_bar);
57+
//App
58+
TextArea textArea = new TextArea();
59+
textArea.setStyle("-fx-text-fill: white");
60+
textArea.setWrapText(true);
61+
node.setCenter(textArea);
62+
textArea.setText("Enter some text...");
63+
// add the node to the root pane
64+
root.getChildren().add(node);
65+
open_windows.add(node);
66+
}
67+
68+
public static void spawn_Terminal_Window(Pane root, ArrayList<Pane> open_windows) {
69+
// The Node Window (In-Game App)
70+
DraggableNode node = new DraggableNode();
71+
node.getStylesheets().add("config.css");
72+
node.setPrefSize(350, 225); // Window Size
73+
// define the style via css
74+
node.setStyle("-fx-background-color: rgb(35, 35, 37);" + "-fx-border-color: rgb(39, 39, 40)");
75+
// position the node
76+
node.setLayoutX(10 + node.getPrefWidth());
77+
78+
//Shadows
79+
DropShadow dropShadow = new DropShadow();
80+
dropShadow.setRadius(5.0);
81+
dropShadow.setColor(Color.color(0, 0, 0, 0.6));
82+
83+
node.setEffect(dropShadow);
84+
//node.setEffect(null); //remove effect
85+
86+
//TitleBar
87+
HBox title_bar = new HBox();
88+
title_bar.setPrefHeight(10);
89+
title_bar.setPadding(new Insets(0,0,0,5));
90+
//title_bar.setStyle("-fx-background-color: rgb(0, 0, 0, 0.6)");
91+
//Name
92+
Label win_name = new Label("Terminal");
93+
win_name.setStyle("-fx-text-fill: white");
94+
//Spacer
95+
Region spacer = new Region();
96+
HBox.setHgrow(spacer, Priority.ALWAYS);
97+
//Quit
98+
Button win_close = new Button("X");
99+
win_close.setOnAction(close -> {
100+
open_windows.remove(node);
101+
root.getChildren().remove(node);
102+
});
103+
title_bar.getChildren().addAll(win_name, spacer, win_close);
104+
title_bar.setAlignment(Pos.CENTER_RIGHT);
105+
node.setTop(title_bar);
106+
//App
107+
ScrollPane termWindow = new ScrollPane();
108+
termWindow.setFitToWidth(true);
109+
node.setCenter(termWindow);
110+
VBox terminalApp = new VBox();
111+
termWindow.setContent(terminalApp);
112+
Label termArea = new Label();
113+
termArea.setStyle("-fx-text-fill: white");
114+
termArea.setPrefWidth(node.getPrefWidth());
115+
termArea.setWrapText(true);
116+
terminalApp.getChildren().add(termArea);
117+
termArea.setText(" This is a WIP, and has limited commands.\n");
118+
TagArea termEntry = new TagArea();
119+
termEntry.setWrapText(true);
120+
termEntry.setStyle("-fx-text-fill: white");
121+
terminalApp.getChildren().add(termEntry);
122+
123+
termEntry.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>()
124+
{
125+
@Override
126+
public void handle(KeyEvent ke) {
127+
if (ke.getCode().equals(KeyCode.ENTER)) {
128+
ke.consume(); // necessary to prevent event handlers for this event
129+
String output = new String(termEntry.getText().replace(username, ""));
130+
System.out.println("[Console Command: " + output + "]");
131+
Console.runCommand(output, username, termArea);
132+
termEntry.setText(username);
133+
termEntry.end();
134+
}
135+
}
136+
});
137+
138+
// add the node to the root pane
139+
root.getChildren().add(node);
140+
open_windows.add(node);
141+
}
142+
143+
public static void spawn_Settings_Window(Pane root, ArrayList<Pane> open_windows, Stage primaryStage) {
144+
// The Node Window (In-Game App)
145+
DraggableNode node = new DraggableNode();
146+
node.getStylesheets().add("config.css");
147+
node.setPrefSize(300, 225); // Window Size
148+
// define the style via css
149+
node.setStyle("-fx-background-color: rgb(35, 35, 37);" + "-fx-border-color: rgb(39, 39, 40)");
150+
// position the node
151+
node.setLayoutX(10 + node.getPrefWidth());
152+
153+
//ShadowTest
154+
DropShadow dropShadow = new DropShadow();
155+
dropShadow.setRadius(5.0);
156+
dropShadow.setColor(Color.color(0, 0, 0, 0.6));
157+
158+
node.setEffect(dropShadow);
159+
//node.setEffect(null); //remove effect
160+
161+
//TitleBar
162+
HBox title_bar = new HBox();
163+
title_bar.setPrefHeight(10);
164+
title_bar.setPadding(new Insets(0,0,0,5));
165+
//title_bar.setStyle("-fx-background-color: rgb(0, 0, 0, 0.6)");
166+
//Name
167+
Label win_name = new Label("System Settings");
168+
win_name.setStyle("-fx-text-fill: white");
169+
//Spacer
170+
Region spacer = new Region();
171+
HBox.setHgrow(spacer, Priority.ALWAYS);
172+
//Quit
173+
Button win_close = new Button("X");
174+
win_close.setOnAction(close -> {
175+
open_windows.remove(node);
176+
root.getChildren().remove(node);
177+
});
178+
title_bar.getChildren().addAll(win_name, spacer, win_close);
179+
title_bar.setAlignment(Pos.CENTER_RIGHT);
180+
node.setTop(title_bar);
181+
//App
182+
VBox system_settings = new VBox();
183+
node.setCenter(system_settings);
184+
185+
// Toggle Fullscreen
186+
ToggleButton fullscreen_mode = new ToggleButton("Fullscreen On");
187+
system_settings.getChildren().add(fullscreen_mode);
188+
fullscreen_mode.setOnAction(toggle_fullscreen -> {
189+
if (fullscreen_mode.isSelected()) {
190+
System.out.println("[Fullscreen Toggle OFF]");
191+
primaryStage.setFullScreen(false);
192+
fullscreen_mode.setText("Fullscreen Off");
193+
} else {
194+
System.out.println("[Fullscreen Toggle ON]");
195+
primaryStage.setFullScreen(true);
196+
fullscreen_mode.setText("Fullscreen On");
197+
}
198+
});
199+
200+
ToggleButton shadow_mode = new ToggleButton("Shadows On");
201+
system_settings.getChildren().add(shadow_mode);
202+
shadow_mode.setOnAction(toggle_shadows -> {
203+
if (shadow_mode.isSelected()) {
204+
for (Pane winnode : open_windows) {
205+
System.out.println("[ShadowEffect Toggle OFF]");
206+
winnode.setEffect(null);
207+
}
208+
shadow_mode.setText("Shadows Off");
209+
} else {
210+
//DropShadow dropShadow = new DropShadow();
211+
dropShadow.setRadius(5.0);
212+
dropShadow.setColor(Color.color(0, 0, 0, 0.6));
213+
for (Pane winnode : open_windows) {
214+
System.out.println("[ShadowEffect Toggle ON]");
215+
winnode.setEffect(dropShadow);
216+
}
217+
shadow_mode.setText("Shadows On");
218+
}
219+
});
220+
// add the node to the root pane
221+
root.getChildren().add(node);
222+
open_windows.add(node);
223+
}
224+
225+
public static void spawn_Start_Window(Pane root, ArrayList<Pane> open_windows) {
226+
// The Node Window (In-Game App)
227+
DraggableNode node = new DraggableNode();
228+
node.setFocusTraversable(true);
229+
node.getStylesheets().add("config.css");
230+
node.setPrefSize(300, 225); // Window Size
231+
// define the style via css
232+
node.setStyle("-fx-background-color: rgb(35, 35, 37);" + "-fx-border-color: rgb(39, 39, 40)");
233+
// position the node
234+
node.setLayoutX(10 + node.getPrefWidth()); //stage.getWidth() stage.getX()
235+
236+
//ShadowTest
237+
DropShadow dropShadow = new DropShadow();
238+
dropShadow.setRadius(5.0);
239+
dropShadow.setColor(Color.color(0, 0, 0, 0.6));
240+
241+
node.setEffect(dropShadow);
242+
//node.setEffect(null); //remove effect
243+
244+
//TitleBar
245+
246+
//Listener
247+
node.focusedProperty().addListener(new ChangeListener<Boolean>()
248+
{
249+
@Override
250+
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue)
251+
{
252+
if (newPropertyValue)
253+
{
254+
System.out.println("Textfield on focus");
255+
}
256+
else
257+
{
258+
System.out.println("Textfield out focus");
259+
}
260+
}
261+
});
262+
263+
//App
264+
265+
// add the node to the root pane
266+
root.getChildren().add(node);
267+
open_windows.add(node);
268+
}
269+
270+
public static void main(String[] args) {
271+
272+
}
273+
274+
}
275+
276+
// This is an extra class for the Terminal
277+
278+
class TagArea extends TextArea{
279+
String initTag;
280+
String closeTag;
281+
public TagArea(){
282+
this.initTag = Apps.username;
283+
setTagText(initTag);
284+
super.textProperty().addListener(new ChangeListener<String>(){
285+
@Override
286+
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
287+
if(!newValue.contains(initTag)){
288+
setTagText(oldValue);
289+
}
290+
}
291+
});
292+
}
293+
public void setTagText(String text){
294+
super.setText(text);
295+
}
296+
}

‎main/application/Console.java‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package application;
2+
3+
import javafx.stage.*;
4+
import javafx.scene.control.*;
5+
import javafx.scene.layout.*;
6+
import javafx.scene.effect.*;
7+
import javafx.beans.value.*;
8+
import javafx.scene.paint.*;
9+
import javafx.scene.input.*;
10+
import javafx.scene.text.*;
11+
import javafx.geometry.*;
12+
import javafx.event.*;
13+
import java.util.*;
14+
15+
// This is just a few command tests
16+
17+
public class Console {
18+
19+
public static void runCommand(String input, String username, Label termArea) {
20+
String command = new String();
21+
String body = new String();
22+
if(!input.contains(" ")){
23+
command = input.trim();
24+
body = "null";
25+
}
26+
else
27+
{
28+
command = input.split(" ", 2)[0];
29+
body = input.split(" ", 2)[1];
30+
if(body.trim().equals("")) {
31+
body = "null";
32+
}
33+
}
34+
if(termArea.getText().trim().equals("")) {
35+
termArea.setText(" " + username + input);
36+
}
37+
else
38+
{
39+
termArea.setText(termArea.getText() + "\n " + username + input);
40+
}
41+
if(!Arrays.asList("echo", "clear", "help").contains(command)) {
42+
termArea.setText(termArea.getText() + "\n \"" + command + "\" is not a valid command.\n");
43+
}
44+
else
45+
{
46+
if (command.trim().equals("help")) {
47+
termArea.setText(termArea.getText() + "\n help - Shows a list of all commands"
48+
+"\n echo - Prints text to console"
49+
+"\n clear - Clears the console\n");
50+
}
51+
else if(command.trim().equals("echo")) {
52+
if(!body.equals("null")) {
53+
termArea.setText(termArea.getText() + "\n " + body + "\n");
54+
}
55+
else
56+
{
57+
termArea.setText(termArea.getText() + "\n");
58+
}
59+
}
60+
else if (command.trim().equals("clear")) {
61+
termArea.setText("");
62+
}
63+
}
64+
65+
}
66+
}

0 commit comments

Comments
 (0)