Skip to content

Commit

Permalink
Verify accessibility options when closing video settings screen as well
Browse files Browse the repository at this point in the history
  • Loading branch information
spiralhalo committed Jun 11, 2023
1 parent ef1239d commit b9ee6a3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import net.minecraft.client.Minecraft;
import net.minecraft.client.OptionInstance;
import net.minecraft.client.Options;
import net.minecraft.client.gui.screens.AccessibilityOptionsScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.SimpleOptionsSubScreen;
import net.minecraft.network.chat.Component;

import grondag.canvas.apiimpl.CanvasState;
import grondag.canvas.shader.data.AccessibilityData;

@Mixin(AccessibilityOptionsScreen.class)
Expand All @@ -44,18 +42,12 @@ public MixinAccessibilityOptionsScreen(Screen screen, Options options, Component

@Inject(at = @At("HEAD"), method = "method_31384")
void onClosing(CallbackInfo ci) {
canvas_onClose();
AccessibilityData.onCloseOptionScreen();
}

@Override
public void onClose() {
canvas_onClose();
AccessibilityData.onCloseOptionScreen();
super.onClose();
}

private static void canvas_onClose() {
if (AccessibilityData.checkChanged() && Minecraft.getInstance().level != null) {
CanvasState.recompileIfNeeded(true);
}
}
}
12 changes: 12 additions & 0 deletions src/main/java/grondag/canvas/mixin/MixinVideoSettingsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.client.gui.screens.VideoSettingsScreen;
import net.minecraft.network.chat.Component;

import grondag.canvas.shader.data.AccessibilityData;
import grondag.canvas.varia.CanvasButtonWidget;

@Mixin(VideoSettingsScreen.class)
Expand All @@ -41,4 +42,15 @@ public MixinVideoSettingsScreen(Component title) {
private void onInit(CallbackInfo info) {
CanvasButtonWidget.parent = this;
}

@Inject(at = @At("HEAD"), method = "method_19865")
void onClosing(CallbackInfo ci) {
AccessibilityData.onCloseOptionScreen();
}

@Override
public void onClose() {
AccessibilityData.onCloseOptionScreen();
super.onClose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;

import grondag.canvas.apiimpl.CanvasState;

public class AccessibilityData {
static final ResourceLocation id = new ResourceLocation("canvas:accessibility");

Expand All @@ -37,6 +39,12 @@ public class AccessibilityData {

static String cache = null;

public static void onCloseOptionScreen() {
if (AccessibilityData.checkChanged() && Minecraft.getInstance().level != null) {
CanvasState.recompileIfNeeded(true);
}
}

public static boolean checkChanged() {
final var mc = Minecraft.getInstance();

Expand Down

0 comments on commit b9ee6a3

Please sign in to comment.