Search in sources :

Example 1 with GuiConfigsBase

use of fi.dy.masa.malilib.gui.GuiConfigsBase in project MasaGadget by plusls.

the class MixinWidgetListConfigOptions method filterFavorites.

@Inject(method = "getEntryStringsForFilter*", at = @At(value = "HEAD"), cancellable = true)
private void filterFavorites(GuiConfigsBase.ConfigOptionWrapper entry, CallbackInfoReturnable<List<String>> cir) {
    if (Configs.Malilib.FAVORITES_SUPPORT.getBooleanValue() && Configs.Malilib.favoritesFilter) {
        IConfigBase config = entry.getConfig();
        Screen screen = MinecraftClient.getInstance().currentScreen;
        if (!(screen instanceof GuiConfigsBase)) {
            return;
        }
        String modId = ((GuiConfigsBase) screen).getModId();
        if (config == null || !Configs.Malilib.FAVORITES.computeIfAbsent(modId, k -> new HashSet<>()).contains(config.getName())) {
            cir.setReturnValue(ImmutableList.of(""));
        }
    }
}
Also used : WidgetListConfigOptions(fi.dy.masa.malilib.gui.widgets.WidgetListConfigOptions) WidgetListConfigOptionsBase(fi.dy.masa.malilib.gui.widgets.WidgetListConfigOptionsBase) Inject(org.spongepowered.asm.mixin.injection.Inject) Collection(java.util.Collection) GuiConfigsBase(fi.dy.masa.malilib.gui.GuiConfigsBase) IConfigBase(fi.dy.masa.malilib.config.IConfigBase) Configs(com.plusls.MasaGadget.config.Configs) CallbackInfoReturnable(org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable) HashSet(java.util.HashSet) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) ImmutableList(com.google.common.collect.ImmutableList) Mixin(org.spongepowered.asm.mixin.Mixin) MinecraftClient(net.minecraft.client.MinecraftClient) WidgetConfigOption(fi.dy.masa.malilib.gui.widgets.WidgetConfigOption) At(org.spongepowered.asm.mixin.injection.At) Screen(net.minecraft.client.gui.screen.Screen) IConfigBase(fi.dy.masa.malilib.config.IConfigBase) GuiConfigsBase(fi.dy.masa.malilib.gui.GuiConfigsBase) HashSet(java.util.HashSet) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with GuiConfigsBase

use of fi.dy.masa.malilib.gui.GuiConfigsBase in project MasaGadget by plusls.

the class MasaGuiUtil method initMasaModScreenList.

private static void initMasaModScreenList() {
    initialised = true;
    MinecraftClient client = MinecraftClient.getInstance();
    if (!ModInfo.isModLoaded(ModInfo.MODMENU_MOD_ID)) {
        return;
    }
    FabricLoader.getInstance().getEntrypointContainers("modmenu", ModMenuApi.class).forEach(entrypoint -> {
        ModMetadata metadata = entrypoint.getProvider().getMetadata();
        try {
            ModMenuApi api = entrypoint.getEntrypoint();
            Screen screen = api.getModConfigScreenFactory().create(client.currentScreen);
            if (screen instanceof GuiConfigsBase) {
                ConfigScreenFactory<?> configScreenFactory = api.getModConfigScreenFactory();
                masaGuiData.put(configScreenFactory, metadata.getName());
                masaGuiClassData.put(screen.getClass(), configScreenFactory);
            }
        } catch (Throwable e) {
            ModInfo.LOGGER.error("Mod {} provides a broken implementation of ModMenuApi", metadata.getId(), e);
        }
    });
}
Also used : ModMetadata(net.fabricmc.loader.api.metadata.ModMetadata) Screen(net.minecraft.client.gui.screen.Screen) MinecraftClient(net.minecraft.client.MinecraftClient) GuiConfigsBase(fi.dy.masa.malilib.gui.GuiConfigsBase) ModMenuApi(com.terraformersmc.modmenu.api.ModMenuApi)

Example 3 with GuiConfigsBase

use of fi.dy.masa.malilib.gui.GuiConfigsBase in project tweakermore by Fallen-Breath.

the class WidgetListBaseMixin method drawTweakerMoreConfigGuiDropDownListAgain.

private void drawTweakerMoreConfigGuiDropDownListAgain(int mouseX, int mouseY) {
    if (this.isTweakerMoreConfigGui() && this.shouldRenderTweakerMoreConfigGuiDropDownList) {
        GuiConfigsBase guiConfig = ((WidgetListConfigOptionsAccessor) this).getParent();
        // render it again to make sure it's on the top but below hovering widgets
        ((TweakerMoreConfigGui) guiConfig).renderDropDownList(mouseX, mouseY);
        this.shouldRenderTweakerMoreConfigGuiDropDownList = false;
    }
}
Also used : GuiConfigsBase(fi.dy.masa.malilib.gui.GuiConfigsBase) TweakerMoreConfigGui(me.fallenbreath.tweakermore.gui.TweakerMoreConfigGui)

Example 4 with GuiConfigsBase

use of fi.dy.masa.malilib.gui.GuiConfigsBase in project MasaGadget by plusls.

the class MixinWidgetConfigOption method addFavoritesButton.

@Inject(method = "addConfigOption", at = @At(value = "RETURN"))
private void addFavoritesButton(int x, int y, float zLevel, int labelWidth, int configWidth, IConfigBase config, CallbackInfo ci) {
    if (!Configs.Malilib.FAVORITES_SUPPORT.getBooleanValue()) {
        return;
    }
    ConfigType type = config.getType();
    if (type == ConfigType.COLOR) {
        configWidth += 22;
    } else if (type == ConfigType.INTEGER || type == ConfigType.DOUBLE) {
        configWidth += 18;
    }
    Screen screen = MinecraftClient.getInstance().currentScreen;
    if (!(screen instanceof GuiConfigsBase)) {
        return;
    }
    String modId = ((GuiConfigsBase) screen).getModId();
    this.addWidget(new WidgetIconToggleButton(x + configWidth + 15 + this.getStringWidth(I18n.translate("malilib.gui.button.reset.caps")), y + 2, MasaGadgetIcons.FAVORITE, Configs.Malilib.FAVORITES.computeIfAbsent(modId, k -> new HashSet<>()).contains(config.getName()), status -> {
        HashSet<String> modFavorites = Configs.Malilib.FAVORITES.computeIfAbsent(modId, k -> new HashSet<>());
        if (status) {
            modFavorites.add(config.getName());
        } else {
            modFavorites.remove(config.getName());
        }
        Configs.saveToFile();
        Configs.loadFromFile();
    }, status -> status ? I18n.translate("masa_gadget_mod.message.cancelFavorite") : I18n.translate("masa_gadget_mod.message.setFavorite"), widgetIconToggleButton -> Configs.Malilib.FAVORITES_SUPPORT.getBooleanValue()));
}
Also used : MasaGadgetIcons(com.plusls.MasaGadget.gui.MasaGadgetIcons) WidgetListConfigOptionsBase(fi.dy.masa.malilib.gui.widgets.WidgetListConfigOptionsBase) I18n(net.minecraft.client.resource.language.I18n) Inject(org.spongepowered.asm.mixin.injection.Inject) ConfigType(fi.dy.masa.malilib.config.ConfigType) WidgetConfigOptionBase(fi.dy.masa.malilib.gui.widgets.WidgetConfigOptionBase) GuiConfigsBase(fi.dy.masa.malilib.gui.GuiConfigsBase) IConfigBase(fi.dy.masa.malilib.config.IConfigBase) Configs(com.plusls.MasaGadget.config.Configs) HashSet(java.util.HashSet) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) WidgetIconToggleButton(com.plusls.MasaGadget.gui.WidgetIconToggleButton) Screen(net.minecraft.client.gui.screen.Screen) Mixin(org.spongepowered.asm.mixin.Mixin) MinecraftClient(net.minecraft.client.MinecraftClient) WidgetConfigOption(fi.dy.masa.malilib.gui.widgets.WidgetConfigOption) At(org.spongepowered.asm.mixin.injection.At) Screen(net.minecraft.client.gui.screen.Screen) WidgetIconToggleButton(com.plusls.MasaGadget.gui.WidgetIconToggleButton) ConfigType(fi.dy.masa.malilib.config.ConfigType) GuiConfigsBase(fi.dy.masa.malilib.gui.GuiConfigsBase) HashSet(java.util.HashSet) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with GuiConfigsBase

use of fi.dy.masa.malilib.gui.GuiConfigsBase in project MasaGadget by plusls.

the class MixinWidgetListConfigOptions method addNonFilteredContents.

@Override
protected void addNonFilteredContents(Collection<GuiConfigsBase.ConfigOptionWrapper> placements) {
    if (Configs.Malilib.FAVORITES_SUPPORT.getBooleanValue() && Configs.Malilib.favoritesFilter) {
        Screen screen = MinecraftClient.getInstance().currentScreen;
        if (!(screen instanceof GuiConfigsBase)) {
            return;
        }
        String modId = ((GuiConfigsBase) screen).getModId();
        for (GuiConfigsBase.ConfigOptionWrapper configWrapper : placements) {
            IConfigBase config = configWrapper.getConfig();
            if (config != null && Configs.Malilib.FAVORITES.computeIfAbsent(modId, k -> new HashSet<>()).contains(config.getName())) {
                this.listContents.add(configWrapper);
            }
        }
    } else {
        this.listContents.addAll(placements);
    }
}
Also used : Screen(net.minecraft.client.gui.screen.Screen) IConfigBase(fi.dy.masa.malilib.config.IConfigBase) GuiConfigsBase(fi.dy.masa.malilib.gui.GuiConfigsBase)

Aggregations

GuiConfigsBase (fi.dy.masa.malilib.gui.GuiConfigsBase)5 Screen (net.minecraft.client.gui.screen.Screen)4 IConfigBase (fi.dy.masa.malilib.config.IConfigBase)3 MinecraftClient (net.minecraft.client.MinecraftClient)3 Configs (com.plusls.MasaGadget.config.Configs)2 WidgetConfigOption (fi.dy.masa.malilib.gui.widgets.WidgetConfigOption)2 WidgetListConfigOptionsBase (fi.dy.masa.malilib.gui.widgets.WidgetListConfigOptionsBase)2 HashSet (java.util.HashSet)2 Mixin (org.spongepowered.asm.mixin.Mixin)2 At (org.spongepowered.asm.mixin.injection.At)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 ImmutableList (com.google.common.collect.ImmutableList)1 MasaGadgetIcons (com.plusls.MasaGadget.gui.MasaGadgetIcons)1 WidgetIconToggleButton (com.plusls.MasaGadget.gui.WidgetIconToggleButton)1 ModMenuApi (com.terraformersmc.modmenu.api.ModMenuApi)1 ConfigType (fi.dy.masa.malilib.config.ConfigType)1 WidgetConfigOptionBase (fi.dy.masa.malilib.gui.widgets.WidgetConfigOptionBase)1 WidgetListConfigOptions (fi.dy.masa.malilib.gui.widgets.WidgetListConfigOptions)1 Collection (java.util.Collection)1 List (java.util.List)1