Skip to content

Commit 4df85f4

Browse files
committed
Add boolean option to confirm to disable confirming on exiting the pack
1 parent 93173bd commit 4df85f4

2 files changed

Lines changed: 32 additions & 19 deletions

File tree

src/main/java/com/dreammaster/config/CoreModConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public CoreModConfig(File pConfigBaseDirectory, String pModCollectionDirectory,
1616
public boolean OreDictItems_Enabled;
1717
public static boolean ModLoginMessage_Enabled;
1818
public boolean gtnhPauseMenuButtons;
19+
public boolean confirmExit;
1920
public static String ModPackVersion = Refstrings.MODPACKPACK_VERSION;
2021

2122
public boolean ModHazardousItems_Enabled;
@@ -58,6 +59,7 @@ public CoreModConfig(File pConfigBaseDirectory, String pModCollectionDirectory,
5859
protected void PreInit() {
5960
ModLoginMessage_Enabled = true;
6061
gtnhPauseMenuButtons = true;
62+
confirmExit = true;
6163
ModDebugVersionDisplay_Enabled = true;
6264
ModHazardousItems_Enabled = false;
6365
ModCustomToolTips_Enabled = false;
@@ -104,6 +106,11 @@ protected void Init() {
104106
"Modules",
105107
gtnhPauseMenuButtons,
106108
"Set to true to display GTNH buttons in the pause menu");
109+
confirmExit = _mainConfig.getBoolean(
110+
"ConfirmExit",
111+
"Modules",
112+
confirmExit,
113+
"Set to false to exit without confirming");
107114
ModPackVersion = _mainConfig.getString("ModPackVersion", "Modules", ModPackVersion, "Version of the Modpack");
108115
ModDebugVersionDisplay_Enabled = _mainConfig.getBoolean(
109116
"DebugVersionDisplay",

src/main/java/com/dreammaster/mixin/mixins/early/MixinMinecraft_ConfirmExit.java

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import javax.swing.JFrame;
77
import javax.swing.JOptionPane;
88

9+
import com.dreammaster.main.MainRegistry;
910
import net.minecraft.client.Minecraft;
1011
import net.minecraft.util.StatCollector;
1112

@@ -40,28 +41,33 @@ public abstract class MixinMinecraft_ConfirmExit {
4041
if (!this.dreamcraft$waitingDialogQuit) {
4142
this.dreamcraft$waitingDialogQuit = true;
4243
new Thread(() -> {
43-
final JFrame frame = new JFrame();
44-
frame.setAlwaysOnTop(true);
45-
final URL resource = IconLoader.class.getClassLoader()
46-
.getResource("assets/dreamcraft/textures/icon/GTNH_42x42.png");
47-
final ImageIcon imageIcon = resource == null ? null : new ImageIcon(resource);
48-
final int result = JOptionPane.showConfirmDialog(
49-
frame,
50-
// When FML encounters an error, the only way to close the window is through the close button,
51-
// which will show this message, unfortunately at this point, no localisations will have been
52-
// loaded, so we add a hardcoded fallback message here.
53-
StatCollector.canTranslate("dreamcraft.gui.quitmessage")
54-
? StatCollector.translateToLocal("dreamcraft.gui.quitmessage")
55-
: "Are you sure you want to exit the game?",
56-
Refstrings.NAME,
57-
JOptionPane.YES_NO_OPTION,
58-
JOptionPane.QUESTION_MESSAGE,
59-
imageIcon);
60-
if (result == JOptionPane.YES_OPTION) {
44+
if(MainRegistry.CoreConfig.confirmExit) {
45+
final JFrame frame = new JFrame();
46+
frame.setAlwaysOnTop(true);
47+
final URL resource = IconLoader.class.getClassLoader()
48+
.getResource("assets/dreamcraft/textures/icon/GTNH_42x42.png");
49+
final ImageIcon imageIcon = resource == null ? null : new ImageIcon(resource);
50+
final int result = JOptionPane.showConfirmDialog(
51+
frame,
52+
// When FML encounters an error, the only way to close the window is through the close button,
53+
// which will show this message, unfortunately at this point, no localisations will have been
54+
// loaded, so we add a hardcoded fallback message here.
55+
StatCollector.canTranslate("dreamcraft.gui.quitmessage")
56+
? StatCollector.translateToLocal("dreamcraft.gui.quitmessage")
57+
: "Are you sure you want to exit the game?",
58+
Refstrings.NAME,
59+
JOptionPane.YES_NO_OPTION,
60+
JOptionPane.QUESTION_MESSAGE,
61+
imageIcon);
62+
if (result == JOptionPane.YES_OPTION) {
63+
this.dreamcraft$isCloseRequested = true;
64+
this.shutdown();
65+
}
66+
this.dreamcraft$waitingDialogQuit = false;
67+
} else {
6168
this.dreamcraft$isCloseRequested = true;
6269
this.shutdown();
6370
}
64-
this.dreamcraft$waitingDialogQuit = false;
6571
}).start();
6672
}
6773
ci.cancel();

0 commit comments

Comments
 (0)