use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class AdvancedTextWidget method updateComponentTextSize.
@SideOnly(Side.CLIENT)
private void updateComponentTextSize() {
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
int maxStringWidth = 0;
int totalHeight = 0;
for (ITextComponent textComponent : displayText) {
maxStringWidth = Math.max(maxStringWidth, fontRenderer.getStringWidth(textComponent.getFormattedText()));
totalHeight += fontRenderer.FONT_HEIGHT + 2;
}
totalHeight -= 2;
setSize(new Size(maxStringWidth, totalHeight));
if (uiAccess != null) {
uiAccess.notifySizeChange();
}
}
use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class AbstractWidgetGroup method recomputeSize.
protected boolean recomputeSize() {
if (isDynamicSized) {
Size currentSize = getSize();
Size dynamicSize = computeDynamicSize();
if (!currentSize.equals(dynamicSize)) {
setSize(dynamicSize);
if (uiAccess != null)
uiAccess.notifySizeChange();
return true;
}
}
return false;
}
use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class ClickButtonWidget method drawInBackground.
@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
super.drawInBackground(mouseX, mouseY, context);
Position position = getPosition();
Size size = getSize();
if (buttonTexture instanceof SizedTextureArea) {
((SizedTextureArea) buttonTexture).drawHorizontalCutSubArea(position.x, position.y, size.width, size.height, 0.0, 1.0);
} else {
buttonTexture.drawSubArea(position.x, position.y, size.width, size.height, 0.0, 0.0, 1.0, 1.0);
}
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String text = I18n.format(displayText);
fontRenderer.drawString(text, position.x + size.width / 2 - fontRenderer.getStringWidth(text) / 2, position.y + size.height / 2 - fontRenderer.FONT_HEIGHT / 2, textColor);
GlStateManager.color(1.0f, 1.0f, 1.0f);
}
use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class CycleButtonWidget 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, 0.0, 1.0);
} else {
buttonTexture.drawSubArea(pos.x, pos.y, size.width, size.height, 0.0, 0.0, 1.0, 1.0);
}
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String text = I18n.format(optionNames[currentOption]);
fontRenderer.drawString(text, pos.x + size.width / 2 - fontRenderer.getStringWidth(text) / 2, pos.y + size.height / 2 - fontRenderer.FONT_HEIGHT / 2 + 1, textColor);
GlStateManager.color(1.0f, 1.0f, 1.0f);
}
use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class DynamicLabelWidget method updateSize.
@SideOnly(Side.CLIENT)
private void updateSize() {
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String resultText = lastTextValue;
setSize(new Size(fontRenderer.getStringWidth(resultText), fontRenderer.FONT_HEIGHT));
if (uiAccess != null) {
uiAccess.notifySizeChange();
}
}
Aggregations