chore: Inject config in config screen
This commit is contained in:
parent
ee13575e15
commit
8b319f3839
@ -149,7 +149,7 @@ public final class SmoothChunks implements ClientModInitializer, ModMenuApi {
|
|||||||
return new ConfigScreenFactory<Screen>() {
|
return new ConfigScreenFactory<Screen>() {
|
||||||
@Override
|
@Override
|
||||||
public Screen create(Screen parent) {
|
public Screen create(Screen parent) {
|
||||||
return new SmoothChunksScreen(parent, animation, ease);
|
return new SmoothChunksScreen(parent, animation, ease, config);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import net.minecraft.text.LiteralText;
|
|||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.ColorHelper.Argb;
|
import net.minecraft.util.math.ColorHelper.Argb;
|
||||||
|
import me.topchetoeu.smoothchunks.ConfigManager;
|
||||||
import me.topchetoeu.smoothchunks.Manager;
|
import me.topchetoeu.smoothchunks.Manager;
|
||||||
import me.topchetoeu.smoothchunks.animation.Animation;
|
import me.topchetoeu.smoothchunks.animation.Animation;
|
||||||
import me.topchetoeu.smoothchunks.easing.Ease;
|
import me.topchetoeu.smoothchunks.easing.Ease;
|
||||||
@ -19,6 +20,7 @@ public class SmoothChunksScreen extends Screen {
|
|||||||
private final HorizontalSection mainSection = new HorizontalSection();
|
private final HorizontalSection mainSection = new HorizontalSection();
|
||||||
private final Manager<Animation> animation;
|
private final Manager<Animation> animation;
|
||||||
private final Manager<Ease> ease;
|
private final Manager<Ease> ease;
|
||||||
|
private final ConfigManager config;
|
||||||
|
|
||||||
public static void playClick() {
|
public static void playClick() {
|
||||||
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0f));
|
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0f));
|
||||||
@ -50,6 +52,7 @@ public class SmoothChunksScreen extends Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
config.save();
|
||||||
MinecraftClient.getInstance().setScreen(parent);
|
MinecraftClient.getInstance().setScreen(parent);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@ -102,10 +105,12 @@ public class SmoothChunksScreen extends Screen {
|
|||||||
res.children.addSelectableChild(selectionSection(ease, "Ease"));
|
res.children.addSelectableChild(selectionSection(ease, "Ease"));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
public SmoothChunksScreen(Screen parent, Manager<Animation> animation, Manager<Ease> ease) {
|
public SmoothChunksScreen(Screen parent, Manager<Animation> animation, Manager<Ease> ease, ConfigManager config) {
|
||||||
super(Text.of("Smooth Chunks Config"));
|
super(Text.of("Smooth Chunks Config"));
|
||||||
|
config.reload();
|
||||||
this.animation = animation;
|
this.animation = animation;
|
||||||
this.ease = ease;
|
this.ease = ease;
|
||||||
|
this.config = config;
|
||||||
mainSection.x = mainSection.y = 5;
|
mainSection.x = mainSection.y = 5;
|
||||||
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
Loading…
Reference in New Issue
Block a user