fixed stack tooltip display in advanced UIs
This commit is contained in:
parent
c6430035ff
commit
6f8466a8f4
8 changed files with 40 additions and 15 deletions
|
@ -60,7 +60,7 @@ public class GuiBuilder extends GuiAdvancedInterface {
|
||||||
fontRendererObj.drawString(StringUtils.localize("gui.needed"), 178, 7, 0x404040);
|
fontRendererObj.drawString(StringUtils.localize("gui.needed"), 178, 7, 0x404040);
|
||||||
fontRendererObj.drawString(StringUtils.localize("gui.building.fluids"), 178, 133, 0x404040);
|
fontRendererObj.drawString(StringUtils.localize("gui.building.fluids"), 178, 133, 0x404040);
|
||||||
|
|
||||||
drawForegroundSelection(par1, par2);
|
drawTooltipForSlotAt(par1, par2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class GuiUrbanist extends GuiAdvancedInterface {
|
||||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||||
super.drawGuiContainerForegroundLayer(par1, par2);
|
super.drawGuiContainerForegroundLayer(par1, par2);
|
||||||
|
|
||||||
drawForegroundSelection(par1, par2);
|
drawTooltipForSlotAt(par1, par2);
|
||||||
|
|
||||||
if (selectedTool != -1) {
|
if (selectedTool != -1) {
|
||||||
tools [selectedTool].drawGuiContainerForegroundLayer(this, par1, par2);
|
tools [selectedTool].drawGuiContainerForegroundLayer(this, par1, par2);
|
||||||
|
|
|
@ -32,10 +32,26 @@ public abstract class AdvancedSlot {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
if (getItemStack() != null) {
|
return null;
|
||||||
return getItemStack().getItem().getItemStackDisplayName(getItemStack());
|
}
|
||||||
|
|
||||||
|
public final void drawTooltip(GuiAdvancedInterface gui, int x, int y) {
|
||||||
|
String s = getDescription();
|
||||||
|
|
||||||
|
if (s != null) {
|
||||||
|
gui.drawTooltip(s, x, y);
|
||||||
} else {
|
} 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
||||||
|
@ -56,9 +57,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawForegroundSelection(int mouseX, int mouseY) {
|
public void drawTooltipForSlotAt(int mouseX, int mouseY) {
|
||||||
String s = "";
|
|
||||||
|
|
||||||
int cornerX = (width - xSize) / 2;
|
int cornerX = (width - xSize) / 2;
|
||||||
int cornerY = (height - ySize) / 2;
|
int cornerY = (height - ySize) / 2;
|
||||||
|
|
||||||
|
@ -68,14 +67,19 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
||||||
AdvancedSlot slot = slots[position];
|
AdvancedSlot slot = slots[position];
|
||||||
|
|
||||||
if (slot != null) {
|
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 i2 = mouseX - cornerX;
|
||||||
int k2 = mouseY - cornerY;
|
int k2 = mouseY - cornerY;
|
||||||
drawCreativeTabHoveringText(s, i2, k2);
|
drawCreativeTabHoveringText(caption, i2, k2);
|
||||||
RenderHelper.enableGUIStandardItemLighting();
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,4 +95,9 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
||||||
public int getYSize () {
|
public int getYSize () {
|
||||||
return ySize;
|
return ySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderToolTip(ItemStack stack, int x, int y) {
|
||||||
|
super.renderToolTip(stack, x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class GuiRefinery extends GuiAdvancedInterface {
|
||||||
fontRendererObj.drawString("<-", 106, 59, 0x404040);
|
fontRendererObj.drawString("<-", 106, 59, 0x404040);
|
||||||
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||||
|
|
||||||
drawForegroundSelection(par1, par2);
|
drawTooltipForSlotAt(par1, par2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
|
||||||
String title = StringUtils.localize("tile.assemblyTableBlock.name");
|
String title = StringUtils.localize("tile.assemblyTableBlock.name");
|
||||||
fontRendererObj.drawString(title, getCenteredOffset(title), 15, 0x404040);
|
fontRendererObj.drawString(title, getCenteredOffset(title), 15, 0x404040);
|
||||||
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
|
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
|
||||||
drawForegroundSelection(par1, par2);
|
drawTooltipForSlotAt(par1, par2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class GuiRedstoneBoard extends GuiAdvancedInterface {
|
||||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||||
super.drawGuiContainerForegroundLayer(par1, par2);
|
super.drawGuiContainerForegroundLayer(par1, par2);
|
||||||
|
|
||||||
drawForegroundSelection(par1, par2);
|
drawTooltipForSlotAt(par1, par2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -318,7 +318,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
||||||
fontRendererObj.drawString(name, getCenteredOffset(name), 10, 0x404040);
|
fontRendererObj.drawString(name, getCenteredOffset(name), 10, 0x404040);
|
||||||
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
|
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040);
|
||||||
|
|
||||||
drawForegroundSelection(par1, par2);
|
drawTooltipForSlotAt(par1, par2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue