Fix #410 Catalogue has glitched text

This commit is contained in:
mezz committed 2014-12-27 21:58:41 -08:00
1 parent 00c444a46d
commit d55b119019
5 files changed
+48 -31

No files matched your search

@@ -41,6 +41,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@@ -248,7 +249,7 @@ public abstract class GuiForestry<T extends TileForestry> extends GuiContainer i
int y;
for (ToolTipLine tip : toolTips) {
y = this.fontRendererObj.getStringWidth(tip.getText());
y = this.fontRendererObj.getStringWidth(tip.toString());
height += 10 + tip.getSpacing();
if (y > length)
@@ -277,17 +278,19 @@ public abstract class GuiForestry<T extends TileForestry> extends GuiContainer i
this.drawGradientRect(x - 3, y - 3, x + length + 2, y - 3 + 1, borderColorTopInt, borderColorTopInt);
this.drawGradientRect(x - 3, y + height, x + length + 2, y + height + 1, borderColorBottomInt, borderColorBottomInt);
boolean firstLine = true;
for (ToolTipLine tip : toolTips) {
String line = tip.getText();
String line = tip.toString();
if (tip.getColor() == null)
line = "\u00a77" + line;
else
line = "\u00a7" + tip.getColor().getFormattingCode() + line;
if (!firstLine) {
line = EnumChatFormatting.GRAY + line;
}
this.fontRendererObj.drawStringWithShadow(line, x, y, -1);
y += 10 + tip.getSpacing();
firstLine = false;
}
this.zLevel = 0.0F;
@@ -74,7 +74,7 @@ public class ToolTip extends ForwardingList<ToolTipLine> {
public List<String> convertToStrings() {
List<String> tips = new ArrayList<String>(size());
for (ToolTipLine line : this) {
tips.add(line.getText());
tips.add(line.toString());
}
return tips;
}
@@ -40,12 +40,10 @@ public class ToolTipLine {
return spacing;
}
public String getText() {
return text;
}
public EnumChatFormatting getColor() {
return color;
public String toString() {
if (color == null)
return text;
return color + text;
}
}
@@ -10,26 +10,35 @@
******************************************************************************/
package forestry.mail.gui;
import java.util.ArrayList;
import java.util.List;
import forestry.api.mail.EnumAddressee;
import forestry.api.mail.TradeStationInfo;
import forestry.core.config.SessionVars;
import forestry.core.gadgets.TileForestry;
import forestry.core.gui.GuiForestry;
import forestry.core.gui.widgets.Widget;
import forestry.core.utils.StringUtil;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
public class GuiCatalogue extends GuiForestry<TileForestry> {
private static final String boldUnderline = EnumChatFormatting.BOLD.toString() + EnumChatFormatting.UNDERLINE;
// GuiButton buttonTrade;
// GuiButton buttonClose;
private GuiButton buttonFilter;
private GuiButton buttonCopy;
private final List<ItemStackWidget> tradeInfoWidgets = new ArrayList<ItemStackWidget>();
private final ContainerCatalogue container;
public GuiCatalogue(EntityPlayer player) {
@@ -85,30 +94,36 @@ public class GuiCatalogue extends GuiForestry<TileForestry> {
private void drawTradePreview(int x, int y) {
fontRendererObj.drawString("\u00A7l\u00A7n" + container.getTradeInfo().address.getName(), x, y, fontColor.get("gui.book"));
fontRendererObj.drawString(boldUnderline + container.getTradeInfo().address.getName(), x, y, fontColor.get("gui.book"));
TradeStationInfo info = container.getTradeInfo();
fontRendererObj.drawString(String.format(StringUtil.localize("gui.mail.willtrade"), info.owner.getName()), x, y + 18, fontColor.get("gui.book"));
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, info.tradegood, x, y + 28);
itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, info.tradegood, x, y + 28);
clearTradeInfoWidgets();
addTradeInfoWidget(new ItemStackWidget(x - guiLeft, y - guiTop + 28, info.tradegood));
GL11.glDisable(GL11.GL_LIGHTING);
fontRendererObj.drawString(StringUtil.localize("gui.mail.tradefor"), x, y + 46, fontColor.get("gui.book"));
GL11.glEnable(GL11.GL_LIGHTING);
for (int i = 0; i < container.getTradeInfo().required.length; i++) {
GL11.glDisable(GL11.GL_LIGHTING);
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, info.required[i], x + i * 18, y + 56);
itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, info.required[i], x + i * 18, y + 56);
GL11.glEnable(GL11.GL_LIGHTING);
addTradeInfoWidget(new ItemStackWidget(x - guiLeft + i * 18, y - guiTop + 56, info.required[i]));
}
GL11.glDisable(GL11.GL_LIGHTING);
if(info.state.isOk())
fontRendererObj.drawSplitString("\u00A72" + StringUtil.localize("chat.mail." + info.state.getIdentifier()), x, y + 82, 119, fontColor.get("gui.book"));
fontRendererObj.drawSplitString(EnumChatFormatting.DARK_GREEN + StringUtil.localize("chat.mail." + info.state.getIdentifier()), x, y + 82, 119, fontColor.get("gui.book"));
else
fontRendererObj.drawSplitString("\u00A74" + StringUtil.localize("chat.mail." + info.state.getIdentifier()), x, y + 82, 119, fontColor.get("gui.book"));
GL11.glEnable(GL11.GL_LIGHTING);
fontRendererObj.drawSplitString(EnumChatFormatting.DARK_RED + StringUtil.localize("chat.mail." + info.state.getIdentifier()), x, y + 82, 119, fontColor.get("gui.book"));
}
private void addTradeInfoWidget(ItemStackWidget widget) {
tradeInfoWidgets.add(widget);
widgetManager.add(widget);
}
private void clearTradeInfoWidgets() {
for (Widget widget : tradeInfoWidgets) {
widgetManager.remove(widget);
}
tradeInfoWidgets.clear();
}
@Override
@@ -70,11 +70,10 @@ public class GuiLetter extends GuiForestry<TileForestry> {
private GuiTextField address;
private GuiTextBox text;
boolean addressFocus;
boolean textFocus;
protected final ArrayList<Widget> tradeInfoWidgets;
private boolean addressFocus;
private boolean textFocus;
private final ArrayList<Widget> tradeInfoWidgets;
private final ContainerLetter container;
public GuiLetter(EntityPlayer player, LetterInventory inventory) {
@@ -217,8 +216,10 @@ public class GuiLetter extends GuiForestry<TileForestry> {
}
private void clearTradeInfoWidgets() {
for (Widget widget : tradeInfoWidgets)
for (Widget widget : tradeInfoWidgets) {
widgetManager.remove(widget);
}
tradeInfoWidgets.clear();
}
@Override