mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-25 14:34:33 +00:00
Added some localization
Added AlleleHelper
This commit is contained in:
1 parent
89f0b94f65
commit
5e35e3c803
12 files changed
+150
-49
No files matched your search
@@ -1,8 +1,5 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumAcidity {
|
||||
ACID,
|
||||
NEUTRAL,
|
||||
@@ -11,8 +8,4 @@ public enum EnumAcidity {
|
||||
public String getID() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getLocalisedName() {
|
||||
return I18N.localise(Botany.instance, "ph." + getID());
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumMoisture {
|
||||
DRY,
|
||||
NORMAL,
|
||||
@@ -11,8 +8,4 @@ public enum EnumMoisture {
|
||||
public String getID() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getLocalisedName() {
|
||||
return I18N.localise(Botany.instance, "moisture." + getID());
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumSoilType {
|
||||
SOIL,
|
||||
LOAM,
|
||||
@@ -11,8 +8,4 @@ public enum EnumSoilType {
|
||||
public String getID() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getLocalisedName() {
|
||||
return I18N.localise(Botany.instance, "soil." + getID());
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,8 @@ import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
import binnie.core.craftgui.geometry.TextJustification;
|
||||
import binnie.core.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.genetics.genetics.AlleleHelper;
|
||||
import binnie.core.util.I18N;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
@@ -59,15 +59,15 @@ public class PageSpeciesFlowerGenome extends PageSpecies {
|
||||
int th = 14;
|
||||
int valueX = w2 + 4;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), I18N.localise(Botany.instance, "gui.database.tab.genome.temp"), TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(valueX, y, w3, th), AlleleManager.climateHelper.toDisplay(treeSpecies.getTemperature()), TextJustification.MiddleLeft);
|
||||
new ControlText(contents, new IArea(valueX, y, w3, th), AlleleHelper.toDisplay(treeSpecies.getTemperature()), TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), I18N.localise(Botany.instance, "gui.database.tab.genome.moist"), TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(valueX, y, w3, th), treeSpecies.getMoisture().getLocalisedName(), TextJustification.MiddleLeft);
|
||||
new ControlText(contents, new IArea(valueX, y, w3, th), AlleleHelper.toDisplay(treeSpecies.getMoisture()), TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), I18N.localise(Botany.instance, "gui.database.tab.genome.ph"), TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(valueX, y, w3, th), treeSpecies.getPH().getLocalisedName(), TextJustification.MiddleLeft);
|
||||
new ControlText(contents, new IArea(valueX, y, w3, th), AlleleHelper.toDisplay(treeSpecies.getPH()), TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), I18N.localise(Botany.instance, "gui.database.tab.genome.fertility"), TextJustification.MiddleRight);
|
||||
|
||||
@@ -7,6 +7,8 @@ import binnie.botany.api.EnumMoisture;
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
import binnie.botany.api.gardening.IBlockSoil;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.genetics.genetics.AlleleHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -47,7 +49,7 @@ public class ItemSoilMeter extends Item {
|
||||
EnumChatFormatting.LIGHT_PURPLE,
|
||||
};
|
||||
String info = "Type: ";
|
||||
info += colors[type.ordinal()] + type.getLocalisedName() + EnumChatFormatting.RESET;
|
||||
info += colors[type.ordinal()] + AlleleHelper.toDisplay(type) + EnumChatFormatting.RESET;
|
||||
|
||||
colors = new EnumChatFormatting[]{
|
||||
EnumChatFormatting.YELLOW,
|
||||
@@ -55,7 +57,7 @@ public class ItemSoilMeter extends Item {
|
||||
EnumChatFormatting.BLUE,
|
||||
};
|
||||
info += ", Moisture: ";
|
||||
info += colors[moisture.ordinal()] + moisture.getLocalisedName() + EnumChatFormatting.RESET;
|
||||
info += colors[moisture.ordinal()] + AlleleHelper.toDisplay(moisture) + EnumChatFormatting.RESET;
|
||||
|
||||
colors = new EnumChatFormatting[]{
|
||||
EnumChatFormatting.RED,
|
||||
@@ -63,7 +65,7 @@ public class ItemSoilMeter extends Item {
|
||||
EnumChatFormatting.AQUA,
|
||||
};
|
||||
info += ", pH: ";
|
||||
info += colors[pH.ordinal()] + pH.getLocalisedName() + EnumChatFormatting.RESET;
|
||||
info += colors[pH.ordinal()] + AlleleHelper.toDisplay(pH) + EnumChatFormatting.RESET;
|
||||
IChatComponent chat = new ChatComponentText(info);
|
||||
player.addChatMessage(chat);
|
||||
}
|
||||
@@ -77,7 +79,7 @@ public class ItemSoilMeter extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack i) {
|
||||
return "Soil Meter";
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return I18N.localise(Botany.instance, "item.soilMeter.name");
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ import binnie.botany.api.IFlowerGenome;
|
||||
import binnie.botany.api.IFlowerMutation;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.genetics.genetics.AlleleHelper;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.core.genetics.Chromosome;
|
||||
@@ -37,7 +37,6 @@ public class Flower extends Individual implements IFlower {
|
||||
}
|
||||
|
||||
public Flower(IFlowerGenome genome, int age) {
|
||||
this.age = 0;
|
||||
this.genome = genome;
|
||||
this.age = age;
|
||||
wilting = false;
|
||||
@@ -62,11 +61,10 @@ public class Flower extends Individual implements IFlower {
|
||||
list.add(EnumChatFormatting.BLUE + I18N.localise(Botany.instance, "item.tooltip.hybrid", primary.getName(), secondary.getName()));
|
||||
}
|
||||
|
||||
// TODO localize enum strings
|
||||
list.add(EnumChatFormatting.GRAY + I18N.localise(Botany.instance, "item.tooltip.age", getAge()));
|
||||
list.add(EnumChatFormatting.GREEN + I18N.localise(Botany.instance, "item.tooltip.temperature", AlleleManager.climateHelper.toDisplay(primary.getTemperature()), genome.getToleranceTemperature()));
|
||||
list.add(EnumChatFormatting.GREEN + I18N.localise(Botany.instance, "item.tooltip.moisture", primary.getMoisture().getLocalisedName(), genome.getToleranceMoisture()));
|
||||
list.add(EnumChatFormatting.GREEN + I18N.localise(Botany.instance, "item.tooltip.pH", AlleleManager.climateHelper.toDisplay(primary.getHumidity()), genome.getTolerancePH()));
|
||||
list.add(EnumChatFormatting.GREEN + I18N.localise(Botany.instance, "item.tooltip.temperature", AlleleHelper.toDisplay(primary.getTemperature()), AlleleHelper.toDisplay(genome.getToleranceTemperature())));
|
||||
list.add(EnumChatFormatting.GREEN + I18N.localise(Botany.instance, "item.tooltip.moisture", AlleleHelper.toDisplay(primary.getMoisture()), AlleleHelper.toDisplay(genome.getToleranceMoisture())));
|
||||
list.add(EnumChatFormatting.GREEN + I18N.localise(Botany.instance, "item.tooltip.pH", AlleleHelper.toDisplay(primary.getHumidity()), AlleleHelper.toDisplay(genome.getTolerancePH())));
|
||||
list.add(EnumChatFormatting.GRAY + I18N.localise(Botany.instance, "item.tooltip.fertility", genome.getFertility()));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import binnie.botany.api.IFlowerRoot;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.genetics.genetics.AlleleHelper;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -23,12 +24,10 @@ import forestry.api.genetics.IAlleleRegistry;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.genetics.alleles.AlleleHelper;
|
||||
import forestry.core.genetics.alleles.EnumAllele;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -597,7 +596,7 @@ public enum FlowerSpecies implements IAlleleFlowerSpecies {
|
||||
}
|
||||
|
||||
public IAllele[] getTemplate() {
|
||||
AlleleHelper alleleHelper = AlleleHelper.instance;
|
||||
forestry.core.genetics.alleles.AlleleHelper alleleHelper = forestry.core.genetics.alleles.AlleleHelper.instance;
|
||||
IAlleleRegistry alleleRegistry = AlleleManager.alleleRegistry;
|
||||
IAllele[] template = FlowerTemplates.getDefaultTemplate();
|
||||
template[0] = this;
|
||||
@@ -606,9 +605,9 @@ public enum FlowerSpecies implements IAlleleFlowerSpecies {
|
||||
alleleHelper.set(template, EnumFlowerChromosome.TEMPERATURE_TOLERANCE, Binnie.Genetics.getToleranceAllele(tempTolerance));
|
||||
alleleHelper.set(template, EnumFlowerChromosome.PH_TOLERANCE, Binnie.Genetics.getToleranceAllele(pHTolerance));
|
||||
alleleHelper.set(template, EnumFlowerChromosome.HUMIDITY_TOLERANCE, Binnie.Genetics.getToleranceAllele(moistureTolerance));
|
||||
alleleHelper.set(template, EnumFlowerChromosome.FERTILITY, alleleRegistry.getAllele("forestry.fertility" + WordUtils.capitalize(fert.toString().toLowerCase())));
|
||||
alleleHelper.set(template, EnumFlowerChromosome.LIFESPAN, alleleRegistry.getAllele("forestry.lifespan" + WordUtils.capitalize(life.toString().toLowerCase())));
|
||||
alleleHelper.set(template, EnumFlowerChromosome.SAPPINESS, alleleRegistry.getAllele("forestry.sappiness" + WordUtils.capitalize(sap.toString().toLowerCase())));
|
||||
alleleHelper.set(template, EnumFlowerChromosome.FERTILITY, alleleRegistry.getAllele(AlleleHelper.getUid(fert)));
|
||||
alleleHelper.set(template, EnumFlowerChromosome.LIFESPAN, alleleRegistry.getAllele(AlleleHelper.getUid(life)));
|
||||
alleleHelper.set(template, EnumFlowerChromosome.SAPPINESS, alleleRegistry.getAllele(AlleleHelper.getUid(sap)));
|
||||
alleleHelper.set(template, EnumFlowerChromosome.STEM, stemColor.getAllele());
|
||||
return template;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package binnie.genetics.genetics;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.EnumAcidity;
|
||||
import binnie.botany.api.EnumMoisture;
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
import binnie.core.util.I18N;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.core.genetics.alleles.EnumAllele;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class AlleleHelper {
|
||||
public static String toDisplay(EnumTemperature temperature) {
|
||||
return AlleleManager.climateHelper.toDisplay(temperature);
|
||||
}
|
||||
|
||||
public static String toDisplay(EnumHumidity humidity) {
|
||||
return AlleleManager.climateHelper.toDisplay(humidity);
|
||||
}
|
||||
|
||||
public static String toDisplay(EnumMoisture moisture) {
|
||||
return I18N.localise(Botany.instance, "moisture." + moisture.getID());
|
||||
}
|
||||
|
||||
public static String toDisplay(EnumAcidity acidity) {
|
||||
return I18N.localise(Botany.instance, "ph." + acidity.getID());
|
||||
}
|
||||
|
||||
public static String toDisplay(EnumSoilType soilType) {
|
||||
return I18N.localise(Botany.instance, "soil." + soilType.getID());
|
||||
}
|
||||
|
||||
public static String toDisplay(EnumTolerance tolerance) {
|
||||
return toAlleleDisplay("tolerance", tolerance.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumAllele.Fertility fertility) {
|
||||
return getUid("fertility", fertility.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumAllele.Lifespan lifespan) {
|
||||
return getUid("lifespan", lifespan.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumAllele.Sappiness sappiness) {
|
||||
return getUid("sappiness", sappiness.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumAllele.Saplings saplings) {
|
||||
if (saplings == EnumAllele.Saplings.AVERAGE) {
|
||||
return getUid("saplings", "Default");
|
||||
}
|
||||
if (saplings == EnumAllele.Saplings.HIGH) {
|
||||
return getUid("saplings", "Double");
|
||||
}
|
||||
if (saplings == EnumAllele.Saplings.HIGHER) {
|
||||
return getUid("saplings", "Triple");
|
||||
}
|
||||
return getUid("saplings", saplings.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumAllele.Height height) {
|
||||
if (height == EnumAllele.Height.AVERAGE) {
|
||||
return getUid("height", "Max10", false);
|
||||
}
|
||||
return getUid("height", height.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumAllele.Maturation maturation) {
|
||||
return getUid("maturation", maturation.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumAllele.Territory territory) {
|
||||
return getUid("territory", territory.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumAllele.Yield yield) {
|
||||
if (yield == EnumAllele.Yield.AVERAGE) {
|
||||
return getUid("yield", "Default", false);
|
||||
}
|
||||
return getUid("yield", yield.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumAllele.Fireproof fireproof) {
|
||||
return getUid("bool", fireproof.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumAllele.Flowering flowering) {
|
||||
return getUid("flowering", flowering.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumTolerance tolerance) {
|
||||
return getUid("tolerance", tolerance.name());
|
||||
}
|
||||
|
||||
public static String getUid(EnumAllele.Speed speed) {
|
||||
return getUid("speed", speed.name());
|
||||
}
|
||||
|
||||
protected static String getUid(String key, String valueName) {
|
||||
return getUid(key, valueName, true);
|
||||
}
|
||||
|
||||
protected static String getUid(String key, String valueName, boolean needCapitalize) {
|
||||
if (needCapitalize) {
|
||||
valueName = WordUtils.capitalize(valueName.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return "forestry." + key + valueName;
|
||||
}
|
||||
|
||||
protected static String toAlleleDisplay(String key, String valueName) {
|
||||
String name = valueName.toLowerCase().replace("_", "");
|
||||
return I18N.localise("forestry.allele." + key + "." + name);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.geometry.TextJustification;
|
||||
import binnie.core.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.core.genetics.Tolerance;
|
||||
import binnie.genetics.genetics.AlleleHelper;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
@@ -52,11 +53,10 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
recomMoisture = EnumMoisture.DRY;
|
||||
}
|
||||
} else {
|
||||
if (canTolDamp) {
|
||||
recomMoisture = EnumMoisture.DAMP;
|
||||
}
|
||||
if (canTolDry) {
|
||||
recomMoisture = EnumMoisture.DRY;
|
||||
} else if (canTolDamp) {
|
||||
recomMoisture = EnumMoisture.DAMP;
|
||||
}
|
||||
}
|
||||
EnumAcidity recomPH = EnumAcidity.NEUTRAL;
|
||||
@@ -84,7 +84,7 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
y += 32;
|
||||
new ControlText(this, new IArea(4.0f, y, w() - 8.0f, 14.0f), "Other Soils", TextJustification.MiddleCenter).setColor(getColor());
|
||||
y += 12;
|
||||
List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
List<ItemStack> stacks = new ArrayList<>();
|
||||
for (EnumAcidity a : EnumSet.range(EnumAcidity.ACID, EnumAcidity.ALKALINE)) {
|
||||
for (EnumMoisture b : EnumSet.range(EnumMoisture.DRY, EnumMoisture.DAMP)) {
|
||||
if (Tolerance.canTolerate(pH, a, pHTol) && Tolerance.canTolerate(moisture, b, moistureTol) && (a != recomPH || b != recomMoisture)) {
|
||||
@@ -106,12 +106,12 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
new ControlToleranceBar<EnumMoisture>(parent, x, y, w, h, EnumMoisture.class) {
|
||||
@Override
|
||||
protected String getName(EnumMoisture value) {
|
||||
return value.getLocalisedName();
|
||||
return AlleleHelper.toDisplay(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getColour(EnumMoisture value) {
|
||||
return (new int[]{13434828, 6737151, 3368703})[value.ordinal()];
|
||||
return (new int[]{0xccffcc, 0x66ccff, 0x3366ff})[value.ordinal()];
|
||||
}
|
||||
}.setValues(value, tol);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class AnalystPageSoil extends ControlAnalystPage {
|
||||
new ControlToleranceBar<EnumAcidity>(parent, x, y, w, h, EnumAcidity.class) {
|
||||
@Override
|
||||
protected String getName(EnumAcidity value) {
|
||||
return value.getLocalisedName();
|
||||
return AlleleHelper.toDisplay(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user