Made ModLoader opaque
This commit is contained in:
parent
249000c9d0
commit
8e079a9c36
|
@ -1,3 +1,8 @@
|
|||
## 22.2.0.0-alpha.1
|
||||
* `plutoengine-demos/` Removed third-party fonts
|
||||
* `[PlutoRuntime]` The `ModLoader` component is now opaque,
|
||||
pre-added mods are now specified when creating the token
|
||||
|
||||
## 22.2.0.0-alpha.0
|
||||
* `[PlutoComponent]` **Added support for dependencies and strengtened type checks**
|
||||
* `[PlutoComponent]` *Removed* `IComponent` as it was redundant to `AbstractComponent`
|
||||
|
|
|
@ -201,9 +201,6 @@ public abstract class PlutoApplication
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Start the application in a new thread
|
||||
* */
|
||||
public final void run(String[] args, StartupConfig config)
|
||||
{
|
||||
if (config == null)
|
||||
|
@ -213,7 +210,7 @@ public abstract class PlutoApplication
|
|||
|
||||
var globalComponents = PlutoGlobal.COMPONENTS;
|
||||
|
||||
globalComponents.addComponent(Logger.TOKEN);
|
||||
var logger = globalComponents.addComponent(Logger.TOKEN);
|
||||
|
||||
Logger.log(SmartSeverity.INFO, "Debug mode: " + (Pluto.DEBUG_MODE ? "enabled" : "disabled"));
|
||||
|
||||
|
@ -264,12 +261,7 @@ public abstract class PlutoApplication
|
|||
|
||||
var inputBus = components.addComponent(InputBus.fromDisplay(this.display));
|
||||
var audioEngine = components.addComponent(AudioEngine.TOKEN);
|
||||
|
||||
var modLoader = components.addComponent(ModLoader.TOKEN);
|
||||
|
||||
modLoader.registerMod(this.getMainModule());
|
||||
|
||||
modLoader.load();
|
||||
var modLoader = components.addComponent(ModLoader.with(this.getMainModule()));
|
||||
|
||||
if (config.icons != null)
|
||||
{
|
||||
|
@ -295,12 +287,10 @@ public abstract class PlutoApplication
|
|||
}
|
||||
|
||||
components.removeComponent(audioEngine);
|
||||
|
||||
modLoader.unload();
|
||||
components.removeComponent(modLoader);
|
||||
|
||||
GL.destroy();
|
||||
|
||||
components.removeComponent(modLoader);
|
||||
components.removeComponent(inputBus);
|
||||
|
||||
this.display.destroy();
|
||||
|
@ -309,7 +299,7 @@ public abstract class PlutoApplication
|
|||
|
||||
DisplayBuilder.destroyGLFW();
|
||||
|
||||
globalComponents.removeComponents(Logger.TOKEN);
|
||||
globalComponents.removeComponent(logger);
|
||||
}
|
||||
|
||||
public Display getDisplayInstance()
|
||||
|
|
|
@ -63,7 +63,7 @@ public class Display extends PlutoLocalComponent
|
|||
throw new IllegalStateException("Failed to create a window...");
|
||||
}
|
||||
|
||||
GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
|
||||
var vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
|
||||
|
||||
if (vidmode == null)
|
||||
{
|
||||
|
|
|
@ -81,9 +81,7 @@ public class DisplayBuilder
|
|||
public static void initGLFW()
|
||||
{
|
||||
if (!GLFW.glfwInit())
|
||||
{
|
||||
throw new IllegalStateException("Could not init GLFW!");
|
||||
}
|
||||
}
|
||||
|
||||
public static void destroyGLFW()
|
||||
|
|
|
@ -18,8 +18,6 @@ import java.util.*;
|
|||
*/
|
||||
public final class ModLoader extends PlutoLocalComponent
|
||||
{
|
||||
public static final ComponentToken<ModLoader> TOKEN = ComponentToken.create(ModLoader::new);
|
||||
|
||||
private EnumModLoadingPhase loadingPhase;
|
||||
private final Map<VirtualAddress, Mod> modNameLookup;
|
||||
private final Map<Class<?>, Mod> modLookup;
|
||||
|
@ -43,6 +41,16 @@ public final class ModLoader extends PlutoLocalComponent
|
|||
this.entryPoints = new HashMap<>();
|
||||
}
|
||||
|
||||
public static ComponentToken<ModLoader> with(Class<?>... modClasses)
|
||||
{
|
||||
return ComponentToken.create(() -> {
|
||||
var ml = new ModLoader();
|
||||
for (var modClass : modClasses)
|
||||
ml.registerMod(modClass);
|
||||
return ml;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Denotes whether this component should be unique.
|
||||
* Unique components can only exist once per instance
|
||||
|
@ -68,7 +76,7 @@ public final class ModLoader extends PlutoLocalComponent
|
|||
* @author 493msi
|
||||
* @since 20.2.0.0-alpha.3
|
||||
*/
|
||||
public void registerMod(Class<?> modClass)
|
||||
void registerMod(Class<?> modClass)
|
||||
{
|
||||
if (loadingPhase != EnumModLoadingPhase.INITIAL && loadingPhase != EnumModLoadingPhase.CLASSLOADING_EXTERNAL)
|
||||
{
|
||||
|
@ -151,13 +159,8 @@ public final class ModLoader extends PlutoLocalComponent
|
|||
return Optional.ofNullable(this.modNameLookup.get(modID));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author 493msi
|
||||
* @since 20.2.0.0-alpha.3
|
||||
*/
|
||||
public void load()
|
||||
@Override
|
||||
protected void onMount(ComponentDependencyManager manager)
|
||||
{
|
||||
Logger.log(SmartSeverity.MODULE, "Number of pre-added mod/s: " + this.loadList.size());
|
||||
|
||||
|
@ -229,13 +232,8 @@ public final class ModLoader extends PlutoLocalComponent
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author 493msi
|
||||
* @since 20.2.0.0-alpha.3
|
||||
*/
|
||||
public void unload()
|
||||
@Override
|
||||
protected void onUnmount()
|
||||
{
|
||||
this.loadingPhase = EnumModLoadingPhase.UNLOADING;
|
||||
Logger.log(SmartSeverity.MODULE_MINUS, "Unloading all mods.");
|
||||
|
|
Binary file not shown.
|
@ -7,10 +7,6 @@
|
|||
"path": "icons",
|
||||
"type": "open"
|
||||
},
|
||||
"fonts": {
|
||||
"path": "fonts.zip",
|
||||
"type": "zip"
|
||||
},
|
||||
"plutofonts": {
|
||||
"path": "plutofonts",
|
||||
"type": "open"
|
||||
|
|
Loading…
Reference in New Issue