use of gregtech.api.gui.Widget in project GregTech by GregTechCE.
the class PipeGridElementWidget method determineConnections.
private int determineConnections() {
ComponentGridWidget gridWidget = parentWidget;
if (gridWidget == null) {
return 0;
}
Position self = gridWidget.getWidgetOrigin(this);
int resultConnections = 0;
for (ElementOrientation orientation : ElementOrientation.values()) {
Position position = new Position(self.x + orientation.offsetX, self.y + orientation.offsetY);
Widget widget = gridWidget.getWidgetAt(position.x, position.y);
Position origin = gridWidget.getWidgetOrigin(widget);
Position relativePos = position.subtract(origin);
if (widget instanceof GridElementWidget && ((GridElementWidget) widget).canConnect(orientation.getOpposite(), relativePos, connectionType)) {
resultConnections |= 1 << orientation.ordinal();
}
}
return resultConnections;
}
use of gregtech.api.gui.Widget in project GregTech by GregTechCE.
the class ScrollableListWidget method updateElementPositions.
private void updateElementPositions() {
Position position = getPosition();
int currentPosY = position.y - scrollOffset;
int totalListHeight = 0;
for (Widget widget : widgets) {
Position childPosition = new Position(position.x, currentPosY);
widget.setParentPosition(childPosition);
currentPosY += widget.getSize().getHeight();
totalListHeight += widget.getSize().getHeight();
final Size size = getSize();
widget.applyScissor(position.x, position.y, size.width - scrollPaneWidth, size.height);
}
this.totalListHeight = totalListHeight;
this.slotHeight = widgets.isEmpty() ? 0 : totalListHeight / widgets.size();
}
use of gregtech.api.gui.Widget in project GregTech by GregTechCE.
the class SimpleFluidFilter method initUI.
@Override
public void initUI(Consumer<Widget> widgetGroup) {
for (int i = 0; i < 9; ++i) {
int index = i;
widgetGroup.accept((new PhantomFluidWidget(10 + 18 * (i % 3), 18 * (i / 3), 18, 18, () -> getFluidInSlot(index), (newFluid) -> setFluidInSlot(index, newFluid))).setBackgroundTexture(GuiTextures.SLOT));
}
}
use of gregtech.api.gui.Widget in project GregTech by GregTechCE.
the class RecipeMapCategory method drawExtras.
@Override
public void drawExtras(Minecraft minecraft) {
for (Widget widget : modularUI.guiWidgets.values()) {
widget.drawInBackground(0, 0, new IRenderContext() {
});
widget.drawInForeground(0, 0);
}
}
use of gregtech.api.gui.Widget in project GregTech by GregTechCE.
the class RecipeMapCategory method setRecipe.
@Override
public void setRecipe(IRecipeLayout recipeLayout, GTRecipeWrapper recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup itemStackGroup = recipeLayout.getItemStacks();
IGuiFluidStackGroup fluidStackGroup = recipeLayout.getFluidStacks();
for (Widget uiWidget : modularUI.guiWidgets.values()) {
if (uiWidget instanceof SlotWidget) {
SlotWidget slotWidget = (SlotWidget) uiWidget;
if (!(slotWidget.getHandle() instanceof SlotItemHandler)) {
continue;
}
SlotItemHandler handle = (SlotItemHandler) slotWidget.getHandle();
if (handle.getItemHandler() == importItems) {
// this is input item stack slot widget, so add it to item group
itemStackGroup.init(handle.getSlotIndex(), true, slotWidget.getPosition().x, slotWidget.getPosition().y);
} else if (handle.getItemHandler() == exportItems) {
// this is output item stack slot widget, so add it to item group
itemStackGroup.init(importItems.getSlots() + handle.getSlotIndex(), false, slotWidget.getPosition().x, slotWidget.getPosition().y);
}
} else if (uiWidget instanceof TankWidget) {
TankWidget tankWidget = (TankWidget) uiWidget;
if (importFluids.getFluidTanks().contains(tankWidget.fluidTank)) {
int importIndex = importFluids.getFluidTanks().indexOf(tankWidget.fluidTank);
List<List<FluidStack>> inputsList = ingredients.getInputs(FluidStack.class);
int fluidAmount = 0;
if (inputsList.size() > importIndex && !inputsList.get(importIndex).isEmpty())
fluidAmount = inputsList.get(importIndex).get(0).amount;
// this is input tank widget, so add it to fluid group
fluidStackGroup.init(importIndex, true, tankWidget.getPosition().x + tankWidget.fluidRenderOffset, tankWidget.getPosition().y + tankWidget.fluidRenderOffset, tankWidget.getSize().width - (2 * tankWidget.fluidRenderOffset), tankWidget.getSize().height - (2 * tankWidget.fluidRenderOffset), fluidAmount, false, null);
} else if (exportFluids.getFluidTanks().contains(tankWidget.fluidTank)) {
int exportIndex = exportFluids.getFluidTanks().indexOf(tankWidget.fluidTank);
List<List<FluidStack>> inputsList = ingredients.getOutputs(FluidStack.class);
int fluidAmount = 0;
if (inputsList.size() > exportIndex && !inputsList.get(exportIndex).isEmpty())
fluidAmount = inputsList.get(exportIndex).get(0).amount;
// this is output tank widget, so add it to fluid group
fluidStackGroup.init(importFluids.getFluidTanks().size() + exportIndex, false, tankWidget.getPosition().x + tankWidget.fluidRenderOffset, tankWidget.getPosition().y + tankWidget.fluidRenderOffset, tankWidget.getSize().width - (2 * tankWidget.fluidRenderOffset), tankWidget.getSize().height - (2 * tankWidget.fluidRenderOffset), fluidAmount, false, null);
}
}
}
itemStackGroup.addTooltipCallback(recipeWrapper::addTooltip);
fluidStackGroup.addTooltipCallback(recipeWrapper::addTooltip);
itemStackGroup.set(ingredients);
fluidStackGroup.set(ingredients);
}
Aggregations