Search in sources :

Example 1 with IStructureConfig

use of com.silverminer.shrines.config.IStructureConfig in project Shrines by Silverminer007.

the class StructuresList method refreshList.

public void refreshList(Supplier<String> search) {
    this.clearEntries();
    List<AbstractStructure<NoFeatureConfig>> structs = NewStructureInit.STRUCTURES.values().stream().collect(Collectors.toList());
    structs.removeIf(struct -> struct == null);
    this.structures = structs.stream().map((config) -> {
        AbstractStructure<?> st = (AbstractStructure<?>) config.getStructure();
        return st.getConfig();
    }).collect(Collectors.toList());
    this.structures.removeIf(entry -> entry == null);
    List<String> structures = this.structures.stream().map(st -> st.getName()).collect(Collectors.toList());
    for (CustomStructureData d : Utils.getStructures(false)) {
        if (!structures.contains(d.getName())) {
            this.structures.add(d);
        }
    }
    if (!this.screen.builtInV) {
        this.structures.removeIf(st -> st.isBuiltIn());
    }
    if (!this.screen.customsV) {
        this.structures.removeIf(st -> !st.isBuiltIn());
    }
    Collections.sort(this.structures);
    String s = search.get().toLowerCase(Locale.ROOT);
    for (IStructureConfig cfg : this.structures) {
        if (cfg.getName().toLowerCase(Locale.ROOT).contains(s)) {
            this.addEntry(new StructuresList.Entry(this, cfg));
        }
    }
}
Also used : AbstractStructure(com.silverminer.shrines.structures.AbstractStructure) DynamicTexture(net.minecraft.client.renderer.texture.DynamicTexture) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) ConfirmScreen(net.minecraft.client.gui.screen.ConfirmScreen) Util(net.minecraft.util.Util) NewStructureInit(com.silverminer.shrines.init.NewStructureInit) Style(net.minecraft.util.text.Style) NoFeatureConfig(net.minecraft.world.gen.feature.NoFeatureConfig) Hashing(com.google.common.hash.Hashing) ConfigStructureScreen(com.silverminer.shrines.client.gui.config.options.ConfigStructureScreen) NativeImage(net.minecraft.client.renderer.texture.NativeImage) Supplier(java.util.function.Supplier) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Dist(net.minecraftforge.api.distmarker.Dist) Minecraft(net.minecraft.client.Minecraft) Locale(java.util.Locale) Color(net.minecraft.util.text.Color) Utils(com.silverminer.shrines.utils.custom_structures.Utils) StringTextComponent(net.minecraft.util.text.StringTextComponent) CustomStructureData(com.silverminer.shrines.structures.custom.helper.CustomStructureData) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) IStructureConfig(com.silverminer.shrines.config.IStructureConfig) Nullable(javax.annotation.Nullable) WorkingScreen(net.minecraft.client.gui.screen.WorkingScreen) ExtendedList(net.minecraft.client.gui.widget.list.ExtendedList) FileInputStream(java.io.FileInputStream) Collectors(java.util.stream.Collectors) File(java.io.File) AbstractGui(net.minecraft.client.gui.AbstractGui) List(java.util.List) Validate(org.apache.commons.lang3.Validate) Logger(org.apache.logging.log4j.Logger) DialogTexts(net.minecraft.client.gui.DialogTexts) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) ShrinesMod(com.silverminer.shrines.ShrinesMod) ResourceLocation(net.minecraft.util.ResourceLocation) Optional(java.util.Optional) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) InputStream(java.io.InputStream) CustomStructureData(com.silverminer.shrines.structures.custom.helper.CustomStructureData) AbstractStructure(com.silverminer.shrines.structures.AbstractStructure) IStructureConfig(com.silverminer.shrines.config.IStructureConfig)

Example 2 with IStructureConfig

use of com.silverminer.shrines.config.IStructureConfig in project Shrines by Silverminer007.

the class ConfigStructureScreen method init.

@Override
public void init(Minecraft mc, int width, int height) {
    super.init(mc, width, height);
    IStructureConfig config = StructureUtils.getConfigOf(this.configSpecs.getName(), false);
    this.configSpecs = config != null ? config : this.configSpecs;
    int titleHeight = mc.font.wordWrapHeight(title.getString(), width - 2 * PADDING);
    int paddedTitleHeight = titleHeight + PADDING * 2;
    addButton(width - 120 - 2 * PADDING, 0, 60, paddedTitleHeight, new StringTextComponent("Back"), button -> mc.setScreen(parent));
    this.saveButton = addButton(width - 60 - PADDING, 0, 60, paddedTitleHeight, new StringTextComponent("Save"), button -> {
        this.optionList.commitChanges();
        // change(with commitChanges)
        if (this.configSpecs instanceof CustomStructureData) {
            CustomStructureData csd = (CustomStructureData) this.configSpecs;
            for (Entry e : this.optionList.children()) {
                if (e instanceof NameEntry) {
                    csd.name = ((NameEntry) e).data.getName();
                } else if (e instanceof OptionEntry) {
                    OptionEntry oe = (OptionEntry) e;
                    csd.fromString(oe.getOption().getName(), oe.getOption().getValue().toString());
                }
            }
            if (this.isNew) {
                Utils.addStructure(csd, false);
            } else {
                Utils.replace(csd, false);
            }
            Utils.saveStructures();
        }
        mc.setScreen(parent);
    });
    int optionListHeaderHeight = titleHeight + 2 * PADDING;
    this.optionList = new ModOptionList(configSpecs, minecraft, width, height, optionListHeaderHeight, height - optionListHeaderHeight, 26, isNew);
    this.children.add(optionList);
    ConfigStructureScreen.this.updateValid();
}
Also used : OptionParsingResult(com.silverminer.shrines.utils.custom_structures.OptionParsingResult) AbstractOptionList(net.minecraft.client.gui.widget.list.AbstractOptionList) Arrays(java.util.Arrays) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) IGuiEventListener(net.minecraft.client.gui.IGuiEventListener) Random(java.util.Random) NameEntry(com.silverminer.shrines.client.gui.config.options.ConfigStructureScreen.ModOptionList.NameEntry) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Dist(net.minecraftforge.api.distmarker.Dist) I18n(net.minecraft.client.resources.I18n) IConfigOption(com.silverminer.shrines.config.IConfigOption) ImmutableList(com.google.common.collect.ImmutableList) Minecraft(net.minecraft.client.Minecraft) Locale(java.util.Locale) TextFieldWidget(net.minecraft.client.gui.widget.TextFieldWidget) Button(net.minecraft.client.gui.widget.button.Button) Utils(com.silverminer.shrines.utils.custom_structures.Utils) StringTextComponent(net.minecraft.util.text.StringTextComponent) StructureUtils(com.silverminer.shrines.utils.StructureUtils) CustomStructureData(com.silverminer.shrines.structures.custom.helper.CustomStructureData) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) IStructureConfig(com.silverminer.shrines.config.IStructureConfig) PieceData(com.silverminer.shrines.structures.custom.helper.PieceData) ValidationStatusButton(com.silverminer.shrines.client.gui.config.widgets.buttons.ValidationStatusButton) CheckboxButtonEx(com.silverminer.shrines.client.gui.config.widgets.buttons.CheckboxButtonEx) ConfigOption(com.silverminer.shrines.structures.custom.helper.ConfigOption) SharedConstants(net.minecraft.util.SharedConstants) AddResourceScreen(com.silverminer.shrines.client.gui.config.resource.AddResourceScreen) Collectors(java.util.stream.Collectors) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Screen(net.minecraft.client.gui.screen.Screen) StringUtils(net.minecraft.util.StringUtils) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) OptionEntry(com.silverminer.shrines.client.gui.config.options.ConfigStructureScreen.ModOptionList.OptionEntry) LogManager(org.apache.logging.log4j.LogManager) ExtendedButton(net.minecraftforge.fml.client.gui.widget.ExtendedButton) Entry(com.silverminer.shrines.client.gui.config.options.ConfigStructureScreen.ModOptionList.Entry) NameEntry(com.silverminer.shrines.client.gui.config.options.ConfigStructureScreen.ModOptionList.NameEntry) OptionEntry(com.silverminer.shrines.client.gui.config.options.ConfigStructureScreen.ModOptionList.OptionEntry) Entry(com.silverminer.shrines.client.gui.config.options.ConfigStructureScreen.ModOptionList.Entry) CustomStructureData(com.silverminer.shrines.structures.custom.helper.CustomStructureData) OptionEntry(com.silverminer.shrines.client.gui.config.options.ConfigStructureScreen.ModOptionList.OptionEntry) StringTextComponent(net.minecraft.util.text.StringTextComponent) NameEntry(com.silverminer.shrines.client.gui.config.options.ConfigStructureScreen.ModOptionList.NameEntry) IStructureConfig(com.silverminer.shrines.config.IStructureConfig)

Example 3 with IStructureConfig

use of com.silverminer.shrines.config.IStructureConfig in project Shrines by Silverminer007.

the class NormalListScreen method save.

@Override
protected void save() {
    IStructureConfig csd = this.screen.getConfig();
    csd.fromString(this.option, this.activeValues.toString());
    this.screen.setConfig(csd);
    this.parent = screen;
}
Also used : IStructureConfig(com.silverminer.shrines.config.IStructureConfig)

Aggregations

IStructureConfig (com.silverminer.shrines.config.IStructureConfig)3 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)2 CustomStructureData (com.silverminer.shrines.structures.custom.helper.CustomStructureData)2 Utils (com.silverminer.shrines.utils.custom_structures.Utils)2 List (java.util.List)2 Locale (java.util.Locale)2 Collectors (java.util.stream.Collectors)2 Minecraft (net.minecraft.client.Minecraft)2 ITextComponent (net.minecraft.util.text.ITextComponent)2 StringTextComponent (net.minecraft.util.text.StringTextComponent)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 Dist (net.minecraftforge.api.distmarker.Dist)2 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)2 LogManager (org.apache.logging.log4j.LogManager)2 Logger (org.apache.logging.log4j.Logger)2 ImmutableList (com.google.common.collect.ImmutableList)1 Hashing (com.google.common.hash.Hashing)1 ShrinesMod (com.silverminer.shrines.ShrinesMod)1 ConfigStructureScreen (com.silverminer.shrines.client.gui.config.options.ConfigStructureScreen)1