mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-21 04:32:24 +00:00
port to forestry 4.2
This commit is contained in:
1 parent
dbc5c1a564
commit
f969f63b66
3697 files changed
+78372
No files matched your search
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import binnie.craftgui.controls.listbox.ControlListBox;
|
||||
|
||||
class ControlBranchBox extends ControlListBox<IClassification>
|
||||
{
|
||||
@Override
|
||||
public IWidget createOption(final IClassification value, final int y) {
|
||||
return new ControlBranchBoxOption(((ControlScrollableContent<ControlList<IClassification>>) this).getContent(), value, y);
|
||||
}
|
||||
|
||||
public ControlBranchBox(final IWidget parent, final float x, final float y, final float width, final float height) {
|
||||
super(parent, x, y, width, height, 12.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import binnie.craftgui.controls.listbox.ControlTextOption;
|
||||
|
||||
class ControlBranchBoxOption extends ControlTextOption<IClassification>
|
||||
{
|
||||
public ControlBranchBoxOption(final ControlList<IClassification> controlList, final IClassification option, final int y) {
|
||||
super(controlList, option, (option.getName() == null) ? option.getScientific() : (option.getName().contains(".") ? option.getScientific() : option.getName()), y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITextureSheet;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
class ControlBreedingProgress extends Control
|
||||
{
|
||||
private static Texture Progress;
|
||||
private float percentage;
|
||||
private int colour;
|
||||
|
||||
public ControlBreedingProgress(final IWidget parent, final int x, final int y, final int width, final int height, final BreedingSystem system, final float percentage) {
|
||||
super(parent, x, y, width, height);
|
||||
this.percentage = percentage;
|
||||
this.colour = system.getColour();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.texture(CraftGUITexture.PanelBlack, this.getArea());
|
||||
final IArea area = this.getArea().inset(1);
|
||||
area.setSize(new IPoint(area.size().x() * this.percentage, area.size().y()));
|
||||
CraftGUI.Render.colour(this.colour);
|
||||
CraftGUI.Render.texture(ControlBreedingProgress.Progress, area);
|
||||
}
|
||||
|
||||
static {
|
||||
ControlBreedingProgress.Progress = new StandardTexture(80, 22, 4, 4, CraftGUITextureSheet.Controls2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import net.minecraft.util.IIcon;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
|
||||
public class ControlDatabaseIndividualDisplay extends ControlItemDisplay implements ITooltip
|
||||
{
|
||||
private IAlleleSpecies species;
|
||||
EnumDiscoveryState discovered;
|
||||
|
||||
public void setSpecies(final IAlleleSpecies species) {
|
||||
this.setSpecies(species, EnumDiscoveryState.Show);
|
||||
}
|
||||
|
||||
public void setSpecies(final IAlleleSpecies species, EnumDiscoveryState state) {
|
||||
final ISpeciesRoot speciesRoot = Binnie.Genetics.getSpeciesRoot(species);
|
||||
final BreedingSystem system = Binnie.Genetics.getSystem(speciesRoot.getUID());
|
||||
final IIndividual ind = system.getSpeciesRoot().templateAsIndividual(system.getSpeciesRoot().getTemplate(species.getUID()));
|
||||
super.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
|
||||
this.species = species;
|
||||
final GameProfile username = Window.get(this).getUsername();
|
||||
if (state == EnumDiscoveryState.Undetermined) {
|
||||
state = (system.isSpeciesDiscovered(species, Window.get(this).getWorld(), username) ? EnumDiscoveryState.Discovered : EnumDiscoveryState.Undiscovered);
|
||||
}
|
||||
if (Window.get(this) instanceof WindowAbstractDatabase && ((WindowAbstractDatabase) Window.get(this)).isNEI) {
|
||||
state = EnumDiscoveryState.Show;
|
||||
}
|
||||
this.discovered = state;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
public ControlDatabaseIndividualDisplay(final IWidget parent, final float x, final float y) {
|
||||
this(parent, x, y, 16.0f);
|
||||
}
|
||||
|
||||
public ControlDatabaseIndividualDisplay(final IWidget parent, final float x, final float y, final float size) {
|
||||
super(parent, x, y, size);
|
||||
this.species = null;
|
||||
this.discovered = EnumDiscoveryState.Show;
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
if (event.getButton() == 0 && ControlDatabaseIndividualDisplay.this.species != null && EnumDiscoveryState.Show == ControlDatabaseIndividualDisplay.this.discovered) {
|
||||
((WindowAbstractDatabase) ControlDatabaseIndividualDisplay.this.getSuperParent()).gotoSpeciesDelayed(ControlDatabaseIndividualDisplay.this.species);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
IIcon icon = null;
|
||||
if (this.species == null) {
|
||||
return;
|
||||
}
|
||||
final BreedingSystem system = Binnie.Genetics.getSystem(this.species.getRoot());
|
||||
switch (this.discovered) {
|
||||
case Show: {
|
||||
super.onRenderForeground();
|
||||
return;
|
||||
}
|
||||
case Discovered: {
|
||||
icon = system.getDiscoveredIcon();
|
||||
break;
|
||||
}
|
||||
case Undiscovered: {
|
||||
icon = system.getUndiscoveredIcon();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (icon != null) {
|
||||
CraftGUI.Render.iconItem(IPoint.ZERO, icon);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
if (this.species != null) {
|
||||
switch (this.discovered) {
|
||||
case Show: {
|
||||
tooltip.add(this.species.getName());
|
||||
break;
|
||||
}
|
||||
case Discovered: {
|
||||
tooltip.add("Discovered Species");
|
||||
break;
|
||||
}
|
||||
case Undiscovered: {
|
||||
tooltip.add("Undiscovered Species");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.geometry.CraftGUIUtil;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.craftgui.controls.listbox.ControlTextOption;
|
||||
|
||||
public class ControlItemStackOption extends ControlTextOption<ItemStack>
|
||||
{
|
||||
private ControlItemDisplay controlBee;
|
||||
|
||||
public ControlItemStackOption(final ControlList<ItemStack> controlList, final ItemStack option, final int y) {
|
||||
super(controlList, option, option.getDisplayName(), y);
|
||||
this.setSize(new IPoint(this.getSize().x(), 20.0f));
|
||||
(this.controlBee = new ControlItemDisplay(this, 2.0f, 2.0f)).setItemStack(option);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
CraftGUIUtil.moveWidget(this.textWidget, new IPoint(22.0f, 0.0f));
|
||||
this.textWidget.setSize(this.textWidget.getSize().sub(new IPoint(24.0f, 0.0f)));
|
||||
final int th = (int) CraftGUI.Render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x());
|
||||
final int height = Math.max(20, th + 6);
|
||||
this.setSize(new IPoint(this.size().x(), height));
|
||||
this.textWidget.setSize(new IPoint(this.textWidget.getSize().x(), height));
|
||||
this.controlBee.setPosition(new IPoint(this.controlBee.pos().x(), (height - 18) / 2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import java.util.List;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import binnie.craftgui.controls.listbox.ControlListBox;
|
||||
|
||||
class ControlMutationBox extends ControlListBox<IMutation>
|
||||
{
|
||||
private int index;
|
||||
private Type type;
|
||||
private IAlleleSpecies species;
|
||||
|
||||
@Override
|
||||
public IWidget createOption(final IMutation value, final int y) {
|
||||
return new ControlMutationItem(((ControlScrollableContent<ControlList<IMutation>>) this).getContent(), value, this.species, y);
|
||||
}
|
||||
|
||||
public ControlMutationBox(final IWidget parent, final int x, final int y, final int width, final int height, final Type type) {
|
||||
super(parent, x, y, width, height, 12.0f);
|
||||
this.species = null;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setSpecies(final IAlleleSpecies species) {
|
||||
if (species != this.species) {
|
||||
this.species = species;
|
||||
this.index = 0;
|
||||
this.movePercentage(-100.0f);
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
|
||||
final List<IMutation> discovered = system.getDiscoveredMutations(Window.get(this).getWorld(), Window.get(this).getUsername());
|
||||
if (species != null) {
|
||||
if (this.type == Type.Resultant) {
|
||||
this.setOptions(system.getResultantMutations(species));
|
||||
}
|
||||
else {
|
||||
final List<IMutation> mutations = system.getFurtherMutations(species);
|
||||
int i = 0;
|
||||
while (i < mutations.size()) {
|
||||
final IMutation mutation = mutations.get(i);
|
||||
if (!discovered.contains(mutations) && !((IAlleleSpecies) mutation.getTemplate()[0]).isCounted()) {
|
||||
mutations.remove(i);
|
||||
}
|
||||
else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
this.setOptions(mutations);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum Type
|
||||
{
|
||||
Resultant,
|
||||
Further;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import binnie.craftgui.controls.listbox.ControlOption;
|
||||
|
||||
class ControlMutationItem extends ControlOption<IMutation>
|
||||
{
|
||||
private ControlDatabaseIndividualDisplay itemWidget1;
|
||||
private ControlDatabaseIndividualDisplay itemWidget2;
|
||||
private ControlDatabaseIndividualDisplay itemWidget3;
|
||||
private ControlMutationSymbol addSymbol;
|
||||
private ControlMutationSymbol arrowSymbol;
|
||||
|
||||
public ControlMutationItem(final ControlList<IMutation> controlList, final IMutation option, final IAlleleSpecies species, final int y) {
|
||||
super(controlList, option, y);
|
||||
this.itemWidget1 = new ControlDatabaseIndividualDisplay(this, 4.0f, 4.0f);
|
||||
this.itemWidget2 = new ControlDatabaseIndividualDisplay(this, 44.0f, 4.0f);
|
||||
this.itemWidget3 = new ControlDatabaseIndividualDisplay(this, 104.0f, 4.0f);
|
||||
this.addSymbol = new ControlMutationSymbol(this, 24, 4, 0);
|
||||
this.arrowSymbol = new ControlMutationSymbol(this, 64, 4, 1);
|
||||
final boolean isNEI = ((WindowAbstractDatabase) this.getSuperParent()).isNEI();
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
|
||||
if (this.getValue() != null) {
|
||||
final boolean isMutationDiscovered = system.isMutationDiscovered(this.getValue(), Window.get(this).getWorld(), Window.get(this).getUsername());
|
||||
IAlleleSpecies allele = null;
|
||||
EnumDiscoveryState state = null;
|
||||
allele = this.getValue().getAllele0();
|
||||
state = ((isNEI || isMutationDiscovered) ? EnumDiscoveryState.Show : ((species == allele) ? EnumDiscoveryState.Show : EnumDiscoveryState.Undetermined));
|
||||
this.itemWidget1.setSpecies(allele, state);
|
||||
allele = this.getValue().getAllele1();
|
||||
state = ((isNEI || isMutationDiscovered) ? EnumDiscoveryState.Show : ((species == allele) ? EnumDiscoveryState.Show : EnumDiscoveryState.Undetermined));
|
||||
this.itemWidget2.setSpecies(allele, state);
|
||||
allele = (IAlleleSpecies) this.getValue().getTemplate()[0];
|
||||
state = ((isNEI || isMutationDiscovered) ? EnumDiscoveryState.Show : ((species == allele) ? EnumDiscoveryState.Show : EnumDiscoveryState.Undetermined));
|
||||
this.itemWidget3.setSpecies(allele, state);
|
||||
this.addSymbol.setValue(this.getValue());
|
||||
this.arrowSymbol.setValue(this.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITextureSheet;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
class ControlMutationSymbol extends Control implements ITooltip
|
||||
{
|
||||
private static Texture MutationPlus;
|
||||
private static Texture MutationArrow;
|
||||
private IMutation value;
|
||||
private boolean discovered;
|
||||
private int type;
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
super.onRenderBackground();
|
||||
if (this.type == 0) {
|
||||
CraftGUI.Render.texture(ControlMutationSymbol.MutationPlus, IPoint.ZERO);
|
||||
}
|
||||
else {
|
||||
CraftGUI.Render.texture(ControlMutationSymbol.MutationArrow, IPoint.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
protected ControlMutationSymbol(final IWidget parent, final int x, final int y, final int type) {
|
||||
super(parent, x, y, 16 + type * 16, 16.0f);
|
||||
this.value = null;
|
||||
this.type = type;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
public void setValue(final IMutation value) {
|
||||
this.value = value;
|
||||
final boolean isNEI = ((WindowAbstractDatabase) this.getSuperParent()).isNEI();
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
|
||||
this.discovered = (isNEI || system.isMutationDiscovered(value, Window.get(this).getWorld(), Window.get(this).getUsername()));
|
||||
if (this.discovered) {
|
||||
this.setColour(16777215);
|
||||
}
|
||||
else {
|
||||
this.setColour(7829367);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
if (this.type == 1 && this.discovered) {
|
||||
final IAllele species1 = this.value.getAllele0();
|
||||
final IAllele species2 = this.value.getAllele1();
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
|
||||
final float chance = system.getChance(this.value, Window.get(this).getPlayer(), species1, species2);
|
||||
tooltip.add("Current Chance - " + chance + "%");
|
||||
if (this.value.getSpecialConditions() != null) {
|
||||
for (final String string : this.value.getSpecialConditions()) {
|
||||
tooltip.add(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
ControlMutationSymbol.MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
|
||||
ControlMutationSymbol.MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import java.util.List;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.controls.listbox.ControlListBox;
|
||||
|
||||
public class ControlSpeciesBox extends ControlListBox<IAlleleSpecies>
|
||||
{
|
||||
private IClassification branch;
|
||||
|
||||
@Override
|
||||
public IWidget createOption(final IAlleleSpecies value, final int y) {
|
||||
return new ControlSpeciexBoxOption(((ControlScrollableContent<ControlList<IAlleleSpecies>>) this).getContent(), value, y);
|
||||
}
|
||||
|
||||
public ControlSpeciesBox(final IWidget parent, final float x, final float y, final float width, final float height) {
|
||||
super(parent, x, y, width, height, 12.0f);
|
||||
this.branch = null;
|
||||
}
|
||||
|
||||
public void setBranch(final IClassification branch) {
|
||||
if (branch != this.branch) {
|
||||
this.branch = branch;
|
||||
final List<IAlleleSpecies> speciesList2 = new ArrayList<IAlleleSpecies>();
|
||||
this.movePercentage(-100.0f);
|
||||
this.setOptions(speciesList2);
|
||||
final EntityPlayer player = Window.get(this).getPlayer();
|
||||
final GameProfile playerName = Window.get(this).getUsername();
|
||||
final WindowAbstractDatabase db = Window.get(this);
|
||||
final Collection<IAlleleSpecies> speciesList3 = db.isNEI ? db.getBreedingSystem().getAllSpecies() : db.getBreedingSystem().getDiscoveredSpecies(db.getWorld(), playerName);
|
||||
if (branch != null) {
|
||||
for (final IAlleleSpecies species : branch.getMemberSpecies()) {
|
||||
if (speciesList3.contains(species)) {
|
||||
speciesList2.add(species);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setOptions(speciesList2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.geometry.CraftGUIUtil;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.controls.listbox.ControlTextOption;
|
||||
|
||||
class ControlSpeciexBoxOption extends ControlTextOption<IAlleleSpecies>
|
||||
{
|
||||
private ControlDatabaseIndividualDisplay controlBee;
|
||||
|
||||
public ControlSpeciexBoxOption(final ControlList<IAlleleSpecies> controlList, final IAlleleSpecies option, final int y) {
|
||||
super(controlList, option, option.getName(), y);
|
||||
this.setSize(new IPoint(this.getSize().x(), 20.0f));
|
||||
(this.controlBee = new ControlDatabaseIndividualDisplay(this, 2.0f, 2.0f)).setSpecies(this.getValue(), EnumDiscoveryState.Undetermined);
|
||||
if (this.controlBee.discovered == EnumDiscoveryState.Discovered) {
|
||||
this.controlBee.discovered = EnumDiscoveryState.Show;
|
||||
}
|
||||
this.textWidget.setValue((this.controlBee.discovered == EnumDiscoveryState.Show) ? option.getName() : "Undiscovered");
|
||||
if (this.controlBee.discovered == EnumDiscoveryState.Show) {
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
CraftGUIUtil.moveWidget(this.textWidget, new IPoint(22.0f, 0.0f));
|
||||
this.textWidget.setSize(this.textWidget.getSize().sub(new IPoint(24.0f, 0.0f)));
|
||||
final int th = (int) CraftGUI.Render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x());
|
||||
final int height = Math.max(20, th + 6);
|
||||
this.setSize(new IPoint(this.size().x(), height));
|
||||
this.textWidget.setSize(new IPoint(this.textWidget.getSize().x(), height));
|
||||
this.controlBee.setPosition(new IPoint(this.controlBee.pos().x(), (height - 18) / 2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.Binnie;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.craftgui.core.ITooltipHelp;
|
||||
|
||||
public class DatabaseTab implements ITooltipHelp
|
||||
{
|
||||
private AbstractMod mod;
|
||||
private String unloc;
|
||||
private int colour;
|
||||
|
||||
public DatabaseTab(final AbstractMod mod, final String unloc, final int colour) {
|
||||
this.mod = mod;
|
||||
this.unloc = unloc;
|
||||
this.colour = colour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Binnie.Language.localise(this.mod, "gui.database.tab." + this.unloc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHelpTooltip(final Tooltip tooltip) {
|
||||
tooltip.add(Binnie.Language.localiseOrBlank(this.mod, "gui.database.tab." + this.unloc + ".help"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
public enum EnumDiscoveryState
|
||||
{
|
||||
Show,
|
||||
Undetermined,
|
||||
Discovered,
|
||||
Undiscovered;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
public interface IDatabaseMode
|
||||
{
|
||||
String getName();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.page.ControlPage;
|
||||
|
||||
public abstract class PageAbstract<T> extends ControlPage<DatabaseTab>
|
||||
{
|
||||
public PageAbstract(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), tab);
|
||||
}
|
||||
|
||||
public abstract void onValueChanged(final T p0);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import forestry.api.genetics.IClassification;
|
||||
|
||||
abstract class PageBranch extends PageAbstract<IClassification>
|
||||
{
|
||||
public PageBranch(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import java.util.List;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
|
||||
public class PageBranchOverview extends PageBranch
|
||||
{
|
||||
private ControlText pageBranchOverview_branchName;
|
||||
private ControlText pageBranchOverview_branchScientific;
|
||||
private ControlText pageBranchOverview_branchAuthority;
|
||||
private List<ControlText> pageBranchOverview_branchDescription;
|
||||
|
||||
public PageBranchOverview(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageBranchOverview_branchDescription = new ArrayList<ControlText>();
|
||||
this.pageBranchOverview_branchName = new ControlTextCentered(this, 8.0f, "");
|
||||
this.pageBranchOverview_branchScientific = new ControlTextCentered(this, 32.0f, "");
|
||||
this.pageBranchOverview_branchAuthority = new ControlTextCentered(this, 44.0f, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IClassification branch) {
|
||||
this.pageBranchOverview_branchName.setValue("§n" + branch.getName() + " Branch§r");
|
||||
this.pageBranchOverview_branchScientific.setValue("§oApidae " + branch.getScientific() + "§r");
|
||||
this.pageBranchOverview_branchAuthority.setValue("Discovered by §l" + branch.getMemberSpecies()[0].getAuthority() + "§r");
|
||||
for (final IWidget widget : this.pageBranchOverview_branchDescription) {
|
||||
this.deleteChild(widget);
|
||||
}
|
||||
this.pageBranchOverview_branchDescription.clear();
|
||||
String desc = branch.getDescription();
|
||||
if (desc == null || desc == "") {
|
||||
desc = "No Description Provided.";
|
||||
}
|
||||
String line = "";
|
||||
final List<String> descLines = new ArrayList<String>();
|
||||
for (final String str : desc.split(" ")) {
|
||||
if (CraftGUI.Render.textWidth(line + " " + str) > 134) {
|
||||
descLines.add("§o" + line + "§r");
|
||||
line = "";
|
||||
}
|
||||
line = line + " " + str;
|
||||
}
|
||||
descLines.add(line);
|
||||
int i = 0;
|
||||
for (final String dLine : descLines) {
|
||||
this.pageBranchOverview_branchDescription.add(new ControlTextCentered(this, 84 + 12 * i++, dLine));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import forestry.api.genetics.IClassification;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
|
||||
public class PageBranchSpecies extends PageBranch
|
||||
{
|
||||
private ControlText pageBranchSpecies_title;
|
||||
private ControlSpeciesBox pageBranchSpecies_speciesList;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onHandleEvent(final EventValueChanged<IAlleleSpecies> event) {
|
||||
}
|
||||
|
||||
public PageBranchSpecies(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageBranchSpecies_title = new ControlTextCentered(this, 8.0f, "Species");
|
||||
this.addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
if (event.isOrigin(PageBranchSpecies.this.pageBranchSpecies_speciesList)) {
|
||||
((WindowAbstractDatabase) PageBranchSpecies.this.getSuperParent()).gotoSpecies((IAlleleSpecies) event.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
this.pageBranchSpecies_speciesList = new ControlSpeciesBox(this, 4.0f, 20.0f, 136.0f, 152.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IClassification branch) {
|
||||
this.pageBranchSpecies_speciesList.setBranch(branch);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import binnie.craftgui.controls.page.ControlPage;
|
||||
|
||||
public class PageBreeder extends ControlPage<DatabaseTab>
|
||||
{
|
||||
private GameProfile player;
|
||||
|
||||
public PageBreeder(final IWidget parent, final GameProfile player, final DatabaseTab tab) {
|
||||
super(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), tab);
|
||||
this.player = player;
|
||||
this.onPageRefresh();
|
||||
}
|
||||
|
||||
public void onPageRefresh() {
|
||||
while (this.getWidgets().size() > 0) {
|
||||
this.deleteChild(this.getWidgets().get(0));
|
||||
}
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) Window.get(this)).getBreedingSystem();
|
||||
final String descriptor = system.getDescriptor();
|
||||
new ControlTextCentered(this, 8.0f, "§n" + system.getDescriptor() + " Profile§r");
|
||||
new ControlTextCentered(this, 75.0f, "" + system.discoveredSpeciesCount + "/" + system.totalSpeciesCount + " Species");
|
||||
new ControlBreedingProgress(this, 20, 87, 102, 14, system, system.discoveredSpeciesPercentage);
|
||||
new ControlTextCentered(this, 115.0f, "" + system.discoveredBranchCount + "/" + system.totalBranchCount + " Branches");
|
||||
new ControlBreedingProgress(this, 20, 127, 102, 14, system, system.discoveredBranchPercentage);
|
||||
if (system.discoveredSecretCount > 0) {
|
||||
new ControlTextCentered(this, 155.0f, "" + system.discoveredSecretCount + "/" + system.totalSecretCount + " Secret Species");
|
||||
}
|
||||
new ControlTextCentered(this, 32.0f, this.player.getName());
|
||||
new ControlTextCentered(this, 44.0f, "§o" + system.getEpitome() + "§r");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class PageBreederStats extends Control
|
||||
{
|
||||
String player;
|
||||
|
||||
public PageBreederStats(final IWidget parent, final int w, final int h, final String player) {
|
||||
super(parent, 0.0f, 0.0f, w, h);
|
||||
this.player = player;
|
||||
final ControlText pageBranchOverview_branchName = new ControlTextCentered(this, 8.0f, "§nStats§r");
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
public abstract class PageSpecies extends PageAbstract<IAlleleSpecies>
|
||||
{
|
||||
public PageSpecies(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import java.util.LinkedHashMap;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import java.util.Map;
|
||||
|
||||
public class PageSpeciesClassification extends PageSpecies
|
||||
{
|
||||
private Map<IClassification.EnumClassLevel, ControlText> levels;
|
||||
private ControlText genus;
|
||||
|
||||
public PageSpeciesClassification(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.levels = new LinkedHashMap<IClassification.EnumClassLevel, ControlText>();
|
||||
int y = 16;
|
||||
for (final IClassification.EnumClassLevel level : IClassification.EnumClassLevel.values()) {
|
||||
final ControlText text = new ControlTextCentered(this, y, "");
|
||||
text.setColour(level.getColour());
|
||||
this.levels.put(level, text);
|
||||
y += 12;
|
||||
}
|
||||
(this.genus = new ControlTextCentered(this, y, "")).setColour(16759415);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
if (species != null) {
|
||||
for (final ControlText text : this.levels.values()) {
|
||||
text.setValue("- - -");
|
||||
}
|
||||
this.genus.setValue(species.getBinomial());
|
||||
for (IClassification classification = species.getBranch(); classification != null; classification = classification.getParent()) {
|
||||
final IClassification.EnumClassLevel level = classification.getLevel();
|
||||
String text2 = "";
|
||||
final int n = level.ordinal();
|
||||
text2 += classification.getScientific();
|
||||
this.levels.get(level).setValue(text2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
|
||||
public class PageSpeciesMutations extends PageSpecies
|
||||
{
|
||||
private ControlText pageSpeciesFurther_Title;
|
||||
private ControlMutationBox pageSpeciesFurther_List;
|
||||
|
||||
public PageSpeciesMutations(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8.0f, "Further Mutations");
|
||||
this.pageSpeciesFurther_List = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.Further);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
this.pageSpeciesFurther_List.setSpecies(species);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
|
||||
public class PageSpeciesOverview extends PageSpecies
|
||||
{
|
||||
private ControlText controlName;
|
||||
private ControlText controlScientific;
|
||||
private ControlText controlAuthority;
|
||||
private ControlText controlComplexity;
|
||||
private ControlText controlDescription;
|
||||
private ControlText controlSignature;
|
||||
private ControlDatabaseIndividualDisplay controlInd1;
|
||||
private ControlDatabaseIndividualDisplay controlInd2;
|
||||
|
||||
public PageSpeciesOverview(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.controlInd1 = new ControlDatabaseIndividualDisplay(this, 5.0f, 5.0f);
|
||||
this.controlInd2 = new ControlDatabaseIndividualDisplay(this, 123.0f, 5.0f);
|
||||
this.controlName = new ControlTextCentered(this, 8.0f, "");
|
||||
this.controlScientific = new ControlTextCentered(this, 32.0f, "");
|
||||
this.controlAuthority = new ControlTextCentered(this, 44.0f, "");
|
||||
this.controlComplexity = new ControlTextCentered(this, 56.0f, "");
|
||||
this.controlDescription = new ControlText(this, new IArea(8.0f, 84.0f, this.getSize().x() - 16.0f, 0.0f), "", TextJustification.MiddleCenter);
|
||||
this.controlSignature = new ControlText(this, new IArea(8.0f, 84.0f, this.getSize().x() - 16.0f, 0.0f), "", TextJustification.BottomRight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
this.controlInd1.setSpecies(species, EnumDiscoveryState.Show);
|
||||
this.controlInd2.setSpecies(species, EnumDiscoveryState.Show);
|
||||
final String branchBinomial = (species.getBranch() != null) ? species.getBranch().getScientific() : "<Unknown>";
|
||||
final String branchName = (species.getBranch() != null) ? species.getBranch().getName() : "Unknown";
|
||||
this.controlName.setValue("§n" + species.getName() + "§r");
|
||||
this.controlScientific.setValue("§o" + branchBinomial + " " + species.getBinomial() + "§r");
|
||||
this.controlAuthority.setValue("Discovered by §l" + species.getAuthority() + "§r");
|
||||
this.controlComplexity.setValue("Complexity: " + species.getComplexity());
|
||||
final String desc = species.getDescription();
|
||||
String descBody = "§o";
|
||||
String descSig = "";
|
||||
if (desc == null || desc == "") {
|
||||
descBody += "No Description Provided.";
|
||||
}
|
||||
else {
|
||||
final String[] descStrings = desc.split("\\|");
|
||||
descBody += descStrings[0];
|
||||
for (int i = 1; i < descStrings.length - 1; ++i) {
|
||||
descBody = descBody + " " + descStrings[i];
|
||||
}
|
||||
if (descStrings.length > 1) {
|
||||
descSig += descStrings[descStrings.length - 1];
|
||||
}
|
||||
}
|
||||
this.controlDescription.setValue(descBody + "§r");
|
||||
this.controlSignature.setValue(descSig + "§r");
|
||||
final float descHeight = CraftGUI.Render.textHeight(this.controlDescription.getValue(), this.controlDescription.getSize().x());
|
||||
this.controlSignature.setPosition(new IPoint(this.controlSignature.pos().x(), this.controlDescription.getPosition().y() + descHeight + 10.0f));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
|
||||
public class PageSpeciesResultant extends PageSpecies
|
||||
{
|
||||
private ControlText pageSpeciesResultant_Title;
|
||||
private ControlMutationBox pageSpeciesResultant_List;
|
||||
|
||||
public PageSpeciesResultant(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageSpeciesResultant_Title = new ControlTextCentered(this, 8.0f, "Resultant Mutations");
|
||||
this.pageSpeciesResultant_List = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.Resultant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
this.pageSpeciesResultant_List.setSpecies(species);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.mod.database;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import binnie.craftgui.core.geometry.CraftGUIUtil;
|
||||
import binnie.craftgui.controls.tab.ControlTab;
|
||||
import binnie.craftgui.controls.tab.ControlTabBar;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.controls.listbox.ControlListBox;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import java.util.Collection;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.controls.ControlTextEdit;
|
||||
import binnie.craftgui.minecraft.MinecraftGUI;
|
||||
import binnie.craftgui.minecraft.control.ControlHelp;
|
||||
import binnie.craftgui.controls.listbox.ControlTextOption;
|
||||
import binnie.core.util.IValidator;
|
||||
import binnie.craftgui.events.EventTextEdit;
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.page.ControlPage;
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import java.util.HashMap;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.controls.page.ControlPages;
|
||||
import binnie.craftgui.window.Panel;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import java.util.Map;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public abstract class WindowAbstractDatabase extends Window
|
||||
{
|
||||
private float selectionBoxWidth;
|
||||
private final float infoBoxWidth = 144.0f;
|
||||
private final float infoBoxHeight = 176.0f;
|
||||
private final float infoTabWidth = 16.0f;
|
||||
private final float modeTabWidth = 22.0f;
|
||||
private final float searchBoxHeight = 16.0f;
|
||||
private Map<IDatabaseMode, ModeWidgets> modes;
|
||||
boolean isNEI;
|
||||
private BreedingSystem system;
|
||||
private Panel panelInformation;
|
||||
private Panel panelSearch;
|
||||
private ControlPages<IDatabaseMode> modePages;
|
||||
private IAlleleSpecies gotoSpecies;
|
||||
|
||||
public void changeMode(final IDatabaseMode mode) {
|
||||
this.modePages.setValue(mode);
|
||||
}
|
||||
|
||||
public WindowAbstractDatabase(final EntityPlayer player, final Side side, final boolean nei, final BreedingSystem system, final float wid) {
|
||||
super(100.0f, 192.0f, player, null, side);
|
||||
this.selectionBoxWidth = 95.0f;
|
||||
this.modes = new HashMap<IDatabaseMode, ModeWidgets>();
|
||||
this.panelInformation = null;
|
||||
this.panelSearch = null;
|
||||
this.modePages = null;
|
||||
this.gotoSpecies = null;
|
||||
this.isNEI = nei;
|
||||
this.system = system;
|
||||
this.selectionBoxWidth = wid;
|
||||
}
|
||||
|
||||
public ControlPages<DatabaseTab> getInfoPages(final IDatabaseMode mode) {
|
||||
return this.modes.get(mode).infoPages;
|
||||
}
|
||||
|
||||
public boolean isNEI() {
|
||||
return this.isNEI;
|
||||
}
|
||||
|
||||
public BreedingSystem getBreedingSystem() {
|
||||
return this.system;
|
||||
}
|
||||
|
||||
public WindowAbstractDatabase(final EntityPlayer player, final Side side, final boolean nei, final BreedingSystem system) {
|
||||
this(player, side, nei, system, 95.0f);
|
||||
}
|
||||
|
||||
protected ModeWidgets createMode(final IDatabaseMode mode, final ModeWidgets widgets) {
|
||||
this.modes.put(mode, widgets);
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setSize(new IPoint(176.0f + this.selectionBoxWidth + 22.0f + 8.0f, 208.0f));
|
||||
this.addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
if (event.getOrigin().getParent() instanceof ControlPage && !(event.getValue() instanceof DatabaseTab)) {
|
||||
final ControlPage parent = (ControlPage) event.getOrigin().getParent();
|
||||
if (parent.getValue() instanceof IDatabaseMode) {
|
||||
for (final IWidget widget : parent.getWidgets()) {
|
||||
if (widget instanceof ControlPages) {
|
||||
if (event.getValue() == null) {
|
||||
widget.hide();
|
||||
}
|
||||
else {
|
||||
widget.show();
|
||||
for (final IWidget widget2 : widget.getWidgets()) {
|
||||
if (widget2 instanceof PageAbstract) {
|
||||
((PageAbstract) widget2).onValueChanged(event.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.addEventHandler(new EventTextEdit.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventTextEdit event) {
|
||||
for (final ModeWidgets widgets : WindowAbstractDatabase.this.modes.values()) {
|
||||
widgets.listBox.setValidator(new IValidator<IWidget>() {
|
||||
@Override
|
||||
public boolean isValid(final IWidget object) {
|
||||
return event.getValue() == "" || ((ControlTextOption) object).getText().toLowerCase().contains(event.getValue().toLowerCase());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, this));
|
||||
new ControlHelp(this, 4.0f, 4.0f);
|
||||
(this.panelInformation = new Panel(this, 24.0f, 24.0f, 144.0f, 176.0f, MinecraftGUI.PanelType.Black)).setColour(860416);
|
||||
(this.panelSearch = new Panel(this, 176.0f, 24.0f, this.selectionBoxWidth, 160.0f, MinecraftGUI.PanelType.Black)).setColour(860416);
|
||||
this.modePages = new ControlPages<IDatabaseMode>(this, 0.0f, 0.0f, this.getSize().x(), this.getSize().y());
|
||||
new ControlTextEdit(this, 176.0f, 184.0f, this.selectionBoxWidth, 16.0f);
|
||||
this.createMode(Mode.Species, new ModeWidgets(Mode.Species, this) {
|
||||
@Override
|
||||
public void createListBox(final IArea area) {
|
||||
final GameProfile playerName = WindowAbstractDatabase.this.getUsername();
|
||||
final Collection<IAlleleSpecies> speciesList = this.database.isNEI ? this.database.system.getAllSpecies() : this.database.system.getDiscoveredSpecies(this.database.getWorld(), playerName);
|
||||
(this.listBox = new ControlSpeciesBox(this.modePage, area.x(), area.y(), area.w(), area.h())).setOptions(speciesList);
|
||||
}
|
||||
});
|
||||
this.createMode(Mode.Branches, new ModeWidgets(Mode.Branches, this) {
|
||||
@Override
|
||||
public void createListBox(final IArea area) {
|
||||
final EntityPlayer player = this.database.getPlayer();
|
||||
final GameProfile playerName = WindowAbstractDatabase.this.getUsername();
|
||||
final Collection<IClassification> speciesList = this.database.isNEI ? this.database.system.getAllBranches() : this.database.system.getDiscoveredBranches(this.database.getWorld(), playerName);
|
||||
(this.listBox = new ControlBranchBox(this.modePage, area.x(), area.y(), area.w(), area.h())).setOptions(speciesList);
|
||||
}
|
||||
});
|
||||
this.createMode(Mode.Breeder, new ModeWidgets(Mode.Breeder, this) {
|
||||
@Override
|
||||
public void createListBox(final IArea area) {
|
||||
this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f);
|
||||
}
|
||||
});
|
||||
this.addTabs();
|
||||
final ControlTabBar<IDatabaseMode> tab = new ControlTabBar<IDatabaseMode>(this, 176.0f + this.selectionBoxWidth, 24.0f, 22.0f, 176.0f, Position.Right) {
|
||||
@Override
|
||||
public ControlTab<IDatabaseMode> createTab(final float x, final float y, final float w, final float h, final IDatabaseMode value) {
|
||||
return new ControlTab<IDatabaseMode>(this, x, y, w, h, value) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.value.getName();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
tab.setValues(this.modePages.getValues());
|
||||
CraftGUIUtil.linkWidgets(tab, this.modePages);
|
||||
this.changeMode(Mode.Species);
|
||||
for (final IDatabaseMode mode : this.modes.keySet()) {
|
||||
this.modes.get(mode).infoTabs = new ControlTabBar(this.modes.get(mode).modePage, 8.0f, 24.0f, 16.0f, 176.0f, Position.Left);
|
||||
this.modes.get(mode).infoTabs.setValues(this.modes.get(mode).infoPages.getValues());
|
||||
CraftGUIUtil.linkWidgets(this.modes.get(mode).infoTabs, this.modes.get(mode).infoPages);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseServer() {
|
||||
final IBreedingTracker tracker = this.system.getSpeciesRoot().getBreedingTracker(this.getWorld(), this.getUsername());
|
||||
if (tracker != null) {
|
||||
tracker.synchToPlayer(this.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
protected void addTabs() {
|
||||
}
|
||||
|
||||
public void gotoSpecies(final IAlleleSpecies value) {
|
||||
if (value != null) {
|
||||
this.modePages.setValue(Mode.Species);
|
||||
this.changeMode(Mode.Species);
|
||||
this.modes.get(this.modePages.getValue()).listBox.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void gotoSpeciesDelayed(final IAlleleSpecies species) {
|
||||
this.gotoSpecies = species;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
if (this.gotoSpecies != null) {
|
||||
((WindowAbstractDatabase) this.getSuperParent()).gotoSpecies(this.gotoSpecies);
|
||||
this.gotoSpecies = null;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Mode implements IDatabaseMode
|
||||
{
|
||||
Species,
|
||||
Branches,
|
||||
Breeder;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return BinnieCore.proxy.localise("gui.database.mode." + this.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class ModeWidgets
|
||||
{
|
||||
public WindowAbstractDatabase database;
|
||||
public ControlPage<IDatabaseMode> modePage;
|
||||
private ControlPages<DatabaseTab> infoPages;
|
||||
public ControlListBox listBox;
|
||||
private ControlTabBar<DatabaseTab> infoTabs;
|
||||
|
||||
public ModeWidgets(final IDatabaseMode mode, final WindowAbstractDatabase database) {
|
||||
this.database = database;
|
||||
this.modePage = new ControlPage<IDatabaseMode>(database.modePages, 0.0f, 0.0f, database.getSize().x(), database.getSize().y(), mode);
|
||||
final IArea listBoxArea = database.panelSearch.area().inset(2);
|
||||
this.createListBox(listBoxArea);
|
||||
CraftGUIUtil.alignToWidget(this.listBox, database.panelSearch);
|
||||
CraftGUIUtil.moveWidget(this.listBox, new IPoint(2.0f, 2.0f));
|
||||
CraftGUIUtil.alignToWidget(this.infoPages = new ControlPages<DatabaseTab>(this.modePage, 0.0f, 0.0f, 144.0f, 176.0f), database.panelInformation);
|
||||
}
|
||||
|
||||
public abstract void createListBox(final IArea p0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user