MidnightLib 0.4.2 - Add opt-out from AutoModMenu

This commit is contained in:
Motschen
2022-06-06 17:57:05 +02:00
parent da2c76ed5f
commit 5ef681693e
6 changed files with 16 additions and 6 deletions

View File

@@ -5,9 +5,12 @@ import com.terraformersmc.modmenu.api.ModMenuApi;
import eu.midnightdust.core.config.MidnightLibConfig;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AutoModMenu implements ModMenuApi {
protected static List<String> hiddenMods = List.of();
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> MidnightLibConfig.getScreen(parent,"midnightlib");
@@ -16,7 +19,14 @@ public class AutoModMenu implements ModMenuApi {
@Override
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() {
HashMap<String, ConfigScreenFactory<?>> map = new HashMap<>();
MidnightConfig.configClass.forEach((modid, cClass) -> map.put(modid, parent -> MidnightConfig.getScreen(parent, modid)));
MidnightConfig.configClass.forEach((modid, cClass) -> {
if (!hiddenMods.contains(modid))
map.put(modid, parent -> MidnightConfig.getScreen(parent, modid));
}
);
return map;
}
public static void hideFromModMenu(String hiddenMod) {
hiddenMods.add(hiddenMod);
}
}

View File

@@ -379,7 +379,7 @@ public abstract class MidnightConfig {
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
buttons.forEach(b -> { b.y = y; b.render(matrices, mouseX, mouseY, tickDelta); });
if (text != null && (!text.getString().contains("spacer") || !buttons.isEmpty()))
DrawableHelper.drawTextWithShadow(matrices,textRenderer, text,12,y+5,0xFFFFFF);
DrawableHelper.drawTextWithShadow(matrices,textRenderer, text,12,y+5,0xFFFFFF);
}
public List<? extends Element> children() {return children;}
public List<? extends Selectable> selectableChildren() {return children;}