use of com.enderio.core.client.gui.button.CheckBox in project EnderIO by SleepyTrousers.
the class GuiPowerMonitor method drawControls.
private void drawControls(int sx, int sy) {
FontRenderer fr = getFontRenderer();
int textColor = ColorUtil.getRGB(engineControlEnabled.isSelected() ? Color.black : Color.darkGray);
int x0 = sx + TEXT_MARGIN_LEFT;
int y0 = sy + TEXT_MARGIN_TOP;
// Emit signal when storage less
String engineTxt1 = Lang.GUI_POWER_MONITOR_ENGINE_1.get().trim();
// than
String engineTxt2 = Lang.GUI_POWER_MONITOR_ENGINE_2.get().trim();
// % full.
String engineTxt3 = Lang.GUI_POWER_MONITOR_ENGINE_3.get().trim();
// Stop when storage greater than
String engineTxt4 = Lang.GUI_POWER_MONITOR_ENGINE_4.get().trim();
// or equal to
String engineTxt5 = Lang.GUI_POWER_MONITOR_ENGINE_5.get().trim();
List<Object> elems = new ArrayList<Object>();
elems.add(engineControlEnabled);
elems.addAll(Arrays.asList(engineTxt1.split("(\\s+)")));
elems.addAll(Arrays.asList(engineTxt2.split("(\\s+)")));
elems.add(engineControlStart);
elems.addAll(Arrays.asList(engineTxt3.split("(\\s+)")));
elems.addAll(Arrays.asList(engineTxt4.split("(\\s+)")));
elems.addAll(Arrays.asList(engineTxt5.split("(\\s+)")));
elems.add(engineControlStop);
elems.addAll(Arrays.asList(engineTxt3.split("(\\s+)")));
int x = 0, y = 0;
for (Object elem : elems) {
int elemWidth = 0;
if (elem instanceof String) {
elemWidth = fr.getStringWidth((String) elem);
} else if (elem instanceof CheckBox) {
elemWidth = ((CheckBox) elem).width;
} else if (elem instanceof TextFieldEnder) {
elemWidth = ((TextFieldEnder) elem).width;
}
if (x + elemWidth > TEXT_WIDTH) {
x = 0;
y += CONTROL_LF_PX;
if (" ".equals(elem)) {
continue;
}
}
if (elem instanceof String) {
fr.drawString((String) elem, x0 + x, y0 + y + TEXT_Y_OFFSET, textColor);
} else if (elem instanceof CheckBox) {
((CheckBox) elem).x = x0 + x;
((CheckBox) elem).y = y0 + y;
} else if (elem instanceof TextFieldEnder) {
((TextFieldEnder) elem).x = x0 + x;
((TextFieldEnder) elem).y = y0 + y;
}
x += elemWidth + fr.getStringWidth(" ");
}
}
Aggregations