use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class DynamicLabelWidget method drawInForeground.
@Override
@SideOnly(Side.CLIENT)
public void drawInForeground(int mouseX, int mouseY) {
String suppliedText = textSupplier.get();
if (!suppliedText.equals(lastTextValue)) {
this.lastTextValue = suppliedText;
updateSize();
}
String[] split = textSupplier.get().split("\n");
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
Position position = getPosition();
for (int i = 0; i < split.length; i++) {
fontRenderer.drawString(split[i], position.x, position.y + (i * (fontRenderer.FONT_HEIGHT + 2)), color);
}
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class ImageWidget method drawInBackground.
@Override
@SideOnly(Side.CLIENT)
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
if (!this.isVisible || area == null)
return;
Position position = getPosition();
Size size = getSize();
area.draw(position.x, position.y, size.width, size.height);
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class LabelWidget method drawInBackground.
@Override
@SideOnly(Side.CLIENT)
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
String resultText = getResultText();
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
Position pos = getPosition();
if (!xCentered) {
fontRenderer.drawString(resultText, pos.x, pos.y, color);
} else {
fontRenderer.drawString(resultText, pos.x - fontRenderer.getStringWidth(resultText) / 2, pos.y, color);
}
GlStateManager.color(1.0f, 1.0f, 1.0f);
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class ScrollableListWidget method drawInBackground.
@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
// make sure mouse is not hovered on any element when outside of bounds
if (!isPositionInsideScissor(mouseX, mouseY)) {
mouseX = Integer.MAX_VALUE;
mouseY = Integer.MAX_VALUE;
}
int finalMouseX = mouseX;
int finalMouseY = mouseY;
Position position = getPosition();
Size size = getSize();
int paneSize = scrollPaneWidth;
int scrollX = position.x + size.width - paneSize;
drawSolidRect(scrollX, position.y, paneSize, size.height, 0xFF666666);
drawSolidRect(scrollX + 1, position.y + 1, paneSize - 2, size.height - 2, 0xFF888888);
int maxScrollOffset = totalListHeight - getSize().height;
float scrollPercent = maxScrollOffset == 0 ? 0 : scrollOffset / (maxScrollOffset * 1.0f);
int scrollSliderHeight = 14;
int scrollSliderY = Math.round(position.y + (size.height - scrollSliderHeight) * scrollPercent);
drawGradientRect(scrollX + 1, scrollSliderY, paneSize - 2, scrollSliderHeight, 0xFF555555, 0xFF454545);
RenderUtil.useScissor(position.x, position.y, size.width - paneSize, size.height, () -> super.drawInBackground(finalMouseX, finalMouseY, context));
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class SimpleTextWidget method drawInBackground.
@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String text = formatLocale.isEmpty() ? (I18n.hasKey(lastText) ? I18n.format(lastText) : lastText) : I18n.format(formatLocale, lastText);
Position position = getPosition();
fontRenderer.drawString(text, position.x - fontRenderer.getStringWidth(text) / 2, position.y - fontRenderer.FONT_HEIGHT / 2, color);
GlStateManager.color(1.0f, 1.0f, 1.0f);
}
Aggregations