From 430115a7d44a983702bc35db1d18f4029574eed3 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 13 Nov 2015 03:38:06 -0800 Subject: [PATCH] Refactor text layout from GuiForestry into its own class --- .../forestry/apiculture/gui/GuiBeealyzer.java | 106 +++++++------- .../apiculture/gui/GuiHabitatLocator.java | 2 +- .../arboriculture/gui/GuiTreealyzer.java | 116 +++++++-------- .../core/circuits/GuiSolderingIron.java | 2 +- .../java/forestry/core/gui/GuiAlyzer.java | 137 +++++++++--------- .../java/forestry/core/gui/GuiEscritoire.java | 14 +- .../java/forestry/core/gui/GuiForestry.java | 97 ++----------- .../forestry/core/gui/GuiForestryTitled.java | 8 +- .../core/gui/GuiNaturalistInventory.java | 48 +++--- .../forestry/core/gui/TextLayoutHelper.java | 111 ++++++++++++++ .../java/forestry/farming/gui/GuiFarm.java | 12 +- .../java/forestry/farming/tiles/TileFarm.java | 9 +- .../lepidopterology/gui/GuiFlutterlyzer.java | 101 +++++++------ .../java/forestry/mail/gui/GuiTradeName.java | 5 +- .../java/forestry/mail/gui/GuiTrader.java | 6 +- 15 files changed, 407 insertions(+), 367 deletions(-) create mode 100644 src/main/java/forestry/core/gui/TextLayoutHelper.java diff --git a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java index 40e1e7cf5..bf05555b5 100755 --- a/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java +++ b/src/main/java/forestry/apiculture/gui/GuiBeealyzer.java @@ -98,81 +98,81 @@ public class GuiBeealyzer extends GuiAlyzer { private void drawAnalyticsPage1(IBee bee, EnumBeeType type) { - startPage(COLUMN_0, COLUMN_1, COLUMN_2); + textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2); - drawLine(StringUtil.localize("gui.active"), COLUMN_1); - drawLine(StringUtil.localize("gui.inactive"), COLUMN_2); + textLayout.drawLine(StringUtil.localize("gui.active"), COLUMN_1); + textLayout.drawLine(StringUtil.localize("gui.inactive"), COLUMN_2); - newLine(); - newLine(); + textLayout.newLine(); + textLayout.newLine(); { String customPrimaryBeeKey = "bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.", ""); String customSecondaryBeeKey = "bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getSecondary().getUnlocalizedName().replace("bees.species.", ""); drawSpeciesRow(StringUtil.localize("gui.species"), bee, EnumBeeChromosome.SPECIES, checkCustomName(customPrimaryBeeKey), checkCustomName(customSecondaryBeeKey)); - newLine(); + textLayout.newLine(); } drawChromosomeRow(StringUtil.localize("gui.lifespan"), bee, EnumBeeChromosome.LIFESPAN); - newLine(); + textLayout.newLine(); drawChromosomeRow(StringUtil.localize("gui.speed"), bee, EnumBeeChromosome.SPEED); - newLine(); + textLayout.newLine(); drawChromosomeRow(StringUtil.localize("gui.pollination"), bee, EnumBeeChromosome.FLOWERING); - newLine(); + textLayout.newLine(); drawChromosomeRow(StringUtil.localize("gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER); - newLine(); + textLayout.newLine(); - drawLine(StringUtil.localize("gui.fertility"), COLUMN_0); + textLayout.drawLine(StringUtil.localize("gui.fertility"), COLUMN_0); IAlleleInteger primaryFertility = (IAlleleInteger) bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY); IAlleleInteger secondaryFertility = (IAlleleInteger) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY); drawFertilityInfo(primaryFertility.getValue(), COLUMN_1, getColorCoding(primaryFertility.isDominant()), 0); drawFertilityInfo(secondaryFertility.getValue(), COLUMN_2, getColorCoding(secondaryFertility.isDominant()), 0); - newLine(); + textLayout.newLine(); drawChromosomeRow(StringUtil.localize("gui.area"), bee, EnumBeeChromosome.TERRITORY); - newLine(); + textLayout.newLine(); drawChromosomeRow(StringUtil.localize("gui.effect"), bee, EnumBeeChromosome.EFFECT); - newLine(); + textLayout.newLine(); - endPage(); + textLayout.endPage(); } private void drawAnalyticsPage2(IBee bee, EnumBeeType type) { - startPage(COLUMN_0, COLUMN_1, COLUMN_2); + textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2); - drawLine(StringUtil.localize("gui.active"), COLUMN_1); - drawLine(StringUtil.localize("gui.inactive"), COLUMN_2); + textLayout.drawLine(StringUtil.localize("gui.active"), COLUMN_1); + textLayout.drawLine(StringUtil.localize("gui.inactive"), COLUMN_2); - newLine(); + textLayout.newLine(); drawRow(StringUtil.localize("gui.climate"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getTemperature()), AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getTemperature()), bee, EnumBeeChromosome.SPECIES); - newLine(); + textLayout.newLine(); IAlleleTolerance tempToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); IAlleleTolerance tempToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE); - drawLine(" " + StringUtil.localize("gui.tolerance"), COLUMN_0); + textLayout.drawLine(" " + StringUtil.localize("gui.tolerance"), COLUMN_0); drawToleranceInfo(tempToleranceActive, COLUMN_1); drawToleranceInfo(tempToleranceInactive, COLUMN_2); - newLine(16); + textLayout.newLine(16); drawRow(StringUtil.localize("gui.humidity"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getHumidity()), AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getHumidity()), bee, EnumBeeChromosome.SPECIES); - newLine(); + textLayout.newLine(); IAlleleTolerance humidToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); IAlleleTolerance humidToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE); - drawLine(" " + StringUtil.localize("gui.tolerance"), COLUMN_0); + textLayout.drawLine(" " + StringUtil.localize("gui.tolerance"), COLUMN_0); drawToleranceInfo(humidToleranceActive, COLUMN_1); drawToleranceInfo(humidToleranceInactive, COLUMN_2); - newLine(16); + textLayout.newLine(16); String yes = StringUtil.localize("yes"); String no = StringUtil.localize("no"); @@ -191,29 +191,29 @@ public class GuiBeealyzer extends GuiAlyzer { diurnal1 = !bee.getGenome().getSecondary().isNocturnal() ? yes : no; } - drawLine(StringUtil.localize("gui.diurnal"), COLUMN_0); - drawLine(diurnal0, COLUMN_1, getColorCoding(false)); - drawLine(diurnal1, COLUMN_2, getColorCoding(false)); - newLineCompressed(); + textLayout.drawLine(StringUtil.localize("gui.diurnal"), COLUMN_0); + textLayout.drawLine(diurnal0, COLUMN_1, getColorCoding(false)); + textLayout.drawLine(diurnal1, COLUMN_2, getColorCoding(false)); + textLayout.newLineCompressed(); - drawLine(StringUtil.localize("gui.nocturnal"), COLUMN_0); - drawLine(nocturnal0, COLUMN_1, getColorCoding(false)); - drawLine(nocturnal1, COLUMN_2, getColorCoding(false)); - newLineCompressed(); + textLayout.drawLine(StringUtil.localize("gui.nocturnal"), COLUMN_0); + textLayout.drawLine(nocturnal0, COLUMN_1, getColorCoding(false)); + textLayout.drawLine(nocturnal1, COLUMN_2, getColorCoding(false)); + textLayout.newLineCompressed(); String primary = StringUtil.readableBoolean(bee.getGenome().getTolerantFlyer(), yes, no); String secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TOLERANT_FLYER)).getValue(), yes, no); drawRow(StringUtil.localize("gui.flyer"), primary, secondary, bee, EnumBeeChromosome.TOLERANT_FLYER); - newLineCompressed(); + textLayout.newLineCompressed(); primary = StringUtil.readableBoolean(bee.getGenome().getCaveDwelling(), yes, no); secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue(), yes, no); drawRow(StringUtil.localize("gui.cave"), primary, secondary, bee, EnumBeeChromosome.CAVE_DWELLING); - newLine(); + textLayout.newLine(); String displayText; if (type == EnumBeeType.PRINCESS || type == EnumBeeType.QUEEN) { @@ -222,57 +222,57 @@ public class GuiBeealyzer extends GuiAlyzer { displayText = "bees.stock.ignoble"; } displayText = StringUtil.localize(displayText); - drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial")); + textLayout.drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial")); } if (bee.getGeneration() >= 0) { - newLineCompressed(); + textLayout.newLineCompressed(); displayText = StringUtil.localizeAndFormat("gui.beealyzer.generations", bee.getGeneration()); - drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial")); + textLayout.drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial")); } - endPage(); + textLayout.endPage(); } private void drawAnalyticsPage3(IBee bee) { - startPage(COLUMN_0, COLUMN_1, COLUMN_2); + textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2); - drawLine(StringUtil.localize("gui.beealyzer.produce") + ":", COLUMN_0); + textLayout.drawLine(StringUtil.localize("gui.beealyzer.produce") + ":", COLUMN_0); - newLine(); + textLayout.newLine(); int x = COLUMN_0; for (ItemStack stack : bee.getProduceList()) { - widgetManager.add(new ItemStackWidget(widgetManager, x, getLineY(), stack)); + widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), stack)); x += 18; if (x > 148) { x = COLUMN_0; - newLine(); + textLayout.newLine(); } } - newLine(); - newLine(); - newLine(); - newLine(); + textLayout.newLine(); + textLayout.newLine(); + textLayout.newLine(); + textLayout.newLine(); - drawLine(StringUtil.localize("gui.beealyzer.specialty") + ":", COLUMN_0); - newLine(); + textLayout.drawLine(StringUtil.localize("gui.beealyzer.specialty") + ":", COLUMN_0); + textLayout.newLine(); x = COLUMN_0; for (ItemStack stack : bee.getSpecialtyList()) { - widgetManager.add(new ItemStackWidget(widgetManager, x, getLineY(), stack)); + widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), stack)); x += 18; if (x > 148) { x = COLUMN_0; - newLine(); + textLayout.newLine(); } } - endPage(); + textLayout.endPage(); } } diff --git a/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java b/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java index 53ad4d5b3..bafb88f43 100755 --- a/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java +++ b/src/main/java/forestry/apiculture/gui/GuiHabitatLocator.java @@ -97,7 +97,7 @@ public class GuiHabitatLocator extends GuiForestry activeBiomeTypes = EnumSet.noneOf(BiomeDictionary.Type.class); diff --git a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java index 9b5f965c2..782a2e075 100755 --- a/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java +++ b/src/main/java/forestry/arboriculture/gui/GuiTreealyzer.java @@ -106,41 +106,41 @@ public class GuiTreealyzer extends GuiAlyzer { private void drawAnalyticsPage1(ITree tree, EnumGermlingType type) { - startPage(COLUMN_0, COLUMN_1, COLUMN_2); + textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2); - drawLine(StringUtil.localize("gui.active"), COLUMN_1); - drawLine(StringUtil.localize("gui.inactive"), COLUMN_2); + textLayout.drawLine(StringUtil.localize("gui.active"), COLUMN_1); + textLayout.drawLine(StringUtil.localize("gui.inactive"), COLUMN_2); - newLine(); - newLine(); + textLayout.newLine(); + textLayout.newLine(); { String customPrimaryTreeKey = "trees.custom.treealyzer." + type.getName() + "." + tree.getGenome().getPrimary().getUnlocalizedName().replace("trees.species.", ""); String customSecondaryTreeKey = "trees.custom.treealyzer." + type.getName() + "." + tree.getGenome().getSecondary().getUnlocalizedName().replace("trees.species.", ""); drawSpeciesRow(StringUtil.localize("gui.species"), tree, EnumTreeChromosome.SPECIES, checkCustomName(customPrimaryTreeKey), checkCustomName(customSecondaryTreeKey)); - newLine(); + textLayout.newLine(); } drawChromosomeRow(StringUtil.localize("gui.saplings"), tree, EnumTreeChromosome.FERTILITY); - newLineCompressed(); + textLayout.newLineCompressed(); drawChromosomeRow(StringUtil.localize("gui.maturity"), tree, EnumTreeChromosome.MATURATION); - newLineCompressed(); + textLayout.newLineCompressed(); drawChromosomeRow(StringUtil.localize("gui.height"), tree, EnumTreeChromosome.HEIGHT); - newLineCompressed(); + textLayout.newLineCompressed(); IAlleleInteger activeGirth = (IAlleleInteger) tree.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH); IAlleleInteger inactiveGirth = (IAlleleInteger) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GIRTH); - drawLine(StringUtil.localize("gui.girth"), COLUMN_0); + textLayout.drawLine(StringUtil.localize("gui.girth"), COLUMN_0); drawLine(String.format("%sx%s", activeGirth.getValue(), activeGirth.getValue()), COLUMN_1, tree, EnumTreeChromosome.GIRTH, false); drawLine(String.format("%sx%s", inactiveGirth.getValue(), inactiveGirth.getValue()), COLUMN_2, tree, EnumTreeChromosome.GIRTH, true); - newLineCompressed(); + textLayout.newLineCompressed(); drawChromosomeRow(StringUtil.localize("gui.yield"), tree, EnumTreeChromosome.YIELD); - newLineCompressed(); + textLayout.newLineCompressed(); drawChromosomeRow(StringUtil.localize("gui.sappiness"), tree, EnumTreeChromosome.SAPPINESS); - newLineCompressed(); + textLayout.newLineCompressed(); String yes = StringUtil.localize("yes"); String no = StringUtil.localize("no"); @@ -148,46 +148,46 @@ public class GuiTreealyzer extends GuiAlyzer { AlleleBoolean primaryFireproof = (AlleleBoolean) tree.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF); AlleleBoolean secondaryFireproof = (AlleleBoolean) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FIREPROOF); - drawLine(StringUtil.localize("gui.fireproof"), COLUMN_0); + textLayout.drawLine(StringUtil.localize("gui.fireproof"), COLUMN_0); drawLine(StringUtil.readableBoolean(primaryFireproof.getValue(), yes, no), COLUMN_1, tree, EnumTreeChromosome.FIREPROOF, false); drawLine(StringUtil.readableBoolean(secondaryFireproof.getValue(), yes, no), COLUMN_2, tree, EnumTreeChromosome.FIREPROOF, false); - newLineCompressed(); + textLayout.newLineCompressed(); drawChromosomeRow(StringUtil.localize("gui.effect"), tree, EnumTreeChromosome.EFFECT); - endPage(); + textLayout.endPage(); } private void drawAnalyticsPage2(ITree tree) { - startPage(); + textLayout.startPage(); int speciesDominance0 = getColorCoding(tree.getGenome().getPrimary().isDominant()); int speciesDominance1 = getColorCoding(tree.getGenome().getSecondary().isDominant()); - drawLine(StringUtil.localize("gui.active"), COLUMN_1); - drawLine(StringUtil.localize("gui.inactive"), COLUMN_2); + textLayout.drawLine(StringUtil.localize("gui.active"), COLUMN_1); + textLayout.drawLine(StringUtil.localize("gui.inactive"), COLUMN_2); - newLine(); - newLine(); + textLayout.newLine(); + textLayout.newLine(); - drawLine(StringUtil.localize("gui.growth"), COLUMN_0); + textLayout.drawLine(StringUtil.localize("gui.growth"), COLUMN_0); drawLine(tree.getGenome().getGrowthProvider().getDescription(), COLUMN_1, tree, EnumTreeChromosome.GROWTH, false); drawLine(((IAlleleGrowth) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GROWTH)).getProvider().getDescription(), COLUMN_2, tree, EnumTreeChromosome.GROWTH, true); - newLine(); + textLayout.newLine(); - drawLine(StringUtil.localize("gui.native"), COLUMN_0); - drawLine(StringUtil.localize("gui." + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), COLUMN_1, + textLayout.drawLine(StringUtil.localize("gui.native"), COLUMN_0); + textLayout.drawLine(StringUtil.localize("gui." + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), COLUMN_1, speciesDominance0); - drawLine(StringUtil.localize("gui." + tree.getGenome().getSecondary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), COLUMN_2, + textLayout.drawLine(StringUtil.localize("gui." + tree.getGenome().getSecondary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), COLUMN_2, speciesDominance1); - newLine(); + textLayout.newLine(); - drawLine(StringUtil.localize("gui.tolerated"), COLUMN_0); + textLayout.drawLine(StringUtil.localize("gui.tolerated"), COLUMN_0); List activeTolerated = new ArrayList<>(tree.getGenome().getPlantTypes()); List inactiveTolerated = Collections.emptyList(); @@ -200,7 +200,7 @@ public class GuiTreealyzer extends GuiAlyzer { int max = Math.max(activeTolerated.size(), inactiveTolerated.size()); for (int i = 0; i < max; i++) { if (i > 0) { - newLine(); + textLayout.newLine(); } if (activeTolerated.size() > i) { drawLine(StringUtil.localize("gui." + activeTolerated.get(i).toString().toLowerCase(Locale.ENGLISH)), COLUMN_1, tree, EnumTreeChromosome.PLANT, false); @@ -209,101 +209,101 @@ public class GuiTreealyzer extends GuiAlyzer { drawLine(StringUtil.localize("gui." + inactiveTolerated.get(i).toString().toLowerCase(Locale.ENGLISH)), COLUMN_2, tree, EnumTreeChromosome.PLANT, true); } } - newLine(); + textLayout.newLine(); // FRUITS - drawLine(StringUtil.localize("gui.supports"), COLUMN_0); + textLayout.drawLine(StringUtil.localize("gui.supports"), COLUMN_0); List families0 = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit()); List families1 = new ArrayList<>(tree.getGenome().getSecondary().getSuitableFruit()); max = Math.max(families0.size(), families1.size()); for (int i = 0; i < max; i++) { if (i > 0) { - newLine(); + textLayout.newLine(); } if (families0.size() > i) { - drawLine(families0.get(i).getName(), COLUMN_1, speciesDominance0); + textLayout.drawLine(families0.get(i).getName(), COLUMN_1, speciesDominance0); } if (families1.size() > i) { - drawLine(families1.get(i).getName(), COLUMN_2, speciesDominance1); + textLayout.drawLine(families1.get(i).getName(), COLUMN_2, speciesDominance1); } } - newLine(); - newLine(); + textLayout.newLine(); + textLayout.newLine(); int fruitDominance0 = getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).isDominant()); int fruitDominance1 = getColorCoding(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS).isDominant()); - drawLine(StringUtil.localize("gui.fruits"), COLUMN_0); + textLayout.drawLine(StringUtil.localize("gui.fruits"), COLUMN_0); String strike = ""; IAllele fruit0 = tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS); if (!tree.canBearFruit() && fruit0 != AlleleFruit.fruitNone) { strike = EnumChatFormatting.STRIKETHROUGH.toString(); } - drawLine(strike + StringUtil.localize(tree.getGenome().getFruitProvider().getDescription()), COLUMN_1, fruitDominance0); + textLayout.drawLine(strike + StringUtil.localize(tree.getGenome().getFruitProvider().getDescription()), COLUMN_1, fruitDominance0); strike = ""; IAllele fruit1 = tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS); if (!tree.getGenome().getSecondary().getSuitableFruit().contains(((IAlleleFruit) fruit1).getProvider().getFamily()) && fruit1 != AlleleFruit.fruitNone) { strike = EnumChatFormatting.STRIKETHROUGH.toString(); } - drawLine(strike + StringUtil.localize(((IAlleleFruit) fruit1).getProvider().getDescription()), COLUMN_2, fruitDominance1); + textLayout.drawLine(strike + StringUtil.localize(((IAlleleFruit) fruit1).getProvider().getDescription()), COLUMN_2, fruitDominance1); - newLine(); + textLayout.newLine(); - drawLine(StringUtil.localize("gui.family"), COLUMN_0); + textLayout.drawLine(StringUtil.localize("gui.family"), COLUMN_0); IFruitFamily primary = tree.getGenome().getFruitProvider().getFamily(); IFruitFamily secondary = ((IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS)).getProvider().getFamily(); if (primary != null) { - drawLine(primary.getName(), COLUMN_1, fruitDominance0); + textLayout.drawLine(primary.getName(), COLUMN_1, fruitDominance0); } if (secondary != null) { - drawLine(secondary.getName(), COLUMN_2, fruitDominance1); + textLayout.drawLine(secondary.getName(), COLUMN_2, fruitDominance1); } - endPage(); + textLayout.endPage(); } private void drawAnalyticsPage3(ITree tree) { - startPage(COLUMN_0, COLUMN_1, COLUMN_2); + textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2); - drawLine(StringUtil.localize("gui.beealyzer.produce") + ":", COLUMN_0); - newLine(); + textLayout.drawLine(StringUtil.localize("gui.beealyzer.produce") + ":", COLUMN_0); + textLayout.newLine(); int x = COLUMN_0; for (ItemStack stack : tree.getProduceList()) { - itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, stack, guiLeft + x, guiTop + getLineY()); + itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, stack, guiLeft + x, guiTop + textLayout.getLineY()); x += 18; if (x > 148) { x = COLUMN_0; - newLine(); + textLayout.newLine(); } } - newLine(); - newLine(); - newLine(); - newLine(); + textLayout.newLine(); + textLayout.newLine(); + textLayout.newLine(); + textLayout.newLine(); - drawLine(StringUtil.localize("gui.beealyzer.specialty") + ":", COLUMN_0); - newLine(); + textLayout.drawLine(StringUtil.localize("gui.beealyzer.specialty") + ":", COLUMN_0); + textLayout.newLine(); x = COLUMN_0; for (ItemStack stack : tree.getSpecialtyList()) { - itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, stack, guiLeft + x, guiTop + getLineY()); + itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, stack, guiLeft + x, guiTop + textLayout.getLineY()); x += 18; if (x > 148) { x = COLUMN_0; - newLine(); + textLayout.newLine(); } } - endPage(); + textLayout.endPage(); } } diff --git a/src/main/java/forestry/core/circuits/GuiSolderingIron.java b/src/main/java/forestry/core/circuits/GuiSolderingIron.java index 9c3a7c257..a270cea63 100755 --- a/src/main/java/forestry/core/circuits/GuiSolderingIron.java +++ b/src/main/java/forestry/core/circuits/GuiSolderingIron.java @@ -40,7 +40,7 @@ public class GuiSolderingIron extends GuiForestry protected final void drawLine(String text, int x, IIndividual individual, IChromosomeType chromosome, boolean inactive) { if (!inactive) { - drawLine(text, x, getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant())); + textLayout.drawLine(text, x, getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant())); } else { - drawLine(text, x, getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant())); + textLayout.drawLine(text, x, getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant())); } } protected final void drawSplitLine(String text, int x, int maxWidth, IIndividual individual, IChromosomeType chromosome, boolean inactive) { if (!inactive) { - drawSplitLine(text, x, maxWidth, getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant())); + textLayout.drawSplitLine(text, x, maxWidth, getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant())); } else { - drawSplitLine(text, x, maxWidth, getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant())); + textLayout.drawSplitLine(text, x, maxWidth, getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant())); } } protected final void drawRow(String text0, String text1, String text2, IIndividual individual, IChromosomeType chromosome) { - drawRow(text0, text1, text2, fontColor.get("gui.screen"), getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant()), + textLayout.drawRow(text0, text1, text2, fontColor.get("gui.screen"), getColorCoding(individual.getGenome().getActiveAllele(chromosome).isDominant()), getColorCoding(individual.getGenome().getInactiveAllele(chromosome).isDominant())); } protected final void drawChromosomeRow(String chromosomeName, IIndividual individual, IChromosomeType chromosome) { IAllele active = individual.getGenome().getActiveAllele(chromosome); IAllele inactive = individual.getGenome().getInactiveAllele(chromosome); - drawRow(chromosomeName, active.getName(), inactive.getName(), + textLayout.drawRow(chromosomeName, active.getName(), inactive.getName(), fontColor.get("gui.screen"), getColorCoding(active.isDominant()), getColorCoding(inactive.isDominant())); } @@ -110,21 +110,21 @@ public abstract class GuiAlyzer extends GuiForestry IAlleleSpecies primary = individual.getGenome().getPrimary(); IAlleleSpecies secondary = individual.getGenome().getSecondary(); - drawLine(text0, column0); - int columnwidth = column2 - column1 - 2; + textLayout.drawLine(text0, textLayout.column0); + int columnwidth = textLayout.column2 - textLayout.column1 - 2; RenderHelper.enableStandardItemLighting(); - drawItemStack(iconStacks.get(primary.getUID()), guiLeft + column1 + (columnwidth - 20), guiTop + 10); - drawItemStack(iconStacks.get(secondary.getUID()), guiLeft + column2 + (columnwidth - 20), guiTop + 10); + drawItemStack(iconStacks.get(primary.getUID()), guiLeft + textLayout.column1 + (columnwidth - 20), guiTop + 10); + drawItemStack(iconStacks.get(secondary.getUID()), guiLeft + textLayout.column2 + (columnwidth - 20), guiTop + 10); RenderHelper.disableStandardItemLighting(); String primaryName = customPrimaryName == null ? primary.getName() : customPrimaryName; String secondaryName = customSecondaryName == null ? secondary.getName() : customSecondaryName; - drawSplitLine(primaryName, column1, columnwidth, individual, chromosome, false); - drawSplitLine(secondaryName, column2, columnwidth, individual, chromosome, true); + drawSplitLine(primaryName, textLayout.column1, columnwidth, individual, chromosome, false); + drawSplitLine(secondaryName, textLayout.column2, columnwidth, individual, chromosome, true); - newLine(); + textLayout.newLine(); } protected static String checkCustomName(String key) { @@ -143,45 +143,45 @@ public abstract class GuiAlyzer extends GuiForestry protected void drawAnalyticsOverview() { - startPage(); + textLayout.startPage(); - newLine(); + textLayout.newLine(); String title = StringUtil.localize(guiName).toUpperCase(); - drawCenteredLine(title, 8, 208); - newLine(); + textLayout.drawCenteredLine(title, 8, 208, fontColor.get("gui.screen")); + textLayout.newLine(); fontRendererObj.drawSplitString(StringUtil.localize(guiName + ".help"), guiLeft + COLUMN_0 + 4, guiTop + 42, 200, fontColor.get("gui.screen")); - newLine(); - newLine(); - newLine(); + textLayout.newLine(); + textLayout.newLine(); + textLayout.newLine(); - drawLine(StringUtil.localize("gui.alyzer.overview") + ":", COLUMN_0 + 4); - newLine(); - drawLine("I : " + StringUtil.localize("gui.general"), COLUMN_0 + 4); - newLine(); - drawLine("II : " + StringUtil.localize("gui.environment"), COLUMN_0 + 4); - newLine(); - drawLine("III: " + StringUtil.localize("gui.produce"), COLUMN_0 + 4); - newLine(); - drawLine("IV : " + StringUtil.localize("gui.evolution"), COLUMN_0 + 4); + textLayout.drawLine(StringUtil.localize("gui.alyzer.overview") + ":", COLUMN_0 + 4); + textLayout.newLine(); + textLayout.drawLine("I : " + StringUtil.localize("gui.general"), COLUMN_0 + 4); + textLayout.newLine(); + textLayout.drawLine("II : " + StringUtil.localize("gui.environment"), COLUMN_0 + 4); + textLayout.newLine(); + textLayout.drawLine("III: " + StringUtil.localize("gui.produce"), COLUMN_0 + 4); + textLayout.newLine(); + textLayout.drawLine("IV : " + StringUtil.localize("gui.evolution"), COLUMN_0 + 4); - newLine(); + textLayout.newLine(); String mode = breedingTracker.getModeName(); if (mode != null && !mode.isEmpty()) { String rules = StringUtil.localize(guiName + ".behaviour") + ": " + WordUtils.capitalize(mode); - drawCenteredLine(rules, 8, 208, fontColor.get(guiName + ".binomial")); + textLayout.drawCenteredLine(rules, 8, 208, fontColor.get(guiName + ".binomial")); } - endPage(); + textLayout.endPage(); } protected final void drawAnalyticsPageClassification(IIndividual individual) { - startPage(); + textLayout.startPage(); - drawLine(StringUtil.localize("gui.alyzer.classification") + ":", 12); - newLine(); + textLayout.drawLine(StringUtil.localize("gui.alyzer.classification") + ":", 12); + textLayout.newLine(); Stack hierarchy = new Stack<>(); IClassification classification = individual.getGenome().getPrimary().getBranch(); @@ -204,9 +204,9 @@ public abstract class GuiAlyzer extends GuiForestry continue; } - drawLine(group.getScientific(), x, group.getLevel().getColour()); - drawLine(group.getLevel().name(), 170, group.getLevel().getColour()); - newLineCompressed(); + textLayout.drawLine(group.getScientific(), x, group.getLevel().getColour()); + textLayout.drawLine(group.getLevel().name(), 170, group.getLevel().getColour()); + textLayout.newLineCompressed(); x += 12; } @@ -216,39 +216,38 @@ public abstract class GuiAlyzer extends GuiForestry binomial = group.getScientific().substring(0, 1) + ". " + binomial.toLowerCase(Locale.ENGLISH); } - drawLine(binomial, x, 0xebae85); - drawLine("SPECIES", 170, 0xebae85); + textLayout.drawLine(binomial, x, 0xebae85); + textLayout.drawLine("SPECIES", 170, 0xebae85); - newLine(); - drawLine(StringUtil.localize("gui.alyzer.authority") + ": " + individual.getGenome().getPrimary().getAuthority(), 12); + textLayout.newLine(); + textLayout.drawLine(StringUtil.localize("gui.alyzer.authority") + ": " + individual.getGenome().getPrimary().getAuthority(), 12); if (AlleleManager.alleleRegistry.isBlacklisted(individual.getIdent())) { String extinct = ">> " + StringUtil.localize("gui.alyzer.extinct").toUpperCase() + " <<"; fontRendererObj.drawStringWithShadow(extinct, guiLeft + 200 - fontRendererObj.getStringWidth(extinct), - guiTop + getLineY(), fontColor.get("gui.beealyzer.dominant")); + guiTop + textLayout.getLineY(), fontColor.get("gui.beealyzer.dominant")); } - newLine(); + textLayout.newLine(); String description = individual.getGenome().getPrimary().getDescription(); if (StringUtils.isBlank(description) || description.startsWith("for.description.")) { - drawSplitLine(StringUtil.localize("gui.alyzer.nodescription"), 12, 200, 0x666666); + textLayout.drawSplitLine(StringUtil.localize("gui.alyzer.nodescription"), 12, 200, 0x666666); } else { String tokens[] = description.split("\\|"); - drawSplitLine(tokens[0], 12, 200, 0x666666); + textLayout.drawSplitLine(tokens[0], 12, 200, 0x666666); if (tokens.length > 1) { String signature = "- " + tokens[1]; fontRendererObj.drawStringWithShadow(signature, (guiLeft + 210) - fontRendererObj.getStringWidth(signature), guiTop + 145 - 14, 0x99cc32); } } - endPage(); - + textLayout.endPage(); } protected void drawAnalyticsPageMutations(IIndividual individual) { - startPage(COLUMN_0, COLUMN_1, COLUMN_2); - drawLine(StringUtil.localize("gui.beealyzer.mutations") + ":", COLUMN_0); - newLine(); + textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2); + textLayout.drawLine(StringUtil.localize("gui.beealyzer.mutations") + ":", COLUMN_0); + textLayout.newLine(); RenderHelper.enableGUIStandardItemLighting(); @@ -281,32 +280,32 @@ public abstract class GuiAlyzer extends GuiForestry x += columnWidth; if (x >= columnWidth * 4) { x = 0; - newLine(); + textLayout.newLine(); } } - endPage(); + textLayout.endPage(); } protected void drawMutationInfo(IMutation combination, IAllele species, int x) { ItemStack partnerBee = iconStacks.get(combination.getPartner(species).getUID()); - widgetManager.add(new ItemStackWidget(widgetManager, x, getLineY(), partnerBee)); + widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), partnerBee)); - drawProbabilityArrow(combination.getBaseChance(), guiLeft + x + 18, guiTop + getLineY() + 4); + drawProbabilityArrow(combination.getBaseChance(), guiLeft + x + 18, guiTop + textLayout.getLineY() + 4); IAllele result = combination.getTemplate()[EnumBeeChromosome.SPECIES.ordinal()]; ItemStack resultBee = iconStacks.get(result.getUID()); - widgetManager.add(new ItemStackWidget(widgetManager, x + 33, getLineY(), resultBee)); + widgetManager.add(new ItemStackWidget(widgetManager, x + 33, textLayout.getLineY(), resultBee)); } private void drawUnknownMutation(IMutation combination, int x) { - drawQuestionMark(guiLeft + x, guiTop + getLineY()); + drawQuestionMark(guiLeft + x, guiTop + textLayout.getLineY()); - drawProbabilityArrow(combination.getBaseChance(), guiLeft + x + 18, guiTop + getLineY() + 4); + drawProbabilityArrow(combination.getBaseChance(), guiLeft + x + 18, guiTop + textLayout.getLineY() + 4); - drawQuestionMark(guiLeft + x + 32, guiTop + getLineY()); + drawQuestionMark(guiLeft + x + 32, guiTop + textLayout.getLineY()); } private void drawQuestionMark(int x, int y) { @@ -358,28 +357,28 @@ public abstract class GuiAlyzer extends GuiForestry case BOTH_3: case BOTH_4: case BOTH_5: - drawBothSymbol(x - 2, getLineY() - 1); - drawLine(text, x + 14, textColor); + drawBothSymbol(x - 2, textLayout.getLineY() - 1); + textLayout.drawLine(text, x + 14, textColor); break; case DOWN_1: case DOWN_2: case DOWN_3: case DOWN_4: case DOWN_5: - drawDownSymbol(x - 2, getLineY() - 1); - drawLine(text, x + 14, textColor); + drawDownSymbol(x - 2, textLayout.getLineY() - 1); + textLayout.drawLine(text, x + 14, textColor); break; case UP_1: case UP_2: case UP_3: case UP_4: case UP_5: - drawUpSymbol(x - 2, getLineY() - 1); - drawLine(text, x + 14, textColor); + drawUpSymbol(x - 2, textLayout.getLineY() - 1); + textLayout.drawLine(text, x + 14, textColor); break; default: - drawNoneSymbol(x - 2, getLineY() - 1); - drawLine("(0)", x + 14, textColor); + drawNoneSymbol(x - 2, textLayout.getLineY() - 1); + textLayout.drawLine("(0)", x + 14, textColor); break; } } @@ -413,9 +412,9 @@ public abstract class GuiAlyzer extends GuiForestry int stringWidth = fontRendererObj.getStringWidth(fertilityString); Proxies.render.bindTexture(textureFile); - drawTexturedModalRect(guiLeft + x + stringWidth + 2, guiTop + getLineY() - 1, 60, 240 + texOffset, 12, 8); + drawTexturedModalRect(guiLeft + x + stringWidth + 2, guiTop + textLayout.getLineY() - 1, 60, 240 + texOffset, 12, 8); - drawLine(fertilityString, x, textColor); + textLayout.drawLine(fertilityString, x, textColor); } } diff --git a/src/main/java/forestry/core/gui/GuiEscritoire.java b/src/main/java/forestry/core/gui/GuiEscritoire.java index 232edc100..8e9ea4a64 100755 --- a/src/main/java/forestry/core/gui/GuiEscritoire.java +++ b/src/main/java/forestry/core/gui/GuiEscritoire.java @@ -87,22 +87,22 @@ public class GuiEscritoire extends GuiForestry extends GuiContainer implements INEIGuiHandler { - protected static final int LINE_HEIGHT = 12; - protected final I inventory; protected final C container; - protected final FontColour fontColor; + public final ResourceLocation textureFile; protected final WidgetManager widgetManager; protected LedgerManager ledgerManager; + protected TextLayoutHelper textLayout; + protected FontColour fontColor; protected GuiForestry(String texture, C container, I inventory) { this(new ResourceLocation("forestry", texture), container, inventory); @@ -81,6 +82,13 @@ public abstract class GuiForestry ext this.container = container; this.fontColor = new FontColour(Proxies.render.getSelectedTexturePack()); + this.textLayout = new TextLayoutHelper(this, this.fontColor); + } + + @Override + public void setWorldAndResolution(Minecraft minecraft, int width, int height) { + super.setWorldAndResolution(minecraft, width, height); + textLayout.setFontRendererObj(fontRendererObj); } /* LEDGERS */ @@ -127,83 +135,8 @@ public abstract class GuiForestry ext ledgerManager.onGuiClosed(); } - /* TEXT HELPER FUNCTIONS */ - protected int column0; - protected int column1; - protected int column2; - private int line; - - protected final void startPage() { - line = LINE_HEIGHT; - GL11.glPushMatrix(); - } - - protected final void startPage(int column0, int column1, int column2) { - - this.column0 = column0; - this.column1 = column1; - this.column2 = column2; - - startPage(); - } - - protected final int getLineY() { - return line; - } - - protected final void newLine() { - line += LINE_HEIGHT; - } - - protected final void newLineCompressed() { - line += (LINE_HEIGHT - 2); - } - - protected final void newLine(int lineHeight) { - line += lineHeight; - } - - protected final void endPage() { - GL11.glPopMatrix(); - } - - protected final void drawRow(String text0, String text1, String text2, int colour0, int colour1, int colour2) { - drawLine(text0, column0, colour0); - drawLine(text1, column1, colour1); - drawLine(text2, column2, colour2); - } - - protected final void drawLine(String text, int x) { - drawLine(text, x, fontColor.get("gui.screen")); - } - - protected final void drawSplitLine(String text, int x, int maxWidth) { - drawSplitLine(text, x, maxWidth, fontColor.get("gui.screen")); - } - - protected final void drawCenteredLine(String text, int x, int width) { - drawCenteredLine(text, x, width, fontColor.get("gui.screen")); - } - - protected final void drawCenteredLine(String text, int x, int width, int color) { - fontRendererObj.drawString(text, guiLeft + x + (width - fontRendererObj.getStringWidth(text)) / 2, guiTop + line, color); - } - - protected final void drawLine(String text, int x, int color) { - fontRendererObj.drawString(text, guiLeft + x, guiTop + line, color); - } - - protected final void drawSplitLine(String text, int x, int maxWidth, int color) { - fontRendererObj.drawSplitString(text, guiLeft + x, guiTop + line, maxWidth, color); - } - - /* CORE GUI HANDLING */ - protected int getCenteredOffset(String string) { - return getCenteredOffset(string, xSize); - } - - protected int getCenteredOffset(String string, int xWidth) { - return (xWidth - fontRendererObj.getStringWidth(string)) / 2; + public FontColour getFontColor() { + return fontColor; } @Override @@ -425,10 +358,6 @@ public abstract class GuiForestry ext return guiTop; } - public FontColour getFontColor() { - return fontColor; - } - @Override public void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) { super.drawGradientRect(par1, par2, par3, par4, par5, par6); diff --git a/src/main/java/forestry/core/gui/GuiForestryTitled.java b/src/main/java/forestry/core/gui/GuiForestryTitled.java index d27fd6794..7535e4270 100644 --- a/src/main/java/forestry/core/gui/GuiForestryTitled.java +++ b/src/main/java/forestry/core/gui/GuiForestryTitled.java @@ -23,9 +23,11 @@ public abstract class GuiForestryTitled 75) { column = 10; - newLine(18); + textLayout.newLine(18); } } - newLine(); - newLine(); + textLayout.newLine(); + textLayout.newLine(); } private void drawMutationIcon(IMutation combination, IAlleleSpecies species, int x) { RenderHelper.enableGUIStandardItemLighting(); - drawItemStack(iconStacks.get(combination.getPartner(species).getUID()), guiLeft + x, guiTop + getLineY()); + drawItemStack(iconStacks.get(combination.getPartner(species).getUID()), guiLeft + x, guiTop + textLayout.getLineY()); RenderHelper.disableStandardItemLighting(); int line = 48; @@ -220,7 +220,7 @@ public class GuiNaturalistInventory extends GuiForestry { +public class GuiFarm extends GuiForestryTitled { public GuiFarm(EntityPlayer player, TileFarm tile) { super(Constants.TEXTURE_PATH_GUI + "/mfarm.png", new ContainerFarm(player.inventory, tile), tile); @@ -58,13 +57,6 @@ public class GuiFarm extends GuiForestry { ledgerManager.add(new OwnerLedger(ledgerManager, farmController)); } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - String title = StringUtil.localize("gui.farm.title"); - this.fontRendererObj.drawString(title, getCenteredOffset(title), 6, fontColor.get("gui.title")); - } - @Override protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); diff --git a/src/main/java/forestry/farming/tiles/TileFarm.java b/src/main/java/forestry/farming/tiles/TileFarm.java index 6d7e1538f..4a97b7835 100644 --- a/src/main/java/forestry/farming/tiles/TileFarm.java +++ b/src/main/java/forestry/farming/tiles/TileFarm.java @@ -36,10 +36,11 @@ import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; import forestry.core.network.GuiId; import forestry.core.network.IStreamableGui; +import forestry.core.tiles.ITitled; import forestry.farming.multiblock.MultiblockLogicFarm; import forestry.farming.render.EnumFarmBlockTexture; -public abstract class TileFarm extends MultiblockTileEntityForestry implements IFarmComponent, IHintSource, ISocketable, IStreamableGui, IErrorLogicSource, IRestrictedAccess { +public abstract class TileFarm extends MultiblockTileEntityForestry implements IFarmComponent, IHintSource, ISocketable, IStreamableGui, IErrorLogicSource, IRestrictedAccess, ITitled { public static final int TYPE_PLAIN = 0; public static final int TYPE_REVERSE = 1; @@ -177,4 +178,10 @@ public abstract class TileFarm extends MultiblockTileEntityForestry 148) { x = COLUMN_0; - newLine(); + textLayout.newLine(); } } - newLine(); - newLine(); + textLayout.newLine(); + textLayout.newLine(); - drawLine(StringUtil.localize("gui.loot.caterpillar") + ":", COLUMN_0); - newLine(); + textLayout.drawLine(StringUtil.localize("gui.loot.caterpillar") + ":", COLUMN_0); + textLayout.newLine(); x = COLUMN_0; for (ItemStack stack : butterfly.getGenome().getPrimary().getCaterpillarLoot().keySet()) { - itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, stack, guiLeft + x, guiTop + getLineY()); + itemRender.renderItemIntoGUI(fontRendererObj, mc.renderEngine, stack, guiLeft + x, guiTop + textLayout.getLineY()); x += 18; if (x > 148) { x = COLUMN_0; - newLine(); + textLayout.newLine(); } } - endPage(); + textLayout.endPage(); } } diff --git a/src/main/java/forestry/mail/gui/GuiTradeName.java b/src/main/java/forestry/mail/gui/GuiTradeName.java index 116c1f448..271c508e6 100755 --- a/src/main/java/forestry/mail/gui/GuiTradeName.java +++ b/src/main/java/forestry/mail/gui/GuiTradeName.java @@ -71,7 +71,10 @@ public class GuiTradeName extends GuiForestry { super.drawGuiContainerBackgroundLayer(var1, var2, var3); String prompt = StringUtil.localize("gui.mail.nametrader"); - fontRendererObj.drawString(prompt, guiLeft + this.getCenteredOffset(prompt), guiTop + 16, fontColor.get("gui.mail.text")); + textLayout.startPage(); + textLayout.newLine(); + textLayout.drawCenteredLine(prompt, 0, fontColor.get("gui.mail.text")); + textLayout.endPage(); addressNameField.drawTextBox(); } diff --git a/src/main/java/forestry/mail/gui/GuiTrader.java b/src/main/java/forestry/mail/gui/GuiTrader.java index b7fca58d7..31c74e75f 100755 --- a/src/main/java/forestry/mail/gui/GuiTrader.java +++ b/src/main/java/forestry/mail/gui/GuiTrader.java @@ -28,13 +28,13 @@ public class GuiTrader extends GuiForestry { @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { String name = StringUtil.localizeTile(inventory.getUnlocalizedTitle()); - this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.mail.text")); + this.fontRendererObj.drawString(name, textLayout.getCenteredOffset(name), 6, fontColor.get("gui.mail.text")); String receive = StringUtil.localize("gui.mail.receive"); - this.fontRendererObj.drawString(receive, getCenteredOffset(receive, 70) + 51, 45, fontColor.get("gui.mail.text")); + this.fontRendererObj.drawString(receive, textLayout.getCenteredOffset(receive, 70) + 51, 45, fontColor.get("gui.mail.text")); String send = StringUtil.localize("gui.mail.send"); - this.fontRendererObj.drawString(send, getCenteredOffset(send, 70) + 51, 99, fontColor.get("gui.mail.text")); + this.fontRendererObj.drawString(send, textLayout.getCenteredOffset(send, 70) + 51, 99, fontColor.get("gui.mail.text")); super.drawGuiContainerForegroundLayer(mouseX, mouseY); }