public ControlPage(final IWidget parent, final int x, final int y, final int w, final int h, final T value) { super(parent, x, y, w, h); this.value = value; if (parent instanceof IControlValue) { IControlValue controlValue = (IControlValue) parent; if (controlValue.getValue() == null) { controlValue.setValue(value); } } }
public static <T> void linkWidgets(final IControlValue<T> tab, final IControlValue<T> target) { tab.addSelfEventHandler(EventValueChanged.class, event -> { target.setValue((T) event.getValue()); }); target.addSelfEventHandler(EventValueChanged.class, event -> { tab.setValue((T) event.getValue()); }); } }
@Override public boolean isChildVisible(final IWidget child) { return child != null && this.value == ((IControlValue) child).getValue(); }
@Override public Collection<T> getValues() { final List<T> list = new ArrayList<>(); for (final IWidget child : this.getChildren()) { list.add((T) ((IControlValue) child).getValue()); } return list; } }
public boolean isCurrentSelection() { return this.getValue().equals(((IControlValue) this.getParent()).getValue()); }
@Override @SideOnly(Side.CLIENT) public void onRenderForeground(int guiWidth, int guiHeight) { final ItemStack image = ((WindowDesigner) this.getTopParent()).getDesignerType().getDisplayStack(this.getValue()); RenderUtil.drawItem(new Point(1, 1), image); GlStateManager.disableBlend(); if (((IControlValue) this.getParent()).getValue() != this.getValue()) { if (Window.get(this).getMousedOverWidget() == this) { RenderUtil.drawGradientRect(this.getArea().inset(1), 1157627903, 1157627903); } else { RenderUtil.drawGradientRect(this.getArea().inset(1), -1433892728, -1433892728); } } GlStateManager.enableBlend(); } }