Skip to content

Commit

Permalink
Merge pull request #222 from LostLuma/fix/reduced-video-settings-pers…
Browse files Browse the repository at this point in the history
…isting

Fix runtime modified graphics settings potentially being saved
  • Loading branch information
LostLuma authored Sep 20, 2024
2 parents e126b3e + 0137012 commit 2b4dd49
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ public static boolean shouldShowToasts() {
return config.showToasts();
}

public static GraphicsState graphicsState() {
return config.graphicsState();
}

public static boolean shouldShowLevels() {
return isDisabled() || !isLevelCoveredByOverlay();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dynamic_fps.impl.mixin;

import dynamic_fps.impl.DynamicFPSMod;
import dynamic_fps.impl.config.option.GraphicsState;
import dynamic_fps.impl.feature.state.OptionHolder;
import net.minecraft.client.*;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

/**
* Resets runtime modified graphics settings to the user-specified defaults during saving.
* Prevents the game from saving the reduced or minimal preset to disk and loading it again.
*/
@Mixin(Options.class)
public abstract class OptionsMixin {
@Inject(method = "save", at = @At("HEAD"))
private void save0(CallbackInfo callbackInfo) {
if (DynamicFPSMod.graphicsState() != GraphicsState.DEFAULT) {
OptionHolder.applyOptions(Minecraft.getInstance().options, GraphicsState.DEFAULT);
}
}

@Inject(method = "save", at = @At("RETURN"))
private void save1(CallbackInfo callbackInfo) {
if (DynamicFPSMod.graphicsState() != GraphicsState.DEFAULT) {
OptionHolder.applyOptions(Minecraft.getInstance().options, DynamicFPSMod.graphicsState());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"GuiMixin",
"LoadingOverlayMixin",
"MinecraftMixin",
"OptionsMixin",
"SoundEngineMixin",
"ToastManagerMixin",
"ToastManagerMixin",
"bugfix.BlockableEventLoopMixin"
],
"mixins": [],
Expand Down

0 comments on commit 2b4dd49

Please sign in to comment.