mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-23 21:49:49 +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,298 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.binniecore;
|
||||
|
||||
import binnie.extrabees.gui.punnett.ExtraBeeGUITexture;
|
||||
import binnie.craftgui.resource.minecraft.PaddedTexture;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.resource.StyleSheet;
|
||||
import binnie.genetics.machine.Analyser;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import java.util.List;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.minecraft.InventoryType;
|
||||
import binnie.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.craftgui.minecraft.control.ControlImage;
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import net.minecraft.init.Items;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.AbstractMod;
|
||||
import java.util.HashMap;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import java.util.Map;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.genetics.gui.ControlChromosome;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
import java.util.Random;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public class WindowFieldKit extends Window
|
||||
{
|
||||
private float glassOffsetX;
|
||||
private float glassOffsetY;
|
||||
private float glassVX;
|
||||
private float glassVY;
|
||||
private Random glassRand;
|
||||
private Control GlassControl;
|
||||
private ControlChromosome chromo;
|
||||
private ControlText text;
|
||||
private float analyseProgress;
|
||||
private boolean isAnalysing;
|
||||
private Map<IChromosomeType, String> info;
|
||||
private ItemStack prev;
|
||||
|
||||
public WindowFieldKit(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(280.0f, 230.0f, player, inventory, side);
|
||||
this.glassOffsetX = 0.0f;
|
||||
this.glassOffsetY = 0.0f;
|
||||
this.glassVX = 0.0f;
|
||||
this.glassVY = 0.0f;
|
||||
this.glassRand = new Random();
|
||||
this.analyseProgress = 1.0f;
|
||||
this.isAnalysing = false;
|
||||
this.info = new HashMap<IChromosomeType, String>();
|
||||
this.prev = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return BinnieCore.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "Field Kit";
|
||||
}
|
||||
|
||||
private void setupValidators() {
|
||||
this.getWindowInventory().setValidator(0, new SlotValidator(null) {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack object) {
|
||||
return AlleleManager.alleleRegistry.isIndividual(object) || Binnie.Genetics.getConversion(object) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Individual";
|
||||
}
|
||||
});
|
||||
this.getWindowInventory().setValidator(1, new SlotValidator(null) {
|
||||
@Override
|
||||
public boolean isValid(final ItemStack object) {
|
||||
return object.getItem() == Items.paper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Paper";
|
||||
}
|
||||
});
|
||||
this.getWindowInventory().disableAutoDispense(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle("Field Kit");
|
||||
CraftGUI.Render.stylesheet(new StyleSheetPunnett());
|
||||
this.getWindowInventory().createSlot(0);
|
||||
this.getWindowInventory().createSlot(1);
|
||||
this.setupValidators();
|
||||
new ControlPlayerInventory(this);
|
||||
final IPoint handGlass = new IPoint(16.0f, 32.0f);
|
||||
this.GlassControl = new ControlImage(this, handGlass.x(), handGlass.y(), new StandardTexture(0, 160, 96, 96, ExtraBeeTexture.GUIPunnett));
|
||||
new ControlSlot(this, handGlass.x() + 54.0f, handGlass.y() + 26.0f).assign(InventoryType.Window, 0);
|
||||
new ControlSlot(this, 208.0f, 8.0f).assign(InventoryType.Window, 1);
|
||||
(this.text = new ControlText(this, new IPoint(232.0f, 13.0f), "Paper")).setColour(2236962);
|
||||
(this.text = new ControlText(this, new IArea(0.0f, 120.0f, this.w(), 24.0f), "", TextJustification.MiddleCenter)).setColour(2236962);
|
||||
this.chromo = new ControlChromosome(this, 150.0f, 24.0f);
|
||||
this.addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
final IChromosomeType type = (IChromosomeType) event.getValue();
|
||||
if (type != null && WindowFieldKit.this.info.containsKey(type)) {
|
||||
final String t = WindowFieldKit.this.info.get(type);
|
||||
WindowFieldKit.this.text.setValue(t);
|
||||
}
|
||||
else {
|
||||
WindowFieldKit.this.text.setValue("");
|
||||
}
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, this.chromo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseServer() {
|
||||
final ItemStack kit = this.getPlayer().getHeldItem();
|
||||
final int sheets = 64 - kit.getItemDamage();
|
||||
if (sheets != 0) {
|
||||
this.getWindowInventory().setInventorySlotContents(1, new ItemStack(Items.paper, sheets));
|
||||
}
|
||||
this.setupValidators();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
if (this.isAnalysing) {
|
||||
this.analyseProgress += 0.01f;
|
||||
if (this.analyseProgress >= 1.0f) {
|
||||
this.isAnalysing = false;
|
||||
this.analyseProgress = 1.0f;
|
||||
final ItemStack stack = this.getWindowInventory().getStackInSlot(0);
|
||||
if (stack != null) {
|
||||
this.sendClientAction("analyse", new NBTTagCompound());
|
||||
}
|
||||
this.refreshSpecies();
|
||||
}
|
||||
}
|
||||
this.glassVX += this.glassRand.nextFloat() - 0.5f - this.glassOffsetX * 0.2f;
|
||||
this.glassVY += this.glassRand.nextFloat() - 0.5f - this.glassOffsetY * 0.2f;
|
||||
this.glassOffsetX += this.glassVX;
|
||||
this.glassOffsetX *= 1.0f - this.analyseProgress;
|
||||
this.glassOffsetY += this.glassVY;
|
||||
this.glassOffsetY *= 1.0f - this.analyseProgress;
|
||||
this.GlassControl.setOffset(new IPoint(this.glassOffsetX, this.glassOffsetY));
|
||||
}
|
||||
|
||||
private void refreshSpecies() {
|
||||
final ItemStack item = this.getWindowInventory().getStackInSlot(0);
|
||||
if (item == null || !AlleleManager.alleleRegistry.isIndividual(item)) {
|
||||
return;
|
||||
}
|
||||
final IIndividual ind = AlleleManager.alleleRegistry.getIndividual(item);
|
||||
if (ind == null) {
|
||||
return;
|
||||
}
|
||||
final ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(item);
|
||||
this.chromo.setRoot(root);
|
||||
final Random rand = new Random();
|
||||
this.info.clear();
|
||||
for (final IChromosomeType type : root.getKaryotype()) {
|
||||
if (!Binnie.Genetics.isInvalidChromosome(type)) {
|
||||
final IAllele allele = ind.getGenome().getActiveAllele(type);
|
||||
final List<String> infos = new ArrayList<String>();
|
||||
int i = 0;
|
||||
for (String pref = root.getUID() + ".fieldkit." + type.getName().toLowerCase() + "."; Binnie.Language.canLocalise(pref + i); ++i) {
|
||||
infos.add(Binnie.Language.localise(pref + i));
|
||||
}
|
||||
String text = Binnie.Genetics.getSystem(root).getAlleleName(type, allele);
|
||||
if (!infos.isEmpty()) {
|
||||
text = infos.get(rand.nextInt(infos.size()));
|
||||
}
|
||||
this.info.put(type, text);
|
||||
this.chromo.setRoot(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowInventoryChanged() {
|
||||
super.onWindowInventoryChanged();
|
||||
if (this.isServer()) {
|
||||
final ItemStack kit = this.getPlayer().getHeldItem();
|
||||
final int sheets = 64 - kit.getItemDamage();
|
||||
final int size = (this.getWindowInventory().getStackInSlot(1) == null) ? 0 : this.getWindowInventory().getStackInSlot(1).stackSize;
|
||||
if (sheets != size) {
|
||||
kit.setItemDamage(64 - size);
|
||||
}
|
||||
((EntityPlayerMP) this.getPlayer()).updateHeldItem();
|
||||
}
|
||||
if (this.isClient()) {
|
||||
final ItemStack item = this.getWindowInventory().getStackInSlot(0);
|
||||
this.prev = item;
|
||||
this.text.setValue("");
|
||||
if (item != null && !Analyser.isAnalysed(item)) {
|
||||
if (this.getWindowInventory().getStackInSlot(1) == null) {
|
||||
this.text.setValue("No Paper!");
|
||||
this.isAnalysing = false;
|
||||
this.analyseProgress = 1.0f;
|
||||
}
|
||||
else {
|
||||
this.startAnalysing();
|
||||
this.chromo.setRoot(null);
|
||||
if (this.damageKit()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item != null) {
|
||||
this.isAnalysing = false;
|
||||
this.analyseProgress = 1.0f;
|
||||
this.refreshSpecies();
|
||||
if (this.damageKit()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.isAnalysing = false;
|
||||
this.analyseProgress = 1.0f;
|
||||
this.chromo.setRoot(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean damageKit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void startAnalysing() {
|
||||
this.glassVX = 0.0f;
|
||||
this.glassVY = 0.0f;
|
||||
this.glassOffsetX = 0.0f;
|
||||
this.glassOffsetY = 0.0f;
|
||||
this.isAnalysing = true;
|
||||
this.analyseProgress = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showHelpButton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String showInfoButton() {
|
||||
return "The Field Kit analyses bees, trees, flowers and butterflies. All that is required is a piece of paper to jot notes";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound action) {
|
||||
super.recieveGuiNBT(side, player, name, action);
|
||||
if (side == Side.SERVER && name.equals("analyse")) {
|
||||
this.getWindowInventory().setInventorySlotContents(0, Analyser.analyse(this.getWindowInventory().getStackInSlot(0)));
|
||||
this.getWindowInventory().decrStackSize(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
this.textures.put(CraftGUITexture.HelpButton, new StandardTexture(178, 0, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
|
||||
this.textures.put(CraftGUITexture.InfoButton, new StandardTexture(178, 16, 16, 16, 0, ExtraBeeTexture.GUIPunnett));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.binniecore;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.controls.listbox.ControlTextOption;
|
||||
import binnie.genetics.gui.ControlGenesisOption;
|
||||
import binnie.craftgui.minecraft.MinecraftGUI;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.craftgui.minecraft.control.ControlTabIcon;
|
||||
import binnie.craftgui.controls.tab.ControlTab;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.craftgui.controls.tab.ControlTabBar;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.AbstractMod;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.craftgui.window.Panel;
|
||||
import binnie.core.genetics.Gene;
|
||||
import binnie.craftgui.controls.listbox.ControlListBox;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public class WindowGenesis extends Window
|
||||
{
|
||||
private ISpeciesRoot root;
|
||||
private IAllele[] template;
|
||||
private ControlListBox<Gene> geneList;
|
||||
private ControlListBox<Gene> geneOptions;
|
||||
private Panel panelPickup;
|
||||
|
||||
public WindowGenesis(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(342.0f, 228.0f, player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return BinnieCore.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "Genesis";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
new ControlPlayerInventory(this);
|
||||
this.setTitle("Genesis");
|
||||
final ControlTabBar<BreedingSystem> tabSystems = new ControlTabBar<BreedingSystem>(this, 8.0f, 28.0f, 23.0f, 100.0f, Position.Left) {
|
||||
@Override
|
||||
public ControlTab<BreedingSystem> createTab(final float x, final float y, final float w, final float h, final BreedingSystem value) {
|
||||
return new ControlTabIcon<BreedingSystem>(this, x, y, w, h, value) {
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
final int type = this.value.getDefaultType();
|
||||
final IIndividual ind = this.value.getDefaultIndividual();
|
||||
return this.value.getSpeciesRoot().getMemberStack(ind, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.value.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOutlineColour() {
|
||||
return this.value.getColour();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOutline() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
tabSystems.setValues(Binnie.Genetics.getActiveSystems());
|
||||
this.root = Binnie.Genetics.getActiveSystems().iterator().next().getSpeciesRoot();
|
||||
this.template = this.root.getDefaultTemplate();
|
||||
final IArea one = new IArea(32.0f, 28.0f, 170.0f, 100.0f);
|
||||
final IArea two = new IArea(214.0f, 28.0f, 100.0f, 100.0f);
|
||||
new Panel(this, one.outset(1), MinecraftGUI.PanelType.Black);
|
||||
new Panel(this, two.outset(1), MinecraftGUI.PanelType.Black);
|
||||
this.geneList = new ControlListBox<Gene>(this, one.x(), one.y(), one.w(), one.h(), 10.0f) {
|
||||
@Override
|
||||
public IWidget createOption(final Gene value, final int y) {
|
||||
return new ControlGenesisOption(this.getContent(), value, y);
|
||||
}
|
||||
};
|
||||
this.geneOptions = new ControlListBox<Gene>(this, two.x(), two.y(), two.w(), two.h(), 10.0f) {
|
||||
@Override
|
||||
public IWidget createOption(final Gene value, final int y) {
|
||||
return new ControlTextOption<Gene>(this.getContent(), value, y);
|
||||
}
|
||||
};
|
||||
tabSystems.addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
WindowGenesis.this.root = ((BreedingSystem) event.getValue()).getSpeciesRoot();
|
||||
WindowGenesis.this.template = WindowGenesis.this.root.getDefaultTemplate();
|
||||
WindowGenesis.this.refreshTemplate(null);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, tabSystems));
|
||||
this.geneList.addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
final Map<IChromosomeType, List<IAllele>> map = Binnie.Genetics.getChromosomeMap(WindowGenesis.this.root);
|
||||
final List<Gene> opts = new ArrayList<Gene>();
|
||||
final IChromosomeType chromo = ((Gene) event.value) != null ? ((Gene) event.value).getChromosome() : null;
|
||||
if (chromo != null)// fix NPE
|
||||
for (final IAllele allele : map.get(chromo)) {
|
||||
opts.add(new Gene(allele, chromo, WindowGenesis.this.root));
|
||||
}
|
||||
WindowGenesis.this.geneOptions.setOptions(opts);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this.geneList));
|
||||
this.geneOptions.addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
if (event.value == null) {
|
||||
return;
|
||||
}
|
||||
final IChromosomeType chromo = ((Gene) event.value).getChromosome();
|
||||
WindowGenesis.this.template[chromo.ordinal()] = ((Gene) event.value).getAllele();
|
||||
if (chromo == ((Gene) event.value).getSpeciesRoot().getKaryotypeKey()) {
|
||||
WindowGenesis.this.template = ((Gene) event.value).getSpeciesRoot().getTemplate(((Gene) event.value).getAllele().getUID());
|
||||
}
|
||||
WindowGenesis.this.refreshTemplate(chromo);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this.geneOptions));
|
||||
this.panelPickup = new Panel(this, 16.0f, 140.0f, 60.0f, 42.0f, MinecraftGUI.PanelType.Black);
|
||||
this.refreshTemplate(null);
|
||||
}
|
||||
|
||||
private void refreshTemplate(final IChromosomeType selection) {
|
||||
final List<Gene> genes = new ArrayList<Gene>();
|
||||
final IChromosomeType[] arr$;
|
||||
final IChromosomeType[] chromos = arr$ = Binnie.Genetics.getChromosomeMap(this.root).keySet().toArray(new IChromosomeType[0]);
|
||||
for (final IChromosomeType type : arr$) {
|
||||
final IAllele allele = this.template[type.ordinal()];
|
||||
if (allele == null) {
|
||||
throw new NullPointerException("Allele missing for Chromosome " + type.getName());
|
||||
}
|
||||
genes.add(new Gene(allele, type, this.root));
|
||||
}
|
||||
final Map<IChromosomeType, List<IAllele>> map = Binnie.Genetics.getChromosomeMap(this.root);
|
||||
this.geneList.setOptions(genes);
|
||||
if (selection != null) {
|
||||
this.geneList.setValue(new Gene(this.template[selection.ordinal()], selection, this.root));
|
||||
}
|
||||
else {
|
||||
this.geneOptions.setOptions(new ArrayList<Gene>());
|
||||
}
|
||||
this.refreshPickup();
|
||||
}
|
||||
|
||||
private void refreshPickup() {
|
||||
this.panelPickup.deleteAllChildren();
|
||||
int i = 0;
|
||||
for (final int type : Binnie.Genetics.getSystem(this.root).getActiveTypes()) {
|
||||
final IIndividual ind = this.root.templateAsIndividual(this.template);
|
||||
ind.analyze();
|
||||
final ItemStack stack = this.root.getMemberStack(ind, type);
|
||||
final ControlItemDisplay display = new ControlItemDisplay(this.panelPickup, 4 + i % 3 * 18, 4 + i / 3 * 18);
|
||||
display.setItemStack(stack);
|
||||
display.setTooltip();
|
||||
display.addEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
stack.writeToNBT(nbt);
|
||||
Window.get(event.getOrigin()).sendClientAction("genesis", nbt);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, display));
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound action) {
|
||||
super.recieveGuiNBT(side, player, name, action);
|
||||
if (side == Side.SERVER && name.equals("genesis")) {
|
||||
final ItemStack stack = ItemStack.loadItemStackFromNBT(action);
|
||||
final InventoryPlayer playerInv = player.inventory;
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
if (playerInv.getItemStack() == null) {
|
||||
playerInv.setItemStack(stack);
|
||||
}
|
||||
else if (playerInv.getItemStack().isItemEqual(stack) && ItemStack.areItemStackTagsEqual(playerInv.getItemStack(), stack)) {
|
||||
final int fit = stack.getMaxStackSize() - (stack.stackSize + playerInv.getItemStack().stackSize);
|
||||
if (fit >= 0) {
|
||||
final ItemStack itemStack;
|
||||
final ItemStack rec = itemStack = stack;
|
||||
itemStack.stackSize += playerInv.getItemStack().stackSize;
|
||||
playerInv.setItemStack(rec);
|
||||
}
|
||||
}
|
||||
player.openContainer.detectAndSendChanges();
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) player).updateHeldItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.botany;
|
||||
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlColourDisplay extends Control implements IControlValue<IFlowerColour>, ITooltip
|
||||
{
|
||||
IFlowerColour value;
|
||||
|
||||
public ControlColourDisplay(final IWidget parent, final float x, final float y) {
|
||||
super(parent, x, y, 16.0f, 16.0f);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColour getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final IFlowerColour value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.solid(this.getArea(), -1);
|
||||
CraftGUI.Render.solid(this.getArea().inset(1), -16777216 + this.getValue().getColor(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
super.getTooltip(tooltip);
|
||||
tooltip.add(this.value.getName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.botany;
|
||||
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.craftgui.controls.listbox.ControlListBox;
|
||||
|
||||
public class ControlColourMixBox extends ControlListBox<IColourMix>
|
||||
{
|
||||
private int index;
|
||||
private Type type;
|
||||
|
||||
@Override
|
||||
public IWidget createOption(final IColourMix value, final int y) {
|
||||
return new ControlColourMixItem(((ControlScrollableContent<ControlList<IColourMix>>) this).getContent(), value, y);
|
||||
}
|
||||
|
||||
public ControlColourMixBox(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.type = type;
|
||||
}
|
||||
|
||||
enum Type
|
||||
{
|
||||
Resultant,
|
||||
Further;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.botany;
|
||||
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.craftgui.mod.database.WindowAbstractDatabase;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.craftgui.controls.listbox.ControlOption;
|
||||
|
||||
public class ControlColourMixItem extends ControlOption<IColourMix>
|
||||
{
|
||||
ControlColourDisplay itemWidget1;
|
||||
ControlColourDisplay itemWidget2;
|
||||
ControlColourDisplay itemWidget3;
|
||||
ControlColourMixSymbol addSymbol;
|
||||
ControlColourMixSymbol arrowSymbol;
|
||||
|
||||
public ControlColourMixItem(final ControlList<IColourMix> controlList, final IColourMix option, final int y) {
|
||||
super(controlList, option, y);
|
||||
this.itemWidget1 = new ControlColourDisplay(this, 4.0f, 4.0f);
|
||||
this.itemWidget2 = new ControlColourDisplay(this, 44.0f, 4.0f);
|
||||
this.itemWidget3 = new ControlColourDisplay(this, 104.0f, 4.0f);
|
||||
this.addSymbol = new ControlColourMixSymbol(this, 24, 4, 0);
|
||||
this.arrowSymbol = new ControlColourMixSymbol(this, 64, 4, 1);
|
||||
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
|
||||
if (this.getValue() != null) {
|
||||
this.itemWidget1.setValue(this.getValue().getColour1());
|
||||
this.itemWidget2.setValue(this.getValue().getColour2());
|
||||
this.itemWidget3.setValue(this.getValue().getResult());
|
||||
this.addSymbol.setValue(this.getValue());
|
||||
this.arrowSymbol.setValue(this.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.botany;
|
||||
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITextureSheet;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlColourMixSymbol extends Control implements ITooltip
|
||||
{
|
||||
static Texture MutationPlus;
|
||||
static Texture MutationArrow;
|
||||
IColourMix value;
|
||||
int type;
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
super.onRenderBackground();
|
||||
if (this.type == 0) {
|
||||
CraftGUI.Render.texture(ControlColourMixSymbol.MutationPlus, IPoint.ZERO);
|
||||
}
|
||||
else {
|
||||
CraftGUI.Render.texture(ControlColourMixSymbol.MutationArrow, IPoint.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
protected ControlColourMixSymbol(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 IColourMix value) {
|
||||
this.value = value;
|
||||
this.setColour(16777215);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
if (this.type == 1) {
|
||||
final float chance = this.value.getChance();
|
||||
tooltip.add("Current Chance - " + chance + "%");
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
ControlColourMixSymbol.MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
|
||||
ControlColourMixSymbol.MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.botany;
|
||||
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.geometry.CraftGUIUtil;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.craftgui.controls.listbox.ControlTextOption;
|
||||
|
||||
public class ControlColourOption extends ControlTextOption<IFlowerColour>
|
||||
{
|
||||
ControlColourDisplay controlBee;
|
||||
IPoint boxPosition;
|
||||
|
||||
public ControlColourOption(final ControlList<IFlowerColour> controlList, final IFlowerColour option, final int y) {
|
||||
super(controlList, option, option.getName(), y);
|
||||
this.setSize(new IPoint(this.getSize().x(), 20.0f));
|
||||
(this.controlBee = new ControlColourDisplay(this, 2.0f, 2.0f)).setValue(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.boxPosition = new IPoint(2.0f, (height - 18) / 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.botany;
|
||||
|
||||
import java.util.List;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.api.IColourMix;
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.craftgui.mod.database.PageAbstract;
|
||||
|
||||
public class PageColourMix extends PageAbstract<IFlowerColour>
|
||||
{
|
||||
ControlText pageSpeciesFurther_Title;
|
||||
ControlColourMixBox pageSpeciesFurther_List;
|
||||
|
||||
public PageColourMix(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8.0f, "Further Mixes");
|
||||
this.pageSpeciesFurther_List = new ControlColourMixBox(this, 4, 20, 136, 152, ControlColourMixBox.Type.Further);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IFlowerColour colour) {
|
||||
final List<IColourMix> mixes = new ArrayList<IColourMix>();
|
||||
for (final IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
|
||||
if (mix.getColour1() == colour || mix.getColour2() == colour) {
|
||||
mixes.add(mix);
|
||||
}
|
||||
}
|
||||
this.pageSpeciesFurther_List.setOptions(mixes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.botany;
|
||||
|
||||
import java.util.List;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.api.IColourMix;
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.craftgui.mod.database.PageAbstract;
|
||||
|
||||
public class PageColourMixResultant extends PageAbstract<IFlowerColour>
|
||||
{
|
||||
ControlText pageSpeciesFurther_Title;
|
||||
ControlColourMixBox pageSpeciesFurther_List;
|
||||
|
||||
public PageColourMixResultant(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8.0f, "Resultant Mixes");
|
||||
this.pageSpeciesFurther_List = new ControlColourMixBox(this, 4, 20, 136, 152, ControlColourMixBox.Type.Resultant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IFlowerColour colour) {
|
||||
final List<IColourMix> mixes = new ArrayList<IColourMix>();
|
||||
for (final IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
|
||||
if (mix.getResult() == colour) {
|
||||
mixes.add(mix);
|
||||
}
|
||||
}
|
||||
this.pageSpeciesFurther_List.setOptions(mixes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.botany;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.botany.api.IAlleleFlowerSpecies;
|
||||
import binnie.botany.api.IFlowerGenome;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.IFlower;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.mod.database.PageSpecies;
|
||||
|
||||
public class PageSpeciesFlowerGenome extends PageSpecies
|
||||
{
|
||||
public PageSpeciesFlowerGenome(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
this.deleteAllChildren();
|
||||
final IAllele[] template = Binnie.Genetics.getFlowerRoot().getTemplate(species.getUID());
|
||||
if (template == null) {
|
||||
return;
|
||||
}
|
||||
final IFlower tree = Binnie.Genetics.getFlowerRoot().templateAsIndividual(template);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
final IFlowerGenome genome = tree.getGenome();
|
||||
final IAlleleFlowerSpecies treeSpecies = genome.getPrimary();
|
||||
final int w = 144;
|
||||
final int h = 176;
|
||||
new ControlText(this, new IArea(0.0f, 4.0f, w, 16.0f), "Genome", TextJustification.MiddleCenter);
|
||||
final ControlScrollableContent scrollable = new ControlScrollableContent(this, 4.0f, 20.0f, w - 8, h - 8 - 16, 12.0f);
|
||||
final Control contents = new Control(scrollable, 0.0f, 0.0f, w - 8 - 12, h - 8 - 16);
|
||||
final int tw = w - 8 - 12;
|
||||
final int w2 = 55;
|
||||
final int w3 = tw - 50;
|
||||
int y = 0;
|
||||
final int th = 14;
|
||||
final int th2 = 18;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), "Temp. : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), "Moist. : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), Binnie.Language.localise(treeSpecies.getMoisture()), TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), "pH. : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), Binnie.Language.localise(treeSpecies.getPH()), TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), "Fertility : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
final float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), "Lifespan : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), "" + String.format("%.2f", lifespan) + " days", TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), "Nectar : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
int x = w2;
|
||||
int tot = 0;
|
||||
for (final IIndividual vid : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
|
||||
if (vid.getGenome().getPrimary() == treeSpecies) {
|
||||
if (tot > 0 && tot % 3 == 0) {
|
||||
x -= 54;
|
||||
y += 18;
|
||||
}
|
||||
final ItemStack stack = BotanyCore.getFlowerRoot().getMemberStack(vid, EnumFlowerStage.FLOWER.ordinal());
|
||||
final ControlItemDisplay display = new ControlItemDisplay(contents, x, y);
|
||||
display.setItemStack(stack);
|
||||
++tot;
|
||||
x += 18;
|
||||
}
|
||||
}
|
||||
final int numOfLines = 1 + (tot - 1) / 3;
|
||||
new ControlText(contents, new IArea(0.0f, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), "Varieties : ", TextJustification.MiddleRight);
|
||||
y += th;
|
||||
contents.setSize(new IPoint(contents.size().x(), y));
|
||||
scrollable.setScrollableContent(contents);
|
||||
}
|
||||
|
||||
public static String tolerated(final boolean t) {
|
||||
if (t) {
|
||||
return "Tolerated";
|
||||
}
|
||||
return "Not Tolerated";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.botany;
|
||||
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import binnie.craftgui.mod.database.PageBreeder;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.mod.database.PageBranchSpecies;
|
||||
import binnie.craftgui.mod.database.PageBranchOverview;
|
||||
import binnie.craftgui.mod.database.PageSpeciesMutations;
|
||||
import binnie.craftgui.mod.database.PageSpeciesResultant;
|
||||
import binnie.craftgui.mod.database.PageSpeciesClassification;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.craftgui.mod.database.IDatabaseMode;
|
||||
import binnie.craftgui.mod.database.PageSpeciesOverview;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.Binnie;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.craftgui.controls.listbox.ControlListBox;
|
||||
import binnie.craftgui.mod.database.WindowAbstractDatabase;
|
||||
|
||||
public class WindowBotanistDatabase extends WindowAbstractDatabase
|
||||
{
|
||||
ControlListBox<EnumFlowerColor> selectionBoxColors;
|
||||
|
||||
public WindowBotanistDatabase(final EntityPlayer player, final Side side, final boolean nei) {
|
||||
super(player, side, nei, Binnie.Genetics.flowerBreedingSystem, 130.0f);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final Side side, final boolean nei) {
|
||||
return new WindowBotanistDatabase(player, side, nei);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTabs() {
|
||||
new PageSpeciesOverview(this.getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.overview", 0));
|
||||
new PageSpeciesFlowerGenome(this.getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.genome", 0));
|
||||
new PageSpeciesClassification(this.getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.classification", 0));
|
||||
new PageSpeciesResultant(this.getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.resultant", 0));
|
||||
new PageSpeciesMutations(this.getInfoPages(Mode.Species), new DatabaseTab(Botany.instance, "species.further", 0));
|
||||
new PageBranchOverview(this.getInfoPages(Mode.Branches), new DatabaseTab(Botany.instance, "branches.overview", 0));
|
||||
new PageBranchSpecies(this.getInfoPages(Mode.Branches), new DatabaseTab(Botany.instance, "branches.species", 0));
|
||||
this.createMode(FlowerMode.Colour, new ModeWidgets(FlowerMode.Colour, this) {
|
||||
@Override
|
||||
public void createListBox(final IArea area) {
|
||||
this.listBox = new ControlListBox<IFlowerColour>(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) {
|
||||
@Override
|
||||
public IWidget createOption(final IFlowerColour value, final int y) {
|
||||
return new ControlColourOption(((ControlScrollableContent<ControlList<IFlowerColour>>) this).getContent(), value, y);
|
||||
}
|
||||
};
|
||||
final List<IFlowerColour> colors = new ArrayList<IFlowerColour>();
|
||||
for (final IFlowerColour c : EnumFlowerColor.values()) {
|
||||
colors.add(c);
|
||||
}
|
||||
this.listBox.setOptions(colors);
|
||||
}
|
||||
});
|
||||
new PageColourMixResultant(this.getInfoPages(FlowerMode.Colour), new DatabaseTab(Botany.instance, "colour.resultant", 0));
|
||||
new PageColourMix(this.getInfoPages(FlowerMode.Colour), new DatabaseTab(Botany.instance, "colour.further", 0));
|
||||
new PageBreeder(this.getInfoPages(Mode.Breeder), this.getUsername(), new DatabaseTab(Botany.instance, "breeder", 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return Botany.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "FlowerDatabase";
|
||||
}
|
||||
|
||||
enum FlowerMode implements IDatabaseMode
|
||||
{
|
||||
Colour;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Botany.proxy.localise("gui.database.mode." + this.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls;
|
||||
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlCheckbox extends Control implements IControlValue<Boolean>
|
||||
{
|
||||
boolean value;
|
||||
String text;
|
||||
|
||||
public ControlCheckbox(final IWidget parent, final float x, final float y, final boolean bool) {
|
||||
this(parent, x, y, 0.0f, "", bool);
|
||||
}
|
||||
|
||||
public ControlCheckbox(final IWidget parent, final float x, final float y, final float w, final String text, final boolean bool) {
|
||||
super(parent, x, y, (w > 16.0f) ? w : 16.0f, 16.0f);
|
||||
this.text = text;
|
||||
this.value = bool;
|
||||
if (w > 16.0f) {
|
||||
new ControlText(this, new IArea(16.0f, 1.0f, w - 16.0f, 16.0f), text, TextJustification.MiddleCenter).setColour(4473924);
|
||||
}
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.addEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
ControlCheckbox.this.toggleValue();
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
|
||||
protected void onValueChanged(final boolean value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final Boolean value) {
|
||||
this.value = value;
|
||||
this.onValueChanged(value);
|
||||
this.callEvent(new EventValueChanged<Object>(this, value));
|
||||
}
|
||||
|
||||
public void toggleValue() {
|
||||
this.setValue(Boolean.valueOf(!this.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
Object texture = this.getValue() ? CraftGUITexture.CheckboxChecked : CraftGUITexture.Checkbox;
|
||||
if (this.isMouseOver()) {
|
||||
texture = (this.getValue() ? CraftGUITexture.CheckboxCheckedHighlighted : CraftGUITexture.CheckboxHighlighted);
|
||||
}
|
||||
CraftGUI.Render.texture(texture, IPoint.ZERO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls;
|
||||
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlText extends Control implements IControlValue<String>
|
||||
{
|
||||
private String text;
|
||||
private TextJustification align;
|
||||
|
||||
public ControlText(final IWidget parent, final IPoint pos, final String text) {
|
||||
this(parent, new IArea(pos, new IPoint(500.0f, 0.0f)), text, TextJustification.TopLeft);
|
||||
}
|
||||
|
||||
public ControlText(final IWidget parent, final String text, final TextJustification align) {
|
||||
this(parent, parent.getArea(), text, align);
|
||||
}
|
||||
|
||||
public ControlText(final IWidget parent, final IArea area, final String text, final TextJustification align) {
|
||||
super(parent, area.pos().x(), area.pos().y(), area.size().x(), area.size().y());
|
||||
this.setValue(text);
|
||||
this.align = align;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.text(this.getArea(), this.align, this.text, this.getColour());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return this.text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls;
|
||||
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class ControlTextCentered extends ControlText
|
||||
{
|
||||
public ControlTextCentered(final IWidget parent, final float y, final String text) {
|
||||
super(parent, new IArea(new IPoint(0.0f, y), new IPoint(parent.size().x(), 0.0f)), text, TextJustification.TopCenter);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls;
|
||||
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import binnie.craftgui.events.EventTextEdit;
|
||||
import binnie.craftgui.events.EventKey;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlTextEdit extends Control implements IControlValue<String>
|
||||
{
|
||||
GuiTextField field;
|
||||
private String cachedValue;
|
||||
|
||||
public ControlTextEdit(final IWidget parent, final float x, final float y, final float width, final float height) {
|
||||
super(parent, x, y, width, height);
|
||||
this.cachedValue = "";
|
||||
this.field = new GuiTextField(this.getWindow().getGui().getFontRenderer(), 0, 0, 10, 10);
|
||||
this.addAttribute(Attribute.CanFocus);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.field.setEnableBackgroundDrawing(false);
|
||||
this.addEventHandler(new EventKey.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventKey.Down event) {
|
||||
ControlTextEdit.this.field.textboxKeyTyped(event.getCharacter(), event.getKey());
|
||||
final String text = ControlTextEdit.this.getValue();
|
||||
if (!text.equals(ControlTextEdit.this.cachedValue)) {
|
||||
ControlTextEdit.this.cachedValue = text;
|
||||
ControlTextEdit.this.callEvent(new EventTextEdit(ControlTextEdit.this, ControlTextEdit.this.cachedValue));
|
||||
ControlTextEdit.this.onTextEdit(ControlTextEdit.this.cachedValue);
|
||||
}
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
this.addEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
ControlTextEdit.this.field.mouseClicked((int) ControlTextEdit.this.getRelativeMousePosition().x(), (int) ControlTextEdit.this.getRelativeMousePosition().y(), event.getButton());
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
this.addEventHandler(new EventWidget.GainFocus.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.GainFocus event) {
|
||||
ControlTextEdit.this.field.setFocused(true);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
this.addEventHandler(new EventWidget.LoseFocus.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.LoseFocus event) {
|
||||
ControlTextEdit.this.field.setFocused(false);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return (this.field.getText() == null) ? "" : this.field.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final String value) {
|
||||
if (!this.getValue().equals(value)) {
|
||||
this.field.setText(value);
|
||||
this.field.setCursorPosition(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
}
|
||||
|
||||
protected void onTextEdit(final String value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.texture(CraftGUITexture.Slot, this.getArea());
|
||||
this.renderTextField();
|
||||
}
|
||||
|
||||
protected void renderTextField() {
|
||||
this.field.width = (int) this.w();
|
||||
this.field.height = (int) this.h();
|
||||
this.field.xPosition = (int) ((this.h() - 8.0f) / 2.0f);
|
||||
this.field.yPosition = (int) ((this.h() - 8.0f) / 2.0f);
|
||||
this.field.drawTextBox();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls;
|
||||
|
||||
public interface IControlSelection<T>
|
||||
{
|
||||
T getSelectedValue();
|
||||
|
||||
void setSelectedValue(final T p0);
|
||||
|
||||
boolean isSelected(final IControlSelectionOption<T> p0);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls;
|
||||
|
||||
public interface IControlSelectionOption<T>
|
||||
{
|
||||
T getValue();
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.button;
|
||||
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import binnie.craftgui.events.EventButtonClicked;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlButton extends Control
|
||||
{
|
||||
private ControlText textWidget;
|
||||
private String text;
|
||||
|
||||
public ControlButton(final IWidget parent, final float x, final float y, final float width, final float height) {
|
||||
super(parent, x, y, width, height);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.addEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
ControlButton.this.callEvent(new EventButtonClicked(ControlButton.this.getWidget()));
|
||||
ControlButton.this.onMouseClick(event);
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
|
||||
protected void onMouseClick(final EventMouse.Down event) {
|
||||
}
|
||||
|
||||
public ControlButton(final IWidget parent, final float x, final float y, final float width, final float height, final String text) {
|
||||
this(parent, x, y, width, height);
|
||||
this.text = text;
|
||||
this.textWidget = new ControlText(this, this.getArea(), text, TextJustification.MiddleCenter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
if (this.textWidget != null) {
|
||||
this.textWidget.setValue(this.getText());
|
||||
}
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
Object texture = CraftGUITexture.ButtonDisabled;
|
||||
if (this.isMouseOver()) {
|
||||
texture = CraftGUITexture.ButtonHighlighted;
|
||||
}
|
||||
else if (this.isEnabled()) {
|
||||
texture = CraftGUITexture.Button;
|
||||
}
|
||||
CraftGUI.Render.texture(texture, this.getArea());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.button;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import java.util.List;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
|
||||
public class ControlEnumButton<T> extends ControlButton implements IControlValue<T>
|
||||
{
|
||||
public static final String eventEnumChanged = "eventEnumButtonChanged";
|
||||
private T currentSelection;
|
||||
private List<T> enumConstants;
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return this.currentSelection.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseClick(final EventMouse.Down event) {
|
||||
int index = this.enumConstants.indexOf(this.currentSelection);
|
||||
if (index < this.enumConstants.size() - 1) {
|
||||
++index;
|
||||
}
|
||||
else {
|
||||
index = 0;
|
||||
}
|
||||
final T newEnum = this.enumConstants.get(index);
|
||||
this.setValue(newEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final T selection) {
|
||||
if (this.currentSelection != selection) {
|
||||
this.currentSelection = selection;
|
||||
this.callEvent(new EventValueChanged<Object>(this, this.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
public ControlEnumButton(final IWidget parent, final float x, final float y, final float width, final float height, final T[] values) {
|
||||
super(parent, x, y, width, height, "");
|
||||
this.enumConstants = new ArrayList<T>();
|
||||
for (final T value : values) {
|
||||
this.enumConstants.add(value);
|
||||
}
|
||||
if (values.length > 0) {
|
||||
this.currentSelection = values[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return this.currentSelection;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.button;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.events.EventToggleButtonClicked;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
|
||||
public class ControlToggleButton extends ControlButton
|
||||
{
|
||||
boolean toggled;
|
||||
|
||||
@Override
|
||||
public void onMouseClick(final EventMouse.Down event) {
|
||||
this.callEvent(new EventToggleButtonClicked(this, this.toggled));
|
||||
}
|
||||
|
||||
public ControlToggleButton(final IWidget parent, final int x, final int y, final int width, final int height) {
|
||||
super(parent, x, y, width, height);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.core;
|
||||
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import java.util.List;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.core.ITooltipHelp;
|
||||
import binnie.craftgui.core.Widget;
|
||||
|
||||
public class Control extends Widget implements ITooltipHelp, ITooltip
|
||||
{
|
||||
List<String> helpStrings;
|
||||
List<String> tooltipStrings;
|
||||
public int extraLevel;
|
||||
|
||||
public Control(final IWidget parent, final float x, final float y, final float w, final float h) {
|
||||
super(parent);
|
||||
this.helpStrings = new ArrayList<String>();
|
||||
this.tooltipStrings = new ArrayList<String>();
|
||||
this.extraLevel = 0;
|
||||
this.setPosition(new IPoint(x, y));
|
||||
this.setSize(new IPoint(w, h));
|
||||
this.initialise();
|
||||
}
|
||||
|
||||
public Control(final IWidget parent, final IArea area) {
|
||||
this(parent, area.x(), area.y(), area.w(), area.h());
|
||||
}
|
||||
|
||||
protected void initialise() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
}
|
||||
|
||||
public void addHelp(final String string) {
|
||||
this.helpStrings.add(string);
|
||||
}
|
||||
|
||||
public void addHelp(final String[] strings) {
|
||||
for (final String string : strings) {
|
||||
this.addHelp(string);
|
||||
}
|
||||
}
|
||||
|
||||
public void addTooltip(final String string) {
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.tooltipStrings.add(string);
|
||||
}
|
||||
|
||||
public void addTooltip(final String[] strings) {
|
||||
for (final String string : strings) {
|
||||
this.addTooltip(string);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return this.extraLevel + super.getLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getHelpTooltip(final Tooltip tooltip) {
|
||||
tooltip.add(this.helpStrings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
tooltip.add(this.tooltipStrings);
|
||||
}
|
||||
|
||||
public Window getWindow() {
|
||||
return (Window) this.getSuperParent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.core;
|
||||
|
||||
public interface IControlIndexed
|
||||
{
|
||||
int getIndex();
|
||||
|
||||
void setIndex(final int p0);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.core;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public interface IControlValue<T> extends IWidget
|
||||
{
|
||||
T getValue();
|
||||
|
||||
void setValue(final T p0);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.core;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface IControlValues<T> extends IControlValue<T>
|
||||
{
|
||||
Collection<T> getValues();
|
||||
|
||||
void setValues(final Collection<T> p0);
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.listbox;
|
||||
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import java.util.Collection;
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import java.util.LinkedHashMap;
|
||||
import binnie.core.util.IValidator;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import java.util.Map;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlList<T> extends Control implements IControlValue<T>
|
||||
{
|
||||
ControlListBox<T> parent;
|
||||
T value;
|
||||
Map<T, IWidget> allOptions;
|
||||
Map<T, IWidget> optionWidgets;
|
||||
boolean creating;
|
||||
IValidator<IWidget> validator;
|
||||
|
||||
protected ControlList(final ControlListBox<T> parent, final float x, final float y, final float w, final float h) {
|
||||
super(parent, x, y, w, h);
|
||||
this.value = null;
|
||||
this.allOptions = new LinkedHashMap<T, IWidget>();
|
||||
this.optionWidgets = new LinkedHashMap<T, IWidget>();
|
||||
this.creating = false;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final T value) {
|
||||
if (value == this.value) {
|
||||
return;
|
||||
}
|
||||
this.value = value;
|
||||
if (value != null && this.optionWidgets.containsKey(value)) {
|
||||
final IWidget child = this.optionWidgets.get(value);
|
||||
this.parent.ensureVisible(child.y(), child.y() + child.h(), this.h());
|
||||
}
|
||||
this.getParent().callEvent(new EventValueChanged<Object>(this.getParent(), value));
|
||||
}
|
||||
|
||||
public void setOptions(final Collection<T> options) {
|
||||
this.deleteAllChildren();
|
||||
this.allOptions.clear();
|
||||
int i = 0;
|
||||
for (final T option : options) {
|
||||
final IWidget optionWidget = ((ControlListBox) this.getParent()).createOption(option, 0);
|
||||
if (optionWidget != null) {
|
||||
this.allOptions.put(option, optionWidget);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
this.filterOptions();
|
||||
}
|
||||
|
||||
public void filterOptions() {
|
||||
int height = 0;
|
||||
this.optionWidgets.clear();
|
||||
for (final Map.Entry<T, IWidget> entry : this.allOptions.entrySet()) {
|
||||
if (this.isValidOption(entry.getValue())) {
|
||||
entry.getValue().show();
|
||||
this.optionWidgets.put(entry.getKey(), entry.getValue());
|
||||
entry.getValue().setPosition(new IPoint(0.0f, height));
|
||||
height += (int) entry.getValue().getSize().y();
|
||||
}
|
||||
else {
|
||||
entry.getValue().hide();
|
||||
}
|
||||
}
|
||||
this.creating = true;
|
||||
this.setValue(this.getValue());
|
||||
this.setSize(new IPoint(this.getSize().x(), height));
|
||||
}
|
||||
|
||||
public Collection<T> getOptions() {
|
||||
return this.optionWidgets.keySet();
|
||||
}
|
||||
|
||||
public Collection<T> getAllOptions() {
|
||||
return this.allOptions.keySet();
|
||||
}
|
||||
|
||||
public int getIndexOf(final T value) {
|
||||
int index = 0;
|
||||
for (final T option : this.getOptions()) {
|
||||
if (option.equals(value)) {
|
||||
return index;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getCurrentIndex() {
|
||||
return this.getIndexOf(this.getValue());
|
||||
}
|
||||
|
||||
public void setIndex(final int currentIndex) {
|
||||
int index = 0;
|
||||
for (final T option : this.getOptions()) {
|
||||
if (index == currentIndex) {
|
||||
this.setValue(option);
|
||||
return;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
this.setValue(null);
|
||||
}
|
||||
|
||||
private boolean isValidOption(final IWidget widget) {
|
||||
return this.validator == null || this.validator.isValid(widget);
|
||||
}
|
||||
|
||||
public void setValidator(final IValidator<IWidget> validator) {
|
||||
if (this.validator != validator) {
|
||||
this.validator = validator;
|
||||
this.filterOptions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.listbox;
|
||||
|
||||
import binnie.core.util.IValidator;
|
||||
import java.util.Collection;
|
||||
import binnie.craftgui.events.EventKey;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
|
||||
public class ControlListBox<T> extends ControlScrollableContent<ControlList<T>> implements IControlValue<T>
|
||||
{
|
||||
public ControlListBox(final IWidget parent, final float x, final float y, final float w, final float h, final float scrollBarSize) {
|
||||
super(parent, x, y, w, h, scrollBarSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialise() {
|
||||
this.setScrollableContent(new ControlList<T>(this, 1.0f, 1.0f, this.w() - 2.0f - this.scrollBarSize, this.h() - 2.0f));
|
||||
this.addEventHandler(new EventKey.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventKey.Down event) {
|
||||
if (ControlListBox.this.calculateIsMouseOver()) {
|
||||
int currentIndex = ControlListBox.this.getContent().getCurrentIndex();
|
||||
if (event.getKey() == 208) {
|
||||
if (++currentIndex >= ControlListBox.this.getContent().getOptions().size()) {
|
||||
currentIndex = 0;
|
||||
}
|
||||
}
|
||||
else if (event.getKey() == 200 && --currentIndex < 0) {
|
||||
currentIndex = ControlListBox.this.getContent().getOptions().size() - 1;
|
||||
}
|
||||
ControlListBox.this.getContent().setIndex(currentIndex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T getValue() {
|
||||
return this.getContent().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setValue(final T value) {
|
||||
this.getContent().setValue(value);
|
||||
}
|
||||
|
||||
public void setOptions(final Collection<T> options) {
|
||||
this.getContent().setOptions(options);
|
||||
}
|
||||
|
||||
public IWidget createOption(final T value, final int y) {
|
||||
return new ControlOption<T>(this.getContent(), value, y);
|
||||
}
|
||||
|
||||
public void setValidator(final IValidator<IWidget> validator) {
|
||||
this.getContent().setValidator(validator);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.listbox;
|
||||
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlOption<T> extends Control implements IControlValue<T>
|
||||
{
|
||||
T value;
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
if (this.getValue() == null) {
|
||||
return;
|
||||
}
|
||||
int colour = 10526880;
|
||||
if (this.isCurrentSelection()) {
|
||||
colour = 16777215;
|
||||
}
|
||||
this.setColour(colour);
|
||||
}
|
||||
|
||||
public ControlOption(final ControlList<T> controlList, final T option) {
|
||||
this(controlList, option, 16);
|
||||
}
|
||||
|
||||
public ControlOption(final ControlList<T> controlList, final T option, final int height) {
|
||||
super(controlList, 0.0f, height, controlList.getSize().x(), 20.0f);
|
||||
this.value = option;
|
||||
if (this.value != null) {
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
((IControlValue) ControlOption.this.getParent()).setValue(ControlOption.this.getValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean isCurrentSelection() {
|
||||
return this.getValue() != null && this.getValue().equals(((IControlValue) this.getParent()).getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
if (this.isCurrentSelection()) {
|
||||
CraftGUI.Render.texture(CraftGUITexture.Outline, this.getArea());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.listbox;
|
||||
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
|
||||
public class ControlTextOption<T> extends ControlOption<T>
|
||||
{
|
||||
protected ControlText textWidget;
|
||||
|
||||
public ControlTextOption(final ControlList<T> controlList, final T option, final String optionName, final int y) {
|
||||
super(controlList, option, y);
|
||||
this.textWidget = null;
|
||||
this.textWidget = new ControlText(this, this.getArea(), optionName, TextJustification.MiddleCenter);
|
||||
this.addEventHandler(new EventWidget.ChangeColour.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.ChangeColour event) {
|
||||
ControlTextOption.this.textWidget.setColour(ControlTextOption.this.getColour());
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
|
||||
public ControlTextOption(final ControlList<T> controlList, final T option, final int y) {
|
||||
this(controlList, option, option.toString(), y);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.textWidget.getValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.page;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlPage<T> extends Control implements IControlValue<T>
|
||||
{
|
||||
T value;
|
||||
|
||||
public ControlPage(final IWidget parent, final T value) {
|
||||
this(parent, 0.0f, 0.0f, parent.w(), parent.h(), value);
|
||||
}
|
||||
|
||||
public ControlPage(final IWidget parent, final float x, final float y, final float w, final float h, final T value) {
|
||||
super(parent, x, y, w, h);
|
||||
this.setValue(value);
|
||||
if (parent instanceof IControlValue && ((IControlValue) parent).getValue() == null) {
|
||||
((IControlValue) parent).setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final T value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.page;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.IControlValues;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlPages<T> extends Control implements IControlValues<T>, IControlValue<T>
|
||||
{
|
||||
T value;
|
||||
|
||||
@Override
|
||||
public boolean isChildVisible(final IWidget child) {
|
||||
return child != null && this.value == ((IControlValue) child).getValue();
|
||||
}
|
||||
|
||||
public ControlPages(final IWidget parent, final float x, final float y, final float w, final float h) {
|
||||
super(parent, x, y, w, h);
|
||||
this.value = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddChild(final IWidget widget) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final T value) {
|
||||
if (this.value != value) {
|
||||
this.value = value;
|
||||
this.callEvent(new EventValueChanged<Object>(this, value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<T> getValues() {
|
||||
final List<T> list = new ArrayList<T>();
|
||||
for (final IWidget child : this.getWidgets()) {
|
||||
list.add((T) ((IControlValue) child).getValue());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValues(final Collection<T> values) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.scroll;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlScroll extends Control
|
||||
{
|
||||
private IControlScrollable scrollWidget;
|
||||
|
||||
public ControlScroll(final IWidget parent, final float x, final float y, final float width, final float height, final IControlScrollable scrollWidget) {
|
||||
super(parent, x, y, width, height);
|
||||
this.scrollWidget = scrollWidget;
|
||||
new ControlScrollBar(this);
|
||||
}
|
||||
|
||||
public IControlScrollable getScrollableWidget() {
|
||||
return this.scrollWidget;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.scroll;
|
||||
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlScrollBar extends Control
|
||||
{
|
||||
protected final IControlScrollable scrollable;
|
||||
|
||||
public ControlScrollBar(final ControlScroll parent) {
|
||||
this(parent, 0.0f, 0.0f, parent.getSize().x(), parent.getSize().y(), parent.getScrollableWidget());
|
||||
}
|
||||
|
||||
public ControlScrollBar(final IWidget parent, final float x, final float y, final float w, final float h, final IControlScrollable scrollable2) {
|
||||
super(parent, x, y, w, h);
|
||||
this.scrollable = scrollable2;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.addSelfEventHandler(new EventMouse.Drag.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Drag event) {
|
||||
ControlScrollBar.this.scrollable.movePercentage(event.getDy() / (ControlScrollBar.this.h() - ControlScrollBar.this.getBarHeight()));
|
||||
}
|
||||
});
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
final float shownPercentage = ControlScrollBar.this.scrollable.getPercentageShown();
|
||||
final float percentageIndex = ControlScrollBar.this.scrollable.getPercentageIndex();
|
||||
final float minPercent = (1.0f - shownPercentage) * percentageIndex;
|
||||
final float maxPercent = minPercent + shownPercentage;
|
||||
float clickedPercentage = ControlScrollBar.this.getRelativeMousePosition().y() / (ControlScrollBar.this.h() - 2.0f);
|
||||
clickedPercentage = Math.max(Math.min(clickedPercentage, 1.0f), 0.0f);
|
||||
if (clickedPercentage > maxPercent) {
|
||||
ControlScrollBar.this.scrollable.setPercentageIndex((clickedPercentage - shownPercentage) / (1.0f - shownPercentage));
|
||||
}
|
||||
if (clickedPercentage < minPercent) {
|
||||
ControlScrollBar.this.scrollable.setPercentageIndex(clickedPercentage / (1.0f - shownPercentage));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.scrollable.getPercentageShown() < 0.99f;
|
||||
}
|
||||
|
||||
public float getBarHeight() {
|
||||
return this.h() * this.scrollable.getPercentageShown();
|
||||
}
|
||||
|
||||
protected IArea getRenderArea() {
|
||||
float height = this.getBarHeight();
|
||||
if (height < 6.0f) {
|
||||
height = 6.0f;
|
||||
}
|
||||
final float yOffset = ((int) this.h() - (int) this.getBarHeight()) * this.scrollable.getPercentageIndex();
|
||||
return new IArea(0.0f, yOffset, this.getSize().x(), height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
final IArea renderArea = this.getRenderArea();
|
||||
Object texture = CraftGUITexture.ScrollDisabled;
|
||||
if (this.isMouseOver()) {
|
||||
texture = CraftGUITexture.ScrollHighlighted;
|
||||
}
|
||||
else if (this.isEnabled()) {
|
||||
texture = CraftGUITexture.Scroll;
|
||||
}
|
||||
CraftGUI.Render.texture(texture, renderArea);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.scroll;
|
||||
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class ControlScrollableContent<T extends IWidget> extends Control implements IControlScrollable
|
||||
{
|
||||
protected T controlChild;
|
||||
protected float scrollBarSize;
|
||||
float percentageIndex;
|
||||
|
||||
public ControlScrollableContent(final IWidget parent, final float x, final float y, final float w, final float h, final float scrollBarSize) {
|
||||
super(parent, x, y, w, h);
|
||||
this.percentageIndex = 0.0f;
|
||||
if (scrollBarSize != 0.0f) {
|
||||
new ControlScroll(this, this.getSize().x() - scrollBarSize, 0.0f, scrollBarSize, this.getSize().y(), this);
|
||||
}
|
||||
this.addEventHandler(new EventMouse.Wheel.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Wheel event) {
|
||||
if (ControlScrollableContent.this.getRelativeMousePosition().x() > 0.0f && ControlScrollableContent.this.getRelativeMousePosition().y() > 0.0f && ControlScrollableContent.this.getRelativeMousePosition().x() < ControlScrollableContent.this.getSize().x() && ControlScrollableContent.this.getRelativeMousePosition().y() < ControlScrollableContent.this.getSize().y()) {
|
||||
if (ControlScrollableContent.this.getMovementRange() == 0.0f) {
|
||||
return;
|
||||
}
|
||||
final float percentageMove = 0.8f / ControlScrollableContent.this.getMovementRange();
|
||||
ControlScrollableContent.this.movePercentage(percentageMove * -event.getDWheel());
|
||||
}
|
||||
}
|
||||
});
|
||||
this.scrollBarSize = scrollBarSize;
|
||||
}
|
||||
|
||||
public void setScrollableContent(final T child) {
|
||||
this.controlChild = child;
|
||||
if (child == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
child.setCroppedZone(this, new IArea(1.0F, 1.0F, getSize().x() - 2.0F - this.scrollBarSize, getSize().y() - 2.0F));
|
||||
|
||||
child.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.ChangeSize event) {
|
||||
ControlScrollableContent.this.controlChild.setOffset(new IPoint(0.0f, -ControlScrollableContent.this.percentageIndex * ControlScrollableContent.this.getMovementRange()));
|
||||
if (ControlScrollableContent.this.getMovementRange() == 0.0f) {
|
||||
ControlScrollableContent.this.percentageIndex = 0.0f;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public T getContent() {
|
||||
return this.controlChild;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPercentageShown() {
|
||||
if (this.controlChild == null || this.controlChild.getSize().y() == 0.0f) {
|
||||
return 1.0f;
|
||||
}
|
||||
final float shown = this.getSize().y() / this.controlChild.getSize().y();
|
||||
return Math.min(shown, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPercentageIndex() {
|
||||
return this.percentageIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void movePercentage(final float percentage) {
|
||||
if (this.controlChild == null) {
|
||||
return;
|
||||
}
|
||||
this.percentageIndex += percentage;
|
||||
if (this.percentageIndex > 1.0f) {
|
||||
this.percentageIndex = 1.0f;
|
||||
}
|
||||
else if (this.percentageIndex < 0.0f) {
|
||||
this.percentageIndex = 0.0f;
|
||||
}
|
||||
if (this.getMovementRange() == 0.0f) {
|
||||
this.percentageIndex = 0.0f;
|
||||
}
|
||||
this.controlChild.setOffset(new IPoint(0.0f, -this.percentageIndex * this.getMovementRange()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPercentageIndex(final float index) {
|
||||
this.movePercentage(index - this.percentageIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMovementRange() {
|
||||
if (this.controlChild == null) {
|
||||
return 0.0f;
|
||||
}
|
||||
final float range = this.controlChild.getSize().y() - this.getSize().y();
|
||||
return Math.max(range, 0.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
this.setPercentageIndex(this.getPercentageIndex());
|
||||
}
|
||||
|
||||
public void ensureVisible(float minY, float maxY, final float totalY) {
|
||||
minY /= totalY;
|
||||
maxY /= totalY;
|
||||
final float shownPercentage = this.getPercentageShown();
|
||||
final float percentageIndex = this.getPercentageIndex();
|
||||
final float minPercent = (1.0f - shownPercentage) * percentageIndex;
|
||||
final float maxPercent = minPercent + shownPercentage;
|
||||
if (maxY > maxPercent) {
|
||||
this.setPercentageIndex((maxY - shownPercentage) / (1.0f - shownPercentage));
|
||||
}
|
||||
if (minY < minPercent) {
|
||||
this.setPercentageIndex(minY / (1.0f - shownPercentage));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.scroll;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public interface IControlScrollable extends IWidget
|
||||
{
|
||||
float getPercentageShown();
|
||||
|
||||
float getPercentageIndex();
|
||||
|
||||
void movePercentage(final float p0);
|
||||
|
||||
void setPercentageIndex(final float p0);
|
||||
|
||||
float getMovementRange();
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.tab;
|
||||
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.craftgui.minecraft.control.ControlTabIcon;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlTab<T> extends Control implements ITooltip, IControlValue<T>
|
||||
{
|
||||
private ControlTabBar<T> tabBar;
|
||||
protected T value;
|
||||
|
||||
public ControlTab(final ControlTabBar<T> parent, final float x, final float y, final float w, final float h, final T value) {
|
||||
super(parent, x, y, w, h);
|
||||
this.setValue(value);
|
||||
this.tabBar = parent;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
ControlTab.this.callEvent(new EventValueChanged<Object>(ControlTab.this.getWidget(), ControlTab.this.getValue()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
final String name = this.getName();
|
||||
if (name != null && !name.isEmpty()) {
|
||||
tooltip.add(this.getName());
|
||||
}
|
||||
if (this.value instanceof ITooltip) {
|
||||
((ITooltip) this.value).getTooltip(tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean isCurrentSelection() {
|
||||
return this.getValue() != null && this.getValue().equals(this.tabBar.getValue());
|
||||
}
|
||||
|
||||
public Position getTabPosition() {
|
||||
return this.tabBar.position;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
Object texture = CraftGUITexture.TabDisabled;
|
||||
if (this.isMouseOver()) {
|
||||
texture = CraftGUITexture.TabHighlighted;
|
||||
}
|
||||
else if (this.isCurrentSelection()) {
|
||||
texture = CraftGUITexture.Tab;
|
||||
}
|
||||
final Texture lTexture = CraftGUI.Render.getTexture(texture);
|
||||
final Position position = this.getTabPosition();
|
||||
Texture iTexture = lTexture.crop(position, 8.0f);
|
||||
final IArea area = this.getArea();
|
||||
if (texture == CraftGUITexture.TabDisabled) {
|
||||
if (position == Position.Top || position == Position.Left) {
|
||||
area.setPosition(area.getPosition().sub(new IPoint(4 * position.x(), 4 * position.y())));
|
||||
area.setSize(area.getSize().add(new IPoint(4 * position.x(), 4 * position.y())));
|
||||
}
|
||||
else {
|
||||
area.setSize(area.getSize().sub(new IPoint(4 * position.x(), 4 * position.y())));
|
||||
}
|
||||
}
|
||||
CraftGUI.Render.texture(iTexture, area);
|
||||
if (this instanceof ControlTabIcon) {
|
||||
final ControlTabIcon icon = (ControlTabIcon) this;
|
||||
final ControlItemDisplay item = (ControlItemDisplay) this.getWidgets().get(0);
|
||||
if (texture == CraftGUITexture.TabDisabled) {
|
||||
item.setColour(-1431655766);
|
||||
}
|
||||
else {
|
||||
item.setColour(-1);
|
||||
}
|
||||
if (icon.hasOutline()) {
|
||||
iTexture = CraftGUI.Render.getTexture(CraftGUITexture.TabOutline);
|
||||
iTexture = iTexture.crop(position, 8.0f);
|
||||
CraftGUI.Render.colour(icon.getOutlineColour());
|
||||
CraftGUI.Render.texture(iTexture, area.inset(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.controls.tab;
|
||||
|
||||
import java.util.Collection;
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlTabBar<T> extends Control implements IControlValue<T>
|
||||
{
|
||||
T value;
|
||||
Position position;
|
||||
|
||||
public ControlTabBar(final IWidget parent, final float x, final float y, final float width, final float height, final Position position) {
|
||||
super(parent, x, y, width, height);
|
||||
this.position = position;
|
||||
this.addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
ControlTabBar.this.setValue((T) event.getValue());
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, this));
|
||||
}
|
||||
|
||||
public void setValues(final Collection<T> values) {
|
||||
final int i = 0;
|
||||
while (i < this.getWidgets().size()) {
|
||||
this.deleteChild(this.getWidgets().get(0));
|
||||
}
|
||||
final float length = values.size();
|
||||
int tabDimension = (int) (this.getSize().y() / length);
|
||||
if (this.position == Position.Top || this.position == Position.Bottom) {
|
||||
tabDimension = (int) (this.getSize().x() / length);
|
||||
}
|
||||
int j = 0;
|
||||
for (final T value : values) {
|
||||
if (this.position == Position.Top || this.position == Position.Bottom) {
|
||||
final IWidget tab = this.createTab(j * tabDimension, 0.0f, tabDimension, this.getSize().y(), value);
|
||||
}
|
||||
else {
|
||||
final IWidget tab = this.createTab(0.0f, j * tabDimension, this.getSize().x(), tabDimension, value);
|
||||
}
|
||||
++j;
|
||||
}
|
||||
if (this.value == null && !values.isEmpty()) {
|
||||
this.setValue(values.iterator().next());
|
||||
}
|
||||
}
|
||||
|
||||
public ControlTab<T> createTab(final float x, final float y, final float w, final float h, final T value) {
|
||||
return new ControlTab<T>(this, x, y, w, h, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final T value) {
|
||||
final boolean change = this.value != value;
|
||||
this.value = value;
|
||||
if (change) {
|
||||
this.callEvent(new EventValueChanged<Object>(this, value));
|
||||
}
|
||||
}
|
||||
|
||||
public Position getDirection() {
|
||||
return this.position;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
public enum Attribute implements IWidgetAttribute
|
||||
{
|
||||
MouseOver,
|
||||
CanFocus,
|
||||
NeedsDeletion,
|
||||
AlwaysOnTop,
|
||||
BlockTooltip;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import binnie.craftgui.core.renderer.Renderer;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUIResourceManager;
|
||||
|
||||
public class CraftGUI
|
||||
{
|
||||
public static CraftGUIResourceManager ResourceManager;
|
||||
public static Renderer Render;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
public interface ITooltip
|
||||
{
|
||||
void getTooltip(final Tooltip p0);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
public interface ITooltipHelp
|
||||
{
|
||||
void getHelpTooltip(final Tooltip p0);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
|
||||
public interface ITopLevelWidget extends IWidget
|
||||
{
|
||||
void setMousePosition(final int p0, final int p1);
|
||||
|
||||
IPoint getAbsoluteMousePosition();
|
||||
|
||||
IWidget getFocusedWidget();
|
||||
|
||||
IWidget getMousedOverWidget();
|
||||
|
||||
IWidget getDraggedWidget();
|
||||
|
||||
boolean isFocused(final IWidget p0);
|
||||
|
||||
boolean isMouseOver(final IWidget p0);
|
||||
|
||||
boolean isDragged(final IWidget p0);
|
||||
|
||||
void updateTopLevel();
|
||||
|
||||
void widgetDeleted(final IWidget p0);
|
||||
|
||||
IPoint getDragDistance();
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import binnie.craftgui.events.Event;
|
||||
import java.util.List;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
|
||||
public interface IWidget
|
||||
{
|
||||
IWidget getParent();
|
||||
|
||||
void deleteChild(final IWidget p0);
|
||||
|
||||
void deleteAllChildren();
|
||||
|
||||
ITopLevelWidget getSuperParent();
|
||||
|
||||
boolean isTopLevel();
|
||||
|
||||
IPoint getPosition();
|
||||
|
||||
IPoint pos();
|
||||
|
||||
void setPosition(final IPoint p0);
|
||||
|
||||
IPoint getSize();
|
||||
|
||||
IPoint size();
|
||||
|
||||
void setSize(final IPoint p0);
|
||||
|
||||
IPoint getOriginalPosition();
|
||||
|
||||
IPoint getAbsolutePosition();
|
||||
|
||||
IPoint getOriginalAbsolutePosition();
|
||||
|
||||
IPoint getOffset();
|
||||
|
||||
IArea getArea();
|
||||
|
||||
IArea area();
|
||||
|
||||
void setOffset(final IPoint p0);
|
||||
|
||||
IPoint getMousePosition();
|
||||
|
||||
IPoint getRelativeMousePosition();
|
||||
|
||||
void setColour(final int p0);
|
||||
|
||||
int getColour();
|
||||
|
||||
void render();
|
||||
|
||||
void updateClient();
|
||||
|
||||
void enable();
|
||||
|
||||
void disable();
|
||||
|
||||
void show();
|
||||
|
||||
void hide();
|
||||
|
||||
boolean calculateIsMouseOver();
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
boolean isVisible();
|
||||
|
||||
boolean isFocused();
|
||||
|
||||
boolean isMouseOver();
|
||||
|
||||
boolean isDragged();
|
||||
|
||||
boolean isChildVisible(final IWidget p0);
|
||||
|
||||
boolean isChildEnabled(final IWidget p0);
|
||||
|
||||
boolean canMouseOver();
|
||||
|
||||
boolean canFocus();
|
||||
|
||||
IWidget addWidget(final IWidget p0);
|
||||
|
||||
List<IWidget> getWidgets();
|
||||
|
||||
void callEvent(final Event p0);
|
||||
|
||||
void recieveEvent(final Event p0);
|
||||
|
||||
void onUpdateClient();
|
||||
|
||||
void delete();
|
||||
|
||||
void onDelete();
|
||||
|
||||
<T> T getWidget(final Class<T> p0);
|
||||
|
||||
IArea getCroppedZone();
|
||||
|
||||
void setCroppedZone(final IWidget p0, final IArea p1);
|
||||
|
||||
boolean isCroppedWidet();
|
||||
|
||||
IWidget getCropWidget();
|
||||
|
||||
boolean isMouseOverWidget(final IPoint p0);
|
||||
|
||||
int getLevel();
|
||||
|
||||
boolean isDescendant(final IWidget p0);
|
||||
|
||||
List<IWidgetAttribute> getAttributes();
|
||||
|
||||
boolean hasAttribute(final IWidgetAttribute p0);
|
||||
|
||||
boolean addAttribute(final IWidgetAttribute p0);
|
||||
|
||||
<E extends Event> void addEventHandler(final EventHandler<E> p0);
|
||||
|
||||
<E extends Event> void addSelfEventHandler(final EventHandler<E> p0);
|
||||
|
||||
boolean contains(final IPoint p0);
|
||||
|
||||
float x();
|
||||
|
||||
float y();
|
||||
|
||||
float w();
|
||||
|
||||
float h();
|
||||
|
||||
void onRender(final RenderStage p0);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
public interface IWidgetAttribute
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
public enum RenderStage
|
||||
{
|
||||
PreChildren,
|
||||
PostChildren,
|
||||
PostSiblings;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Tooltip
|
||||
{
|
||||
List<String> tooltip;
|
||||
ITooltipType type;
|
||||
public int maxWidth;
|
||||
|
||||
public Tooltip() {
|
||||
this.tooltip = new ArrayList<String>();
|
||||
this.type = Type.Standard;
|
||||
this.maxWidth = 256;
|
||||
}
|
||||
|
||||
public void add(final String string) {
|
||||
this.tooltip.add(string);
|
||||
}
|
||||
|
||||
public String getLine(final int index) {
|
||||
final String string = this.getList().get(index);
|
||||
return string;
|
||||
}
|
||||
|
||||
public void add(final List list) {
|
||||
for (final Object obj : list) {
|
||||
this.tooltip.add((String) obj);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getList() {
|
||||
return this.tooltip;
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
return this.tooltip.size() > 0;
|
||||
}
|
||||
|
||||
public void setType(final ITooltipType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setMaxWidth(final int w) {
|
||||
this.maxWidth = w;
|
||||
}
|
||||
|
||||
public ITooltipType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void add(final ItemStack item, final String string) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
item.writeToNBT(nbt);
|
||||
nbt.setByte("nbt-type", (byte) 105);
|
||||
this.add("~~~" + nbt.toString() + "~~~" + string);
|
||||
}
|
||||
|
||||
public void add(final FluidStack item, final String string) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
item.writeToNBT(nbt);
|
||||
nbt.setByte("nbt-type", (byte) 102);
|
||||
this.add("~~~" + nbt.toString() + "~~~" + string);
|
||||
}
|
||||
|
||||
public enum Type implements ITooltipType
|
||||
{
|
||||
Standard,
|
||||
Help,
|
||||
Information,
|
||||
User,
|
||||
Power;
|
||||
}
|
||||
|
||||
public interface ITooltipType
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import java.util.ListIterator;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
|
||||
public abstract class TopLevelWidget extends Widget implements ITopLevelWidget
|
||||
{
|
||||
IWidget mousedOverWidget;
|
||||
IWidget draggedWidget;
|
||||
IWidget focusedWidget;
|
||||
protected IPoint mousePosition;
|
||||
IPoint dragStart;
|
||||
|
||||
public TopLevelWidget() {
|
||||
super(null);
|
||||
this.mousedOverWidget = null;
|
||||
this.draggedWidget = null;
|
||||
this.focusedWidget = null;
|
||||
this.mousePosition = new IPoint(0.0f, 0.0f);
|
||||
this.dragStart = IPoint.ZERO;
|
||||
this.addEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
TopLevelWidget.this.setDraggedWidget(TopLevelWidget.this.mousedOverWidget, event.getButton());
|
||||
TopLevelWidget.this.setFocusedWidget(TopLevelWidget.this.mousedOverWidget);
|
||||
}
|
||||
});
|
||||
this.addEventHandler(new EventMouse.Up.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Up event) {
|
||||
TopLevelWidget.this.setDraggedWidget(null);
|
||||
}
|
||||
});
|
||||
this.addEventHandler(new EventWidget.StartDrag.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.StartDrag event) {
|
||||
TopLevelWidget.this.dragStart = TopLevelWidget.this.getRelativeMousePosition();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setMousedOverWidget(final IWidget widget) {
|
||||
if (this.mousedOverWidget == widget) {
|
||||
return;
|
||||
}
|
||||
if (this.mousedOverWidget != null) {
|
||||
this.callEvent(new EventWidget.EndMouseOver(this.mousedOverWidget));
|
||||
}
|
||||
this.mousedOverWidget = widget;
|
||||
if (this.mousedOverWidget != null) {
|
||||
this.callEvent(new EventWidget.StartMouseOver(this.mousedOverWidget));
|
||||
}
|
||||
}
|
||||
|
||||
public void setDraggedWidget(final IWidget widget) {
|
||||
this.setDraggedWidget(widget, -1);
|
||||
}
|
||||
|
||||
public void setDraggedWidget(final IWidget widget, final int button) {
|
||||
if (this.draggedWidget == widget) {
|
||||
return;
|
||||
}
|
||||
if (this.draggedWidget != null) {
|
||||
this.callEvent(new EventWidget.EndDrag(this.draggedWidget));
|
||||
}
|
||||
this.draggedWidget = widget;
|
||||
if (this.draggedWidget != null) {
|
||||
this.callEvent(new EventWidget.StartDrag(this.draggedWidget, button));
|
||||
}
|
||||
}
|
||||
|
||||
public void setFocusedWidget(final IWidget widget) {
|
||||
IWidget newWidget = widget;
|
||||
if (this.focusedWidget == newWidget) {
|
||||
return;
|
||||
}
|
||||
if (newWidget != null && !newWidget.canFocus()) {
|
||||
newWidget = null;
|
||||
}
|
||||
if (this.focusedWidget != null) {
|
||||
this.callEvent(new EventWidget.LoseFocus(this.focusedWidget));
|
||||
}
|
||||
this.focusedWidget = newWidget;
|
||||
if (this.focusedWidget != null) {
|
||||
this.callEvent(new EventWidget.GainFocus(this.focusedWidget));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getMousedOverWidget() {
|
||||
return this.mousedOverWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getDraggedWidget() {
|
||||
return this.draggedWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getFocusedWidget() {
|
||||
return this.focusedWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOver(final IWidget widget) {
|
||||
return this.getMousedOverWidget() == widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDragged(final IWidget widget) {
|
||||
return this.getDraggedWidget() == widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFocused(final IWidget widget) {
|
||||
return this.getFocusedWidget() == widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTopLevel() {
|
||||
this.setMousedOverWidget(this.calculateMousedOverWidget());
|
||||
if (this.getFocusedWidget() != null && (!this.getFocusedWidget().isVisible() || !this.getFocusedWidget().isEnabled())) {
|
||||
this.setFocusedWidget(null);
|
||||
}
|
||||
if (!Mouse.isButtonDown(0)) {
|
||||
if (this.draggedWidget != null) {
|
||||
this.setDraggedWidget(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IWidget calculateMousedOverWidget() {
|
||||
final Deque<IWidget> queue = this.calculateMousedOverWidgets();
|
||||
while (!queue.isEmpty()) {
|
||||
final IWidget widget = queue.removeFirst();
|
||||
if (widget.isEnabled() && widget.isVisible()) {
|
||||
if (!widget.canMouseOver()) {
|
||||
continue;
|
||||
}
|
||||
if (widget.isEnabled() && widget.isVisible() && widget.canMouseOver() && widget.calculateIsMouseOver()) {
|
||||
return widget;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Deque<IWidget> calculateMousedOverWidgets() {
|
||||
final Deque<IWidget> list = new ArrayDeque<IWidget>();
|
||||
for (final IWidget widget : this.getQueuedWidgets(this)) {
|
||||
if (widget.calculateIsMouseOver()) {
|
||||
list.addLast(widget);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Collection<IWidget> getQueuedWidgets(final IWidget widget) {
|
||||
final List<IWidget> widgets = new ArrayList<IWidget>();
|
||||
boolean addChildren = true;
|
||||
if (widget.isCroppedWidet()) {
|
||||
addChildren = widget.getCroppedZone().contains(widget.getCropWidget().getRelativeMousePosition());
|
||||
}
|
||||
if (addChildren) {
|
||||
final ListIterator<IWidget> li = widget.getWidgets().listIterator(widget.getWidgets().size());
|
||||
while (li.hasPrevious()) {
|
||||
final IWidget child = li.previous();
|
||||
widgets.addAll(this.getQueuedWidgets(child));
|
||||
}
|
||||
}
|
||||
widgets.add(widget);
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMousePosition(final int x, final int y) {
|
||||
final float dx = x - this.mousePosition.x();
|
||||
final float dy = y - this.mousePosition.y();
|
||||
if (dx != 0.0f || dy != 0.0f) {
|
||||
if (this.getDraggedWidget() != null) {
|
||||
this.callEvent(new EventMouse.Drag(this.getDraggedWidget(), dx, dy));
|
||||
}
|
||||
else {
|
||||
this.callEvent(new EventMouse.Move(this, dx, dy));
|
||||
}
|
||||
}
|
||||
if (this.mousePosition.x() != x || this.mousePosition.y() != y) {
|
||||
this.mousePosition = new IPoint(x, y);
|
||||
this.setMousedOverWidget(this.calculateMousedOverWidget());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPoint getAbsoluteMousePosition() {
|
||||
return this.mousePosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDeleted(final IWidget widget) {
|
||||
if (this.isMouseOver(widget)) {
|
||||
this.setMousedOverWidget(null);
|
||||
}
|
||||
if (this.isDragged(widget)) {
|
||||
this.setDraggedWidget(null);
|
||||
}
|
||||
if (this.isFocused(widget)) {
|
||||
this.setFocusedWidget(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPoint getDragDistance() {
|
||||
return this.getRelativeMousePosition().sub(this.dragStart);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,517 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import binnie.craftgui.events.Event;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Widget implements IWidget
|
||||
{
|
||||
private IWidget parent;
|
||||
private List<IWidget> subWidgets;
|
||||
private List<IWidgetAttribute> attributes;
|
||||
private IPoint position;
|
||||
private IPoint size;
|
||||
private IPoint offset;
|
||||
IArea cropArea;
|
||||
IWidget cropWidget;
|
||||
boolean cropped;
|
||||
int colour;
|
||||
private Collection<EventHandler> globalEventHandlers;
|
||||
private boolean enabled;
|
||||
private boolean visible;
|
||||
|
||||
public Widget(final IWidget parent) {
|
||||
this.parent = null;
|
||||
this.subWidgets = new ArrayList<IWidget>();
|
||||
this.attributes = new ArrayList<IWidgetAttribute>();
|
||||
this.position = new IPoint(0.0f, 0.0f);
|
||||
this.size = new IPoint(0.0f, 0.0f);
|
||||
this.offset = new IPoint(0.0f, 0.0f);
|
||||
this.cropped = false;
|
||||
this.colour = 16777215;
|
||||
this.globalEventHandlers = new ArrayList<EventHandler>();
|
||||
this.enabled = true;
|
||||
this.visible = true;
|
||||
this.parent = parent;
|
||||
if (parent != null) {
|
||||
parent.addWidget(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IWidgetAttribute> getAttributes() {
|
||||
return this.attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAttribute(final IWidgetAttribute attribute) {
|
||||
return this.attributes.contains(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAttribute(final IWidgetAttribute attribute) {
|
||||
return this.attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void deleteChild(final IWidget child) {
|
||||
if (child == null) {
|
||||
return;
|
||||
}
|
||||
child.delete();
|
||||
this.subWidgets.remove(child);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void deleteAllChildren() {
|
||||
while (!this.subWidgets.isEmpty()) {
|
||||
this.deleteChild(this.subWidgets.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IWidget getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ITopLevelWidget getSuperParent() {
|
||||
return (ITopLevelWidget) (this.isTopLevel() ? this : this.parent.getSuperParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IWidget addWidget(final IWidget widget) {
|
||||
if (this.subWidgets.size() != 0 && this.subWidgets.get(this.subWidgets.size() - 1).hasAttribute(Attribute.AlwaysOnTop)) {
|
||||
this.subWidgets.add(this.subWidgets.size() - 1, widget);
|
||||
}
|
||||
else {
|
||||
this.subWidgets.add(widget);
|
||||
}
|
||||
this.onAddChild(widget);
|
||||
return widget;
|
||||
}
|
||||
|
||||
protected void onAddChild(final IWidget widget) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<IWidget> getWidgets() {
|
||||
return this.subWidgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isTopLevel() {
|
||||
return this instanceof ITopLevelWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint pos() {
|
||||
return this.position.add(this.offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint size() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IArea area() {
|
||||
return this.getArea();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getPosition() {
|
||||
return this.pos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IArea getArea() {
|
||||
return new IArea(IPoint.ZERO, this.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getOriginalPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IArea getCroppedZone() {
|
||||
return this.cropArea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCroppedZone(final IWidget relative, final IArea area) {
|
||||
this.cropArea = area;
|
||||
this.cropped = true;
|
||||
this.cropWidget = relative;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getAbsolutePosition() {
|
||||
return this.isTopLevel() ? this.getPosition() : this.getParent().getAbsolutePosition().add(this.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getOriginalAbsolutePosition() {
|
||||
return this.isTopLevel() ? this.getOriginalPosition() : this.getParent().getOriginalPosition().sub(this.getOriginalPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getSize() {
|
||||
return this.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getOffset() {
|
||||
return this.offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setPosition(final IPoint vector) {
|
||||
if (!vector.equals(this.position)) {
|
||||
this.position = new IPoint(vector);
|
||||
this.callEvent(new EventWidget.ChangePosition(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setSize(final IPoint vector) {
|
||||
if (!vector.equals(this.size)) {
|
||||
this.size = new IPoint(vector);
|
||||
this.callEvent(new EventWidget.ChangeSize(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setOffset(final IPoint vector) {
|
||||
if (vector != this.offset) {
|
||||
this.offset = new IPoint(vector);
|
||||
this.callEvent(new EventWidget.ChangeOffset(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setColour(final int colour) {
|
||||
if (this.colour != colour) {
|
||||
this.colour = colour;
|
||||
this.callEvent(new EventWidget.ChangeColour(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getColour() {
|
||||
return this.colour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMouseOver() {
|
||||
return this.hasAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFocus() {
|
||||
return this.hasAttribute(Attribute.CanFocus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEventHandler(final EventHandler handler) {
|
||||
this.globalEventHandlers.add(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelfEventHandler(final EventHandler handler) {
|
||||
this.addEventHandler(handler.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void callEvent(final Event event) {
|
||||
this.getSuperParent().recieveEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void recieveEvent(final Event event) {
|
||||
for (final EventHandler handler : this.globalEventHandlers) {
|
||||
if (handler.handles(event)) {
|
||||
handler.onEvent(event);
|
||||
}
|
||||
}
|
||||
try {
|
||||
for (final IWidget child : this.getWidgets()) {
|
||||
child.recieveEvent(event);
|
||||
}
|
||||
} catch (ConcurrentModificationException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getMousePosition() {
|
||||
return this.getSuperParent().getAbsoluteMousePosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getRelativeMousePosition() {
|
||||
return this.isTopLevel() ? this.getMousePosition() : this.getParent().getRelativeMousePosition().sub(this.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCroppedWidet() {
|
||||
return this.cropped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IWidget getCropWidget() {
|
||||
return (this.cropWidget == null) ? this : this.cropWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void render() {
|
||||
if (this.isVisible()) {
|
||||
CraftGUI.Render.preRender(this);
|
||||
this.onRender(RenderStage.PreChildren);
|
||||
for (final IWidget widget : this.getWidgets()) {
|
||||
widget.render();
|
||||
}
|
||||
for (final IWidget widget : this.getWidgets()) {
|
||||
CraftGUI.Render.preRender(widget);
|
||||
widget.onRender(RenderStage.PostSiblings);
|
||||
CraftGUI.Render.postRender(widget);
|
||||
}
|
||||
this.onRender(RenderStage.PostChildren);
|
||||
CraftGUI.Render.postRender(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void updateClient() {
|
||||
if (!this.isVisible()) {
|
||||
return;
|
||||
}
|
||||
if (this.getSuperParent() == this) {
|
||||
((ITopLevelWidget) this).updateTopLevel();
|
||||
}
|
||||
this.onUpdateClient();
|
||||
final List<IWidget> deletedWidgets = new ArrayList<IWidget>();
|
||||
for (final IWidget widget : this.getWidgets()) {
|
||||
if (widget.hasAttribute(Attribute.NeedsDeletion)) {
|
||||
deletedWidgets.add(widget);
|
||||
}
|
||||
else {
|
||||
widget.updateClient();
|
||||
}
|
||||
}
|
||||
for (final IWidget widget : deletedWidgets) {
|
||||
this.deleteChild(widget);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean calculateIsMouseOver() {
|
||||
final IPoint mouse = this.getRelativeMousePosition();
|
||||
if (!this.cropped) {
|
||||
return this.isMouseOverWidget(mouse);
|
||||
}
|
||||
final IWidget cropRelative = (this.cropWidget != null) ? this.cropWidget : this;
|
||||
final IPoint pos = IPoint.sub(cropRelative.getAbsolutePosition(), this.getAbsolutePosition());
|
||||
final IPoint size = new IPoint(this.cropArea.size().x(), this.cropArea.size().y());
|
||||
final boolean inCrop = mouse.x() > pos.x() && mouse.y() > pos.y() && mouse.x() < pos.x() + size.x() && mouse.y() < pos.y() + size.y();
|
||||
return inCrop && this.isMouseOverWidget(mouse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOverWidget(final IPoint relativeMouse) {
|
||||
return this.getArea().contains(relativeMouse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void enable() {
|
||||
this.enabled = true;
|
||||
this.callEvent(new EventWidget.Enable(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void disable() {
|
||||
this.enabled = false;
|
||||
this.callEvent(new EventWidget.Disable(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void show() {
|
||||
this.visible = true;
|
||||
this.callEvent(new EventWidget.Show(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void hide() {
|
||||
this.visible = false;
|
||||
this.callEvent(new EventWidget.Hide(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (this.enabled) {
|
||||
if (!this.isTopLevel()) {
|
||||
if (!this.getParent().isEnabled() || !this.getParent().isChildEnabled(this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isVisible() {
|
||||
if (this.visible) {
|
||||
if (!this.isTopLevel()) {
|
||||
if (!this.getParent().isVisible() || !this.getParent().isChildVisible(this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isFocused() {
|
||||
return this.getSuperParent().isFocused(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isDragged() {
|
||||
return this.getSuperParent().isDragged(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isMouseOver() {
|
||||
return this.getSuperParent().isMouseOver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildVisible(final IWidget child) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildEnabled(final IWidget child) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRender(final RenderStage stage) {
|
||||
if (stage == RenderStage.PreChildren) {
|
||||
this.onRenderBackground();
|
||||
}
|
||||
if (stage == RenderStage.PostChildren) {
|
||||
this.onRenderForeground();
|
||||
}
|
||||
if (stage == RenderStage.PostSiblings) {
|
||||
this.onRenderOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
public void onRenderBackground() {
|
||||
}
|
||||
|
||||
public void onRenderForeground() {
|
||||
}
|
||||
|
||||
public void onRenderOverlay() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void delete() {
|
||||
this.getSuperParent().widgetDeleted(this);
|
||||
this.onDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDelete() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getWidget(final Class<T> x) {
|
||||
for (final IWidget child : this.getWidgets()) {
|
||||
if (x.isInstance(child)) {
|
||||
return (T) child;
|
||||
}
|
||||
final T found = child.getWidget(x);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean contains(final IPoint position) {
|
||||
return this.getArea().contains(position);
|
||||
}
|
||||
|
||||
public void scheduleDeletion() {
|
||||
this.addAttribute(Attribute.NeedsDeletion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
final int level = (this.getParent() == null) ? 0 : this.getParent().getLevel();
|
||||
final int index = (this.getParent() == null) ? 0 : this.getParent().getWidgets().indexOf(this);
|
||||
return level + index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDescendant(final IWidget widget) {
|
||||
IWidget clss = this;
|
||||
while (clss != widget) {
|
||||
clss = clss.getParent();
|
||||
if (clss == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float x() {
|
||||
return this.pos().x();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float y() {
|
||||
return this.pos().y();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float w() {
|
||||
return this.size().x();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float h() {
|
||||
return this.size().y();
|
||||
}
|
||||
|
||||
public IWidget getWidget() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class CraftGUIUtil
|
||||
{
|
||||
public static void alignToWidget(final IWidget target, final IWidget relativeTo) {
|
||||
final IPoint startPos = target.getAbsolutePosition();
|
||||
final IPoint endPos = relativeTo.getAbsolutePosition();
|
||||
moveWidget(target, endPos.sub(startPos));
|
||||
}
|
||||
|
||||
public static void moveWidget(final IWidget target, final IPoint movement) {
|
||||
target.setPosition(target.getPosition().add(movement));
|
||||
}
|
||||
|
||||
public static void horizontalGrid(final float px, final float py, final IWidget... widgets) {
|
||||
horizontalGrid(px, py, TextJustification.MiddleCenter, 0.0f, widgets);
|
||||
}
|
||||
|
||||
public static void horizontalGrid(final float px, final float py, final TextJustification just, final float spacing, final IWidget... widgets) {
|
||||
float x = 0.0f;
|
||||
float h = 0.0f;
|
||||
for (final IWidget widget : widgets) {
|
||||
h = Math.max(h, widget.getSize().y());
|
||||
}
|
||||
for (final IWidget widget : widgets) {
|
||||
widget.setPosition(new IPoint(px + x, py + (h - widget.getSize().y()) * just.yOffset));
|
||||
x += widget.getSize().x() + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
public static void verticalGrid(final float px, final float py, final IWidget... widgets) {
|
||||
horizontalGrid(px, py, TextJustification.MiddleCenter, 0.0f, widgets);
|
||||
}
|
||||
|
||||
public static void verticalGrid(final float px, final float py, final TextJustification just, final float spacing, final IWidget... widgets) {
|
||||
float y = 0.0f;
|
||||
float w = 0.0f;
|
||||
for (final IWidget widget : widgets) {
|
||||
w = Math.max(w, widget.getSize().x());
|
||||
}
|
||||
for (final IWidget widget : widgets) {
|
||||
widget.setPosition(new IPoint(px + (w - widget.getSize().x()) * just.xOffset, py + y));
|
||||
y += widget.getSize().y() + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void linkWidgets(final IControlValue<T> tab, final IControlValue<T> target) {
|
||||
tab.addSelfEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
target.setValue((T) event.getValue());
|
||||
}
|
||||
});
|
||||
target.addSelfEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
tab.setValue((T) event.getValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
public class IArea
|
||||
{
|
||||
private IPoint pos;
|
||||
private IPoint size;
|
||||
|
||||
public IArea(final IArea area) {
|
||||
this(area.pos().x(), area.pos().y(), area.size().x(), area.size().y());
|
||||
}
|
||||
|
||||
public IArea(final IPoint pos, final IPoint size) {
|
||||
this(pos.x(), pos.y(), size.x(), size.y());
|
||||
}
|
||||
|
||||
public IArea(final float xywh) {
|
||||
this(xywh, xywh, xywh, xywh);
|
||||
}
|
||||
|
||||
public IArea(final float xy, final float wh) {
|
||||
this(xy, xy, wh, wh);
|
||||
}
|
||||
|
||||
public IArea(final float x, final float y, final float wh) {
|
||||
this(x, y, wh, wh);
|
||||
}
|
||||
|
||||
public IArea(final float x, final float y, final float w, final float h) {
|
||||
this.setPosition(new IPoint(x, y));
|
||||
this.setSize(new IPoint(w, h));
|
||||
}
|
||||
|
||||
public IPoint pos() {
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
public IPoint getPosition() {
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
public void setPosition(final IPoint position) {
|
||||
this.pos = position.copy();
|
||||
}
|
||||
|
||||
public IPoint size() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public IPoint getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public void setSize(final IPoint size) {
|
||||
this.size = size.copy();
|
||||
}
|
||||
|
||||
public boolean contains(final IPoint position) {
|
||||
return position.x() >= this.pos().x() && position.y() >= this.pos.y() && position.x() <= this.pos().x() + this.size().x() && position.y() <= this.pos().y() + this.size().y();
|
||||
}
|
||||
|
||||
public float x() {
|
||||
return this.pos().x();
|
||||
}
|
||||
|
||||
public float y() {
|
||||
return this.pos().y();
|
||||
}
|
||||
|
||||
public float w() {
|
||||
return this.size().x();
|
||||
}
|
||||
|
||||
public float h() {
|
||||
return this.size().y();
|
||||
}
|
||||
|
||||
public float x(final float n) {
|
||||
return this.pos.x(n);
|
||||
}
|
||||
|
||||
public float y(final float n) {
|
||||
return this.pos.y(n);
|
||||
}
|
||||
|
||||
public float w(final float n) {
|
||||
return this.size.x(n);
|
||||
}
|
||||
|
||||
public float h(final float n) {
|
||||
return this.size.y(n);
|
||||
}
|
||||
|
||||
public IArea inset(final IBorder border) {
|
||||
return new IArea(this.x() + border.l(), this.y() + border.t(), this.w() - border.l() - border.r(), this.h() - border.t() - border.b());
|
||||
}
|
||||
|
||||
public IArea outset(final int outset) {
|
||||
return this.outset(new IBorder(outset));
|
||||
}
|
||||
|
||||
public IArea outset(final IBorder border) {
|
||||
return new IArea(this.x() - border.l(), this.y() - border.t(), this.w() + border.l() + border.r(), this.h() + border.t() + border.b());
|
||||
}
|
||||
|
||||
public IArea inset(final int inset) {
|
||||
return this.inset(new IBorder(inset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.w() + "x" + this.h() + "@" + this.x() + "," + this.y();
|
||||
}
|
||||
|
||||
public IArea shift(final float dx, final float f) {
|
||||
return new IArea(this.x() + dx, this.y() + f, this.w(), this.h());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
public class IBorder
|
||||
{
|
||||
public static final IBorder ZERO;
|
||||
float t;
|
||||
float b;
|
||||
float l;
|
||||
float r;
|
||||
|
||||
public IBorder(final float pad) {
|
||||
this(pad, pad, pad, pad);
|
||||
}
|
||||
|
||||
public IBorder(final float tb, final float rl) {
|
||||
this(tb, rl, tb, rl);
|
||||
}
|
||||
|
||||
public IBorder(final float t, final float rl, final float b) {
|
||||
this(t, rl, b, rl);
|
||||
}
|
||||
|
||||
public IBorder(final float t, final float r, final float b, final float l) {
|
||||
this.t = t;
|
||||
this.b = b;
|
||||
this.l = l;
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public IBorder(final Position edge, final float n) {
|
||||
this((edge == Position.Top) ? n : 0.0f, (edge == Position.Right) ? n : 0.0f, (edge == Position.Bottom) ? n : 0.0f, (edge == Position.Left) ? n : 0.0f);
|
||||
}
|
||||
|
||||
public IBorder(final IBorder padding) {
|
||||
this(padding.t(), padding.r(), padding.b(), padding.l());
|
||||
}
|
||||
|
||||
public float t() {
|
||||
return this.t;
|
||||
}
|
||||
|
||||
public float b() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public float l() {
|
||||
return this.l;
|
||||
}
|
||||
|
||||
public float r() {
|
||||
return this.r;
|
||||
}
|
||||
|
||||
public float t(final float n) {
|
||||
return this.t = n;
|
||||
}
|
||||
|
||||
public float b(final float n) {
|
||||
return this.b = n;
|
||||
}
|
||||
|
||||
public float l(final float n) {
|
||||
return this.l = n;
|
||||
}
|
||||
|
||||
public float r(final float n) {
|
||||
return this.r = n;
|
||||
}
|
||||
|
||||
public boolean isNonZero() {
|
||||
return this.t != 0.0f || this.r != 0.0f || this.l != 0.0f || this.r != 0.0f;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint tl() {
|
||||
return new IPoint(this.l(), this.t());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint tr() {
|
||||
return new IPoint(this.r(), this.t());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint bl() {
|
||||
return new IPoint(this.l(), this.b());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint br() {
|
||||
return new IPoint(this.r(), this.b());
|
||||
}
|
||||
|
||||
public IBorder add(final IBorder o) {
|
||||
return new IBorder(this.t() + o.t(), this.r() + o.r(), this.b() + o.b(), this.l() + o.l());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.t() + "-" + this.r() + "-" + this.b() + "-" + this.l();
|
||||
}
|
||||
|
||||
static {
|
||||
ZERO = new IBorder(0.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
public class IPoint
|
||||
{
|
||||
public static final IPoint ZERO;
|
||||
float x;
|
||||
float y;
|
||||
|
||||
public IPoint(final float x, final float y) {
|
||||
this.x = 0.0f;
|
||||
this.y = 0.0f;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public IPoint(final IPoint o) {
|
||||
this.x = 0.0f;
|
||||
this.y = 0.0f;
|
||||
this.x = o.x();
|
||||
this.y = o.y();
|
||||
}
|
||||
|
||||
public static IPoint add(final IPoint a, final IPoint b) {
|
||||
return new IPoint(a.x() + b.x(), a.y() + b.y());
|
||||
}
|
||||
|
||||
public static IPoint sub(final IPoint a, final IPoint b) {
|
||||
return new IPoint(a.x() - b.x(), a.y() - b.y());
|
||||
}
|
||||
|
||||
public IPoint sub(final IPoint a) {
|
||||
return sub(this, a);
|
||||
}
|
||||
|
||||
public IPoint add(final IPoint other) {
|
||||
return add(this, other);
|
||||
}
|
||||
|
||||
public IPoint add(final float dx, final float dy) {
|
||||
return add(this, new IPoint(dx, dy));
|
||||
}
|
||||
|
||||
public IPoint copy() {
|
||||
return new IPoint(this);
|
||||
}
|
||||
|
||||
public float x() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public float y() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public void xy(final float x, final float y) {
|
||||
this.x(x);
|
||||
this.y(y);
|
||||
}
|
||||
|
||||
public float x(final float x) {
|
||||
return this.x = x;
|
||||
}
|
||||
|
||||
public float y(final float y) {
|
||||
return this.y = y;
|
||||
}
|
||||
|
||||
public boolean equals(final IPoint other) {
|
||||
return this.x() == other.x() && this.y() == other.y();
|
||||
}
|
||||
|
||||
static {
|
||||
ZERO = new IPoint(0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
public enum Position
|
||||
{
|
||||
Top(0, -1),
|
||||
Bottom(0, 1),
|
||||
Left(-1, 0),
|
||||
Right(1, 0);
|
||||
|
||||
int x;
|
||||
int y;
|
||||
|
||||
private Position(final int x, final int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int x() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int y() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public Position opposite() {
|
||||
switch (this) {
|
||||
case Bottom: {
|
||||
return Position.Top;
|
||||
}
|
||||
case Left: {
|
||||
return Position.Right;
|
||||
}
|
||||
case Right: {
|
||||
return Position.Left;
|
||||
}
|
||||
case Top: {
|
||||
return Position.Bottom;
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
public enum TextJustification
|
||||
{
|
||||
TopLeft(0.0f, 0.0f),
|
||||
TopCenter(0.5f, 0.0f),
|
||||
TopRight(1.0f, 0.0f),
|
||||
MiddleLeft(0.0f, 0.5f),
|
||||
MiddleCenter(0.5f, 0.5f),
|
||||
MiddleRight(1.0f, 0.5f),
|
||||
BottomLeft(0.0f, 1.0f),
|
||||
BottomCenter(0.5f, 1.0f),
|
||||
BottomRight(1.0f, 1.0f);
|
||||
|
||||
float xOffset;
|
||||
float yOffset;
|
||||
|
||||
private TextJustification(final float xOffset, final float yOffset) {
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
|
||||
public float getXOffset() {
|
||||
return this.xOffset;
|
||||
}
|
||||
|
||||
public float getYOffset() {
|
||||
return this.yOffset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.renderer;
|
||||
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.List;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.resource.IStyleSheet;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.minecraft.GuiCraftGUI;
|
||||
|
||||
public class Renderer
|
||||
{
|
||||
GuiCraftGUI gui;
|
||||
int currentColour;
|
||||
Texture currentTexture;
|
||||
IStyleSheet stylesheet;
|
||||
|
||||
public Renderer(final GuiCraftGUI gui) {
|
||||
this.currentColour = 16777215;
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
public final void preRender(final IWidget widget) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(widget.getPosition().x(), widget.getPosition().y(), 0.0f);
|
||||
this.colour(widget.getColour());
|
||||
if (widget.isCroppedWidet()) {
|
||||
final IWidget cropRelative = (widget.getCropWidget() != null) ? widget.getCropWidget() : widget;
|
||||
final IPoint pos = cropRelative.getAbsolutePosition();
|
||||
final IArea cropZone = widget.getCroppedZone();
|
||||
GL11.glEnable(3089);
|
||||
this.limitArea(new IArea(pos.add(cropZone.pos()), cropZone.size()));
|
||||
|
||||
}
|
||||
GL11.glDisable(2929);
|
||||
}
|
||||
|
||||
public final void postRender(final IWidget widget) {
|
||||
if (widget.isCroppedWidet()) {
|
||||
GL11.glDisable(3089);
|
||||
}
|
||||
GL11.glEnable(2929);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void colour(final int hex) {
|
||||
this.currentColour = hex;
|
||||
int a = (hex & 0xFF000000) >> 24;
|
||||
final int r = (hex & 0xFF0000) >> 16;
|
||||
final int g = (hex & 0xFF00) >> 8;
|
||||
final int b = hex & 0xFF;
|
||||
if (a < 0) {
|
||||
a += 256;
|
||||
}
|
||||
if (a > 0 && a != 255) {
|
||||
GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||
GL11.glEnable(3042);
|
||||
}
|
||||
else {
|
||||
GL11.glColor3f(r / 255.0f, g / 255.0f, b / 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public Texture getTexture(final Object key) {
|
||||
if (key instanceof Texture) {
|
||||
return (Texture) key;
|
||||
}
|
||||
return this.stylesheet.getTexture(key);
|
||||
}
|
||||
|
||||
public void setTexture(final Texture texture) {
|
||||
if (texture != this.currentTexture && texture != null) {
|
||||
BinnieCore.proxy.bindTexture(texture.getFilename());
|
||||
}
|
||||
this.colour(this.currentColour);
|
||||
}
|
||||
|
||||
public void texture(final Object texture, final IPoint position) {
|
||||
this.texture(this.getTexture(texture), position);
|
||||
}
|
||||
|
||||
public void texture(final Texture texture, final IPoint position) {
|
||||
if (texture == null) {
|
||||
return;
|
||||
}
|
||||
this.setTexture(texture);
|
||||
final IPoint point = position.sub(new IPoint(texture.getBorder().l(), texture.getBorder().t()));
|
||||
final IArea textureArea = texture.getArea().outset(texture.getBorder());
|
||||
this.gui.renderTexture(point, textureArea);
|
||||
}
|
||||
|
||||
public void texture(final Object window, final IArea area) {
|
||||
this.texture(this.getTexture(window), area);
|
||||
}
|
||||
|
||||
public void texture(final Texture texture, final IArea area) {
|
||||
if (texture == null) {
|
||||
return;
|
||||
}
|
||||
this.setTexture(texture);
|
||||
final IArea textureArea = texture.getArea().outset(texture.getBorder());
|
||||
final IArea targetArea = area.outset(texture.getBorder());
|
||||
if (textureArea.w() == targetArea.w() && textureArea.h() == targetArea.h()) {
|
||||
this.gui.renderTexture(targetArea.pos(), textureArea);
|
||||
}
|
||||
else {
|
||||
this.gui.renderTexturePadded(targetArea, textureArea, texture.getTotalPadding());
|
||||
}
|
||||
}
|
||||
|
||||
public void stylesheet(final IStyleSheet sheet) {
|
||||
this.stylesheet = sheet;
|
||||
}
|
||||
|
||||
public int textWidth(final String text) {
|
||||
return this.gui.getFontRenderer().getStringWidth(text);
|
||||
}
|
||||
|
||||
public int textHeight() {
|
||||
return (this.gui.getFontRenderer() == null) ? 0 : this.gui.getFontRenderer().FONT_HEIGHT;
|
||||
}
|
||||
|
||||
public void text(final IPoint pos, final String text, final int colour) {
|
||||
this.text(new IArea(pos, new IPoint(500.0f, 500.0f)), TextJustification.TopLeft, text, colour);
|
||||
}
|
||||
|
||||
public void text(final IArea area, final TextJustification justification, final String text, final int colour) {
|
||||
final IPoint pos = area.pos();
|
||||
if (area.size().x() <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
final List<String> wrappedStrings = this.gui.getFontRenderer().listFormattedStringToWidth(text, (int) area.size().x());
|
||||
final float totalHeight = wrappedStrings.size() * this.textHeight();
|
||||
float posY = area.pos().y();
|
||||
if (area.size().y() > totalHeight) {
|
||||
posY += (area.size().y() - totalHeight) * justification.getYOffset();
|
||||
}
|
||||
for (final String string : wrappedStrings) {
|
||||
final float stringWidth = this.textWidth(string);
|
||||
float posX = area.size().x() - stringWidth;
|
||||
posX *= justification.getXOffset();
|
||||
GL11.glDisable(2929);
|
||||
this.gui.getFontRenderer().drawString(string, (int) (pos.x() + posX), (int) posY, colour);
|
||||
posY += this.textHeight();
|
||||
}
|
||||
GL11.glColor3f(1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
public void solid(final IArea area, final int colour) {
|
||||
this.gui.drawRect(area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), 0xFF000000 | colour);
|
||||
}
|
||||
|
||||
public void solidAlpha(final IArea area, final int c1) {
|
||||
this.gui.drawGradientArea(area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), c1, c1);
|
||||
}
|
||||
|
||||
public void gradientRect(final IArea area, final int c1, final int c2) {
|
||||
this.gui.drawGradientArea(area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), c1, c2);
|
||||
}
|
||||
|
||||
public void item(final IPoint pos, final ItemStack item) {
|
||||
this.gui.renderItem(pos, item, false);
|
||||
}
|
||||
|
||||
public void item(final IPoint pos, final ItemStack item, final boolean rotating) {
|
||||
this.gui.renderItem(pos, item, rotating);
|
||||
}
|
||||
|
||||
public void iconBlock(final IPoint pos, final IIcon icon) {
|
||||
this.gui.renderIcon(pos, icon, TextureMap.locationBlocksTexture);
|
||||
}
|
||||
|
||||
public void iconItem(final IPoint pos, final IIcon icon) {
|
||||
this.gui.renderIcon(pos, icon, TextureMap.locationItemsTexture);
|
||||
}
|
||||
|
||||
public void limitArea(final IArea area) {
|
||||
this.gui.limitArea(area);
|
||||
}
|
||||
|
||||
public float textHeight(final String text, final float width) {
|
||||
return this.gui.getFontRenderer().listFormattedStringToWidth(text, (int) width).size() * this.textHeight();
|
||||
}
|
||||
|
||||
public void texturePercentage(final Texture texture, final IArea area, final Position direction, final float percentage) {
|
||||
final float dist = (direction == Position.Top || direction == Position.Bottom) ? (percentage * texture.h()) : (percentage * texture.w());
|
||||
final float dim = (direction == Position.Top || direction == Position.Bottom) ? texture.h() : texture.w();
|
||||
float x = area.pos().x();
|
||||
float y = area.pos().y();
|
||||
float w = area.size().x();
|
||||
float h = area.size().y();
|
||||
switch (direction) {
|
||||
case Top: {
|
||||
h *= percentage;
|
||||
break;
|
||||
}
|
||||
case Right: {
|
||||
x += (1.0f - percentage) * w;
|
||||
w *= percentage;
|
||||
break;
|
||||
}
|
||||
case Left: {
|
||||
w *= percentage;
|
||||
break;
|
||||
}
|
||||
case Bottom: {
|
||||
y += h - (int) (percentage * h);
|
||||
h *= percentage;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.texture(texture.crop(direction, dim - dist), new IArea(x, y, w, h));
|
||||
}
|
||||
|
||||
public void test(final IWidget widget) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.renderer;
|
||||
|
||||
public enum TextureType
|
||||
{
|
||||
Stretched,
|
||||
Tiled;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class Event
|
||||
{
|
||||
IWidget origin;
|
||||
|
||||
public Event(final IWidget origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
public IWidget getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
public boolean isOrigin(final IWidget widget) {
|
||||
return this.origin == widget;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class EventButtonClicked extends Event
|
||||
{
|
||||
public EventButtonClicked(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<EventButtonClicked>
|
||||
{
|
||||
public Handler() {
|
||||
super(EventButtonClicked.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class EventCycleChanged extends Event
|
||||
{
|
||||
public int value;
|
||||
|
||||
public EventCycleChanged(final IWidget origin, final int value) {
|
||||
super(origin);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public abstract class EventHandler<E extends Event>
|
||||
{
|
||||
Class<E> eventClass;
|
||||
Origin origin;
|
||||
IWidget relative;
|
||||
|
||||
public EventHandler(final Class<E> eventClass) {
|
||||
this.origin = Origin.Any;
|
||||
this.relative = null;
|
||||
this.eventClass = eventClass;
|
||||
}
|
||||
|
||||
public EventHandler setOrigin(final Origin origin, final IWidget relative) {
|
||||
this.origin = origin;
|
||||
this.relative = relative;
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract void onEvent(final E p0);
|
||||
|
||||
public final boolean handles(final Event e) {
|
||||
return this.eventClass.isInstance(e) && this.origin.isOrigin(e.getOrigin(), this.relative);
|
||||
}
|
||||
|
||||
public enum Origin
|
||||
{
|
||||
Any,
|
||||
Self,
|
||||
Parent,
|
||||
DirectChild;
|
||||
|
||||
public boolean isOrigin(final IWidget origin, final IWidget test) {
|
||||
switch (this) {
|
||||
case Any: {
|
||||
return true;
|
||||
}
|
||||
case DirectChild: {
|
||||
return test.getWidgets().contains(origin);
|
||||
}
|
||||
case Parent: {
|
||||
return test.getParent() == origin;
|
||||
}
|
||||
case Self: {
|
||||
return test == origin;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public abstract class EventKey extends Event
|
||||
{
|
||||
char character;
|
||||
int key;
|
||||
|
||||
public EventKey(final IWidget origin, final char character, final int key) {
|
||||
super(origin);
|
||||
this.character = character;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public char getCharacter() {
|
||||
return this.character;
|
||||
}
|
||||
|
||||
public int getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public static class Down extends EventKey
|
||||
{
|
||||
public Down(final IWidget origin, final char character, final int key) {
|
||||
super(origin, character, key);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Down>
|
||||
{
|
||||
public Handler() {
|
||||
super(Down.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Up extends EventKey
|
||||
{
|
||||
public Up(final IWidget origin, final char character, final int key) {
|
||||
super(origin, character, key);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Up>
|
||||
{
|
||||
public Handler() {
|
||||
super(Up.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public abstract class EventMouse extends Event
|
||||
{
|
||||
public EventMouse(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public static class Button extends EventMouse
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int button;
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getButton() {
|
||||
return this.button;
|
||||
}
|
||||
|
||||
public Button(final IWidget currentMousedOverWidget, final int x, final int y, final int button) {
|
||||
super(currentMousedOverWidget);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.button = button;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Down extends Button
|
||||
{
|
||||
public Down(final IWidget currentMousedOverWidget, final int x, final int y, final int button) {
|
||||
super(currentMousedOverWidget, x, y, button);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Down>
|
||||
{
|
||||
public Handler() {
|
||||
super(Down.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Up extends Button
|
||||
{
|
||||
public Up(final IWidget currentMousedOverWidget, final int x, final int y, final int button) {
|
||||
super(currentMousedOverWidget, x, y, button);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Up>
|
||||
{
|
||||
public Handler() {
|
||||
super(Up.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Move extends EventMouse
|
||||
{
|
||||
float dx;
|
||||
float dy;
|
||||
|
||||
public float getDx() {
|
||||
return this.dx;
|
||||
}
|
||||
|
||||
public float getDy() {
|
||||
return this.dy;
|
||||
}
|
||||
|
||||
public Move(final IWidget origin, final float dx, final float dy) {
|
||||
super(origin);
|
||||
this.dx = dx;
|
||||
this.dy = dy;
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Move>
|
||||
{
|
||||
public Handler() {
|
||||
super(Move.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Drag extends Move
|
||||
{
|
||||
public Drag(final IWidget draggedWidget, final float dx, final float dy) {
|
||||
super(draggedWidget, dx, dy);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Drag>
|
||||
{
|
||||
public Handler() {
|
||||
super(Drag.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Wheel extends EventMouse
|
||||
{
|
||||
int dWheel;
|
||||
|
||||
public Wheel(final IWidget origin, final int dWheel) {
|
||||
super(origin);
|
||||
this.dWheel = 0;
|
||||
this.dWheel = dWheel / 28;
|
||||
}
|
||||
|
||||
public int getDWheel() {
|
||||
return this.dWheel;
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Wheel>
|
||||
{
|
||||
public Handler() {
|
||||
super(Wheel.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class EventTextEdit extends EventValueChanged<String>
|
||||
{
|
||||
public EventTextEdit(final IWidget origin, final String text) {
|
||||
super(origin, text);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<EventTextEdit>
|
||||
{
|
||||
public Handler() {
|
||||
super(EventTextEdit.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class EventToggleButtonClicked extends Event
|
||||
{
|
||||
boolean toggled;
|
||||
|
||||
public EventToggleButtonClicked(final IWidget origin, final boolean toggled) {
|
||||
super(origin);
|
||||
this.toggled = toggled;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return this.toggled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class EventValueChanged<T> extends Event
|
||||
{
|
||||
public T value;
|
||||
|
||||
public EventValueChanged(final IWidget origin, final T value) {
|
||||
super(origin);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<EventValueChanged>
|
||||
{
|
||||
public Handler() {
|
||||
super(EventValueChanged.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class EventValuesChanged<T> extends Event
|
||||
{
|
||||
public T[] values;
|
||||
|
||||
public EventValuesChanged(final IWidget origin, final T[] values) {
|
||||
super(origin);
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public T[] getValues() {
|
||||
return this.values;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.events;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class EventWidget extends Event
|
||||
{
|
||||
public EventWidget(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public static class Enable extends EventWidget
|
||||
{
|
||||
public Enable(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Enable>
|
||||
{
|
||||
public Handler() {
|
||||
super(Enable.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Disable extends EventWidget
|
||||
{
|
||||
public Disable(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Disable>
|
||||
{
|
||||
public Handler() {
|
||||
super(Disable.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Show extends EventWidget
|
||||
{
|
||||
public Show(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Show>
|
||||
{
|
||||
public Handler() {
|
||||
super(Show.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Hide extends EventWidget
|
||||
{
|
||||
public Hide(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Hide>
|
||||
{
|
||||
public Handler() {
|
||||
super(Hide.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChangePosition extends EventWidget
|
||||
{
|
||||
public ChangePosition(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<ChangePosition>
|
||||
{
|
||||
public Handler() {
|
||||
super(ChangePosition.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChangeSize extends EventWidget
|
||||
{
|
||||
public ChangeSize(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<ChangeSize>
|
||||
{
|
||||
public Handler() {
|
||||
super(ChangeSize.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChangeOffset extends EventWidget
|
||||
{
|
||||
public ChangeOffset(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<ChangeOffset>
|
||||
{
|
||||
public Handler() {
|
||||
super(ChangeOffset.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChangeColour extends EventWidget
|
||||
{
|
||||
public ChangeColour(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<ChangeColour>
|
||||
{
|
||||
public Handler() {
|
||||
super(ChangeColour.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class StartMouseOver extends EventWidget
|
||||
{
|
||||
public StartMouseOver(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<StartMouseOver>
|
||||
{
|
||||
public Handler() {
|
||||
super(StartMouseOver.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class EndMouseOver extends EventWidget
|
||||
{
|
||||
public EndMouseOver(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<EndMouseOver>
|
||||
{
|
||||
public Handler() {
|
||||
super(EndMouseOver.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class StartDrag extends EventWidget
|
||||
{
|
||||
int button;
|
||||
|
||||
public StartDrag(final IWidget origin, final int button) {
|
||||
super(origin);
|
||||
this.button = button;
|
||||
}
|
||||
|
||||
public int getButton() {
|
||||
return this.button;
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<StartDrag>
|
||||
{
|
||||
public Handler() {
|
||||
super(StartDrag.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class EndDrag extends EventWidget
|
||||
{
|
||||
public EndDrag(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<EndDrag>
|
||||
{
|
||||
public Handler() {
|
||||
super(EndDrag.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class GainFocus extends EventWidget
|
||||
{
|
||||
public GainFocus(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<GainFocus>
|
||||
{
|
||||
public Handler() {
|
||||
super(GainFocus.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LoseFocus extends EventWidget
|
||||
{
|
||||
public LoseFocus(final IWidget origin) {
|
||||
super(origin);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<LoseFocus>
|
||||
{
|
||||
public Handler() {
|
||||
super(LoseFocus.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import net.minecraft.util.IIcon;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlBlockIconDisplay extends Control
|
||||
{
|
||||
IIcon icon;
|
||||
|
||||
public ControlBlockIconDisplay(final IWidget parent, final float x, final float y, final IIcon icon) {
|
||||
super(parent, x, y, 18.0f, 18.0f);
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.iconBlock(IPoint.ZERO, this.icon);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.util.ItemStackSet;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.extratrees.machines.Brewery;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.minecraft.control.ControlProgressBase;
|
||||
|
||||
public class ControlBreweryProgress extends ControlProgressBase
|
||||
{
|
||||
static Texture Brewery;
|
||||
static Texture BreweryOverlay;
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.texture(ControlBreweryProgress.Brewery, new IPoint(0.0f, 0.0f));
|
||||
final Brewery.ComponentBreweryLogic logic = Machine.getInterface(Brewery.ComponentBreweryLogic.class, Window.get(this).getInventory());
|
||||
if (logic.currentCrafting == null) {
|
||||
return;
|
||||
}
|
||||
if (logic.currentCrafting.currentInput == null) {
|
||||
return;
|
||||
}
|
||||
final int fermentedHeight = (int) (32.0f * logic.getProgress() / 100.0f);
|
||||
CraftGUI.Render.limitArea(new IArea(new IPoint(1.0f, 6.0f).add(this.getAbsolutePosition()), new IPoint(32.0f, 32 - fermentedHeight)));
|
||||
GL11.glEnable(3089);
|
||||
this.renderFluid(logic.currentCrafting.currentInput, new IPoint(1.0f, 6.0f));
|
||||
this.renderFluid(logic.currentCrafting.currentInput, new IPoint(17.0f, 6.0f));
|
||||
this.renderFluid(logic.currentCrafting.currentInput, new IPoint(1.0f, 22.0f));
|
||||
this.renderFluid(logic.currentCrafting.currentInput, new IPoint(17.0f, 22.0f));
|
||||
GL11.glDisable(3089);
|
||||
CraftGUI.Render.limitArea(new IArea(new IPoint(1.0f, 38 - fermentedHeight).add(this.getAbsolutePosition()), new IPoint(32.0f, fermentedHeight)));
|
||||
GL11.glEnable(3089);
|
||||
this.renderFluid(binnie.extratrees.machines.Brewery.getOutput(logic.currentCrafting), new IPoint(1.0f, 6.0f));
|
||||
this.renderFluid(binnie.extratrees.machines.Brewery.getOutput(logic.currentCrafting), new IPoint(17.0f, 6.0f));
|
||||
this.renderFluid(binnie.extratrees.machines.Brewery.getOutput(logic.currentCrafting), new IPoint(1.0f, 22.0f));
|
||||
this.renderFluid(binnie.extratrees.machines.Brewery.getOutput(logic.currentCrafting), new IPoint(17.0f, 22.0f));
|
||||
GL11.glDisable(3089);
|
||||
final ItemStackSet stacks = new ItemStackSet();
|
||||
for (final ItemStack stack : logic.currentCrafting.inputs) {
|
||||
stacks.add(stack);
|
||||
}
|
||||
stacks.add(logic.currentCrafting.ingr);
|
||||
int x = 1;
|
||||
int y = 6;
|
||||
for (final ItemStack stack : stacks) {
|
||||
CraftGUI.Render.item(new IPoint(x, y), stack);
|
||||
x += 16;
|
||||
if (x > 18) {
|
||||
x = 1;
|
||||
y += 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
}
|
||||
|
||||
protected ControlBreweryProgress(final IWidget parent, final float x, final float y) {
|
||||
super(parent, x, y, 34.0f, 39.0f);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
public void renderFluid(final FluidStack fluid, final IPoint pos) {
|
||||
final int hex = fluid.getFluid().getColor(fluid);
|
||||
final int r = (hex & 0xFF0000) >> 16;
|
||||
final int g = (hex & 0xFF00) >> 8;
|
||||
final int b = hex & 0xFF;
|
||||
final IIcon icon = fluid.getFluid().getIcon();
|
||||
GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
CraftGUI.Render.iconBlock(pos, fluid.getFluid().getIcon());
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
|
||||
static {
|
||||
ControlBreweryProgress.Brewery = new StandardTexture(0, 69, 34, 39, ExtraTreeTexture.Gui);
|
||||
ControlBreweryProgress.BreweryOverlay = new StandardTexture(34, 69, 34, 39, ExtraTreeTexture.Gui);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import net.minecraft.util.IIcon;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.extratrees.machines.Distillery;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.minecraft.control.ControlProgressBase;
|
||||
|
||||
public class ControlDistilleryProgress extends ControlProgressBase
|
||||
{
|
||||
static Texture DistilleryBase;
|
||||
static Texture DistilleryOverlay;
|
||||
static Texture LiquidFlow;
|
||||
static Texture Output;
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.texture(ControlDistilleryProgress.DistilleryBase, new IPoint(0.0f, 0.0f));
|
||||
CraftGUI.Render.texturePercentage(ControlDistilleryProgress.LiquidFlow, new IArea(18.0f, 0.0f, 38.0f, 66.0f), Position.Left, this.progress);
|
||||
final Distillery.ComponentDistilleryLogic component = Machine.getInterface(Distillery.ComponentDistilleryLogic.class, Window.get(this).getInventory());
|
||||
FluidStack stack = null;
|
||||
if (component != null) {
|
||||
stack = component.currentFluid;
|
||||
}
|
||||
if (stack != null) {
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
this.renderFluid(stack, new IPoint(1.0f, 1 + y * 16));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
final int level = Machine.getInterface(Distillery.ComponentDistilleryLogic.class, Window.get(this).getInventory()).level;
|
||||
CraftGUI.Render.texture(ControlDistilleryProgress.Output, new IPoint(47.0f, 14 + level * 15));
|
||||
CraftGUI.Render.texture(ControlDistilleryProgress.DistilleryOverlay, new IPoint(0.0f, 0.0f));
|
||||
}
|
||||
|
||||
protected ControlDistilleryProgress(final IWidget parent, final float x, final float y) {
|
||||
super(parent, x, y, 58.0f, 66.0f);
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
int distillationLevel = -1;
|
||||
if (new IArea(45.0f, 8.0f, 19.0f, 11.0f).contains(ControlDistilleryProgress.this.getRelativeMousePosition())) {
|
||||
distillationLevel = 0;
|
||||
}
|
||||
else if (new IArea(45.0f, 23.0f, 19.0f, 11.0f).contains(ControlDistilleryProgress.this.getRelativeMousePosition())) {
|
||||
distillationLevel = 1;
|
||||
}
|
||||
else if (new IArea(45.0f, 38.0f, 19.0f, 11.0f).contains(ControlDistilleryProgress.this.getRelativeMousePosition())) {
|
||||
distillationLevel = 2;
|
||||
}
|
||||
if (distillationLevel >= 0) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setByte("i", (byte) distillationLevel);
|
||||
Window.get(ControlDistilleryProgress.this.getWidget()).sendClientAction("still-level", nbt);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void renderFluid(final FluidStack fluid, final IPoint pos) {
|
||||
final int hex = fluid.getFluid().getColor(fluid);
|
||||
final int r = (hex & 0xFF0000) >> 16;
|
||||
final int g = (hex & 0xFF00) >> 8;
|
||||
final int b = hex & 0xFF;
|
||||
final IIcon icon = fluid.getFluid().getIcon();
|
||||
GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
CraftGUI.Render.iconBlock(pos, fluid.getFluid().getIcon());
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
|
||||
static {
|
||||
ControlDistilleryProgress.DistilleryBase = new StandardTexture(43, 0, 58, 66, ExtraTreeTexture.Gui);
|
||||
ControlDistilleryProgress.DistilleryOverlay = new StandardTexture(139, 0, 18, 66, ExtraTreeTexture.Gui);
|
||||
ControlDistilleryProgress.LiquidFlow = new StandardTexture(101, 0, 38, 66, ExtraTreeTexture.Gui);
|
||||
ControlDistilleryProgress.Output = new StandardTexture(68, 66, 17, 7, ExtraTreeTexture.Gui);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import binnie.extratrees.machines.Press;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.minecraft.control.ControlProgressBase;
|
||||
|
||||
public class ControlFruitPressProgress extends ControlProgressBase
|
||||
{
|
||||
static Texture PressTexture;
|
||||
static Texture PressSlot;
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.texture(ControlFruitPressProgress.PressSlot, new IPoint(3.0f, 52.0f));
|
||||
final ItemStack input = Window.get(this).getContainer().getSlotFromInventory(Window.get(this).getInventory(), Press.slotCurrent).getStack();
|
||||
if (input == null || Press.getOutput(input) == null) {
|
||||
return;
|
||||
}
|
||||
final Fluid fluid = Press.getOutput(input).getFluid();
|
||||
final int hex = fluid.getColor(Press.getOutput(input));
|
||||
final int r = (hex & 0xFF0000) >> 16;
|
||||
final int g = (hex & 0xFF00) >> 8;
|
||||
final int b = hex & 0xFF;
|
||||
IIcon icon = fluid.getIcon();
|
||||
GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
CraftGUI.Render.iconBlock(new IPoint(4.0f, 52.0f), fluid.getIcon());
|
||||
GL11.glDisable(3042);
|
||||
icon = input.getIconIndex();
|
||||
CraftGUI.Render.iconItem(new IPoint(4.0f, 52.0f), icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
CraftGUI.Render.texture(ControlFruitPressProgress.PressTexture, new IPoint(0.0f, 16.0f * this.progress));
|
||||
}
|
||||
|
||||
protected ControlFruitPressProgress(final IWidget parent, final float x, final float y) {
|
||||
super(parent, x, y, 37.0f, 69.0f);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
if (event.getButton() == 0) {
|
||||
final NBTTagCompound action = new NBTTagCompound();
|
||||
Window.get(ControlFruitPressProgress.this.getWidget()).sendClientAction("fruitpress-click", action);
|
||||
}
|
||||
else if (event.getButton() == 1) {
|
||||
final NBTTagCompound action = new NBTTagCompound();
|
||||
Window.get(ControlFruitPressProgress.this.getWidget()).sendClientAction("clear-fruit", action);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
ControlFruitPressProgress.PressTexture = new StandardTexture(6, 0, 24, 52, ExtraTreeTexture.Gui);
|
||||
ControlFruitPressProgress.PressSlot = new StandardTexture(9, 52, 34, 17, ExtraTreeTexture.Gui);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import binnie.craftgui.minecraft.MinecraftGUI;
|
||||
import binnie.craftgui.window.Panel;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import binnie.extratrees.machines.Lumbermill;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.minecraft.control.ControlProgressBase;
|
||||
|
||||
public class ControlLumbermillProgress extends ControlProgressBase
|
||||
{
|
||||
float oldProgress;
|
||||
float animation;
|
||||
static Texture Saw;
|
||||
static Texture Saw2;
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
if (this.oldProgress != this.progress) {
|
||||
this.oldProgress = this.progress;
|
||||
this.animation += 5.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
GL11.glDisable(2896);
|
||||
final int sawX = (int) (63.0f * this.progress);
|
||||
CraftGUI.Render.texture(ControlLumbermillProgress.Saw, new IPoint(sawX, -8.0f + 6.0f * (float) Math.sin(this.animation)));
|
||||
final ItemStack item = Window.get(this).getInventory().getStackInSlot(Lumbermill.slotWood);
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
GL11.glDisable(2896);
|
||||
Block block = null;
|
||||
if (item.getItem() instanceof ItemBlock) {
|
||||
block = ((ItemBlock) item.getItem()).field_150939_a;
|
||||
}
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
final IIcon icon = block.getIcon(2, item.getItemDamage());
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
CraftGUI.Render.iconBlock(new IPoint(1 + i * 16, 1.0f), icon);
|
||||
}
|
||||
final ItemStack result = Lumbermill.getPlankProduct(item);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
Block block2 = null;
|
||||
if (item.getItem() instanceof ItemBlock) {
|
||||
block2 = ((ItemBlock) result.getItem()).field_150939_a;
|
||||
}
|
||||
if (block2 == null) {
|
||||
return;
|
||||
}
|
||||
final IIcon icon2 = block2.getIcon(2, result.getItemDamage());
|
||||
final IPoint size = this.getSize();
|
||||
final IPoint pos = this.getAbsolutePosition();
|
||||
CraftGUI.Render.limitArea(new IArea(pos.add(new IPoint(0.0f, 0.0f)), new IPoint(this.progress * 64.0f + 2.0f, 18.0f)));
|
||||
GL11.glEnable(3089);
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
CraftGUI.Render.iconBlock(new IPoint(1 + j * 16, 1.0f), icon2);
|
||||
}
|
||||
GL11.glDisable(3089);
|
||||
CraftGUI.Render.texture(ControlLumbermillProgress.Saw2, new IPoint(sawX + 2, -8.0f + 6.0f * (float) Math.sin(this.animation)));
|
||||
}
|
||||
|
||||
protected ControlLumbermillProgress(final IWidget parent, final float x, final float y) {
|
||||
super(parent, x, y, 66.0f, 18.0f);
|
||||
this.oldProgress = 0.0f;
|
||||
this.animation = 0.0f;
|
||||
new Panel(this, 0.0f, 0.0f, 66.0f, 18.0f, MinecraftGUI.PanelType.Black);
|
||||
}
|
||||
|
||||
static {
|
||||
ControlLumbermillProgress.Saw = new StandardTexture(0, 0, 6, 32, ExtraTreeTexture.Gui);
|
||||
ControlLumbermillProgress.Saw2 = new StandardTexture(2, 0, 4, 32, ExtraTreeTexture.Gui);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.component.IComponentRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.control.ControlSlotBase;
|
||||
|
||||
public class ControlRecipeSlot extends ControlSlotBase
|
||||
{
|
||||
public ControlRecipeSlot(final IWidget parent, final int x, final int y) {
|
||||
super(parent, x, y, 50);
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
final TileEntity tile = (TileEntity) Window.get(ControlRecipeSlot.this.getWidget()).getInventory();
|
||||
if (tile == null || !(tile instanceof TileEntityMachine)) {
|
||||
return;
|
||||
}
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
Window.get(ControlRecipeSlot.this.getWidget()).sendClientAction("recipe", nbt);
|
||||
}
|
||||
});
|
||||
this.setRotating();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
final IComponentRecipe recipe = Machine.getInterface(IComponentRecipe.class, Window.get(this).getInventory());
|
||||
return recipe.isRecipe() ? recipe.getProduct() : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.Binnie;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import java.util.Map;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import binnie.extratrees.api.IDesignCategory;
|
||||
import java.util.HashMap;
|
||||
import binnie.extratrees.machines.Designer;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.extratrees.carpentry.EnumDesign;
|
||||
import binnie.extratrees.api.CarpentryManager;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.scroll.IControlScrollable;
|
||||
import binnie.extratrees.api.IDesign;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlTileSelect extends Control implements IControlValue<IDesign>, IControlScrollable
|
||||
{
|
||||
IDesign value;
|
||||
float shownHeight;
|
||||
|
||||
protected ControlTileSelect(final IWidget parent, final float x, final float y) {
|
||||
super(parent, x, y, 102.0f, 20 * (CarpentryManager.carpentryInterface.getSortedDesigns().size() / 4) + 22);
|
||||
this.value = EnumDesign.Blank;
|
||||
this.shownHeight = 92.0f;
|
||||
this.refresh("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPercentageIndex() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPercentageShown() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesign getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void movePercentage(final float percentage) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
final TileEntityMachine tile = (TileEntityMachine) Window.get(this).getInventory();
|
||||
if (tile == null) {
|
||||
return;
|
||||
}
|
||||
final Designer.ComponentWoodworkerRecipe recipe = tile.getMachine().getComponent(Designer.ComponentWoodworkerRecipe.class);
|
||||
this.setValue(recipe.getDesign());
|
||||
}
|
||||
|
||||
public void refresh(final String filterText) {
|
||||
this.deleteAllChildren();
|
||||
int cx = 2;
|
||||
int cy = 2;
|
||||
final Map<IDesignCategory, List<IDesign>> designs = new HashMap<IDesignCategory, List<IDesign>>();
|
||||
for (final IDesignCategory category : CarpentryManager.carpentryInterface.getAllDesignCategories()) {
|
||||
designs.put(category, new ArrayList<IDesign>());
|
||||
for (final IDesign tile : category.getDesigns()) {
|
||||
if (filterText == "" || tile.getName().toLowerCase().contains(filterText)) {
|
||||
designs.get(category).add(tile);
|
||||
}
|
||||
}
|
||||
if (designs.get(category).isEmpty()) {
|
||||
designs.remove(category);
|
||||
}
|
||||
}
|
||||
for (final IDesignCategory category : designs.keySet()) {
|
||||
cx = 2;
|
||||
new ControlText(this, new IPoint(cx, cy + 3), category.getName());
|
||||
cy += 16;
|
||||
for (final IDesign tile : designs.get(category)) {
|
||||
if (cx > 90) {
|
||||
cx = 2;
|
||||
cy += 20;
|
||||
}
|
||||
new ControlTile(this, cx, cy, tile);
|
||||
cx += 20;
|
||||
}
|
||||
cy += 20;
|
||||
}
|
||||
final int height = cy;
|
||||
this.setSize(new IPoint(this.getSize().x(), height));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPercentageIndex(final float index) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final IDesign value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMovementRange() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public static class ControlTile extends Control implements IControlValue<IDesign>, ITooltip
|
||||
{
|
||||
IDesign value;
|
||||
|
||||
protected ControlTile(final IWidget parent, final float x, final float y, final IDesign value) {
|
||||
super(parent, x, y, 18.0f, 18.0f);
|
||||
this.setValue(value);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
final TileEntityMachine tile = (TileEntityMachine) Window.get(ControlTile.this.getWidget()).getInventory();
|
||||
if (tile == null) {
|
||||
return;
|
||||
}
|
||||
final Designer.ComponentWoodworkerRecipe recipe = tile.getMachine().getComponent(Designer.ComponentWoodworkerRecipe.class);
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setShort("d", (short) CarpentryManager.carpentryInterface.getDesignIndex(ControlTile.this.getValue()));
|
||||
Window.get(ControlTile.this.getWidget()).sendClientAction("design", nbt);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
tooltip.add(Binnie.Language.localise(BinnieCore.instance, "gui.designer.pattern", this.getValue().getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesign getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.texture(CraftGUITexture.Slot, IPoint.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
final ItemStack image = ((WindowWoodworker) this.getSuperParent()).getDesignerType().getDisplayStack(this.getValue());
|
||||
CraftGUI.Render.item(new IPoint(1.0f, 1.0f), image);
|
||||
if (((IControlValue) this.getParent()).getValue() != this.getValue()) {
|
||||
if (Window.get(this).getMousedOverWidget() == this) {
|
||||
CraftGUI.Render.gradientRect(this.getArea().inset(1), 1157627903, 1157627903);
|
||||
}
|
||||
else {
|
||||
CraftGUI.Render.gradientRect(this.getArea().inset(1), -1433892728, -1433892728);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final IDesign value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.Dialog;
|
||||
|
||||
public class DialogBreweryRecipe extends Dialog
|
||||
{
|
||||
public DialogBreweryRecipe(final IWidget parent, final float w, final float h) {
|
||||
super(parent, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialise() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import java.util.Collection;
|
||||
import binnie.craftgui.mod.database.ControlSpeciesBox;
|
||||
import binnie.core.genetics.TreeBreedingSystem;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.mod.database.WindowAbstractDatabase;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.craftgui.mod.database.PageAbstract;
|
||||
|
||||
public class PageFruit extends PageAbstract<ItemStack>
|
||||
{
|
||||
boolean treesThatBearFruit;
|
||||
|
||||
public PageFruit(final IWidget parent, final DatabaseTab tab, final boolean treesThatBearFruit) {
|
||||
super(parent, tab);
|
||||
this.treesThatBearFruit = treesThatBearFruit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final ItemStack species) {
|
||||
this.deleteAllChildren();
|
||||
final WindowAbstractDatabase database = Window.get(this);
|
||||
new ControlText(this, new IArea(0.0f, 0.0f, this.size().x(), 24.0f), ExtraTrees.proxy.localise("gui.database.tab.fruit." + (this.treesThatBearFruit ? "natural" : "potential")), TextJustification.MiddleCenter);
|
||||
final Collection<IAlleleSpecies> trees = this.treesThatBearFruit ? ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatBearFruit(species, database.isNEI(), database.getWorld(), database.getUsername()) : ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatCanBearFruit(species, database.isNEI(), database.getWorld(), database.getUsername());
|
||||
new ControlSpeciesBox(this, 4.0f, 24.0f, this.size().x() - 8.0f, this.size().y() - 4.0f - 24.0f).setOptions(trees);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.extratrees.block.IPlankType;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.extratrees.block.DoorType;
|
||||
import binnie.extratrees.block.decor.FenceType;
|
||||
import binnie.extratrees.block.WoodManager;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.mod.database.WindowAbstractDatabase;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.craftgui.mod.database.PageAbstract;
|
||||
|
||||
public class PagePlanksOverview extends PageAbstract<ItemStack>
|
||||
{
|
||||
public PagePlanksOverview(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final ItemStack species) {
|
||||
this.deleteAllChildren();
|
||||
final WindowAbstractDatabase database = Window.get(this);
|
||||
new ControlText(this, new IArea(0.0f, 0.0f, this.size().x(), 24.0f), species.getDisplayName(), TextJustification.MiddleCenter);
|
||||
new ControlText(this, new IArea(12.0f, 24.0f, this.size().x() - 24.0f, 24.0f), ExtraTrees.proxy.localise("gui.database.planks.use"), TextJustification.MiddleLeft);
|
||||
final IPlankType type = WoodManager.get(species);
|
||||
int x = 12;
|
||||
if (type != null) {
|
||||
final ItemStack fence = WoodManager.getFence(type, new FenceType(0), 1);
|
||||
final ItemStack gate = WoodManager.getGate(type);
|
||||
final ItemStack door = WoodManager.getDoor(type, DoorType.Standard);
|
||||
if (fence != null) {
|
||||
new ControlItemDisplay(this, x, 48.0f).setItemStack(fence);
|
||||
x += 22;
|
||||
}
|
||||
if (gate != null) {
|
||||
new ControlItemDisplay(this, x, 48.0f).setItemStack(gate);
|
||||
x += 22;
|
||||
}
|
||||
if (door != null) {
|
||||
new ControlItemDisplay(this, x, 48.0f).setItemStack(door);
|
||||
x += 22;
|
||||
}
|
||||
}
|
||||
final ControlText controlDescription = new ControlText(this, new IArea(8.0f, 84.0f, this.getSize().x() - 16.0f, 0.0f), "", TextJustification.MiddleCenter);
|
||||
final ControlText controlSignature = new ControlText(this, new IArea(8.0f, 84.0f, this.getSize().x() - 16.0f, 0.0f), "", TextJustification.BottomRight);
|
||||
String desc = "";
|
||||
if (type != null) {
|
||||
desc = type.getDescription();
|
||||
}
|
||||
String descBody = "§o";
|
||||
String descSig = "";
|
||||
if (desc == null || desc.length() == 0) {
|
||||
descBody += BinnieCore.proxy.localise("gui.database.nodescription");
|
||||
}
|
||||
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];
|
||||
}
|
||||
}
|
||||
controlDescription.setValue(descBody + "§r");
|
||||
controlSignature.setValue(descSig + "§r");
|
||||
final float descHeight = CraftGUI.Render.textHeight(controlDescription.getValue(), controlDescription.getSize().x());
|
||||
controlSignature.setPosition(new IPoint(controlSignature.pos().x(), controlDescription.getPosition().y() + descHeight + 10.0f));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import java.util.Collection;
|
||||
import binnie.craftgui.mod.database.ControlSpeciesBox;
|
||||
import binnie.core.genetics.TreeBreedingSystem;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.mod.database.WindowAbstractDatabase;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.craftgui.mod.database.PageAbstract;
|
||||
|
||||
public class PagePlanksTrees extends PageAbstract<ItemStack>
|
||||
{
|
||||
public PagePlanksTrees(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final ItemStack species) {
|
||||
this.deleteAllChildren();
|
||||
final WindowAbstractDatabase database = Window.get(this);
|
||||
new ControlText(this, new IArea(0.0f, 0.0f, this.size().x(), 24.0f), species.getDisplayName(), TextJustification.MiddleCenter);
|
||||
final Collection<IAlleleSpecies> trees = ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatMakePlanks(species, database.isNEI(), database.getWorld(), database.getUsername());
|
||||
new ControlSpeciesBox(this, 4.0f, 24.0f, this.size().x() - 8.0f, this.size().y() - 4.0f - 24.0f).setOptions(trees);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.mod.database.EnumDiscoveryState;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.craftgui.minecraft.MinecraftGUI;
|
||||
import binnie.craftgui.window.Panel;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.mod.database.ControlDatabaseIndividualDisplay;
|
||||
import binnie.craftgui.mod.database.PageSpecies;
|
||||
|
||||
public class PageSpeciesImage extends PageSpecies
|
||||
{
|
||||
ControlDatabaseIndividualDisplay display;
|
||||
|
||||
public PageSpeciesImage(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
new Panel(this, 7.0f, 25.0f, 130.0f, 120.0f, MinecraftGUI.PanelType.Gray);
|
||||
this.display = new ControlDatabaseIndividualDisplay(this, 12.0f, 25.0f, 120.0f);
|
||||
this.display.hastooltip = false;
|
||||
new ControlTextCentered(this, 8.0f, this.getValue().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
this.display.setSpecies(species, EnumDiscoveryState.Show);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import forestry.api.arboriculture.IAlleleTreeSpecies;
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.FakeWorld;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import binnie.core.BinnieCore;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.Binnie;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.mod.database.PageSpecies;
|
||||
|
||||
public class PageSpeciesTreeGenome extends PageSpecies
|
||||
{
|
||||
public PageSpeciesTreeGenome(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
this.deleteAllChildren();
|
||||
final IAllele[] template = Binnie.Genetics.getTreeRoot().getTemplate(species.getUID());
|
||||
if (template == null) {
|
||||
return;
|
||||
}
|
||||
final ITree tree = Binnie.Genetics.getTreeRoot().templateAsIndividual(template);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack log = null;
|
||||
try {
|
||||
FakeWorld world = FakeWorld.instance;
|
||||
tree.getGenome().getPrimary().getGenerator().setLogBlock(tree.getGenome(), world, 0, 0, 0, ForgeDirection.UP);// getGenome().getPrimary().getGenerator().getWorldGenerator(tree);
|
||||
log = world.getWooLog();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
final ITreeGenome genome = tree.getGenome();
|
||||
final IAlleleTreeSpecies treeSpecies = genome.getPrimary();
|
||||
final int w = 144;
|
||||
final int h = 176;
|
||||
new ControlText(this, new IArea(0.0f, 4.0f, w, 16.0f), this.getValue().toString(), TextJustification.MiddleCenter);
|
||||
final ControlScrollableContent scrollable = new ControlScrollableContent(this, 4.0f, 20.0f, w - 8, h - 8 - 16, 12.0f);
|
||||
final Control contents = new Control(scrollable, 0.0f, 0.0f, w - 8 - 12, h - 8 - 16);
|
||||
final int tw = w - 8 - 12;
|
||||
final int w2 = 65;
|
||||
final int w3 = tw - 50;
|
||||
int y = 0;
|
||||
final int th = 14;
|
||||
final int th2 = 18;
|
||||
final BreedingSystem syst = Binnie.Genetics.treeBreedingSystem;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.PLANT) + " : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), treeSpecies.getPlantType().toString(), TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), BinnieCore.proxy.localise("gui.temperature.short") + " : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
final IIcon leaf = treeSpecies.getLeafIcon(false, false);
|
||||
IIcon fruit = null;
|
||||
int fruitColour = 16777215;
|
||||
try {
|
||||
fruit = ForestryAPI.textureManager.getIcon(genome.getFruitProvider().getIconIndex(genome, (IBlockAccess) null, 0, 0, 0, 100, false));
|
||||
fruitColour = genome.getFruitProvider().getColour(genome, (IBlockAccess) null, 0, 0, 0, 100);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (leaf != null) {
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th2), ExtraTrees.proxy.localise("gui.database.leaves") + " : ", TextJustification.MiddleRight);
|
||||
new ControlBlockIconDisplay(contents, w2, y, leaf).setColour(treeSpecies.getLeafColour(false));
|
||||
if (fruit != null && !treeSpecies.getUID().equals("forestry.treeOak")) {
|
||||
new ControlBlockIconDisplay(contents, w2, y, fruit).setColour(fruitColour);
|
||||
}
|
||||
y += th2;
|
||||
}
|
||||
// final ItemStack log = (genome.getFruitProvider().getProducts().length
|
||||
// > 0) ? genome.getFruitProvider().getProducts()[0] : null;
|
||||
if (log != null) {
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th2), ExtraTrees.proxy.localise("gui.database.log") + " : ", TextJustification.MiddleRight);
|
||||
final ControlItemDisplay display = new ControlItemDisplay(contents, w2, y);
|
||||
display.setItemStack(log);
|
||||
display.setTooltip();
|
||||
y += th2;
|
||||
}
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.GROWTH) + " : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), genome.getGrowthProvider().getDescription(), TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.HEIGHT) + " : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), genome.getHeight() + "x", TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.FERTILITY) + " : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
final List<ItemStack> fruits = new ArrayList<ItemStack>();
|
||||
for (final ItemStack stack : genome.getFruitProvider().getProducts()) {
|
||||
fruits.add(stack);
|
||||
}
|
||||
if (!fruits.isEmpty()) {
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th2), syst.getChromosomeShortName(EnumTreeChromosome.FRUITS) + " : ", TextJustification.MiddleRight);
|
||||
for (final ItemStack fruitw : fruits) {
|
||||
final ControlItemDisplay display2 = new ControlItemDisplay(contents, w2, y);
|
||||
display2.setItemStack(fruitw);
|
||||
display2.setTooltip();
|
||||
y += th2;
|
||||
}
|
||||
}
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.YIELD) + " : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), genome.getYield() + "x", TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.SAPPINESS) + " : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), genome.getSappiness() + "x", TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.MATURATION) + " : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), genome.getMaturationTime() + "x", TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
new ControlText(contents, new IArea(0.0f, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.GIRTH) + " : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new IArea(w2, y, w3, th), genome.getGirth() + "x" + genome.getGirth(), TextJustification.MiddleLeft);
|
||||
y += th;
|
||||
contents.setSize(new IPoint(contents.size().x(), y));
|
||||
scrollable.setScrollableContent(contents);
|
||||
}
|
||||
|
||||
public static String tolerated(final boolean t) {
|
||||
if (t) {
|
||||
return BinnieCore.proxy.localise("gui.tolerated");
|
||||
}
|
||||
return BinnieCore.proxy.localise("gui.nottolerated");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import java.util.Collection;
|
||||
import binnie.craftgui.mod.database.ControlSpeciesBox;
|
||||
import binnie.core.genetics.TreeBreedingSystem;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.mod.database.WindowAbstractDatabase;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.craftgui.mod.database.PageAbstract;
|
||||
|
||||
public class PageWood extends PageAbstract<ItemStack>
|
||||
{
|
||||
public PageWood(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final ItemStack species) {
|
||||
this.deleteAllChildren();
|
||||
final WindowAbstractDatabase database = Window.get(this);
|
||||
new ControlText(this, new IArea(0.0f, 0.0f, this.size().x(), 24.0f), this.getValue().toString(), TextJustification.MiddleCenter);
|
||||
final Collection<IAlleleSpecies> trees = ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatHaveWood(species, database.isNEI(), database.getWorld(), database.getUsername());
|
||||
new ControlSpeciesBox(this, 4.0f, 24.0f, this.size().x() - 8.0f, this.size().y() - 4.0f - 24.0f).setOptions(trees);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import binnie.core.genetics.TreeBreedingSystem;
|
||||
import binnie.craftgui.mod.database.ControlItemStackOption;
|
||||
import binnie.craftgui.controls.listbox.ControlList;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.mod.database.PageBreeder;
|
||||
import binnie.craftgui.mod.database.PageBranchSpecies;
|
||||
import binnie.craftgui.mod.database.PageBranchOverview;
|
||||
import binnie.craftgui.mod.database.PageSpeciesMutations;
|
||||
import binnie.craftgui.mod.database.PageSpeciesResultant;
|
||||
import binnie.craftgui.mod.database.PageSpeciesClassification;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.craftgui.mod.database.IDatabaseMode;
|
||||
import binnie.craftgui.mod.database.PageSpeciesOverview;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.Binnie;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.craftgui.controls.listbox.ControlListBox;
|
||||
import binnie.craftgui.mod.database.WindowAbstractDatabase;
|
||||
|
||||
public class WindowArboristDatabase extends WindowAbstractDatabase
|
||||
{
|
||||
ControlListBox<ItemStack> selectionBoxFruit;
|
||||
ControlListBox<ItemStack> selectionBoxWood;
|
||||
ControlListBox<ItemStack> selectionBoxPlanks;
|
||||
|
||||
public WindowArboristDatabase(final EntityPlayer player, final Side side, final boolean nei) {
|
||||
super(player, side, nei, Binnie.Genetics.treeBreedingSystem, 120.0f);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final Side side, final boolean nei) {
|
||||
return new WindowArboristDatabase(player, side, nei);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTabs() {
|
||||
new PageSpeciesOverview(this.getInfoPages(Mode.Species), new DatabaseTab(ExtraTrees.instance, "species.overview", 0));
|
||||
new PageSpeciesTreeGenome(this.getInfoPages(Mode.Species), new DatabaseTab(ExtraTrees.instance, "species.genome", 0));
|
||||
new PageSpeciesClassification(this.getInfoPages(Mode.Species), new DatabaseTab(ExtraTrees.instance, "species.classification", 0));
|
||||
new PageSpeciesResultant(this.getInfoPages(Mode.Species), new DatabaseTab(ExtraTrees.instance, "species.resultant", 0));
|
||||
new PageSpeciesMutations(this.getInfoPages(Mode.Species), new DatabaseTab(ExtraTrees.instance, "species.further", 0));
|
||||
new PageBranchOverview(this.getInfoPages(Mode.Branches), new DatabaseTab(ExtraTrees.instance, "branches.overview", 0));
|
||||
new PageBranchSpecies(this.getInfoPages(Mode.Branches), new DatabaseTab(ExtraTrees.instance, "branches.species", 0));
|
||||
new PageBreeder(this.getInfoPages(Mode.Breeder), this.getUsername(), new DatabaseTab(ExtraTrees.instance, "breeder", 0));
|
||||
this.createMode(TreeMode.Fruit, new ModeWidgets(TreeMode.Fruit, this) {
|
||||
@Override
|
||||
public void createListBox(final IArea area) {
|
||||
(this.listBox = new ControlListBox<ItemStack>(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) {
|
||||
@Override
|
||||
public IWidget createOption(final ItemStack value, final int y) {
|
||||
return new ControlItemStackOption(((ControlScrollableContent<ControlList<ItemStack>>) this).getContent(), value, y);
|
||||
}
|
||||
}).setOptions(((TreeBreedingSystem) WindowArboristDatabase.this.getBreedingSystem()).allFruits);
|
||||
}
|
||||
});
|
||||
this.createMode(TreeMode.Wood, new ModeWidgets(TreeMode.Wood, this) {
|
||||
@Override
|
||||
public void createListBox(final IArea area) {
|
||||
(this.listBox = new ControlListBox<ItemStack>(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) {
|
||||
@Override
|
||||
public IWidget createOption(final ItemStack value, final int y) {
|
||||
return new ControlItemStackOption(((ControlScrollableContent<ControlList<ItemStack>>) this).getContent(), value, y);
|
||||
}
|
||||
}).setOptions(((TreeBreedingSystem) WindowArboristDatabase.this.getBreedingSystem()).allWoods);
|
||||
}
|
||||
});
|
||||
this.createMode(TreeMode.Planks, new ModeWidgets(TreeMode.Planks, this) {
|
||||
@Override
|
||||
public void createListBox(final IArea area) {
|
||||
this.listBox = new ControlListBox<ItemStack>(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0f) {
|
||||
@Override
|
||||
public IWidget createOption(final ItemStack value, final int y) {
|
||||
return new ControlItemStackOption(((ControlScrollableContent<ControlList<ItemStack>>) this).getContent(), value, y);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
new PageFruit(this.getInfoPages(TreeMode.Fruit), new DatabaseTab(ExtraTrees.instance, "fruit.natural", 0), true);
|
||||
new PageFruit(this.getInfoPages(TreeMode.Fruit), new DatabaseTab(ExtraTrees.instance, "fruit.potential", 0), false);
|
||||
new PageWood(this.getInfoPages(TreeMode.Wood), new DatabaseTab(ExtraTrees.instance, "wood.natural", 0));
|
||||
new PagePlanksOverview(this.getInfoPages(TreeMode.Planks), new DatabaseTab(ExtraTrees.instance, "planks.overview", 0));
|
||||
new PagePlanksTrees(this.getInfoPages(TreeMode.Planks), new DatabaseTab(ExtraTrees.instance, "planks.natural", 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return ExtraTrees.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "TreeDatabase";
|
||||
}
|
||||
|
||||
enum TreeMode implements IDatabaseMode
|
||||
{
|
||||
Fruit,
|
||||
Wood,
|
||||
Planks;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ExtraTrees.proxy.localise("gui.database.mode." + this.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.minecraft.control.ControlErrorState;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.minecraft.control.ControlEnergyBar;
|
||||
import binnie.craftgui.minecraft.control.ControlLiquidTank;
|
||||
import binnie.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.extratrees.machines.Brewery;
|
||||
import binnie.craftgui.minecraft.control.ControlSlotArray;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.core.AbstractMod;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public class WindowBrewery extends Window
|
||||
{
|
||||
public WindowBrewery(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(228.0f, 218.0f, player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return ExtraTrees.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "Brewery";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
new ControlSlotArray(this, 42, 32, 1, 3).create(Brewery.slotRecipeGrains);
|
||||
new ControlSlot(this, 16.0f, 41.0f).assign(Brewery.slotRecipeInput);
|
||||
new ControlSlot(this, 105.0f, 77.0f).assign(Brewery.slotRecipeYeast);
|
||||
new ControlLiquidTank(this, 76, 32).setTankID(Brewery.tankInput);
|
||||
new ControlLiquidTank(this, 162, 32).setTankID(Brewery.tankOutput);
|
||||
new ControlEnergyBar(this, 196, 32, 16, 60, Position.Bottom);
|
||||
new ControlBreweryProgress(this, 110.0f, 32.0f);
|
||||
new ControlSlotArray(this, (int) (this.getSize().x() / 2.0f - 81.0f), 104, 9, 1).create(Brewery.slotInventory);
|
||||
new ControlPlayerInventory(this);
|
||||
new ControlErrorState(this, 133.0f, 79.0f);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
return new WindowBrewery(player, inventory, side);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.minecraft.control.ControlErrorState;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.minecraft.control.ControlEnergyBar;
|
||||
import binnie.extratrees.machines.Distillery;
|
||||
import binnie.craftgui.minecraft.control.ControlLiquidTank;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.core.AbstractMod;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public class WindowDistillery extends Window
|
||||
{
|
||||
public WindowDistillery(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(224.0f, 192.0f, player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return ExtraTrees.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "Distillery";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
int x = 16;
|
||||
new ControlLiquidTank(this, x, 35).setTankID(Distillery.tankInput);
|
||||
x += 34;
|
||||
new ControlDistilleryProgress(this, x, 32.0f);
|
||||
x += 64;
|
||||
new ControlLiquidTank(this, x, 35).setTankID(Distillery.tankOutput);
|
||||
x += 34;
|
||||
new ControlEnergyBar(this, x, 36, 60, 16, Position.Left);
|
||||
new ControlPlayerInventory(this);
|
||||
new ControlErrorState(this, x + 21, 62.0f);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
return new WindowDistillery(player, inventory, side);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.mod.database.PageBreeder;
|
||||
import binnie.craftgui.mod.database.PageBranchSpecies;
|
||||
import binnie.craftgui.mod.database.PageBranchOverview;
|
||||
import binnie.craftgui.mod.database.PageSpeciesMutations;
|
||||
import binnie.craftgui.mod.database.PageSpeciesResultant;
|
||||
import binnie.craftgui.mod.database.PageSpeciesClassification;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.craftgui.mod.database.DatabaseTab;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.craftgui.mod.database.PageSpeciesOverview;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.Binnie;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.craftgui.mod.database.WindowAbstractDatabase;
|
||||
|
||||
public class WindowLepidopteristDatabase extends WindowAbstractDatabase
|
||||
{
|
||||
public WindowLepidopteristDatabase(final EntityPlayer player, final Side side, final boolean nei) {
|
||||
super(player, side, nei, Binnie.Genetics.mothBreedingSystem, 160.0f);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final Side side, final boolean nei) {
|
||||
return new WindowLepidopteristDatabase(player, side, nei);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTabs() {
|
||||
new PageSpeciesOverview(this.getInfoPages(Mode.Species), new DatabaseTab(ExtraTrees.instance, "butterfly.species.overview", 0));
|
||||
new PageSpeciesClassification(this.getInfoPages(Mode.Species), new DatabaseTab(ExtraTrees.instance, "butterfly.species.classification", 0));
|
||||
new PageSpeciesImage(this.getInfoPages(Mode.Species), new DatabaseTab(ExtraTrees.instance, "butterfly.species.specimen", 0));
|
||||
new PageSpeciesResultant(this.getInfoPages(Mode.Species), new DatabaseTab(ExtraTrees.instance, "butterfly.species.resultant", 0));
|
||||
new PageSpeciesMutations(this.getInfoPages(Mode.Species), new DatabaseTab(ExtraTrees.instance, "butterfly.species.further", 0));
|
||||
new PageBranchOverview(this.getInfoPages(Mode.Branches), new DatabaseTab(ExtraTrees.instance, "butterfly.branches.overview", 0));
|
||||
new PageBranchSpecies(this.getInfoPages(Mode.Branches), new DatabaseTab(ExtraTrees.instance, "butterfly.branches.species", 0));
|
||||
new PageBreeder(this.getInfoPages(Mode.Breeder), this.getUsername(), new DatabaseTab(ExtraTrees.instance, "butterfly.breeder", 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return ExtraTrees.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "MothDatabase";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.craftgui.minecraft.control.ControlErrorState;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.minecraft.control.ControlEnergyBar;
|
||||
import binnie.craftgui.minecraft.control.ControlLiquidTank;
|
||||
import binnie.extratrees.machines.Lumbermill;
|
||||
import binnie.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.core.AbstractMod;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public class WindowLumbermill extends Window
|
||||
{
|
||||
public WindowLumbermill(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(220.0f, 192.0f, player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return ExtraTrees.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "Lumbermill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
new ControlSlot(this, 42.0f, 43.0f).assign(Lumbermill.slotWood);
|
||||
new ControlSlot(this, 148.0f, 43.0f).assign(Lumbermill.slotPlanks);
|
||||
new ControlSlot(this, 172.0f, 28.0f).assign(Lumbermill.slotBark);
|
||||
new ControlSlot(this, 172.0f, 58.0f).assign(Lumbermill.slotSawdust);
|
||||
new ControlLumbermillProgress(this, 70.0f, 43.0f);
|
||||
new ControlLiquidTank(this, 16, 32);
|
||||
new ControlEnergyBar(this, 8, 112, 16, 60, Position.Bottom);
|
||||
new ControlPlayerInventory(this);
|
||||
new ControlErrorState(this, 95.0f, 73.0f);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
return new WindowLumbermill(player, inventory, side);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.craftgui.minecraft.InventoryType;
|
||||
import binnie.craftgui.minecraft.control.ControlErrorState;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.minecraft.control.ControlEnergyBar;
|
||||
import binnie.craftgui.minecraft.control.ControlLiquidTank;
|
||||
import binnie.extratrees.machines.Press;
|
||||
import binnie.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.core.AbstractMod;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public class WindowPress extends Window
|
||||
{
|
||||
public WindowPress(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(194.0f, 192.0f, player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return ExtraTrees.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "Press";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
new ControlSlot(this, 24.0f, 52.0f).assign(Press.slotFruit);
|
||||
new ControlLiquidTank(this, 99, 32).setTankID(Press.tankWater);
|
||||
new ControlEnergyBar(this, 154, 32, 16, 60, Position.Bottom);
|
||||
new ControlPlayerInventory(this);
|
||||
new ControlErrorState(this, 128.0f, 54.0f);
|
||||
new ControlFruitPressProgress(this, 62.0f, 24.0f);
|
||||
((Window) this.getSuperParent()).getContainer().getOrCreateSlot(InventoryType.Machine, Press.slotCurrent);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
return new WindowPress(player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound action) {
|
||||
final Press.ComponentFruitPressLogic logic = Machine.getInterface(Press.ComponentFruitPressLogic.class, this.getInventory());
|
||||
super.recieveGuiNBT(side, player, name, action);
|
||||
if (side == Side.SERVER && name.equals("fruitpress-click")) {
|
||||
if (logic.canWork() == null && (logic.canProgress() == null || logic.canProgress() instanceof ErrorState.InsufficientPower)) {
|
||||
logic.alterProgress(2.0f);
|
||||
}
|
||||
else if (side == Side.SERVER && name.equals("clear-fruit")) {
|
||||
logic.setProgress(0.0f);
|
||||
this.getInventory().setInventorySlotContents(Press.slotCurrent, (ItemStack) null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.core.AbstractMod;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public class WindowSetSquare extends Window
|
||||
{
|
||||
public WindowSetSquare(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(150.0f, 150.0f, player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return ExtraTrees.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side) {
|
||||
return new WindowSetSquare(player, null, side);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.dictionary;
|
||||
|
||||
import binnie.extratrees.machines.DesignerType;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import binnie.craftgui.events.EventTextEdit;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.extratrees.machines.Designer;
|
||||
import binnie.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.craftgui.minecraft.control.ControlErrorState;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import binnie.craftgui.minecraft.MinecraftGUI;
|
||||
import binnie.craftgui.window.Panel;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.craftgui.controls.ControlTextEdit;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public class WindowWoodworker extends Window
|
||||
{
|
||||
ControlTextEdit textEdit;
|
||||
ControlTileSelect tileSelect;
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
new ControlText(this, new IArea(190.0f, 36.0f, 114.0f, 10.0f), BinnieCore.proxy.localise("gui.design"), TextJustification.TopCenter).setColour(4473924);
|
||||
new Panel(this, 188.0f, 48.0f, 118.0f, 126.0f, MinecraftGUI.PanelType.Gray);
|
||||
this.textEdit = new ControlTextEdit(this, 188.0f, 178.0f, 118.0f, 12.0f);
|
||||
final ControlScrollableContent scroll = new ControlScrollableContent(this, 190.0f, 50.0f, 114.0f, 122.0f, 12.0f);
|
||||
scroll.setScrollableContent(this.tileSelect = new ControlTileSelect(scroll, 0.0f, 0.0f));
|
||||
new ControlPlayerInventory(this).setPosition(new IPoint(14.0f, 96.0f));
|
||||
new ControlErrorState(this, 76.0f, 65.0f);
|
||||
if (this.getInventory() != null) {
|
||||
final ControlSlot slotWood1 = new ControlSlot(this, 22.0f, 34.0f);
|
||||
slotWood1.assign(Designer.design1Slot);
|
||||
final ControlSlot slotWood2 = new ControlSlot(this, 62.0f, 34.0f);
|
||||
slotWood2.assign(Designer.design2Slot);
|
||||
final ControlSlot slotBeeswax = new ControlSlot(this, 42.0f, 64.0f);
|
||||
slotBeeswax.assign(Designer.beeswaxSlot);
|
||||
final ControlRecipeSlot slotFinished = new ControlRecipeSlot(this, 112, 34);
|
||||
}
|
||||
}
|
||||
|
||||
public WindowWoodworker(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(320.0f, 216.0f, player, inventory, side);
|
||||
this.addEventHandler(new EventTextEdit.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventTextEdit event) {
|
||||
WindowWoodworker.this.tileSelect.refresh(event.getValue());
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, this));
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
return new WindowWoodworker(player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return ExtraTrees.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "Woodworker";
|
||||
}
|
||||
|
||||
public DesignerType getDesignerType() {
|
||||
return Machine.getInterface(Designer.ComponentWoodworkerRecipe.class, this.getInventory()).getDesignerType();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.kitchen;
|
||||
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.minecraft.MinecraftGUI;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.window.Panel;
|
||||
|
||||
public class ControlDropDownMenu extends Panel
|
||||
{
|
||||
public boolean stayOpenOnChildClick;
|
||||
|
||||
public ControlDropDownMenu(final IWidget parent, final float x, final float y, final float width, final float height) {
|
||||
super(parent, x, y, width, 2.0f, MinecraftGUI.PanelType.Gray);
|
||||
this.stayOpenOnChildClick = false;
|
||||
this.addAttribute(Attribute.CanFocus);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.kitchen;
|
||||
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.button.ControlButton;
|
||||
|
||||
public abstract class ControlDropdownButton extends ControlButton
|
||||
{
|
||||
public ControlDropdownButton(final IWidget parent, final float x, final float y, final float width, final float height, final String text) {
|
||||
super(parent, x, y, width, height, text);
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
ControlDropDownMenu menu = ControlDropdownButton.this.getWidget(ControlDropDownMenu.class);
|
||||
ControlDropdownButton.this.deleteChild(ControlDropdownButton.this.getWidget(ControlDropDownMenu.class));
|
||||
if (ControlDropdownButton.this.getWidget(ControlDropDownMenu.class) == null) {
|
||||
menu = ControlDropdownButton.this.createDropDownMenu();
|
||||
Window.get(ControlDropdownButton.this.getWidget()).setFocusedWidget(menu);
|
||||
}
|
||||
else {
|
||||
ControlDropdownButton.this.deleteChild(ControlDropdownButton.this.getWidget(ControlDropDownMenu.class));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public abstract ControlDropDownMenu createDropDownMenu();
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.kitchen;
|
||||
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlFluidDisplay extends Control implements ITooltip
|
||||
{
|
||||
FluidStack itemStack;
|
||||
public boolean hastooltip;
|
||||
|
||||
public void setTooltip() {
|
||||
this.hastooltip = true;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
public ControlFluidDisplay(final IWidget parent, final float f, final float y) {
|
||||
this(parent, f, y, 16.0f);
|
||||
}
|
||||
|
||||
public ControlFluidDisplay(final IWidget parent, final float f, final float y, final FluidStack stack, final boolean tooltip) {
|
||||
this(parent, f, y, 16.0f);
|
||||
this.setItemStack(stack);
|
||||
if (tooltip) {
|
||||
this.setTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
public ControlFluidDisplay(final IWidget parent, final float x, final float y, final float size) {
|
||||
super(parent, x, y, size, size);
|
||||
this.itemStack = null;
|
||||
this.hastooltip = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
if (this.itemStack == null) {
|
||||
return;
|
||||
}
|
||||
final IPoint relativeToWindow = this.getAbsolutePosition().sub(this.getSuperParent().getPosition());
|
||||
if (relativeToWindow.x() > Window.get(this).getSize().x() + 100.0f || relativeToWindow.y() > Window.get(this).getSize().y() + 100.0f) {
|
||||
return;
|
||||
}
|
||||
if (this.itemStack != null) {
|
||||
final Fluid fluid = this.itemStack.getFluid();
|
||||
final int hex = fluid.getColor(this.itemStack);
|
||||
final int r = (hex & 0xFF0000) >> 16;
|
||||
final int g = (hex & 0xFF00) >> 8;
|
||||
final int b = hex & 0xFF;
|
||||
final IIcon icon = this.itemStack.getFluid().getIcon(this.itemStack);
|
||||
GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
if (this.getSize().x() != 16.0f) {
|
||||
GL11.glPushMatrix();
|
||||
final float scale = this.getSize().x() / 16.0f;
|
||||
GL11.glScalef(scale, scale, 1.0f);
|
||||
CraftGUI.Render.iconBlock(IPoint.ZERO, this.itemStack.getFluid().getIcon(this.itemStack));
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else {
|
||||
CraftGUI.Render.iconBlock(IPoint.ZERO, this.itemStack.getFluid().getIcon(this.itemStack));
|
||||
}
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
}
|
||||
|
||||
public void setItemStack(final FluidStack itemStack) {
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
if (this.hastooltip && this.itemStack != null) {
|
||||
tooltip.add(this.itemStack.getLocalizedName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.kitchen;
|
||||
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlSlotFluid extends Control implements ITooltip
|
||||
{
|
||||
ControlFluidDisplay itemDisplay;
|
||||
FluidStack fluidStack;
|
||||
|
||||
public ControlSlotFluid(final IWidget parent, final int x, final int y, final FluidStack fluid) {
|
||||
this(parent, x, y, 18, fluid);
|
||||
}
|
||||
|
||||
public ControlSlotFluid(final IWidget parent, final int x, final int y, final int size, final FluidStack fluid) {
|
||||
super(parent, x, y, size, size);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.itemDisplay = new ControlFluidDisplay(this, 1.0f, 1.0f, size - 2);
|
||||
this.fluidStack = fluid;
|
||||
this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.ChangeSize event) {
|
||||
if (ControlSlotFluid.this.itemDisplay != null) {
|
||||
ControlSlotFluid.this.itemDisplay.setSize(ControlSlotFluid.this.getSize().sub(new IPoint(2.0f, 2.0f)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
final int size = (int) this.getSize().x();
|
||||
CraftGUI.Render.texture(CraftGUITexture.Slot, this.getArea());
|
||||
if (this.getSuperParent().getMousedOverWidget() == this) {
|
||||
CraftGUI.Render.gradientRect(new IArea(new IPoint(1.0f, 1.0f), this.getArea().size().sub(new IPoint(2.0f, 2.0f))), -2130706433, -2130706433);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
this.itemDisplay.setItemStack(this.getFluidStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
final FluidStack item = this.getFluidStack();
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
tooltip.add(item.getFluid().getLocalizedName());
|
||||
}
|
||||
|
||||
public FluidStack getFluidStack() {
|
||||
return this.fluidStack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.kitchen;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.extratrees.alcohol.Glassware;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.minecraft.control.ControlSlotBase;
|
||||
|
||||
public class ControlSlotGlassware extends ControlSlotBase implements IControlValue<Glassware>
|
||||
{
|
||||
Glassware glassware;
|
||||
|
||||
public ControlSlotGlassware(final IWidget parent, final int x, final int y, final Glassware glassware) {
|
||||
super(parent, x, y);
|
||||
this.glassware = glassware;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glassware getValue() {
|
||||
return this.glassware;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final Glassware value) {
|
||||
this.glassware = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.glassware.get(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.kitchen;
|
||||
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class ControlTankSlot extends ControlSlotFluid
|
||||
{
|
||||
int tankID;
|
||||
|
||||
public ControlTankSlot(final IWidget parent, final int x, final int y, final int i) {
|
||||
super(parent, x, y, null);
|
||||
this.tankID = 0;
|
||||
this.tankID = i;
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
if (event.getButton() == 0) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setByte("id", (byte) ControlTankSlot.this.tankID);
|
||||
Window.get(ControlTankSlot.this.getWidget()).sendClientAction("tank-click", nbt);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
this.fluidStack = Window.get(this).getContainer().getTankInfo(this.tankID).liquid;
|
||||
final int height = (int) (16.0f * (((this.fluidStack == null) ? 0 : this.fluidStack.amount) / 1000.0f));
|
||||
this.itemDisplay.setCroppedZone(this.itemDisplay, new IArea(0.0f, 16 - height, 16.0f, 16.0f));
|
||||
super.onUpdateClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
super.onRenderBackground();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.extratrees.kitchen;
|
||||
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.core.AbstractMod;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public class WindowBottleRack extends Window
|
||||
{
|
||||
public WindowBottleRack(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(248.0f, 180.0f, player, inventory, side);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
return new WindowBottleRack(player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return ExtraTrees.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "BottleBank";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
for (int i = 0; i < 36; ++i) {
|
||||
final int x = i % 12;
|
||||
final int y = i / 12;
|
||||
new ControlTankSlot(this, 16 + x * 18, 32 + y * 18, i);
|
||||
}
|
||||
new ControlPlayerInventory(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.genetics.machine;
|
||||
|
||||
import binnie.genetics.core.GeneticsTexture;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import binnie.genetics.genetics.Engineering;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.Binnie;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.genetics.api.IGene;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlGene extends Control implements IControlValue<IGene>, ITooltip
|
||||
{
|
||||
IGene gene;
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
final String cName = Binnie.Genetics.getSystem(this.gene.getSpeciesRoot()).getChromosomeName(this.gene.getChromosome());
|
||||
tooltip.add(cName + ": " + this.gene.getName());
|
||||
if (this.isMouseOver() && this.canFill(Window.get(this).getHeldItemStack())) {
|
||||
tooltip.add("Left click to assign gene");
|
||||
final IGene existingGene = Engineering.getGene(Window.get(this).getHeldItemStack(), this.gene.getChromosome().ordinal());
|
||||
if (existingGene == null) {
|
||||
return;
|
||||
}
|
||||
final String dName = Binnie.Genetics.getSystem(this.gene.getSpeciesRoot()).getChromosomeName(this.gene.getChromosome());
|
||||
tooltip.add("Will replace " + dName + ": " + existingGene.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canFill(final ItemStack stack) {
|
||||
return stack != null && stack.stackSize == 1 && Engineering.isGeneAcceptor(stack) && Engineering.canAcceptGene(stack, this.getValue());
|
||||
}
|
||||
|
||||
protected ControlGene(final IWidget parent, final float x, final float y) {
|
||||
super(parent, x, y, 16.0f, 16.0f);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
if (ControlGene.this.canFill(Window.get(ControlGene.this.getWidget()).getHeldItemStack())) {
|
||||
final NBTTagCompound action = new NBTTagCompound();
|
||||
final NBTTagCompound geneNBT = new NBTTagCompound();
|
||||
ControlGene.this.getValue().writeToNBT(geneNBT);
|
||||
action.setTag("gene", geneNBT);
|
||||
Window.get(ControlGene.this.getWidget()).sendClientAction("gene-select", action);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGene getValue() {
|
||||
return this.gene;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final IGene value) {
|
||||
this.gene = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
if (this.isMouseOver() && this.canFill(Window.get(this).getHeldItemStack())) {
|
||||
CraftGUI.Render.solid(this.getArea(), -1);
|
||||
CraftGUI.Render.solid(this.getArea().inset(1), -12303292);
|
||||
}
|
||||
CraftGUI.Render.colour(-1);
|
||||
CraftGUI.Render.iconItem(IPoint.ZERO, GeneticsTexture.dnaIcon.getIcon());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.genetics.machine;
|
||||
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.core.genetics.Gene;
|
||||
import java.util.ArrayList;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import java.util.List;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import java.util.Map;
|
||||
import binnie.Binnie;
|
||||
import binnie.genetics.genetics.GeneTracker;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlGeneScroll extends Control implements IControlValue<BreedingSystem>
|
||||
{
|
||||
private String filter;
|
||||
private BreedingSystem system;
|
||||
|
||||
protected ControlGeneScroll(final IWidget parent, final float x, final float y, final float w, final float h) {
|
||||
super(parent, x, y, w, h);
|
||||
this.filter = "";
|
||||
this.system = null;
|
||||
}
|
||||
|
||||
public void setFilter(final String filter) {
|
||||
this.filter = filter.toLowerCase();
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
public void setGenes(final BreedingSystem system) {
|
||||
this.system = system;
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
this.deleteAllChildren();
|
||||
final GeneTracker tracker = GeneTracker.getTracker(Window.get(this).getWorld(), Window.get(this).getUsername());
|
||||
final Map<IChromosomeType, List<IAllele>> genes = Binnie.Genetics.getChromosomeMap(this.system.getSpeciesRoot());
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final boolean isNEI = ((WindowGeneBank) Window.get(this)).isNei;
|
||||
for (final Map.Entry<IChromosomeType, List<IAllele>> entry : genes.entrySet()) {
|
||||
final List<IAllele> discovered = new ArrayList<IAllele>();
|
||||
for (final IAllele allele : entry.getValue()) {
|
||||
final Gene gene = new Gene(allele, entry.getKey(), this.system.getSpeciesRoot());
|
||||
if ((isNEI || tracker.isSequenced(new Gene(allele, entry.getKey(), this.system.getSpeciesRoot()))) && gene.getName().toLowerCase().contains(this.filter)) {
|
||||
discovered.add(allele);
|
||||
}
|
||||
}
|
||||
if (discovered.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
x = 0;
|
||||
new ControlText(this, new IPoint(x, y), this.system.getChromosomeName(entry.getKey()));
|
||||
y += 12;
|
||||
for (final IAllele allele : discovered) {
|
||||
if (x + 18 > this.getSize().x()) {
|
||||
y += 20;
|
||||
x = 0;
|
||||
}
|
||||
new ControlGene(this, x, y).setValue(new Gene(allele, entry.getKey(), this.system.getSpeciesRoot()));
|
||||
x += 18;
|
||||
}
|
||||
y += 24;
|
||||
}
|
||||
this.setSize(new IPoint(this.getSize().x(), y));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final BreedingSystem system) {
|
||||
this.setGenes(system);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BreedingSystem getValue() {
|
||||
return this.system;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.genetics.machine;
|
||||
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.control.ControlMachineProgress;
|
||||
|
||||
public class ControlProcessTemporary extends ControlMachineProgress
|
||||
{
|
||||
public ControlProcessTemporary(final IWidget parent, final int x, final int y, final int width, final int height) {
|
||||
super(parent, x, y, null, null, null);
|
||||
this.setSize(new IPoint(width, height));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.solid(this.getArea(), -4868683);
|
||||
final float w = this.getSize().y() * this.progress / 100.0f;
|
||||
CraftGUI.Render.solid(new IArea(this.getArea().x(), this.getArea().y(), w, this.getArea().h()), -65536);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.genetics.machine;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.Random;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.window.Panel;
|
||||
import binnie.craftgui.minecraft.MinecraftGUI;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.minecraft.control.ControlProgressBase;
|
||||
|
||||
public class ControlSequencerProgress extends ControlProgressBase
|
||||
{
|
||||
ControlText textControl;
|
||||
|
||||
public ControlSequencerProgress(final IWidget parent, final int x, final int y) {
|
||||
super(parent, x, y, 100.0f, 52.0f);
|
||||
final Panel panel = new Panel(this, 0.0f, 0.0f, 100.0f, 52.0f, MinecraftGUI.PanelType.Gray);
|
||||
this.textControl = new ControlText(panel, new IArea(4.0f, 4.0f, 92.0f, 44.0f), "", TextJustification.MiddleCenter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
final ItemStack stack = Machine.getMachine(Window.get(this).getInventory()).getMachineUtil().getStack(5);
|
||||
if (stack == null) {
|
||||
this.textControl.setValue("");
|
||||
}
|
||||
else {
|
||||
final Random rand = new Random(stack.getDisplayName().length());
|
||||
String text = "";
|
||||
final String[] codes = { "A", "T", "G", "C" };
|
||||
final String[] colors = { "a", "d", "b", "c" };
|
||||
for (int i = 0; i < 65; ++i) {
|
||||
final int k = rand.nextInt(4);
|
||||
final String code = codes[k];
|
||||
if (rand.nextFloat() < this.progress) {
|
||||
final String col = "§" + colors[k];
|
||||
text = text + "§r" + col + "§l" + code;
|
||||
}
|
||||
else {
|
||||
text = text + "§r§7§k§l" + code;
|
||||
}
|
||||
}
|
||||
this.textControl.setValue(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.genetics.machine;
|
||||
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.control.ControlProgressBase;
|
||||
|
||||
public class ControlSplicerProgress extends ControlProgressBase
|
||||
{
|
||||
float strength;
|
||||
|
||||
public ControlSplicerProgress(final IWidget parent, final float x, final float y, final float w, final float h) {
|
||||
super(parent, x, y, w, h);
|
||||
this.strength = 0.0f;
|
||||
this.strength = 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
final float progress = this.getProcess().getCurrentProgress() / 100.0f;
|
||||
final float n = this.getProcess().getProcessTime() / 12.0f;
|
||||
final float spacing = 10.0f;
|
||||
final float range = this.w();
|
||||
final float h = 8.0f;
|
||||
final float ooy = -((n - 1.0f) * spacing) - range / 2.0f;
|
||||
final float ddy = (n - 1.0f) * spacing + range;
|
||||
final float oy = ooy + ddy * progress;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
final int seed = 432523;
|
||||
final int[] colours = { 10027008, 30464, 255, 10057472 };
|
||||
int c1 = colours[(int) Math.abs(13.0 * Math.sin(i) + 48.0 * Math.cos(i) + 25.0 * Math.sin(7 * i)) % 4];
|
||||
int c2 = colours[(int) Math.abs(23.0 * Math.sin(i) + 28.0 * Math.cos(i) + 15.0 * Math.sin(7 * i)) % 4];
|
||||
int c3 = colours[(int) Math.abs(43.0 * Math.sin(i) + 38.0 * Math.cos(i) + 55.0 * Math.sin(7 * i)) % 4];
|
||||
int c4 = colours[(int) Math.abs(3.0 * Math.sin(i) + 18.0 * Math.cos(i) + 35.0 * Math.sin(7 * i)) % 4];
|
||||
final float y = oy + i * spacing;
|
||||
if (y > -range / 2.0f && y < range / 2.0f) {
|
||||
final float percentView = (float) Math.sqrt(1.0f - Math.abs(2.0f * y / range));
|
||||
final float offMovement = (this.h() - 2.0f * h) / 2.0f;
|
||||
final int alpha = 16777216 * (int) (255.0f * percentView);
|
||||
c1 += alpha;
|
||||
c2 += alpha;
|
||||
c3 += alpha;
|
||||
c4 += alpha;
|
||||
CraftGUI.Render.solidAlpha(new IArea(this.w() / 2.0f + y, offMovement * percentView, 4.0f, h / 2.0f), c1);
|
||||
CraftGUI.Render.solidAlpha(new IArea(this.w() / 2.0f + y, offMovement * percentView + 4.0f, 4.0f, h / 2.0f), (y < 0.0f) ? c2 : c3);
|
||||
CraftGUI.Render.solidAlpha(new IArea(this.w() / 2.0f + y, this.h() - offMovement * percentView - 8.0f, 4.0f, h / 2.0f), (y < 0.0f) ? c3 : c2);
|
||||
CraftGUI.Render.solidAlpha(new IArea(this.w() / 2.0f + y, this.h() - offMovement * percentView - 4.0f, 4.0f, h / 2.0f), c4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 3697 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user