mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-28 07:55:53 +00:00
More tweaks to the mod loading callbacks to make loading bars work better (#9585)
This commit is contained in:
12 files changed
+90
-60
No files matched your search
@@ -7,7 +7,6 @@ package net.minecraftforge.fml.loading;
|
||||
|
||||
import com.electronwill.nightconfig.core.CommentedConfig;
|
||||
import com.electronwill.nightconfig.core.ConfigSpec;
|
||||
import com.electronwill.nightconfig.core.UnmodifiableCommentedConfig;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import com.electronwill.nightconfig.core.file.FileNotFoundAction;
|
||||
import com.electronwill.nightconfig.core.io.ParsingException;
|
||||
@@ -17,9 +16,7 @@ import org.slf4j.Logger;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -28,7 +25,7 @@ import static net.minecraftforge.fml.loading.LogMarkers.CORE;
|
||||
public class FMLConfig
|
||||
{
|
||||
public enum ConfigValue {
|
||||
SPLASHSCREEN("splashscreen", Boolean.TRUE, "should we show the early splashscreen"),
|
||||
EARLY_WINDOW_CONTROL("earlyWindowControl", Boolean.TRUE, "Should we control the window. Disabling this disables new GL features and can be bad for mods that rely on them."),
|
||||
MAX_THREADS("maxThreads", -1, "Max threads for early initialization parallelism, -1 is based on processor count", FMLConfig::maxThreads),
|
||||
VERSION_CHECK("versionCheck", Boolean.TRUE, "Enable forge global version checking"),
|
||||
DEFAULT_CONFIG_PATH("defaultConfigPath", "defaultconfigs", "Default config path for servers"),
|
||||
@@ -63,6 +60,7 @@ public class FMLConfig
|
||||
} else {
|
||||
spec.define(this.entry, this.defaultValue);
|
||||
}
|
||||
commentedConfig.add(this.entry, this.defaultValue);
|
||||
commentedConfig.setComment(this.entry, this.comment);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -10,8 +10,6 @@ import net.minecraftforge.fml.loading.progress.StartupNotificationManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
@@ -28,7 +26,7 @@ public class ImmediateWindowHandler {
|
||||
if (!List.of("forgeclient", "forgeclientuserdev", "forgeclientdev").contains(launchTarget)) {
|
||||
provider = new DummyProvider();
|
||||
LOGGER.info("ImmediateWindowProvider not loading because launch target is {}", launchTarget);
|
||||
} else if (!FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.SPLASHSCREEN)) {
|
||||
} else if (!FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.EARLY_WINDOW_CONTROL)) {
|
||||
provider = new DummyProvider();
|
||||
LOGGER.info("ImmediateWindowProvider not loading because splash screen is disabled");
|
||||
} else {
|
||||
@@ -88,6 +86,7 @@ public class ImmediateWindowHandler {
|
||||
private static Method NV_HANDOFF;
|
||||
private static Method NV_POSITION;
|
||||
private static Method NV_OVERLAY;
|
||||
private static Method NV_VERSION;
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
@@ -131,7 +130,11 @@ public class ImmediateWindowHandler {
|
||||
|
||||
@Override
|
||||
public String getGLVersion() {
|
||||
return "3.2"; // The default minecraft GL version
|
||||
try {
|
||||
return (String) NV_VERSION.invoke(null);
|
||||
} catch (Throwable e) {
|
||||
throw new IllegalStateException("How did you get here?", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,6 +147,7 @@ public class ImmediateWindowHandler {
|
||||
NV_HANDOFF = methods.get("windowHandoff");
|
||||
NV_OVERLAY = methods.get("loadingOverlay");
|
||||
NV_POSITION = methods.get("windowPositioning");
|
||||
NV_VERSION = methods.get("glVersion");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -24,6 +24,13 @@ public class StartupNotificationManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static ProgressMeter prependProgressBar(final String barName, final int count) {
|
||||
var pm = new ProgressMeter(barName, count, 0, new Message(barName, Message.MessageType.ML));
|
||||
synchronized (progressMeters) {
|
||||
progressMeters.addLast(pm);
|
||||
}
|
||||
return pm;
|
||||
}
|
||||
public static ProgressMeter addProgressBar(final String barName, final int count) {
|
||||
var pm = new ProgressMeter(barName, count, 0, new Message(barName, Message.MessageType.ML));
|
||||
synchronized (progressMeters) {
|
||||
|
||||
Reference in new issue
Block a user