Skip to content

Commit

Permalink
Add mod check for default tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
BloCamLimb committed Nov 10, 2023
1 parent 5eab71e commit 928e431
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fabric/src/main/java/icyllis/modernui/mc/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private Client(@Nonnull ForgeConfigSpec.Builder builder) {

mTooltip = builder.comment(
"Whether to enable Modern UI enhanced tooltip, or back to vanilla default.")
.define("enable", true);
.define("enable", !ModernUIMod.isSodiumLoaded() && !ModernUIMod.isLegendaryTooltipsLoaded());
mRoundedTooltip = builder.comment(
"Whether to use rounded tooltip shapes, or to use rectangular shapes.")
.define("roundedShape", true);
Expand Down
14 changes: 12 additions & 2 deletions fabric/src/main/java/icyllis/modernui/mc/ModernUIMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ public abstract class ModernUIMod {
public static volatile boolean sDevelopment;
public static volatile boolean sDeveloperMode;

public static boolean sOptiFineLoaded;
public static boolean sIrisApiLoaded;
protected static boolean sOptiFineLoaded;
protected static boolean sIrisApiLoaded;
protected static volatile boolean sLegendaryTooltipsLoaded;
protected static volatile boolean sSodiumLoaded;

static {
try {
Expand Down Expand Up @@ -89,6 +91,14 @@ public static boolean isIrisApiLoaded() {
return sIrisApiLoaded;
}

public static boolean isLegendaryTooltipsLoaded() {
return sLegendaryTooltipsLoaded;
}

public static boolean isSodiumLoaded() {
return sSodiumLoaded;
}

public static boolean isDeveloperMode() {
return sDeveloperMode || sDevelopment;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public void onInitialize() {
LOGGER.warn(MARKER, "Signature is missing");
}

sLegendaryTooltipsLoaded = FabricLoader.getInstance().isModLoaded("legendarytooltips");
sSodiumLoaded = FabricLoader.getInstance().isModLoaded("sodium");

ModConfigEvents.loading(ID).register(Config::reloadCommon);
ModConfigEvents.reloading(ID).register(Config::reloadCommon);
Config.initCommonConfig(
Expand Down
2 changes: 1 addition & 1 deletion forge/src/main/java/icyllis/modernui/mc/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ private Client(@Nonnull ForgeConfigSpec.Builder builder) {

mTooltip = builder.comment(
"Whether to enable Modern UI enhanced tooltip, or back to vanilla default.")
.define("enable", true);
.define("enable", !ModernUIMod.isLegendaryTooltipsLoaded());
mRoundedTooltip = builder.comment(
"Whether to use rounded tooltip shapes, or to use rectangular shapes.")
.define("roundedShape", true);
Expand Down
9 changes: 7 additions & 2 deletions forge/src/main/java/icyllis/modernui/mc/ModernUIMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public abstract class ModernUIMod {
public static volatile boolean sDevelopment;
public static volatile boolean sDeveloperMode;

public static boolean sOptiFineLoaded;
public static boolean sIrisApiLoaded;
protected static boolean sOptiFineLoaded;
protected static boolean sIrisApiLoaded;
protected static volatile boolean sLegendaryTooltipsLoaded;

static {
try {
Expand Down Expand Up @@ -76,6 +77,10 @@ public static boolean isIrisApiLoaded() {
return sIrisApiLoaded;
}

public static boolean isLegendaryTooltipsLoaded() {
return sLegendaryTooltipsLoaded;
}

public static boolean isDeveloperMode() {
return sDeveloperMode || sDevelopment;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public ModernUIForge() {
warnSetup("You should remove ReBlurred, Modern UI already includes its features, " +
"and Modern UI has better performance than it");
}
sLegendaryTooltipsLoaded = ModList.get().isLoaded("legendarytooltips");

Config.initCommonConfig(
spec -> ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, spec,
Expand Down

0 comments on commit 928e431

Please sign in to comment.