Skip to content

Commit 1f134ec

Browse files
AzureAaronlineargraph
authored andcommitted
Allow forcing the use of the values array in dropdowns
1 parent 444fda7 commit 1f134ec

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

common/src/main/java/io/github/notenoughupdates/moulconfig/gui/editors/GuiOptionEditorDropdown.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,27 @@ public class GuiOptionEditorDropdown extends ComponentEditor {
3737
private Enum<?>[] constants;
3838
private String valuesForSearch;
3939

40+
public GuiOptionEditorDropdown(ProcessedOption option, String[] values) {
41+
this(option, values, false);
42+
}
43+
4044
public GuiOptionEditorDropdown(
4145
ProcessedOption option,
42-
String[] values
46+
String[] values,
47+
boolean forceGivenValues
4348
) {
4449
super(option);
4550
Class<?> clazz = (Class<?>) option.getType();
4651
if (Enum.class.isAssignableFrom(clazz)) {
4752
constants = (Enum<?>[]) (clazz).getEnumConstants();
48-
this.values = new String[constants.length];
49-
for (int i = 0; i < constants.length; i++) {
50-
this.values[i] = constants[i].toString();
53+
if (forceGivenValues) {
54+
assert values.length == constants.length;
55+
this.values = values;
56+
} else {
57+
this.values = new String[constants.length];
58+
for (int i = 0; i < constants.length; i++) {
59+
this.values[i] = constants[i].toString();;
60+
}
5161
}
5262
} else {
5363
this.values = values;

0 commit comments

Comments
 (0)