use of gregtech.api.util.Size 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.Size 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.Size 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);
}
}
use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class Widget method isMouseOverElement.
public boolean isMouseOverElement(int mouseX, int mouseY) {
Position position = getPosition();
Size size = getSize();
return isMouseOver(position.x, position.y, size.width, size.height, mouseX, mouseY);
}
use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class Widget method toRectangleBox.
public Rectangle toRectangleBox() {
Position pos = getPosition();
Size size = getSize();
return new Rectangle(pos.x, pos.y, size.width, size.height);
}
Aggregations