aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/platform
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/platform')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/platform/GLPlatform.java17
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/platform/GuiPlatform.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/platform/I18nPlatform.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/platform/LoaderPlatform.java19
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/platform/MousePlatform.java15
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/platform/Platform.java55
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/platform/ServerPlatform.java7
7 files changed, 126 insertions, 0 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/platform/GLPlatform.java b/src/main/java/cc/polyfrost/oneconfig/platform/GLPlatform.java
new file mode 100644
index 0000000..b572527
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/platform/GLPlatform.java
@@ -0,0 +1,17 @@
+package cc.polyfrost.oneconfig.platform;
+
+import cc.polyfrost.oneconfig.libs.universal.UMatrixStack;
+
+public interface GLPlatform {
+ void drawRect(float x, float y, float x2, float y2, int color);
+
+ void enableStencil();
+
+ default float drawText(String text, float x, float y, int color, boolean shadow) {
+ return drawText(null, text, x, y, color, shadow);
+ }
+
+ float drawText(UMatrixStack matrixStack, String text, float x, float y, int color, boolean shadow);
+
+ int getStringWidth(String text);
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/platform/GuiPlatform.java b/src/main/java/cc/polyfrost/oneconfig/platform/GuiPlatform.java
new file mode 100644
index 0000000..b3e7221
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/platform/GuiPlatform.java
@@ -0,0 +1,8 @@
+package cc.polyfrost.oneconfig.platform;
+
+public interface GuiPlatform {
+ Object getCurrentScreen();
+ void setCurrentScreen(Object screen);
+ boolean isInChat();
+ boolean isInDebug();
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/platform/I18nPlatform.java b/src/main/java/cc/polyfrost/oneconfig/platform/I18nPlatform.java
new file mode 100644
index 0000000..bcc87a3
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/platform/I18nPlatform.java
@@ -0,0 +1,5 @@
+package cc.polyfrost.oneconfig.platform;
+
+public interface I18nPlatform {
+ String format(String key, Object... args);
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/platform/LoaderPlatform.java b/src/main/java/cc/polyfrost/oneconfig/platform/LoaderPlatform.java
new file mode 100644
index 0000000..b07efa2
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/platform/LoaderPlatform.java
@@ -0,0 +1,19 @@
+package cc.polyfrost.oneconfig.platform;
+
+public interface LoaderPlatform {
+ boolean isModLoaded(String id);
+ boolean hasActiveModContainer();
+ ActiveMod getActiveModContainer();
+
+ class ActiveMod {
+ public final String name;
+ public final String id;
+ public final String version;
+
+ public ActiveMod(String name, String id, String version) {
+ this.name = name;
+ this.id = id;
+ this.version = version;
+ }
+ }
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/platform/MousePlatform.java b/src/main/java/cc/polyfrost/oneconfig/platform/MousePlatform.java
new file mode 100644
index 0000000..add5f4f
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/platform/MousePlatform.java
@@ -0,0 +1,15 @@
+package cc.polyfrost.oneconfig.platform;
+
+public interface MousePlatform {
+ int getMouseX();
+ int getMouseY();
+ int getDWheel();
+ int getMouseDX();
+ int getMouseDY();
+
+ boolean next();
+ boolean getEventButtonState();
+ int getEventButton();
+
+ boolean isButtonDown(int button);
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/platform/Platform.java b/src/main/java/cc/polyfrost/oneconfig/platform/Platform.java
new file mode 100644
index 0000000..3eea049
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/platform/Platform.java
@@ -0,0 +1,55 @@
+package cc.polyfrost.oneconfig.platform;
+
+import java.util.ServiceLoader;
+
+/**
+ * Contains various platform-specific utilities for OneConfig.
+ *
+ * This is meant for internal usage, however other mods may use these (unless otherwise stated).
+ */
+public interface Platform {
+
+ static Platform getInstance() {
+ return PlatformHolder.INSTANCE.platform;
+ }
+
+ static MousePlatform getMousePlatform() {
+ return PlatformHolder.INSTANCE.mousePlatform;
+ }
+
+ static LoaderPlatform getLoaderPlatform() {
+ return PlatformHolder.INSTANCE.loaderPlatform;
+ }
+
+ static ServerPlatform getServerPlatform() {
+ return PlatformHolder.INSTANCE.serverPlatform;
+ }
+
+ static GLPlatform getGLPlatform() {
+ return PlatformHolder.INSTANCE.glPlatform;
+ }
+
+ static GuiPlatform getGuiPlatform() {
+ return PlatformHolder.INSTANCE.guiPlatform;
+ }
+
+ static I18nPlatform getI18nPlatform() {
+ return PlatformHolder.INSTANCE.i18nPlatform;
+ }
+
+ boolean isCallingFromMinecraftThread();
+
+ class PlatformHolder {
+ private PlatformHolder() {
+
+ }
+ static PlatformHolder INSTANCE = new PlatformHolder();
+ Platform platform = ServiceLoader.load(Platform.class, Platform.class.getClassLoader()).iterator().next();
+ MousePlatform mousePlatform = ServiceLoader.load(MousePlatform.class, MousePlatform.class.getClassLoader()).iterator().next();
+ LoaderPlatform loaderPlatform = ServiceLoader.load(LoaderPlatform.class, LoaderPlatform.class.getClassLoader()).iterator().next();
+ ServerPlatform serverPlatform = ServiceLoader.load(ServerPlatform.class, ServerPlatform.class.getClassLoader()).iterator().next();
+ GLPlatform glPlatform = ServiceLoader.load(GLPlatform.class, GLPlatform.class.getClassLoader()).iterator().next();
+ GuiPlatform guiPlatform = ServiceLoader.load(GuiPlatform.class, GuiPlatform.class.getClassLoader()).iterator().next();
+ I18nPlatform i18nPlatform = ServiceLoader.load(I18nPlatform.class, I18nPlatform.class.getClassLoader()).iterator().next();
+ }
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/platform/ServerPlatform.java b/src/main/java/cc/polyfrost/oneconfig/platform/ServerPlatform.java
new file mode 100644
index 0000000..01ab55d
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/platform/ServerPlatform.java
@@ -0,0 +1,7 @@
+package cc.polyfrost.oneconfig.platform;
+
+public interface ServerPlatform {
+ boolean inMultiplayer();
+
+ String getServerBrand();
+}