aboutsummaryrefslogtreecommitdiff
path: root/src/Java/binnie/extrabees/gui/punnett
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-01-20 14:24:34 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-01-20 14:24:34 +1000
commit869c206c4fcc8001bd2e1d66f704290331813835 (patch)
tree96735ce8fe4665e2759c3374221d6f06f4527df2 /src/Java/binnie/extrabees/gui/punnett
parentec2c72827f01dd4bb2174137f1ab162f9ddaab62 (diff)
downloadGT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.tar.gz
GT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.tar.bz2
GT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.zip
Initial Commit
Diffstat (limited to 'src/Java/binnie/extrabees/gui/punnett')
-rw-r--r--src/Java/binnie/extrabees/gui/punnett/ControlChromosome.java49
-rw-r--r--src/Java/binnie/extrabees/gui/punnett/ControlPunnett.java86
-rw-r--r--src/Java/binnie/extrabees/gui/punnett/ExtraBeeGUITexture.java8
-rw-r--r--src/Java/binnie/extrabees/gui/punnett/WindowPunnettSquare.java67
4 files changed, 210 insertions, 0 deletions
diff --git a/src/Java/binnie/extrabees/gui/punnett/ControlChromosome.java b/src/Java/binnie/extrabees/gui/punnett/ControlChromosome.java
new file mode 100644
index 0000000000..f4a7ffc507
--- /dev/null
+++ b/src/Java/binnie/extrabees/gui/punnett/ControlChromosome.java
@@ -0,0 +1,49 @@
+package binnie.extrabees.gui.punnett;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.renderer.Renderer;
+import forestry.api.genetics.IChromosomeType;
+
+public class ControlChromosome
+ extends Control
+ implements IControlValue<IChromosomeType>, ITooltip
+{
+ IChromosomeType value;
+
+ protected ControlChromosome(IWidget parent, float x, float y, IChromosomeType type)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ setValue(type);
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public IChromosomeType getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(IChromosomeType value)
+ {
+ this.value = value;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(ExtraBeeGUITexture.Chromosome, getArea());
+ CraftGUI.Render.colour(16711680);
+ CraftGUI.Render.texture(ExtraBeeGUITexture.Chromosome2, getArea());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ if (this.value != null) {
+ tooltip.add(this.value.getName());
+ }
+ }
+}
diff --git a/src/Java/binnie/extrabees/gui/punnett/ControlPunnett.java b/src/Java/binnie/extrabees/gui/punnett/ControlPunnett.java
new file mode 100644
index 0000000000..56b2f6c916
--- /dev/null
+++ b/src/Java/binnie/extrabees/gui/punnett/ControlPunnett.java
@@ -0,0 +1,86 @@
+package binnie.extrabees.gui.punnett;
+
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.core.renderer.Renderer;
+import forestry.api.genetics.IAllele;
+import forestry.api.genetics.IChromosomeType;
+import forestry.api.genetics.IGenome;
+import forestry.api.genetics.IIndividual;
+import forestry.api.genetics.ISpeciesRoot;
+import java.util.LinkedList;
+import java.util.List;
+
+public class ControlPunnett
+ extends Control
+{
+ protected ControlPunnett(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, boxWidth * 3, boxWidth * 3);
+ }
+
+ static int boxWidth = 80;
+ static int boxHeight = 28;
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.solid(new IArea(0.0F, boxHeight, boxWidth * 3, 1.0F), 11184810);
+ CraftGUI.Render.solid(new IArea(boxWidth / 2.0F, boxHeight * 2, boxWidth * 2.5F, 1.0F), 11184810);
+
+ CraftGUI.Render.solid(new IArea(boxWidth, 0.0F, 1.0F, boxHeight * 3), 11184810);
+ CraftGUI.Render.solid(new IArea(boxWidth * 2, boxHeight / 2.0F, 1.0F, boxHeight * 2.5F), 11184810);
+ }
+
+ public void setup(IChromosomeType chromosome, IIndividual ind1, IIndividual ind2, ISpeciesRoot root)
+ {
+ deleteAllChildren();
+ if ((chromosome == null) || (ind1 == null) || (ind2 == null) || (root == null)) {
+ return;
+ }
+ IAllele primary1 = ind1.getGenome().getActiveAllele(chromosome);
+ IAllele primary2 = ind2.getGenome().getActiveAllele(chromosome);
+ IAllele secondary1 = ind1.getGenome().getInactiveAllele(chromosome);
+ IAllele secondary2 = ind2.getGenome().getInactiveAllele(chromosome);
+
+ int x = 1;
+ int y = 1;
+ for (IAllele allele1 : new IAllele[] { primary1, secondary1 })
+ {
+ y = 1;
+ for (IAllele allele2 : new IAllele[] { primary2, secondary2 })
+ {
+ List<IAllele> alleles = new LinkedList();
+ if ((allele1.isDominant()) && (!allele2.isDominant()))
+ {
+ alleles.add(allele1);
+ }
+ else if ((allele2.isDominant()) && (!allele1.isDominant()))
+ {
+ alleles.add(allele2);
+ }
+ else
+ {
+ alleles.add(allele1);
+ if (allele1 != allele2) {
+ alleles.add(allele2);
+ }
+ }
+ String text = "";
+ for (IAllele allele : alleles) {
+ text = text + allele.getName() + ": " + 25.0F / alleles.size() + "%\n";
+ }
+ new ControlText(this, new IArea(x * boxWidth, boxHeight * y, boxWidth, boxHeight), text, TextJustification.TopCenter).setColour(11184810);
+ y++;
+ }
+ x++;
+ }
+ new ControlText(this, new IArea(boxWidth, 0.0F, boxWidth, boxHeight), "\n" + primary1.getName(), TextJustification.TopCenter).setColour(11184810);
+ new ControlText(this, new IArea(boxWidth * 2, 0.0F, boxWidth, boxHeight), "\n" + secondary1.getName(), TextJustification.TopCenter).setColour(11184810);
+ new ControlText(this, new IArea(0.0F, boxHeight, boxWidth, boxHeight), primary2.getName(), TextJustification.TopCenter).setColour(11184810);
+ new ControlText(this, new IArea(0.0F, boxHeight * 2, boxWidth, boxHeight), primary2.getName(), TextJustification.TopCenter).setColour(11184810);
+ }
+}
diff --git a/src/Java/binnie/extrabees/gui/punnett/ExtraBeeGUITexture.java b/src/Java/binnie/extrabees/gui/punnett/ExtraBeeGUITexture.java
new file mode 100644
index 0000000000..eac77aabf9
--- /dev/null
+++ b/src/Java/binnie/extrabees/gui/punnett/ExtraBeeGUITexture.java
@@ -0,0 +1,8 @@
+package binnie.extrabees.gui.punnett;
+
+public enum ExtraBeeGUITexture
+{
+ Chromosome, Chromosome2;
+
+ private ExtraBeeGUITexture() {}
+}
diff --git a/src/Java/binnie/extrabees/gui/punnett/WindowPunnettSquare.java b/src/Java/binnie/extrabees/gui/punnett/WindowPunnettSquare.java
new file mode 100644
index 0000000000..488f2b6922
--- /dev/null
+++ b/src/Java/binnie/extrabees/gui/punnett/WindowPunnettSquare.java
@@ -0,0 +1,67 @@
+package binnie.extrabees.gui.punnett;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.resource.StyleSheet;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import binnie.craftgui.resource.minecraft.PaddedTexture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.extrabees.ExtraBees;
+import binnie.extrabees.core.ExtraBeeTexture;
+import cpw.mods.fml.relauncher.Side;
+import forestry.api.genetics.ISpeciesRoot;
+import java.util.Map;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowPunnettSquare
+ extends Window
+{
+ ControlSlot bee1;
+ ControlSlot bee2;
+ ControlPunnett punnett;
+
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowPunnettSquare(player, inventory, side);
+ }
+
+ public WindowPunnettSquare(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(245.0F, 205.0F, player, inventory, side);
+ }
+
+ public AbstractMod getMod()
+ {
+ return ExtraBees.instance;
+ }
+
+ public String getName()
+ {
+ return "Punnett";
+ }
+
+ public void initialiseClient()
+ {
+ setTitle("Punnett Square");
+
+ CraftGUI.Render.stylesheet(new StyleSheetPunnett());
+ }
+
+ ISpeciesRoot root = null;
+
+ static class StyleSheetPunnett
+ extends StyleSheet
+ {
+ public StyleSheetPunnett()
+ {
+ this.textures.put(CraftGUITexture.Window, new PaddedTexture(0, 0, 160, 160, 0, ExtraBeeTexture.GUIPunnett, 32, 32, 32, 32));
+ this.textures.put(CraftGUITexture.Slot, new StandardTexture(160, 0, 18, 18, 0, ExtraBeeTexture.GUIPunnett));
+ this.textures.put(ExtraBeeGUITexture.Chromosome, new StandardTexture(160, 36, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
+ this.textures.put(ExtraBeeGUITexture.Chromosome2, new StandardTexture(160, 52, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
+ }
+ }
+}