aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/internal
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-30 16:01:02 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-30 16:01:02 +0200
commit68a2dfb5a22137fb433531542e8660bae023595f (patch)
treed9b8808db52e1c196e37cd3d3b41bf491cf341d0 /src/main/java/cc/polyfrost/oneconfig/internal
parentdcee46d4d0039993466fc7c0e2d0be7b31af3d4b (diff)
downloadOneConfig-68a2dfb5a22137fb433531542e8660bae023595f.tar.gz
OneConfig-68a2dfb5a22137fb433531542e8660bae023595f.tar.bz2
OneConfig-68a2dfb5a22137fb433531542e8660bae023595f.zip
lots of stuff
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/internal')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/config/InternalConfig.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/config/OneConfigConfig.java1
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java22
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/gui/BlurHandler.java21
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/plugin/hooks/VigilantHook.java2
6 files changed, 24 insertions, 29 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/InternalConfig.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/InternalConfig.java
index f0b065e..df90c19 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/config/InternalConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/InternalConfig.java
@@ -19,12 +19,11 @@ public abstract class InternalConfig extends Config {
}
@Override
- public void init(Mod mod) {
+ public void initialize() {
if (new File("OneConfig/" + configFile).exists()) load();
else save();
generateOptionList(this, mod.defaultPage, mod, false);
mod.config = this;
- this.mod = mod;
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/OneConfigConfig.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/OneConfigConfig.java
index 96fde65..0ed5dc2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/config/OneConfigConfig.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/OneConfigConfig.java
@@ -26,5 +26,6 @@ public class OneConfigConfig extends InternalConfig {
public OneConfigConfig() {
super("", "OneConfig.json");
+ initialize();
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java
index c8a5163..fff8fed 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/Preferences.java
@@ -5,7 +5,9 @@ import cc.polyfrost.oneconfig.config.annotations.Slider;
import cc.polyfrost.oneconfig.config.annotations.Switch;
import cc.polyfrost.oneconfig.config.core.OneKeyBind;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
+import cc.polyfrost.oneconfig.internal.gui.BlurHandler;
import cc.polyfrost.oneconfig.libs.universal.UKeyboard;
+import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
public class Preferences extends InternalConfig {
@@ -37,6 +39,8 @@ public class Preferences extends InternalConfig {
public Preferences() {
super("Preferences", "Preferences.json");
+ initialize();
+ addListener("enableBlur", () -> BlurHandler.INSTANCE.reloadBlur(UMinecraft.getMinecraft().currentScreen));
registerKeyBind(oneConfigKeyBind, () -> GuiUtils.displayScreen(OneConfigGui.create()));
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java
index 90c1062..4edff74 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/core/ConfigCore.java
@@ -20,31 +20,31 @@ public class ConfigCore {
}
}, 30000, 30000);
}
- public static List<Mod> oneConfigMods = new ArrayList<>();
+ public static List<Mod> mods = new ArrayList<>();
public static void saveAll() {
- for (Mod modData : oneConfigMods) {
+ for (Mod modData : mods) {
modData.config.save();
}
}
public static void reInitAll() {
- ArrayList<Mod> data = new ArrayList<>(oneConfigMods);
- oneConfigMods.clear();
+ ArrayList<Mod> data = new ArrayList<>(mods);
+ mods.clear();
HudCore.huds.clear();
KeyBindHandler.INSTANCE.clearKeyBinds();
for (Mod modData : data) {
- modData.config.init(modData);
+ modData.config.initialize();
}
sortMods();
}
public static void sortMods() {
- ArrayList<Mod> mods = new ArrayList<>(oneConfigMods);
- oneConfigMods = mods.stream().filter((mod -> OneConfigConfig.favoriteMods.contains(mod.name))).sorted().collect(Collectors.toList());
- mods.removeAll(oneConfigMods);
- oneConfigMods.addAll(mods.stream().filter(mod -> mod.modType != ModType.THIRD_PARTY).sorted().collect(Collectors.toList()));
- mods.removeAll(oneConfigMods);
- oneConfigMods.addAll(mods.stream().sorted().collect(Collectors.toList()));
+ ArrayList<Mod> mods = new ArrayList<>(ConfigCore.mods);
+ ConfigCore.mods = mods.stream().filter((mod -> OneConfigConfig.favoriteMods.contains(mod.name))).sorted().collect(Collectors.toList());
+ mods.removeAll(ConfigCore.mods);
+ ConfigCore.mods.addAll(mods.stream().filter(mod -> mod.modType != ModType.THIRD_PARTY).sorted().collect(Collectors.toList()));
+ mods.removeAll(ConfigCore.mods);
+ ConfigCore.mods.addAll(mods.stream().sorted().collect(Collectors.toList()));
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/gui/BlurHandler.java b/src/main/java/cc/polyfrost/oneconfig/internal/gui/BlurHandler.java
index 697f2d4..dac0202 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/gui/BlurHandler.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/gui/BlurHandler.java
@@ -38,7 +38,7 @@ public class BlurHandler {
private final ResourceLocation blurShader = new ResourceLocation("shaders/post/fade_in_blur.json");
private final Logger logger = LogManager.getLogger("OneConfig - Blur");
private long start;
- private float lastProgress = 0;
+ private float progress = 0;
/**
* Simply initializes the blur mod so events are properly handled by forge.
@@ -67,18 +67,8 @@ public class BlurHandler {
if (!UMinecraft.getMinecraft().entityRenderer.isShaderActive()) {
return;
}
-
- float progress = getBlurStrengthProgress();
-
- // If the new progress value matches the old one this
- // will skip the frame update, which (hopefully) resolves the issue
- // with the heavy computations after the "animation" is complete.
- if (progress == this.lastProgress) {
- return;
- }
-
- // Store it for the next iteration!
- this.lastProgress = progress;
+ if (progress >= 5) return;
+ progress = getBlurStrengthProgress();
// This is hilariously bad, and could cause frame issues on low-end computers.
// Why is this being computed every tick? Surely there is a better way?
@@ -112,7 +102,7 @@ public class BlurHandler {
* one of many conditions are met, such as no current other shader
* is being used, we actually have the blur setting enabled
*/
- private void reloadBlur(GuiScreen gui) {
+ public void reloadBlur(GuiScreen gui) {
// Don't do anything if no world is loaded
if (UMinecraft.getWorld() == null) {
return;
@@ -124,9 +114,10 @@ public class BlurHandler {
UMinecraft.getMinecraft().entityRenderer.loadShader(this.blurShader);
this.start = System.currentTimeMillis();
+ this.progress = 0;
// If a shader is active and the incoming UI is null or we have blur disabled, stop using the shader.
- } else if (UMinecraft.getMinecraft().entityRenderer.isShaderActive() && (gui == null)) {
+ } else if (UMinecraft.getMinecraft().entityRenderer.isShaderActive() && (gui == null || !Preferences.enableBlur)) {
String name = UMinecraft.getMinecraft().entityRenderer.getShaderGroup().getShaderGroupName();
// Only stop our specific blur ;)
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/hooks/VigilantHook.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/hooks/VigilantHook.java
index 59aebca..7b66435 100644
--- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/hooks/VigilantHook.java
+++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/hooks/VigilantHook.java
@@ -18,7 +18,7 @@ public class VigilantHook {
if (name.equals("OneConfig")) name = "Essential";
String finalName = name;
// duplicate fix
- if (ConfigCore.oneConfigMods.stream().anyMatch(mod -> mod.name.equals(finalName))) return null;
+ if (ConfigCore.mods.stream().anyMatch(mod -> mod.name.equals(finalName))) return null;
return new VigilanceConfig(new Mod(name, ModType.THIRD_PARTY), file.getAbsolutePath(), vigilant);
} else {
return null;