Fix #210 Database missed description

This commit is contained in:
Nedelosk committed 2017-07-30 22:04:25 +02:00
1 parent 2a451bc72e
commit 705581b9ac
15 files changed
+118 -78

No files matched your search

@@ -31,7 +31,7 @@ public class FlowerBreedingSystem extends BreedingSystem {
}
@Override
public float getChance(IMutation mutation, EntityPlayer player, IAlleleSpecies species1, IAlleleSpecies species2) {
public float getChance(IMutation mutation, EntityPlayer player, IAlleleSpecies firstSpecies, IAlleleSpecies secondSpecies) {
return mutation.getBaseChance();
}
@@ -8,17 +8,17 @@ import binnie.core.craftgui.controls.ControlTextCentered;
import binnie.core.util.I18N;
public class PageSpeciesMutations extends PageSpecies {
private ControlText pageSpeciesFurther_Title;
private ControlMutationBox pageSpeciesFurther_List;
private ControlText title;
private ControlMutationBox list;
public PageSpeciesMutations(final IWidget parent, final DatabaseTab tab) {
super(parent, tab);
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, I18N.localise("binniecore.gui.database.mutations.further"));
this.pageSpeciesFurther_List = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.Further);
this.title = new ControlTextCentered(this, 8, I18N.localise("binniecore.gui.database.mutations.further"));
this.list = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.Further);
}
@Override
public void onValueChanged(final IAlleleSpecies species) {
this.pageSpeciesFurther_List.setSpecies(species);
this.list.setSpecies(species);
}
}
@@ -54,7 +54,7 @@ public class PageSpeciesOverview extends PageSpecies {
final String desc = species.getDescription();
StringBuilder descBody = new StringBuilder(TextFormatting.ITALIC.toString());
String descSig = "";
if (desc == null || Objects.equals(desc, "")) {
if (desc == null || Objects.equals(desc, "") || desc.contains("for.description") || desc.contains(".desc")) {
descBody.append(I18N.localise("binniecore.gui.database.no.description"));
} else {
final String[] descStrings = desc.split("\\|");
@@ -67,7 +67,9 @@ 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();
}
@@ -112,8 +112,8 @@ public class ControlSlot extends ControlSlotBase {
} else {
RenderUtil.drawGradientRect(new Area(1, 1, 16, 16), -2130706433, -2130706433);
}
GlStateManager.enableDepth();
GlStateManager.enableBlend();
GlStateManager.enableDepth();
}
}
@@ -31,14 +31,14 @@ class BeeBreedingSystem extends BreedingSystem {
}
@Override
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies species1, final IAlleleSpecies species2) {
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies firstSpecies, final IAlleleSpecies secondSpecies) {
return ((IBeeMutation) mutation).
getChance(new VirtualBeeHousing(player),
(IAlleleBeeSpecies) species1,
(IAlleleBeeSpecies) species2,
(IAlleleBeeSpecies) firstSpecies,
(IAlleleBeeSpecies) secondSpecies,
(IBeeGenome) this.getSpeciesRoot().
templateAsGenome(this.getSpeciesRoot().getTemplate(species1)),
(IBeeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(species2))
templateAsGenome(this.getSpeciesRoot().getTemplate(firstSpecies)),
(IBeeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(secondSpecies))
);
}
@@ -346,7 +346,7 @@ public abstract class BreedingSystem implements IItemStackRepresentitive {
return this.iconDiscovered.getSprite();
}
public abstract float getChance(final IMutation p0, final EntityPlayer p1, final IAlleleSpecies p2, final IAlleleSpecies p3);
public abstract float getChance(IMutation mutation, EntityPlayer player, IAlleleSpecies firstSpecies, IAlleleSpecies secondSpecies);
public abstract Class<? extends IBreedingTracker> getTrackerClass();
@@ -427,9 +427,9 @@ public abstract class BreedingSystem implements IItemStackRepresentitive {
}
@Nullable
public final IChromosomeType getChromosome(final int i) {
for (final IChromosomeType chromosome : this.getSpeciesRoot().getKaryotype()) {
if (i == chromosome.ordinal()) {
public final IChromosomeType getChromosome(int index) {
for (IChromosomeType chromosome : this.getSpeciesRoot().getKaryotype()) {
if (index == chromosome.ordinal()) {
return chromosome;
}
}
@@ -440,12 +440,13 @@ public abstract class BreedingSystem implements IItemStackRepresentitive {
public String getAlleleName(final IChromosomeType chromosome, final IAllele allele) {
if (allele instanceof IAlleleBoolean) {
return ((IAlleleBoolean) allele).getValue() ? I18N.localise("binniecore.allele.true") : I18N.localise("binniecore.allele.false");
IAlleleBoolean alleleBoolean = (IAlleleBoolean) allele;
return alleleBoolean.getValue() ? I18N.localise("binniecore.allele.true") : I18N.localise("binniecore.allele.false");
}
if (Objects.equals(allele.getName(), "for.gui.maximum")) {
if (Objects.equals(allele.getAlleleName(), "for.gui.maximum")) {
return I18N.localise("binniecore.allele.fertility.maximum");
}
return allele.getName();
return allele.getAlleleName();
}
public String getName() {
@@ -463,9 +464,9 @@ public abstract class BreedingSystem implements IItemStackRepresentitive {
return this.getName();
}
public abstract boolean isDNAManipulable(final ItemStack p0);
public abstract boolean isDNAManipulable(ItemStack stack);
public abstract boolean isDNAManipulable(final ISpeciesType type);
public abstract boolean isDNAManipulable(ISpeciesType type);
@Nullable
public IIndividual getConversion(final ItemStack stack) {
@@ -505,7 +506,7 @@ public abstract class BreedingSystem implements IItemStackRepresentitive {
}
@Nullable
public IIndividual getIndividual(final String uid) {
public IIndividual getIndividual(String uid) {
IAllele[] template = this.getSpeciesRoot().getTemplate(uid);
if (template == null) {
return null;
@@ -514,7 +515,7 @@ public abstract class BreedingSystem implements IItemStackRepresentitive {
}
@Nullable
public IGenome getGenome(final String uid) {
public IGenome getGenome(String uid) {
IAllele[] template = this.getSpeciesRoot().getTemplate(uid);
if (template == null) {
return null;
@@ -28,7 +28,7 @@ class MothBreedingSystem extends BreedingSystem {
}
@Override
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies species1, final IAlleleSpecies species2) {
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies firstSpecies, final IAlleleSpecies secondSpecies) {
return 0.0f;
}
@@ -58,11 +58,11 @@ public class TreeBreedingSystem extends BreedingSystem {
}
@Override
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies species1, final IAlleleSpecies species2) {
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies firstSpecies, final IAlleleSpecies secondSpecies) {
ISpeciesRoot speciesRoot = this.getSpeciesRoot();
final ITreeGenome genome0 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(species1));
final ITreeGenome genome2 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(species2));
return ((ITreeMutation) mutation).getChance(player.world, player.getPosition(), (IAlleleTreeSpecies) species1, (IAlleleTreeSpecies) species2, genome0, genome2);
final ITreeGenome genome0 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(firstSpecies));
final ITreeGenome genome2 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(secondSpecies));
return ((ITreeMutation) mutation).getChance(player.world, player.getPosition(), (IAlleleTreeSpecies) firstSpecies, (IAlleleTreeSpecies) secondSpecies, genome0, genome2);
}
@Override
@@ -12,6 +12,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -24,6 +25,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidActionResult;
@@ -34,6 +36,8 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.core.utils.Translator;
import binnie.core.BinnieCore;
import binnie.core.machines.component.IRender;
import binnie.core.util.TileUtil;
@@ -108,9 +112,13 @@ class BlockMachine extends Block implements IBlockMachine, ITileEntityProvider {
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
MachinePackage machinePackage = this.getPackage(stack.getMetadata());
if(machinePackage != null){
tooltip.add(machinePackage.getInformation());
if (GuiScreen.isShiftKeyDown()) {
MachinePackage machinePackage = this.getPackage(stack.getMetadata());
if(machinePackage != null){
tooltip.add(machinePackage.getInformation());
}
} else {
tooltip.add(TextFormatting.ITALIC + "<" + Translator.translateToLocal("for.gui.tooltip.tmi") + ">");
}
}
@@ -39,17 +39,7 @@ public class AnalystPageDatabase extends ControlAnalystPage {
public AnalystPageDatabase(IWidget parent, Area area, BreedingSystem system, boolean isMaster) {
super(parent, area);
this.isMaster = isMaster;
int cOfSystem = system.getColour();
int cr = (0xFF0000 & cOfSystem) >> 16;
int cg = (0xFF00 & cOfSystem) >> 8;
int cb = 0xFF & cOfSystem;
float brightness = 0.1f * cb / 255.0f + 0.35f * cr / 255.0f + 0.55f * cg / 255.0f;
brightness = 0.3f / brightness;
if (brightness > 1.0f) {
brightness = 1.0f;
}
int newColour = (int) (cr * brightness) * 65536 + (int) (cg * brightness) * 256 + (int) (cb * brightness);
setColor(newColour);
setColor(getColor(system));
int y = 4;
new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColor(getColor());
y += 16;
@@ -61,7 +51,7 @@ public class AnalystPageDatabase extends ControlAnalystPage {
for (IAlleleSpecies species : getSpecies(system)) {
if (value != null) {
if (!Objects.equals(value, "")) {
if (!species.getName().toLowerCase().contains(value.toLowerCase())) {
if (!species.getAlleleName().toLowerCase().contains(value.toLowerCase())) {
continue;
}
}
@@ -109,7 +99,7 @@ public class AnalystPageDatabase extends ControlAnalystPage {
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
RenderUtil.drawText(getArea(), TextJustification.MIDDLE_CENTER, value.getName(), 16777215);
RenderUtil.drawText(getArea(), TextJustification.MIDDLE_CENTER, value.getAlleleName(), 16777215);
}
};
}
@@ -131,6 +121,19 @@ public class AnalystPageDatabase extends ControlAnalystPage {
};
}
private static int getColor(BreedingSystem system){
int cOfSystem = system.getColour();
int cr = (0xFF0000 & cOfSystem) >> 16;
int cg = (0xFF00 & cOfSystem) >> 8;
int cb = 0xFF & cOfSystem;
float brightness = 0.1f * cb / 255.0f + 0.35f * cr / 255.0f + 0.55f * cg / 255.0f;
brightness = 0.3f / brightness;
if (brightness > 1.0f) {
brightness = 1.0f;
}
return (int) (cr * brightness) * 65536 + (int) (cg * brightness) * 256 + (int) (cb * brightness);
}
private IWidget getItemScrollList(BreedingSystem system, Collection<IAlleleSpecies> options) {
return new Control(scroll, 0, 0, scroll.width(), scroll.height()) {
@Override
@@ -31,7 +31,7 @@ public class AnalystPageDescription extends ControlAnalystPage {
String desc = species.getDescription();
StringBuilder descBody = new StringBuilder(TextFormatting.ITALIC.toString());
String descSig = "";
if (Objects.equals(desc, "") || desc.contains("for.description")) {
if (Objects.equals(desc, "") || desc.contains("for.description") || desc.contains(".desc")) {
descBody.append("");
} else {
String[] descStrings = desc.split("\\|");
@@ -55,7 +55,7 @@ public class AnalystPageDescription extends ControlAnalystPage {
}
new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColor(getColor());
y += 16;
new ControlTextCentered(this, y, species.getName() + TextFormatting.RESET).setColor(getColor());
new ControlTextCentered(this, y, species.getAlleleName() + TextFormatting.RESET).setColor(getColor());
y += 10;
new ControlTextCentered(this, y, TextFormatting.ITALIC + branchBinomial + " " + species.getBinomial() + TextFormatting.RESET).setColor(getColor());
y += 20;
@@ -67,6 +67,12 @@ public class AnalystPageGenome extends ControlAnalystPage {
@Override
public String getTitle() {
return I18N.localise("genetics.gui.analyst.genome." + (active ? "active" : "inactive")) + " " + I18N.localise("genetics.gui.analyst.genome.title");
String stateKey = "genetics.gui.analyst.genome.";
if(active){
stateKey+="active";
}else{
stateKey+="inactive";
}
return I18N.localise("genetics.gui.analyst.genome.title", I18N.localise(stateKey));
}
}
@@ -21,6 +21,7 @@ import binnie.core.util.I18N;
import binnie.genetics.genetics.AlleleHelper;
public class PageSpeciesGenome extends PageSpecies {
static final String PRE_FIX = "genetics.gui.database.tab.species.genome.extrabees.";
ControlText title;
ControlText speedText;
ControlText lifespanText;
@@ -35,17 +36,17 @@ public class PageSpeciesGenome extends PageSpecies {
public PageSpeciesGenome(IWidget parent, DatabaseTab tab) {
super(parent, tab);
title = new ControlTextCentered(this, 8, I18N.localise("extrabees.gui.database.tab.species.genome"));
new ControlText(this, new Area(0, 32, 68, 30), I18N.localise("extrabees.gui.database.tab.species.genome.speed"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 44, 68, 30), I18N.localise("extrabees.gui.database.tab.species.genome.lifespan"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 56, 68, 30), I18N.localise("extrabees.gui.database.tab.species.genome.fertility"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 68, 68, 30), I18N.localise("extrabees.gui.database.tab.species.genome.flowering"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 80, 68, 30), I18N.localise("extrabees.gui.database.tab.species.genome.territory"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 97, 68, 30), I18N.localise("extrabees.gui.database.tab.species.genome.behavior"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 109, 68, 30), I18N.localise("extrabees.gui.database.tab.species.genome.sunlight"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 121, 68, 30), I18N.localise("extrabees.gui.database.tab.species.genome.rain"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 138, 68, 30), I18N.localise("extrabees.gui.database.tab.species.genome.flower"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 155, 68, 30), I18N.localise("extrabees.gui.database.tab.species.genome.effect"), TextJustification.TOP_RIGHT);
title = new ControlTextCentered(this, 8, I18N.localise(PRE_FIX + "title"));
new ControlText(this, new Area(0, 32, 68, 30), I18N.localise(PRE_FIX + "speed"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 44, 68, 30), I18N.localise(PRE_FIX + "lifespan"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 56, 68, 30), I18N.localise(PRE_FIX + "fertility"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 68, 68, 30), I18N.localise(PRE_FIX + "flowering"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 80, 68, 30), I18N.localise(PRE_FIX + "territory"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 97, 68, 30), I18N.localise(PRE_FIX + "behavior"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 109, 68, 30), I18N.localise(PRE_FIX + "sunlight"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 121, 68, 30), I18N.localise(PRE_FIX + "rain"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 138, 68, 30), I18N.localise(PRE_FIX + "flower"), TextJustification.TOP_RIGHT);
new ControlText(this, new Area(0, 155, 68, 30), I18N.localise(PRE_FIX + "effect"), TextJustification.TOP_RIGHT);
int x = 72;
speedText = new ControlText(this, new Area(x, 32, 72, 30), "", TextJustification.TOP_LEFT);
lifespanText = new ControlText(this, new Area(x, 44, 72, 30), "", TextJustification.TOP_LEFT);
@@ -136,7 +137,7 @@ public class PageSpeciesGenome extends PageSpecies {
public static String tolerated(boolean t) {
if (t) {
return I18N.localise("extrabees.gui.database.tab.species.genome.tolerated");
return I18N.localise(PRE_FIX + "tolerated");
}
return AlleleHelper.toDisplay(EnumTolerance.NONE);
}
@@ -152,23 +153,23 @@ public class PageSpeciesGenome extends PageSpecies {
IBee bee = Binnie.GENETICS.getBeeRoot().getBee(genome);
speedText.setValue(rateSpeed(genome.getSpeed()));
lifespanText.setValue(rateLifespan(genome.getLifespan()));
fertilityText.setValue(I18N.localise("extrabees.gui.database.tab.species.genome.children", genome.getFertility()));
fertilityText.setValue(I18N.localise(PRE_FIX + "children", genome.getFertility()));
floweringText.setValue(rateFlowering(genome.getFlowering()));
Vec3i area = genome.getTerritory();
territoryText.setValue(area.getX() + "x" + area.getY() + "x" + area.getZ());
String behavior = I18N.localise("extrabees.gui.database.tab.species.genome.daytime");
String behavior = I18N.localise(PRE_FIX + "daytime");
if (genome.getPrimary().isNocturnal()) {
behavior = I18N.localise("extrabees.gui.database.tab.species.genome.nighttime");
behavior = I18N.localise(PRE_FIX + "nighttime");
}
if (genome.getNeverSleeps()) {
behavior = I18N.localise("extrabees.gui.database.tab.species.genome.allDay");
behavior = I18N.localise(PRE_FIX + "allDay");
}
nocturnalText.setValue(behavior);
if (genome.getCaveDwelling()) {
caveDwellingText.setValue(I18N.localise("extrabees.gui.database.tab.species.genome.notNeeded"));
caveDwellingText.setValue(I18N.localise(PRE_FIX + "notNeeded"));
} else {
caveDwellingText.setValue(I18N.localise("extrabees.gui.database.tab.species.genome.required"));
caveDwellingText.setValue(I18N.localise(PRE_FIX + "required"));
}
tolerantFlyerText.setValue(tolerated(genome.getToleratesRain()));
@@ -177,6 +178,6 @@ public class PageSpeciesGenome extends PageSpecies {
} else {
flowerText.setValue(AlleleHelper.toDisplay(EnumTolerance.NONE));
}
effectText.setValue(genome.getEffect().getName());
effectText.setValue(genome.getEffect().getAlleleName());
}
}