Add a second profiles button to Angelica

This commit is contained in:
SpacEagle17 authored and Jason Mitchell committed 2026-03-22 10:09:23 -07:00
1 parent e7d08a53b6
commit aff5ff7e7b
5 files changed
+41 -7

No files matched your search

@@ -97,6 +97,7 @@ public class ShaderProperties {
@Getter private OptionalBoolean prepareBeforeShadow = OptionalBoolean.DEFAULT;
@Getter private List<String> sliderOptions = new ArrayList<>();
@Getter private final Map<String, List<String>> profiles = new LinkedHashMap<>();
@Getter private final Map<String, List<String>> profiles2 = new LinkedHashMap<>();
private List<String> mainScreenOptions = null;
@Getter private final Map<String, List<String>> subScreenOptions = new HashMap<>();
private Integer mainScreenColumnCount = null;
@@ -517,6 +518,7 @@ public class ShaderProperties {
// the last definition being used, should be tested if behavior matches OptiFine
handleWhitespacedListDirective(key, value, "sliders", sliders -> sliderOptions = sliders);
handlePrefixedWhitespacedListDirective("profile.", key, value, profiles::put);
handlePrefixedWhitespacedListDirective("profile2.", key, value, profiles2::put);
if (handleIntDirective(key, value, "screen.columns", columns -> mainScreenColumnCount = columns)) {
return;
@@ -1,6 +1,7 @@
package net.coderbot.iris.shaderpack.option.menu;
import com.google.common.collect.Lists;
import lombok.Getter;
import net.coderbot.iris.Iris;
import net.coderbot.iris.shaderpack.ShaderProperties;
import net.coderbot.iris.shaderpack.option.ProfileSet;
@@ -21,10 +22,12 @@ public class OptionMenuContainer {
private final List<String> usedOptions = new ArrayList<>();
private final List<String> unusedOptions = new ArrayList<>(); // To be used when screens contain a "*" element
private final Map<List<OptionMenuElement>, Integer> unusedOptionDumpQueue = new HashMap<>(); // Used by screens with "*" element
private final ProfileSet profiles;
@Getter private final ProfileSet profiles;
@Getter private final ProfileSet profiles2;
public OptionMenuContainer(ShaderProperties shaderProperties, ShaderPackOptions shaderPackOptions, ProfileSet profiles) {
this.profiles = profiles;
this.profiles2 = ProfileSet.fromTree(shaderProperties.getProfiles2(), shaderPackOptions.getOptionSet());
// note: if the Shader Pack does not provide a list of options for the main screen, then dump all options on to
// the main screen by default.
@@ -68,10 +71,6 @@ public class OptionMenuContainer {
}
}
public ProfileSet getProfiles() {
return profiles;
}
// Screens will call this when they contain a "*" element, so that the list of
// unused options can be added after all other screens have been resolved
public void queueForUnusedOptionDump(int index, List<OptionMenuElement> elementList) {
@@ -12,6 +12,7 @@ public abstract class OptionMenuElement {
private static final String ELEMENT_EMPTY = "<empty>";
private static final String ELEMENT_PROFILE = "<profile>";
private static final String ELEMENT_PROFILE2 = "<profile2>";
public static OptionMenuElement create(String elementString, OptionMenuContainer container, ShaderProperties shaderProperties, ShaderPackOptions shaderPackOptions) throws IllegalArgumentException {
// Empty element
@@ -24,6 +25,13 @@ public abstract class OptionMenuElement {
// null indicates that the element should be forgotten (not treated as empty)
return container.getProfiles().size() > 0 ? new OptionMenuProfileElement(container.getProfiles(), shaderPackOptions.getOptionSet(), shaderPackOptions.getOptionValues()) : null;
}
// Second profile element
if (ELEMENT_PROFILE2.equals(elementString)) {
// null indicates that the element should be forgotten (not treated as empty)
return container.getProfiles2().size() > 0
? ProfileElementTracker.markSecondProfileSet(new OptionMenuProfileElement(container.getProfiles2(), shaderPackOptions.getOptionSet(), shaderPackOptions.getOptionValues()))
: null;
}
// Link to sub screen element
if (elementString.startsWith("[") && elementString.endsWith("]")) {
return new OptionMenuLinkElement(elementString.substring(1, elementString.length() - 1));
@@ -0,0 +1,22 @@
package net.coderbot.iris.shaderpack.option.menu;
import java.util.Collections;
import java.util.Set;
import java.util.WeakHashMap;
public final class ProfileElementTracker {
private static final Set<Object> SECOND_PROFILE_ELEMENTS =
Collections.newSetFromMap(new WeakHashMap<>());
private ProfileElementTracker() {
}
public static <T> T markSecondProfileSet(T element) {
SECOND_PROFILE_ELEMENTS.add(element);
return element;
}
public static boolean isSecondProfileSet(Object element) {
return SECOND_PROFILE_ELEMENTS.contains(element);
}
}