mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 12:19:47 +00:00
Clean Up Mutation Page
This commit is contained in:
1 parent
cbfb25647a
commit
d2a9e62cb2
9 files changed
+263
-82
No files matched your search
@@ -22,17 +22,17 @@ public class Control extends Widget implements ITooltipHelp, ITooltip {
|
||||
List<String> helpStrings;
|
||||
List<String> tooltipStrings;
|
||||
|
||||
public Control(final IWidget parent, final int x, final int y, final int w, final int h) {
|
||||
public Control(IWidget parent, int x, int y, int width, int height) {
|
||||
super(parent);
|
||||
this.helpStrings = new ArrayList<>();
|
||||
this.tooltipStrings = new ArrayList<>();
|
||||
this.extraLevel = 0;
|
||||
this.setPosition(new Point(x, y));
|
||||
this.setSize(new Point(w, h));
|
||||
this.setSize(new Point(width, height));
|
||||
this.initialise();
|
||||
}
|
||||
|
||||
public Control(final IWidget parent, final Area area) {
|
||||
public Control(IWidget parent, Area area) {
|
||||
this(parent, area.xPos(), area.yPos(), area.width(), area.height());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
package binnie.core.gui.minecraft;
|
||||
|
||||
public enum EnumColor {
|
||||
BLACK("Black", 0, '0'),
|
||||
DARK_BLUE("Dark Blue", 170, '1'),
|
||||
DARK_GREEN("Dark Green", 43520, '2'),
|
||||
DARK_AQUA("Dark Aqua", 43690, '3'),
|
||||
DARK_RED("Dark Red", 11141120, '4'),
|
||||
PURPLE("Purple", 11141290, '5'),
|
||||
GOLD("Gold", 16755200, '6'),
|
||||
GREY("Grey", 11184810, '7'),
|
||||
DARK_GREY("Dark Grey", 5592405, '8'),
|
||||
BLUE("Blue", 5592575, '9'),
|
||||
GREEN("Green", 5635925, 'a'),
|
||||
AQUA("Aqua", 5636095, 'b'),
|
||||
RED("Red", 16733525, 'c'),
|
||||
PINK("Pink", 16733695, 'd'),
|
||||
YELLOW("Yellow", 16777045, 'e'),
|
||||
WHITE("White", 16777215, 'f');
|
||||
BLACK("Black", 0x0,'0'),
|
||||
DARK_BLUE("Dark Blue", 0xaa,'1'),
|
||||
DARK_GREEN("Dark Green", 0xaa00,'2'),
|
||||
DARK_AQUA("Dark Aqua", 0xaaaa,'3'),
|
||||
DARK_RED("Dark Red", 0xaa0000,'4'),
|
||||
PURPLE("Purple", 0xaa00aa,'5'),
|
||||
GOLD("Gold", 0xffaa00,'6'),
|
||||
GREY("Grey", 0xaaaaaa,'7'),
|
||||
DARK_GREY("Dark Grey", 0x555555,'8'),
|
||||
BLUE("Blue", 0x5555ff,'9'),
|
||||
GREEN("Green", 0x55ff55,'a'),
|
||||
AQUA("Aqua", 0x55ffff,'b'),
|
||||
RED("Red", 0xff5555,'c'),
|
||||
PINK("Pink", 0xff55ff,'d'),
|
||||
YELLOW("Yellow", 0xffff55,'e'),
|
||||
WHITE("White", 0xffffff,'f');
|
||||
|
||||
int color;
|
||||
String name;
|
||||
@@ -26,10 +26,6 @@ public enum EnumColor {
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
this.code = code;
|
||||
System.out.print(name() + "(\"" + name + "\n,"+ Integer.toHexString(color) + ",\'" + code + "\'),\n");
|
||||
if(color == 16777215){
|
||||
getClass();
|
||||
}
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
|
||||
@@ -67,9 +67,7 @@ public class ControlItemDisplay extends Control implements ITooltip {
|
||||
RenderUtil.drawItem(Point.ZERO, this.itemStack, this.rotating);
|
||||
GlStateManager.popMatrix();
|
||||
} else {
|
||||
GlStateManager.enableBlend();
|
||||
RenderUtil.drawItem(Point.ZERO, this.itemStack, this.rotating);
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
GlStateManager.enableAlpha();
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ public class RenderUtil {
|
||||
}
|
||||
|
||||
public static void drawItem(final Point pos, final ItemStack itemStack, final boolean rotating) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.pushAttrib();
|
||||
Preconditions.checkNotNull(itemStack);
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
@@ -71,6 +73,8 @@ public class RenderUtil {
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popAttrib();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableDepth();
|
||||
}
|
||||
|
||||
private static FontRenderer getFontRenderer(Minecraft minecraft, ItemStack ingredient) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
@@ -11,6 +12,7 @@ import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
import binnie.core.IInitializable;
|
||||
|
||||
@@ -48,6 +50,22 @@ public class ExtraBeesIntegration implements IInitializable {
|
||||
marble = getExtraBeesSpecies("marble");
|
||||
}
|
||||
|
||||
public static ItemStack getHive(IAlleleSpecies speciesCurrent){
|
||||
if (speciesCurrent == ExtraBeesIntegration.water) {
|
||||
return new ItemStack(ExtraBeesIntegration.hive, 1, 0);
|
||||
}
|
||||
if (speciesCurrent == ExtraBeesIntegration.rock) {
|
||||
return new ItemStack(ExtraBeesIntegration.hive, 1, 1);
|
||||
}
|
||||
if (speciesCurrent == ExtraBeesIntegration.basalt) {
|
||||
return new ItemStack(ExtraBeesIntegration.hive, 1, 2);
|
||||
}
|
||||
if (speciesCurrent == ExtraBeesIntegration.marble) {
|
||||
return new ItemStack(ExtraBeesIntegration.hive, 1, 3);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
private IAlleleBeeSpecies getExtraBeesSpecies(String species) {
|
||||
return Preconditions.checkNotNull((IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele("extrabees.species." + species));
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import binnie.core.gui.renderer.RenderUtil;
|
||||
import binnie.core.integration.extrabees.ExtraBeesIntegration;
|
||||
import binnie.core.resource.BinnieSprite;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.genetics.item.ModuleItems;
|
||||
|
||||
public class AnalystPageMutations extends ControlAnalystPage {
|
||||
public AnalystPageMutations(IWidget parent, Area area, IIndividual ind, boolean isMaster) {
|
||||
@@ -49,45 +48,7 @@ public class AnalystPageMutations extends ControlAnalystPage {
|
||||
Collection<IMutation> resultant = system.getResultantMutations(speciesCurrent);
|
||||
Collection<IMutation> further = system.getFurtherMutations(speciesCurrent);
|
||||
if (ind instanceof IBee) {
|
||||
ItemStack hive = null;
|
||||
if (ExtraBeesIntegration.isLoaded()) {
|
||||
if (speciesCurrent == ExtraBeesIntegration.water) {
|
||||
hive = new ItemStack(ExtraBeesIntegration.hive, 1, 0);
|
||||
}
|
||||
if (speciesCurrent == ExtraBeesIntegration.rock) {
|
||||
hive = new ItemStack(ExtraBeesIntegration.hive, 1, 1);
|
||||
}
|
||||
if (speciesCurrent == ExtraBeesIntegration.basalt) {
|
||||
hive = new ItemStack(ExtraBeesIntegration.hive, 1, 2);
|
||||
}
|
||||
if (speciesCurrent == ExtraBeesIntegration.marble) {
|
||||
hive = new ItemStack(ExtraBeesIntegration.hive, 1, 3);
|
||||
}
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Forest.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 1);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Meadows.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 2);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Modest.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 3);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Tropical.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 4);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Ended.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 5);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Wintry.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 6);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Marshy.getAllele()) {
|
||||
hive = new ItemStack(Mods.Forestry.block("beehives"), 1, 7);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Steadfast.getAllele()) {
|
||||
hive = new ItemStack(Blocks.CHEST);
|
||||
}
|
||||
ItemStack hive = getHive(speciesCurrent);
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Valiant.getAllele()) {
|
||||
new ControlTextCentered(this, y, I18N.localise(AnalystConstants.MUTATIONS_KEY + ".bee.natural")).setColor(getColor());
|
||||
y += 10;
|
||||
@@ -98,7 +59,7 @@ public class AnalystPageMutations extends ControlAnalystPage {
|
||||
y += 10;
|
||||
new ControlTextCentered(this, y, TextFormatting.ITALIC + I18N.localise(AnalystConstants.MUTATIONS_KEY + ".bee.villager")).setColor(getColor());
|
||||
y += 22;
|
||||
} else if (hive != null) {
|
||||
} else if (!hive.isEmpty()) {
|
||||
new ControlTextCentered(this, y, I18N.localise(AnalystConstants.MUTATIONS_KEY + ".bee.natural")).setColor(getColor());
|
||||
y += 10;
|
||||
ControlItemDisplay display = new ControlItemDisplay(this, (getWidth() - 16) / 2, y);
|
||||
@@ -124,20 +85,21 @@ public class AnalystPageMutations extends ControlAnalystPage {
|
||||
if (!isMaster && !isKnown(system, mutation)) {
|
||||
new ControlUnknownMutation(this, ox + dx, y, 44, 16);
|
||||
} else {
|
||||
new Control(this, ox + dx, y, 44, 16) {
|
||||
new ControlResultantMutation(this, ox + dx, y, mutation, specificChance, system, mutation.getAllele0(), mutation.getAllele1());
|
||||
/*new Control(this, ox + dx, y, 44, 16) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
IAlleleSpecies species0 = mutation.getAllele0();
|
||||
IAlleleSpecies species2 = mutation.getAllele1();
|
||||
String comb = species0.getAlleleName() + " + " + species2.getAlleleName();
|
||||
IAlleleSpecies firstSpecies = mutation.getAllele0();
|
||||
IAlleleSpecies secondSpecies = mutation.getAllele1();
|
||||
String comb = firstSpecies.getAlleleName() + " + " + secondSpecies.getAlleleName();
|
||||
addTooltip(comb);
|
||||
String chance = getMutationColour(mutation.getBaseChance()).getCode() + (int) mutation.getBaseChance() + "% " + I18N.localise(AnalystConstants.MUTATIONS_KEY + ".chance");
|
||||
if (specificChance != mutation.getBaseChance()) {
|
||||
chance = chance + getMutationColour(specificChance).getCode() + " (" + (int) specificChance + "% " + I18N.localise(AnalystConstants.MUTATIONS_KEY + ".currently") + ")";
|
||||
}
|
||||
addTooltip(chance);
|
||||
for (String s : mutation.getSpecialConditions()) {
|
||||
addTooltip(s);
|
||||
for (String condition : mutation.getSpecialConditions()) {
|
||||
addTooltip(condition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +118,7 @@ public class AnalystPageMutations extends ControlAnalystPage {
|
||||
drawSprite(ModuleItems.iconAdd);
|
||||
}
|
||||
}
|
||||
};
|
||||
};*/
|
||||
}
|
||||
dx = 52 - dx;
|
||||
if (dx == 0 || resultant.size() == 1) {
|
||||
@@ -178,25 +140,26 @@ public class AnalystPageMutations extends ControlAnalystPage {
|
||||
y += 10;
|
||||
for (IMutation mutation : further) {
|
||||
IAllele speciesComb = mutation.getPartner(speciesCurrent);
|
||||
float specificChance2 = getSpecificChance(ind, mutation, system);
|
||||
float specificChance = getSpecificChance(ind, mutation, system);
|
||||
if (!isMaster && !isKnown(system, mutation)) {
|
||||
new ControlUnknownMutation(this, ox + dx, y, 44, 16);
|
||||
} else {
|
||||
new Control(this, ox + dx, y, 44, 16) {
|
||||
new ControlFurtherMutation(this, ox + dx, y, mutation, specificChance, system, speciesCurrent, (IAlleleSpecies) speciesComb, (IAlleleSpecies) mutation.getTemplate()[0]);
|
||||
/*new Control(this, ox + dx, y, 44, 16) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
IAlleleSpecies species0 = (IAlleleSpecies) speciesComb;
|
||||
IAlleleSpecies species2 = (IAlleleSpecies) mutation.getTemplate()[0];
|
||||
addTooltip(species2.getAlleleName());
|
||||
String comb = speciesCurrent.getAlleleName() + " + " + species0.getAlleleName();
|
||||
IAlleleSpecies firstSpecies = (IAlleleSpecies) speciesComb;
|
||||
IAlleleSpecies secondSpecies = (IAlleleSpecies) mutation.getTemplate()[0];
|
||||
addTooltip(secondSpecies.getAlleleName());
|
||||
String comb = speciesCurrent.getAlleleName() + " + " + firstSpecies.getAlleleName();
|
||||
addTooltip(comb);
|
||||
String chance = getMutationColour(mutation.getBaseChance()).getCode() + (int) mutation.getBaseChance() + "% " + I18N.localise(AnalystConstants.MUTATIONS_KEY + ".chance");
|
||||
if (specificChance2 != mutation.getBaseChance()) {
|
||||
chance = chance + getMutationColour(specificChance2).getCode() + " (" + (int) specificChance2 + "% " + I18N.localise(AnalystConstants.MUTATIONS_KEY + ".currently") + ")";
|
||||
}
|
||||
addTooltip(chance);
|
||||
for (String s : mutation.getSpecialConditions()) {
|
||||
addTooltip(s);
|
||||
for (String condition : mutation.getSpecialConditions()) {
|
||||
addTooltip(condition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +179,7 @@ public class AnalystPageMutations extends ControlAnalystPage {
|
||||
drawSprite(ModuleItems.iconArrow);
|
||||
}
|
||||
}
|
||||
};
|
||||
};*/
|
||||
}
|
||||
dx = 52 - dx;
|
||||
if (dx == 0 || further.size() == 1) {
|
||||
@@ -268,6 +231,40 @@ public class AnalystPageMutations extends ControlAnalystPage {
|
||||
return EnumColor.DARK_RED;
|
||||
}
|
||||
|
||||
protected ItemStack getHive(IAlleleSpecies speciesCurrent){
|
||||
if (ExtraBeesIntegration.isLoaded()) {
|
||||
ItemStack hive = ExtraBeesIntegration.getHive(speciesCurrent);
|
||||
if(!hive.isEmpty()){
|
||||
return hive;
|
||||
}
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Forest.getAllele()) {
|
||||
return new ItemStack(Mods.Forestry.block("beehives"), 1, 1);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Meadows.getAllele()) {
|
||||
return new ItemStack(Mods.Forestry.block("beehives"), 1, 2);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Modest.getAllele()) {
|
||||
return new ItemStack(Mods.Forestry.block("beehives"), 1, 3);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Tropical.getAllele()) {
|
||||
return new ItemStack(Mods.Forestry.block("beehives"), 1, 4);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Ended.getAllele()) {
|
||||
return new ItemStack(Mods.Forestry.block("beehives"), 1, 5);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Wintry.getAllele()) {
|
||||
return new ItemStack(Mods.Forestry.block("beehives"), 1, 6);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Marshy.getAllele()) {
|
||||
return new ItemStack(Mods.Forestry.block("beehives"), 1, 7);
|
||||
}
|
||||
if (speciesCurrent == ForestryAllele.BeeSpecies.Steadfast.getAllele()) {
|
||||
return new ItemStack(Blocks.CHEST);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
static class ControlUnknownMutation extends Control {
|
||||
public ControlUnknownMutation(IWidget parent, int x, int y, int w, int h) {
|
||||
super(parent, x, y, w, h);
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package binnie.genetics.gui.analyst;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IMutation;
|
||||
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.core.gui.IWidget;
|
||||
import binnie.core.gui.geometry.Point;
|
||||
import binnie.core.gui.renderer.RenderUtil;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.genetics.item.ModuleItems;
|
||||
|
||||
public class ControlFurtherMutation extends ControlMutation {
|
||||
private final IAlleleSpecies resolute;
|
||||
|
||||
public ControlFurtherMutation(IWidget parent, int x, int y, IMutation mutation, float specificChance, BreedingSystem system, IAlleleSpecies firstSpecies, IAlleleSpecies secondSpecies, IAlleleSpecies resolute) {
|
||||
super(parent, x, y, mutation, specificChance, system, firstSpecies, secondSpecies);
|
||||
this.resolute = resolute;
|
||||
|
||||
addTooltip(resolute.getAlleleName());
|
||||
String comb = firstSpecies.getAlleleName() + " + " + secondSpecies.getAlleleName();
|
||||
addTooltip(comb);
|
||||
String chance = getMutationColour(mutation.getBaseChance()).getCode() + (int) mutation.getBaseChance() + "% " + I18N.localise(AnalystConstants.MUTATIONS_KEY + ".chance");
|
||||
if (specificChance != mutation.getBaseChance()) {
|
||||
chance = chance + getMutationColour(specificChance).getCode() + " (" + (int) specificChance + "% " + I18N.localise(AnalystConstants.MUTATIONS_KEY + ".currently") + ")";
|
||||
}
|
||||
addTooltip(chance);
|
||||
for (String condition : mutation.getSpecialConditions()) {
|
||||
addTooltip(condition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
GlStateManager.enableBlend();
|
||||
RenderUtil.drawItem(Point.ZERO, system.getDefaultMember(secondSpecies.getUID()));
|
||||
RenderUtil.drawItem(new Point(28, 0), system.getDefaultMember(resolute.getUID()));
|
||||
GlStateManager.disableBlend();
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColor());
|
||||
if (specificChance != mutation.getBaseChance()) {
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColor());
|
||||
drawSprite(ModuleItems.iconArrow0);
|
||||
RenderUtil.setColour(getMutationColour(specificChance).getColor());
|
||||
drawSprite(ModuleItems.iconArrow1);
|
||||
} else {
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColor());
|
||||
drawSprite(ModuleItems.iconArrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package binnie.genetics.gui.analyst;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IMutation;
|
||||
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.core.gui.IWidget;
|
||||
import binnie.core.gui.controls.core.Control;
|
||||
import binnie.core.gui.geometry.Point;
|
||||
import binnie.core.gui.minecraft.EnumColor;
|
||||
import binnie.core.gui.renderer.RenderUtil;
|
||||
import binnie.core.resource.BinnieSprite;
|
||||
|
||||
public abstract class ControlMutation extends Control {
|
||||
protected final IMutation mutation;
|
||||
protected final float specificChance;
|
||||
protected final BreedingSystem system;
|
||||
protected final IAlleleSpecies firstSpecies;
|
||||
protected final IAlleleSpecies secondSpecies;
|
||||
|
||||
protected ControlMutation(IWidget parent, int x, int y, IMutation mutation, float specificChance, BreedingSystem system, IAlleleSpecies firstSpecies, IAlleleSpecies secondSpecies) {
|
||||
super(parent, x, y, 44, 16);
|
||||
this.mutation = mutation;
|
||||
this.specificChance = specificChance;
|
||||
this.system = system;
|
||||
this.firstSpecies = firstSpecies;
|
||||
this.secondSpecies = secondSpecies;
|
||||
}
|
||||
|
||||
protected EnumColor getMutationColour(float percent) {
|
||||
if (percent >= 20.0f) {
|
||||
return EnumColor.DARK_GREEN;
|
||||
}
|
||||
if (percent >= 15.0f) {
|
||||
return EnumColor.GREEN;
|
||||
}
|
||||
if (percent >= 10.0f) {
|
||||
return EnumColor.YELLOW;
|
||||
}
|
||||
if (percent >= 5.0f) {
|
||||
return EnumColor.GOLD;
|
||||
}
|
||||
if (percent > 0.0f) {
|
||||
return EnumColor.RED;
|
||||
}
|
||||
return EnumColor.DARK_RED;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void drawSprite(BinnieSprite sprite) {
|
||||
RenderUtil.drawSprite(new Point(14, 0), sprite.getSprite());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package binnie.genetics.gui.analyst;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IMutation;
|
||||
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.core.gui.IWidget;
|
||||
import binnie.core.gui.geometry.Point;
|
||||
import binnie.core.gui.renderer.RenderUtil;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.genetics.item.ModuleItems;
|
||||
|
||||
public class ControlResultantMutation extends ControlMutation {
|
||||
|
||||
public ControlResultantMutation(IWidget parent, int x, int y, IMutation mutation, float specificChance, BreedingSystem system, IAlleleSpecies firstSpecies, IAlleleSpecies secondSpecies) {
|
||||
super(parent, x, y, mutation, specificChance, system, firstSpecies, secondSpecies);
|
||||
|
||||
String comb = firstSpecies.getAlleleName() + " + " + secondSpecies.getAlleleName();
|
||||
addTooltip(comb);
|
||||
String chance = getMutationColour(mutation.getBaseChance()).getCode() + (int) mutation.getBaseChance() + "% " + I18N.localise(AnalystConstants.MUTATIONS_KEY + ".chance");
|
||||
if (specificChance != mutation.getBaseChance()) {
|
||||
chance = chance + getMutationColour(specificChance).getCode() + " (" + (int) specificChance + "% " + I18N.localise(AnalystConstants.MUTATIONS_KEY + ".currently") + ")";
|
||||
}
|
||||
addTooltip(chance);
|
||||
for (String condition : mutation.getSpecialConditions()) {
|
||||
addTooltip(condition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialise() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
GlStateManager.enableBlend();
|
||||
RenderUtil.drawItem(Point.ZERO, system.getDefaultMember(firstSpecies.getUID()));
|
||||
RenderUtil.drawItem(new Point(28, 0), system.getDefaultMember(secondSpecies.getUID()));
|
||||
GlStateManager.disableBlend();
|
||||
if (specificChance != mutation.getBaseChance()) {
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColor());
|
||||
drawSprite(ModuleItems.iconAdd0);
|
||||
RenderUtil.setColour(getMutationColour(specificChance).getColor());
|
||||
drawSprite(ModuleItems.iconAdd1);
|
||||
} else {
|
||||
RenderUtil.setColour(getMutationColour(mutation.getBaseChance()).getColor());
|
||||
drawSprite(ModuleItems.iconAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user