Updated version to 3.11 because of Java 11 requirements
Also introduced mod support -> Documentation tbd
This commit is contained in:
parent
c607426328
commit
93ece68815
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.cookiestudios</groupId>
|
||||||
|
<artifactId>QuickLaunch</artifactId>
|
||||||
|
<version>3.11</version>
|
||||||
|
<name>INTQuick</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<junit.version>5.7.1</junit.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjfx</groupId>
|
||||||
|
<artifactId>javafx-controls</artifactId>
|
||||||
|
<version>11.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjfx</groupId>
|
||||||
|
<artifactId>javafx-fxml</artifactId>
|
||||||
|
<version>11.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<version>${junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<version>${junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>11</source>
|
||||||
|
<target>11</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.openjfx</groupId>
|
||||||
|
<artifactId>javafx-maven-plugin</artifactId>
|
||||||
|
<version>0.0.6</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<!-- Default configuration for running with: mvn clean javafx:run -->
|
||||||
|
<id>default-cli</id>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>main/main.Start
|
||||||
|
</mainClass>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -59,7 +59,7 @@ public class BasicGuiApp extends Application{
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
|
|
||||||
mainStage = primaryStage;
|
mainStage = primaryStage;
|
||||||
mainStage.setTitle("QuickLaunch "+Start.VERSION);
|
mainStage.setTitle("QuickLaunch v"+Start.VERSION);
|
||||||
mainStage.getIcons().add(new Image(BasicGuiApp.class.getResourceAsStream("/icon.png")));
|
mainStage.getIcons().add(new Image(BasicGuiApp.class.getResourceAsStream("/icon.png")));
|
||||||
mainStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
mainStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||||
|
|
||||||
|
|
|
@ -3,31 +3,14 @@ package basics;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class BasicMod {
|
public abstract class BasicMod {
|
||||||
private String modname = "mod:mod";
|
protected String modName = "mod:mod";
|
||||||
private double version = 0.0;
|
protected double version = 0.0;
|
||||||
|
public double getVersion() { return version; }
|
||||||
|
public String getModName() { return modName; }
|
||||||
|
|
||||||
public void setModName(String name) {
|
public abstract int init();
|
||||||
this.modname = name;
|
public abstract void checkInput(String input);
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,7 @@ public class MainGui extends AnchorPane{
|
||||||
}
|
}
|
||||||
|
|
||||||
for (BasicMod bm : ModLoader.mods) {
|
for (BasicMod bm : ModLoader.mods) {
|
||||||
try {
|
|
||||||
bm.checkInput(input);
|
bm.checkInput(input);
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,81 +53,6 @@ public class SettingGui extends AnchorPane {
|
||||||
setting3Box.prefWidth(30);
|
setting3Box.prefWidth(30);
|
||||||
setting3Box.prefHeight(30);
|
setting3Box.prefHeight(30);
|
||||||
setting3Box.setSelected(SettingManager.isCheckUptdateOnBoot());
|
setting3Box.setSelected(SettingManager.isCheckUptdateOnBoot());
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
if (SettingManager.getOperatingSystem() == OperatingSystem.WINDOWS) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.getChildren().add(setting4);
|
|
||||||
this.getChildren().add(setting4button1);
|
|
||||||
this.getChildren().add(setting4button2);
|
|
||||||
}
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
Button exit = new Button("Done");
|
Button exit = new Button("Done");
|
||||||
exit.setFont(ResourceManager.getFontSmall());
|
exit.setFont(ResourceManager.getFontSmall());
|
||||||
|
|
|
@ -6,6 +6,8 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import basics.BasicMod;
|
import basics.BasicMod;
|
||||||
|
@ -49,37 +51,19 @@ public class ModLoader {
|
||||||
}
|
}
|
||||||
while (nextMod != null) {
|
while (nextMod != null) {
|
||||||
try {
|
try {
|
||||||
mods.add((BasicMod)Class.forName(nextMod).getConstructors()[0].newInstance(new Object[0]));
|
System.out.println("Trying for "+nextMod+".jar");
|
||||||
nextMod = this.bfr.readLine();
|
File modJar = new File(SettingManager.getJarDirectory()+File.separator+nextMod+".jar");
|
||||||
continue;
|
System.out.println(modJar.exists() ? "Found "+nextMod : "Not found");
|
||||||
}
|
ClassLoader cl = new URLClassLoader(new URL[] {modJar.toURL()}, Thread.currentThread().getContextClassLoader());
|
||||||
catch (InstantiationException e) {
|
mods.add((BasicMod)cl.loadClass("mod_"+nextMod.toLowerCase()+"."+nextMod).getConstructors()[0].newInstance(new Object[0]));
|
||||||
|
nextMod = bfr.readLine();
|
||||||
|
} catch (InstantiationException | IOException | SecurityException | InvocationTargetException | IllegalArgumentException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
continue;
|
System.out.println("Did not work");
|
||||||
}
|
} catch (ClassNotFoundException e) {
|
||||||
catch (IllegalAccessException e) {
|
System.err.println("'" + nextMod + "'" + " is not installed");
|
||||||
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;
|
break;
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import manager.SettingManager;
|
||||||
import manager.ResourceManager;
|
import manager.ResourceManager;
|
||||||
|
|
||||||
public class Start {
|
public class Start {
|
||||||
public static final float VERSION = 3.1f;
|
public static final float VERSION = 3.11f;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
|
|
|
@ -10,9 +10,9 @@ import guis.FileChooseWindow;
|
||||||
public class Gui extends BasicMod {
|
public class Gui extends BasicMod {
|
||||||
|
|
||||||
FileChooseWindow fcw;
|
FileChooseWindow fcw;
|
||||||
public void init() {
|
public int init() {
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void checkInput(String input) {
|
public void checkInput(String input) {
|
||||||
|
|
|
@ -14,17 +14,17 @@ public class Calcmod extends BasicMod{
|
||||||
String tmp;
|
String tmp;
|
||||||
double output;
|
double output;
|
||||||
double temp;
|
double temp;
|
||||||
public void init(){
|
public int init(){
|
||||||
values = new ArrayList<Double>();
|
values = new ArrayList<Double>();
|
||||||
operators = new ArrayList<Character>();
|
operators = new ArrayList<Character>();
|
||||||
current = ' ';
|
current = ' ';
|
||||||
tmp = "";
|
tmp = "";
|
||||||
System.out.println("Calculator installed");
|
System.out.println("Calculator installed");
|
||||||
this.setModName("Calculator");
|
modName = "Calculator";
|
||||||
this.setVersion(0.81);
|
version = 0.81;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
public void checkInput(String input) throws IOException {
|
public void checkInput(String input){
|
||||||
if(!input.isEmpty()){
|
if(!input.isEmpty()){
|
||||||
if(input.charAt(0)=='$'){
|
if(input.charAt(0)=='$'){
|
||||||
for(int i = 1;i < input.length();i++){
|
for(int i = 1;i < input.length();i++){
|
||||||
|
|
|
@ -13,13 +13,14 @@ extends BasicMod {
|
||||||
Scanner scn;
|
Scanner scn;
|
||||||
|
|
||||||
|
|
||||||
public void init() {
|
public int init() {
|
||||||
this.setModName("ipChat");
|
modName = "ipChat";
|
||||||
this.scn = new Scanner(System.in);
|
this.scn = new Scanner(System.in);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkInput(String input) throws IOException {
|
public void checkInput(String input) {
|
||||||
if (input.equalsIgnoreCase("chat")) {
|
if (input.equalsIgnoreCase("chat")) {
|
||||||
System.out.println("Syntax: chat -c \"creating a chat client\"");
|
System.out.println("Syntax: chat -c \"creating a chat client\"");
|
||||||
System.out.println(" chat -s \"creating a chat server\"");
|
System.out.println(" chat -s \"creating a chat server\"");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package mod_pPw;
|
package mod_ppw;
|
||||||
|
|
||||||
public class Hasher
|
public class Hasher
|
||||||
{
|
{
|
|
@ -1,24 +1,25 @@
|
||||||
package mod_pPw;
|
package mod_ppw;
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import basics.BasicMod;
|
import basics.BasicMod;
|
||||||
|
|
||||||
public class PPW
|
public class PPW extends BasicMod {
|
||||||
extends BasicMod
|
|
||||||
{
|
|
||||||
Scanner scn;
|
Scanner scn;
|
||||||
Hasher hash;
|
Hasher hash;
|
||||||
|
|
||||||
public void init()
|
public int init()
|
||||||
{
|
{
|
||||||
setModName("PPW");
|
|
||||||
setVersion(0.1D);
|
modName = "PPW";
|
||||||
System.out.println("PPW: Start init");
|
version = 0.1D;
|
||||||
|
|
||||||
|
System.out.println("PPWINT: Start init");
|
||||||
|
|
||||||
this.scn = new Scanner(System.in);
|
this.scn = new Scanner(System.in);
|
||||||
this.hash = new Hasher();
|
this.hash = new Hasher();
|
||||||
System.out.println("PPW: Exit init");
|
System.out.println("PPW: Exit init");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkInput(String input)
|
public void checkInput(String input)
|
|
@ -6,7 +6,8 @@ import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import basics.BasicGuiApp;
|
import basics.BasicGuiApp;
|
||||||
import basics.BasicMod;
|
import basics.BasicMod;
|
||||||
|
@ -24,13 +25,11 @@ public class QuickLaunch extends BasicMod {
|
||||||
private File textfile;
|
private File textfile;
|
||||||
private BufferedReader br;
|
private BufferedReader br;
|
||||||
private BufferedWriter bw;
|
private BufferedWriter bw;
|
||||||
private ArrayList<Shortcut> shortcuts;
|
private Map<String, String> shortcuts;
|
||||||
private String tmpSh = ".";
|
|
||||||
private String tmpPa = ".";
|
|
||||||
|
|
||||||
public void init() {
|
public int init() {
|
||||||
try {
|
try {
|
||||||
this.setModName("QL");
|
modName = "QL";
|
||||||
|
|
||||||
System.out.println("QL: Starting QuickLaunch");
|
System.out.println("QL: Starting QuickLaunch");
|
||||||
this.textfile = new File(SettingManager.getJarDirectory()+File.separator+"File.txt");
|
this.textfile = new File(SettingManager.getJarDirectory()+File.separator+"File.txt");
|
||||||
|
@ -40,7 +39,7 @@ public class QuickLaunch extends BasicMod {
|
||||||
this.textfile.createNewFile();
|
this.textfile.createNewFile();
|
||||||
System.out.println("QL: File.txt created");
|
System.out.println("QL: File.txt created");
|
||||||
}
|
}
|
||||||
shortcuts = new ArrayList<Shortcut>();
|
shortcuts = new HashMap<String, String>();
|
||||||
|
|
||||||
System.out.println("QL: Finished Initialisation");
|
System.out.println("QL: Finished Initialisation");
|
||||||
if(SettingManager.isLoadFileOnBoot()){
|
if(SettingManager.isLoadFileOnBoot()){
|
||||||
|
@ -50,16 +49,17 @@ public class QuickLaunch extends BasicMod {
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkInput(String input) throws IOException {
|
public void checkInput(String input){
|
||||||
if (input.equalsIgnoreCase("/cos")){
|
if (input.equalsIgnoreCase("/cos")){
|
||||||
this.centerOnScreen();
|
this.centerOnScreen();
|
||||||
} else if (input.equalsIgnoreCase("/cu")) {
|
} else if (input.equalsIgnoreCase("/cu")) {
|
||||||
this.checkForUpdates();
|
this.checkForUpdates();
|
||||||
} else if (input.equalsIgnoreCase("exit")) {
|
} else if (input.equalsIgnoreCase("exit") || input.equalsIgnoreCase("/x")) {
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
} else if ((input.equalsIgnoreCase("help")) || (input.equalsIgnoreCase("/?"))) {
|
} else if (input.equalsIgnoreCase("help") || input.equalsIgnoreCase("/?")) {
|
||||||
this.writeHelp();
|
this.writeHelp();
|
||||||
} else if (input.equalsIgnoreCase("loadFile") || input.equalsIgnoreCase("/lf")) {
|
} else if (input.equalsIgnoreCase("loadFile") || input.equalsIgnoreCase("/lf")) {
|
||||||
this.loadFile();
|
this.loadFile();
|
||||||
|
@ -74,18 +74,15 @@ public class QuickLaunch extends BasicMod {
|
||||||
} else if (input.equalsIgnoreCase("/c")) {
|
} else if (input.equalsIgnoreCase("/c")) {
|
||||||
this.showSettings();
|
this.showSettings();
|
||||||
} else {
|
} else {
|
||||||
int i = 0;
|
if(shortcuts.containsKey(input)) {
|
||||||
for (Shortcut sh : shortcuts) {
|
try {
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
ProcessBuilder pb = new ProcessBuilder(shortcuts.get(input).split(";"));
|
||||||
|
pb.start();
|
||||||
|
}catch (IOException io){
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,22 +101,24 @@ public class QuickLaunch extends BasicMod {
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadFile() throws IOException {
|
private void loadFile() {
|
||||||
|
try (BufferedReader br = new BufferedReader(new FileReader(this.textfile))){
|
||||||
System.out.println("loading shortcuts");
|
System.out.println("loading shortcuts");
|
||||||
this.br = new BufferedReader(new FileReader(this.textfile));
|
|
||||||
shortcuts.clear();
|
shortcuts.clear();
|
||||||
tmpSh = "";
|
String tmpSh = ".";
|
||||||
tmpPa = "";
|
String tmpPa = ".";
|
||||||
while (this.tmpSh != null) {
|
while (tmpSh != null) {
|
||||||
this.tmpSh = this.br.readLine();
|
tmpSh = br.readLine();
|
||||||
if (this.tmpSh == null) break;
|
if (tmpSh == null) break;
|
||||||
System.out.println(this.tmpSh);
|
System.out.println(tmpSh);
|
||||||
tmpPa = this.br.readLine();
|
tmpPa = br.readLine();
|
||||||
System.out.println(this.tmpPa);
|
System.out.println(tmpPa);
|
||||||
shortcuts.add(new Shortcut(tmpSh, tmpPa));
|
shortcuts.put(tmpSh, tmpPa);
|
||||||
System.out.println("shortcut added");
|
System.out.println("shortcut added");
|
||||||
|
}}catch (IOException io){
|
||||||
|
//TODO
|
||||||
}
|
}
|
||||||
br.close();
|
|
||||||
try{
|
try{
|
||||||
MainGui.addNotification("All shortcuts loaded", 2);
|
MainGui.addNotification("All shortcuts loaded", 2);
|
||||||
}catch(NullPointerException npe){
|
}catch(NullPointerException npe){
|
||||||
|
@ -129,18 +128,17 @@ public class QuickLaunch extends BasicMod {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveFile(boolean silent) throws IOException {
|
private void saveFile(boolean silent) {
|
||||||
this.bw = new BufferedWriter(new FileWriter(this.textfile));
|
try (BufferedWriter bw = new BufferedWriter(new FileWriter(this.textfile))) {
|
||||||
|
for (String key : shortcuts.keySet()) {
|
||||||
int i = 0;
|
bw.write(key);
|
||||||
while (i <= shortcuts.size() - 1) {
|
bw.newLine();
|
||||||
this.bw.write(shortcuts.get(i).getShortcut());
|
bw.write(shortcuts.get(key));
|
||||||
this.bw.newLine();
|
bw.newLine();
|
||||||
this.bw.write(shortcuts.get(i).getPath());
|
}
|
||||||
this.bw.newLine();
|
}catch (IOException io){
|
||||||
++i;
|
//TODO
|
||||||
}
|
}
|
||||||
this.bw.close();
|
|
||||||
if(!silent) {
|
if(!silent) {
|
||||||
MainGui.addNotification("Data has been written", 2);
|
MainGui.addNotification("Data has been written", 2);
|
||||||
}
|
}
|
||||||
|
@ -154,11 +152,7 @@ public class QuickLaunch extends BasicMod {
|
||||||
stage.setResizable(false);
|
stage.setResizable(false);
|
||||||
stage.initStyle(StageStyle.UNDECORATED);
|
stage.initStyle(StageStyle.UNDECORATED);
|
||||||
stage.showAndWait();
|
stage.showAndWait();
|
||||||
try {
|
|
||||||
saveFile(true);
|
saveFile(true);
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getFilePath(){
|
private void getFilePath(){
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -11,7 +11,7 @@ public class ShortcutEntryPane extends Pane{
|
||||||
private TextField shortcutField;
|
private TextField shortcutField;
|
||||||
private TextField pathField;
|
private TextField pathField;
|
||||||
|
|
||||||
public ShortcutEntryPane(Shortcut cut,int layoutY) {
|
public ShortcutEntryPane(int layoutY) {
|
||||||
this.setPrefWidth(600);
|
this.setPrefWidth(600);
|
||||||
this.setPrefHeight(35);
|
this.setPrefHeight(35);
|
||||||
this.setLayoutX(0);
|
this.setLayoutX(0);
|
||||||
|
@ -26,7 +26,7 @@ public class ShortcutEntryPane extends Pane{
|
||||||
|
|
||||||
|
|
||||||
shortcutField = new TextField();
|
shortcutField = new TextField();
|
||||||
shortcutField.setText(cut.getShortcut());
|
shortcutField.setText("");
|
||||||
shortcutField.setPrefWidth(92);
|
shortcutField.setPrefWidth(92);
|
||||||
shortcutField.setPrefHeight(27);
|
shortcutField.setPrefHeight(27);
|
||||||
shortcutField.setLayoutX(8);
|
shortcutField.setLayoutX(8);
|
||||||
|
@ -36,7 +36,7 @@ public class ShortcutEntryPane extends Pane{
|
||||||
shortcutField.setStyle("-fx-text-fill: gray");
|
shortcutField.setStyle("-fx-text-fill: gray");
|
||||||
|
|
||||||
pathField = new TextField();
|
pathField = new TextField();
|
||||||
pathField.setText(cut.getPath());
|
pathField.setText("");
|
||||||
pathField.setPrefWidth(497);
|
pathField.setPrefWidth(497);
|
||||||
pathField.setPrefHeight(27);
|
pathField.setPrefHeight(27);
|
||||||
pathField.setLayoutX(100);
|
pathField.setLayoutX(100);
|
||||||
|
@ -57,6 +57,12 @@ public class ShortcutEntryPane extends Pane{
|
||||||
return pathField.getText();
|
return pathField.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShortcutEntryPane setFieldContent(String shortcut, String path){
|
||||||
|
shortcutField.setText(shortcut);
|
||||||
|
pathField.setText(path);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
return checkBox.isSelected();
|
return checkBox.isSelected();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package mod_quicklaunch;
|
package mod_quicklaunch;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
|
@ -29,7 +30,7 @@ public class ShortcutWindow extends AnchorPane {
|
||||||
ScrollPane scrollPane;
|
ScrollPane scrollPane;
|
||||||
private ArrayList<ShortcutEntryPane> shortcutEntries;
|
private ArrayList<ShortcutEntryPane> shortcutEntries;
|
||||||
|
|
||||||
public ShortcutWindow(ArrayList<Shortcut> currentShortcuts) {
|
public ShortcutWindow(Map<String, String> currentShortcuts) {
|
||||||
|
|
||||||
this.setPrefWidth(600);
|
this.setPrefWidth(600);
|
||||||
this.setMaxWidth(600);
|
this.setMaxWidth(600);
|
||||||
|
@ -55,7 +56,7 @@ public class ShortcutWindow extends AnchorPane {
|
||||||
addButton.setOnAction(new EventHandler<ActionEvent>() {
|
addButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
|
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
shortcutEntries.add(new ShortcutEntryPane(new Shortcut("",""), shortcutEntries.size()*35));
|
shortcutEntries.add(new ShortcutEntryPane(shortcutEntries.size()*35));
|
||||||
shortcutEntries.get(shortcutEntries.size()-1).setEditable(true);
|
shortcutEntries.get(shortcutEntries.size()-1).setEditable(true);
|
||||||
shortcutRootPane.setPrefHeight(shortcutRootPane.getPrefHeight()+35);
|
shortcutRootPane.setPrefHeight(shortcutRootPane.getPrefHeight()+35);
|
||||||
shortcutRootPane.getChildren().add(shortcutEntries.get(shortcutEntries.size()-1));
|
shortcutRootPane.getChildren().add(shortcutEntries.get(shortcutEntries.size()-1));
|
||||||
|
@ -145,8 +146,8 @@ public class ShortcutWindow extends AnchorPane {
|
||||||
saveButton.setGraphic(ResourceManager.getSaveImage());
|
saveButton.setGraphic(ResourceManager.getSaveImage());
|
||||||
editButton.fire();
|
editButton.fire();
|
||||||
currentShortcuts.clear();
|
currentShortcuts.clear();
|
||||||
for(int i = 0;i < shortcutEntries.size();i++) {
|
for (ShortcutEntryPane shortcutEntry : shortcutEntries) {
|
||||||
currentShortcuts.add(new Shortcut(shortcutEntries.get(i).getShortcut(),shortcutEntries.get(i).getPath()));
|
currentShortcuts.put(shortcutEntry.getShortcut(), shortcutEntry.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -197,11 +198,12 @@ public class ShortcutWindow extends AnchorPane {
|
||||||
scrollPane.setLayoutX(0);
|
scrollPane.setLayoutX(0);
|
||||||
scrollPane.setLayoutY(40);
|
scrollPane.setLayoutY(40);
|
||||||
|
|
||||||
shortcutEntries = new ArrayList<ShortcutEntryPane>();
|
shortcutEntries = new ArrayList<>();
|
||||||
int y = 0;
|
int y = 0;
|
||||||
for(int i = 0;i<currentShortcuts.size();i++) {
|
for(String key : currentShortcuts.keySet()){
|
||||||
shortcutEntries.add(new ShortcutEntryPane(currentShortcuts.get(i), y));
|
ShortcutEntryPane sep = new ShortcutEntryPane(y).setFieldContent(key, currentShortcuts.get(key));
|
||||||
shortcutRootPane.getChildren().add(shortcutEntries.get(i));
|
shortcutEntries.add(sep);
|
||||||
|
shortcutRootPane.getChildren().add(sep);
|
||||||
y+=35;
|
y+=35;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue