fix native dialog for MC 26
This commit is contained in:
+38
@@ -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. <br><br>
|
||||
*
|
||||
* source:
|
||||
* https://sourceforge.net/projects/tinyfiledialogs/
|
||||
*
|
||||
* @see TinyFileDialogs
|
||||
*/
|
||||
public class NativeDialogUtil
|
||||
{
|
||||
/**
|
||||
* @param dialogType the dialog type. One of:<br><table><tr><td>"ok"</td><td>"okcancel"</td><td>"yesno"</td><td>"yesnocancel"</td></tr></table>
|
||||
* @param iconType the icon type. One of:<br><table><tr><td>"info"</td><td>"warning"</td><td>"error"</td><td>"question"</td></tr></table>
|
||||
*/
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
Submodule coreSubProjects updated: 1d9bffe64e...a44c5d562d
@@ -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.*;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user