use of gregtech.api.gui.Widget in project GregTech by GregTechCE.
the class AbstractWidgetGroup method handleClientAction.
@Override
public void handleClientAction(int id, PacketBuffer buffer) {
if (id == 1) {
int widgetIndex = buffer.readVarInt();
int widgetUpdateId = buffer.readVarInt();
Widget widget = widgets.get(widgetIndex);
widget.handleClientAction(widgetUpdateId, buffer);
}
}
use of gregtech.api.gui.Widget in project GregTech by GregTechCE.
the class AbstractWidgetGroup method initWidget.
@Override
public void initWidget() {
this.initialized = true;
for (Widget widget : widgets) {
widget.setGui(gui);
widget.setSizes(sizes);
widget.initWidget();
}
}
use of gregtech.api.gui.Widget in project GregTech by GregTechCE.
the class AbstractWidgetGroup method getIngredientOverMouse.
@Override
public Object getIngredientOverMouse(int mouseX, int mouseY) {
if (!isVisible) {
return Collections.emptyList();
}
for (Widget widget : widgets) {
if (widget instanceof IIngredientSlot) {
IIngredientSlot ingredientSlot = (IIngredientSlot) widget;
Object result = ingredientSlot.getIngredientOverMouse(mouseX, mouseY);
if (result != null)
return result;
}
}
return null;
}
use of gregtech.api.gui.Widget in project GregTech by GregTechCE.
the class AbstractWidgetGroup method computeDynamicSize.
protected Size computeDynamicSize() {
Position selfPosition = getPosition();
Size currentSize = getSize();
for (Widget widget : widgets) {
Position size = widget.getPosition().add(widget.getSize()).subtract(selfPosition);
if (size.x > currentSize.width) {
currentSize = new Size(size.x, currentSize.height);
}
if (size.y > currentSize.height) {
currentSize = new Size(currentSize.width, size.y);
}
}
return currentSize;
}
use of gregtech.api.gui.Widget in project GregTech by GregTechCE.
the class ComponentGridWidget method mouseClicked.
@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
if (isMouseOverElement(mouseX, mouseY)) {
int mouseSlotX = (mouseX - getPosition().x - offset) / slotSize;
int mouseSlotY = (mouseY - getPosition().y - offset) / slotSize;
if (isValidPosition(mouseSlotX, mouseSlotY)) {
Widget widget = getWidgetAt(mouseSlotX, mouseSlotY);
if (button == 1) {
if (widget != null) {
removeWidget(widget);
return true;
}
} else if (button == 0 && widget == null) {
GridElementDef elementDef = new GridElementDef(1, 1, GridElementCable::new);
if (canPlaceWidgetAt(mouseSlotX, mouseSlotY, elementDef, ElementOrientation.TOP)) {
placeWidgetAt(mouseSlotX, mouseSlotY, elementDef, ElementOrientation.TOP);
return true;
}
}
}
}
return super.mouseClicked(mouseX, mouseY, button);
}
Aggregations