|
@@ -3,22 +3,28 @@ package xyz.tbvns.ui;
|
|
|
import lombok.Getter;
|
|
|
import org.reflections.Reflections;
|
|
|
|
|
|
-import java.lang.reflect.InvocationTargetException;
|
|
|
import java.util.*;
|
|
|
|
|
|
public class UIManager {
|
|
|
- private static List<UIElement> registeredUiElements = new ArrayList<>();
|
|
|
+ private static List<Element> registeredElements = new ArrayList<>();
|
|
|
private static List<MenuBarTab> registeredMenuBarTabs = new ArrayList<>();
|
|
|
@Getter
|
|
|
private static final HashMap<Class, Boolean> activeUI = new HashMap<>();
|
|
|
|
|
|
public static void loadUi() {
|
|
|
try {
|
|
|
- Reflections reflections = new Reflections("xyz.tbvns.ui.Elements");
|
|
|
- Set<Class<? extends UIElement>> elements = reflections.getSubTypesOf(UIElement.class);
|
|
|
- for (Class<? extends UIElement> element : elements) {
|
|
|
- registeredUiElements.add(element.getDeclaredConstructor().newInstance());
|
|
|
- activeUI.put(element.getClass(), false);
|
|
|
+ Reflections reflections = new Reflections("xyz.tbvns.ui.Windows");
|
|
|
+ Set<Class<? extends Element>> windows = reflections.getSubTypesOf(Element.class);
|
|
|
+ for (Class<? extends Element> element : windows) {
|
|
|
+ registeredElements.add(element.getDeclaredConstructor().newInstance());
|
|
|
+ activeUI.put(element.asSubclass(Element.class), false);
|
|
|
+ }
|
|
|
+
|
|
|
+ reflections = new Reflections("xyz.tbvns.ui.Elements");
|
|
|
+ Set<Class<? extends Element>> elements = reflections.getSubTypesOf(Element.class);
|
|
|
+ for (Class<? extends Element> element : elements) {
|
|
|
+ registeredElements.add(element.getDeclaredConstructor().newInstance());
|
|
|
+ activeUI.put(element.asSubclass(Element.class), true);
|
|
|
}
|
|
|
|
|
|
reflections = new Reflections("xyz.tbvns.ui.MenuBarTabs");
|
|
@@ -33,7 +39,7 @@ public class UIManager {
|
|
|
}
|
|
|
|
|
|
public static void render() {
|
|
|
- for (UIElement element : registeredUiElements) {
|
|
|
+ for (Element element : registeredElements) {
|
|
|
boolean isEnabled = activeUI.get(element.getClass());
|
|
|
if (isEnabled) {
|
|
|
element.render();
|