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