diff --git a/.idea/libraries/libRefTools.xml b/.idea/libraries/libRefTools.xml
new file mode 100644
index 0000000..c38d72c
--- /dev/null
+++ b/.idea/libraries/libRefTools.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TAL.iml b/TAL.iml
index d5c0743..7647c6b 100644
--- a/TAL.iml
+++ b/TAL.iml
@@ -7,6 +7,6 @@
+
-
-
+
\ No newline at end of file
diff --git a/libs/libRefTools.jar b/libs/libRefTools.jar
new file mode 100644
index 0000000..5782ea6
Binary files /dev/null and b/libs/libRefTools.jar differ
diff --git a/src/Launcher/Main.java b/src/Launcher/Main.java
index 569631e..151c63c 100644
--- a/src/Launcher/Main.java
+++ b/src/Launcher/Main.java
@@ -10,6 +10,7 @@ favour and pour yourself some nice Jack Daniels. You deserve it if you're going
package Launcher;
+import com.tofvesson.reflection.SafeReflection;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
@@ -22,6 +23,7 @@ import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import java.net.URL;
+import com.tofvesson.async.*;
public class Main extends Application {
@@ -48,6 +50,7 @@ public class Main extends Application {
primaryStage.getIcons().clear();
primaryStage.getIcons().add(appIcon = new Image(getClass().getResourceAsStream("../assets/icons/app.png")));
+
// Field initialization
exit = (Button) root.lookup("#exit");
min = (Button) root.lookup("#min");
@@ -60,12 +63,26 @@ public class Main extends Application {
Search_modpacks_btn = (Button) root.lookup("#search-modpacks-btn");
Search_modpacks = (TextField) root.lookup("#search-modpacks");
+
// Infrastructural navigation
exit.setOnMouseClicked(event -> primaryStage.close()); // Closes the program if exit button is clicked
min.setOnMouseClicked(event -> primaryStage.setIconified(true)); // Minimizes the program if minimize button is clicked
- Home_btn.setOnMouseClicked(event -> {if(activeTab!=Tabs.Home)(activeTab=Tabs.Home).switchTab(tab);}); // Sets the active tab to the home tab unless it's already active
- Modpack_btn.setOnMouseClicked(event -> {if(activeTab!=Tabs.Modpacks)(activeTab=Tabs.Modpacks).switchTab(tab);});// Sets the active tab to the modpacks tab unless it's already active
- Settings_btn.setOnMouseClicked(event -> {if(activeTab!=Tabs.Settings)(activeTab=Tabs.Settings).switchTab(tab);});
+ Home_btn.setOnMouseClicked(event ->{if(activeTab!=Tabs.Home)(activeTab=Tabs.Home).switchTab(tab);}); // Sets the active tab to the home tab unless it's already active
+ Modpack_btn.setOnMouseClicked(event ->{
+ if(activeTab!=Tabs.Modpacks){
+ (activeTab=Tabs.Modpacks).switchTab(tab); // Sets the active tab to the modpacks tab unless it's already active
+ Tabs.Modpacks.loaded.lookup("#search-modpacks").setOnInputMethodTextChanged(System.out::println);
+ }
+ });
+ Settings_btn.setOnMouseClicked(event ->{
+ if(activeTab!=Tabs.Settings){
+ (activeTab=Tabs.Settings).switchTab(tab); // Sets the active tab to the settings tab unless it's already active
+ }
+ });
+
+
+ Async a = new Async(null, SafeReflection.getMethod(getClass(), "run", (Class>[]) null), null);
+ System.out.println(a.await());
// Drag
dragBar.setOnMousePressed(event -> {
@@ -77,6 +94,7 @@ public class Main extends Application {
primaryStage.setY(event.getScreenY() - yOffset);
});
+
// Set up default layout
Tabs.Home.switchTab(tab);
icon.setImage(appIcon);
@@ -86,5 +104,8 @@ public class Main extends Application {
launch(args);
}
+ public static int run(){
+ return 500;
+ }
}
diff --git a/src/Launcher/Tabs.java b/src/Launcher/Tabs.java
index b7b98ad..bf1c46b 100644
--- a/src/Launcher/Tabs.java
+++ b/src/Launcher/Tabs.java
@@ -10,18 +10,25 @@ public enum Tabs {
Modpacks(Tabs.class.getResource("../assets/layout/modpacks.fxml")), Home(Tabs.class.getResource("../assets/layout/home.fxml")), Settings(Tabs.class.getResource("../assets/layout/settings.fxml"));
+ /**
+ * Url referencing xml.
+ */
public final URL url;
- private Parent loaded;
+
+ /**
+ * Loaded layout
+ */
+ public final Parent loaded;
+
Tabs(URL url){
this.url = url;
+ Parent p = null;
+ try { p = FXMLLoader.load(url); } catch (IOException e) { e.printStackTrace(); }
+ loaded = p;
}
public void switchTab(Pane holder){
holder.getChildren().clear();
- try {
- holder.getChildren().add(loaded==null?loaded=FXMLLoader.load(url):loaded);
- } catch (IOException e) {
- e.printStackTrace();
- }
+ holder.getChildren().add(loaded);
}
}