Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix runtime modified graphics settings potentially being saved #222

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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