Refactor text layout from GuiForestry into its own class

This commit is contained in:
mezz committed 2015-11-13 03:38:06 -08:00
1 parent a516886087
commit 430115a7d4
15 files changed
+407 -367

No files matched your search

@@ -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();
}
}
@@ -97,7 +97,7 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Item
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
String str = StatCollector.translateToLocal("item.for.habitatLocator.name").toUpperCase();
fontRendererObj.drawString(str, startX + 8 + getCenteredOffset(str, 138), startY + 16, fontColor.get("gui.screen"));
fontRendererObj.drawString(str, startX + 8 + textLayout.getCenteredOffset(str, 138), startY + 16, fontColor.get("gui.screen"));
// Set active according to valid biomes.
Set<BiomeDictionary.Type> activeBiomeTypes = EnumSet.noneOf(BiomeDictionary.Type.class);
@@ -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<EnumPlantType> activeTolerated = new ArrayList<>(tree.getGenome().getPlantTypes());
List<EnumPlantType> 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<IFruitFamily> families0 = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit());
List<IFruitFamily> 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();
}
}
@@ -40,7 +40,7 @@ public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, ItemIn
ICircuitLayout layout = ((ContainerSolderingIron) inventorySlots).getLayout();
String title = layout.getName();
fontRendererObj.drawString(title, guiLeft + 8 + getCenteredOffset(title, 138), guiTop + 16, fontColor.get("gui.screen"));
fontRendererObj.drawString(title, guiLeft + 8 + textLayout.getCenteredOffset(title, 138), guiTop + 16, fontColor.get("gui.screen"));
for (int i = 0; i < 4; i++) {
String description;
+68 -69
View File
@@ -79,29 +79,29 @@ public abstract class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory>
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<ContainerAlyzer, IInventory>
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<ContainerAlyzer, IInventory>
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<IClassification> hierarchy = new Stack<>();
IClassification classification = individual.getGenome().getPrimary().getBranch();
@@ -204,9 +204,9 @@ public abstract class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory>
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<ContainerAlyzer, IInventory>
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<ContainerAlyzer, IInventory>
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<ContainerAlyzer, IInventory>
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<ContainerAlyzer, IInventory>
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);
}
}
@@ -87,22 +87,22 @@ public class GuiEscritoire extends GuiForestry<ContainerEscritoire, TileEscritoi
RenderHelper.disableStandardItemLighting();
}
startPage();
textLayout.startPage();
GL11.glPushMatrix();
{
GL11.glScaled(0.5, 0.5, 0.5);
GL11.glTranslated(guiLeft + 170, guiTop + 10, 0.0);
newLine();
newLine();
textLayout.newLine();
textLayout.newLine();
String format = EnumChatFormatting.UNDERLINE + EnumChatFormatting.ITALIC.toString();
int attemptNo = EscritoireGame.BOUNTY_MAX - inventory.getGame().getBountyLevel();
drawLine(format + "Attempt No. " + attemptNo, 170, fontColor.get("gui.mail.lettertext"));
newLine();
textLayout.drawLine(format + "Attempt No. " + attemptNo, 170, fontColor.get("gui.mail.lettertext"));
textLayout.newLine();
String escritoireText = textSource.getText(inventory.getGame());
drawSplitLine(escritoireText, 170, 90, fontColor.get("gui.mail.lettertext"));
textLayout.drawSplitLine(escritoireText, 170, 90, fontColor.get("gui.mail.lettertext"));
}
GL11.glPopMatrix();
endPage();
textLayout.endPage();
}
}
@@ -15,6 +15,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.OpenGlHelper;
@@ -57,14 +58,14 @@ import codechicken.nei.api.TaggedInventoryArea;
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
public abstract class GuiForestry<C extends Container, I extends IInventory> 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<C extends Container, I extends IInventory> 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<C extends Container, I extends IInventory> 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<C extends Container, I extends IInventory> 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);
@@ -23,9 +23,11 @@ public abstract class GuiForestryTitled<C extends Container, I extends ITitled &
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
String name = StatCollector.translateToLocal(inventory.getUnlocalizedTitle());
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.title"));
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
textLayout.line = 6;
textLayout.drawCenteredLine(name, 0, fontColor.get("gui.title"));
}
}
@@ -62,7 +62,7 @@ public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInvento
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
super.drawGuiContainerBackgroundLayer(f, i, j);
String header = StringUtil.localize("gui.page") + " " + (pageCurrent + 1) + "/" + pageMax;
fontRendererObj.drawString(header, guiLeft + 95 + getCenteredOffset(header, 98), guiTop + 10, fontColor.get("gui.title"));
fontRendererObj.drawString(header, guiLeft + 95 + textLayout.getCenteredOffset(header, 98), guiTop + 10, fontColor.get("gui.title"));
IIndividual individual = getIndividualAtPosition(i, j);
if (individual == null) {
@@ -71,14 +71,14 @@ public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInvento
if (individual != null) {
RenderHelper.enableGUIStandardItemLighting();
startPage();
textLayout.startPage();
displaySpeciesInformation(true, individual.getGenome().getPrimary(), iconStacks.get(individual.getIdent()), 10);
if (!individual.isPureBred(EnumTreeChromosome.SPECIES)) {
displaySpeciesInformation(individual.isAnalyzed(), individual.getGenome().getSecondary(), iconStacks.get(individual.getGenome().getSecondary().getUID()), 10);
}
endPage();
textLayout.endPage();
}
}
@@ -129,40 +129,40 @@ public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInvento
private void displayBreedingStatistics(int x) {
startPage();
textLayout.startPage();
drawLine(StringUtil.localize("gui.speciescount") + ": " + breedingTracker.getSpeciesBred() + "/" + speciesRoot.getSpeciesCount(), x);
newLine();
newLine();
textLayout.drawLine(StringUtil.localize("gui.speciescount") + ": " + breedingTracker.getSpeciesBred() + "/" + speciesRoot.getSpeciesCount(), x);
textLayout.newLine();
textLayout.newLine();
if (breedingTracker instanceof IApiaristTracker) {
IApiaristTracker tracker = (IApiaristTracker) breedingTracker;
drawLine(StringUtil.localize("gui.queens") + ": " + tracker.getQueenCount(), x);
newLine();
textLayout.drawLine(StringUtil.localize("gui.queens") + ": " + tracker.getQueenCount(), x);
textLayout.newLine();
drawLine(StringUtil.localize("gui.princesses") + ": " + tracker.getPrincessCount(), x);
newLine();
textLayout.drawLine(StringUtil.localize("gui.princesses") + ": " + tracker.getPrincessCount(), x);
textLayout.newLine();
drawLine(StringUtil.localize("gui.drones") + ": " + tracker.getDroneCount(), x);
newLine();
textLayout.drawLine(StringUtil.localize("gui.drones") + ": " + tracker.getDroneCount(), x);
textLayout.newLine();
}
endPage();
textLayout.endPage();
}
private void displaySpeciesInformation(boolean analyzed, IAlleleSpecies species, ItemStack iconStack, int x) {
if (!analyzed) {
drawLine(StringUtil.localize("gui.unknown"), x);
textLayout.drawLine(StringUtil.localize("gui.unknown"), x);
return;
}
drawLine(species.getName(), x);
textLayout.drawLine(species.getName(), x);
RenderHelper.enableGUIStandardItemLighting();
drawItemStack(iconStack, guiLeft + x + 69, guiTop + getLineY() - 2);
drawItemStack(iconStack, guiLeft + x + 69, guiTop + textLayout.getLineY() - 2);
RenderHelper.disableStandardItemLighting();
newLine();
textLayout.newLine();
// Viable Combinations
int columnWidth = 16;
@@ -182,18 +182,18 @@ public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInvento
column += columnWidth;
if (column > 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<Container, IPagedInvento
}
Proxies.render.bindTexture(textureFile);
drawTexturedModalRect(guiLeft + x, guiTop + getLineY(), column, line, 16, 16);
drawTexturedModalRect(guiLeft + x, guiTop + textLayout.getLineY(), column, line, 16, 16);
}
@@ -251,7 +251,7 @@ public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInvento
}
Proxies.render.bindTexture(textureFile);
drawTexturedModalRect(guiLeft + x, guiTop + getLineY(), column, line, 16, 16);
drawTexturedModalRect(guiLeft + x, guiTop + textLayout.getLineY(), column, line, 16, 16);
}
@Override
@@ -0,0 +1,111 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.core.gui;
import net.minecraft.client.gui.FontRenderer;
import org.lwjgl.opengl.GL11;
import forestry.core.render.FontColour;
public class TextLayoutHelper {
private static final int LINE_HEIGHT = 12;
private final GuiForestry guiForestry;
private final int defaultFontColor;
private FontRenderer fontRendererObj;
public int column0;
public int column1;
public int column2;
public int line;
public TextLayoutHelper(GuiForestry guiForestry, FontColour fontColour) {
this.guiForestry = guiForestry;
this.defaultFontColor = fontColour.get("gui.screen");
}
public void setFontRendererObj(FontRenderer fontRendererObj) {
this.fontRendererObj = fontRendererObj;
}
public void startPage() {
line = LINE_HEIGHT;
GL11.glPushMatrix();
}
public void startPage(int column0, int column1, int column2) {
this.column0 = column0;
this.column1 = column1;
this.column2 = column2;
startPage();
}
public int getLineY() {
return line;
}
public void newLine() {
line += LINE_HEIGHT;
}
public void newLineCompressed() {
line += (LINE_HEIGHT - 2);
}
public void newLine(int lineHeight) {
line += lineHeight;
}
public void endPage() {
GL11.glPopMatrix();
}
public 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);
}
public void drawLine(String text, int x) {
drawLine(text, x, defaultFontColor);
}
public void drawSplitLine(String text, int x, int maxWidth) {
drawSplitLine(text, x, maxWidth, defaultFontColor);
}
public void drawCenteredLine(String text, int x, int color) {
drawCenteredLine(text, x, guiForestry.getSizeX(), color);
}
public void drawCenteredLine(String text, int x, int width, int color) {
fontRendererObj.drawString(text, guiForestry.getGuiLeft() + x + getCenteredOffset(text, width), guiForestry.getGuiTop() + line, color);
}
public void drawLine(String text, int x, int color) {
fontRendererObj.drawString(text, guiForestry.getGuiLeft() + x, guiForestry.getGuiTop() + line, color);
}
public void drawSplitLine(String text, int x, int maxWidth, int color) {
fontRendererObj.drawSplitString(text, guiForestry.getGuiLeft() + x, guiForestry.getGuiTop() + line, maxWidth, color);
}
public int getCenteredOffset(String string) {
return getCenteredOffset(string, guiForestry.getSizeX());
}
public int getCenteredOffset(String string, int xWidth) {
return (xWidth - fontRendererObj.getStringWidth(string)) / 2;
}
}
@@ -18,7 +18,7 @@ import org.lwjgl.opengl.GL11;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.IFarmLogic;
import forestry.core.config.Constants;
import forestry.core.gui.GuiForestry;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.gui.ledgers.ClimateLedger;
import forestry.core.gui.ledgers.OwnerLedger;
import forestry.core.gui.tooltips.ToolTip;
@@ -27,11 +27,10 @@ import forestry.core.gui.widgets.TankWidget;
import forestry.core.gui.widgets.Widget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StringUtil;
import forestry.farming.multiblock.IFarmControllerInternal;
import forestry.farming.tiles.TileFarm;
public class GuiFarm extends GuiForestry<ContainerFarm, TileFarm> {
public class GuiFarm extends GuiForestryTitled<ContainerFarm, TileFarm> {
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<ContainerFarm, TileFarm> {
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);
@@ -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<MultiblockLogicFarm> implements IFarmComponent, IHintSource, ISocketable, IStreamableGui, IErrorLogicSource, IRestrictedAccess {
public abstract class TileFarm extends MultiblockTileEntityForestry<MultiblockLogicFarm> 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<MultiblockLo
public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) {
getMultiblockLogic().getController().onSwitchAccess(oldAccess, newAccess);
}
/* ITitled */
@Override
public String getUnlocalizedTitle() {
return "for.gui.farm.title";
}
}
@@ -94,91 +94,89 @@ public class GuiFlutterlyzer extends GuiAlyzer {
}
private void drawAnalyticsPage1(IButterfly butterfly) {
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();
drawSpeciesRow(StringUtil.localize("gui.species"), butterfly, EnumButterflyChromosome.SPECIES, null, null);
newLine();
textLayout.newLine();
drawRow(StringUtil.localize("gui.size"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.SIZE).getName(),
butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.SIZE).getName(), butterfly, EnumButterflyChromosome.SPEED);
newLine();
textLayout.newLine();
drawRow(StringUtil.localize("gui.lifespan"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.LIFESPAN).getName(),
butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.LIFESPAN).getName(), butterfly,
EnumButterflyChromosome.LIFESPAN);
newLine();
textLayout.newLine();
drawRow(StringUtil.localize("gui.speed"), butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.SPEED).getName(),
butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.SPEED).getName(), butterfly, EnumButterflyChromosome.SPEED);
newLine();
textLayout.newLine();
drawRow(StringUtil.localize("gui.metabolism"), GenericRatings.rateMetabolism(butterfly.getGenome().getMetabolism()),
GenericRatings.rateMetabolism(((IAlleleInteger) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.METABOLISM)).getValue()), butterfly, EnumButterflyChromosome.METABOLISM);
newLine();
textLayout.newLine();
drawLine(StringUtil.localize("gui.fertility"), COLUMN_0);
textLayout.drawLine(StringUtil.localize("gui.fertility"), COLUMN_0);
drawFertilityInfo(butterfly.getGenome().getFertility(), COLUMN_1, getColorCoding(butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.FERTILITY)
.isDominant()), 8);
drawFertilityInfo(((IAlleleInteger) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FERTILITY)).getValue(), COLUMN_2, getColorCoding(butterfly
.getGenome().getInactiveAllele(EnumButterflyChromosome.FERTILITY).isDominant()), 8);
newLine();
textLayout.newLine();
drawRow(StringUtil.localize("gui.flowers"), butterfly.getGenome().getFlowerProvider().getDescription(),
((IAlleleFlowers) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FLOWER_PROVIDER)).getProvider()
.getDescription(), butterfly, EnumButterflyChromosome.FLOWER_PROVIDER);
newLine();
textLayout.newLine();
drawRow(StringUtil.localize("gui.effect"), butterfly.getGenome().getEffect().getName(),
butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.EFFECT).getName(), butterfly,
EnumButterflyChromosome.EFFECT);
newLine();
endPage();
textLayout.newLine();
textLayout.endPage();
}
private void drawAnalyticsPage2(IButterfly butterfly) {
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();
drawRow(StringUtil.localize("gui.climate"), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getTemperature()),
AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getTemperature()), butterfly, EnumButterflyChromosome.SPECIES);
newLine();
textLayout.newLine();
IAlleleTolerance tempToleranceActive = (IAlleleTolerance) butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.TEMPERATURE_TOLERANCE);
IAlleleTolerance tempToleranceInactive = (IAlleleTolerance) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.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();
textLayout.newLine();
drawRow(StringUtil.localize("gui.humidity"), AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getHumidity()),
AlleleManager.climateHelper.toDisplay(butterfly.getGenome().getPrimary().getHumidity()), butterfly, EnumButterflyChromosome.SPECIES);
newLine();
textLayout.newLine();
IAlleleTolerance humidToleranceActive = (IAlleleTolerance) butterfly.getGenome().getActiveAllele(EnumButterflyChromosome.HUMIDITY_TOLERANCE);
IAlleleTolerance humidToleranceInactive = (IAlleleTolerance) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.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();
newLine();
textLayout.newLine();
textLayout.newLine();
String yes = StringUtil.localize("yes");
String no = StringUtil.localize("no");
@@ -197,22 +195,22 @@ public class GuiFlutterlyzer extends GuiAlyzer {
diurnal1 = !butterfly.getGenome().getSecondary().isNocturnal() ? yes : no;
}
drawLine(StringUtil.localize("gui.diurnal"), COLUMN_0);
drawLine(diurnal0, COLUMN_1, getColorCoding(false));
drawLine(diurnal1, COLUMN_2, getColorCoding(false));
newLine();
textLayout.drawLine(StringUtil.localize("gui.diurnal"), COLUMN_0);
textLayout.drawLine(diurnal0, COLUMN_1, getColorCoding(false));
textLayout.drawLine(diurnal1, COLUMN_2, getColorCoding(false));
textLayout.newLine();
drawLine(StringUtil.localize("gui.nocturnal"), COLUMN_0);
drawLine(nocturnal0, COLUMN_1, getColorCoding(false));
drawLine(nocturnal1, COLUMN_2, getColorCoding(false));
newLine();
textLayout.drawLine(StringUtil.localize("gui.nocturnal"), COLUMN_0);
textLayout.drawLine(nocturnal0, COLUMN_1, getColorCoding(false));
textLayout.drawLine(nocturnal1, COLUMN_2, getColorCoding(false));
textLayout.newLine();
String primary = StringUtil.readableBoolean(butterfly.getGenome().getTolerantFlyer(), yes, no);
String secondary = StringUtil.readableBoolean(((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.TOLERANT_FLYER)).getValue(), yes,
no);
drawRow(StringUtil.localize("gui.flyer"), primary, secondary, butterfly, EnumButterflyChromosome.TOLERANT_FLYER);
newLine();
textLayout.newLine();
primary = StringUtil.readableBoolean(butterfly.getGenome().getFireResist(), yes, no);
secondary = StringUtil.readableBoolean(((AlleleBoolean) butterfly.getGenome().getInactiveAllele(EnumButterflyChromosome.FIRE_RESIST)).getValue(), yes,
@@ -220,43 +218,42 @@ public class GuiFlutterlyzer extends GuiAlyzer {
drawRow(StringUtil.localize("gui.fireresist"), primary, secondary, butterfly, EnumButterflyChromosome.FIRE_RESIST);
endPage();
textLayout.endPage();
}
private void drawAnalyticsPage3(IButterfly butterfly) {
startPage(COLUMN_0, COLUMN_1, COLUMN_2);
textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2);
drawLine(StringUtil.localize("gui.loot.butterfly") + ":", COLUMN_0);
newLine();
textLayout.drawLine(StringUtil.localize("gui.loot.butterfly") + ":", COLUMN_0);
textLayout.newLine();
int x = COLUMN_0;
for (ItemStack stack : butterfly.getGenome().getPrimary().getButterflyLoot().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();
}
}
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();
}
}
@@ -71,7 +71,10 @@ public class GuiTradeName extends GuiForestry<ContainerTradeName, TileTrader> {
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();
}
@@ -28,13 +28,13 @@ public class GuiTrader extends GuiForestry<ContainerTrader, TileTrader> {
@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);
}