Search in sources :

Example 1 with OptionStorage

use of me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage in project sodium-fabric by CaffeineMC.

the class SodiumOptionsGUI method applyChanges.

private void applyChanges() {
    final HashSet<OptionStorage<?>> dirtyStorages = new HashSet<>();
    final EnumSet<OptionFlag> flags = EnumSet.noneOf(OptionFlag.class);
    for (Option<?> option : this.currentPage.getOptions()) {
        if (!option.hasChanged()) {
            continue;
        }
        option.applyChanges();
        flags.addAll(option.getFlags());
        dirtyStorages.add(option.getStorage());
    }
    MinecraftClient client = MinecraftClient.getInstance();
    if (flags.contains(OptionFlag.REQUIRES_RENDERER_RELOAD)) {
        client.worldRenderer.reload();
    }
    if (flags.contains(OptionFlag.REQUIRES_ASSET_RELOAD)) {
        client.resetMipmapLevels(client.options.mipmapLevels);
        client.reloadResourcesConcurrently();
    }
    for (OptionStorage<?> storage : dirtyStorages) {
        storage.save();
    }
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) OptionStorage(me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage) HashSet(java.util.HashSet)

Example 2 with OptionStorage

use of me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage in project reeses-sodium-options by FlashyReese.

the class SodiumVideoOptionsScreen method applyChanges.

private void applyChanges() {
    final HashSet<OptionStorage<?>> dirtyStorages = new HashSet<>();
    final EnumSet<OptionFlag> flags = EnumSet.noneOf(OptionFlag.class);
    this.getAllOptions().forEach((option -> {
        if (!option.hasChanged()) {
            return;
        }
        option.applyChanges();
        flags.addAll(option.getFlags());
        dirtyStorages.add(option.getStorage());
    }));
    MinecraftClient client = MinecraftClient.getInstance();
    if (flags.contains(OptionFlag.REQUIRES_RENDERER_RELOAD)) {
        client.worldRenderer.reload();
    }
    if (flags.contains(OptionFlag.REQUIRES_ASSET_RELOAD)) {
        client.setMipmapLevels(client.options.mipmapLevels);
        client.reloadResourcesConcurrently();
    }
    for (OptionStorage<?> storage : dirtyStorages) {
        storage.save();
    }
}
Also used : FabricLoader(net.fabricmc.loader.api.FabricLoader) LiteralText(net.minecraft.text.LiteralText) Util(net.minecraft.util.Util) TranslatableText(net.minecraft.text.TranslatableText) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) OptionFlag(me.jellysquid.mods.sodium.client.gui.options.OptionFlag) TabFrame(me.flashyreese.mods.reeses_sodium_options.client.gui.frame.tab.TabFrame) EnumSet(java.util.EnumSet) FlatButtonWidget(me.jellysquid.mods.sodium.client.gui.widgets.FlatButtonWidget) SodiumGameOptions(me.jellysquid.mods.sodium.client.gui.SodiumGameOptions) Dim2i(me.jellysquid.mods.sodium.client.util.Dim2i) SodiumClientMod(me.jellysquid.mods.sodium.client.SodiumClientMod) VideoOptionsScreen(net.minecraft.client.gui.screen.option.VideoOptionsScreen) MatrixStack(net.minecraft.client.util.math.MatrixStack) IOException(java.io.IOException) OptionStorage(me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage) GLFW(org.lwjgl.glfw.GLFW) Tab(me.flashyreese.mods.reeses_sodium_options.client.gui.frame.tab.Tab) Option(me.jellysquid.mods.sodium.client.gui.options.Option) OptionPage(me.jellysquid.mods.sodium.client.gui.options.OptionPage) AbstractFrame(me.flashyreese.mods.reeses_sodium_options.client.gui.frame.AbstractFrame) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) Stream(java.util.stream.Stream) MinecraftClient(net.minecraft.client.MinecraftClient) BasicFrame(me.flashyreese.mods.reeses_sodium_options.client.gui.frame.BasicFrame) IrisApi(net.irisshaders.iris.api.v0.IrisApi) MinecraftClient(net.minecraft.client.MinecraftClient) OptionStorage(me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage) OptionFlag(me.jellysquid.mods.sodium.client.gui.options.OptionFlag) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 OptionStorage (me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage)2 MinecraftClient (net.minecraft.client.MinecraftClient)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 List (java.util.List)1 Stream (java.util.stream.Stream)1 AbstractFrame (me.flashyreese.mods.reeses_sodium_options.client.gui.frame.AbstractFrame)1 BasicFrame (me.flashyreese.mods.reeses_sodium_options.client.gui.frame.BasicFrame)1 Tab (me.flashyreese.mods.reeses_sodium_options.client.gui.frame.tab.Tab)1 TabFrame (me.flashyreese.mods.reeses_sodium_options.client.gui.frame.tab.TabFrame)1 SodiumClientMod (me.jellysquid.mods.sodium.client.SodiumClientMod)1 SodiumGameOptions (me.jellysquid.mods.sodium.client.gui.SodiumGameOptions)1 Option (me.jellysquid.mods.sodium.client.gui.options.Option)1 OptionFlag (me.jellysquid.mods.sodium.client.gui.options.OptionFlag)1 OptionPage (me.jellysquid.mods.sodium.client.gui.options.OptionPage)1 FlatButtonWidget (me.jellysquid.mods.sodium.client.gui.widgets.FlatButtonWidget)1 Dim2i (me.jellysquid.mods.sodium.client.util.Dim2i)1 FabricLoader (net.fabricmc.loader.api.FabricLoader)1