diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java
index 7934972a5..038433e84 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java
@@ -31,7 +31,7 @@ import com.seibel.distanthorizons.core.config.types.enums.*;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.pos.DhSectionPos;
-import com.seibel.distanthorizons.core.util.NativeDialogUtil;
+import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
import com.seibel.distanthorizons.coreapi.ModInfo;
import com.seibel.distanthorizons.core.logging.DhLogger;
@@ -1210,9 +1210,11 @@ public class Config
});
public static void onButtonPressed()
{
+ IMinecraftClientWrapper mcClient = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
+
LOGGER.info("Attempting to show tinyfd message box...");
- boolean buttonPress = NativeDialogUtil.showDialog("Button pressed!", "UITester dialog", "ok", "info");
- LOGGER.info("dialog returned with ["+(buttonPress ? "TRUE" : "FALSE")+"]");
+ mcClient.showDialog("Button pressed!", "UITester dialog", "ok", "info");
+ LOGGER.info("dialog closed");
}
public static ConfigCategory categoryTest = new ConfigCategory.Builder().set(CategoryTest.class).build();
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java
index 369609856..87a272721 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/jar/updater/SelfUpdater.java
@@ -28,16 +28,13 @@ import com.seibel.distanthorizons.core.jar.installer.GitlabGetter;
import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
import com.seibel.distanthorizons.core.jar.installer.WebDownloader;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
-import com.seibel.distanthorizons.core.logging.f3.F3Screen;
-import com.seibel.distanthorizons.core.util.NativeDialogUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants;
+import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.coreapi.ModInfo;
import com.seibel.distanthorizons.coreapi.util.StringUtil;
import com.seibel.distanthorizons.coreapi.util.jar.DeleteOnUnlock;
import com.seibel.distanthorizons.core.logging.DhLogger;
-import javax.swing.*;
-import java.awt.*;
import java.io.*;
import java.net.URLEncoder;
import java.nio.file.Files;
@@ -59,6 +56,8 @@ public class SelfUpdater
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
+ private static final IMinecraftClientWrapper MC_CLIENT = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
+
/** As we cannot delete(or replace) the jar while the mod is running, we just have this to delete it once the game closes */
public static boolean deleteOldJarOnJvmShutdown = false;
@@ -264,7 +263,7 @@ public class SelfUpdater
{
try
{
- NativeDialogUtil.showDialog(ModInfo.READABLE_NAME, successMessage, "ok", "info");
+ MC_CLIENT.showDialog(ModInfo.READABLE_NAME, successMessage, "ok", "info");
}
catch (Exception ignore) { }
}).start();
@@ -287,7 +286,7 @@ public class SelfUpdater
LOGGER.error(failMessage, e);
try
{
- NativeDialogUtil.showDialog(ModInfo.READABLE_NAME, failMessage, "ok", "error");
+ MC_CLIENT.showDialog(ModInfo.READABLE_NAME, failMessage, "ok", "error");
}
catch (Exception ignore) { }
@@ -386,7 +385,7 @@ public class SelfUpdater
{
try
{
- NativeDialogUtil.showDialog(ModInfo.READABLE_NAME, successMessage, "ok", "info");
+ MC_CLIENT.showDialog(ModInfo.READABLE_NAME, successMessage, "ok", "info");
}
catch (Exception ignore) { }
}).start();
@@ -424,7 +423,7 @@ public class SelfUpdater
LOGGER.error(failMessage, e);
try
{
- NativeDialogUtil.showDialog(ModInfo.READABLE_NAME, failMessage, "ok", "error");
+ MC_CLIENT.showDialog(ModInfo.READABLE_NAME, failMessage, "ok", "error");
}
catch (Exception ignore) { }
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/NativeDialogUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/util/NativeDialogUtil.java
deleted file mode 100644
index d29db9e09..000000000
--- a/core/src/main/java/com/seibel/distanthorizons/core/util/NativeDialogUtil.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.seibel.distanthorizons.core.util;
-
-import org.lwjgl.util.tinyfd.TinyFileDialogs;
-
-/**
- * Should be used instead of the direct call to {@link TinyFileDialogs}
- * so we can run additional validation and/or string cleanup.
- * Otherwise, we may get error messages back.
- *
- * @see TinyFileDialogs
- */
-public class NativeDialogUtil
-{
- /**
- * @param dialogType the dialog type. One of:
| "ok" | "okcancel" | "yesno" | "yesnocancel" |
- * @param iconType the icon type. One of:
| "info" | "warning" | "error" | "question" |
- */
- public static boolean showDialog(String title, String message, String dialogType, String iconType)
- {
- // Tinyfd doesn't support the following characters, attempting to display them will cause the message
- // to be replaced with an error message
- String unsafeCharsRegex = "['\"`]";
-
- title = title.replaceAll(unsafeCharsRegex, "`");
- message = message.replaceAll(unsafeCharsRegex, "`");
-
- return TinyFileDialogs.tinyfd_messageBox(title, message, dialogType, iconType, false);
- }
-
-}
diff --git a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftClientWrapper.java b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftClientWrapper.java
index 092b98d5d..d964c828b 100644
--- a/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftClientWrapper.java
+++ b/core/src/main/java/com/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftClientWrapper.java
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.core.wrapperInterfaces.minecraft;
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos;
import com.seibel.distanthorizons.core.pos.DhChunkPos;
+import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.distanthorizons.coreapi.interfaces.dependencyInjection.IBindable;
@@ -113,17 +114,19 @@ public interface IMinecraftClientWrapper extends IBindable
void crashMinecraft(String errorMessage, Throwable exception);
/**
- * This is only designed to be used internally by {@link GLProxy}
+ * This is only designed to be used internally by {@link RenderThreadTaskHandler}
* since it handles task frame limiting (reducing/preventing stuttering)
* whereas this method causes the task to be run whenever MC decides to
* (likely all at once the next frame).
*
* Any tasks submitted here will be run on the render thread.
*
- * @see GLProxy#queueRunningOnRenderThread(Runnable)
+ * @see RenderThreadTaskHandler
*/
void executeOnRenderThread(Runnable runnable);
+ void showDialog(String title, String message, String dialogType, String iconType);
+
//=============//