Initial git commit

This commit is contained in:
2019-04-14 12:18:58 +02:00
commit e1c1b51c90
113 changed files with 2646 additions and 0 deletions

View File

@@ -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<WindowEvent>() {
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();
}
}
}

View File

@@ -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 {
}
}

View File

@@ -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;
}
}
}

View File

@@ -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<KeyEvent>(){
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<ActionEvent>() {
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();
}
}

View File

@@ -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<ActionEvent>() {
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<ActionEvent>() {
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<ActionEvent>() {
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);
}
}

View File

@@ -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) {
}
}

View File

@@ -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<BasicMod> mods = new ArrayList<BasicMod>();
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();
}
}
}

View File

@@ -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");
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,3 @@
package manager;
public enum OperatingSystem {WINDOWS,OSX,LINUX}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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) {
}
}

View File

@@ -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();
}
}

View File

@@ -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<Double> values;
ArrayList<Character> operators;
char current;
String tmp;
double output;
double temp;
public void init(){
values = new ArrayList<Double>();
operators = new ArrayList<Character>();
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<operators.size();i++){
temp = values.get(i+1);
if(operators.get(i) == '+'){
output += temp;
}
else if(operators.get(i) == '-'){
output -= temp;
}
else if(operators.get(i) == '*'){
output *= temp;
}
else if(operators.get(i) == '/'){
output /= temp;
}
}
System.out.println(output);
JOptionPane.showMessageDialog(null, output);
}
}
private void clear(){
values.clear();
operators.clear();
current = ' ';
tmp = "";
temp = 0;
output = 0;
}
}

View File

@@ -0,0 +1,63 @@
package mod_ipchat;
import java.io.IOException;
import java.net.Socket;
import mod_ipchat.ChatInThread;
import mod_ipchat.ChatOutThread;
public class ChatClient {
private Socket outsocket;
private Socket insocket;
private boolean running = true;
Thread chatout;
public ChatClient(String ip) {
try {
this.insocket = new Socket(ip, 8080);
System.out.println("C: insocket connected");
this.outsocket = new Socket(ip, 8081);
System.out.println("C: outsocket connected");
}
catch (IOException e) {
e.printStackTrace();
}
}
public void create() {
ChatOutThread cot = new ChatOutThread(this.outsocket);
Thread chatout = new Thread(cot);
chatout.start();
ChatInThread cin = new ChatInThread(this.insocket);
Thread chatin = new Thread(cin);
chatin.start();
while (chatin.isAlive() && chatout.isAlive()) {
}
if (!chatin.isAlive()) {
cot.setKill(true);
} else if (chatout.isAlive()) {
cin.setKill(true);
}
this.running = false;
}
public boolean isRunning() {
return this.running;
}
public void setRunning(boolean running) {
this.running = running;
}
public Thread getChatout() {
return this.chatout;
}
public void setChatout(Thread chatout) {
this.chatout = chatout;
}
}

View File

@@ -0,0 +1,65 @@
package mod_ipchat;
import java.io.DataInputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;
public class ChatInThread
implements Runnable {
Scanner scn = new Scanner(System.in);
DataInputStream in;
boolean kill = false;
public ChatInThread(Socket socket) {
try {
this.in = new DataInputStream(socket.getInputStream());
}
catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void run() {
block : do {
try {
do {
String msg = this.in.readUTF();
if (this.kill) {
this.in.close();
break block;
}
if (msg.equalsIgnoreCase("xxx")) {
this.in.close();
break block;
}
System.out.println(msg);
Thread.sleep(1000);
} while (true);
}
catch (IOException e) {
e.printStackTrace();
continue;
}
catch (InterruptedException e) {
e.printStackTrace();
continue;
}
} while (true);
System.out.println("Chatin Done");
}
public boolean isKill() {
return this.kill;
}
public void setKill(boolean kill) {
this.kill = kill;
}
}

View File

@@ -0,0 +1,66 @@
package mod_ipchat;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;
public class ChatOutThread
implements Runnable {
Scanner scn = new Scanner(System.in);
DataOutputStream out;
String msg = "";
boolean kill = false;
public ChatOutThread(Socket socket) {
try {
this.out = new DataOutputStream(socket.getOutputStream());
}
catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void run() {
block : do {
try {
do {
this.msg = this.scn.nextLine();
this.out.writeUTF(this.msg);
if (!this.kill) continue;
this.out.close();
break block;
} while (!this.msg.equalsIgnoreCase("xxx"));
this.out.close();
break;
}
catch (IOException e) {
e.printStackTrace();
continue;
}
} while (true);
System.out.println("Chatout Done");
}
public String getMsg() {
return this.msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public boolean isKill() {
return this.kill;
}
public void setKill(boolean kill) {
this.kill = kill;
}
}

View File

@@ -0,0 +1,60 @@
package mod_ipchat;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import mod_ipchat.ChatInThread;
import mod_ipchat.ChatOutThread;
public class ChatServer {
private ServerSocket outserver;
private Socket outsocket;
private ServerSocket inserver;
private Socket insocket;
private boolean running = false;
public ChatServer() {
try {
this.running = true;
this.outserver = new ServerSocket(8080);
this.outsocket = this.outserver.accept();
System.out.println("S: outsocket connected");
this.inserver = new ServerSocket(8081);
this.insocket = this.inserver.accept();
System.out.println("S: insocket connected");
}
catch (IOException e) {
e.printStackTrace();
}
}
public void create() {
ChatOutThread cot = new ChatOutThread(this.outsocket);
Thread chatout = new Thread(cot);
chatout.start();
ChatInThread cin = new ChatInThread(this.insocket);
Thread chatin = new Thread(cin);
chatin.start();
while (chatin.isAlive() && chatout.isAlive()) {
}
if (!chatin.isAlive()) {
cot.setKill(true);
} else if (chatout.isAlive()) {
cin.setKill(true);
}
this.running = false;
}
public boolean isRunning() {
return this.running;
}
public void setRunning(boolean running) {
this.running = running;
}
}

View File

@@ -0,0 +1,44 @@
package mod_ipchat;
import java.io.IOException;
import java.util.Scanner;
import basics.BasicMod;
import mod_ipchat.ChatClient;
import mod_ipchat.ChatServer;
public class Chatmod
extends BasicMod {
Scanner scn;
public void init() {
this.setModName("ipChat");
this.scn = new Scanner(System.in);
}
@Override
public void checkInput(String input) throws IOException {
if (input.equalsIgnoreCase("chat")) {
System.out.println("Syntax: chat -c \"creating a chat client\"");
System.out.println(" chat -s \"creating a chat server\"");
} else if (input.equalsIgnoreCase("chat -c")) {
System.out.println("Please enter server ip");
String ip = this.scn.nextLine();
ChatClient cc = new ChatClient(ip);
cc.create();
while (cc.isRunning()) {
}
} else if (input.equalsIgnoreCase("chat -s")) {
ChatServer cs = new ChatServer();
cs.create();
while (cs.isRunning()) {
}
}
}
}

View File

@@ -0,0 +1,45 @@
package mod_pPw;
public class Hasher
{
public String outputID;
public byte decodeFactor = 0;
private byte inputLenght = 0;
private byte exceptionCounter = 0;
private char currentChar;
public Hasher()
{
this.outputID = "";
}
public String hash(String str)
{
this.outputID = "";
this.inputLenght = ((byte)str.length());
for (int i = 0; i < this.inputLenght; i++)
{
this.currentChar = ((char)(str.charAt(i) + this.decodeFactor));
for (int index = 0; index < 2; index++)
{
while ((this.currentChar < '!') || (this.currentChar > '~'))
{
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;
}
}

View File

@@ -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));
}
}
}

View File

@@ -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();
}
}

View File

@@ -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<Shortcut> 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<Shortcut>();
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);
}
}

View File

@@ -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;
}
}

View File

@@ -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();
}
}

View File

@@ -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<ShortcutEntryPane> shortcutEntries;
public ShortcutWindow(ArrayList<Shortcut> 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<ActionEvent>() {
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<ActionEvent>() {
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<ActionEvent>() {
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<ActionEvent>() {
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<ActionEvent>() {
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<ShortcutEntryPane>();
int y = 0;
for(int i = 0;i<currentShortcuts.size();i++) {
shortcutEntries.add(new ShortcutEntryPane(currentShortcuts.get(i), y));
shortcutRootPane.getChildren().add(shortcutEntries.get(i));
y+=35;
}
this.getChildren().add(scrollPane);
this.getChildren().add(buttonBar);
this.getChildren().add(addButton);
this.getChildren().add(backButton);
this.getChildren().add(editButton);
this.getChildren().add(saveButton);
this.getChildren().add(trashButton);
}
}

View File

@@ -0,0 +1,31 @@
package mod_quicklaunch;
import java.util.ArrayList;
public class TokenConverter {
public static String[] convert(String input){
ArrayList<String> tokens = new ArrayList<String>();
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;
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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();
}
}
}

View File

@@ -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();
}
}
}
}
}

View File

@@ -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<ButtonType> 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();
}
}
}