Fix enum entries
This commit is contained in:
parent
08f6a9821b
commit
163b1524a8
|
@ -38,6 +38,15 @@ public class ConfigEnumEntry extends Entry<Integer> {
|
|||
return val instanceof ConfigEnumEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendString(StringBuilder sb) {
|
||||
sb.append(getValueName()).append('/').append(getValue()).append(" (").append(getDefaultName()).append('/').append(getDefault()).append(" of:");
|
||||
for (Map.Entry<String, Integer> e : values.entrySet()) {
|
||||
sb.append(' ').append(e.getKey()).append('/').append(e.getValue());
|
||||
}
|
||||
sb.append(')');
|
||||
}
|
||||
|
||||
public void setFieldName(String s) {
|
||||
if (s != null)
|
||||
fieldName = s;
|
||||
|
|
|
@ -6,7 +6,7 @@ import io.gitlab.jfronny.respackopts.data.RpoError;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
//TODO implement equality checking for string/number variables
|
||||
|
||||
public class EqualityCondition implements Condition {
|
||||
@Override
|
||||
public boolean evaluate(JsonElement node) throws RpoError {
|
||||
|
@ -15,7 +15,7 @@ public class EqualityCondition implements Condition {
|
|||
Optional<Boolean> v = Optional.empty();
|
||||
for (JsonElement jsonElement : node.getAsJsonArray()) {
|
||||
boolean current = ConditionEvaluator.evaluate(jsonElement);
|
||||
if (!v.isPresent())
|
||||
if (v.isEmpty())
|
||||
v = Optional.of(current);
|
||||
if (current != v.get())
|
||||
return false;
|
||||
|
|
|
@ -21,7 +21,6 @@ import net.minecraft.util.Language;
|
|||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
//TODO fix enums always showing "reset" and not saving/loading properly from GUI
|
||||
public class GuiFactory {
|
||||
public void buildCategory(ConfigBranch source, String screenId, JfConfigCategory config, ConfigEntryBuilder entryBuilder, String namePrefix) {
|
||||
String b = "respackopts.field." + screenId;
|
||||
|
@ -43,8 +42,8 @@ public class GuiFactory {
|
|||
}
|
||||
else if (entry instanceof ConfigEnumEntry e) {
|
||||
config.addEntry(entryBuilder.startDropdownMenu(getText(n, b),
|
||||
DropdownMenuBuilder.TopCellElementBuilder.of(e.getValueName(), LiteralText::new),
|
||||
new DropdownBoxEntry.DefaultSelectionCellCreator())
|
||||
DropdownMenuBuilder.TopCellElementBuilder.of(e.getValueName(), s -> s, LiteralText::new),
|
||||
new DropdownBoxEntry.DefaultSelectionCellCreator<>())
|
||||
.setSuggestionMode(false)
|
||||
.setDefaultValue(e.getDefaultName())
|
||||
.setSelections(() -> e.values.keySet().iterator())
|
||||
|
|
Loading…
Reference in New Issue
Block a user