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