/
JEIModConfigGui.java
46 lines (35 loc) · 1.75 KB
/
JEIModConfigGui.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package mezz.jei.config;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.fml.client.GuiModList;
import net.minecraftforge.fml.client.config.GuiConfig;
import net.minecraftforge.fml.client.config.IConfigElement;
import mezz.jei.util.Translator;
public class JEIModConfigGui extends GuiConfig {
public JEIModConfigGui(GuiScreen parent) {
super(parent, getConfigElements(), Constants.MOD_ID, false, false, getTitle(parent));
}
private static List<IConfigElement> getConfigElements() {
ConfigCategory categoryAdvanced = Config.configFile.getCategory(Config.categoryAdvanced);
ConfigCategory categoryInterface = Config.configFile.getCategory(Config.categoryInterface);
ConfigCategory categoryMode = Config.configFile.getCategory(Config.categoryMode);
ConfigCategory categoryAddons = Config.configFile.getCategory(Config.categoryAddons);
List<IConfigElement> configElements = new ArrayList<>();
configElements.addAll(new ConfigElement(categoryMode).getChildElements());
configElements.addAll(new ConfigElement(categoryInterface).getChildElements());
configElements.add(new ConfigElement(categoryAdvanced));
if (!categoryAddons.isEmpty() || categoryAddons.getChildren().size() > 0) {
configElements.add(new ConfigElement(categoryAddons));
}
return configElements;
}
private static String getTitle(GuiScreen parent) {
if (parent instanceof GuiModList) {
return GuiConfig.getAbridgedConfigPath(Config.configFile.toString());
}
return Translator.translateToLocal("config.jei.title").replace("%MODNAME", Constants.NAME);
}
}