Smaller fixes
This commit is contained in:
parent
93ece68815
commit
c2a4ba9d6a
|
@ -61,13 +61,10 @@ public class BasicGuiApp extends Application{
|
||||||
mainStage = primaryStage;
|
mainStage = primaryStage;
|
||||||
mainStage.setTitle("QuickLaunch v"+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(event -> {
|
||||||
|
|
||||||
public void handle(WindowEvent event) {
|
|
||||||
SettingManager.saveSettings();
|
SettingManager.saveSettings();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
primaryStage.initStyle(StageStyle.TRANSPARENT);
|
primaryStage.initStyle(StageStyle.TRANSPARENT);
|
||||||
|
@ -81,12 +78,9 @@ public class BasicGuiApp extends Application{
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
|
||||||
if(SettingManager.isCheckUptdateOnBoot()){
|
if(SettingManager.isCheckUptdateOnBoot()){
|
||||||
new Thread(new Runnable() {
|
new Thread(() -> {
|
||||||
|
|
||||||
public void run() {
|
|
||||||
Updater up = new Updater();
|
Updater up = new Updater();
|
||||||
up.checkForUpdate();
|
up.checkForUpdate();
|
||||||
}
|
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package guis;
|
package guis;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import basics.BasicGuiApp;
|
import basics.BasicGuiApp;
|
||||||
import basics.BasicMod;
|
import basics.BasicMod;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
|
@ -19,7 +17,7 @@ public class MainGui extends AnchorPane{
|
||||||
|
|
||||||
|
|
||||||
private static Text notificationText;
|
private static Text notificationText;
|
||||||
public static TextField inputField;
|
public final TextField inputField;
|
||||||
|
|
||||||
public MainGui(){
|
public MainGui(){
|
||||||
|
|
||||||
|
@ -46,13 +44,13 @@ public class MainGui extends AnchorPane{
|
||||||
public void handle(KeyEvent event) {
|
public void handle(KeyEvent event) {
|
||||||
String input;
|
String input;
|
||||||
if(event.getCode().name().equals("ENTER")){
|
if(event.getCode().name().equals("ENTER")){
|
||||||
|
//TODO create a layout for suggestions of which maybe 5 can be displayed
|
||||||
BasicGuiApp.mainStage.setAlwaysOnTop(false);
|
BasicGuiApp.mainStage.setAlwaysOnTop(false);
|
||||||
input = inputField.getText();
|
input = inputField.getText();
|
||||||
inputField.setText("");
|
inputField.setText("");
|
||||||
if(input.equals("exit")){
|
if(input.equals("exit")){
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (BasicMod bm : ModLoader.mods) {
|
for (BasicMod bm : ModLoader.mods) {
|
||||||
bm.checkInput(input);
|
bm.checkInput(input);
|
||||||
}
|
}
|
||||||
|
@ -80,6 +78,8 @@ public class MainGui extends AnchorPane{
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//TODO maybe show this only when notification is present
|
||||||
|
//TODO Enlarge and collapse window if content is present
|
||||||
notificationText = new Text();
|
notificationText = new Text();
|
||||||
notificationText.setLayoutX(0);
|
notificationText.setLayoutX(0);
|
||||||
notificationText.setLayoutY(65);
|
notificationText.setLayoutY(65);
|
||||||
|
@ -88,6 +88,8 @@ public class MainGui extends AnchorPane{
|
||||||
notificationText.setStyle("-fx-background-color: rgba(0, 0, 0, 0);"
|
notificationText.setStyle("-fx-background-color: rgba(0, 0, 0, 0);"
|
||||||
+ "-fx-fill: rgb(221,255,0);");
|
+ "-fx-fill: rgb(221,255,0);");
|
||||||
notificationText.setFont(ResourceManager.getFontSmall());
|
notificationText.setFont(ResourceManager.getFontSmall());
|
||||||
|
notificationText.setVisible(false);
|
||||||
|
notificationText.setManaged(false);
|
||||||
|
|
||||||
this.getChildren().add(inputField);
|
this.getChildren().add(inputField);
|
||||||
this.getChildren().add(minimize);
|
this.getChildren().add(minimize);
|
||||||
|
@ -97,15 +99,21 @@ public class MainGui extends AnchorPane{
|
||||||
|
|
||||||
public static void addNotification(String msg,final int sec){
|
public static void addNotification(String msg,final int sec){
|
||||||
notificationText.setText(msg);
|
notificationText.setText(msg);
|
||||||
Thread t = new Thread(new Runnable() {
|
notificationText.setManaged(true);
|
||||||
public void run() {
|
notificationText.setVisible(true);
|
||||||
|
BasicGuiApp.mainScene.getRoot().resize(400,60);
|
||||||
|
BasicGuiApp.mainScene.getWindow().sizeToScene();
|
||||||
|
Thread t = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(sec*1000);
|
Thread.sleep(sec*1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
notificationText.setText("");
|
notificationText.setText("");
|
||||||
}
|
notificationText.setVisible(false);
|
||||||
|
notificationText.setManaged(false);
|
||||||
|
BasicGuiApp.mainScene.getRoot().resize(400,40);
|
||||||
|
BasicGuiApp.mainScene.getWindow().sizeToScene();
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,8 @@ public class KeyChecker implements NativeKeyListener{
|
||||||
BasicGuiApp.mainStage.setAlwaysOnTop(true);
|
BasicGuiApp.mainStage.setAlwaysOnTop(true);
|
||||||
BasicGuiApp.mainStage.setAlwaysOnTop(false);
|
BasicGuiApp.mainStage.setAlwaysOnTop(false);
|
||||||
BasicGuiApp.mainStage.requestFocus();
|
BasicGuiApp.mainStage.requestFocus();
|
||||||
MainGui.inputField.requestFocus();
|
//MainGui.inputField.requestFocus();
|
||||||
|
//TODO
|
||||||
BasicGuiApp.mainStage.setIconified(true);
|
BasicGuiApp.mainStage.setIconified(true);
|
||||||
BasicGuiApp.mainStage.setIconified(false);
|
BasicGuiApp.mainStage.setIconified(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package main;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
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;
|
||||||
|
@ -15,7 +14,7 @@ import manager.SettingManager;
|
||||||
import mod_quicklaunch.QuickLaunch;
|
import mod_quicklaunch.QuickLaunch;
|
||||||
|
|
||||||
public class ModLoader {
|
public class ModLoader {
|
||||||
public static ArrayList<BasicMod> mods = new ArrayList<BasicMod>();
|
public static ArrayList<BasicMod> mods = new ArrayList<>();
|
||||||
private BufferedReader bfr;
|
private BufferedReader bfr;
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -30,11 +29,7 @@ public class ModLoader {
|
||||||
System.out.println("ModLoader: Ready to install mods");
|
System.out.println("ModLoader: Ready to install mods");
|
||||||
}
|
}
|
||||||
this.bfr = new BufferedReader(new FileReader(modfile));
|
this.bfr = new BufferedReader(new FileReader(modfile));
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
System.out.println("ModLoader: Exit init");
|
System.out.println("ModLoader: Exit init");
|
||||||
|
@ -49,12 +44,14 @@ public class ModLoader {
|
||||||
catch (IOException e1) {
|
catch (IOException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO move mods maybe to mods folder
|
||||||
while (nextMod != null) {
|
while (nextMod != null) {
|
||||||
try {
|
try {
|
||||||
System.out.println("Trying for "+nextMod+".jar");
|
System.out.println("Trying for "+nextMod+".jar");
|
||||||
File modJar = new File(SettingManager.getJarDirectory()+File.separator+nextMod+".jar");
|
File modJar = new File(SettingManager.getJarDirectory()+File.separator+nextMod+".jar");
|
||||||
System.out.println(modJar.exists() ? "Found "+nextMod : "Not found");
|
System.out.println(modJar.exists() ? "Found "+nextMod : "Not found");
|
||||||
ClassLoader cl = new URLClassLoader(new URL[] {modJar.toURL()}, Thread.currentThread().getContextClassLoader());
|
ClassLoader cl = new URLClassLoader(new URL[] {modJar.toURI().toURL()}, Thread.currentThread().getContextClassLoader());
|
||||||
mods.add((BasicMod)cl.loadClass("mod_"+nextMod.toLowerCase()+"."+nextMod).getConstructors()[0].newInstance(new Object[0]));
|
mods.add((BasicMod)cl.loadClass("mod_"+nextMod.toLowerCase()+"."+nextMod).getConstructors()[0].newInstance(new Object[0]));
|
||||||
nextMod = bfr.readLine();
|
nextMod = bfr.readLine();
|
||||||
} catch (InstantiationException | IOException | SecurityException | InvocationTargetException | IllegalArgumentException | IllegalAccessException e) {
|
} catch (InstantiationException | IOException | SecurityException | InvocationTargetException | IllegalArgumentException | IllegalAccessException e) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class Calcmod extends BasicMod{
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNumber(char check){
|
private boolean isNumber(char check){
|
||||||
if((check == '1') ||
|
return (check == '1') ||
|
||||||
(check == '2') ||
|
(check == '2') ||
|
||||||
(check == '3') ||
|
(check == '3') ||
|
||||||
(check == '4') ||
|
(check == '4') ||
|
||||||
|
@ -63,36 +63,21 @@ public class Calcmod extends BasicMod{
|
||||||
(check == '8') ||
|
(check == '8') ||
|
||||||
(check == '9') ||
|
(check == '9') ||
|
||||||
(check == '0') ||
|
(check == '0') ||
|
||||||
(check == '.')){
|
(check == '.');
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOperator(char check){
|
private boolean isOperator(char check){
|
||||||
if((check == '+') ||
|
return (check == '+') ||
|
||||||
(check == '-') ||
|
(check == '-') ||
|
||||||
(check == '*') ||
|
(check == '*') ||
|
||||||
(check == '/')){
|
(check == '/');
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAlternative(char check){
|
private boolean isAlternative(char check){
|
||||||
if((check == ',') ||
|
return (check == ',') ||
|
||||||
(check == 'x')){
|
(check == 'x');
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private char changeAlternatives(char check){
|
private char changeAlternatives(char check){
|
||||||
|
|
|
@ -12,8 +12,7 @@ public class UpdateChecker {
|
||||||
HashMap<String, String> serverData = new HashMap<>();
|
HashMap<String, String> serverData = new HashMap<>();
|
||||||
|
|
||||||
public void requestServerData(){
|
public void requestServerData(){
|
||||||
try {
|
try (Socket socket = new Socket()) {
|
||||||
Socket socket = new Socket();
|
|
||||||
socket.connect(new InetSocketAddress(InetAddress.getByName("cookiestudios.org"), 9999), 2000);
|
socket.connect(new InetSocketAddress(InetAddress.getByName("cookiestudios.org"), 9999), 2000);
|
||||||
DataInputStream in = new DataInputStream(socket.getInputStream());
|
DataInputStream in = new DataInputStream(socket.getInputStream());
|
||||||
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
|
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
|
||||||
|
@ -30,9 +29,8 @@ public class UpdateChecker {
|
||||||
String[] keyValue = str.split("=");
|
String[] keyValue = str.split("=");
|
||||||
serverData.put(keyValue[0], keyValue[1]);
|
serverData.put(keyValue[0], keyValue[1]);
|
||||||
}
|
}
|
||||||
socket.close();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
System.err.println("Could not reach update server");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue