Search in sources :

Example 6 with ShaderPack

use of net.coderbot.iris.shaderpack.ShaderPack in project Iris by IrisShaders.

the class ShaderPackScreen method init.

@Override
protected void init() {
    super.init();
    int bottomCenter = this.width / 2 - 50;
    int topCenter = this.width / 2 - 76;
    boolean inWorld = this.minecraft.level != null;
    this.children.remove(this.shaderPackList);
    this.children.remove(this.shaderOptionList);
    this.shaderPackList = new ShaderPackSelectionList(this.minecraft, this.width, this.height, 32, this.height - 58, 0, this.width);
    if (Iris.getCurrentPack().isPresent() && this.navigation != null) {
        ShaderPack currentPack = Iris.getCurrentPack().get();
        this.shaderOptionList = new ShaderPackOptionList(this, this.navigation, currentPack, this.minecraft, this.width, this.height, 32, this.height - 58, 0, this.width);
        this.navigation.setActiveOptionList(this.shaderOptionList);
        this.shaderOptionList.rebuild();
    } else {
        optionMenuOpen = false;
        this.shaderOptionList = null;
    }
    if (inWorld) {
        this.shaderPackList.setRenderBackground(false);
        if (shaderOptionList != null) {
            this.shaderOptionList.setRenderBackground(false);
        }
    }
    if (optionMenuOpen && shaderOptionList != null) {
        this.children.add(shaderOptionList);
    } else {
        this.children.add(shaderPackList);
    }
    this.buttons.clear();
    this.addButton(new Button(bottomCenter + 104, this.height - 27, 100, 20, CommonComponents.GUI_DONE, button -> onClose()));
    this.addButton(new Button(bottomCenter, this.height - 27, 100, 20, new TranslatableComponent("options.iris.apply"), button -> this.applyChanges()));
    this.addButton(new Button(bottomCenter - 104, this.height - 27, 100, 20, CommonComponents.GUI_CANCEL, button -> this.dropChangesAndClose()));
    this.addButton(new Button(topCenter - 78, this.height - 51, 152, 20, new TranslatableComponent("options.iris.openShaderPackFolder"), button -> openShaderPackFolder()));
    this.screenSwitchButton = this.addButton(new Button(topCenter + 78, this.height - 51, 152, 20, new TranslatableComponent("options.iris.shaderPackList"), button -> {
        this.optionMenuOpen = !this.optionMenuOpen;
        this.init();
    }));
    refreshScreenSwitchButton();
}
Also used : ShaderPackSelectionList(net.coderbot.iris.gui.element.ShaderPackSelectionList) ShaderPackOptionList(net.coderbot.iris.gui.element.ShaderPackOptionList) AbstractElementWidget(net.coderbot.iris.gui.element.widget.AbstractElementWidget) Arrays(java.util.Arrays) CommonComponents(net.minecraft.network.chat.CommonComponents) MutableComponent(net.minecraft.network.chat.MutableComponent) PoseStack(com.mojang.blaze3d.vertex.PoseStack) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ChatFormatting(net.minecraft.ChatFormatting) Path(java.nio.file.Path) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Button(net.minecraft.client.gui.components.Button) Iris(net.coderbot.iris.Iris) Properties(java.util.Properties) Component(net.minecraft.network.chat.Component) Files(java.nio.file.Files) Screen(net.minecraft.client.gui.screens.Screen) Set(java.util.Set) IOException(java.io.IOException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException) Collectors(java.util.stream.Collectors) GLFW(org.lwjgl.glfw.GLFW) ShaderPack(net.coderbot.iris.shaderpack.ShaderPack) GuiUtil(net.coderbot.iris.gui.GuiUtil) Nullable(org.jetbrains.annotations.Nullable) Util(net.minecraft.Util) TextComponent(net.minecraft.network.chat.TextComponent) List(java.util.List) CommentedElementWidget(net.coderbot.iris.gui.element.widget.CommentedElementWidget) ShaderPackSelectionList(net.coderbot.iris.gui.element.ShaderPackSelectionList) FormattedCharSequence(net.minecraft.util.FormattedCharSequence) Optional(java.util.Optional) NavigationController(net.coderbot.iris.gui.NavigationController) IrisApi(net.irisshaders.iris.api.v0.IrisApi) InputStream(java.io.InputStream) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Button(net.minecraft.client.gui.components.Button) ShaderPack(net.coderbot.iris.shaderpack.ShaderPack) ShaderPackOptionList(net.coderbot.iris.gui.element.ShaderPackOptionList)

Example 7 with ShaderPack

use of net.coderbot.iris.shaderpack.ShaderPack in project Iris by IrisShaders.

the class ShaderPackScreen method refreshForChangedPack.

public void refreshForChangedPack() {
    if (Iris.getCurrentPack().isPresent()) {
        ShaderPack currentPack = Iris.getCurrentPack().get();
        this.navigation = new NavigationController(currentPack.getMenuContainer());
        if (this.shaderOptionList != null) {
            this.shaderOptionList.applyShaderPack(currentPack);
            this.shaderOptionList.rebuild();
        }
    } else {
        this.navigation = null;
    }
    refreshScreenSwitchButton();
}
Also used : NavigationController(net.coderbot.iris.gui.NavigationController) ShaderPack(net.coderbot.iris.shaderpack.ShaderPack)

Example 8 with ShaderPack

use of net.coderbot.iris.shaderpack.ShaderPack in project Iris by IrisShaders.

the class MixinClientLanguage method iris$lookupOverriddenEntry.

@Unique
private String iris$lookupOverriddenEntry(String key) {
    ShaderPack pack = Iris.getCurrentPack().orElse(null);
    if (pack == null) {
        // This prevents a cryptic NullPointerException when shaderpack loading fails for some reason.
        return null;
    }
    // Minecraft loads the "en_us" language code by default, and any other code will be right after it.
    // 
    // So we also check if the user is loading a special language, and if the shaderpack has support for that
    // language. If they do, we load that, but if they do not, we load "en_us" instead.
    LanguageMap languageMap = pack.getLanguageMap();
    if (storage.containsKey(key)) {
        // TODO: Should we allow shader packs to override existing MC translations?
        return null;
    }
    for (String code : languageCodes) {
        Map<String, String> translations = languageMap.getTranslations(code);
        if (translations != null) {
            String translation = translations.get(key);
            if (translation != null) {
                return translation;
            }
        }
    }
    return null;
}
Also used : LanguageMap(net.coderbot.iris.shaderpack.LanguageMap) ShaderPack(net.coderbot.iris.shaderpack.ShaderPack) Unique(org.spongepowered.asm.mixin.Unique)

Aggregations

ShaderPack (net.coderbot.iris.shaderpack.ShaderPack)8 IOException (java.io.IOException)3 Files (java.nio.file.Files)3 Path (java.nio.file.Path)3 Map (java.util.Map)3 Optional (java.util.Optional)3 Properties (java.util.Properties)3 OptionSet (net.coderbot.iris.shaderpack.option.OptionSet)3 MutableOptionValues (net.coderbot.iris.shaderpack.option.values.MutableOptionValues)3 OptionValues (net.coderbot.iris.shaderpack.option.values.OptionValues)3 IrisApi (net.irisshaders.iris.api.v0.IrisApi)3 ChatFormatting (net.minecraft.ChatFormatting)3 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)3 GLFW (org.lwjgl.glfw.GLFW)3 Throwables (com.google.common.base.Throwables)2 InputConstants (com.mojang.blaze3d.platform.InputConstants)2 OutputStream (java.io.OutputStream)2 FileSystem (java.nio.file.FileSystem)2 FileSystemNotFoundException (java.nio.file.FileSystemNotFoundException)2 FileSystems (java.nio.file.FileSystems)2