Skip to content

Commit 4966d0f

Browse files
committed
feat: add config to pause game if book is open
Closes #371
1 parent a2c9c56 commit 4966d0f

10 files changed

Lines changed: 35 additions & 4 deletions

File tree

common/src/main/java/com/klikli_dev/modonomicon/client/gui/book/index/BookParentIndexScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,6 @@ protected boolean isClickOutsideEntry(double pMouseX, double pMouseY) {
408408

409409
@Override
410410
public boolean isPauseScreen() {
411-
return false;
411+
return ClientServices.CLIENT_CONFIG.pauseGameWhenOpen();
412412
}
413413
}

common/src/main/java/com/klikli_dev/modonomicon/client/gui/book/node/BookParentNodeScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ protected void onShowRecentlyUnlockedButtonClick(ShowRecentlyUnlockedButton butt
396396

397397
@Override
398398
public boolean isPauseScreen() {
399-
return false;
399+
return ClientServices.CLIENT_CONFIG.pauseGameWhenOpen();
400400
}
401401
}
402402

common/src/main/java/com/klikli_dev/modonomicon/platform/services/ClientConfigHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ public interface ClientConfigHelper {
1414
boolean storeLastOpenPageWhenClosingEntry();
1515

1616
List<String> fontFallbackLocales();
17+
18+
boolean pauseGameWhenOpen();
1719
}

fabric/src/main/java/com/klikli_dev/modonomicon/config/ClientConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class ClientConfig {
2727
public static PropertyMirror<Boolean> enableSmoothZoom = PropertyMirror.create(ConfigTypes.BOOLEAN);
2828
public static PropertyMirror<Boolean> storeLastOpenPageWhenClosingEntry = PropertyMirror.create(ConfigTypes.BOOLEAN);
2929
public static PropertyMirror<List<String>> fontFallbackLocales = PropertyMirror.create(ConfigTypes.makeList(ConfigTypes.STRING));
30+
public static PropertyMirror<Boolean> pauseGameWhenOpen = PropertyMirror.create(ConfigTypes.BOOLEAN);
3031

3132
private static final ConfigTree CONFIG = ConfigTree.builder()
3233
.fork("qol")
@@ -41,6 +42,9 @@ public class ClientConfig {
4142
.beginValue("fontFallbackLocales", ConfigTypes.makeList(ConfigTypes.STRING), List.of("zh_cn", "ja_jp", "ko_kr"))
4243
.withComment("If your locale is not supported by the default Modonomicon font, indicated by the book just rendering blocky shapes instead of characters, add your locale to this list to fall back to the builtin Minecraft font.")
4344
.finishValue(fontFallbackLocales::mirror)
45+
.beginValue("pauseGameWhenOpen", ConfigTypes.BOOLEAN, true)
46+
.withComment("If true, the game will pause when a Modonomicon book is open (singleplayer only).")
47+
.finishValue(pauseGameWhenOpen::mirror)
4448
.finishBranch()
4549
.build();
4650

fabric/src/main/java/com/klikli_dev/modonomicon/config/FabricClientConfigHelper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ public boolean storeLastOpenPageWhenClosingEntry() {
2525
public List<String> fontFallbackLocales() {
2626
return ClientConfig.fontFallbackLocales.getValue();
2727
}
28+
29+
@Override
30+
public boolean pauseGameWhenOpen() {
31+
return ClientConfig.pauseGameWhenOpen.getValue();
32+
}
2833
}

fabric/src/main/java/com/klikli_dev/modonomicon/gui/FabricMultiLayerScreen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
package com.klikli_dev.modonomicon.gui;
88

9+
import com.klikli_dev.modonomicon.platform.ClientServices;
910
import net.minecraft.CrashReport;
1011
import net.minecraft.client.Minecraft;
1112
import net.minecraft.client.gui.ComponentPath;
@@ -75,7 +76,7 @@ public void triggerImmediateNarration(boolean onlyNarrateNew) {
7576

7677
@Override
7778
public boolean isPauseScreen() {
78-
return this.guiLayers.peek().isPauseScreen();
79+
return ClientServices.CLIENT_CONFIG.pauseGameWhenOpen();
7980
}
8081

8182

forge/src/main/java/com/klikli_dev/modonomicon/config/ClientConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public static class QoLCategory {
3434
public final BooleanValue storeLastOpenPageWhenClosingEntry;
3535

3636
public final ForgeConfigSpec.ConfigValue<List<String>> fontFallbackLocales;
37+
public final BooleanValue pauseGameWhenOpen;
3738

3839
public QoLCategory(ForgeConfigSpec.Builder builder) {
3940
builder.comment("Quality of Life Settings").push("qol");
@@ -47,6 +48,9 @@ public QoLCategory(ForgeConfigSpec.Builder builder) {
4748
this.fontFallbackLocales = builder.comment("If your locale is not supported by the default Modonomicon font, indicated by the book just rendering blocky shapes instead of characters, add your locale to this list to fall back to the builtin Minecraft font.")
4849
.define("fontFallbackLocales", fontFallbackLocalesDefault);
4950

51+
this.pauseGameWhenOpen = builder.comment("If true, the game will pause when a Modonomicon book is open (singleplayer only).")
52+
.define("pauseGameWhenOpen", true);
53+
5054
builder.pop();
5155
}
5256
}

forge/src/main/java/com/klikli_dev/modonomicon/config/ForgeClientConfigHelper.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,13 @@ public List<String> fontFallbackLocales() {
2626
return ClientConfig.get().qolCategory.fontFallbackLocales.get();
2727
}
2828

29+
@Override
30+
public boolean shouldShowResearchToasts() {
31+
return ClientConfig.get().qolCategory.showResearchToasts.get();
32+
}
2933

34+
@Override
35+
public boolean pauseGameWhenOpen() {
36+
return ClientConfig.get().qolCategory.pauseGameWhenOpen.get();
37+
}
3038
}

neo/src/main/java/com/klikli_dev/modonomicon/config/ClientConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public static class QoLCategory {
3434
public final ModConfigSpec.BooleanValue storeLastOpenPageWhenClosingEntry;
3535

3636
public final ModConfigSpec.ConfigValue<List<? extends String>> fontFallbackLocales;
37+
public final ModConfigSpec.BooleanValue pauseGameWhenOpen;
3738

3839
public QoLCategory(ModConfigSpec.Builder builder) {
3940
builder.comment("Quality of Life Settings").push("qol");
@@ -47,6 +48,9 @@ public QoLCategory(ModConfigSpec.Builder builder) {
4748
this.fontFallbackLocales = builder.comment("If your locale is not supported by the default Modonomicon font, indicated by the book just rendering blocky shapes instead of characters, add your locale to this list to fall back to the builtin Minecraft font.")
4849
.defineList("fontFallbackLocales", fontFallbackLocalesDefault, () -> "", (e) -> true);
4950

51+
this.pauseGameWhenOpen = builder.comment("If true, the game will pause when a Modonomicon book is open (singleplayer only).")
52+
.define("pauseGameWhenOpen", true);
53+
5054
builder.pop();
5155
}
5256
}

neo/src/main/java/com/klikli_dev/modonomicon/config/NeoClientConfigHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ public List<String> fontFallbackLocales() {
2626
return ClientConfig.get().qolCategory.fontFallbackLocales.get().stream().map(String::toString).toList();
2727
}
2828

29-
29+
@Override
30+
public boolean pauseGameWhenOpen() {
31+
return ClientConfig.get().qolCategory.pauseGameWhenOpen.get();
32+
}
3033
}

0 commit comments

Comments
 (0)