diff --git a/.idea/libraries/JOE.xml b/.idea/libraries/JOE.xml new file mode 100644 index 0000000..148b25d --- /dev/null +++ b/.idea/libraries/JOE.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index e4b1d97..fd8f1f4 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,11 @@ Team Avion Launcher (TAL) Is an open source java launcher for all of Team Avion' We wish to form a Community that is fueled by passion and unwitting determination. In order to establish such a community we are going to develop a custom Minecraft launcher for Windows and MAC. We are also developing a fast, fun, and easy way to explore modded Minecraft through Android, IOS, Xbox, and Playstation. ### More Info -Please visit our [Project Page](https://github.com/Michael-Jouanneau/TeamAvion-Lancher/projects/1) to see our progress as we delve into the future of a stronger community! +Please visit our [Project Page](https://github.com/GabrielTofvesson/TeamAvionLauncher/projects/1) to see our progress as we delve into the future of a stronger community!

-Please Read [Terms of Services](https://github.com/Michael-Jouanneau/Team-Avion-Launcher/blob/master/agreements/Terms%20of%20Service.md) and [Privacy Policy](https://github.com/Michael-Jouanneau/Team-Avion-Launcher/blob/master/agreements/Privacy%20Policy.md) +Please Read [Terms of Services](https://github.com/GabrielTofvesson/TeamAvionLauncher/blob/master/agreements/Terms%20of%20Service.md) and [Privacy Policy](https://github.com/GabrielTofvesson/TeamAvionLauncher/blob/master/agreements/Privacy%20Policy.md) ### - Libraries - [RefTools](https://github.com/GabrielTofvesson/libRefTools) (Provided by [Blynd3 Dev](https://github.com/GabrielTofvesson)) +- [JOE](https://github.com/GabrielTofvesson/JOE) (Provided by [Blynd3 Dev](https://github.com/GabrielTofvesson)) diff --git a/TAL.iml b/TAL.iml index f6ccf03..3948b33 100644 --- a/TAL.iml +++ b/TAL.iml @@ -17,5 +17,6 @@ + \ No newline at end of file diff --git a/libs/JOE.jar b/libs/JOE.jar new file mode 100644 index 0000000..4d4c19e Binary files /dev/null and b/libs/JOE.jar differ diff --git a/src/Launcher/Main.java b/src/Launcher/Main.java index de7f54f..292e3fb 100644 --- a/src/Launcher/Main.java +++ b/src/Launcher/Main.java @@ -6,45 +6,68 @@ not-so-messy code is extremely messy just because of how I work. I mean, I try t always tell me that it's virtually unreadable and it doesn't help that it's difficult to explain to them what the code does without them losing interest. Also, in case you are actually, seriously going to read this crap, do yourself a favour and pour yourself some nice Jack Daniels. You deserve it if you're going to read through this. - */ + + + +Do not Read Past this point... This is a human health advisory. Anyone reading past this point will risk his or her life. +If you get sick reading, we will not claim responsibility on your health. Please Stay Clear of the Code. +*/ package Launcher; import Launcher.net.Updater; +import com.tofvesson.async.Async; +import com.tofvesson.joe.Localization; import com.tofvesson.reflection.SafeReflection; import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Application; +import javafx.collections.ObservableList; import javafx.scene.Node; +import javafx.scene.Parent; import javafx.scene.Scene; -import javafx.scene.control.*; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.Pane; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; import javafx.stage.StageStyle; -import java.io.File; -import com.tofvesson.async.*; import javafx.util.Duration; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/* +Do not go further. you risk your life. Read guideline above. Anyone reading past this point is no longer under our responsibility. +Beware the crocodiles on line 100! +*/ + public class Main extends Application { // Semantic versioning system data public static final String semVerDevState = "PreDev"; // Development stage public static final int semVerMajor = 0; // Major version public static final int semVerMinor = 2; // Minor version - public static final int semVerPatch = 2; // Patch version + public static final int semVerPatch = 4; // Patch version - private double xOffset = 0, yOffset = 0; // Offsets for dragging + + double xOffset = 0, yOffset = 0; // Offsets for dragging private static String[] args; - private Button exit, min, Home_btn, Modpack_btn, Settings_btn, Instance_btn; // Define buttons + Button exit, min, Home_btn, Modpack_btn, Settings_btn, Instance_btn, Default_theme, Dark_theme, Light_theme; // Define buttons private ImageView icon; private TextField Search_modpacks; private Image appIcon; private Rectangle dragBar; // Draggable top bar - private Pane root, tab; - private Node activeTab, settings_activeTab; + Pane root, tab; + Node activeTab, settings_activeTab; + private Label dialog_changer; + Async stringUpdater; @Override @@ -86,6 +109,11 @@ public class Main extends Application { Modpack_btn = (Button) root.lookup("#Modpacks-btn"); Settings_btn = (Button) root.lookup("#Settings-btn"); Instance_btn = (Button) root.lookup("#Instance-btn"); + Default_theme = (Button) root.lookup("#default-theme"); + Light_theme = (Button) root.lookup("#light-theme"); + Dark_theme = (Button) root.lookup("#dark-theme"); + + dialog_changer = (Label) root.lookup("#dialog-changer"); tab = (Pane) root.lookup("#tab"); @@ -110,6 +138,12 @@ public class Main extends Application { Tabs.switchTab("modpacks", tab); if(stringUpdater!=null && stringUpdater.isAlive()) stringUpdater.cancel(); stringUpdater = new Async(SafeReflection.getFirstMethod(Main.class, "detectStringUpdate"), Tabs.load("modpacks").lookup("#search-modpacks")); + Tabs.load("modpacks").lookup("#download-modpack").setOnMouseClicked(event1 -> { + System.out.println("Downloading Modpack"); + }); + Tabs.load("modpacks").lookup("#view-modpack").setOnMouseClicked(event1 -> { + System.out.println("Viewing Modpack"); + }); } }); @@ -118,7 +152,7 @@ public class Main extends Application { updateTabSelection(Instance_btn, TabType.MAIN); Tabs.switchTab("instance", tab); Tabs.load("instance").lookup("#Launch-VM").setOnMouseClicked(event1 -> { - + System.out.println("Launching Minecraft"); }); } }); @@ -126,7 +160,7 @@ public class Main extends Application { Settings_btn.setOnMouseClicked(event ->{ if(!activeTab.equals(Settings_btn)){ updateTabSelection(Settings_btn, TabType.MAIN); - Node n = Tabs.switchTab("settings", tab); // Sets the active tab to the settings tab unless it's already active + Node n = Tabs.switchTab("settings", tab), tmp; // Sets the active tab to the settings tab unless it's already active if(settings_activeTab==null) settings_activeTab = n.lookup("#Settings-Gen-btn"); // First time stuff @@ -136,7 +170,6 @@ public class Main extends Application { updateTabSelection(n.lookup("#Settings-Gen-btn"), TabType.SETTINGS); Node genericLayout = Tabs.switchTab("settings_generic", (Pane) n.lookup("#Settings-Pane")); - } }); @@ -145,11 +178,28 @@ public class Main extends Application { if(!settings_activeTab.getId().equals(n.lookup("#Settings-Mine-btn").getId())){ // Use id to identify layouts updateTabSelection(n.lookup("#Settings-Mine-btn"), TabType.SETTINGS); Node minecraftLayout = Tabs.switchTab("settings_minecraft", (Pane) n.lookup("#Settings-Pane")); + Tabs.load("settings_minecraft").lookup("#minecraft-login-btn").setOnMouseClicked(event3 ->{ + System.out.println("Logging into minecraft"); + }); } }); Tabs.switchTab(settings_activeTab.getId().equals("Settings-Gen-btn") ? "settings_generic" : "settings_minecraft", (Pane) n.lookup("#Settings-Pane")); + if((tmp=Tabs.load("settings_generic").lookup("#default-theme")).getOnMouseClicked()==null) { + tmp.setOnMouseClicked(event2 -> { + Theme.Default.switchTo(root); + System.out.println("Changing Theme to Default"); + }); + Tabs.load("settings_generic").lookup("#light-theme").setOnMouseClicked(event2 -> { + Theme.Light.switchTo(root); + System.out.println("Changing Theme to Light"); + }); + Tabs.load("settings_generic").lookup("#dark-theme").setOnMouseClicked(event1 -> { + Theme.Dark.switchTo(root); + System.out.println("Changing Theme to Dark"); + }); + } } }); @@ -170,10 +220,14 @@ public class Main extends Application { } public static void main(String[] args) throws Exception{ + // TODO: Try and fix this code please, It still doesn't work on my PC. + /* Localization l = new Localization(new File(Main.class.getResource("../assets/lang/").getFile())); // Create a localization with aggressive loading + System.out.println(Arrays.toString(l.getLanguageNames())); + System.out.println("Success: "+l.get("du_label")); */ Main.args = args; if (args.length > 0) { File f = new File(args[0]); - if (f.isFile()) f.delete(); // Delete previous jar + if (f.isFile()) while(!f.delete()) Thread.sleep(50); // Delete previous jar } launch(args); } @@ -198,7 +252,36 @@ public class Main extends Application { newTab.getStyleClass().add("selected"); } + public static List getFlatRepresentation(Parent root){ + List l = new ArrayList<>(); + l.add(root); + for(Node n : root.getChildrenUnmodifiable()){ + if(n instanceof Parent) + l.addAll(getFlatRepresentation((Parent)n)); + else l.add(n); + } + return l; + } + + public void processStyleData(Node n){ + + } + enum TabType{ SETTINGS, MAIN } + + enum Theme{ + Default(""), Dark(Main.class.getResource("/assets/style/dark-theme.css").toExternalForm()), Light(Main.class.getResource("/assets/style/light-theme.css").toExternalForm()); + + public final String style; + Theme(String style){ this.style = style; } + + public void switchTo(Pane root){ + ObservableList l = root.getStylesheets(); + if(l.contains(Light.style)) l.remove(Light.style); + if(l.contains(Dark.style)) l.remove(Dark.style); + if(this!=Default) l.add(style); + } + } } diff --git a/src/Launcher/Tabs.java b/src/Launcher/Tabs.java index 45b90ee..936e7ef 100644 --- a/src/Launcher/Tabs.java +++ b/src/Launcher/Tabs.java @@ -8,11 +8,12 @@ import javafx.util.Pair; import java.io.IOException; import java.net.URL; -@SuppressWarnings("unused") +@SuppressWarnings({"unused", "WeakerAccess"}) public class Tabs { private static final ShiftingList> loaded = new ShiftingList<>(35); // Memory-efficient list of loaded files + /** * Loads layout from file in layout assets folder. If layout is already loaded, * Tabs won't bother with reloading and will instead return the cached version. diff --git a/src/Launcher/net/Updater.java b/src/Launcher/net/Updater.java index 07a0b37..1dbf145 100644 --- a/src/Launcher/net/Updater.java +++ b/src/Launcher/net/Updater.java @@ -1,9 +1,13 @@ package Launcher.net; import Launcher.Main; +import Launcher.Tabs; import com.tofvesson.async.Async; import com.tofvesson.reflection.SafeReflection; import javafx.animation.Timeline; +import javafx.scene.control.Label; +import javafx.scene.layout.Pane; + import javax.net.ssl.HttpsURLConnection; import java.io.*; import java.net.MalformedURLException; diff --git a/src/assets/icons/dark-theme.png b/src/assets/icons/dark-theme.png new file mode 100644 index 0000000..a465f26 Binary files /dev/null and b/src/assets/icons/dark-theme.png differ diff --git a/src/assets/icons/light-theme.png b/src/assets/icons/light-theme.png new file mode 100644 index 0000000..757ba2d Binary files /dev/null and b/src/assets/icons/light-theme.png differ diff --git a/src/assets/icons/modpack-default-img.png b/src/assets/icons/modpack-default-img.png new file mode 100644 index 0000000..18c6619 Binary files /dev/null and b/src/assets/icons/modpack-default-img.png differ diff --git a/src/assets/lang/default.txt b/src/assets/lang/default.txt new file mode 100644 index 0000000..d84f458 --- /dev/null +++ b/src/assets/lang/default.txt @@ -0,0 +1,4 @@ +Language: Default + +du_label:Launching... +du_updater:Updating... \ No newline at end of file diff --git a/src/assets/lang/svenska.txt b/src/assets/lang/svenska.txt new file mode 100644 index 0000000..2f7ee71 --- /dev/null +++ b/src/assets/lang/svenska.txt @@ -0,0 +1,4 @@ +Language: Swedish + +du_label:Startar... +du_updater:Uppdaterar... \ No newline at end of file diff --git a/src/assets/layout/dialog_update.fxml b/src/assets/layout/dialog_update.fxml index 79fe1e9..9d61b62 100644 --- a/src/assets/layout/dialog_update.fxml +++ b/src/assets/layout/dialog_update.fxml @@ -1,18 +1,29 @@ + + - -