diff --git a/.gitignore b/.gitignore index 32858aa..d33629a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ .mtj.tmp/ # Package Files # -*.jar *.war *.ear diff --git a/README.md b/README.md index 9ea9b01..9e12763 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,40 @@ -# exit_code_java -One system failure with extra cream, please. >:3 +![Exit_Code banner](https://preview.ibb.co/nNxv85/EC_LOGO_TRANS.png "Exit_Code logo transparent") +#### The Free, Open-Source, Desktop & Hacking Simulator Game. + +ExitCode is a desktop simulator with a emphasis on hacking. The plan is to take the best parts from my favourite games, combined with (of course) my own original ideas, and turn them into something great! + +Here is a brief overview of what's to come: + + +* Full Multi-Platform Support (Windows/Linux/Mac) +* Realistic PC Desktop +* Web-universe to explore (dark web!!!) +* Play In-Game Games (Game-ception?) +* Attack, and team up with other players in multi-player, and connect with friends in the in-game social site (yet to be named) +* Find various in-game Apps/Scripts/Missions, download player-made ones, or create your own. +* Take on randomly generated jobs, attack randomly generated systems, and collect information on randomly created NPCs, in a world that expands dynamically as you play. +* Take either side of the law, or try you luck at playing both, with a reputation system that changes the world around you. (And how the world sees you.) + + +- - - + +- - - + +![patreon banner](https://orig00.deviantart.net/443c/f/2015/334/4/c/patreon_word_logo_for_light_bg_by_angelasasser-d9imh6a.png "Support development on Patreon!") +*Don't forget! If you like what you see, and would like to see development continue, **[you can support development on Patreon!](https://www.patreon.com/TheCyaniteProject)*** + +You can check my page for screenshots, and other updates without having to subscribe. +Patreons can download major updates early! (when they are avalable) + +# HELP WANTED +#### Due to lack of funding, I cannot afford to pay you. + (I will, however, make sure to credit you properly for your work) +* Java Programmers (Any skill level) Preferably ones that have used JavaFX +* Artists (vector-style or pixel, any skill level) [Example of a "Vector-Style"](http://nerdapproved.com/misc-weirdness/beautiful-minimalist-game-of-thrones-fan-art/) +* Creative people to design minimal websites to go in my game (This can be a detailed description, image, or HTML) + +Contact: +Telegram ```@TheCyaniteProject``` +Twitter ```@exit_code_dev``` +Email ```TheCyaniteProject@gmail.com``` + diff --git a/main/application/Apps.java b/main/application/Apps.java new file mode 100644 index 0000000..c4660bc --- /dev/null +++ b/main/application/Apps.java @@ -0,0 +1,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 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 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() + { + @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 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 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() + { + @Override + public void changed(ObservableValue 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(){ + @Override + public void changed(ObservableValue observable, String oldValue, String newValue) { + if(!newValue.contains(initTag)){ + setTagText(oldValue); + } + } + }); + } + public void setTagText(String text){ + super.setText(text); + } +} \ No newline at end of file diff --git a/main/application/Console.java b/main/application/Console.java new file mode 100644 index 0000000..b0a9062 --- /dev/null +++ b/main/application/Console.java @@ -0,0 +1,66 @@ +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.*; + +// This is just a few command tests + +public class Console { + + public static void runCommand(String input, String username, Label termArea) { + String command = new String(); + String body = new String(); + if(!input.contains(" ")){ + command = input.trim(); + body = "null"; + } + else + { + command = input.split(" ", 2)[0]; + body = input.split(" ", 2)[1]; + if(body.trim().equals("")) { + body = "null"; + } + } + if(termArea.getText().trim().equals("")) { + termArea.setText(" " + username + input); + } + else + { + termArea.setText(termArea.getText() + "\n " + username + input); + } + if(!Arrays.asList("echo", "clear", "help").contains(command)) { + termArea.setText(termArea.getText() + "\n \"" + command + "\" is not a valid command.\n"); + } + else + { + if (command.trim().equals("help")) { + termArea.setText(termArea.getText() + "\n help - Shows a list of all commands" + +"\n echo - Prints text to console" + +"\n clear - Clears the console\n"); + } + else if(command.trim().equals("echo")) { + if(!body.equals("null")) { + termArea.setText(termArea.getText() + "\n " + body + "\n"); + } + else + { + termArea.setText(termArea.getText() + "\n"); + } + } + else if (command.trim().equals("clear")) { + termArea.setText(""); + } + } + + } +} \ No newline at end of file diff --git a/main/application/DraggableNode.java b/main/application/DraggableNode.java new file mode 100644 index 0000000..85ef426 --- /dev/null +++ b/main/application/DraggableNode.java @@ -0,0 +1,129 @@ +/** + * Simple draggable node. + * + * Dragging code based on {@link http://blog.ngopal.com.np/2011/06/09/draggable-node-in-javafx-2-0/} + * + * @author Michael Hoffer + */ + +package application; + +import javafx.event.EventHandler; +import javafx.scene.Node; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.BorderPane; + +class DraggableNode extends BorderPane { + + // node position + private double x = 0; + private double y = 0; + // mouse position + private double mousex = 0; + private double mousey = 0; + private Node view; + private boolean dragging = false; + private boolean moveToFront = true; + + public DraggableNode() { + init(); + } + + public DraggableNode(Node view) { + this.view = view; + + getChildren().add(view); + init(); + } + + private void init() { + + onMousePressedProperty().set(new EventHandler() { + @Override + public void handle(MouseEvent event) { + + // record the current mouse X and Y position on Node + mousex = event.getSceneX(); + mousey = event.getSceneY(); + + x = getLayoutX(); + y = getLayoutY(); + + if (isMoveToFront()) { + toFront(); + } + } + }); + + //Event Listener for MouseDragged + onMouseDraggedProperty().set(new EventHandler() { + @Override + public void handle(MouseEvent event) { + + // Get the exact moved X and Y + + double offsetX = event.getSceneX() - mousex; + double offsetY = event.getSceneY() - mousey; + + x += offsetX; + y += offsetY; + + double scaledX = x; + double scaledY = y; + + setLayoutX(scaledX); + setLayoutY(scaledY); + + dragging = true; + + // again set current Mouse x AND y position + mousex = event.getSceneX(); + mousey = event.getSceneY(); + + event.consume(); + } + }); + + onMouseClickedProperty().set(new EventHandler() { + @Override + public void handle(MouseEvent event) { + + dragging = false; + } + }); + + } + + /** + * @return the dragging + */ + protected boolean isDragging() { + return dragging; + } + + + /** + * @return the view + */ + public Node getView() { + return view; + } + + /** + * @param moveToFront the moveToFront to set + */ + public void setMoveToFront(boolean moveToFront) { + this.moveToFront = moveToFront; + } + + /** + * @return the moveToFront + */ + public boolean isMoveToFront() { + return moveToFront; + } + + public void removeNode(Node n) { + getChildren().remove(n); + } +} \ No newline at end of file diff --git a/main/application/Main.java b/main/application/Main.java new file mode 100644 index 0000000..82b7636 --- /dev/null +++ b/main/application/Main.java @@ -0,0 +1,127 @@ +package application; + +import javafx.application.*; +import javafx.stage.*; +import javafx.scene.Node; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.layout.*; +import javafx.scene.effect.*; +import javafx.scene.image.*; +import javafx.beans.value.*; +import javafx.scene.paint.*; +import javafx.scene.input.*; +import javafx.geometry.*; +import javafx.event.*; +import java.util.*; + +public class Main extends Application { + + @Override + public void start(Stage primaryStage) { + + ArrayList open_windows = new ArrayList(); + + // we use a default pane without layout such as HBox, VBox etc. + final Pane root = new Pane(); + final BorderPane root_desktop = new BorderPane(); + root.setPrefSize(800, 475); // Set default size of the window: (Width, height) + root.getChildren().add(root_desktop); + root_desktop.prefWidthProperty().bind(root.widthProperty()); // Fit root_desktop to root (yes, both Pane's are required.) + root_desktop.prefHeightProperty().bind(root.heightProperty()); + root_desktop.setBackground(Background.EMPTY); // Makes the background color transparent, else the background fills with color. + root.setBackground(Background.EMPTY); + + //TaskBar + HBox task_bar = new HBox(); + task_bar.getStylesheets().add("config.css"); + task_bar.setStyle("-fx-background-color: rgb(35, 35, 37);" + "-fx-border-color: rgb(39, 39, 40)"); + root_desktop.setBottom(task_bar); + + //Start + Button start_button = new Button("{ Nix }"); + task_bar.getChildren().add(start_button); + start_button.setOnAction(open -> { + //Apps.spawn_Start_Window(root, open_windows); + }); + + //AppBar + HBox app_bar = new HBox(); + task_bar.getChildren().add(app_bar); + HBox.setHgrow(app_bar, Priority.ALWAYS); + + //Apps + Button open_terminal = new Button("Terminal"); + app_bar.getChildren().add(open_terminal); + open_terminal.setOnAction(open -> { + Apps.spawn_Terminal_Window(root, open_windows); + }); + Button open_quickpad = new Button("QuickPad"); + app_bar.getChildren().add(open_quickpad); + open_quickpad.setOnAction(open -> { + Apps.spawn_QuickPad_Window(root, open_windows); + }); + + + //Util + Button settings_button = new Button("Settings"); + task_bar.getChildren().add(settings_button); + settings_button.setOnAction(open -> { + Apps.spawn_Settings_Window(root, open_windows, primaryStage); + }); + + Button quit_game = new Button("Shutdown"); + task_bar.getChildren().add(quit_game); + quit_game.setOnAction(toggle_fullscreen -> { + preExitTasks(); + primaryStage.close(); + }); + + + // Finalizing stuffs + + + final Scene scene = new Scene(root); + // CSS Styling + //scene.getStylesheets().add("config.css"); + // Add default color + scene.setFill(Color.rgb(0, 128, 128)); + // Create the Wallpaper + try + { + Image image = new Image("wallpaper.jpg"); + ImagePattern pattern = new ImagePattern(image); + scene.setFill(pattern); + } + catch(IllegalArgumentException s) + { + System.out.println("\"wallpaper.jpg\" was not found."); + } + + // Finally, show the stage + primaryStage.setTitle("ExitCode"); + primaryStage.setScene(scene); + primaryStage.show(); + primaryStage.setOnCloseRequest(new EventHandler() { //Propperly kill the app + @Override + public void handle(WindowEvent t) { + Platform.exit(); + System.exit(0); + } + }); + // This sets the fullscreen exit key to blank, and removes the "press ESC to leave fullscreen" because I need Esc for the menu. + primaryStage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); + // This forces fullscreen in the current Stage + primaryStage.setFullScreen(true); + } + + public static void main(String[] args) { + System.out.println("[System startup - Hello, world!]"); + launch(args); + } + + public void preExitTasks() { + System.out.println("[System shutdown - Goodbye, cruel world!]"); + } + +} diff --git a/main/config.css b/main/config.css new file mode 100644 index 0000000..5a14af3 --- /dev/null +++ b/main/config.css @@ -0,0 +1,154 @@ +.text-area, .text-area .viewport, .text-area .content { + -fx-background-color: transparent ; + -fx-border-color: transparent ; +} + +.scroll-pane, .scroll-pane .viewport, .scroll-pane .content { + -fx-background-color: transparent ; + -fx-border-color: transparent ; +} + +.text-area > .scroll-pane {-fx-vbar-policy: never ; /* Toggle visability of the virtical scrollbar (always,needed,never) */} /* */ + +/** ----------------------------- **/ + +/** CSS **/ + +/* The main scrollbar CSS class of ListView */ +.text-area .scroll-bar:horizontal , +.text-area .scroll-bar:vertical{ + -fx-background-color:transparent; + +} + +/* The increment and decrement button CSS class of scrollbar */ +.text-area .increment-button ,.text-area .decrement-button { + -fx-background-color:transparent; + -fx-background-radius: 2em; + +} + +/** This is soposed to be to remove the arrows from the scroll bar ** +.text-area .scroll-bar .increment-arrow, +.text-area .scroll-bar .decrement-arrow, + { + -fx-shape: null; + -fx-padding:0; +}/* */ + +/* The main scrollbar **track** CSS class */ +.text-area .scroll-bar:horizontal .track, +.text-area .scroll-bar:vertical .track{ + -fx-background-color: transparent; + -fx-border-color:derive(gray,80%); + + -fx-background-radius: 2em; + -fx-border-radius:2em; +} + +/* The main scrollbar **thumb** CSS class which we drag every time (movable) */ +.text-area .scroll-bar:horizontal .thumb, +.text-area .scroll-bar:vertical .thumb { + -fx-background-color:derive(black,90%); + -fx-background-insets: 2, 0, 0; + -fx-background-radius: 2em; + +} + +/* ------------------------------------------------------------------------------------- */ +/** EVENT CSS **/ +/* ------------------------------------------------------------------------------------- */ + +/* The main scrollbar **track** CSS class on event of "hover" and "pressed" */ + +.text-area .scroll-bar:horizontal:hover .track , +.text-area .scroll-bar:horizontal:pressed .track , +.text-area .scroll-bar:vertical:hover .track, +.text-area .scroll-bar:vertical:pressed .track{ + -fx-background-color:transparent; + + -fx-opacity: 0.2; + -fx-background-radius: 0em; + +} + +/* The main scrollbar **thumb** CSS class on event of "hover" and "pressed" */ +.text-area .scroll-bar .thumb:hover, +.text-area .scroll-bar .thumb:pressed{ + -fx-background-color: derive(black,50%); +} +.text-area .increment-button:hover ,.text-area .decrement-button:hover { + -fx-background-color:derive(transparent,100%); + -fx-border-color:derive(transparent,80%); + -fx-padding:10px; +} + + + + +.button{ + -fx-border-color: transparent; + -fx-border-width: 0; + -fx-background-radius: 0; + -fx-background-color: transparent; + -fx-font-family:"Segoe UI", Helvetica, Arial, sans-serif; + -fx-font-size: 1em; /* 12 */ + -fx-text-fill: white; +} + +.button:focused { + -fx-border-color: rgb(0, 0, 0, 0.6); + -fx-border-width: 0; + -fx-background-radius: 0; +} + +.button:hover { + -fx-background-color: rgb(0, 0, 0, 0.3); + -fx-text-fill: rgb(200, 200, 200); + -fx-border-width: 0; + -fx-background-radius: 0; +} + +.button:pressed { + -fx-background-color: rgb(0, 0, 0, 0.6); + -fx-border-width: 0; + -fx-background-radius: 0; + -fx-text-fill: white; +} + + + + +.toggle-button{ + -fx-border-color: transparent; + -fx-background-color: transparent; + -fx-border-width: 0; + -fx-background-radius: 0; + -fx-font-family:"Segoe UI", Helvetica, Arial, sans-serif; + -fx-font-size: 1em; /* 12 */ + -fx-text-fill: white; +} + +.toggle-button:selected { + -fx-border-color: transparent; + -fx-background-color: rgb(0, 0, 0, 0.6); + -fx-border-width: 0; + -fx-background-radius: 0; + -fx-text-fill: white; +} + +.toggle-button:hover { + -fx-background-color: rgb(0, 0, 0, 0.3); + -fx-text-fill: rgb(200, 200, 200); + -fx-border-width: 0; + -fx-background-radius: 0; +} + +.toggle-button:pressed { + -fx-background-color: rgb(0, 0, 0, 0.6); + -fx-text-fill: rgb(200, 200, 200); + -fx-border-width: 0; + -fx-background-radius: 0; + -fx-text-fill: white; +} + diff --git a/main/src/Apps.java b/main/src/Apps.java new file mode 100644 index 0000000..c4660bc --- /dev/null +++ b/main/src/Apps.java @@ -0,0 +1,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 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 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() + { + @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 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 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() + { + @Override + public void changed(ObservableValue 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(){ + @Override + public void changed(ObservableValue observable, String oldValue, String newValue) { + if(!newValue.contains(initTag)){ + setTagText(oldValue); + } + } + }); + } + public void setTagText(String text){ + super.setText(text); + } +} \ No newline at end of file diff --git a/main/src/Console.java b/main/src/Console.java new file mode 100644 index 0000000..b0a9062 --- /dev/null +++ b/main/src/Console.java @@ -0,0 +1,66 @@ +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.*; + +// This is just a few command tests + +public class Console { + + public static void runCommand(String input, String username, Label termArea) { + String command = new String(); + String body = new String(); + if(!input.contains(" ")){ + command = input.trim(); + body = "null"; + } + else + { + command = input.split(" ", 2)[0]; + body = input.split(" ", 2)[1]; + if(body.trim().equals("")) { + body = "null"; + } + } + if(termArea.getText().trim().equals("")) { + termArea.setText(" " + username + input); + } + else + { + termArea.setText(termArea.getText() + "\n " + username + input); + } + if(!Arrays.asList("echo", "clear", "help").contains(command)) { + termArea.setText(termArea.getText() + "\n \"" + command + "\" is not a valid command.\n"); + } + else + { + if (command.trim().equals("help")) { + termArea.setText(termArea.getText() + "\n help - Shows a list of all commands" + +"\n echo - Prints text to console" + +"\n clear - Clears the console\n"); + } + else if(command.trim().equals("echo")) { + if(!body.equals("null")) { + termArea.setText(termArea.getText() + "\n " + body + "\n"); + } + else + { + termArea.setText(termArea.getText() + "\n"); + } + } + else if (command.trim().equals("clear")) { + termArea.setText(""); + } + } + + } +} \ No newline at end of file diff --git a/main/src/DraggableNode.java b/main/src/DraggableNode.java new file mode 100644 index 0000000..85ef426 --- /dev/null +++ b/main/src/DraggableNode.java @@ -0,0 +1,129 @@ +/** + * Simple draggable node. + * + * Dragging code based on {@link http://blog.ngopal.com.np/2011/06/09/draggable-node-in-javafx-2-0/} + * + * @author Michael Hoffer + */ + +package application; + +import javafx.event.EventHandler; +import javafx.scene.Node; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.BorderPane; + +class DraggableNode extends BorderPane { + + // node position + private double x = 0; + private double y = 0; + // mouse position + private double mousex = 0; + private double mousey = 0; + private Node view; + private boolean dragging = false; + private boolean moveToFront = true; + + public DraggableNode() { + init(); + } + + public DraggableNode(Node view) { + this.view = view; + + getChildren().add(view); + init(); + } + + private void init() { + + onMousePressedProperty().set(new EventHandler() { + @Override + public void handle(MouseEvent event) { + + // record the current mouse X and Y position on Node + mousex = event.getSceneX(); + mousey = event.getSceneY(); + + x = getLayoutX(); + y = getLayoutY(); + + if (isMoveToFront()) { + toFront(); + } + } + }); + + //Event Listener for MouseDragged + onMouseDraggedProperty().set(new EventHandler() { + @Override + public void handle(MouseEvent event) { + + // Get the exact moved X and Y + + double offsetX = event.getSceneX() - mousex; + double offsetY = event.getSceneY() - mousey; + + x += offsetX; + y += offsetY; + + double scaledX = x; + double scaledY = y; + + setLayoutX(scaledX); + setLayoutY(scaledY); + + dragging = true; + + // again set current Mouse x AND y position + mousex = event.getSceneX(); + mousey = event.getSceneY(); + + event.consume(); + } + }); + + onMouseClickedProperty().set(new EventHandler() { + @Override + public void handle(MouseEvent event) { + + dragging = false; + } + }); + + } + + /** + * @return the dragging + */ + protected boolean isDragging() { + return dragging; + } + + + /** + * @return the view + */ + public Node getView() { + return view; + } + + /** + * @param moveToFront the moveToFront to set + */ + public void setMoveToFront(boolean moveToFront) { + this.moveToFront = moveToFront; + } + + /** + * @return the moveToFront + */ + public boolean isMoveToFront() { + return moveToFront; + } + + public void removeNode(Node n) { + getChildren().remove(n); + } +} \ No newline at end of file diff --git a/main/src/Main.java b/main/src/Main.java new file mode 100644 index 0000000..82b7636 --- /dev/null +++ b/main/src/Main.java @@ -0,0 +1,127 @@ +package application; + +import javafx.application.*; +import javafx.stage.*; +import javafx.scene.Node; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.layout.*; +import javafx.scene.effect.*; +import javafx.scene.image.*; +import javafx.beans.value.*; +import javafx.scene.paint.*; +import javafx.scene.input.*; +import javafx.geometry.*; +import javafx.event.*; +import java.util.*; + +public class Main extends Application { + + @Override + public void start(Stage primaryStage) { + + ArrayList open_windows = new ArrayList(); + + // we use a default pane without layout such as HBox, VBox etc. + final Pane root = new Pane(); + final BorderPane root_desktop = new BorderPane(); + root.setPrefSize(800, 475); // Set default size of the window: (Width, height) + root.getChildren().add(root_desktop); + root_desktop.prefWidthProperty().bind(root.widthProperty()); // Fit root_desktop to root (yes, both Pane's are required.) + root_desktop.prefHeightProperty().bind(root.heightProperty()); + root_desktop.setBackground(Background.EMPTY); // Makes the background color transparent, else the background fills with color. + root.setBackground(Background.EMPTY); + + //TaskBar + HBox task_bar = new HBox(); + task_bar.getStylesheets().add("config.css"); + task_bar.setStyle("-fx-background-color: rgb(35, 35, 37);" + "-fx-border-color: rgb(39, 39, 40)"); + root_desktop.setBottom(task_bar); + + //Start + Button start_button = new Button("{ Nix }"); + task_bar.getChildren().add(start_button); + start_button.setOnAction(open -> { + //Apps.spawn_Start_Window(root, open_windows); + }); + + //AppBar + HBox app_bar = new HBox(); + task_bar.getChildren().add(app_bar); + HBox.setHgrow(app_bar, Priority.ALWAYS); + + //Apps + Button open_terminal = new Button("Terminal"); + app_bar.getChildren().add(open_terminal); + open_terminal.setOnAction(open -> { + Apps.spawn_Terminal_Window(root, open_windows); + }); + Button open_quickpad = new Button("QuickPad"); + app_bar.getChildren().add(open_quickpad); + open_quickpad.setOnAction(open -> { + Apps.spawn_QuickPad_Window(root, open_windows); + }); + + + //Util + Button settings_button = new Button("Settings"); + task_bar.getChildren().add(settings_button); + settings_button.setOnAction(open -> { + Apps.spawn_Settings_Window(root, open_windows, primaryStage); + }); + + Button quit_game = new Button("Shutdown"); + task_bar.getChildren().add(quit_game); + quit_game.setOnAction(toggle_fullscreen -> { + preExitTasks(); + primaryStage.close(); + }); + + + // Finalizing stuffs + + + final Scene scene = new Scene(root); + // CSS Styling + //scene.getStylesheets().add("config.css"); + // Add default color + scene.setFill(Color.rgb(0, 128, 128)); + // Create the Wallpaper + try + { + Image image = new Image("wallpaper.jpg"); + ImagePattern pattern = new ImagePattern(image); + scene.setFill(pattern); + } + catch(IllegalArgumentException s) + { + System.out.println("\"wallpaper.jpg\" was not found."); + } + + // Finally, show the stage + primaryStage.setTitle("ExitCode"); + primaryStage.setScene(scene); + primaryStage.show(); + primaryStage.setOnCloseRequest(new EventHandler() { //Propperly kill the app + @Override + public void handle(WindowEvent t) { + Platform.exit(); + System.exit(0); + } + }); + // This sets the fullscreen exit key to blank, and removes the "press ESC to leave fullscreen" because I need Esc for the menu. + primaryStage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); + // This forces fullscreen in the current Stage + primaryStage.setFullScreen(true); + } + + public static void main(String[] args) { + System.out.println("[System startup - Hello, world!]"); + launch(args); + } + + public void preExitTasks() { + System.out.println("[System shutdown - Goodbye, cruel world!]"); + } + +} diff --git a/main/src/config.css b/main/src/config.css new file mode 100644 index 0000000..5a14af3 --- /dev/null +++ b/main/src/config.css @@ -0,0 +1,154 @@ +.text-area, .text-area .viewport, .text-area .content { + -fx-background-color: transparent ; + -fx-border-color: transparent ; +} + +.scroll-pane, .scroll-pane .viewport, .scroll-pane .content { + -fx-background-color: transparent ; + -fx-border-color: transparent ; +} + +.text-area > .scroll-pane {-fx-vbar-policy: never ; /* Toggle visability of the virtical scrollbar (always,needed,never) */} /* */ + +/** ----------------------------- **/ + +/** CSS **/ + +/* The main scrollbar CSS class of ListView */ +.text-area .scroll-bar:horizontal , +.text-area .scroll-bar:vertical{ + -fx-background-color:transparent; + +} + +/* The increment and decrement button CSS class of scrollbar */ +.text-area .increment-button ,.text-area .decrement-button { + -fx-background-color:transparent; + -fx-background-radius: 2em; + +} + +/** This is soposed to be to remove the arrows from the scroll bar ** +.text-area .scroll-bar .increment-arrow, +.text-area .scroll-bar .decrement-arrow, + { + -fx-shape: null; + -fx-padding:0; +}/* */ + +/* The main scrollbar **track** CSS class */ +.text-area .scroll-bar:horizontal .track, +.text-area .scroll-bar:vertical .track{ + -fx-background-color: transparent; + -fx-border-color:derive(gray,80%); + + -fx-background-radius: 2em; + -fx-border-radius:2em; +} + +/* The main scrollbar **thumb** CSS class which we drag every time (movable) */ +.text-area .scroll-bar:horizontal .thumb, +.text-area .scroll-bar:vertical .thumb { + -fx-background-color:derive(black,90%); + -fx-background-insets: 2, 0, 0; + -fx-background-radius: 2em; + +} + +/* ------------------------------------------------------------------------------------- */ +/** EVENT CSS **/ +/* ------------------------------------------------------------------------------------- */ + +/* The main scrollbar **track** CSS class on event of "hover" and "pressed" */ + +.text-area .scroll-bar:horizontal:hover .track , +.text-area .scroll-bar:horizontal:pressed .track , +.text-area .scroll-bar:vertical:hover .track, +.text-area .scroll-bar:vertical:pressed .track{ + -fx-background-color:transparent; + + -fx-opacity: 0.2; + -fx-background-radius: 0em; + +} + +/* The main scrollbar **thumb** CSS class on event of "hover" and "pressed" */ +.text-area .scroll-bar .thumb:hover, +.text-area .scroll-bar .thumb:pressed{ + -fx-background-color: derive(black,50%); +} +.text-area .increment-button:hover ,.text-area .decrement-button:hover { + -fx-background-color:derive(transparent,100%); + -fx-border-color:derive(transparent,80%); + -fx-padding:10px; +} + + + + +.button{ + -fx-border-color: transparent; + -fx-border-width: 0; + -fx-background-radius: 0; + -fx-background-color: transparent; + -fx-font-family:"Segoe UI", Helvetica, Arial, sans-serif; + -fx-font-size: 1em; /* 12 */ + -fx-text-fill: white; +} + +.button:focused { + -fx-border-color: rgb(0, 0, 0, 0.6); + -fx-border-width: 0; + -fx-background-radius: 0; +} + +.button:hover { + -fx-background-color: rgb(0, 0, 0, 0.3); + -fx-text-fill: rgb(200, 200, 200); + -fx-border-width: 0; + -fx-background-radius: 0; +} + +.button:pressed { + -fx-background-color: rgb(0, 0, 0, 0.6); + -fx-border-width: 0; + -fx-background-radius: 0; + -fx-text-fill: white; +} + + + + +.toggle-button{ + -fx-border-color: transparent; + -fx-background-color: transparent; + -fx-border-width: 0; + -fx-background-radius: 0; + -fx-font-family:"Segoe UI", Helvetica, Arial, sans-serif; + -fx-font-size: 1em; /* 12 */ + -fx-text-fill: white; +} + +.toggle-button:selected { + -fx-border-color: transparent; + -fx-background-color: rgb(0, 0, 0, 0.6); + -fx-border-width: 0; + -fx-background-radius: 0; + -fx-text-fill: white; +} + +.toggle-button:hover { + -fx-background-color: rgb(0, 0, 0, 0.3); + -fx-text-fill: rgb(200, 200, 200); + -fx-border-width: 0; + -fx-background-radius: 0; +} + +.toggle-button:pressed { + -fx-background-color: rgb(0, 0, 0, 0.6); + -fx-text-fill: rgb(200, 200, 200); + -fx-border-width: 0; + -fx-background-radius: 0; + -fx-text-fill: white; +} + diff --git a/main/wallpaper.jpg b/main/wallpaper.jpg new file mode 100644 index 0000000..08772f8 Binary files /dev/null and b/main/wallpaper.jpg differ diff --git a/pre-re_7.jar b/pre-re_7.jar new file mode 100644 index 0000000..3986eec Binary files /dev/null and b/pre-re_7.jar differ