import me.ichun.mods.ichunutil.common.core.config.annotations.IntMinMax; //导入依赖的package包/类
public Tree(ConfigBase conf, ConfigBase.PropInfo obj, int h)
{
config = conf;
propInfo = obj;
theHeight = h;
try
{
obj.field.setAccessible(true);
Class clz = obj.field.getType();
if(clz.equals(int.class) || clz.equals(Integer.class))
{
int[] minmax = new int[] { Integer.MIN_VALUE, Integer.MAX_VALUE };
if(obj.field.isAnnotationPresent(IntMinMax.class))
{
IntMinMax minMax = obj.field.getAnnotation(IntMinMax.class);
minmax[0] = minMax.min();
minmax[1] = minMax.max();
element = new ElementNumberInput(parent, 0, 0, 200, 12, 0, "", 1, false, minmax[0], minmax[1], obj.field.getInt(conf));
}
else if(obj.field.isAnnotationPresent(IntBool.class))
{
element = new ElementToggle(parent, 0, 0, 0, 12, 0, false, 0, 0, "gui.yes", null, obj.field.getInt(conf) == 1);
}
else
{
element = new ElementNumberInput(parent, 0, 0, 200, 12, 0, "", 1, false, minmax[0], minmax[1], obj.field.getInt(conf));
}
}
else if(clz.equals(Colour.class))
{
element = new ElementTextInput(parent, 0, 0, 40, 12, 0, "", Integer.toHexString(((Colour)obj.field.get(conf)).getColour())); //last arg is current text
((ElementTextInput)element).textField.setMaxStringLength(6);
}
else if(clz.equals(String.class))
{
element = new ElementTextInput(parent, 0, 0, 40, 12, 0, "", (String)obj.field.get(conf)); //last arg is current text
}
else if(clz.equals(KeyBind.class))
{
element = new ElementButton(parent, 0, 0, 0, 12, 0, false, 0, 0, "");
}
else if(clz.equals(String[].class) || clz.equals(int[].class) || clz.equals(NestedIntArray.class))
{
element = new ElementButton(parent, 0, 0, 0, 12, 0, false, 0, 0, "Set");
}
}
catch(Exception ignored)
{
}
}
请发表评论