Fix options not refreshing in the options screen without reopening (#22)
This commit is contained in:
parent
b38c3f7c57
commit
427b961fb0
2 changed files with 13 additions and 2 deletions
|
|
@ -4,15 +4,18 @@ import com.axolotlmaid.optionsprofiles.profiles.Profiles;
|
||||||
import net.minecraft.client.gui.components.Button;
|
import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.layouts.LinearLayout;
|
import net.minecraft.client.gui.layouts.LinearLayout;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
|
import net.minecraft.client.gui.screens.options.OptionsScreen;
|
||||||
import net.minecraft.client.gui.screens.options.OptionsSubScreen;
|
import net.minecraft.client.gui.screens.options.OptionsSubScreen;
|
||||||
import net.minecraft.network.chat.CommonComponents;
|
import net.minecraft.network.chat.CommonComponents;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
public class ProfilesScreen extends OptionsSubScreen {
|
public class ProfilesScreen extends OptionsSubScreen {
|
||||||
|
private Screen optionsLastScreen;
|
||||||
public ProfilesList profilesList;
|
public ProfilesList profilesList;
|
||||||
|
|
||||||
public ProfilesScreen(Screen lastScreen) {
|
public ProfilesScreen(Screen lastScreen, Screen optionsLastScreen) {
|
||||||
super(lastScreen, null, Component.translatable("gui.optionsprofiles.profiles-menu"));
|
super(lastScreen, null, Component.translatable("gui.optionsprofiles.profiles-menu"));
|
||||||
|
this.optionsLastScreen = optionsLastScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addOptions() {}
|
protected void addOptions() {}
|
||||||
|
|
@ -41,6 +44,10 @@ public class ProfilesScreen extends OptionsSubScreen {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onClose() {
|
||||||
|
this.minecraft.setScreen(new OptionsScreen(optionsLastScreen, this.minecraft.options));
|
||||||
|
}
|
||||||
|
|
||||||
protected void repositionElements() {
|
protected void repositionElements() {
|
||||||
this.layout.arrangeElements();
|
this.layout.arrangeElements();
|
||||||
this.profilesList.updateSize(this.width, this.layout);
|
this.profilesList.updateSize(this.width, this.layout);
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,17 @@ import net.minecraft.client.gui.components.Button;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.gui.screens.options.OptionsScreen;
|
import net.minecraft.client.gui.screens.options.OptionsScreen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(OptionsScreen.class)
|
@Mixin(OptionsScreen.class)
|
||||||
public class MixinOptionsScreen extends Screen {
|
public class MixinOptionsScreen extends Screen {
|
||||||
|
@Shadow @Final private Screen lastScreen;
|
||||||
|
|
||||||
protected MixinOptionsScreen(Component component) {
|
protected MixinOptionsScreen(Component component) {
|
||||||
super(component);
|
super(component);
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +25,7 @@ public class MixinOptionsScreen extends Screen {
|
||||||
this.addRenderableWidget(
|
this.addRenderableWidget(
|
||||||
Button.builder(
|
Button.builder(
|
||||||
Component.translatable("gui.optionsprofiles.profiles-menu"),
|
Component.translatable("gui.optionsprofiles.profiles-menu"),
|
||||||
(button) -> this.minecraft.setScreen(new ProfilesScreen(this)))
|
(button) -> this.minecraft.setScreen(new ProfilesScreen(this, lastScreen)))
|
||||||
.width(75)
|
.width(75)
|
||||||
.pos(5, 5)
|
.pos(5, 5)
|
||||||
.build()
|
.build()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue