fixed stack tooltip display in advanced UIs

This commit is contained in:
SpaceToad 2014-06-16 00:09:08 +02:00
parent c6430035ff
commit 6f8466a8f4
8 changed files with 40 additions and 15 deletions

View file

@ -60,7 +60,7 @@ public class GuiBuilder extends GuiAdvancedInterface {
fontRendererObj.drawString(StringUtils.localize("gui.needed"), 178, 7, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.building.fluids"), 178, 133, 0x404040);
drawForegroundSelection(par1, par2);
drawTooltipForSlotAt(par1, par2);
}
@Override

View file

@ -114,7 +114,7 @@ public class GuiUrbanist extends GuiAdvancedInterface {
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
drawForegroundSelection(par1, par2);
drawTooltipForSlotAt(par1, par2);
if (selectedTool != -1) {
tools [selectedTool].drawGuiContainerForegroundLayer(this, par1, par2);

View file

@ -32,10 +32,26 @@ public abstract class AdvancedSlot {
}
public String getDescription() {
if (getItemStack() != null) {
return getItemStack().getItem().getItemStackDisplayName(getItemStack());
return null;
}
public final void drawTooltip(GuiAdvancedInterface gui, int x, int y) {
String s = getDescription();
if (s != null) {
gui.drawTooltip(s, x, y);
} else {
return "";
ItemStack stack = getItemStack();
if (stack != null) {
int cornerX = (gui.width - gui.getXSize()) / 2;
int cornerY = (gui.height - gui.getYSize()) / 2;
int xS = x - cornerX;
int yS = y - cornerY;
gui.renderToolTip(stack, xS, yS);
}
}
}

View file

@ -14,6 +14,7 @@ import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public abstract class GuiAdvancedInterface extends GuiBuildCraft {
@ -56,9 +57,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
GL11.glPopMatrix();
}
protected void drawForegroundSelection(int mouseX, int mouseY) {
String s = "";
public void drawTooltipForSlotAt(int mouseX, int mouseY) {
int cornerX = (width - xSize) / 2;
int cornerY = (height - ySize) / 2;
@ -68,14 +67,19 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
AdvancedSlot slot = slots[position];
if (slot != null) {
s = slot.getDescription();
slot.drawTooltip(this, mouseX, mouseY);
}
}
}
if (s.length() > 0) {
public void drawTooltip(String caption, int mouseX, int mouseY) {
int cornerX = (width - xSize) / 2;
int cornerY = (height - ySize) / 2;
if (caption.length() > 0) {
int i2 = mouseX - cornerX;
int k2 = mouseY - cornerY;
drawCreativeTabHoveringText(s, i2, k2);
drawCreativeTabHoveringText(caption, i2, k2);
RenderHelper.enableGUIStandardItemLighting();
}
}
@ -91,4 +95,9 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
public int getYSize () {
return ySize;
}
@Override
public void renderToolTip(ItemStack stack, int x, int y) {
super.renderToolTip(stack, x, y);
}
}

View file

@ -53,7 +53,7 @@ public class GuiRefinery extends GuiAdvancedInterface {
fontRendererObj.drawString("<-", 106, 59, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
drawForegroundSelection(par1, par2);
drawTooltipForSlotAt(par1, par2);
}
@Override

View file

@ -131,7 +131,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
String title = StringUtils.localize("tile.assemblyTableBlock.name");
fontRendererObj.drawString(title, getCenteredOffset(title), 15, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
drawForegroundSelection(par1, par2);
drawTooltipForSlotAt(par1, par2);
}
@Override

View file

@ -80,7 +80,7 @@ public class GuiRedstoneBoard extends GuiAdvancedInterface {
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
super.drawGuiContainerForegroundLayer(par1, par2);
drawForegroundSelection(par1, par2);
drawTooltipForSlotAt(par1, par2);
}
@Override

View file

@ -318,7 +318,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
fontRendererObj.drawString(name, getCenteredOffset(name), 10, 0x404040);
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
drawForegroundSelection(par1, par2);
drawTooltipForSlotAt(par1, par2);
}
@Override