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;
}
}
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);
}
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("");
}
Aggregations