From afb9460ff9cb47428ea0a1e3e2e7a0b90ee5fd44 Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Mon, 31 Jul 2017 01:28:14 +0200 Subject: [PATCH] Clean Up --- .../minecraft/control/ControlItemDisplay.java | 2 -- .../java/binnie/genetics/gui/WindowAnalyst.java | 5 +++++ .../genetics/gui/analyst/AnalystConstants.java | 4 ++++ .../gui/analyst/AnalystPageBiology.java | 5 ++--- .../gui/analyst/tree/AnalystPageClimate.java | 9 +++++---- .../gui/analyst/tree/AnalystPageFruit.java | 15 ++++++++------- .../gui/analyst/tree/AnalystPageGrowth.java | 9 +++++---- .../gui/analyst/tree/AnalystPageWood.java | 17 ++++++++++------- .../resources/assets/genetics/lang/en_US.lang | 4 ++-- 9 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/main/java/binnie/core/craftgui/minecraft/control/ControlItemDisplay.java b/src/main/java/binnie/core/craftgui/minecraft/control/ControlItemDisplay.java index d10c1024..e33148da 100644 --- a/src/main/java/binnie/core/craftgui/minecraft/control/ControlItemDisplay.java +++ b/src/main/java/binnie/core/craftgui/minecraft/control/ControlItemDisplay.java @@ -67,9 +67,7 @@ public class ControlItemDisplay extends Control implements ITooltip { RenderUtil.drawItem(Point.ZERO, this.itemStack, this.rotating); GlStateManager.popMatrix(); } else { - GlStateManager.disableBlend(); RenderUtil.drawItem(Point.ZERO, this.itemStack, this.rotating); - GlStateManager.enableBlend(); } GlStateManager.enableAlpha(); } diff --git a/src/main/java/binnie/genetics/gui/WindowAnalyst.java b/src/main/java/binnie/genetics/gui/WindowAnalyst.java index 84ad377a..5b9c0e68 100644 --- a/src/main/java/binnie/genetics/gui/WindowAnalyst.java +++ b/src/main/java/binnie/genetics/gui/WindowAnalyst.java @@ -4,6 +4,7 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -395,7 +396,11 @@ public class WindowAnalyst extends Window { public void onRenderBackground(int guiWidth, int guiHeight) { boolean active = value == leftPage.getContent() || value == rightPage.getContent(); RenderUtil.setColour((active ? -16777216 : 1140850688) + value.getColor()); + GlStateManager.pushMatrix(); + GlStateManager.enableBlend(); CraftGUI.render.texture(CraftGUITexture.TabSolid, getArea().inset(1)); + GlStateManager.disableBlend(); + GlStateManager.popMatrix(); RenderUtil.setColour(value.getColor()); CraftGUI.render.texture(CraftGUITexture.TabOutline, getArea().inset(1)); super.onRenderBackground(guiWidth, guiHeight); diff --git a/src/main/java/binnie/genetics/gui/analyst/AnalystConstants.java b/src/main/java/binnie/genetics/gui/analyst/AnalystConstants.java index 674e3ef9..fdf0a81b 100644 --- a/src/main/java/binnie/genetics/gui/analyst/AnalystConstants.java +++ b/src/main/java/binnie/genetics/gui/analyst/AnalystConstants.java @@ -12,4 +12,8 @@ public class AnalystConstants { public static final String KARYOGRAM_KEY = KEY + ".karyogram"; public static final String MUTATIONS_KEY = KEY + ".mutations"; public static final String SPECIMEN_KEY = KEY + ".specimen"; + public static final String WOOD_KEY = KEY + ".wood"; + public static final String GROWTH_KEY = KEY + ".growth"; + public static final String FRUIT_KEY = KEY + ".fruit"; + public static final String CLIMATE_KEY = KEY + ".climate"; } diff --git a/src/main/java/binnie/genetics/gui/analyst/AnalystPageBiology.java b/src/main/java/binnie/genetics/gui/analyst/AnalystPageBiology.java index f4eb1725..a1394aa0 100644 --- a/src/main/java/binnie/genetics/gui/analyst/AnalystPageBiology.java +++ b/src/main/java/binnie/genetics/gui/analyst/AnalystPageBiology.java @@ -1,7 +1,6 @@ package binnie.genetics.gui.analyst; import java.text.DecimalFormat; -import java.util.Locale; import net.minecraft.util.text.TextFormatting; @@ -174,10 +173,10 @@ public class AnalystPageBiology extends ControlAnalystPage { .setColor(getColor()); y += 34; - new ControlTextCentered(this, y, I18N.localise(AnalystConstants.BIOLOGY_KEY + ".planTypes")).setColor(getColor()); + new ControlTextCentered(this, y, I18N.localise(AnalystConstants.BIOLOGY_KEY + ".plantTypes")).setColor(getColor()); y += 12; - new ControlTextCentered(this, y, TextFormatting.ITALIC + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)) + new ControlTextCentered(this, y, TextFormatting.ITALIC + tree.getGenome().getPrimary().getPlantType().toString()) .setColor(getColor()); } if (ind instanceof IFlower) { diff --git a/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageClimate.java b/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageClimate.java index d9e2ea11..83aa84b4 100644 --- a/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageClimate.java +++ b/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageClimate.java @@ -27,6 +27,7 @@ import binnie.core.craftgui.geometry.Point; import binnie.core.craftgui.geometry.TextJustification; import binnie.core.genetics.Tolerance; import binnie.core.util.I18N; +import binnie.genetics.gui.analyst.AnalystConstants; import binnie.genetics.gui.analyst.ControlAnalystPage; import binnie.genetics.gui.analyst.ControlBiome; import binnie.genetics.gui.analyst.ControlToleranceBar; @@ -54,17 +55,17 @@ public class AnalystPageClimate extends ControlAnalystPage { int y = 4; new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColor(getColor()); y += 16; - new ControlText(this, new Area(4, y, width() - 8, 14), I18N.localise("genetics.gui.analyst.climate.temp"), TextJustification.MIDDLE_CENTER).setColor(getColor()); + new ControlText(this, new Area(4, y, width() - 8, 14), I18N.localise(AnalystConstants.CLIMATE_KEY + ".temp"), TextJustification.MIDDLE_CENTER).setColor(getColor()); y += 12; createTemperatureBar(this, (width() - 100) / 2, y, 100, 10, temp, tempTol); y += 16; if (!(ind instanceof IFlower)) { - new ControlText(this, new Area(4, y, width() - 8, 14), I18N.localise("genetics.gui.analyst.climate.hum"), TextJustification.MIDDLE_CENTER).setColor(getColor()); + new ControlText(this, new Area(4, y, width() - 8, 14), I18N.localise(AnalystConstants.CLIMATE_KEY + ".hum"), TextJustification.MIDDLE_CENTER).setColor(getColor()); y += 12; createHumidity(this, (width() - 100) / 2, y, 100, 10, humid, humidTol); y += 16; } - new ControlText(this, new Area(4, y, width() - 8, 14), I18N.localise("genetics.gui.analyst.climate.biomes"), TextJustification.MIDDLE_CENTER).setColor(getColor()); + new ControlText(this, new Area(4, y, width() - 8, 14), I18N.localise(AnalystConstants.CLIMATE_KEY + ".biomes"), TextJustification.MIDDLE_CENTER).setColor(getColor()); y += 12; List biomes = new ArrayList<>(); for (Biome biome : Biome.EXPLORATION_BIOMES_LIST) { //TODO check @@ -128,6 +129,6 @@ public class AnalystPageClimate extends ControlAnalystPage { @Override public String getTitle() { - return I18N.localise("genetics.gui.analyst.climate.title"); + return I18N.localise(AnalystConstants.CLIMATE_KEY + ".title"); } } diff --git a/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageFruit.java b/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageFruit.java index f1f578be..80f74651 100644 --- a/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageFruit.java +++ b/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageFruit.java @@ -27,6 +27,7 @@ import binnie.core.craftgui.geometry.Point; import binnie.core.craftgui.minecraft.control.ControlItemDisplay; import binnie.core.util.I18N; import binnie.core.util.UniqueItemStackSet; +import binnie.genetics.gui.analyst.AnalystConstants; import binnie.genetics.gui.analyst.AnalystPageProduce; public class AnalystPageFruit extends AnalystPageProduce { @@ -37,7 +38,7 @@ public class AnalystPageFruit extends AnalystPageProduce { int y = 4; new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColor(getColor()); y += 12; - new ControlTextCentered(this, y, TextFormatting.ITALIC + I18N.localise("genetics.gui.analyst.fruit.yield") + ": " + Binnie.GENETICS.treeBreedingSystem.getAlleleName(EnumTreeChromosome.YIELD, ind.getGenome().getActiveAllele(EnumTreeChromosome.YIELD))).setColor(getColor()); + new ControlTextCentered(this, y, TextFormatting.ITALIC + I18N.localise(AnalystConstants.FRUIT_KEY + ".yield") + ": " + Binnie.GENETICS.treeBreedingSystem.getAlleleName(EnumTreeChromosome.YIELD, ind.getGenome().getActiveAllele(EnumTreeChromosome.YIELD))).setColor(getColor()); y += 20; Collection products = new UniqueItemStackSet(); Collection specialties = new UniqueItemStackSet(); @@ -55,7 +56,7 @@ public class AnalystPageFruit extends AnalystPageProduce { throw Throwables.propagate(e); } if (products.size() > 0) { - new ControlTextCentered(this, y, I18N.localise("genetics.gui.analyst.fruit.natural")).setColor(getColor()); + new ControlTextCentered(this, y, I18N.localise(AnalystConstants.FRUIT_KEY + ".natural")).setColor(getColor()); y += 10; int w = products.size() * 18 - 2; int i = 0; @@ -67,7 +68,7 @@ public class AnalystPageFruit extends AnalystPageProduce { y += 26; } if (specialties.size() > 0) { - new ControlTextCentered(this, y, I18N.localise("genetics.gui.analyst.fruit.specialty")).setColor(getColor()); + new ControlTextCentered(this, y, I18N.localise(AnalystConstants.FRUIT_KEY + ".specialty")).setColor(getColor()); y += 10; int w = products.size() * 18 - 2; int i = 0; @@ -84,14 +85,14 @@ public class AnalystPageFruit extends AnalystPageProduce { Collection refinedProducts = new UniqueItemStackSet(); refinedProducts.addAll(getAllProductsAndFluids(allProducts)); if (refinedProducts.size() > 0) { - y = getRefined(I18N.localise("genetics.gui.analyst.fruit.refined"), y, refinedProducts); + y = getRefined(I18N.localise(AnalystConstants.FRUIT_KEY + ".refined"), y, refinedProducts); y += 8; } if (products.size() == 0 && specialties.size() == 0) { - new ControlTextCentered(this, y, I18N.localise("genetics.gui.analyst.fruit.noFruits")).setColor(getColor()); + new ControlTextCentered(this, y, I18N.localise(AnalystConstants.FRUIT_KEY + ".noFruits")).setColor(getColor()); y += 28; } - new ControlTextCentered(this, y, I18N.localise("genetics.gui.analyst.fruit.possible")).setColor(getColor()); + new ControlTextCentered(this, y, I18N.localise(AnalystConstants.FRUIT_KEY + ".possible")).setColor(getColor()); y += 12; Collection fruitAlleles = Binnie.GENETICS.getChromosomeMap(Binnie.GENETICS.getTreeRoot()).get(EnumTreeChromosome.FRUITS); for (IFruitFamily fam : ind.getGenome().getPrimary().getSuitableFruit()) { @@ -125,6 +126,6 @@ public class AnalystPageFruit extends AnalystPageProduce { @Override public String getTitle() { - return I18N.localise("genetics.gui.analyst.fruit.title"); + return I18N.localise(AnalystConstants.FRUIT_KEY + ".title"); } } diff --git a/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageGrowth.java b/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageGrowth.java index ba61edb8..93f1d252 100644 --- a/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageGrowth.java +++ b/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageGrowth.java @@ -12,6 +12,7 @@ import binnie.core.craftgui.IWidget; import binnie.core.craftgui.controls.ControlTextCentered; import binnie.core.craftgui.geometry.Area; import binnie.core.util.I18N; +import binnie.genetics.gui.analyst.AnalystConstants; import binnie.genetics.gui.analyst.ControlAnalystPage; public class AnalystPageGrowth extends ControlAnalystPage { @@ -25,18 +26,18 @@ public class AnalystPageGrowth extends ControlAnalystPage { if (ind instanceof ITree) { ITree tree = (ITree) ind; int mat = tree.getGenome().getMaturationTime(); - new ControlTextCentered(this, y, I18N.localise("genetics.gui.analyst.growth.mature")).setColor(getColor()); + new ControlTextCentered(this, y, I18N.localise(AnalystConstants.GROWTH_KEY + ".mature")).setColor(getColor()); y += 12; new ControlTextCentered(this, y, TextFormatting.BOLD + getTimeString(Math.round(1373.3999f * mat))).setColor(getColor()); y += 22; - new ControlTextCentered(this, y, TextFormatting.ITALIC + I18N.localise("genetics.gui.analyst.growth.height") + ": " + Binnie.GENETICS.treeBreedingSystem.getAlleleName(EnumTreeChromosome.HEIGHT, ind.getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT))).setColor(getColor()); + new ControlTextCentered(this, y, TextFormatting.ITALIC + I18N.localise(AnalystConstants.GROWTH_KEY + ".height") + ": " + Binnie.GENETICS.treeBreedingSystem.getAlleleName(EnumTreeChromosome.HEIGHT, ind.getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT))).setColor(getColor()); y += 12; - new ControlTextCentered(this, y, TextFormatting.ITALIC + I18N.localise("genetics.gui.analyst.growth.girth") + ": " + Binnie.GENETICS.treeBreedingSystem.getAlleleName(EnumTreeChromosome.GIRTH, ind.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH))).setColor(getColor()); + new ControlTextCentered(this, y, TextFormatting.ITALIC + I18N.localise(AnalystConstants.GROWTH_KEY + ".girth") + ": " + Binnie.GENETICS.treeBreedingSystem.getAlleleName(EnumTreeChromosome.GIRTH, ind.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH))).setColor(getColor()); } } @Override public String getTitle() { - return I18N.localise("genetics.gui.analyst.growth.title"); + return I18N.localise(AnalystConstants.GROWTH_KEY + ".title"); } } diff --git a/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageWood.java b/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageWood.java index 5c2ed443..b4b6449f 100644 --- a/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageWood.java +++ b/src/main/java/binnie/genetics/gui/analyst/tree/AnalystPageWood.java @@ -22,6 +22,7 @@ import binnie.core.craftgui.minecraft.control.ControlIconDisplay; import binnie.core.craftgui.minecraft.control.ControlItemDisplay; import binnie.core.util.I18N; import binnie.core.util.UniqueItemStackSet; +import binnie.genetics.gui.analyst.AnalystConstants; import binnie.genetics.gui.analyst.AnalystPageProduce; import binnie.genetics.item.ModuleItems; @@ -35,9 +36,9 @@ public class AnalystPageWood extends AnalystPageProduce { new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColor(getColor()); y += 12; if (((IAlleleBoolean) ind.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF)).getValue()) { - new ControlIconDisplay(this, (width() - 16) / 2, y, ModuleItems.iconNoFire).addTooltip(I18N.localise("genetics.gui.analyst.wood.fireproof")); + new ControlIconDisplay(this, (width() - 16) / 2, y, ModuleItems.iconNoFire).addTooltip(I18N.localise(AnalystConstants.WOOD_KEY + ".fireproof")); } else { - new ControlIconDisplay(this, (width() - 16) / 2, y, ModuleItems.iconFire).addTooltip(I18N.localise("genetics.gui.analyst.wood.flammable")); + new ControlIconDisplay(this, (width() - 16) / 2, y, ModuleItems.iconFire).addTooltip(I18N.localise(AnalystConstants.WOOD_KEY + ".flammable")); } y += 30; Collection products = new UniqueItemStackSet(); @@ -47,9 +48,10 @@ public class AnalystPageWood extends AnalystPageProduce { if (!stackWood.isEmpty()) { products.add(stackWood); } - products.addAll(ind.getGenome().getFruitProvider().getProducts().keySet()); + //Why ? + //products.addAll(ind.getGenome().getFruitProvider().getProducts().keySet()); if (products.size() > 0) { - new ControlTextCentered(this, y, I18N.localise("genetics.gui.analyst.wood.logs")).setColor(getColor()); + new ControlTextCentered(this, y, I18N.localise(AnalystConstants.WOOD_KEY + ".logs")).setColor(getColor()); y += 10; int w = products.size() * 18 - 2; int i = 0; @@ -57,6 +59,7 @@ public class AnalystPageWood extends AnalystPageProduce { ControlItemDisplay d = new ControlItemDisplay(this, (width() - w) / 2 + 18 * i, y); d.setTooltip(); d.setItemStack(stack); + i++; } y += 26; } @@ -65,11 +68,11 @@ public class AnalystPageWood extends AnalystPageProduce { Collection refinedProducts = new UniqueItemStackSet(); refinedProducts.addAll(getAllProductsAndFluids(allProducts)); if (refinedProducts.size() > 0) { - y = getRefined(I18N.localise("genetics.gui.analyst.wood.refined"), y, refinedProducts); + y = getRefined(I18N.localise(AnalystConstants.WOOD_KEY + ".refined"), y, refinedProducts); y += 8; } if (products.size() == 0) { - new ControlTextCentered(this, y, I18N.localise("genetics.gui.analyst.wood.noFruits")).setColor(getColor()); + new ControlTextCentered(this, y, I18N.localise(AnalystConstants.WOOD_KEY + ".noFruits")).setColor(getColor()); y += 28; } setSize(new Point(width(), y + 8)); @@ -77,6 +80,6 @@ public class AnalystPageWood extends AnalystPageProduce { @Override public String getTitle() { - return I18N.localise("genetics.gui.analyst.wood.title"); + return I18N.localise(AnalystConstants.WOOD_KEY + ".title"); } } diff --git a/src/main/resources/assets/genetics/lang/en_US.lang b/src/main/resources/assets/genetics/lang/en_US.lang index 41062f89..890c1ed0 100644 --- a/src/main/resources/assets/genetics/lang/en_US.lang +++ b/src/main/resources/assets/genetics/lang/en_US.lang @@ -99,8 +99,8 @@ genetics.gui.analyst.biology.fertility.leaf=1 Sapling per 1 leaf genetics.gui.analyst.biology.caterpillarGestation=Caterpillar Gestation genetics.gui.analyst.biology.flightSpeed=Flight Speed genetics.gui.analyst.biology.blocksPerSec=%d blocks per second -genetics.gui.analyst.biology.mothSpawn.perLeaf=Butterflies spawn every\n%s per leaf -genetics.gui.analyst.biology.mothSpawn=Butterflies spawn every\n%s +genetics.gui.analyst.biology.mothSpawn.perLeaf=Butterflies spawn every %s per leaf +genetics.gui.analyst.biology.mothSpawn=Butterflies spawn every %s genetics.gui.analyst.biology.plantTypes=Plant Types genetics.gui.analyst.biology.averageLifespan=Average Lifespan genetics.gui.analyst.biology.pollination=Pollination