diff --git a/.gitignore b/.gitignore
index 1dad0af..3ce0840 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,5 @@
/*/.settings
/*/.project
/*/.classpath
-/.project
\ No newline at end of file
+/.project
+*.log
\ No newline at end of file
diff --git a/plutocore/pom.xml b/plutocore/pom.xml
new file mode 100644
index 0000000..497bcc6
--- /dev/null
+++ b/plutocore/pom.xml
@@ -0,0 +1,50 @@
+
+ 4.0.0
+ cz.tefek
+ plutocore
+ 0.1
+ plutocore
+ The foundation module for games and apps built on top of PlutoEngine.
+
+ 11
+ UTF-8
+ UTF-8
+
+
+
+ cz.tefek
+ plutotexturing
+ 0.1
+
+
+ cz.tefek
+ plutoshader
+ 0.3
+
+
+ cz.tefek
+ plutogui
+ 0.2
+
+
+ cz.tefek
+ plutomesher
+ 0.2
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+ 11
+ UTF-8
+
+
+
+
+
\ No newline at end of file
diff --git a/plutocore/src/main/java/cz/tefek/pluto/PlutoApplication.java b/plutocore/src/main/java/cz/tefek/pluto/PlutoApplication.java
new file mode 100644
index 0000000..5dcbae4
--- /dev/null
+++ b/plutocore/src/main/java/cz/tefek/pluto/PlutoApplication.java
@@ -0,0 +1,90 @@
+package cz.tefek.pluto;
+
+import java.util.Locale;
+
+import org.lwjgl.glfw.GLFW;
+import org.lwjgl.opengl.GL;
+import org.lwjgl.opengl.GL33;
+
+import cz.tefek.io.modloader.ModLoaderCore;
+import cz.tefek.io.pluto.debug.Logger;
+import cz.tefek.io.pluto.debug.SmartSeverity;
+import cz.tefek.l10n.PlutoL10n;
+import cz.tefek.pluto.engine.buffer.GLFWImageUtil;
+import cz.tefek.pluto.engine.display.Display;
+import cz.tefek.pluto.engine.display.DisplayBuilder;
+import cz.tefek.pluto.engine.input.InputBus;
+
+public abstract class PlutoApplication
+{
+ public static final boolean DEBUG_MODE = Boolean.valueOf(System.getProperty("cz.tefek.pluto.debug"));
+
+ protected Display display;
+
+ protected abstract Class> getMainModule();
+
+ protected abstract void loop();
+
+ public final void run(String[] args)
+ {
+ Logger.setup();
+
+ Logger.log(SmartSeverity.INFO, "Debug mode: " + (DEBUG_MODE ? "enabled" : "disabled"));
+
+ PlutoL10n.init(Locale.UK);
+
+ DisplayBuilder.initGLFW();
+
+ this.display = new DisplayBuilder().hintOpenGLVersion(3, 3).hintDebugContext(DEBUG_MODE).hintMSAA(4).hintVisible(true).hintResizeable(true).setInitialSize(1280, 720).export();
+
+ this.display.create("Stardust Miner");
+
+ this.display.setWindowSizeLimits(1000, 600, GLFW.GLFW_DONT_CARE, GLFW.GLFW_DONT_CARE);
+
+ this.display.lockSwapInterval(0);
+
+ this.display.show();
+
+ var icons = GLFWImageUtil.loadIconSet("data/icon16.png", "data/icon32.png", "data/icon64.png", "data/icon128.png");
+
+ this.display.setIcons(icons);
+
+ this.display.createOpenGLCapabilities();
+
+ InputBus.init(this.display);
+
+ ModLoaderCore.registerMod(this.getMainModule());
+
+ ModLoaderCore.loadProcedure();
+
+ while (!this.display.isClosing())
+ {
+ GL33.glViewport(0, 0, this.display.getWidth(), this.display.getHeight());
+ GL33.glClearColor(0f, 0.7f, 1f, 0f);
+ GL33.glClear(GL33.GL_COLOR_BUFFER_BIT | GL33.GL_DEPTH_BUFFER_BIT);
+
+ this.loop();
+
+ this.display.swapBuffers();
+
+ InputBus.resetStates();
+
+ this.display.pollEvents();
+ }
+
+ InputBus.destroy();
+
+ ModLoaderCore.unloadProcedure();
+
+ GL.destroy();
+
+ this.display.destroy();
+
+ DisplayBuilder.destroyGLFW();
+ }
+
+ public Display getDisplayInstance()
+ {
+ return this.display;
+ }
+}
diff --git a/plutocore/src/main/java/cz/tefek/pluto/engine/input/CursorPositionCallback.java b/plutocore/src/main/java/cz/tefek/pluto/engine/input/CursorPositionCallback.java
new file mode 100644
index 0000000..a655b96
--- /dev/null
+++ b/plutocore/src/main/java/cz/tefek/pluto/engine/input/CursorPositionCallback.java
@@ -0,0 +1,55 @@
+package cz.tefek.pluto.engine.input;
+
+import org.lwjgl.glfw.GLFWCursorPosCallback;
+
+public class CursorPositionCallback extends GLFWCursorPosCallback
+{
+ private double posX;
+ private double posY;
+
+ private double deltaX;
+ private double deltaY;
+
+ @Override
+ public void invoke(long window, double xpos, double ypos)
+ {
+ this.deltaX = this.posX - xpos;
+ this.deltaY = this.posY - ypos;
+
+ this.posX = xpos;
+ this.posY = ypos;
+ }
+
+ public void reset()
+ {
+ this.deltaX = 0;
+ this.deltaY = 0;
+ }
+
+ public double getX()
+ {
+ return this.posX;
+ }
+
+ public double getY()
+ {
+ return this.posY;
+ }
+
+ public double getDeltaX()
+ {
+ return this.deltaX;
+ }
+
+ public double getDeltaY()
+ {
+ return this.deltaY;
+ }
+
+ public boolean isInside(int x, int y, int x2, int y2)
+ {
+ boolean inside = this.getX() > x && this.getX() < x2 && this.getY() > y && this.getY() < y2;
+
+ return inside;
+ }
+}
diff --git a/plutocore/src/main/java/cz/tefek/pluto/engine/input/InputBus.java b/plutocore/src/main/java/cz/tefek/pluto/engine/input/InputBus.java
new file mode 100644
index 0000000..2f5e0ad
--- /dev/null
+++ b/plutocore/src/main/java/cz/tefek/pluto/engine/input/InputBus.java
@@ -0,0 +1,138 @@
+package cz.tefek.pluto.engine.input;
+
+import org.lwjgl.glfw.GLFW;
+
+import cz.tefek.pluto.engine.display.Display;
+
+public class InputBus
+{
+ private static ThreadLocal keyboard = new ThreadLocal<>();
+ private static ThreadLocal mouseButton = new ThreadLocal<>();
+ private static ThreadLocal cursorPosition = new ThreadLocal<>();
+ private static ThreadLocal scroll = new ThreadLocal<>();
+
+ public static void init(Display display)
+ {
+ keyboard.set(new KeyboardInputCallback());
+ GLFW.glfwSetKeyCallback(display.getWindowPointer(), keyboard.get());
+
+ mouseButton.set(new MouseButtonCallback());
+ GLFW.glfwSetMouseButtonCallback(display.getWindowPointer(), mouseButton.get());
+
+ cursorPosition.set(new CursorPositionCallback());
+ GLFW.glfwSetCursorPosCallback(display.getWindowPointer(), cursorPosition.get());
+
+ scroll.set(new ScrollInputCallback());
+ GLFW.glfwSetScrollCallback(display.getWindowPointer(), scroll.get());
+
+ }
+
+ public static void destroy()
+ {
+ scroll.get().free();
+ scroll.remove();
+ mouseButton.get().free();
+ mouseButton.remove();
+ keyboard.get().free();
+ keyboard.remove();
+ cursorPosition.get().free();
+ cursorPosition.remove();
+ }
+
+ public static KeyboardInputCallback keyboard()
+ {
+ return keyboard.get();
+ }
+
+ public static MouseButtonCallback mouseButtons()
+ {
+ return mouseButton.get();
+ }
+
+ public static ScrollInputCallback scroll()
+ {
+ return scroll.get();
+ }
+
+ public static CursorPositionCallback cursorPosition()
+ {
+ return cursorPosition.get();
+ }
+
+ public static void resetStates()
+ {
+ keyboard.get().resetPressed();
+ mouseButton.get().reset();
+ scroll.get().reset();
+ cursorPosition.get().reset();
+ }
+
+ public static class Mouse
+ {
+ public static boolean clicked(int button)
+ {
+ var mb = mouseButton.get();
+ return mb.buttonClicked[button];
+ }
+
+ public static boolean released(int button)
+ {
+ var mb = mouseButton.get();
+ return mb.buttonReleased[button];
+ }
+
+ public static boolean isButtonDown(int button)
+ {
+ var mb = mouseButton.get();
+ return mb.buttonDown[button];
+ }
+
+ public static double getX()
+ {
+ return cursorPosition.get().getX();
+ }
+
+ public static double getY()
+ {
+ return cursorPosition.get().getY();
+ }
+
+ public static double getDX()
+ {
+ return cursorPosition.get().getDeltaX();
+ }
+
+ public static double getDY()
+ {
+ return cursorPosition.get().getDeltaY();
+ }
+
+ public static double getScrollX()
+ {
+ return scroll.get().getXScroll();
+ }
+
+ public static double getScrollY()
+ {
+ return scroll.get().getYScroll();
+ }
+ }
+
+ public static class Keyboard
+ {
+ public static boolean pressed(int key)
+ {
+ return keyboard.get().hasBeenPressed(key);
+ }
+
+ public static boolean released(int key)
+ {
+ return keyboard.get().hasBeenReleased(key);
+ }
+
+ public static boolean isKeyDown(int key)
+ {
+ return keyboard.get().isKeyDown(key);
+ }
+ }
+}
diff --git a/plutocore/src/main/java/cz/tefek/pluto/engine/input/KeyboardInputCallback.java b/plutocore/src/main/java/cz/tefek/pluto/engine/input/KeyboardInputCallback.java
new file mode 100644
index 0000000..9da815c
--- /dev/null
+++ b/plutocore/src/main/java/cz/tefek/pluto/engine/input/KeyboardInputCallback.java
@@ -0,0 +1,58 @@
+package cz.tefek.pluto.engine.input;
+
+import static org.lwjgl.glfw.GLFW.GLFW_PRESS;
+import static org.lwjgl.glfw.GLFW.GLFW_RELEASE;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.lwjgl.glfw.GLFWKeyCallback;
+
+public class KeyboardInputCallback extends GLFWKeyCallback
+{
+ private Set keyPressed = new HashSet<>();
+ private Set keyDown = new HashSet<>();
+ private Set keyReleased = new HashSet<>();
+
+ @Override
+ public void invoke(long window, int key, int scancode, int action, int mods)
+ {
+ if (key < 0)
+ {
+ return;
+ }
+
+ if (action == GLFW_PRESS)
+ {
+ this.keyDown.add(key);
+ this.keyPressed.add(key);
+ }
+
+ if (action == GLFW_RELEASE)
+ {
+ this.keyDown.remove(key);
+ this.keyReleased.add(key);
+ }
+ }
+
+ public void resetPressed()
+ {
+ this.keyPressed.clear();
+ this.keyReleased.clear();
+ }
+
+ public boolean hasBeenPressed(int key)
+ {
+ return this.keyPressed.contains(key);
+ }
+
+ public boolean hasBeenReleased(int key)
+ {
+ return this.keyReleased.contains(key);
+ }
+
+ public boolean isKeyDown(int key)
+ {
+ return this.keyDown.contains(key);
+ }
+}
diff --git a/plutocore/src/main/java/cz/tefek/pluto/engine/input/MouseButtonCallback.java b/plutocore/src/main/java/cz/tefek/pluto/engine/input/MouseButtonCallback.java
new file mode 100644
index 0000000..7602e31
--- /dev/null
+++ b/plutocore/src/main/java/cz/tefek/pluto/engine/input/MouseButtonCallback.java
@@ -0,0 +1,33 @@
+package cz.tefek.pluto.engine.input;
+
+import org.lwjgl.glfw.GLFW;
+import org.lwjgl.glfw.GLFWMouseButtonCallback;
+
+public class MouseButtonCallback extends GLFWMouseButtonCallback
+{
+ public boolean[] buttonClicked = new boolean[32];
+ public boolean[] buttonDown = new boolean[32];
+ public boolean[] buttonReleased = new boolean[32];
+
+ @Override
+ public void invoke(long window, int button, int action, int mods)
+ {
+ this.buttonClicked[button] = action == GLFW.GLFW_PRESS;
+ this.buttonDown[button] = action != GLFW.GLFW_RELEASE;
+ this.buttonReleased[button] = action == GLFW.GLFW_RELEASE;
+ }
+
+ public void reset()
+ {
+ for (int i = 0; i < this.buttonClicked.length; i++)
+ {
+ this.buttonClicked[i] = false;
+ }
+
+ for (int i = 0; i < this.buttonClicked.length; i++)
+ {
+ this.buttonReleased[i] = false;
+ }
+ }
+
+}
diff --git a/plutocore/src/main/java/cz/tefek/pluto/engine/input/ScrollInputCallback.java b/plutocore/src/main/java/cz/tefek/pluto/engine/input/ScrollInputCallback.java
new file mode 100644
index 0000000..406090a
--- /dev/null
+++ b/plutocore/src/main/java/cz/tefek/pluto/engine/input/ScrollInputCallback.java
@@ -0,0 +1,46 @@
+package cz.tefek.pluto.engine.input;
+
+import org.lwjgl.glfw.GLFWScrollCallback;
+
+/**
+ * @author 493msi
+ *
+ */
+public class ScrollInputCallback extends GLFWScrollCallback
+{
+ private double xScroll;
+ private double yScroll;
+
+ @Override
+ public void invoke(long window, double xoffset, double yoffset)
+ {
+ xScroll = xoffset;
+ yScroll = yoffset;
+ }
+
+ public void reset()
+ {
+ xScroll = 0;
+ yScroll = 0;
+ }
+
+ public double getYScroll()
+ {
+ return yScroll;
+ }
+
+ public void setYScroll(double yScroll)
+ {
+ this.yScroll = yScroll;
+ }
+
+ public double getXScroll()
+ {
+ return xScroll;
+ }
+
+ public void setXScroll(double xScroll)
+ {
+ this.xScroll = xScroll;
+ }
+}
diff --git a/plutoio2/src/main/java/cz/tefek/io/modloader/ModClassLoader.java b/plutoio2/src/main/java/cz/tefek/io/modloader/ModClassLoader.java
index d37c067..6988278 100644
--- a/plutoio2/src/main/java/cz/tefek/io/modloader/ModClassLoader.java
+++ b/plutoio2/src/main/java/cz/tefek/io/modloader/ModClassLoader.java
@@ -1,16 +1,18 @@
package cz.tefek.io.modloader;
-import java.io.File;
-import java.net.URL;
-import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
import cz.tefek.io.asl.resource.ResourceHelper;
import cz.tefek.io.pluto.debug.Logger;
+import cz.tefek.io.pluto.debug.SmartSeverity;
/**
* Class-loads all valid mods. The only requirement for the mod is to have a
@@ -25,7 +27,7 @@ public class ModClassLoader
public static void loadJars()
{
- Logger.log("[Pluto Mod Loader] Looking for installed mods.");
+ Logger.log(SmartSeverity.MODULE, "Looking for installed mods.");
File modDir = new File(ResourceHelper.GLOBAL_ROOT + "mods/");
@@ -33,7 +35,7 @@ public class ModClassLoader
{
modDir.mkdir();
- Logger.log("[Pluto Mod Loader] No mod found.");
+ Logger.log(SmartSeverity.MODULE, " No mod found.");
return;
}
@@ -42,11 +44,11 @@ public class ModClassLoader
if (mods.size() == 0)
{
- Logger.log("[Pluto Mod Loader] No mod found.");
+ Logger.log(SmartSeverity.MODULE, "No mod found.");
}
else
{
- Logger.log("[Pluto Mod Loader] Found " + mods.size() + " mod(s) to load.");
+ Logger.log(SmartSeverity.MODULE, "Found " + mods.size() + " mod(s) to load.");
try
{
@@ -67,11 +69,11 @@ public class ModClassLoader
{
if (mods.size() == 1)
{
- Logger.log("[Pluto Mod Loader] There is one mod to load.");
+ Logger.log(SmartSeverity.MODULE, "There is one mod to load.");
}
else
{
- Logger.log("[Pluto Mod Loader] There are " + mods.size() + " mods to load.");
+ Logger.log(SmartSeverity.MODULE, "There are " + mods.size() + " mods to load.");
}
for (String modname : mods)
@@ -125,28 +127,28 @@ public class ModClassLoader
jarFile.close();
- Logger.log("[Pluto Mod Loader] Loaded mod jar file: " + modname + "/mod.jar");
+ Logger.log(SmartSeverity.MODULE_PLUS, "Loaded mod jar file: " + modname + "/mod.jar");
i++;
}
else
{
- Logger.log("[Pluto Mod Loader] Failed to load mod jar file: " + modname + ".");
- Logger.log("[Pluto Mod Loader] Reason: Missing mod.jar file.");
+ Logger.log(SmartSeverity.MODULE_WARNING, "Failed to load mod jar file: " + modname + ".");
+ Logger.log(SmartSeverity.MODULE_WARNING, "Reason: Missing mod.jar file.");
}
}
if (i < 1 || i == 0)
{
- System.out.println("[Pluto Mod Loader] Loading mods complete, loaded " + i + " mods.");
+ Logger.log(SmartSeverity.MODULE, "Loading mods complete, loaded " + i + " mods.");
}
else
{
- System.out.println("[Pluto Mod Loader] Loading mods complete, loaded " + i + " mod.");
+ Logger.log(SmartSeverity.MODULE, "Loading mods complete, loaded " + i + " mod.");
}
}
else
{
- Logger.log("[Pluto Mod Loader] There aren't any mods, skipping initialising phase.");
+ Logger.log(SmartSeverity.MODULE, "There aren't any mods, skipping initialising phase.");
}
}
}
diff --git a/plutoio2/src/main/java/cz/tefek/io/modloader/ModInstaller.java b/plutoio2/src/main/java/cz/tefek/io/modloader/ModInstaller.java
index 94ef7f3..f93ed27 100644
--- a/plutoio2/src/main/java/cz/tefek/io/modloader/ModInstaller.java
+++ b/plutoio2/src/main/java/cz/tefek/io/modloader/ModInstaller.java
@@ -13,10 +13,12 @@ import java.io.InputStream;
import cz.tefek.io.asl.resource.ResourceHelper;
import cz.tefek.io.pluto.debug.Logger;
-import cz.tefek.io.pluto.debug.Severity;
+import cz.tefek.io.pluto.debug.SmartSeverity;
/**
* Unzips mod packages from the packages folder into the mods folder. WIP
+ *
+ * 2020 Update: Still WIP
*
* @author 493msi
*/
@@ -24,14 +26,14 @@ public class ModInstaller
{
public static void unpackNewMods()
{
- Logger.log("[Pluto Mod Loader] Looking for new mod packages to install.");
+ Logger.log(SmartSeverity.MODULE, "Looking for new mod packages to install.");
File f = new File(ResourceHelper.GLOBAL_ROOT + "packages/");
if (!f.exists())
{
f.mkdir();
- Logger.log("[Pluto Mod Loader] Package folder does not exist, creating it and aborting unpacking.");
+ Logger.log(SmartSeverity.MODULE, "Package folder does not exist, creating it and aborting unpacking.");
return;
}
@@ -40,15 +42,15 @@ public class ModInstaller
if (files.size() == 0)
{
- Logger.log("[Pluto Mod Loader] No mod package found.");
+ Logger.log(SmartSeverity.MODULE, "No mod package found.");
}
else
{
- Logger.log("[Pluto Mod Loader] Found " + files.size() + " mod packages.");
+ Logger.log(SmartSeverity.MODULE_PLUS, "Found " + files.size() + " mod packages.");
for (String file : files)
{
- Logger.log("[Pluto Mod Loader] Mod package found: " + file + ", installing it.");
+ Logger.log(SmartSeverity.MODULE_PLUS, "Mod package found: " + file + ", installing it.");
try
{
@@ -56,7 +58,7 @@ public class ModInstaller
}
catch (IOException e)
{
- Logger.log(Severity.ERROR, "Unpacking of " + file + " failed!");
+ Logger.log(SmartSeverity.MODULE_ERROR, "Unpacking of " + file + " failed!");
Logger.logException(e);
}
diff --git a/plutoio2/src/main/java/cz/tefek/io/modloader/ModLoaderCore.java b/plutoio2/src/main/java/cz/tefek/io/modloader/ModLoaderCore.java
index 3f1d704..1a6d954 100644
--- a/plutoio2/src/main/java/cz/tefek/io/modloader/ModLoaderCore.java
+++ b/plutoio2/src/main/java/cz/tefek/io/modloader/ModLoaderCore.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import java.util.Queue;
import cz.tefek.io.asl.resource.ResourceHelper;
import cz.tefek.io.modloader.event.ModLoad;
@@ -20,26 +21,26 @@ import cz.tefek.pluto.eventsystem.staticmode.StaticPlutoEventManager;
public class ModLoaderCore
{
- public static final String MOD_ID_STRING_PATTERN = "[a-z0-9_]+";
+ public static final String MOD_ID_STRING_PATTERN = "[a-z0-9]+[a-z0-9_]*";
public static final String FULL_MOD_ID_STRING_PATTERN = "^" + MOD_ID_STRING_PATTERN + "$";
static ModLoadingPhase loadingPhase = ModLoadingPhase.WAITING;
private static final List modArchive = new ArrayList<>();
- private static final LinkedList loadBuffer = new LinkedList<>();
+ private static final Queue loadBuffer = new LinkedList<>();
public static void registerMod(Class> modClass, String modDataRoot)
{
if (loadingPhase != ModLoadingPhase.WAITING && loadingPhase != ModLoadingPhase.CLASSLOADING)
{
- Logger.log(SmartSeverity.ERROR, "Cannot register mod during loading phase " + loadingPhase.name() + "!");
+ Logger.log(SmartSeverity.MODULE_ERROR, "Cannot register mod during loading phase " + loadingPhase.name() + "!");
return;
}
if (getModByMainClass(modClass) != null)
{
- Logger.log(SmartSeverity.WARNING, "[Pluto Mod Loader] Mod class " + modClass.getCanonicalName() + " is already registered, skipping it.");
+ Logger.log(SmartSeverity.MODULE_WARNING, "Mod class " + modClass.getCanonicalName() + " is already registered, skipping it.");
return;
}
@@ -66,8 +67,8 @@ public class ModLoaderCore
if (!mod.getModID().matches(FULL_MOD_ID_STRING_PATTERN))
{
- Logger.log(SmartSeverity.WARNING, "[Pluto Mod Loader] Modid " + mod.getModID() + " contains invalid characters (or none at all), mod will not be loaded.");
- Logger.log(SmartSeverity.WARNING, "[Pluto Mod Loader] Only lowercase letters (a to z) and numbers (0 to 9) are allowed characters.");
+ Logger.log(SmartSeverity.MODULE_WARNING, "Mod id " + mod.getModID() + " contains invalid characters (or none at all), mod will not be loaded.");
+ Logger.log(SmartSeverity.MODULE_WARNING, "Only lowercase letters (a to z) and numbers (0 to 9) are allowed characters.");
return;
}
@@ -142,23 +143,23 @@ public class ModLoaderCore
while (loadBuffer.peek() != null)
{
- var mod = loadBuffer.removeFirst();
+ var mod = loadBuffer.remove();
StaticPlutoEventManager.registerEventHandler(mod.getMainClass());
modArchive.add(mod);
}
if (!modArchive.isEmpty())
{
- Logger.log("[Pluto Mod Loader] Initializing mod(s)...");
+ Logger.log(SmartSeverity.MODULE, "Initializing mod(s)...");
initMods();
if (loadingPhase == ModLoadingPhase.FINISHING)
{
- Logger.log("[Pluto Mod Loader] Initializing mod(s) finished.");
+ Logger.log(SmartSeverity.MODULE, "Initializing mod(s) finished.");
}
else
{
- Logger.log("[Pluto Mod Loader] Initializing mod(s) was canceled due to error(s).");
+ Logger.log(SmartSeverity.MODULE_ERROR, "Initializing mod(s) was canceled due to error(s).");
}
}
}
@@ -189,7 +190,7 @@ public class ModLoaderCore
public static void unloadProcedure()
{
- Logger.log("[Pluto Mod Loader] Unloading all mods.");
+ Logger.log(SmartSeverity.MODULE_MINUS, "Unloading all mods.");
StaticPlutoEventManager.fireEvent(ModUnload.class, new ModUnloadEvent());
modArchive.clear();
}
@@ -207,8 +208,8 @@ public class ModLoaderCore
}
catch (Exception e)
{
- Logger.log("[Pluto Mod Loader] Problem encountered while preloading mods.");
- Logger.log("[Pluto Mod Loader] Mod loading stopped.");
+ Logger.log(SmartSeverity.MODULE_ERROR, "Problem encountered while pre-loading mods.");
+ Logger.log(SmartSeverity.MODULE_ERROR, "Mod loading stopped.");
Logger.logException(e);
@@ -228,8 +229,8 @@ public class ModLoaderCore
}
catch (Exception e)
{
- Logger.log("[Pluto Mod Loader] Problem encountered while loading mods.");
- Logger.log("[Pluto Mod Loader] Mod loading stopped.");
+ Logger.log(SmartSeverity.MODULE_ERROR, "Problem encountered while loading mods.");
+ Logger.log(SmartSeverity.MODULE_ERROR, "Mod loading stopped.");
Logger.logException(e);
@@ -249,8 +250,8 @@ public class ModLoaderCore
}
catch (Exception e)
{
- Logger.log("[Pluto Mod Loader] Problem encountered while loading mods.");
- Logger.log("[Pluto Mod Loader] Mod loading stopped.");
+ Logger.log(SmartSeverity.MODULE_ERROR, "Problem encountered while post-loading mods.");
+ Logger.log(SmartSeverity.MODULE_ERROR, "Mod loading stopped.");
Logger.logException(e);
diff --git a/plutoio2/src/main/java/cz/tefek/io/pluto/debug/Logger.java b/plutoio2/src/main/java/cz/tefek/io/pluto/debug/Logger.java
index f1eca71..ecf1d71 100644
--- a/plutoio2/src/main/java/cz/tefek/io/pluto/debug/Logger.java
+++ b/plutoio2/src/main/java/cz/tefek/io/pluto/debug/Logger.java
@@ -61,37 +61,37 @@ public class Logger
System.out.close();
}
- public static void log(Object string)
+ public static synchronized void log(Object string)
{
log(Severity.NONE, string);
}
- public static void logf(String string, Object... o)
+ public static synchronized void logf(String string, Object... o)
{
System.out.printf(string, o);
}
- public static void logNoLine(Object string)
+ public static synchronized void logNoLine(Object string)
{
System.out.print(string);
}
- public static void logException(Exception e)
+ public static synchronized void logException(Exception e)
{
e.printStackTrace();
}
- public static void log(ISeverity s, Object string)
+ public static synchronized void log(ISeverity s, Object string)
{
(s.isStdErr() ? System.err : System.out).println(s.getDisplayName() + string);
}
- public static void logf(ISeverity s, String string, Object... o)
+ public static synchronized void logf(ISeverity s, String string, Object... o)
{
(s.isStdErr() ? System.err : System.out).printf(s.getDisplayName() + string, o);
}
- public static void logNoLine(ISeverity s, Object string)
+ public static synchronized void logNoLine(ISeverity s, Object string)
{
(s.isStdErr() ? System.err : System.out).print(s.getDisplayName() + string);
}
diff --git a/plutoio2/src/main/java/cz/tefek/io/pluto/debug/SmartSeverity.java b/plutoio2/src/main/java/cz/tefek/io/pluto/debug/SmartSeverity.java
index cefe00b..2482cc2 100644
--- a/plutoio2/src/main/java/cz/tefek/io/pluto/debug/SmartSeverity.java
+++ b/plutoio2/src/main/java/cz/tefek/io/pluto/debug/SmartSeverity.java
@@ -9,10 +9,26 @@ public enum SmartSeverity implements ISeverity
{
ADDED("[+] ", false),
REMOVED("[-] ", false),
+
ZERO("[0] ", false),
+
INFO("[i] ", false),
WARNING("[!] ", true),
- ERROR("[X] ", true);
+ ERROR("[X] ", true),
+
+ AUDIO("[♪] ", false),
+
+ MODULE("[i] [M] ", false),
+ MODULE_PLUS("[+] [M] ", false),
+ MODULE_MINUS("[-] [M] ", false),
+ MODULE_WARNING("[!] [M] ", true),
+ MODULE_ERROR("[X] [M] ", true),
+
+ EVENT("[i] [E] ", false),
+ EVENT_PLUS("[+] [E] ", false),
+ EVENT_MINUS("[-] [E] ", false),
+ EVENT_WARNING("[!] [E] ", true),
+ EVENT_ERROR("[X] [E] ", true);
private String displayName;
private boolean usesStdErr;
diff --git a/plutoio2/src/main/java/cz/tefek/pluto/eventsystem/staticmode/StaticPlutoEventManager.java b/plutoio2/src/main/java/cz/tefek/pluto/eventsystem/staticmode/StaticPlutoEventManager.java
index 56e818c..59f59ef 100644
--- a/plutoio2/src/main/java/cz/tefek/pluto/eventsystem/staticmode/StaticPlutoEventManager.java
+++ b/plutoio2/src/main/java/cz/tefek/pluto/eventsystem/staticmode/StaticPlutoEventManager.java
@@ -11,7 +11,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import cz.tefek.io.pluto.debug.Logger;
-import cz.tefek.io.pluto.debug.Severity;
+import cz.tefek.io.pluto.debug.SmartSeverity;
import cz.tefek.pluto.eventsystem.EventData;
/**
@@ -68,7 +68,7 @@ public class StaticPlutoEventManager
}
}
- Logger.log(Severity.INFO, "Event handler " + clazz.getCanonicalName() + " scan found " + methodsFound + " method callback(s).");
+ Logger.log(SmartSeverity.EVENT_PLUS, "Event handler " + clazz.getCanonicalName() + " scan found " + methodsFound + " method callback(s).");
}
public static void registerEvent(Class extends Annotation> annotation)
@@ -78,14 +78,14 @@ public class StaticPlutoEventManager
{
if (eventRegistry.containsKey(annotation))
{
- Logger.log(Severity.ERROR, "Annotation " + annotation.getCanonicalName() + " is already registered!");
+ Logger.log(SmartSeverity.EVENT_ERROR, "Annotation " + annotation.getCanonicalName() + " is already registered!");
return;
}
else
{
eventRegistry.put(annotation, new ArrayList());
- Logger.log(Severity.INFO, "Event " + annotation.getCanonicalName() + " successfully registered!");
+ Logger.log(SmartSeverity.EVENT_PLUS, "Event " + annotation.getCanonicalName() + " successfully registered!");
short retroactivelyFound = 0;
@@ -110,7 +110,7 @@ public class StaticPlutoEventManager
}
}
- Logger.log(Severity.INFO, "Retroactive method checking found " + retroactivelyFound + " item(s).");
+ Logger.log(SmartSeverity.EVENT_PLUS, "Retroactive method checking found " + retroactivelyFound + " item(s).");
// Let's check the Method orphanage for some potential
// candidates.
@@ -138,12 +138,12 @@ public class StaticPlutoEventManager
orphans.removeAll(foundParents);
- Logger.log(Severity.INFO, orphansFound + " orphan method(s) was/were bound and " + (orphansBefore - orphans.size()) + " removed from the storage!");
+ Logger.log(SmartSeverity.EVENT_PLUS, orphansFound + " orphan method(s) was/were bound and " + (orphansBefore - orphans.size()) + " removed from the storage!");
}
}
else
{
- Logger.log(Severity.ERROR, "Annotation " + annotation.getCanonicalName() + " is not annotated with @Event, can't register it.");
+ Logger.log(SmartSeverity.EVENT_ERROR, "Annotation " + annotation.getCanonicalName() + " is not annotated with @Event, can't register it.");
}
}
@@ -168,7 +168,7 @@ public class StaticPlutoEventManager
if (params.length == 0)
{
- Logger.log(Severity.WARNING, "Method " + m.toGenericString() + " has no parameters, will not be invoked by event!");
+ Logger.log(SmartSeverity.EVENT_WARNING, "Method " + m.toGenericString() + " has no parameters, will not be invoked by event!");
}
for (int i = 0; i < params.length; i++)
@@ -177,7 +177,7 @@ public class StaticPlutoEventManager
if (!EventData.class.isAssignableFrom(parameter))
{
- Logger.log(Severity.ERROR, "Method " + m.toGenericString() + " contains invalid parameters. Only EventData instances are permitted.");
+ Logger.log(SmartSeverity.EVENT_ERROR, "Method " + m.toGenericString() + " contains invalid parameters. Only EventData instances are permitted.");
mostSuitableParam = null;
break;
}
@@ -211,12 +211,12 @@ public class StaticPlutoEventManager
}
else
{
- Logger.log(Severity.ERROR, "There is no event like " + event.getCanonicalName() + " registered.");
+ Logger.log(SmartSeverity.EVENT_ERROR, "There is no event like " + event.getCanonicalName() + " registered.");
}
}
else
{
- Logger.log(Severity.ERROR, event.getCanonicalName() + " is not an event!");
+ Logger.log(SmartSeverity.EVENT_ERROR, event.getCanonicalName() + " is not an event!");
}
}
diff --git a/plutoio2/src/main/java/cz/tefek/tpl/TPL.java b/plutoio2/src/main/java/cz/tefek/tpl/TPL.java
index 6c4d473..e6efa60 100644
--- a/plutoio2/src/main/java/cz/tefek/tpl/TPL.java
+++ b/plutoio2/src/main/java/cz/tefek/tpl/TPL.java
@@ -24,7 +24,7 @@ import cz.tefek.io.pluto.debug.SmartSeverity;
public class TPL
{
private static final int PLACEHOLDER_SIZE = 16;
- private static final int PLACEHOLDER_CHECKEDBOARD = 16;
+ private static final int PLACEHOLDER_CHECKEDBOARD = 8;
private static final int PLACEHOLDER_CHECKEDBOARD_SQUARE_SIZE = PLACEHOLDER_SIZE / PLACEHOLDER_CHECKEDBOARD;
public static TPNImage load(ResourceAddress file)
diff --git a/plutospritesheet/src/main/java/cz/tefek/pluto/engine/graphics/spritesheet/TiledSpriteSheet.java b/plutospritesheet/src/main/java/cz/tefek/pluto/engine/graphics/spritesheet/TiledSpriteSheet.java
index df512fa..ff2a3d6 100644
--- a/plutospritesheet/src/main/java/cz/tefek/pluto/engine/graphics/spritesheet/TiledSpriteSheet.java
+++ b/plutospritesheet/src/main/java/cz/tefek/pluto/engine/graphics/spritesheet/TiledSpriteSheet.java
@@ -100,21 +100,24 @@ public abstract class TiledSpriteSheet extends SpriteSheet
public abstract void copyToNewImage();
- public TileSprite> addSprite(Sprite sprite, int index)
+ public TileSprite> addSpriteSpecial(Sprite sprite, int index, boolean allowSpriteDownscaling)
{
- if (!this.aspectRatiosMatch(sprite))
+ if (!allowSpriteDownscaling)
{
- throw new IllegalArgumentException("Sprite and spritesheet aspect ratios do not match!");
- }
+ if (!this.aspectRatiosMatch(sprite))
+ {
+ throw new IllegalArgumentException("Sprite and spritesheet aspect ratios do not match!");
+ }
- if (!this.isMultiple(sprite))
- {
- throw new IllegalArgumentException("The sprite and the spritesheet do not have a common resolution to scale to.");
- }
+ if (!this.isMultiple(sprite))
+ {
+ throw new IllegalArgumentException("The sprite and the spritesheet do not have a common resolution to scale to.");
+ }
- if (sprite.getWidth() > this.tileWidth)
- {
- this.upscale(sprite.getWidth() / this.tileWidth);
+ if (sprite.getWidth() > this.tileWidth)
+ {
+ this.upscale(sprite.getWidth() / this.tileWidth);
+ }
}
while (this.requiresExpanding(index))
@@ -143,6 +146,11 @@ public abstract class TiledSpriteSheet extends SpriteSheet
return copySprite;
}
+ public TileSprite> addSprite(Sprite sprite, int index)
+ {
+ return this.addSpriteSpecial(sprite, index, false);
+ }
+
private boolean aspectRatiosMatch(Sprite> sprite)
{
final var epsilon = 0.001f;
diff --git a/plutostatic/pom.xml b/plutostatic/pom.xml
index 667f53d..b900885 100644
--- a/plutostatic/pom.xml
+++ b/plutostatic/pom.xml
@@ -11,7 +11,7 @@
UTF-8
UTF-8
3.2.3
- 1.9.17
+ 1.9.25
1.8.0
1.8.0
@@ -119,8 +119,6 @@
org.lwjgl
lwjgl-stb
-
org.lwjgl
lwjgl
@@ -171,13 +169,6 @@
lwjgl-stb
${lwjgl.natives}
-
-
- org.joml
- joml
- ${joml.version}
-
com.code-disaster.steamworks4j
steamworks4j
diff --git a/plutostatic/src/main/java/cz/tefek/pluto/engine/math/collision/CollisionClass.java b/plutostatic/src/main/java/cz/tefek/pluto/engine/math/collision/CollisionClass.java
index 8982a38..b2ece82 100644
--- a/plutostatic/src/main/java/cz/tefek/pluto/engine/math/collision/CollisionClass.java
+++ b/plutostatic/src/main/java/cz/tefek/pluto/engine/math/collision/CollisionClass.java
@@ -21,4 +21,10 @@ public class CollisionClass
{
return this.selfCollision;
}
+
+ @Override
+ public int hashCode()
+ {
+ return this.id;
+ }
}