Smaller fixes

This commit is contained in:
C0d3v 2021-09-30 14:13:21 +02:00
parent 93ece68815
commit c2a4ba9d6a
6 changed files with 54 additions and 71 deletions

View File

@ -61,13 +61,10 @@ public class BasicGuiApp extends Application{
mainStage = primaryStage;
mainStage.setTitle("QuickLaunch v"+Start.VERSION);
mainStage.getIcons().add(new Image(BasicGuiApp.class.getResourceAsStream("/icon.png")));
mainStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
mainStage.setOnCloseRequest(event -> {
SettingManager.saveSettings();
System.exit(0);
public void handle(WindowEvent event) {
SettingManager.saveSettings();
System.exit(0);
}
});
primaryStage.initStyle(StageStyle.TRANSPARENT);
@ -81,12 +78,9 @@ public class BasicGuiApp extends Application{
primaryStage.show();
if(SettingManager.isCheckUptdateOnBoot()){
new Thread(new Runnable() {
public void run() {
Updater up = new Updater();
up.checkForUpdate();
}
new Thread(() -> {
Updater up = new Updater();
up.checkForUpdate();
}).start();
}
}

View File

@ -1,7 +1,5 @@
package guis;
import java.io.IOException;
import basics.BasicGuiApp;
import basics.BasicMod;
import javafx.event.ActionEvent;
@ -19,7 +17,7 @@ public class MainGui extends AnchorPane{
private static Text notificationText;
public static TextField inputField;
public final TextField inputField;
public MainGui(){
@ -46,13 +44,13 @@ public class MainGui extends AnchorPane{
public void handle(KeyEvent event) {
String input;
if(event.getCode().name().equals("ENTER")){
//TODO create a layout for suggestions of which maybe 5 can be displayed
BasicGuiApp.mainStage.setAlwaysOnTop(false);
input = inputField.getText();
inputField.setText("");
if(input.equals("exit")){
System.exit(-1);
}
for (BasicMod bm : ModLoader.mods) {
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.setLayoutX(0);
notificationText.setLayoutY(65);
@ -88,6 +88,8 @@ public class MainGui extends AnchorPane{
notificationText.setStyle("-fx-background-color: rgba(0, 0, 0, 0);"
+ "-fx-fill: rgb(221,255,0);");
notificationText.setFont(ResourceManager.getFontSmall());
notificationText.setVisible(false);
notificationText.setManaged(false);
this.getChildren().add(inputField);
this.getChildren().add(minimize);
@ -97,15 +99,21 @@ public class MainGui extends AnchorPane{
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("");
notificationText.setManaged(true);
notificationText.setVisible(true);
BasicGuiApp.mainScene.getRoot().resize(400,60);
BasicGuiApp.mainScene.getWindow().sizeToScene();
Thread t = new Thread(() -> {
try {
Thread.sleep(sec*1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
notificationText.setText("");
notificationText.setVisible(false);
notificationText.setManaged(false);
BasicGuiApp.mainScene.getRoot().resize(400,40);
BasicGuiApp.mainScene.getWindow().sizeToScene();
});
t.start();
}

View File

@ -33,7 +33,8 @@ public class KeyChecker implements NativeKeyListener{
BasicGuiApp.mainStage.setAlwaysOnTop(true);
BasicGuiApp.mainStage.setAlwaysOnTop(false);
BasicGuiApp.mainStage.requestFocus();
MainGui.inputField.requestFocus();
//MainGui.inputField.requestFocus();
//TODO
BasicGuiApp.mainStage.setIconified(true);
BasicGuiApp.mainStage.setIconified(false);
}

View File

@ -2,7 +2,6 @@ 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;
@ -15,7 +14,7 @@ import manager.SettingManager;
import mod_quicklaunch.QuickLaunch;
public class ModLoader {
public static ArrayList<BasicMod> mods = new ArrayList<BasicMod>();
public static ArrayList<BasicMod> mods = new ArrayList<>();
private BufferedReader bfr;
public void init() {
@ -30,11 +29,7 @@ public class ModLoader {
System.out.println("ModLoader: Ready to install mods");
}
this.bfr = new BufferedReader(new FileReader(modfile));
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("ModLoader: Exit init");
@ -49,12 +44,14 @@ public class ModLoader {
catch (IOException e1) {
e1.printStackTrace();
}
//TODO move mods maybe to mods folder
while (nextMod != null) {
try {
System.out.println("Trying for "+nextMod+".jar");
File modJar = new File(SettingManager.getJarDirectory()+File.separator+nextMod+".jar");
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]));
nextMod = bfr.readLine();
} catch (InstantiationException | IOException | SecurityException | InvocationTargetException | IllegalArgumentException | IllegalAccessException e) {

View File

@ -53,46 +53,31 @@ public class Calcmod extends BasicMod{
}
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;
}
return (check == '1') ||
(check == '2') ||
(check == '3') ||
(check == '4') ||
(check == '5') ||
(check == '6') ||
(check == '7') ||
(check == '8') ||
(check == '9') ||
(check == '0') ||
(check == '.');
}
private boolean isOperator(char check){
if((check == '+') ||
(check == '-') ||
(check == '*') ||
(check == '/')){
return true;
}
else{
return false;
}
return (check == '+') ||
(check == '-') ||
(check == '*') ||
(check == '/');
}
private boolean isAlternative(char check){
if((check == ',') ||
(check == 'x')){
return true;
}
else{
return false;
}
return (check == ',') ||
(check == 'x');
}
private char changeAlternatives(char check){

View File

@ -12,8 +12,7 @@ public class UpdateChecker {
HashMap<String, String> serverData = new HashMap<>();
public void requestServerData(){
try {
Socket socket = new Socket();
try (Socket socket = new Socket()) {
socket.connect(new InetSocketAddress(InetAddress.getByName("cookiestudios.org"), 9999), 2000);
DataInputStream in = new DataInputStream(socket.getInputStream());
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
@ -30,9 +29,8 @@ public class UpdateChecker {
String[] keyValue = str.split("=");
serverData.put(keyValue[0], keyValue[1]);
}
socket.close();
} catch (IOException e) {
e.printStackTrace();
System.err.println("Could not reach update server");
}
}