Search in sources :

Example 1 with TweakerMoreIConfigBase

use of me.fallenbreath.tweakermore.config.options.TweakerMoreIConfigBase in project tweakermore by Fallen-Breath.

the class WidgetListConfigOptionMixin method useMyBetterOptionLabelForTweakerMore.

@ModifyArgs(method = "addConfigOption", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/gui/widgets/WidgetConfigOption;addLabel(IIIII[Ljava/lang/String;)V", remap = false), remap = false)
private void useMyBetterOptionLabelForTweakerMore(Args args, int x_, int y_, float zLevel, int labelWidth, int configWidth, IConfigBase config) {
    if (isTweakerMoreConfigGui() || TweakerMoreConfigs.APPLY_TWEAKERMORE_OPTION_LABEL_GLOBALLY.getBooleanValue()) {
        int x = args.get(0);
        int y = args.get(1);
        int width = args.get(2);
        int height = args.get(3);
        int textColor = args.get(4);
        String[] lines = args.get(5);
        if (lines.length != 1) {
            return;
        }
        // cancel original call
        args.set(5, null);
        Function<String, String> modifier = s -> s;
        if (config instanceof TweakerMoreIConfigBase) {
            modifier = ((TweakerMoreIConfigBase) config).getGuiDisplayLineModifier();
        }
        TweakerMoreOptionLabel label = new TweakerMoreOptionLabel(x, y, width, height, textColor, lines, new String[] { config.getName() }, modifier);
        this.addWidget(label);
        this.showOriginalTextsThisTime = label.shouldShowOriginalLines();
    } else {
        this.showOriginalTextsThisTime = false;
    }
}
Also used : GuiConfigsBase(fi.dy.masa.malilib.gui.GuiConfigsBase) IKeybindConfigGui(fi.dy.masa.malilib.gui.interfaces.IKeybindConfigGui) TweakerMoreOptionLabel(me.fallenbreath.tweakermore.gui.TweakerMoreOptionLabel) IConfigBase(fi.dy.masa.malilib.config.IConfigBase) fi.dy.masa.malilib.gui.widgets(fi.dy.masa.malilib.gui.widgets) IHotkeyTogglable(fi.dy.masa.malilib.config.IHotkeyTogglable) Function(java.util.function.Function) CallbackInfoReturnable(org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable) ConfigButtonKeybind(fi.dy.masa.malilib.gui.button.ConfigButtonKeybind) TweakerMoreConfigs(me.fallenbreath.tweakermore.config.TweakerMoreConfigs) Objects(java.util.Objects) HotkeyedBooleanResetListener(me.fallenbreath.tweakermore.gui.HotkeyedBooleanResetListener) org.spongepowered.asm.mixin.injection(org.spongepowered.asm.mixin.injection) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) TweakerMoreConfigGui(me.fallenbreath.tweakermore.gui.TweakerMoreConfigGui) ConfigButtonBoolean(fi.dy.masa.malilib.gui.button.ConfigButtonBoolean) ConfigBooleanHotkeyed(fi.dy.masa.malilib.config.options.ConfigBooleanHotkeyed) TweakerMoreIConfigBase(me.fallenbreath.tweakermore.config.options.TweakerMoreIConfigBase) ConfigOptionChangeListenerButton(fi.dy.masa.malilib.config.gui.ConfigOptionChangeListenerButton) ButtonGeneric(fi.dy.masa.malilib.gui.button.ButtonGeneric) Args(org.spongepowered.asm.mixin.injection.invoke.arg.Args) org.spongepowered.asm.mixin(org.spongepowered.asm.mixin) fi.dy.masa.malilib.hotkeys(fi.dy.masa.malilib.hotkeys) StringUtils(fi.dy.masa.malilib.util.StringUtils) TweakerMoreIConfigBase(me.fallenbreath.tweakermore.config.options.TweakerMoreIConfigBase) TweakerMoreOptionLabel(me.fallenbreath.tweakermore.gui.TweakerMoreOptionLabel)

Example 2 with TweakerMoreIConfigBase

use of me.fallenbreath.tweakermore.config.options.TweakerMoreIConfigBase in project tweakermore by Fallen-Breath.

the class WidgetListConfigOptionMixin method addButtonAndHotkeyWidgets.

// #endif
private void addButtonAndHotkeyWidgets(int x, int y, int configWidth, IHotkey config) {
    IKeybind keybind = config.getKeybind();
    int triggerBtnWidth = (configWidth - 24) / 2;
    ButtonGeneric triggerButton = new ButtonGeneric(x, y, triggerBtnWidth, 20, StringUtils.translate("tweakermore.gui.trigger_button.text"), StringUtils.translate("tweakermore.gui.trigger_button.hover", config.getName()));
    this.addButton(triggerButton, (button, mouseButton) -> {
        IHotkeyCallback callback = ((KeybindMultiAccessor) keybind).getCallback();
        KeyAction activateOn = keybind.getSettings().getActivateOn();
        if (activateOn == KeyAction.BOTH || activateOn == KeyAction.PRESS) {
            callback.onKeyAction(KeyAction.PRESS, keybind);
        }
        if (activateOn == KeyAction.BOTH || activateOn == KeyAction.RELEASE) {
            callback.onKeyAction(KeyAction.RELEASE, keybind);
        }
        if (config instanceof TweakerMoreIConfigBase) {
            ((TweakerMoreIConfigBase) config).updateStatisticOnUse();
        }
    });
    x += triggerBtnWidth + 2;
    configWidth -= triggerBtnWidth + 2 + 22;
    ConfigButtonKeybind keybindButton = new ConfigButtonKeybind(x, y, configWidth, 20, keybind, this.host);
    x += configWidth + 2;
    this.addWidget(new WidgetKeybindSettings(x, y, 20, 20, keybind, config.getName(), this.parent, this.host.getDialogHandler()));
    // #if MC >= 11800
    // $$ x += 22;
    // #else
    x += 24;
    // #endif
    this.addButton(keybindButton, this.host.getButtonPressListener());
    this.addKeybindResetButton(x, y, keybind, keybindButton);
}
Also used : TweakerMoreIConfigBase(me.fallenbreath.tweakermore.config.options.TweakerMoreIConfigBase) ConfigButtonKeybind(fi.dy.masa.malilib.gui.button.ConfigButtonKeybind) ButtonGeneric(fi.dy.masa.malilib.gui.button.ButtonGeneric)

Example 3 with TweakerMoreIConfigBase

use of me.fallenbreath.tweakermore.config.options.TweakerMoreIConfigBase in project tweakermore by Fallen-Breath.

the class DocumentPrinter method printOption.

private static void printOption(Consumer<String> writeln, TweakerMoreOption tweakerMoreOption, String lang) {
    TweakerMoreIConfigBase config = tweakerMoreOption.getConfig();
    String configId = config.getName();
    String title = config.getConfigGuiDisplayName();
    if (!title.equals(configId)) {
        title += String.format(" (%s)", configId);
    }
    writeln.accept("### " + title);
    writeln.accept("");
    writeln.accept(getComment(config).replace("\n", "\n\n"));
    writeln.accept("");
    writeln.accept(String.format("- %s: %s", tr("category"), tweakerMoreOption.getCategory().getDisplayName()));
    writeln.accept(String.format("- %s: %s", tr("type"), getConfigType(config)));
    writeln.accept(String.format("- %s: %s", tr("default_value"), getDefaultValue(config)));
    getMinValue(config).ifPresent(min -> writeln.accept(String.format("- %s: `%s`", tr("minimum_value"), min)));
    getMaxValue(config).ifPresent(max -> writeln.accept(String.format("- %s: `%s`", tr("maximum_value"), max)));
    getOptionListValueNames(config).ifPresent(values -> writeln.accept(String.format("- %s: %s", tr("options"), Joiner.on(", ").join(values))));
    List<ModRestriction> modRestrictions = tweakerMoreOption.getModRestrictions();
    if (!modRestrictions.isEmpty()) {
        writeln.accept(String.format("- %s:", tr("mod_restrictions")));
        boolean first = true;
        for (ModRestriction modRestriction : modRestrictions) {
            if (!first) {
                writeln.accept("");
                writeln.accept(String.format("  *%s*", StringUtils.translate("tweakermore.gui.mod_relation_footer.or")));
                writeln.accept("");
            }
            first = false;
            if (!modRestriction.getRequirements().isEmpty()) {
                writeln.accept(String.format("  - %s:", tr("requirements")));
                modRestriction.getRequirements().forEach(req -> writeln.accept(String.format("    - %s", prettyPredicate(req))));
            }
            if (!modRestriction.getConflictions().isEmpty()) {
                writeln.accept(String.format("  - %s:", tr("conflictions")));
                modRestriction.getConflictions().forEach(cfl -> writeln.accept(String.format("    - %s", prettyPredicate(cfl))));
            }
        }
    }
    writeln.accept("");
    getScreenShotFileName(configId, lang).ifPresent(fileName -> {
        writeln.accept(String.format("![%s](%s/%s)", configId, ASSETS_DIRECTORY_NAME, fileName));
        writeln.accept("");
    });
    writeln.accept("");
}
Also used : TweakerMoreIConfigBase(me.fallenbreath.tweakermore.config.options.TweakerMoreIConfigBase) ModRestriction(me.fallenbreath.tweakermore.util.condition.ModRestriction)

Aggregations

TweakerMoreIConfigBase (me.fallenbreath.tweakermore.config.options.TweakerMoreIConfigBase)3 ButtonGeneric (fi.dy.masa.malilib.gui.button.ButtonGeneric)2 ConfigButtonKeybind (fi.dy.masa.malilib.gui.button.ConfigButtonKeybind)2 IConfigBase (fi.dy.masa.malilib.config.IConfigBase)1 IHotkeyTogglable (fi.dy.masa.malilib.config.IHotkeyTogglable)1 ConfigOptionChangeListenerButton (fi.dy.masa.malilib.config.gui.ConfigOptionChangeListenerButton)1 ConfigBooleanHotkeyed (fi.dy.masa.malilib.config.options.ConfigBooleanHotkeyed)1 GuiConfigsBase (fi.dy.masa.malilib.gui.GuiConfigsBase)1 ConfigButtonBoolean (fi.dy.masa.malilib.gui.button.ConfigButtonBoolean)1 IKeybindConfigGui (fi.dy.masa.malilib.gui.interfaces.IKeybindConfigGui)1 fi.dy.masa.malilib.gui.widgets (fi.dy.masa.malilib.gui.widgets)1 fi.dy.masa.malilib.hotkeys (fi.dy.masa.malilib.hotkeys)1 StringUtils (fi.dy.masa.malilib.util.StringUtils)1 Objects (java.util.Objects)1 Function (java.util.function.Function)1 TweakerMoreConfigs (me.fallenbreath.tweakermore.config.TweakerMoreConfigs)1 HotkeyedBooleanResetListener (me.fallenbreath.tweakermore.gui.HotkeyedBooleanResetListener)1 TweakerMoreConfigGui (me.fallenbreath.tweakermore.gui.TweakerMoreConfigGui)1 TweakerMoreOptionLabel (me.fallenbreath.tweakermore.gui.TweakerMoreOptionLabel)1 ModRestriction (me.fallenbreath.tweakermore.util.condition.ModRestriction)1