diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/NativeDialogUtil.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/NativeDialogUtil.java new file mode 100644 index 000000000..375d37cbb --- /dev/null +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/NativeDialogUtil.java @@ -0,0 +1,38 @@ +package com.seibel.distanthorizons.common.wrappers.gui; + +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.

+ * + * source: + * https://sourceforge.net/projects/tinyfiledialogs/ + * + * @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 void 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, ""); + + #if MC_VER <= MC_1_21_11 + TinyFileDialogs.tinyfd_messageBox(title, message, dialogType, iconType, false); + #else + // https://mfbridge.github.io/tinyfiledialogs/reference/messageBox.html + TinyFileDialogs.tinyfd_messageBox(title, message, dialogType, iconType, 1 /* ok/yes */); + #endif + } + +} diff --git a/coreSubProjects b/coreSubProjects index 1d9bffe64..a44c5d562 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 1d9bffe64eff1c5219f2183491d4f9fa1eaff0ed +Subproject commit a44c5d562d3603a4f1941e4de80efd7d9cecd1a3 diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricMain.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricMain.java index 61b97e835..00b995a6c 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricMain.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricMain.java @@ -25,7 +25,7 @@ import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; -import com.seibel.distanthorizons.core.util.NativeDialogUtil; +import com.seibel.distanthorizons.common.wrappers.gui.NativeDialogUtil; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender; import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.*; diff --git a/versionProperties/26.1.0.properties b/versionProperties/26.1.0.properties index 87e0754c1..415acbcf4 100644 --- a/versionProperties/26.1.0.properties +++ b/versionProperties/26.1.0.properties @@ -11,7 +11,7 @@ builds_for=fabric,neoforge netty_version=4.1.97.Final # LWJGL -lwjgl_version=3.3.3 +lwjgl_version=3.4.1 # Fabric loader fabric_loader_version=0.18.5