use of gregtech.api.gui.resources.IGuiTexture in project GregTech by GregTechCEu.
the class TankWidget method drawInBackground.
@Override
public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) {
Position pos = getPosition();
Size size = getSize();
if (backgroundTexture != null) {
for (IGuiTexture 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 && !gui.isJEIHandled) {
GlStateManager.disableBlend();
FluidStack stackToDraw = lastFluidInTank;
int drawAmount = alwaysShowFull ? lastFluidInTank.amount : lastTankCapacity;
if (alwaysShowFull && lastFluidInTank.amount == 0) {
stackToDraw = lastFluidInTank.copy();
stackToDraw.amount = 1;
drawAmount = 1;
}
RenderUtil.drawFluidForGui(stackToDraw, drawAmount, pos.x + fluidRenderOffset, pos.y + fluidRenderOffset, size.width - fluidRenderOffset, size.height - fluidRenderOffset);
if (alwaysShowFull && !hideTooltip && drawHoveringText) {
GlStateManager.pushMatrix();
GlStateManager.scale(0.5, 0.5, 1);
String s = TextFormattingUtil.formatLongToCompactString(lastFluidInTank.amount, 4) + "L";
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
fontRenderer.drawStringWithShadow(s, (pos.x + (size.width / 3)) * 2 - fontRenderer.getStringWidth(s) + 21, (pos.y + (size.height / 3) + 6) * 2, 0xFFFFFF);
GlStateManager.popMatrix();
}
GlStateManager.enableBlend();
}
if (overlayTexture != null) {
overlayTexture.draw(pos.x, pos.y, size.width, size.height);
}
}
use of gregtech.api.gui.resources.IGuiTexture in project GregTech by GregTechCEu.
the class SlotWidget method drawInBackground.
@Override
@SideOnly(Side.CLIENT)
public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) {
Position pos = getPosition();
Size size = getSize();
if (backgroundTexture != null) {
for (IGuiTexture backgroundTexture : this.backgroundTexture) {
backgroundTexture.draw(pos.x, pos.y, size.width, size.height);
}
}
ItemStack itemStack = slotReference.getStack();
ModularUIGui modularUIGui = gui == null ? null : gui.getModularUIGui();
if (itemStack.isEmpty() && modularUIGui != null && modularUIGui.getDragSplitting() && modularUIGui.getDragSplittingSlots().contains(slotReference)) {
// draw split
int splitSize = modularUIGui.getDragSplittingSlots().size();
itemStack = gui.entityPlayer.inventory.getItemStack();
if (!itemStack.isEmpty() && splitSize > 1 && Container.canAddItemToSlot(slotReference, itemStack, true)) {
itemStack = itemStack.copy();
Container.computeStackSize(modularUIGui.getDragSplittingSlots(), modularUIGui.dragSplittingLimit, itemStack, slotReference.getStack().isEmpty() ? 0 : slotReference.getStack().getCount());
int k = Math.min(itemStack.getMaxStackSize(), slotReference.getItemStackLimit(itemStack));
if (itemStack.getCount() > k) {
itemStack.setCount(k);
}
}
}
if (!itemStack.isEmpty()) {
GlStateManager.enableBlend();
GlStateManager.enableDepth();
GlStateManager.disableRescaleNormal();
GlStateManager.disableLighting();
RenderHelper.disableStandardItemLighting();
RenderHelper.enableStandardItemLighting();
RenderHelper.enableGUIStandardItemLighting();
GlStateManager.pushMatrix();
RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
itemRender.renderItemAndEffectIntoGUI(itemStack, pos.x + 1, pos.y + 1);
itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRenderer, itemStack, pos.x + 1, pos.y + 1, null);
GlStateManager.enableAlpha();
GlStateManager.popMatrix();
RenderHelper.disableStandardItemLighting();
}
if (isActive()) {
if (slotReference instanceof ISlotWidget) {
if (isMouseOverElement(mouseX, mouseY)) {
GlStateManager.disableDepth();
GlStateManager.colorMask(true, true, true, false);
drawSolidRect(getPosition().x + 1, getPosition().y + 1, 16, 16, -2130706433);
GlStateManager.colorMask(true, true, true, true);
GlStateManager.enableDepth();
GlStateManager.enableBlend();
}
}
} else {
GlStateManager.disableDepth();
GlStateManager.colorMask(true, true, true, false);
drawSolidRect(getPosition().x + 1, getPosition().y + 1, 16, 16, 0xbf000000);
GlStateManager.colorMask(true, true, true, true);
GlStateManager.enableDepth();
GlStateManager.enableBlend();
}
}
use of gregtech.api.gui.resources.IGuiTexture in project GregTech by GregTechCEu.
the class TreeListWidget method drawInBackground.
@Override
public void drawInBackground(int mouseX, int mouseY, float partialTicks, IRenderContext context) {
int x = getPosition().x;
int y = getPosition().y;
int width = getSize().width;
int height = getSize().height;
if (background != null) {
background.draw(x, y, width, height);
} else {
drawGradientRect(x, y, width, height, 0x8f000000, 0x8f000000);
}
RenderUtil.useScissor(x, y, width, height, () -> {
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
int minToRender = scrollOffset / ITEM_HEIGHT;
int maxToRender = Math.min(list.size(), height / ITEM_HEIGHT + 2 + minToRender);
for (int i = minToRender; i < maxToRender; i++) {
GlStateManager.color(1, 1, 1, 1);
TreeNode<K, T> node = list.get(i);
int sX = x + 10 * node.dimension;
int sY = y - scrollOffset + i * ITEM_HEIGHT;
String name = node.toString();
if (node.isLeaf()) {
if (leafTexture != null) {
leafTexture.draw(x, sY, width, ITEM_HEIGHT);
} else {
drawSolidRect(x, sY, width, ITEM_HEIGHT, 0xffff0000);
}
if (node.getContent() != null) {
String nameS = contentNameSupplier == null ? null : contentNameSupplier.apply(node.getContent());
name = nameS == null ? name : nameS;
IGuiTexture icon = contentIconSupplier == null ? null : contentIconSupplier.apply(node.getContent());
if (icon != null) {
icon.draw(sX - 9, sY + 1, 8, 8);
}
}
} else {
if (nodeTexture != null) {
nodeTexture.draw(x, sY, width, ITEM_HEIGHT);
} else {
drawSolidRect(x, sY, width, ITEM_HEIGHT, 0xffffff00);
}
String nameS = keyNameSupplier == null ? null : keyNameSupplier.apply(node.getKey());
name = nameS == null ? name : nameS;
IGuiTexture icon = keyIconSupplier == null ? null : keyIconSupplier.apply(node.getKey());
if (icon != null) {
icon.draw(sX - 9, sY + 1, 8, 8);
}
}
if (node == selected) {
drawSolidRect(x, sY, width, ITEM_HEIGHT, 0x7f000000);
}
int textW = Math.max(width - 10 * node.dimension, 10);
List<String> list = fr.listFormattedStringToWidth(I18n.format(name), textW);
fr.drawString(list.get(Math.abs((tick / 20) % list.size())), sX, sY + 2, 0xff000000);
}
});
GlStateManager.enableBlend();
GlStateManager.color(1, 1, 1, 1);
}
use of gregtech.api.gui.resources.IGuiTexture in project GregTech by GregTechCEu.
the class SlotListWidget method initFixed.
@Override
public Widget initFixed() {
this.clearAllWidgets();
ItemStackHandler itemStackHandler = new ItemStackHandler(item_list.size());
IGuiTexture background = new ColorRectTexture(0x4f000000);
int size = item_list.size();
int maxXSize = getSize().width / 18;
int xPos;
if (maxXSize < 1) {
maxXSize = 1;
xPos = 0;
} else {
xPos = (getSize().width - (Math.min(size, maxXSize)) * 18) / 2;
}
int maxYSize = size / maxXSize + ((size % maxXSize) == 0 ? 0 : 1);
for (int y = 0; y <= size / maxXSize; y++) {
for (int x = 0; x < maxXSize; x++) {
int i = x + y * maxXSize;
if (i < size) {
itemStackHandler.setStackInSlot(i, item_list.get(i).getInstance());
SlotWidget widget = new SlotWidget(itemStackHandler, i, xPos + x * 18, y * 18, false, false);
widget.setBackgroundTexture(background);
this.addWidget(widget);
}
}
}
setSize(new Size(getSize().width / 18 > 0 ? getSize().width : 18, maxYSize * 18));
return this;
}
use of gregtech.api.gui.resources.IGuiTexture in project GregTech by GregTechCEu.
the class TankListWidget method initFixed.
@Override
public Widget initFixed() {
this.clearAllWidgets();
IGuiTexture background = new ColorRectTexture(0x4f000000);
int size = fluid_list.size();
int maxXSize = getSize().width / 18;
int xPos;
if (maxXSize < 1) {
maxXSize = 1;
xPos = 0;
} else {
xPos = (getSize().width - (Math.min(size, maxXSize)) * 18) / 2;
}
int maxYSize = size / maxXSize + ((size % maxXSize) == 0 ? 0 : 1);
for (int y = 0; y <= size / maxXSize; y++) {
for (int x = 0; x < maxXSize; x++) {
int i = x + y * maxXSize;
if (i < size) {
FluidStack fluidStack = fluid_list.get(i).getInstance();
TankWidget widget = new TankWidget(new FluidTank(fluidStack, fluid_list.get(i).amount), xPos + x * 18, y * 18, 18, 18);
widget.setBackgroundTexture(background).setAlwaysShowFull(true).setClient();
this.addWidget(widget);
}
}
}
setSize(new Size(getSize().width / 18 > 0 ? getSize().width : 18, maxYSize * 18));
return this;
}
Aggregations