commit e1c1b51c901f1b3088d113075b6e2171fa90b159 Author: ChococookieOS Date: Sun Apr 14 12:18:58 2019 +0200 Initial git commit diff --git a/QuickLaunch/.DS_Store b/QuickLaunch/.DS_Store new file mode 100644 index 0000000..6688659 Binary files /dev/null and b/QuickLaunch/.DS_Store differ diff --git a/QuickLaunch/.classpath b/QuickLaunch/.classpath new file mode 100644 index 0000000..f057a80 --- /dev/null +++ b/QuickLaunch/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/QuickLaunch/.project b/QuickLaunch/.project new file mode 100644 index 0000000..3d7d6f7 --- /dev/null +++ b/QuickLaunch/.project @@ -0,0 +1,17 @@ + + + QuickLaunch + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/QuickLaunch/.settings/org.eclipse.jdt.core.prefs b/QuickLaunch/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ace45ce --- /dev/null +++ b/QuickLaunch/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/QuickLaunch/.settings/org.eclipse.ltk.core.refactoring.prefs b/QuickLaunch/.settings/org.eclipse.ltk.core.refactoring.prefs new file mode 100644 index 0000000..cfcd1d3 --- /dev/null +++ b/QuickLaunch/.settings/org.eclipse.ltk.core.refactoring.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/QuickLaunch/File.txt b/QuickLaunch/File.txt new file mode 100644 index 0000000..04c084e --- /dev/null +++ b/QuickLaunch/File.txt @@ -0,0 +1,20 @@ +a +/user/path/app.app +b +/path/to/somwhere/bla.exe +e +e +f +f +g +g +h +h +i +i +j +j +k +k +l +l diff --git a/QuickLaunch/bin/HelveticaNeue-UltraLight.otf b/QuickLaunch/bin/HelveticaNeue-UltraLight.otf new file mode 100644 index 0000000..e0aad31 Binary files /dev/null and b/QuickLaunch/bin/HelveticaNeue-UltraLight.otf differ diff --git a/QuickLaunch/bin/LiberationSerif-Regular.ttf b/QuickLaunch/bin/LiberationSerif-Regular.ttf new file mode 100644 index 0000000..e7616da Binary files /dev/null and b/QuickLaunch/bin/LiberationSerif-Regular.ttf differ diff --git a/QuickLaunch/bin/back.png b/QuickLaunch/bin/back.png new file mode 100644 index 0000000..650e6ce Binary files /dev/null and b/QuickLaunch/bin/back.png differ diff --git a/QuickLaunch/bin/basics/BasicGuiApp$1.class b/QuickLaunch/bin/basics/BasicGuiApp$1.class new file mode 100644 index 0000000..37cd720 Binary files /dev/null and b/QuickLaunch/bin/basics/BasicGuiApp$1.class differ diff --git a/QuickLaunch/bin/basics/BasicGuiApp.class b/QuickLaunch/bin/basics/BasicGuiApp.class new file mode 100644 index 0000000..d376be1 Binary files /dev/null and b/QuickLaunch/bin/basics/BasicGuiApp.class differ diff --git a/QuickLaunch/bin/basics/BasicMod.class b/QuickLaunch/bin/basics/BasicMod.class new file mode 100644 index 0000000..be5e2fd Binary files /dev/null and b/QuickLaunch/bin/basics/BasicMod.class differ diff --git a/QuickLaunch/bin/edit.png b/QuickLaunch/bin/edit.png new file mode 100644 index 0000000..16d5fea Binary files /dev/null and b/QuickLaunch/bin/edit.png differ diff --git a/QuickLaunch/bin/guis/FileChooseWindow.class b/QuickLaunch/bin/guis/FileChooseWindow.class new file mode 100644 index 0000000..88b1ffb Binary files /dev/null and b/QuickLaunch/bin/guis/FileChooseWindow.class differ diff --git a/QuickLaunch/bin/guis/MainGui$1.class b/QuickLaunch/bin/guis/MainGui$1.class new file mode 100644 index 0000000..b7635d5 Binary files /dev/null and b/QuickLaunch/bin/guis/MainGui$1.class differ diff --git a/QuickLaunch/bin/guis/MainGui$2.class b/QuickLaunch/bin/guis/MainGui$2.class new file mode 100644 index 0000000..cd8cd4b Binary files /dev/null and b/QuickLaunch/bin/guis/MainGui$2.class differ diff --git a/QuickLaunch/bin/guis/MainGui$3.class b/QuickLaunch/bin/guis/MainGui$3.class new file mode 100644 index 0000000..15752b4 Binary files /dev/null and b/QuickLaunch/bin/guis/MainGui$3.class differ diff --git a/QuickLaunch/bin/guis/MainGui.class b/QuickLaunch/bin/guis/MainGui.class new file mode 100644 index 0000000..4a2cbe6 Binary files /dev/null and b/QuickLaunch/bin/guis/MainGui.class differ diff --git a/QuickLaunch/bin/guis/SettingGui$1.class b/QuickLaunch/bin/guis/SettingGui$1.class new file mode 100644 index 0000000..23383ee Binary files /dev/null and b/QuickLaunch/bin/guis/SettingGui$1.class differ diff --git a/QuickLaunch/bin/guis/SettingGui$2.class b/QuickLaunch/bin/guis/SettingGui$2.class new file mode 100644 index 0000000..f99bc66 Binary files /dev/null and b/QuickLaunch/bin/guis/SettingGui$2.class differ diff --git a/QuickLaunch/bin/guis/SettingGui$3.class b/QuickLaunch/bin/guis/SettingGui$3.class new file mode 100644 index 0000000..97dd6fc Binary files /dev/null and b/QuickLaunch/bin/guis/SettingGui$3.class differ diff --git a/QuickLaunch/bin/guis/SettingGui.class b/QuickLaunch/bin/guis/SettingGui.class new file mode 100644 index 0000000..905675d Binary files /dev/null and b/QuickLaunch/bin/guis/SettingGui.class differ diff --git a/QuickLaunch/bin/icon.ico b/QuickLaunch/bin/icon.ico new file mode 100644 index 0000000..769c031 Binary files /dev/null and b/QuickLaunch/bin/icon.ico differ diff --git a/QuickLaunch/bin/icon.png b/QuickLaunch/bin/icon.png new file mode 100644 index 0000000..c169fda Binary files /dev/null and b/QuickLaunch/bin/icon.png differ diff --git a/QuickLaunch/bin/lock.png b/QuickLaunch/bin/lock.png new file mode 100644 index 0000000..1d4b26f Binary files /dev/null and b/QuickLaunch/bin/lock.png differ diff --git a/QuickLaunch/bin/main/KeyChecker$1.class b/QuickLaunch/bin/main/KeyChecker$1.class new file mode 100644 index 0000000..64788f1 Binary files /dev/null and b/QuickLaunch/bin/main/KeyChecker$1.class differ diff --git a/QuickLaunch/bin/main/KeyChecker$2.class b/QuickLaunch/bin/main/KeyChecker$2.class new file mode 100644 index 0000000..d6171ad Binary files /dev/null and b/QuickLaunch/bin/main/KeyChecker$2.class differ diff --git a/QuickLaunch/bin/main/KeyChecker.class b/QuickLaunch/bin/main/KeyChecker.class new file mode 100644 index 0000000..1803ac8 Binary files /dev/null and b/QuickLaunch/bin/main/KeyChecker.class differ diff --git a/QuickLaunch/bin/main/ModLoader.class b/QuickLaunch/bin/main/ModLoader.class new file mode 100644 index 0000000..591b6c3 Binary files /dev/null and b/QuickLaunch/bin/main/ModLoader.class differ diff --git a/QuickLaunch/bin/main/ShortcutKeyChecker.class b/QuickLaunch/bin/main/ShortcutKeyChecker.class new file mode 100644 index 0000000..a26a59c Binary files /dev/null and b/QuickLaunch/bin/main/ShortcutKeyChecker.class differ diff --git a/QuickLaunch/bin/main/Start.class b/QuickLaunch/bin/main/Start.class new file mode 100644 index 0000000..5142a84 Binary files /dev/null and b/QuickLaunch/bin/main/Start.class differ diff --git a/QuickLaunch/bin/manager/OperatingSystem.class b/QuickLaunch/bin/manager/OperatingSystem.class new file mode 100644 index 0000000..d6aef46 Binary files /dev/null and b/QuickLaunch/bin/manager/OperatingSystem.class differ diff --git a/QuickLaunch/bin/manager/ResourceManager.class b/QuickLaunch/bin/manager/ResourceManager.class new file mode 100644 index 0000000..09f2bf3 Binary files /dev/null and b/QuickLaunch/bin/manager/ResourceManager.class differ diff --git a/QuickLaunch/bin/manager/SettingManager.class b/QuickLaunch/bin/manager/SettingManager.class new file mode 100644 index 0000000..f5caf7b Binary files /dev/null and b/QuickLaunch/bin/manager/SettingManager.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/HelpWindow.class b/QuickLaunch/bin/mod_quicklaunch/HelpWindow.class new file mode 100644 index 0000000..47dbee3 Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/HelpWindow.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/QuickLaunch.class b/QuickLaunch/bin/mod_quicklaunch/QuickLaunch.class new file mode 100644 index 0000000..caf39d4 Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/QuickLaunch.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/Shortcut.class b/QuickLaunch/bin/mod_quicklaunch/Shortcut.class new file mode 100644 index 0000000..0db1701 Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/Shortcut.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/ShortcutEntryPane.class b/QuickLaunch/bin/mod_quicklaunch/ShortcutEntryPane.class new file mode 100644 index 0000000..dc48c84 Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/ShortcutEntryPane.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$1$1.class b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$1$1.class new file mode 100644 index 0000000..8284eb2 Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$1$1.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$1.class b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$1.class new file mode 100644 index 0000000..0e431ff Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$1.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$2.class b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$2.class new file mode 100644 index 0000000..8447731 Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$2.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$3.class b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$3.class new file mode 100644 index 0000000..89f99fc Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$3.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$4.class b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$4.class new file mode 100644 index 0000000..9dc083c Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$4.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$5.class b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$5.class new file mode 100644 index 0000000..e65109c Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow$5.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow.class b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow.class new file mode 100644 index 0000000..b59cecc Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/ShortcutWindow.class differ diff --git a/QuickLaunch/bin/mod_quicklaunch/TokenConverter.class b/QuickLaunch/bin/mod_quicklaunch/TokenConverter.class new file mode 100644 index 0000000..b89a274 Binary files /dev/null and b/QuickLaunch/bin/mod_quicklaunch/TokenConverter.class differ diff --git a/QuickLaunch/bin/plus.png b/QuickLaunch/bin/plus.png new file mode 100644 index 0000000..83f2d7d Binary files /dev/null and b/QuickLaunch/bin/plus.png differ diff --git a/QuickLaunch/bin/save.png b/QuickLaunch/bin/save.png new file mode 100644 index 0000000..c597240 Binary files /dev/null and b/QuickLaunch/bin/save.png differ diff --git a/QuickLaunch/bin/scenes/MainScene.class b/QuickLaunch/bin/scenes/MainScene.class new file mode 100644 index 0000000..19d6885 Binary files /dev/null and b/QuickLaunch/bin/scenes/MainScene.class differ diff --git a/QuickLaunch/bin/scenes/SettingScene.class b/QuickLaunch/bin/scenes/SettingScene.class new file mode 100644 index 0000000..3431a60 Binary files /dev/null and b/QuickLaunch/bin/scenes/SettingScene.class differ diff --git a/QuickLaunch/bin/trash.png b/QuickLaunch/bin/trash.png new file mode 100644 index 0000000..4ce0eff Binary files /dev/null and b/QuickLaunch/bin/trash.png differ diff --git a/QuickLaunch/bin/unsaved.png b/QuickLaunch/bin/unsaved.png new file mode 100644 index 0000000..84cc223 Binary files /dev/null and b/QuickLaunch/bin/unsaved.png differ diff --git a/QuickLaunch/bin/update/UpdateChecker.class b/QuickLaunch/bin/update/UpdateChecker.class new file mode 100644 index 0000000..a273fd3 Binary files /dev/null and b/QuickLaunch/bin/update/UpdateChecker.class differ diff --git a/QuickLaunch/bin/update/UpdateThread.class b/QuickLaunch/bin/update/UpdateThread.class new file mode 100644 index 0000000..31a7280 Binary files /dev/null and b/QuickLaunch/bin/update/UpdateThread.class differ diff --git a/QuickLaunch/bin/update/Updater.class b/QuickLaunch/bin/update/Updater.class new file mode 100644 index 0000000..b6af2e8 Binary files /dev/null and b/QuickLaunch/bin/update/Updater.class differ diff --git a/QuickLaunch/mods.txt b/QuickLaunch/mods.txt new file mode 100644 index 0000000..e69de29 diff --git a/QuickLaunch/res/HelveticaNeue-UltraLight.otf b/QuickLaunch/res/HelveticaNeue-UltraLight.otf new file mode 100644 index 0000000..e0aad31 Binary files /dev/null and b/QuickLaunch/res/HelveticaNeue-UltraLight.otf differ diff --git a/QuickLaunch/res/LiberationSerif-Regular.ttf b/QuickLaunch/res/LiberationSerif-Regular.ttf new file mode 100644 index 0000000..e7616da Binary files /dev/null and b/QuickLaunch/res/LiberationSerif-Regular.ttf differ diff --git a/QuickLaunch/res/back.png b/QuickLaunch/res/back.png new file mode 100644 index 0000000..650e6ce Binary files /dev/null and b/QuickLaunch/res/back.png differ diff --git a/QuickLaunch/res/edit.png b/QuickLaunch/res/edit.png new file mode 100644 index 0000000..16d5fea Binary files /dev/null and b/QuickLaunch/res/edit.png differ diff --git a/QuickLaunch/res/icon.ico b/QuickLaunch/res/icon.ico new file mode 100644 index 0000000..769c031 Binary files /dev/null and b/QuickLaunch/res/icon.ico differ diff --git a/QuickLaunch/res/icon.png b/QuickLaunch/res/icon.png new file mode 100644 index 0000000..c169fda Binary files /dev/null and b/QuickLaunch/res/icon.png differ diff --git a/QuickLaunch/res/jnativehook-2.0.3.jar b/QuickLaunch/res/jnativehook-2.0.3.jar new file mode 100644 index 0000000..d2f0d4f Binary files /dev/null and b/QuickLaunch/res/jnativehook-2.0.3.jar differ diff --git a/QuickLaunch/res/lock.png b/QuickLaunch/res/lock.png new file mode 100644 index 0000000..1d4b26f Binary files /dev/null and b/QuickLaunch/res/lock.png differ diff --git a/QuickLaunch/res/plus.png b/QuickLaunch/res/plus.png new file mode 100644 index 0000000..83f2d7d Binary files /dev/null and b/QuickLaunch/res/plus.png differ diff --git a/QuickLaunch/res/save.png b/QuickLaunch/res/save.png new file mode 100644 index 0000000..c597240 Binary files /dev/null and b/QuickLaunch/res/save.png differ diff --git a/QuickLaunch/res/trash.png b/QuickLaunch/res/trash.png new file mode 100644 index 0000000..4ce0eff Binary files /dev/null and b/QuickLaunch/res/trash.png differ diff --git a/QuickLaunch/res/unsaved.png b/QuickLaunch/res/unsaved.png new file mode 100644 index 0000000..84cc223 Binary files /dev/null and b/QuickLaunch/res/unsaved.png differ diff --git a/QuickLaunch/settings.properties b/QuickLaunch/settings.properties new file mode 100644 index 0000000..d0401d2 --- /dev/null +++ b/QuickLaunch/settings.properties @@ -0,0 +1,5 @@ +#Sat Oct 06 17:21:25 CEST 2018 +Load-File-on-startup=true +key2=44 +key1=29 +Check-for-updates-on-startup=true diff --git a/QuickLaunch/src/basics/BasicGuiApp.java b/QuickLaunch/src/basics/BasicGuiApp.java new file mode 100644 index 0000000..69919ab --- /dev/null +++ b/QuickLaunch/src/basics/BasicGuiApp.java @@ -0,0 +1,86 @@ +package basics; + +import java.util.logging.Level; +import java.util.logging.LogManager; +import java.util.logging.Logger; + +import org.jnativehook.GlobalScreen; +import org.jnativehook.NativeHookException; + +import javafx.application.Application; +import javafx.event.EventHandler; +import javafx.scene.Scene; +import javafx.scene.image.Image; +import javafx.stage.Stage; +import javafx.stage.StageStyle; +import javafx.stage.WindowEvent; +import main.KeyChecker; +import main.ModLoader; +import main.Start; +import manager.SettingManager; +import scenes.MainScene; +import update.Updater; + +public class BasicGuiApp extends Application{ + + + + + public static Stage mainStage; + public static Scene mainScene; + public static KeyChecker listener; + public static Updater up = new Updater(); + + public BasicGuiApp(){ + + ModLoader ml = new ModLoader(); + ml.init(); + ml.addMods(); + ml.initMods(); + + try { + GlobalScreen.registerNativeHook(); + } catch (NativeHookException e) { + + e.printStackTrace(); + } + listener = new KeyChecker(); + LogManager.getLogManager().reset(); + + Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName()); + logger.setLevel(Level.OFF); + GlobalScreen.addNativeKeyListener(listener); + } + + + public void start(Stage primaryStage) throws Exception { + + mainStage = primaryStage; + mainStage.setTitle("QuickLaunch "+Start.VERSION); + mainStage.getIcons().add(new Image(BasicGuiApp.class.getResourceAsStream("/icon.png"))); + mainStage.setOnCloseRequest(new EventHandler() { + + public void handle(WindowEvent event) { + SettingManager.saveSettings(); + System.exit(0); + + } + }); + + primaryStage.initStyle(StageStyle.TRANSPARENT); + mainScene = new MainScene(); + + + + primaryStage.setScene(mainScene); + primaryStage.centerOnScreen(); + primaryStage.requestFocus(); + primaryStage.show(); + + if(SettingManager.isCheckUptdateOnBoot()){ + up.checkForUpdate(); + + } + } + +} diff --git a/QuickLaunch/src/basics/BasicMod.java b/QuickLaunch/src/basics/BasicMod.java new file mode 100644 index 0000000..f1f2fca --- /dev/null +++ b/QuickLaunch/src/basics/BasicMod.java @@ -0,0 +1,35 @@ + +package basics; + +import java.io.IOException; + +public class BasicMod { + private String modname = "mod:mod"; + private double version = 0.0; + + public void setModName(String name) { + this.modname = name; + } + + public void setVersion(double version) { + this.version = version; + } + + public String getModname() { + return this.modname; + } + + public double getVersion() { + return this.version; + } + + public void init() { + } + + public void checkInput(String input) throws IOException { + } +} + + + + diff --git a/QuickLaunch/src/guis/FileChooseWindow.java b/QuickLaunch/src/guis/FileChooseWindow.java new file mode 100644 index 0000000..a1f1178 --- /dev/null +++ b/QuickLaunch/src/guis/FileChooseWindow.java @@ -0,0 +1,32 @@ +package guis; + + +import javax.swing.JFileChooser; +import javax.swing.JFrame; + +public class FileChooseWindow { + + + + public static String chooseFile(JFrame parentFrame){ + + + + JFileChooser jfc = new JFileChooser(); + + int result = jfc.showOpenDialog(parentFrame); + if(result == JFileChooser.APPROVE_OPTION){ + String filePath = jfc.getSelectedFile().getAbsoluteFile().toString(); + return filePath; + } + else { + String filePath = "XXX"; + return filePath; + } + + + } + + + +} diff --git a/QuickLaunch/src/guis/MainGui.java b/QuickLaunch/src/guis/MainGui.java new file mode 100644 index 0000000..5d13ef0 --- /dev/null +++ b/QuickLaunch/src/guis/MainGui.java @@ -0,0 +1,116 @@ +package guis; + +import java.io.IOException; + +import basics.BasicGuiApp; +import basics.BasicMod; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.control.Button; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyEvent; +import javafx.scene.layout.AnchorPane; +import javafx.scene.text.Font; +import javafx.scene.text.Text; +import main.ModLoader; +import manager.ResourceManager; + +public class MainGui extends AnchorPane{ + + + private static Text notificationText; + public static TextField inputField; + + public MainGui(){ + + this.setPrefWidth(400); + this.setPrefHeight(60); + this.setStyle("-fx-background-color: rgba(0, 0, 0, 0.8);"); + + + inputField = new TextField(); + inputField.setLayoutX(0); + inputField.setLayoutY(0); + inputField.setPrefWidth(370); + inputField.setPrefHeight(60); + inputField.requestFocus(); + inputField.setStyle("-fx-background-color: rgba(0, 0, 0, 0);" + + "-fx-text-inner-color: white;" + + "-fx-padding: 0px;" + + "-fx-border-insets: 0px;" + + "-fx-font-weight: bold" + + "-fx-background-insetts: 0px"); + inputField.setFont(ResourceManager.getFontBig()); + inputField.setOnKeyPressed(new EventHandler(){ + + public void handle(KeyEvent event) { + String input; + if(event.getCode().name().equals("ENTER")){ + BasicGuiApp.mainStage.setAlwaysOnTop(false); + input = inputField.getText(); + inputField.setText(""); + if(input.equals("exit")){ + System.exit(-1); + } + + for (BasicMod bm : ModLoader.mods) { + try { + bm.checkInput(input); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + } + }); + + + Button minimize = new Button("-"); + minimize.setPrefWidth(30); + minimize.setPrefHeight(30); + minimize.setLayoutX(370); + minimize.setLayoutY(-10); + minimize.setStyle("-fx-background-color: rgba(0, 0, 0, 0);" + + "-fx-text-inner-color: white;" + + "-fx-text-fill: white;"); + minimize.setFont(new Font("Arial", 25)); + minimize.setOnAction(new EventHandler() { + + + public void handle(ActionEvent event) { + BasicGuiApp.mainStage.setIconified(true); + + } + }); + + notificationText = new Text(); + notificationText.setLayoutX(0); + notificationText.setLayoutY(65); + notificationText.prefWidth(400); + notificationText.prefHeight(22); + notificationText.setStyle("-fx-background-color: rgba(0, 0, 0, 0);" + + "-fx-fill: rgb(221,255,0);"); + notificationText.setFont(ResourceManager.getFontSmall()); + + this.getChildren().add(inputField); + this.getChildren().add(minimize); + this.getChildren().add(notificationText); + } + + + public static void addNotification(String msg,final int sec){ + notificationText.setText(msg); + Thread t = new Thread(new Runnable() { + public void run() { + try { + Thread.sleep(sec*1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + notificationText.setText(""); + } + }); + t.start(); + } +} diff --git a/QuickLaunch/src/guis/SettingGui.java b/QuickLaunch/src/guis/SettingGui.java new file mode 100644 index 0000000..c1da718 --- /dev/null +++ b/QuickLaunch/src/guis/SettingGui.java @@ -0,0 +1,159 @@ +package guis; + + +import org.jnativehook.GlobalScreen; + +import basics.BasicGuiApp; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.layout.AnchorPane; +import javafx.scene.text.Text; +import main.ShortcutKeyChecker; +import manager.ResourceManager; +import manager.SettingManager; + +public class SettingGui extends AnchorPane{ + + + AnchorPane settingPane; + + public SettingGui(){ + this.setPrefWidth(300); + this.setPrefHeight(185); + this.setStyle("-fx-background-color: rgba(240, 240, 240, 1);"); + + ///////////////////////////////////////////////////////////////////////////// + Text setting1 = new Text("Load File.txt on startup:"); + setting1.setFont(ResourceManager.getFontSmall()); + setting1.setLayoutX(10); + setting1.setLayoutY(20); + setting1.prefWidth(170); + setting1.prefHeight(30); + + final CheckBox setting1Box = new CheckBox(); + setting1Box.setLayoutX(180); + setting1Box.setLayoutY(7); + setting1Box.prefWidth(20); + setting1Box.prefHeight(20); + setting1Box.setSelected(SettingManager.isLoadFileOnBoot()); + /////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////// + + Text setting3 = new Text("Check for updates on startup:"); + setting3.setFont(ResourceManager.getFontSmall()); + setting3.setLayoutX(10); + setting3.setLayoutY(100); + setting3.prefWidth(220); + setting3.prefHeight(30); + + final CheckBox setting3Box = new CheckBox(); + setting3Box.setLayoutX(230); + setting3Box.setLayoutY(87); + setting3Box.prefWidth(30); + setting3Box.prefHeight(30); + setting3Box.setSelected(SettingManager.isCheckUptdateOnBoot()); + ///////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////// + Text setting4 = new Text("QuickLaunch shortcut:"); + setting4.setFont(ResourceManager.getFontSmall()); + setting4.setLayoutX(10); + setting4.setLayoutY(128); + setting4.prefWidth(180); + setting4.prefHeight(30); + + final Button setting4button1 = new Button("key1"); + if(!(SettingManager.getKey1() == -1)){ + setting4button1.setText(SettingManager.getKey1()+""); + } + setting4button1.setFont(ResourceManager.getFontSmall()); + setting4button1.setLayoutX(10); + setting4button1.setLayoutY(145); + setting4button1.prefWidth(40); + setting4button1.prefHeight(24); + setting4button1.setOnAction(new EventHandler() { + + + public void handle(ActionEvent event) { + ShortcutKeyChecker skc = new ShortcutKeyChecker(); + GlobalScreen.removeNativeKeyListener(BasicGuiApp.listener); + GlobalScreen.addNativeKeyListener(skc); + while(skc.lastKey == -1){ + + try { + Thread.sleep(100); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + setting4button1.setText(skc.lastKey+""); + SettingManager.setKey1(skc.lastKey); + GlobalScreen.removeNativeKeyListener(skc); + GlobalScreen.addNativeKeyListener(BasicGuiApp.listener); + + } + }); + + final Button setting4button2 = new Button("key2"); + if(!(SettingManager.getKey2() == -1)){ + setting4button2.setText(SettingManager.getKey2()+""); + } + setting4button2.setFont(ResourceManager.getFontSmall()); + setting4button2.setLayoutX(95); + setting4button2.setLayoutY(145); + setting4button2.prefWidth(40); + setting4button2.prefHeight(24); + setting4button2.setOnAction(new EventHandler() { + + + public void handle(ActionEvent event) { + ShortcutKeyChecker skc = new ShortcutKeyChecker(); + GlobalScreen.removeNativeKeyListener(BasicGuiApp.listener); + GlobalScreen.addNativeKeyListener(skc); + while(skc.lastKey == -1){ + try { + Thread.sleep(100); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + setting4button2.setText(skc.lastKey+""); + SettingManager.setKey2(skc.lastKey); + GlobalScreen.removeNativeKeyListener(skc); + GlobalScreen.addNativeKeyListener(BasicGuiApp.listener); + } + }); + ///////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + + Button exit = new Button("Done"); + exit.setFont(ResourceManager.getFontSmall()); + exit.setLayoutX(230); + exit.setLayoutY(145); + exit.prefWidth(50); + exit.prefHeight(24); + exit.setOnAction(new EventHandler() { + + + public void handle(ActionEvent event) { + SettingManager.setLoadFileOnBoot(setting1Box.isSelected()); + SettingManager.setCheckUptdateOnBoot(setting3Box.isSelected()); + SettingManager.saveSettings(); + BasicGuiApp.mainStage.setScene(BasicGuiApp.mainScene); + + } + }); + + + this.getChildren().add(setting1); + this.getChildren().add(setting1Box); + this.getChildren().add(setting3); + this.getChildren().add(setting3Box); + this.getChildren().add(setting4); + this.getChildren().add(setting4button1); + this.getChildren().add(setting4button2); + this.getChildren().add(exit); + } + +} diff --git a/QuickLaunch/src/main/KeyChecker.java b/QuickLaunch/src/main/KeyChecker.java new file mode 100644 index 0000000..8db3cc4 --- /dev/null +++ b/QuickLaunch/src/main/KeyChecker.java @@ -0,0 +1,93 @@ +package main; + + +import org.jnativehook.keyboard.NativeKeyEvent; +import org.jnativehook.keyboard.NativeKeyListener; + +import basics.BasicGuiApp; +import guis.MainGui; +import javafx.application.Platform; +import manager.OperatingSystem; +import manager.SettingManager; + +public class KeyChecker implements NativeKeyListener{ + + + boolean key1 = false; + boolean key2 = false; + + public void nativeKeyPressed(NativeKeyEvent nke) { + if(nke.getKeyCode() == SettingManager.getKey1()){ + key1 = true; + + } + + if(nke.getKeyCode() == SettingManager.getKey2()){ + key2 = true; + } + + if(key1 && key2){ + //Workaround because toFront() does not work and makes window active + Platform.runLater(new Runnable() { + + public void run() { + + if(SettingManager.getOperatingSystem() == OperatingSystem.LINUX) { + BasicGuiApp.mainStage.setIconified(true); + BasicGuiApp.mainStage.setIconified(false); + BasicGuiApp.mainStage.toFront(); + BasicGuiApp.mainStage.requestFocus(); + MainGui.inputField.requestFocus(); + } + else if(SettingManager.getOperatingSystem() == OperatingSystem.WINDOWS) { + BasicGuiApp.mainStage.setAlwaysOnTop(true); + BasicGuiApp.mainStage.setAlwaysOnTop(false); + BasicGuiApp.mainStage.requestFocus(); + MainGui.inputField.requestFocus(); + BasicGuiApp.mainStage.setIconified(true); + BasicGuiApp.mainStage.setIconified(false); + } + else if(SettingManager.getOperatingSystem() == OperatingSystem.OSX) { + BasicGuiApp.mainStage.setIconified(true); + BasicGuiApp.mainStage.setIconified(false); + BasicGuiApp.mainStage.toFront(); + BasicGuiApp.mainStage.requestFocus(); + MainGui.inputField.requestFocus(); + + + } + } + }); + + } + + //1 = ESC => minimize + if(nke.getKeyCode() == 1) { + Platform.runLater(new Runnable() { + + public void run() { + + BasicGuiApp.mainStage.setIconified(true); + + + } + }); + } + } + + + public void nativeKeyReleased(NativeKeyEvent nke) { + if(nke.getKeyCode() == SettingManager.getKey1()){ + key1 = false; + } + + if(nke.getKeyCode() == SettingManager.getKey2()){ + key2 = false; + } + } + + + public void nativeKeyTyped(NativeKeyEvent arg0) { + } + +} diff --git a/QuickLaunch/src/main/ModLoader.java b/QuickLaunch/src/main/ModLoader.java new file mode 100644 index 0000000..21c36f3 --- /dev/null +++ b/QuickLaunch/src/main/ModLoader.java @@ -0,0 +1,91 @@ +package main; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; + +import basics.BasicMod; +import manager.SettingManager; +import mod_quicklaunch.QuickLaunch; + +public class ModLoader { + public static ArrayList mods = new ArrayList(); + private BufferedReader bfr; + + public void init() { + System.out.println("ModLoader: Start init"); + File modfile = new File(SettingManager.getJarDirectory()+File.separator+"mods.txt"); + try { + if (!modfile.exists()) { + System.out.println("ModLoader: No mod file exists"); + System.out.println("ModLoader: Starting for the first time?"); + modfile.createNewFile(); + System.out.println("ModLoader: Mod file: mods.txt created"); + System.out.println("ModLoader: Ready to install mods"); + } + this.bfr = new BufferedReader(new FileReader(modfile)); + } + catch (FileNotFoundException e) { + e.printStackTrace(); + } + catch (IOException e) { + e.printStackTrace(); + } + System.out.println("ModLoader: Exit init"); + } + + public void addMods() { + mods.add(new QuickLaunch()); + String nextMod = null; + try { + nextMod = this.bfr.readLine(); + } + catch (IOException e1) { + e1.printStackTrace(); + } + while (nextMod != null) { + try { + mods.add((BasicMod)Class.forName(nextMod).getConstructors()[0].newInstance(new Object[0])); + nextMod = this.bfr.readLine(); + continue; + } + catch (InstantiationException e) { + e.printStackTrace(); + continue; + } + catch (IllegalAccessException e) { + e.printStackTrace(); + continue; + } + catch (IllegalArgumentException e) { + e.printStackTrace(); + continue; + } + catch (InvocationTargetException e) { + e.printStackTrace(); + continue; + } + catch (SecurityException e) { + e.printStackTrace(); + continue; + } + catch (ClassNotFoundException e) { + System.out.println("'" + nextMod + "'" + " is not installed"); + break; + } + catch (IOException e) { + e.printStackTrace(); + } + } + } + + public void initMods() { + for (BasicMod mod : mods) { + mod.init(); + } + } +} diff --git a/QuickLaunch/src/main/ShortcutKeyChecker.java b/QuickLaunch/src/main/ShortcutKeyChecker.java new file mode 100644 index 0000000..759e6ab --- /dev/null +++ b/QuickLaunch/src/main/ShortcutKeyChecker.java @@ -0,0 +1,32 @@ +package main; + +import org.jnativehook.keyboard.NativeKeyEvent; +import org.jnativehook.keyboard.NativeKeyListener; + +public class ShortcutKeyChecker implements NativeKeyListener{ + + + public int lastKey = -1; + + public ShortcutKeyChecker(){ + lastKey = -1; + } + + public void nativeKeyPressed(NativeKeyEvent nke) { + System.out.println(nke.getKeyCode()); + lastKey = nke.getKeyCode(); + + } + + public void nativeKeyReleased(NativeKeyEvent nke) { + + lastKey = nke.getKeyCode(); + + } + + public void nativeKeyTyped(NativeKeyEvent arg0) { + System.out.println("c"); + + } + +} diff --git a/QuickLaunch/src/main/Start.java b/QuickLaunch/src/main/Start.java new file mode 100644 index 0000000..8421340 --- /dev/null +++ b/QuickLaunch/src/main/Start.java @@ -0,0 +1,27 @@ +package main; + + +import org.jnativehook.NativeHookException; + +import basics.BasicGuiApp; +import javafx.application.Application; +import manager.SettingManager; +import manager.ResourceManager; + +public class Start { + public static final float VERSION = 2.7f; + //public static final float VERSION = 2.3f; + + + @SuppressWarnings("static-access") + public static void main(String[] args) throws NativeHookException { + ResourceManager.loadResources(); + + SettingManager sm = new SettingManager(); + sm.loadSettings(); + sm.saveSettings(); + + Application.launch(BasicGuiApp.class); + + } +} diff --git a/QuickLaunch/src/manager/OperatingSystem.java b/QuickLaunch/src/manager/OperatingSystem.java new file mode 100644 index 0000000..cf59fbf --- /dev/null +++ b/QuickLaunch/src/manager/OperatingSystem.java @@ -0,0 +1,3 @@ +package manager; + +public enum OperatingSystem {WINDOWS,OSX,LINUX} diff --git a/QuickLaunch/src/manager/ResourceManager.java b/QuickLaunch/src/manager/ResourceManager.java new file mode 100644 index 0000000..aa49d1b --- /dev/null +++ b/QuickLaunch/src/manager/ResourceManager.java @@ -0,0 +1,90 @@ +package manager; + + +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.text.Font; + +public class ResourceManager { + + private static Font fontBig = null; + private static Font fontSmall = null; + + private static ImageView addImage = null; + private static ImageView backImage = null; + private static ImageView editImage = null; + private static ImageView lockImage = null; + private static ImageView saveImage = null; + private static ImageView unsavedImage = null; + private static ImageView trashImage = null; + + + public static void loadResources() { + fontBig = Font.loadFont(ResourceManager.class.getResourceAsStream("/LiberationSerif-Regular.ttf"), 40); + fontSmall = Font.loadFont(ResourceManager.class.getResourceAsStream("/LiberationSerif-Regular.ttf"), 17); + + addImage = new ImageView(new Image(ResourceManager.class.getResourceAsStream("/plus.png"), 32, 32, true, false)); + addImage.setFitWidth(32); + addImage.setFitHeight(32); + addImage.setPreserveRatio(true); + + backImage = new ImageView(new Image(ResourceManager.class.getResourceAsStream("/back.png"), 32, 32 ,true, false)); + editImage = new ImageView(new Image(ResourceManager.class.getResourceAsStream("/edit.png"),32 ,32, true, false)); + lockImage = new ImageView(new Image(ResourceManager.class.getResourceAsStream("/lock.png"), 32, 32, true, false)); + saveImage = new ImageView(new Image(ResourceManager.class.getResourceAsStream("/save.png"), 32, 32 ,true, false)); + unsavedImage = new ImageView(new Image(ResourceManager.class.getResourceAsStream("/unsaved.png"), 32, 32, true, false)); + + trashImage = new ImageView(new Image(ResourceManager.class.getResourceAsStream("/trash.png"), 32, 32 ,true, false)); + } + + public static Font getFontBig() { + return fontBig; + } + + + public static Font getFontSmall() { + return fontSmall; + } + + + public static ImageView getAddImage() { + return addImage; + } + + public static ImageView getBackImage() { + return backImage; + } + + + public static ImageView getEditImage() { + return editImage; + } + + + public static ImageView getLockImage() { + return lockImage; + } + + + + public static ImageView getSaveImage() { + return saveImage; + } + + public static ImageView getSaveImageUnsaved() { + return unsavedImage; + } + + + + public static ImageView getTrashImage() { + return trashImage; + } + + + + + + + +} \ No newline at end of file diff --git a/QuickLaunch/src/manager/SettingManager.java b/QuickLaunch/src/manager/SettingManager.java new file mode 100644 index 0000000..613afc5 --- /dev/null +++ b/QuickLaunch/src/manager/SettingManager.java @@ -0,0 +1,185 @@ +package manager; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Properties; + +import main.Start; + +public class SettingManager { + + + + private static boolean loadFileOnBoot = true; + private static boolean checkUptdateOnBoot = true; + private static int key1 = -1,key2 = -1; + private static OperatingSystem currentOS = null; + + + private static String jarDirectory = ""; + + + + + + public SettingManager(){ + if(System.getProperty("os.name").toLowerCase().contains("nux")){ + currentOS = OperatingSystem.LINUX; + } + else if(System.getProperty("os.name").toLowerCase().contains("win")) { + currentOS = OperatingSystem.WINDOWS; + } + else if(System.getProperty("os.name").toLowerCase().contains("mac")) { + currentOS = OperatingSystem.OSX; + } + + + String path = Start.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + jarDirectory = new File(path).getParentFile().getPath(); + } + + public static void loadSettings(){ + try{ + File settingFile = new File(jarDirectory+File.separator+"settings.properties"); + File legacyFile = new File(jarDirectory+File.separator+"settings.txt"); + if(settingFile.exists()){ + if(legacyFile.exists()){ + legacyFile.delete(); + } + InputStream input = null; + Properties prop = new Properties(); + try{ + input = new FileInputStream(settingFile); + prop.load(input); + loadFileOnBoot = Boolean.parseBoolean(prop.getProperty("Load-File-on-startup")); + checkUptdateOnBoot = Boolean.parseBoolean(prop.getProperty("Check-for-updates-on-startup")); + key1 = Integer.parseInt(prop.getProperty("key1")); + key2 = Integer.parseInt(prop.getProperty("key2")); + }catch (IOException e) { + e.printStackTrace(); + }finally{ + input.close(); + } + } + else{ + if(legacyFile.exists()){ + BufferedReader bfr = new BufferedReader(new FileReader(legacyFile)); + ///////////////////////////////////// + String currentLine = bfr.readLine(); + while(currentLine != null){ + if(currentLine.contains("Load File")){ + if(currentLine.contains("true")){ + loadFileOnBoot = true; + } + else if(currentLine.contains("false")){ + loadFileOnBoot = false; + } + } + else if(currentLine.contains("Check for newer")){ + if(currentLine.contains("true")){ + checkUptdateOnBoot = true; + } + else if(currentLine.contains("false")){ + checkUptdateOnBoot = false; + } + } + else if(currentLine.contains(";")){ + key1 = Integer.parseInt(currentLine.substring(0, 2)); + key2 = Integer.parseInt(currentLine.substring(3, 5)); + } + currentLine = bfr.readLine(); + } + bfr.close(); + } + else{ + System.out.println("No setting file found probably first start"); + saveSettings(); + System.out.println("Setting file created"); + } + } + + }catch(NullPointerException npe){ + saveSettings(); + System.out.println("npe There is an error in your setting file\nYour settings File was updated"); + }catch(NumberFormatException nfe){ + saveSettings(); + System.out.println("There is an error in your setting file\nYour settings File was updated"); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + public static void saveSettings(){ + OutputStream out = null; + try { + File settingFile = new File(jarDirectory+File.separator+"settings.properties"); + Properties prop = new Properties(); + out = new FileOutputStream(settingFile); + prop.setProperty("Load-File-on-startup", ""+loadFileOnBoot); + prop.setProperty("Check-for-updates-on-startup", ""+checkUptdateOnBoot); + prop.setProperty("key1", ""+key1); + prop.setProperty("key2", ""+key2); + + prop.store(out, null); + } catch (IOException e) { + System.out.println("Writing permission denied"); + } finally{ + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public static OperatingSystem getOperatingSystem() { + return currentOS; + } + + public static boolean isLoadFileOnBoot() { + return loadFileOnBoot; + } + + public static void setLoadFileOnBoot(boolean loadFileOnBoot) { + SettingManager.loadFileOnBoot = loadFileOnBoot; + } + + public static boolean isCheckUptdateOnBoot() { + return checkUptdateOnBoot; + } + + public static void setCheckUptdateOnBoot(boolean checkUptdateOnBoot) { + SettingManager.checkUptdateOnBoot = checkUptdateOnBoot; + } + + public static int getKey1() { + return key1; + } + + public static void setKey1(int key1) { + SettingManager.key1 = key1; + } + + public static int getKey2() { + return key2; + } + + public static void setKey2(int key2) { + SettingManager.key2 = key2; + } + + public static String getJarDirectory() { + return jarDirectory; + } + + public static void setJarDirectory(String jarDirectory) { + SettingManager.jarDirectory = jarDirectory; + } +} diff --git a/QuickLaunch/src/mod_audio/AudioPlayer.java b/QuickLaunch/src/mod_audio/AudioPlayer.java new file mode 100644 index 0000000..acc353a --- /dev/null +++ b/QuickLaunch/src/mod_audio/AudioPlayer.java @@ -0,0 +1,34 @@ + +package mod_audio; + +import javax.sound.sampled.Clip; + +public class AudioPlayer +implements Runnable { + boolean loop = false; + Clip sound; + + public AudioPlayer(Clip clip) { + this.sound = clip; + } + + @Override + public void run() { + this.sound.start(); + if (this.loop) { + this.sound.loop(-1); + } + } + + public boolean isLoop() { + return this.loop; + } + + public void setLoop(boolean loop) { + this.loop = loop; + } +} + + + + diff --git a/QuickLaunch/src/mod_audio/Gui.java b/QuickLaunch/src/mod_audio/Gui.java new file mode 100644 index 0000000..42f2a8e --- /dev/null +++ b/QuickLaunch/src/mod_audio/Gui.java @@ -0,0 +1,25 @@ + +package mod_audio; + + + + +import basics.BasicMod; +import guis.FileChooseWindow; + +public class Gui extends BasicMod { + + FileChooseWindow fcw; + public void init() { + + + } + @Override + public void checkInput(String input) { + + } +} + + + + diff --git a/QuickLaunch/src/mod_audio/Music.java b/QuickLaunch/src/mod_audio/Music.java new file mode 100644 index 0000000..24e8a7d --- /dev/null +++ b/QuickLaunch/src/mod_audio/Music.java @@ -0,0 +1,46 @@ + +package mod_audio; + +import java.io.File; + +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; + +import mod_audio.AudioPlayer; + +public class Music { + private File audiofile; + private Clip clip; + Thread sound; + private AudioPlayer ap; + + public Music(String filename) { + this.audiofile = new File(filename); + try { + this.clip = AudioSystem.getClip(); + this.clip.open(AudioSystem.getAudioInputStream(this.audiofile)); + } + catch (Exception e) { + e.printStackTrace(); + } + this.ap = new AudioPlayer(this.clip); + this.sound = new Thread(this.ap); + } + + public void play() { + this.sound.start(); + } + + public void loop() { + this.ap.setLoop(true); + this.sound.start(); + } + + public void stop() { + this.clip.close(); + } +} + + + + diff --git a/QuickLaunch/src/mod_calc/Calcmod.java b/QuickLaunch/src/mod_calc/Calcmod.java new file mode 100644 index 0000000..fd4bd90 --- /dev/null +++ b/QuickLaunch/src/mod_calc/Calcmod.java @@ -0,0 +1,145 @@ +package mod_calc; + +import java.io.IOException; +import java.util.ArrayList; + +import javax.swing.JOptionPane; + +import basics.BasicMod; + +public class Calcmod extends BasicMod{ + ArrayList values; + ArrayList operators; + char current; + String tmp; + double output; + double temp; + public void init(){ + values = new ArrayList(); + operators = new ArrayList(); + current = ' '; + tmp = ""; + System.out.println("Calculator installed"); + this.setModName("Calculator"); + this.setVersion(0.81); + + } + public void checkInput(String input) throws IOException { + if(!input.isEmpty()){ + if(input.charAt(0)=='$'){ + for(int i = 1;i < input.length();i++){ + current = input.charAt(i); + if(isAlternative(current)){ + current = changeAlternatives(current); + System.out.println("alt"); + } + if(isNumber(current)){ + tmp+= current; + System.out.println("num"); + } + else if(isOperator(current)){ + values.add(Double.parseDouble(tmp)); + tmp = ""; + operators.add(current); + System.out.println("op"); + } + } + values.add(Double.parseDouble(tmp)); + } + } + solve(); + clear(); + + } + + private boolean isNumber(char check){ + if((check == '1') || + (check == '2') || + (check == '3') || + (check == '4') || + (check == '5') || + (check == '6') || + (check == '7') || + (check == '8') || + (check == '9') || + (check == '0') || + (check == '.')){ + return true; + } + else{ + return false; + } + } + + private boolean isOperator(char check){ + if((check == '+') || + (check == '-') || + (check == '*') || + (check == '/')){ + return true; + } + else{ + return false; + } + + + } + + private boolean isAlternative(char check){ + if((check == ',') || + (check == 'x')){ + return true; + } + else{ + return false; + } + } + + private char changeAlternatives(char check){ + if(check == ','){ + return '.'; + } + else if(check == 'x'){ + return '*'; + } + else{ + return '?'; + } + + } + + private void solve(){ + if(values.size() == operators.size()+1){ + output = values.get(0); + for(int i=0;i '~')) + { + this.currentChar = ((char)(33 + this.exceptionCounter)); + this.exceptionCounter = ((byte)(this.exceptionCounter + 1)); + } + this.outputID += this.currentChar; + } + } + return this.outputID; + } + + public byte getDecodeFactor() + { + return this.decodeFactor; + } + + public void setDecodeFactor(byte decodeFactor) + { + this.decodeFactor = decodeFactor; + } +} diff --git a/QuickLaunch/src/mod_pPw/PPW.java b/QuickLaunch/src/mod_pPw/PPW.java new file mode 100644 index 0000000..f00a6ca --- /dev/null +++ b/QuickLaunch/src/mod_pPw/PPW.java @@ -0,0 +1,38 @@ +package mod_pPw; + +import java.util.Scanner; + +import basics.BasicMod; + +public class PPW + extends BasicMod +{ + Scanner scn; + Hasher hash; + + public void init() + { + setModName("PPW"); + setVersion(0.1D); + System.out.println("PPW: Start init"); + + this.scn = new Scanner(System.in); + this.hash = new Hasher(); + System.out.println("PPW: Exit init"); + } + + public void checkInput(String input) + { + String givenID = ""; + String givenLM = ""; + if (input.equalsIgnoreCase("ppw")) + { + System.out.println("Please enter your private password ID"); + givenID = this.scn.nextLine(); + System.out.println("Please enter you personal parameter (1-100) "); + givenLM = this.scn.nextLine(); + this.hash.setDecodeFactor(Byte.parseByte(givenLM)); + System.out.println("Your encrypted password is:" + this.hash.hash(givenID)); + } + } +} diff --git a/QuickLaunch/src/mod_quicklaunch/HelpWindow.java b/QuickLaunch/src/mod_quicklaunch/HelpWindow.java new file mode 100644 index 0000000..aff629f --- /dev/null +++ b/QuickLaunch/src/mod_quicklaunch/HelpWindow.java @@ -0,0 +1,53 @@ +package mod_quicklaunch; + +import javafx.scene.control.TextArea; +import javafx.scene.layout.AnchorPane; + +public class HelpWindow extends AnchorPane{ + + private TextArea shortcuts; + private TextArea description; + private final int WINDOW_WIDTH = 500; + private final int WINDOW_HEIGHT = 230; + + public HelpWindow() { + + this.setPrefSize(WINDOW_WIDTH, WINDOW_HEIGHT); + + + shortcuts = new TextArea(); + shortcuts.setText("Shortcuts:\n/c\n/cos\n/cu\n/x | exit\n\n/? | help\n/lf\n/s\n/sf\n\nany shortcut"); + shortcuts.setPrefSize(WINDOW_WIDTH/5, WINDOW_HEIGHT+10); + shortcuts.setLayoutX(-5); + shortcuts.setLayoutY(-5); + shortcuts.setEditable(false); + shortcuts.setStyle("-fx-focus-color: transparent; -fx-faint-focus-color: white"); + + description = new TextArea(); + description.setPrefSize(WINDOW_WIDTH/5*4, WINDOW_HEIGHT+10); + description.setLayoutX(WINDOW_WIDTH/5); + description.setLayoutY(-5); + description.setEditable(false); + description.setStyle("-fx-focus-color: transparent ; -fx-faint-focus-color: white"); + description.setText("Description:\n" + + "Settings UI\n" + + "(Re)center QuickLaunch on screen\n" + + "Check for updates\n" + + "Kills the whole program instantly\n" + + "(If you changed something make sure it is already saved)\n" + + "Show this help dialog\n" + + "Load the shortcuts from the hard drive\n" + + "Open shortcut manager\n" + + "Save current shortcuts to hard drive\n" + + "(Overrides existing shortcuts)\n" + + "executes the program linked to the shortcut\n" + + "(Visit /s for all your personal shortcuts)"); + + + + this.getChildren().add(description); + this.getChildren().add(shortcuts); + this.requestFocus(); + } + +} diff --git a/QuickLaunch/src/mod_quicklaunch/QuickLaunch.java b/QuickLaunch/src/mod_quicklaunch/QuickLaunch.java new file mode 100644 index 0000000..1c9341a --- /dev/null +++ b/QuickLaunch/src/mod_quicklaunch/QuickLaunch.java @@ -0,0 +1,179 @@ +package mod_quicklaunch; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; + +import basics.BasicGuiApp; +import basics.BasicMod; +import guis.MainGui; +import javafx.scene.Scene; +import javafx.stage.Stage; +import javafx.stage.StageStyle; +import main.Start; +import manager.SettingManager; +import scenes.SettingScene; + +public class QuickLaunch extends BasicMod { + + private File textfile; + private BufferedReader br; + private BufferedWriter bw; + private ArrayList shortcuts; + private String tmpSh = "."; + private String tmpPa = "."; + + public void init() { + try { + this.setModName("QL"); + + System.out.println("QL: Starting QuickLaunch"); + this.textfile = new File(SettingManager.getJarDirectory()+File.separator+"File.txt"); + System.out.println("QL: File name: File.txt"); + if (!this.textfile.exists()) { + System.out.println("QL: There ist no File"); + this.textfile.createNewFile(); + System.out.println("QL: File.txt created"); + } + shortcuts = new ArrayList(); + + System.out.println("QL: Finished Initialisation"); + if(SettingManager.isLoadFileOnBoot()){ + loadFile(); + } + } + catch (IOException e) { + e.printStackTrace(); + } + } + + public void checkInput(String input) throws IOException { + if (input.equalsIgnoreCase("/cos")){ + this.centerOnScreen(); + } else if (input.equalsIgnoreCase("/cu")) { + this.checkForUpdates(); + } else if (input.equalsIgnoreCase("exit")) { + System.exit(-1); + } else if ((input.equalsIgnoreCase("help")) || (input.equalsIgnoreCase("/?"))) { + this.writeHelp(); + } else if (input.equalsIgnoreCase("loadFile") || input.equalsIgnoreCase("/lf")) { + this.loadFile(); + } else if (input.equalsIgnoreCase("saveFile") || input.equalsIgnoreCase("/sf")) { + this.saveFile(false); + }else if (input.equalsIgnoreCase("/s")) { + this.showShortcuts(); + } else if (input.equalsIgnoreCase("getPath")|| input.equalsIgnoreCase("/gp")) { + this.getFilePath(); + } else if (input.equalsIgnoreCase("/v")) { + this.QLversion(); + } else if (input.equalsIgnoreCase("/c")) { + this.showSettings(); + } else { + int i = 0; + for (Shortcut sh : shortcuts) { + if (input.equalsIgnoreCase(sh.getShortcut())){ + i = shortcuts.indexOf(sh); + //Runtime.getRuntime().exec("cmd /c \"" + shortcuts.get(i).getPath() + "\""); + ProcessBuilder pb = new ProcessBuilder(TokenConverter.convert(shortcuts.get(i).getPath())); + pb.start(); + System.out.println("'" + shortcuts.get(i).getPath() + "' started"); + //MainGui.addNotification("'" + shortcuts.get(i).getPath() + "' started", 2); + break; + } + + } + } + } + + private void centerOnScreen() { + BasicGuiApp.mainStage.centerOnScreen(); + } + + private void checkForUpdates() { + BasicGuiApp.up.checkForUpdate(); + } + + private void loadFile() throws IOException { + System.out.println("loading shortcuts"); + this.br = new BufferedReader(new FileReader(this.textfile)); + shortcuts.clear(); + tmpSh = ""; + tmpPa = ""; + while (this.tmpSh != null) { + this.tmpSh = this.br.readLine(); + if (this.tmpSh == null) break; + System.out.println(this.tmpSh); + tmpPa = this.br.readLine(); + System.out.println(this.tmpPa); + shortcuts.add(new Shortcut(tmpSh, tmpPa)); + System.out.println("shortcut added"); + } + br.close(); + try{ + MainGui.addNotification("All shortcuts loaded", 2); + }catch(NullPointerException npe){ + //will always fail when file gets read on boot + } + + + } + + private void saveFile(boolean silent) throws IOException { + this.bw = new BufferedWriter(new FileWriter(this.textfile)); + + int i = 0; + while (i <= shortcuts.size() - 1) { + this.bw.write(shortcuts.get(i).getShortcut()); + this.bw.newLine(); + this.bw.write(shortcuts.get(i).getPath()); + this.bw.newLine(); + ++i; + } + this.bw.close(); + if(!silent) { + MainGui.addNotification("Data has been written", 2); + } + } + + private void showShortcuts() { + Stage stage = new Stage(); + ShortcutWindow sw = new ShortcutWindow(shortcuts); + Scene s = new Scene(sw); + stage.setScene(s); + stage.setResizable(false); + stage.initStyle(StageStyle.UNDECORATED); + stage.showAndWait(); + try { + saveFile(true); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private void getFilePath(){ + MainGui.addNotification("Path: " + textfile.getAbsolutePath(), 6); + } + + private void QLversion() { + MainGui.addNotification("QuickLaunch version: " + Start.VERSION , 5); + } + + private void writeHelp() { + Stage stage = new Stage(); + HelpWindow hw = new HelpWindow(); + Scene s = new Scene(hw); + stage.setTitle("Help dialog"); + stage.setResizable(false); + stage.setScene(s); + stage.showAndWait(); + } + + private void showSettings() { + SettingScene sc = new SettingScene(); + BasicGuiApp.mainStage.setScene(sc); + } +} \ No newline at end of file diff --git a/QuickLaunch/src/mod_quicklaunch/Shortcut.java b/QuickLaunch/src/mod_quicklaunch/Shortcut.java new file mode 100644 index 0000000..6f1aa1d --- /dev/null +++ b/QuickLaunch/src/mod_quicklaunch/Shortcut.java @@ -0,0 +1,27 @@ +package mod_quicklaunch; + +public class Shortcut { + + private String shortcut; + private String path; + + public Shortcut(String shortcut,String path){ + this.shortcut = shortcut; + this.path = path; + } + public String getShortcut() { + return shortcut; + } + public void setShortcut(String shortcut) { + this.shortcut = shortcut; + } + public String getPath() { + return path; + } + public void setPath(String path) { + this.path = path; + } + + + +} diff --git a/QuickLaunch/src/mod_quicklaunch/ShortcutEntryPane.java b/QuickLaunch/src/mod_quicklaunch/ShortcutEntryPane.java new file mode 100644 index 0000000..ca98c03 --- /dev/null +++ b/QuickLaunch/src/mod_quicklaunch/ShortcutEntryPane.java @@ -0,0 +1,87 @@ +package mod_quicklaunch; + +import javafx.geometry.Pos; +import javafx.scene.control.CheckBox; +import javafx.scene.control.TextField; +import javafx.scene.layout.Pane; + +public class ShortcutEntryPane extends Pane{ + + private CheckBox checkBox; + private TextField shortcutField; + private TextField pathField; + + public ShortcutEntryPane(Shortcut cut,int layoutY) { + this.setPrefWidth(600); + this.setPrefHeight(35); + this.setLayoutX(0); + this.setLayoutY(layoutY); + + checkBox = new CheckBox(); + checkBox.setLayoutX(8); + checkBox.setLayoutY(8); + checkBox.setPrefWidth(18); + checkBox.setPrefHeight(18); + checkBox.setVisible(false); + + + shortcutField = new TextField(); + shortcutField.setText(cut.getShortcut()); + shortcutField.setPrefWidth(92); + shortcutField.setPrefHeight(27); + shortcutField.setLayoutX(8); + shortcutField.setLayoutY(4); + shortcutField.setAlignment(Pos.CENTER); + shortcutField.setEditable(false); + shortcutField.setStyle("-fx-text-fill: gray"); + + pathField = new TextField(); + pathField.setText(cut.getPath()); + pathField.setPrefWidth(497); + pathField.setPrefHeight(27); + pathField.setLayoutX(100); + pathField.setLayoutY(4); + pathField.setEditable(false); + pathField.setStyle("-fx-text-fill: gray"); + + this.getChildren().add(checkBox); + this.getChildren().add(shortcutField); + this.getChildren().add(pathField); + } + + public String getShortcut() { + return shortcutField.getText(); + } + + public String getPath() { + return pathField.getText(); + } + + public boolean isChecked() { + return checkBox.isSelected(); + } + + public void setEditable(boolean value) { + shortcutField.setEditable(value); + pathField.setEditable(value); + if(value) { + shortcutField.setStyle("-fx-text-fill: black"); + pathField.setStyle("-fx-text-fill: black"); + checkBox.setVisible(true); + shortcutField.setPrefWidth(70); + shortcutField.setLayoutX(30); + } + else { + shortcutField.setStyle("-fx-text-fill: gray"); + pathField.setStyle("-fx-text-fill: gray"); + checkBox.setVisible(false); + + shortcutField.setPrefWidth(92); + shortcutField.setLayoutX(8); + } + } + + public void focus() { + shortcutField.requestFocus(); + } +} diff --git a/QuickLaunch/src/mod_quicklaunch/ShortcutWindow.java b/QuickLaunch/src/mod_quicklaunch/ShortcutWindow.java new file mode 100644 index 0000000..25870b8 --- /dev/null +++ b/QuickLaunch/src/mod_quicklaunch/ShortcutWindow.java @@ -0,0 +1,218 @@ +package mod_quicklaunch; + +import java.util.ArrayList; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.scene.control.Button; +import javafx.scene.control.ScrollPane; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.Pane; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.stage.Stage; +import manager.ResourceManager; + +public class ShortcutWindow extends AnchorPane { + + + Rectangle buttonBar; + Button addButton; + Button backButton; + Button editButton; + boolean editable = false; + Button saveButton; + Button trashButton; + + Pane shortcutRootPane; + ScrollPane scrollPane; + private ArrayList shortcutEntries; + + public ShortcutWindow(ArrayList currentShortcuts) { + + this.setPrefWidth(600); + this.setMaxWidth(600); + this.setPrefHeight(400); + this.setMaxHeight(400); + + buttonBar = new Rectangle(600,40); + buttonBar.setLayoutX(0); + buttonBar.setLayoutY(0); + buttonBar.setFill(Color.WHITE); + //buttonBar.setFill(Color.rgb(244, 244, 244)); + + addButton = new Button(); + addButton.setPrefWidth(32); + addButton.setPrefHeight(32); + addButton.setLayoutX(120); + addButton.setLayoutY(5); + addButton.setPadding(Insets.EMPTY); + addButton.setStyle("-fx-background-color: transparent"); + addButton.setGraphic(ResourceManager.getAddImage());//Background(new Background(new BackgroundImage(ResourceManager.getAddImage(),BackgroundRepeat.NO_REPEAT,BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,BackgroundSize.DEFAULT))); + addButton.setVisible(editable); + + addButton.setOnAction(new EventHandler() { + + public void handle(ActionEvent event) { + shortcutEntries.add(new ShortcutEntryPane(new Shortcut("",""), shortcutEntries.size()*35)); + shortcutEntries.get(shortcutEntries.size()-1).setEditable(true); + shortcutRootPane.setPrefHeight(shortcutRootPane.getPrefHeight()+35); + shortcutRootPane.getChildren().add(shortcutEntries.get(shortcutEntries.size()-1)); + scrollPane.getContent().setVisible(false); + scrollPane.getContent().setVisible(true); + //Scrolling Thread :c + Thread t = new Thread(new Runnable() { + public void run() { + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + scrollPane.setVvalue(1.0); + } + }); + t.start(); + shortcutEntries.get(shortcutEntries.size()-1).focus(); + + + } + }); + + backButton = new Button(); + backButton.setPrefWidth(32); + backButton.setPrefHeight(32); + backButton.setLayoutX(0); + backButton.setLayoutY(5); + backButton.setPadding(Insets.EMPTY); + backButton.setStyle("-fx-background-color: transparent"); + backButton.setGraphic(ResourceManager.getBackImage());//setBackground(new Background(new BackgroundImage(ResourceManager.getBackImage(),BackgroundRepeat.NO_REPEAT,BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,BackgroundSize.DEFAULT))); + backButton.setOnAction(new EventHandler() { + + public void handle(ActionEvent event) { + Stage thisStage = (Stage) ShortcutWindow.this.getScene().getWindow(); + thisStage.close(); + } + }); + + editButton = new Button(); + editButton.setPrefWidth(32); + editButton.setPrefHeight(32); + editButton.setLayoutX(80); + editButton.setLayoutY(5); + editButton.setPadding(Insets.EMPTY); + editButton.setStyle("-fx-background-color: transparent"); + editButton.setGraphic(ResourceManager.getEditImage());//setBackground(new Background(new BackgroundImage(ResourceManager.getEditImage(),BackgroundRepeat.NO_REPEAT,BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,BackgroundSize.DEFAULT))); + editButton.setOnAction(new EventHandler() { + + public void handle(ActionEvent event) { + if(!editable) { + editButton.setGraphic(ResourceManager.getLockImage());//setBackground(new Background(new BackgroundImage(ResourceManager.getLockImage(),BackgroundRepeat.NO_REPEAT,BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,BackgroundSize.DEFAULT))); + editable = true; + addButton.setVisible(editable); + trashButton.setVisible(editable); + saveButton.setGraphic(ResourceManager.getSaveImageUnsaved()); + + + for(ShortcutEntryPane sep: shortcutEntries) { + sep.setEditable(editable); + } + } + else { + editButton.setGraphic(ResourceManager.getEditImage());//setBackground(new Background(new BackgroundImage(ResourceManager.getEditImage(),BackgroundRepeat.NO_REPEAT,BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,BackgroundSize.DEFAULT))); + editable = false; + addButton.setVisible(editable); + trashButton.setVisible(editable); + saveButton.setGraphic(ResourceManager.getSaveImage()); + for(ShortcutEntryPane sep: shortcutEntries) { + sep.setEditable(editable); + } + } + } + }); + + saveButton = new Button(); + saveButton.setPrefWidth(32); + saveButton.setPrefHeight(32); + saveButton.setLayoutX(40); + saveButton.setLayoutY(5); + saveButton.setPadding(Insets.EMPTY); + saveButton.setStyle("-fx-background-color: transparent"); + saveButton.setGraphic(ResourceManager.getSaveImage());//setBackground(new Background(new BackgroundImage(ResourceManager.getSaveImage(),BackgroundRepeat.NO_REPEAT,BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,BackgroundSize.DEFAULT))); + saveButton.setOnAction(new EventHandler() { + + public void handle(ActionEvent event) { + saveButton.setGraphic(ResourceManager.getSaveImage()); + editButton.fire(); + currentShortcuts.clear(); + for(int i = 0;i < shortcutEntries.size();i++) { + currentShortcuts.add(new Shortcut(shortcutEntries.get(i).getShortcut(),shortcutEntries.get(i).getPath())); + } + } + }); + + trashButton = new Button(); + trashButton.setPrefWidth(32); + trashButton.setPrefHeight(32); + trashButton.setLayoutX(556); + trashButton.setLayoutY(5); + trashButton.setVisible(false); + trashButton.setPadding(Insets.EMPTY); + trashButton.setStyle("-fx-background-color: transparent"); + trashButton.setGraphic(ResourceManager.getTrashImage());//setBackground(new Background(new BackgroundImage(ResourceManager.getTrashImage(),BackgroundRepeat.NO_REPEAT,BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,BackgroundSize.DEFAULT))); + trashButton.setOnAction(new EventHandler() { + + public void handle(ActionEvent event) { + boolean allRemoved = false; + while(!allRemoved) { + allRemoved = true; + for(int i = 0; i < shortcutEntries.size();i++) { + System.out.println(i); + if(shortcutEntries.get(i).isChecked()) { + allRemoved = false; + shortcutEntries.remove(i); + shortcutRootPane.getChildren().remove(i); + break; + + } + } + } + + shortcutRootPane.setPrefHeight(shortcutEntries.size()*35); + int y = 0; + for(int i = 0;i < shortcutEntries.size();i++) { + shortcutEntries.get(i).setLayoutY(y); + y+=35; + } + } + }); + + shortcutRootPane = new Pane(); + shortcutRootPane.setPrefSize(582 , currentShortcuts.size()*35); + shortcutRootPane.setLayoutX(0); + shortcutRootPane.setLayoutY(0); + + scrollPane = new ScrollPane(shortcutRootPane); + scrollPane.setPrefSize(600, 360); + scrollPane.setLayoutX(0); + scrollPane.setLayoutY(40); + + shortcutEntries = new ArrayList(); + int y = 0; + for(int i = 0;i tokens = new ArrayList(); + String tmp = ""; + for(int i = 0;i < input.length();i++){ + char a = input.charAt(i); + if(!(a == ';')){ + tmp += a; + + } + else{ + + tokens.add(tmp); + tmp = ""; + } + } + tokens.add(tmp); + + String[] returnArray = tokens.toArray(new String[tokens.size()]); + + + + return returnArray; + } + +} diff --git a/QuickLaunch/src/scenes/MainScene.java b/QuickLaunch/src/scenes/MainScene.java new file mode 100644 index 0000000..1301bd2 --- /dev/null +++ b/QuickLaunch/src/scenes/MainScene.java @@ -0,0 +1,20 @@ +package scenes; + + +import guis.MainGui; +import javafx.scene.Scene; +import javafx.scene.paint.Color; + + +public class MainScene extends Scene{ + + public MainScene() { + super(new MainGui()); + + this.setFill(Color.TRANSPARENT); + } + + + + +} diff --git a/QuickLaunch/src/scenes/SettingScene.java b/QuickLaunch/src/scenes/SettingScene.java new file mode 100644 index 0000000..c85f646 --- /dev/null +++ b/QuickLaunch/src/scenes/SettingScene.java @@ -0,0 +1,14 @@ +package scenes; + +import guis.SettingGui; +import javafx.scene.Scene; +import javafx.scene.paint.Color; + +public class SettingScene extends Scene{ + + public SettingScene() { + super(new SettingGui()); + this.setFill(Color.TRANSPARENT); + } + +} diff --git a/QuickLaunch/src/update/UpdateChecker.java b/QuickLaunch/src/update/UpdateChecker.java new file mode 100644 index 0000000..0c0730a --- /dev/null +++ b/QuickLaunch/src/update/UpdateChecker.java @@ -0,0 +1,88 @@ +package update; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.UnknownHostException; + +import guis.MainGui; + +public class UpdateChecker { + Socket socket; + DataInputStream in; + DataOutputStream out; + String ip; + int port; + float feedback = -1; + String linkToFile = ""; + public UpdateChecker(String ip, int port){ + this.ip = ip; + this.port = port; + try { + socket = new Socket(); + socket.connect(new InetSocketAddress(InetAddress.getByName("cookiestudios.org"), port), 700); + in = new DataInputStream(socket.getInputStream()); + out = new DataOutputStream(socket.getOutputStream()); + } catch (UnknownHostException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + + } + + + public float getCurrentVersion(){ + try { + + feedback = in.readFloat(); + out.writeUTF(System.getProperty("os.name")); + out.writeUTF(System.getProperty("os.version")); + out.writeUTF(System.getProperty("os.arch")); + out.writeUTF(System.getProperty("java.version")); + + return feedback; + } catch (IOException e) { + e.printStackTrace(); + return feedback; + + } + } + + public String getDownloadLink(){ + try { + out.writeBoolean(true); + linkToFile = in.readUTF(); + } catch (IOException e) { + + e.printStackTrace(); + } + + return linkToFile; + + } + + public void upToDate() { + try { + out.writeBoolean(false); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void close(){ + try { + out.writeBoolean(false); + in.close(); + out.close(); + socket.close(); + } catch (IOException e) { + + e.printStackTrace(); + } + } +} diff --git a/QuickLaunch/src/update/UpdateThread.java b/QuickLaunch/src/update/UpdateThread.java new file mode 100644 index 0000000..456def7 --- /dev/null +++ b/QuickLaunch/src/update/UpdateThread.java @@ -0,0 +1,50 @@ +package update; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; + +import manager.SettingManager; + +public class UpdateThread implements Runnable { + + File sq; + File qlN; + File fMark; + + public UpdateThread(){ + sq = new File(SettingManager.getJarDirectory()+File.separator+"Squirrel.jar"); + qlN = new File(SettingManager.getJarDirectory()+File.separator+"QuickLaunch.jar"); + fMark = new File(SettingManager.getJarDirectory()+File.separator+"f.MARK"); + } + public void run(){ + + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + + e.printStackTrace(); + } + if(sq.exists()){ + if(fMark.exists()){ + sq.delete(); + fMark.delete(); + } + else{ + try { + Files.copy(sq.toPath(), qlN.toPath(),StandardCopyOption.REPLACE_EXISTING); + fMark.createNewFile(); + + } catch (IOException e) { + + e.printStackTrace(); + } + } + + } + + + } + +} diff --git a/QuickLaunch/src/update/Updater.java b/QuickLaunch/src/update/Updater.java new file mode 100644 index 0000000..3b9505a --- /dev/null +++ b/QuickLaunch/src/update/Updater.java @@ -0,0 +1,94 @@ +package update; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.Optional; + +import guis.MainGui; +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.ButtonType; +import main.Start; +import manager.SettingManager; + +public class Updater { + + Thread uT; + + public void checkForUpdate(){ + try{ + UpdateChecker uc = new UpdateChecker("cookiestudios.org", 9999); + float tmpversion = uc.getCurrentVersion(); + System.out.println("got version: " + tmpversion); + + if(tmpversion > Start.VERSION){ + String dl = uc.getDownloadLink(); + Alert updateAlert = new Alert(AlertType.INFORMATION, + "There is a newer version of QuickLaunch available\nDownload now?", + ButtonType.YES, + ButtonType.NO); + updateAlert.setTitle("Update available!"); + Optional result = updateAlert.showAndWait(); + if(result.isPresent() && result.get() == ButtonType.YES){ + try { + System.out.println("here"); + cleanDirectory(); + URL website = new URL(dl); + ReadableByteChannel rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(SettingManager.getJarDirectory()+File.separator+"Squirrel.jar"); + fos.getChannel().transferFrom(rbc, 0, Integer.MAX_VALUE); + fos.close(); + System.out.println("Done"); + try { + ProcessBuilder pb = new ProcessBuilder("java","-jar",SettingManager.getJarDirectory()+File.separator+"Squirrel.jar"); + pb.directory(new File(SettingManager.getJarDirectory())); + pb.redirectErrorStream(true); + pb.redirectOutput(ProcessBuilder.Redirect.INHERIT); + pb.start(); + + }catch(Exception e) { + e.printStackTrace(); + } + System.out.println("started newer version"); + System.exit(0); + } catch (MalformedURLException e) { + e.printStackTrace(); + MainGui.addNotification("Couldn´t reach update server", 2); + } catch (FileNotFoundException e) { + e.printStackTrace(); + MainGui.addNotification("Couldn´t reach update server", 2); + } catch (IOException e) { + e.printStackTrace(); + MainGui.addNotification("Couldn´t reach update server", 2); + } + } + } + else{ + uc.upToDate(); + MainGui.addNotification("QuickLaunch is up to date", 2); + uT = new Thread(new UpdateThread()); + uT.start(); + } + uc.close(); + }catch(Exception e){ + } + } + + private void cleanDirectory(){ + File squirrel = new File(SettingManager.getJarDirectory()+File.separator+"Squirrel.jar"); + if(squirrel.exists()){ + squirrel.delete(); + } + File fMark = new File(SettingManager.getJarDirectory()+File.separator+"f.MARK"); + if(fMark.exists()){ + fMark.delete(); + } + } + +} diff --git a/QuickLaunchUpdateServer/.DS_Store b/QuickLaunchUpdateServer/.DS_Store new file mode 100644 index 0000000..fcd4b0a Binary files /dev/null and b/QuickLaunchUpdateServer/.DS_Store differ diff --git a/QuickLaunchUpdateServer/.classpath b/QuickLaunchUpdateServer/.classpath new file mode 100644 index 0000000..d171cd4 --- /dev/null +++ b/QuickLaunchUpdateServer/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/QuickLaunchUpdateServer/.project b/QuickLaunchUpdateServer/.project new file mode 100644 index 0000000..5323206 --- /dev/null +++ b/QuickLaunchUpdateServer/.project @@ -0,0 +1,17 @@ + + + QuickLaunchUpdateServer + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/QuickLaunchUpdateServer/.settings/org.eclipse.jdt.core.prefs b/QuickLaunchUpdateServer/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/QuickLaunchUpdateServer/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/QuickLaunchUpdateServer/bin/run/ServerThread.class b/QuickLaunchUpdateServer/bin/run/ServerThread.class new file mode 100644 index 0000000..99f0333 Binary files /dev/null and b/QuickLaunchUpdateServer/bin/run/ServerThread.class differ diff --git a/QuickLaunchUpdateServer/bin/run/Start.class b/QuickLaunchUpdateServer/bin/run/Start.class new file mode 100644 index 0000000..2981809 Binary files /dev/null and b/QuickLaunchUpdateServer/bin/run/Start.class differ diff --git a/QuickLaunchUpdateServer/bin/run/UpdateThread.class b/QuickLaunchUpdateServer/bin/run/UpdateThread.class new file mode 100644 index 0000000..5b90e66 Binary files /dev/null and b/QuickLaunchUpdateServer/bin/run/UpdateThread.class differ diff --git a/QuickLaunchUpdateServer/src/run/ServerThread.java b/QuickLaunchUpdateServer/src/run/ServerThread.java new file mode 100644 index 0000000..618a350 --- /dev/null +++ b/QuickLaunchUpdateServer/src/run/ServerThread.java @@ -0,0 +1,67 @@ +package run; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; +import run.Start; + +public class ServerThread +implements Runnable { + int PORT; + + public ServerThread(int port) { + this.PORT = port; + } + + boolean updateNeeded = true; + ServerSocket ses; + Socket s; + DataOutputStream out; + DataInputStream in; + + public void run() { + do { + try { + do { + updateNeeded = true; + ses = new ServerSocket(this.PORT); + s = ses.accept(); + System.out.println("Connected with: " + s.getInetAddress()); + out = new DataOutputStream(s.getOutputStream()); + in = new DataInputStream(s.getInputStream()); + out.writeFloat(Start.version); + + System.out.println(in.readUTF()); + System.out.println(in.readUTF()); + System.out.println(in.readUTF()); + System.out.println(in.readUTF()); + + updateNeeded = in.readBoolean(); + + if (updateNeeded) { + System.out.println("Update needed, Download link was send"); + out.writeUTF(Start.download); + } + out.close(); + in.close(); + s.close(); + ses.close(); + } while (true); + } + catch (IOException io) { + io.printStackTrace(); + try { + out.close(); + in.close(); + s.close(); + ses.close(); + } catch (IOException e) { + e.printStackTrace(); + System.out.println("Server panic"); + } + } + } while (true); + } +} \ No newline at end of file diff --git a/QuickLaunchUpdateServer/src/run/Start.java b/QuickLaunchUpdateServer/src/run/Start.java new file mode 100644 index 0000000..496f123 --- /dev/null +++ b/QuickLaunchUpdateServer/src/run/Start.java @@ -0,0 +1,25 @@ +package run; + +import javax.swing.JOptionPane; +import run.ServerThread; +import run.UpdateThread; + +public class Start { + public static float version = -1.0f; + public static String download = ""; + + private static final int PORT = 9999; + + + public static void main(String[] args) { + + version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version:")); + download = JOptionPane.showInputDialog("Link to downloadable"); + Thread ut = new Thread(new UpdateThread()); + ut.start(); + System.out.println("Update thread started"); + Thread st = new Thread(new ServerThread(PORT)); + st.start(); + System.out.println("Server listening"); + } +} \ No newline at end of file diff --git a/QuickLaunchUpdateServer/src/run/UpdateThread.java b/QuickLaunchUpdateServer/src/run/UpdateThread.java new file mode 100644 index 0000000..1b61e5b --- /dev/null +++ b/QuickLaunchUpdateServer/src/run/UpdateThread.java @@ -0,0 +1,15 @@ +package run; + +import javax.swing.JOptionPane; +import run.Start; + +public class UpdateThread +implements Runnable { + @Override + public void run() { + do { + Start.version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version (" + Start.version + "): ")); + Start.download = JOptionPane.showInputDialog("Link to downloadable:"); + } while (true); + } +} \ No newline at end of file