use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class GridConnection method draw.
public void draw() {
Position position = getPosition();
ElementOrientation orientation = getOrientation();
connectionType.icon.drawRotated(position.x, position.y, elementSize, new PositionedRect(Position.ORIGIN, elementSize), orientation.rotationValue);
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class GridConnection method computePosition.
private Position computePosition() {
Transformation orientation = TextureArea.createOrientation(parentElementSize, parentOrientation.rotationValue);
PositionedRect parentRect = TextureArea.transformRect(orientation, parentElementRect);
switch(getOrientation()) {
case LEFT:
return new Position(0, connectionOffset);
case RIGHT:
return new Position(parentRect.position.x + parentRect.size.width, connectionOffset);
case TOP:
return new Position(connectionOffset, 0);
case BOTTOM:
return new Position(connectionOffset, parentRect.position.y + parentRect.size.height);
default:
return Position.ORIGIN;
}
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class SliderWidget method mouseClicked.
@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
if (isMouseOverElement(mouseX, mouseY)) {
Position pos = getPosition();
Size size = getSize();
this.sliderPosition = (float) (mouseX - (pos.x + 4)) / (float) (size.width - 8);
if (this.sliderPosition < 0.0F) {
this.sliderPosition = 0.0F;
}
if (this.sliderPosition > 1.0F) {
this.sliderPosition = 1.0F;
}
this.displayString = this.getDisplayString();
writeClientAction(1, buffer -> buffer.writeFloat(sliderPosition));
this.isMouseDown = true;
return true;
}
return false;
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class TankWidget method drawInBackground.
@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
Position pos = getPosition();
Size size = getSize();
if (backgroundTexture != null) {
for (TextureArea textureArea : backgroundTexture) {
textureArea.draw(pos.x, pos.y, size.width, size.height);
}
}
// do not draw fluids if they are handled by JEI - it draws them itself
if (lastFluidInTank != null && lastFluidInTank.amount > 0 && !gui.isJEIHandled) {
GlStateManager.disableBlend();
RenderUtil.drawFluidForGui(lastFluidInTank, alwaysShowFull ? lastFluidInTank.amount : lastTankCapacity, pos.x + fluidRenderOffset, pos.y + fluidRenderOffset, size.width - fluidRenderOffset, size.height - fluidRenderOffset);
int bucketsAmount = lastFluidInTank.amount / 1000;
if (alwaysShowFull && !hideTooltip && bucketsAmount > 0) {
String s = String.valueOf(bucketsAmount);
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
fontRenderer.drawStringWithShadow(s, pos.x + 1 + size.width - 2 - fontRenderer.getStringWidth(s), pos.y + (size.height / 3) + 3, 0xFFFFFF);
}
GlStateManager.enableBlend();
GlStateManager.color(1.0f, 1.0f, 1.0f);
}
if (overlayTexture != null) {
overlayTexture.draw(pos.x, pos.y, size.width, size.height);
}
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class ToggleButtonWidget method drawInBackground.
@Override
@SideOnly(Side.CLIENT)
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
Position pos = getPosition();
Size size = getSize();
if (buttonTexture instanceof SizedTextureArea) {
((SizedTextureArea) buttonTexture).drawHorizontalCutSubArea(pos.x, pos.y, size.width, size.height, isPressed ? 0.5 : 0.0, 0.5);
} else {
buttonTexture.drawSubArea(pos.x, pos.y, size.width, size.height, 0.0, isPressed ? 0.5 : 0.0, 1.0, 0.5);
}
}
Aggregations