aboutsummaryrefslogtreecommitdiff
path: root/src/Java/binnie/craftgui
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-01-20 14:24:34 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-01-20 14:24:34 +1000
commit869c206c4fcc8001bd2e1d66f704290331813835 (patch)
tree96735ce8fe4665e2759c3374221d6f06f4527df2 /src/Java/binnie/craftgui
parentec2c72827f01dd4bb2174137f1ab162f9ddaab62 (diff)
downloadGT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.tar.gz
GT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.tar.bz2
GT5-Unofficial-869c206c4fcc8001bd2e1d66f704290331813835.zip
Initial Commit
Diffstat (limited to 'src/Java/binnie/craftgui')
-rw-r--r--src/Java/binnie/craftgui/binniecore/WindowFieldKit.java334
-rw-r--r--src/Java/binnie/craftgui/binniecore/WindowGenesis.java264
-rw-r--r--src/Java/binnie/craftgui/botany/ControlColourDisplay.java47
-rw-r--r--src/Java/binnie/craftgui/botany/ControlColourMixBox.java31
-rw-r--r--src/Java/binnie/craftgui/botany/ControlColourMixItem.java37
-rw-r--r--src/Java/binnie/craftgui/botany/ControlColourMixSymbol.java58
-rw-r--r--src/Java/binnie/craftgui/botany/ControlColourOption.java38
-rw-r--r--src/Java/binnie/craftgui/botany/PageColourMix.java40
-rw-r--r--src/Java/binnie/craftgui/botany/PageColourMixResultant.java40
-rw-r--r--src/Java/binnie/craftgui/botany/PageSpeciesFlowerGenome.java137
-rw-r--r--src/Java/binnie/craftgui/botany/WindowBotanistDatabase.java103
-rw-r--r--src/Java/binnie/craftgui/controls/ControlCheckbox.java75
-rw-r--r--src/Java/binnie/craftgui/controls/ControlText.java50
-rw-r--r--src/Java/binnie/craftgui/controls/ControlTextCentered.java15
-rw-r--r--src/Java/binnie/craftgui/controls/ControlTextEdit.java154
-rw-r--r--src/Java/binnie/craftgui/controls/IControlSelection.java10
-rw-r--r--src/Java/binnie/craftgui/controls/IControlSelectionOption.java6
-rw-r--r--src/Java/binnie/craftgui/controls/button/ControlButton.java70
-rw-r--r--src/Java/binnie/craftgui/controls/button/ControlEnumButton.java61
-rw-r--r--src/Java/binnie/craftgui/controls/button/ControlToggleButton.java21
-rw-r--r--src/Java/binnie/craftgui/controls/core/Control.java85
-rw-r--r--src/Java/binnie/craftgui/controls/core/IControlIndexed.java8
-rw-r--r--src/Java/binnie/craftgui/controls/core/IControlValue.java11
-rw-r--r--src/Java/binnie/craftgui/controls/core/IControlValues.java11
-rw-r--r--src/Java/binnie/craftgui/controls/listbox/ControlList.java146
-rw-r--r--src/Java/binnie/craftgui/controls/listbox/ControlListBox.java76
-rw-r--r--src/Java/binnie/craftgui/controls/listbox/ControlOption.java73
-rw-r--r--src/Java/binnie/craftgui/controls/listbox/ControlTextOption.java37
-rw-r--r--src/Java/binnie/craftgui/controls/page/ControlPage.java36
-rw-r--r--src/Java/binnie/craftgui/controls/page/ControlPages.java57
-rw-r--r--src/Java/binnie/craftgui/controls/scroll/ControlScroll.java22
-rw-r--r--src/Java/binnie/craftgui/controls/scroll/ControlScrollBar.java94
-rw-r--r--src/Java/binnie/craftgui/controls/scroll/ControlScrollableContent.java134
-rw-r--r--src/Java/binnie/craftgui/controls/scroll/IControlScrollable.java17
-rw-r--r--src/Java/binnie/craftgui/controls/tab/ControlTab.java128
-rw-r--r--src/Java/binnie/craftgui/controls/tab/ControlTabBar.java86
-rw-r--r--src/Java/binnie/craftgui/core/Attribute.java9
-rw-r--r--src/Java/binnie/craftgui/core/CraftGUI.java10
-rw-r--r--src/Java/binnie/craftgui/core/ITooltip.java6
-rw-r--r--src/Java/binnie/craftgui/core/ITooltipHelp.java6
-rw-r--r--src/Java/binnie/craftgui/core/ITopLevelWidget.java29
-rw-r--r--src/Java/binnie/craftgui/core/IWidget.java138
-rw-r--r--src/Java/binnie/craftgui/core/IWidgetAttribute.java3
-rw-r--r--src/Java/binnie/craftgui/core/RenderStage.java8
-rw-r--r--src/Java/binnie/craftgui/core/Tooltip.java84
-rw-r--r--src/Java/binnie/craftgui/core/TopLevelWidget.java248
-rw-r--r--src/Java/binnie/craftgui/core/Widget.java499
-rw-r--r--src/Java/binnie/craftgui/core/geometry/CraftGUIUtil.java77
-rw-r--r--src/Java/binnie/craftgui/core/geometry/IArea.java143
-rw-r--r--src/Java/binnie/craftgui/core/geometry/IBorder.java126
-rw-r--r--src/Java/binnie/craftgui/core/geometry/IPoint.java83
-rw-r--r--src/Java/binnie/craftgui/core/geometry/Position.java41
-rw-r--r--src/Java/binnie/craftgui/core/geometry/TextJustification.java25
-rw-r--r--src/Java/binnie/craftgui/core/renderer/Renderer.java252
-rw-r--r--src/Java/binnie/craftgui/core/renderer/TextureType.java8
-rw-r--r--src/Java/binnie/craftgui/events/Event.java23
-rw-r--r--src/Java/binnie/craftgui/events/EventButtonClicked.java21
-rw-r--r--src/Java/binnie/craftgui/events/EventCycleChanged.java20
-rw-r--r--src/Java/binnie/craftgui/events/EventHandler.java53
-rw-r--r--src/Java/binnie/craftgui/events/EventKey.java63
-rw-r--r--src/Java/binnie/craftgui/events/EventMouse.java156
-rw-r--r--src/Java/binnie/craftgui/events/EventTextEdit.java21
-rw-r--r--src/Java/binnie/craftgui/events/EventToggleButtonClicked.java20
-rw-r--r--src/Java/binnie/craftgui/events/EventValueChanged.java29
-rw-r--r--src/Java/binnie/craftgui/events/EventValuesChanged.java20
-rw-r--r--src/Java/binnie/craftgui/events/EventWidget.java272
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/ControlBlockIconDisplay.java25
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/ControlBreweryProgress.java115
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/ControlDistilleryProgress.java104
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/ControlFruitPressProgress.java90
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/ControlLumbermillProgress.java96
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/ControlRecipeSlot.java42
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/ControlTileSelect.java197
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/DialogBreweryRecipe.java17
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/PageFruit.java47
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/PagePlanksOverview.java103
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/PagePlanksTrees.java40
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/PageSpeciesImage.java31
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/PageSpeciesTreeGenome.java175
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/PageWood.java40
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/WindowArboristDatabase.java133
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/WindowBrewery.java61
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/WindowDistillery.java59
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/WindowLepidopteristDatabase.java57
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/WindowLumbermill.java56
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/WindowPress.java77
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/WindowSetSquare.java35
-rw-r--r--src/Java/binnie/craftgui/extratrees/dictionary/WindowWoodworker.java110
-rw-r--r--src/Java/binnie/craftgui/extratrees/kitchen/ControlDropDownMenu.java18
-rw-r--r--src/Java/binnie/craftgui/extratrees/kitchen/ControlDropdownButton.java36
-rw-r--r--src/Java/binnie/craftgui/extratrees/kitchen/ControlFluidDisplay.java103
-rw-r--r--src/Java/binnie/craftgui/extratrees/kitchen/ControlSlotFluid.java77
-rw-r--r--src/Java/binnie/craftgui/extratrees/kitchen/ControlSlotGlassware.java35
-rw-r--r--src/Java/binnie/craftgui/extratrees/kitchen/ControlTankSlot.java49
-rw-r--r--src/Java/binnie/craftgui/extratrees/kitchen/WindowBottleRack.java48
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/ControlGene.java101
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/ControlGeneScroll.java97
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/ControlProcessTemporary.java27
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/ControlSequencerProgress.java64
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/ControlSplicerProgress.java60
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowAcclimatiser.java80
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowAnalyser.java110
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowGeneBank.java256
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowGeneBankNEI.java14
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowGeneProject.java32
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowGenepool.java96
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowGenomeAssembler.java37
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowIncubator.java99
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowInoculator.java107
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowIsolator.java116
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowMachine.java22
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowPolymeriser.java101
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowSequencer.java116
-rw-r--r--src/Java/binnie/craftgui/genetics/machine/WindowSplicer.java93
-rw-r--r--src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java549
-rw-r--r--src/Java/binnie/craftgui/minecraft/CustomSlot.java54
-rw-r--r--src/Java/binnie/craftgui/minecraft/Dialog.java53
-rw-r--r--src/Java/binnie/craftgui/minecraft/EnumColor.java32
-rw-r--r--src/Java/binnie/craftgui/minecraft/GUIIcon.java30
-rw-r--r--src/Java/binnie/craftgui/minecraft/GuiCraftGUI.java605
-rw-r--r--src/Java/binnie/craftgui/minecraft/IMachineInformation.java6
-rw-r--r--src/Java/binnie/craftgui/minecraft/IMinecraftTooltip.java9
-rw-r--r--src/Java/binnie/craftgui/minecraft/IWindowAffectsShiftClick.java8
-rw-r--r--src/Java/binnie/craftgui/minecraft/InventoryType.java8
-rw-r--r--src/Java/binnie/craftgui/minecraft/ListMap.java149
-rw-r--r--src/Java/binnie/craftgui/minecraft/MinecraftGUI.java14
-rw-r--r--src/Java/binnie/craftgui/minecraft/MinecraftTooltip.java63
-rw-r--r--src/Java/binnie/craftgui/minecraft/ModuleCraftGUI.java18
-rw-r--r--src/Java/binnie/craftgui/minecraft/Window.java338
-rw-r--r--src/Java/binnie/craftgui/minecraft/WindowInventory.java144
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlEnergyBar.java161
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlErrorState.java113
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlHelp.java41
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlIconDisplay.java25
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlImage.java25
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlInfo.java38
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlItemDisplay.java98
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlLiquidTank.java223
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlMachineProgress.java14
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java108
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlPowerSystem.java39
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlProgress.java30
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlProgressBase.java100
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlide.java113
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlot.java221
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlotArray.java76
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlotBase.java77
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlSlotCharge.java43
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlTabIcon.java47
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/ControlUser.java41
-rw-r--r--src/Java/binnie/craftgui/minecraft/control/EnumHighlighting.java28
-rw-r--r--src/Java/binnie/craftgui/minecraft/render/MinecraftTexture.java10
-rw-r--r--src/Java/binnie/craftgui/minecraft/render/RenderCommand.java16
-rw-r--r--src/Java/binnie/craftgui/mod/database/ControlBranchBox.java20
-rw-r--r--src/Java/binnie/craftgui/mod/database/ControlBranchBoxOption.java14
-rw-r--r--src/Java/binnie/craftgui/mod/database/ControlBreedingProgress.java41
-rw-r--r--src/Java/binnie/craftgui/mod/database/ControlDatabaseIndividualDisplay.java120
-rw-r--r--src/Java/binnie/craftgui/mod/database/ControlItemStackOption.java38
-rw-r--r--src/Java/binnie/craftgui/mod/database/ControlMutationBox.java71
-rw-r--r--src/Java/binnie/craftgui/mod/database/ControlMutationItem.java51
-rw-r--r--src/Java/binnie/craftgui/mod/database/ControlMutationSymbol.java80
-rw-r--r--src/Java/binnie/craftgui/mod/database/ControlSpeciesBox.java55
-rw-r--r--src/Java/binnie/craftgui/mod/database/ControlSpeciexBoxOption.java42
-rw-r--r--src/Java/binnie/craftgui/mod/database/DatabaseTab.java32
-rw-r--r--src/Java/binnie/craftgui/mod/database/EnumDiscoveryState.java8
-rw-r--r--src/Java/binnie/craftgui/mod/database/IDatabaseMode.java6
-rw-r--r--src/Java/binnie/craftgui/mod/database/PageAbstract.java16
-rw-r--r--src/Java/binnie/craftgui/mod/database/PageBranch.java13
-rw-r--r--src/Java/binnie/craftgui/mod/database/PageBranchOverview.java67
-rw-r--r--src/Java/binnie/craftgui/mod/database/PageBranchSpecies.java43
-rw-r--r--src/Java/binnie/craftgui/mod/database/PageBreeder.java51
-rw-r--r--src/Java/binnie/craftgui/mod/database/PageBreederStats.java23
-rw-r--r--src/Java/binnie/craftgui/mod/database/PageSpecies.java13
-rw-r--r--src/Java/binnie/craftgui/mod/database/PageSpeciesClassification.java54
-rw-r--r--src/Java/binnie/craftgui/mod/database/PageSpeciesMutations.java27
-rw-r--r--src/Java/binnie/craftgui/mod/database/PageSpeciesOverview.java88
-rw-r--r--src/Java/binnie/craftgui/mod/database/PageSpeciesResultant.java27
-rw-r--r--src/Java/binnie/craftgui/mod/database/WindowAbstractDatabase.java314
-rw-r--r--src/Java/binnie/craftgui/resource/IStyleSheet.java6
-rw-r--r--src/Java/binnie/craftgui/resource/StyleSheet.java18
-rw-r--r--src/Java/binnie/craftgui/resource/StyleSheetManager.java28
-rw-r--r--src/Java/binnie/craftgui/resource/Texture.java128
-rw-r--r--src/Java/binnie/craftgui/resource/minecraft/CraftGUIResourceManager.java155
-rw-r--r--src/Java/binnie/craftgui/resource/minecraft/CraftGUITexture.java18
-rw-r--r--src/Java/binnie/craftgui/resource/minecraft/CraftGUITextureSheet.java33
-rw-r--r--src/Java/binnie/craftgui/resource/minecraft/PaddedTexture.java21
-rw-r--r--src/Java/binnie/craftgui/resource/minecraft/ParsedTextureSheet.java25
-rw-r--r--src/Java/binnie/craftgui/resource/minecraft/StandardTexture.java36
-rw-r--r--src/Java/binnie/craftgui/window/Panel.java58
189 files changed, 14416 insertions, 0 deletions
diff --git a/src/Java/binnie/craftgui/binniecore/WindowFieldKit.java b/src/Java/binnie/craftgui/binniecore/WindowFieldKit.java
new file mode 100644
index 0000000000..d52a6cde31
--- /dev/null
+++ b/src/Java/binnie/craftgui/binniecore/WindowFieldKit.java
@@ -0,0 +1,334 @@
+package binnie.craftgui.binniecore;
+
+import binnie.Binnie;
+import binnie.core.AbstractMod;
+import binnie.core.BinnieCore;
+import binnie.core.genetics.BreedingSystem;
+import binnie.core.genetics.ManagerGenetics;
+import binnie.core.language.ManagerLanguage;
+import binnie.core.machines.inventory.SlotValidator;
+import binnie.core.machines.inventory.ValidatorIcon;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventValueChanged;
+import binnie.craftgui.events.EventValueChanged.Handler;
+import binnie.craftgui.minecraft.InventoryType;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.WindowInventory;
+import binnie.craftgui.minecraft.control.ControlImage;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.resource.StyleSheet;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import binnie.craftgui.resource.minecraft.PaddedTexture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.extrabees.core.ExtraBeeTexture;
+import binnie.extrabees.gui.punnett.ExtraBeeGUITexture;
+import binnie.genetics.gui.ControlChromosome;
+import binnie.genetics.machine.Analyser;
+import cpw.mods.fml.relauncher.Side;
+import forestry.api.genetics.AlleleManager;
+import forestry.api.genetics.IAllele;
+import forestry.api.genetics.IAlleleRegistry;
+import forestry.api.genetics.IChromosomeType;
+import forestry.api.genetics.IGenome;
+import forestry.api.genetics.IIndividual;
+import forestry.api.genetics.ISpeciesRoot;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class WindowFieldKit
+ extends Window
+{
+ public WindowFieldKit(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(280.0F, 230.0F, player, inventory, side);
+ }
+
+ protected AbstractMod getMod()
+ {
+ return BinnieCore.instance;
+ }
+
+ protected String getName()
+ {
+ return "Field Kit";
+ }
+
+ private void setupValidators()
+ {
+ getWindowInventory().setValidator(0, new SlotValidator(null)
+ {
+ public boolean isValid(ItemStack object)
+ {
+ return (AlleleManager.alleleRegistry.isIndividual(object)) || (Binnie.Genetics.getConversion(object) != null);
+ }
+
+ public String getTooltip()
+ {
+ return "Individual";
+ }
+ });
+ getWindowInventory().setValidator(1, new SlotValidator(null)
+ {
+ public boolean isValid(ItemStack object)
+ {
+ return object.getItem() == Items.paper;
+ }
+
+ public String getTooltip()
+ {
+ return "Paper";
+ }
+ });
+ getWindowInventory().disableAutoDispense(1);
+ }
+
+ public void initialiseClient()
+ {
+ setTitle("Field Kit");
+
+ CraftGUI.Render.stylesheet(new StyleSheetPunnett());
+
+ getWindowInventory().createSlot(0);
+ getWindowInventory().createSlot(1);
+
+ setupValidators();
+
+ new ControlPlayerInventory(this);
+
+ 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");
+ this.text.setColour(2236962);
+
+ this.text = new ControlText(this, new IArea(0.0F, 120.0F, w(), 24.0F), "", TextJustification.MiddleCenter);
+ this.text.setColour(2236962);
+
+ this.chromo = new ControlChromosome(this, 150.0F, 24.0F);
+
+ addEventHandler(new EventValueChanged.Handler()
+ {
+ public void onEvent(EventValueChanged event)
+ {
+ IChromosomeType type = (IChromosomeType)event.getValue();
+ if ((type != null) && (WindowFieldKit.this.info.containsKey(type)))
+ {
+ String t = (String)WindowFieldKit.this.info.get(type);
+ WindowFieldKit.this.text.setValue(t);
+ }
+ else
+ {
+ WindowFieldKit.this.text.setValue("");
+ }
+ }
+ }.setOrigin(EventHandler.Origin.DirectChild, this.chromo));
+ }
+
+ public void initialiseServer()
+ {
+ ItemStack kit = getPlayer().getHeldItem();
+ int sheets = 64 - kit.getItemDamage();
+ if (sheets != 0) {
+ getWindowInventory().setInventorySlotContents(1, new ItemStack(Items.paper, sheets));
+ }
+ setupValidators();
+ }
+
+ private float glassOffsetX = 0.0F;
+ private float glassOffsetY = 0.0F;
+ private float glassVX = 0.0F;
+ private float glassVY = 0.0F;
+ private Random glassRand = new Random();
+ private Control GlassControl;
+ private ControlChromosome chromo;
+ private ControlText text;
+ private float analyseProgress = 1.0F;
+ private boolean isAnalysing = false;
+
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+ if (this.isAnalysing)
+ {
+ this.analyseProgress += 0.01F;
+ if (this.analyseProgress >= 1.0F)
+ {
+ this.isAnalysing = false;
+ this.analyseProgress = 1.0F;
+ ItemStack stack = getWindowInventory().getStackInSlot(0);
+ if (stack != null) {
+ sendClientAction("analyse", new NBTTagCompound());
+ }
+ 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 Map<IChromosomeType, String> info = new HashMap();
+
+ private void refreshSpecies()
+ {
+ ItemStack item = getWindowInventory().getStackInSlot(0);
+ if ((item == null) || (!AlleleManager.alleleRegistry.isIndividual(item))) {
+ return;
+ }
+ IIndividual ind = AlleleManager.alleleRegistry.getIndividual(item);
+ if (ind == null) {
+ return;
+ }
+ ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(item);
+ this.chromo.setRoot(root);
+ Random rand = new Random();
+ this.info.clear();
+ for (IChromosomeType type : root.getKaryotype()) {
+ if (!Binnie.Genetics.isInvalidChromosome(type))
+ {
+ IAllele allele = ind.getGenome().getActiveAllele(type);
+ List<String> infos = new ArrayList();
+ int i = 0;
+ String pref = root.getUID() + ".fieldkit." + type.getName().toLowerCase() + ".";
+ while (Binnie.Language.canLocalise(pref + i))
+ {
+ infos.add(Binnie.Language.localise(pref + i));
+ i++;
+ }
+ String text = Binnie.Genetics.getSystem(root).getAlleleName(type, allele);
+ if (!infos.isEmpty()) {
+ text = (String)infos.get(rand.nextInt(infos.size()));
+ }
+ this.info.put(type, text);
+ this.chromo.setRoot(root);
+ }
+ }
+ }
+
+ private ItemStack prev = null;
+
+ public void onWindowInventoryChanged()
+ {
+ super.onWindowInventoryChanged();
+ if (isServer())
+ {
+ ItemStack kit = getPlayer().getHeldItem();
+ int sheets = 64 - kit.getItemDamage();
+ int size = getWindowInventory().getStackInSlot(1) == null ? 0 : getWindowInventory().getStackInSlot(1).stackSize;
+ if (sheets != size) {
+ kit.setItemDamage(64 - size);
+ }
+ ((EntityPlayerMP)getPlayer()).updateHeldItem();
+ }
+ if (isClient())
+ {
+ ItemStack item = getWindowInventory().getStackInSlot(0);
+ this.prev = item;
+ this.text.setValue("");
+ if ((item != null) && (!Analyser.isAnalysed(item)))
+ {
+ if (getWindowInventory().getStackInSlot(1) == null)
+ {
+ this.text.setValue("No Paper!");
+ this.isAnalysing = false;
+ this.analyseProgress = 1.0F;
+ }
+ else
+ {
+ startAnalysing();
+ this.chromo.setRoot(null);
+ if (!damageKit()) {}
+ }
+ }
+ else if (item != null)
+ {
+ this.isAnalysing = false;
+ this.analyseProgress = 1.0F;
+ refreshSpecies();
+ if (!damageKit()) {}
+ }
+ 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;
+ }
+
+ public boolean showHelpButton()
+ {
+ return true;
+ }
+
+ 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";
+ }
+
+ public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound action)
+ {
+ super.recieveGuiNBT(side, player, name, action);
+ if ((side == Side.SERVER) && (name.equals("analyse")))
+ {
+ getWindowInventory().setInventorySlotContents(0, Analyser.analyse(getWindowInventory().getStackInSlot(0)));
+ 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));
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/binniecore/WindowGenesis.java b/src/Java/binnie/craftgui/binniecore/WindowGenesis.java
new file mode 100644
index 0000000000..8295645f5a
--- /dev/null
+++ b/src/Java/binnie/craftgui/binniecore/WindowGenesis.java
@@ -0,0 +1,264 @@
+package binnie.craftgui.binniecore;
+
+import binnie.Binnie;
+import binnie.core.AbstractMod;
+import binnie.core.BinnieCore;
+import binnie.core.genetics.BreedingSystem;
+import binnie.core.genetics.Gene;
+import binnie.core.genetics.ManagerGenetics;
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlListBox;
+import binnie.craftgui.controls.listbox.ControlTextOption;
+import binnie.craftgui.controls.tab.ControlTab;
+import binnie.craftgui.controls.tab.ControlTabBar;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.events.EventValueChanged;
+import binnie.craftgui.events.EventValueChanged.Handler;
+import binnie.craftgui.minecraft.MinecraftGUI.PanelType;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlItemDisplay;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlTabIcon;
+import binnie.craftgui.window.Panel;
+import binnie.genetics.gui.ControlGenesisOption;
+import cpw.mods.fml.relauncher.Side;
+import forestry.api.genetics.IAllele;
+import forestry.api.genetics.IChromosomeType;
+import forestry.api.genetics.IIndividual;
+import forestry.api.genetics.ISpeciesRoot;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class WindowGenesis
+ extends Window
+{
+ private ISpeciesRoot root;
+ private IAllele[] template;
+ private ControlListBox<Gene> geneList;
+ private ControlListBox<Gene> geneOptions;
+ private Panel panelPickup;
+
+ public WindowGenesis(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(342.0F, 228.0F, player, inventory, side);
+ }
+
+ protected AbstractMod getMod()
+ {
+ return BinnieCore.instance;
+ }
+
+ protected String getName()
+ {
+ return "Genesis";
+ }
+
+ public void initialiseClient()
+ {
+ new ControlPlayerInventory(this);
+ setTitle("Genesis");
+
+ ControlTabBar<BreedingSystem> tabSystems = new ControlTabBar(this, 8.0F, 28.0F, 23.0F, 100.0F, Position.Left)
+ {
+ public ControlTab<BreedingSystem> createTab(float x, float y, float w, float h, BreedingSystem value)
+ {
+ new ControlTabIcon(this, x, y, w, h, value)
+ {
+ public ItemStack getItemStack()
+ {
+ int type = ((BreedingSystem)this.value).getDefaultType();
+ IIndividual ind = ((BreedingSystem)this.value).getDefaultIndividual();
+ return ((BreedingSystem)this.value).getSpeciesRoot().getMemberStack(ind, type);
+ }
+
+ public String getName()
+ {
+ return ((BreedingSystem)this.value).getName();
+ }
+
+ public int getOutlineColour()
+ {
+ return ((BreedingSystem)this.value).getColour();
+ }
+
+ public boolean hasOutline()
+ {
+ return true;
+ }
+ };
+ }
+ };
+ tabSystems.setValues(Binnie.Genetics.getActiveSystems());
+
+ this.root = ((BreedingSystem)Binnie.Genetics.getActiveSystems().iterator().next()).getSpeciesRoot();
+ this.template = this.root.getDefaultTemplate();
+
+ IArea one = new IArea(32.0F, 28.0F, 170.0F, 100.0F);
+ 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(this, one.x(), one.y(), one.w(), one.h(), 10.0F)
+ {
+ public IWidget createOption(Gene value, int y)
+ {
+ return new ControlGenesisOption((ControlList)getContent(), value, y);
+ }
+ };
+ this.geneOptions = new ControlListBox(this, two.x(), two.y(), two.w(), two.h(), 10.0F)
+ {
+ public IWidget createOption(Gene value, int y)
+ {
+ return new ControlTextOption((ControlList)getContent(), value, y);
+ }
+ };
+ tabSystems.addEventHandler(new EventValueChanged.Handler()
+ {
+ public void onEvent(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()
+ {
+ public void onEvent(EventValueChanged event)
+ {
+ Map<IChromosomeType, List<IAllele>> map = Binnie.Genetics.getChromosomeMap(WindowGenesis.this.root);
+ List<Gene> opts = new ArrayList();
+ IChromosomeType chromo = ((Gene)event.value).getChromosome();
+ for (IAllele allele : (List)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()
+ {
+ public void onEvent(EventValueChanged event)
+ {
+ if (event.value == null) {
+ return;
+ }
+ 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);
+
+ refreshTemplate(null);
+ }
+
+ private void refreshTemplate(IChromosomeType selection)
+ {
+ List<Gene> genes = new ArrayList();
+ IChromosomeType[] chromos = (IChromosomeType[])Binnie.Genetics.getChromosomeMap(this.root).keySet().toArray(new IChromosomeType[0]);
+ for (IChromosomeType type : chromos)
+ {
+ 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));
+ }
+ 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());
+ }
+ refreshPickup();
+ }
+
+ private void refreshPickup()
+ {
+ this.panelPickup.deleteAllChildren();
+ int i = 0;
+ for (int type : Binnie.Genetics.getSystem(this.root).getActiveTypes())
+ {
+ IIndividual ind = this.root.templateAsIndividual(this.template);
+ ind.analyze();
+ final ItemStack stack = this.root.getMemberStack(ind, type);
+ 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()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ stack.writeToNBT(nbt);
+ Window.get(event.getOrigin()).sendClientAction("genesis", nbt);
+ }
+ }.setOrigin(EventHandler.Origin.Self, display));
+
+
+
+ i++;
+ }
+ }
+
+ public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound action)
+ {
+ super.recieveGuiNBT(side, player, name, action);
+ if ((side == Side.SERVER) && (name.equals("genesis")))
+ {
+ ItemStack stack = ItemStack.loadItemStackFromNBT(action);
+ 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)))
+ {
+ int fit = stack.getMaxStackSize() - (stack.stackSize + playerInv.getItemStack().stackSize);
+ if (fit >= 0)
+ {
+ ItemStack rec = stack;
+ rec.stackSize += playerInv.getItemStack().stackSize;
+ playerInv.setItemStack(rec);
+ }
+ }
+ player.openContainer.detectAndSendChanges();
+ if ((player instanceof EntityPlayerMP)) {
+ ((EntityPlayerMP)player).updateHeldItem();
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/botany/ControlColourDisplay.java b/src/Java/binnie/craftgui/botany/ControlColourDisplay.java
new file mode 100644
index 0000000000..21408ec4ad
--- /dev/null
+++ b/src/Java/binnie/craftgui/botany/ControlColourDisplay.java
@@ -0,0 +1,47 @@
+package binnie.craftgui.botany;
+
+import binnie.botany.api.IFlowerColour;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.renderer.Renderer;
+
+public class ControlColourDisplay
+ extends Control
+ implements IControlValue<IFlowerColour>, ITooltip
+{
+ IFlowerColour value;
+
+ public ControlColourDisplay(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public IFlowerColour getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(IFlowerColour value)
+ {
+ this.value = value;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.solid(getArea(), -1);
+ CraftGUI.Render.solid(getArea().inset(1), -16777216 + getValue().getColor(false));
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ super.getTooltip(tooltip);
+ tooltip.add(this.value.getName());
+ }
+}
diff --git a/src/Java/binnie/craftgui/botany/ControlColourMixBox.java b/src/Java/binnie/craftgui/botany/ControlColourMixBox.java
new file mode 100644
index 0000000000..7ca4fa98f2
--- /dev/null
+++ b/src/Java/binnie/craftgui/botany/ControlColourMixBox.java
@@ -0,0 +1,31 @@
+package binnie.craftgui.botany;
+
+import binnie.botany.api.IColourMix;
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlListBox;
+import binnie.craftgui.core.IWidget;
+
+public class ControlColourMixBox
+ extends ControlListBox<IColourMix>
+{
+ private int index;
+ private Type type;
+
+ public IWidget createOption(IColourMix value, int y)
+ {
+ return new ControlColourMixItem((ControlList)getContent(), value, y);
+ }
+
+ static enum Type
+ {
+ Resultant, Further;
+
+ private Type() {}
+ }
+
+ public ControlColourMixBox(IWidget parent, int x, int y, int width, int height, Type type)
+ {
+ super(parent, x, y, width, height, 12.0F);
+ this.type = type;
+ }
+}
diff --git a/src/Java/binnie/craftgui/botany/ControlColourMixItem.java b/src/Java/binnie/craftgui/botany/ControlColourMixItem.java
new file mode 100644
index 0000000000..cf519b9a8e
--- /dev/null
+++ b/src/Java/binnie/craftgui/botany/ControlColourMixItem.java
@@ -0,0 +1,37 @@
+package binnie.craftgui.botany;
+
+import binnie.botany.api.IColourMix;
+import binnie.core.genetics.BreedingSystem;
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlOption;
+import binnie.craftgui.mod.database.WindowAbstractDatabase;
+
+public class ControlColourMixItem
+ extends ControlOption<IColourMix>
+{
+ ControlColourDisplay itemWidget1;
+ ControlColourDisplay itemWidget2;
+ ControlColourDisplay itemWidget3;
+ ControlColourMixSymbol addSymbol;
+ ControlColourMixSymbol arrowSymbol;
+
+ public ControlColourMixItem(ControlList<IColourMix> controlList, IColourMix option, 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);
+
+ BreedingSystem system = ((WindowAbstractDatabase)getSuperParent()).getBreedingSystem();
+ if (getValue() != null)
+ {
+ this.itemWidget1.setValue(((IColourMix)getValue()).getColour1());
+ this.itemWidget2.setValue(((IColourMix)getValue()).getColour2());
+ this.itemWidget3.setValue(((IColourMix)getValue()).getResult());
+ this.addSymbol.setValue((IColourMix)getValue());
+ this.arrowSymbol.setValue((IColourMix)getValue());
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/botany/ControlColourMixSymbol.java b/src/Java/binnie/craftgui/botany/ControlColourMixSymbol.java
new file mode 100644
index 0000000000..5afb98d54f
--- /dev/null
+++ b/src/Java/binnie/craftgui/botany/ControlColourMixSymbol.java
@@ -0,0 +1,58 @@
+package binnie.craftgui.botany;
+
+import binnie.botany.api.IColourMix;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.CraftGUITextureSheet;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+
+public class ControlColourMixSymbol
+ extends Control
+ implements ITooltip
+{
+ static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
+ static Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
+ IColourMix value;
+ int type;
+
+ public void onRenderBackground()
+ {
+ super.onRenderBackground();
+ if (this.type == 0) {
+ CraftGUI.Render.texture(MutationPlus, IPoint.ZERO);
+ } else {
+ CraftGUI.Render.texture(MutationArrow, IPoint.ZERO);
+ }
+ }
+
+ protected ControlColourMixSymbol(IWidget parent, int x, int y, int type)
+ {
+ super(parent, x, y, 16 + type * 16, 16.0F);
+ this.value = null;
+ this.type = type;
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public void setValue(IColourMix value)
+ {
+ this.value = value;
+
+ setColour(16777215);
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ if (this.type == 1)
+ {
+ float chance = this.value.getChance();
+ tooltip.add("Current Chance - " + chance + "%");
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/botany/ControlColourOption.java b/src/Java/binnie/craftgui/botany/ControlColourOption.java
new file mode 100644
index 0000000000..0a94e5690f
--- /dev/null
+++ b/src/Java/binnie/craftgui/botany/ControlColourOption.java
@@ -0,0 +1,38 @@
+package binnie.craftgui.botany;
+
+import binnie.botany.api.IFlowerColour;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlTextOption;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.geometry.CraftGUIUtil;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+
+public class ControlColourOption
+ extends ControlTextOption<IFlowerColour>
+{
+ ControlColourDisplay controlBee;
+ IPoint boxPosition;
+
+ public ControlColourOption(ControlList<IFlowerColour> controlList, IFlowerColour option, int y)
+ {
+ super(controlList, option, option.getName(), y);
+ setSize(new IPoint(getSize().x(), 20.0F));
+
+ this.controlBee = new ControlColourDisplay(this, 2.0F, 2.0F);
+ this.controlBee.setValue(option);
+
+ 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)));
+
+ int th = (int)CraftGUI.Render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x());
+ int height = Math.max(20, th + 6);
+ setSize(new IPoint(size().x(), height));
+ this.textWidget.setSize(new IPoint(this.textWidget.getSize().x(), height));
+ this.boxPosition = new IPoint(2.0F, (height - 18) / 2);
+ }
+}
diff --git a/src/Java/binnie/craftgui/botany/PageColourMix.java b/src/Java/binnie/craftgui/botany/PageColourMix.java
new file mode 100644
index 0000000000..5fc7e335db
--- /dev/null
+++ b/src/Java/binnie/craftgui/botany/PageColourMix.java
@@ -0,0 +1,40 @@
+package binnie.craftgui.botany;
+
+import binnie.botany.api.IColourMix;
+import binnie.botany.api.IFlowerColour;
+import binnie.botany.api.IFlowerRoot;
+import binnie.botany.core.BotanyCore;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.PageAbstract;
+import java.util.ArrayList;
+import java.util.List;
+
+public class PageColourMix
+ extends PageAbstract<IFlowerColour>
+{
+ ControlText pageSpeciesFurther_Title;
+ ControlColourMixBox pageSpeciesFurther_List;
+
+ public PageColourMix(IWidget parent, 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);
+ }
+
+ public void onValueChanged(IFlowerColour colour)
+ {
+ List<IColourMix> mixes = new ArrayList();
+ for (IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
+ if ((mix.getColour1() == colour) || (mix.getColour2() == colour)) {
+ mixes.add(mix);
+ }
+ }
+ this.pageSpeciesFurther_List.setOptions(mixes);
+ }
+}
diff --git a/src/Java/binnie/craftgui/botany/PageColourMixResultant.java b/src/Java/binnie/craftgui/botany/PageColourMixResultant.java
new file mode 100644
index 0000000000..a8a50f2cb7
--- /dev/null
+++ b/src/Java/binnie/craftgui/botany/PageColourMixResultant.java
@@ -0,0 +1,40 @@
+package binnie.craftgui.botany;
+
+import binnie.botany.api.IColourMix;
+import binnie.botany.api.IFlowerColour;
+import binnie.botany.api.IFlowerRoot;
+import binnie.botany.core.BotanyCore;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.PageAbstract;
+import java.util.ArrayList;
+import java.util.List;
+
+public class PageColourMixResultant
+ extends PageAbstract<IFlowerColour>
+{
+ ControlText pageSpeciesFurther_Title;
+ ControlColourMixBox pageSpeciesFurther_List;
+
+ public PageColourMixResultant(IWidget parent, 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);
+ }
+
+ public void onValueChanged(IFlowerColour colour)
+ {
+ List<IColourMix> mixes = new ArrayList();
+ for (IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
+ if (mix.getResult() == colour) {
+ mixes.add(mix);
+ }
+ }
+ this.pageSpeciesFurther_List.setOptions(mixes);
+ }
+}
diff --git a/src/Java/binnie/craftgui/botany/PageSpeciesFlowerGenome.java b/src/Java/binnie/craftgui/botany/PageSpeciesFlowerGenome.java
new file mode 100644
index 0000000000..dece27f306
--- /dev/null
+++ b/src/Java/binnie/craftgui/botany/PageSpeciesFlowerGenome.java
@@ -0,0 +1,137 @@
+package binnie.craftgui.botany;
+
+import binnie.Binnie;
+import binnie.botany.api.EnumFlowerChromosome;
+import binnie.botany.api.EnumFlowerStage;
+import binnie.botany.api.IAlleleFlowerSpecies;
+import binnie.botany.api.IFlower;
+import binnie.botany.api.IFlowerGenome;
+import binnie.botany.api.IFlowerRoot;
+import binnie.botany.core.BotanyCore;
+import binnie.core.genetics.ManagerGenetics;
+import binnie.core.language.ManagerLanguage;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.scroll.ControlScrollableContent;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.minecraft.control.ControlItemDisplay;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.PageSpecies;
+import forestry.api.core.EnumTemperature;
+import forestry.api.genetics.IAllele;
+import forestry.api.genetics.IAlleleSpecies;
+import forestry.api.genetics.IGenome;
+import forestry.api.genetics.IIndividual;
+import net.minecraft.item.ItemStack;
+
+public class PageSpeciesFlowerGenome
+ extends PageSpecies
+{
+ public PageSpeciesFlowerGenome(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+ }
+
+ public void onValueChanged(IAlleleSpecies species)
+ {
+ deleteAllChildren();
+ IAllele[] template = Binnie.Genetics.getFlowerRoot().getTemplate(species.getUID());
+ if (template == null) {
+ return;
+ }
+ IFlower tree = Binnie.Genetics.getFlowerRoot().templateAsIndividual(template);
+ if (tree == null) {
+ return;
+ }
+ IFlowerGenome genome = tree.getGenome();
+ IAlleleFlowerSpecies treeSpecies = genome.getPrimary();
+
+ int w = 144;
+ int h = 176;
+
+ new ControlText(this, new IArea(0.0F, 4.0F, w, 16.0F), "Genome", TextJustification.MiddleCenter);
+
+ ControlScrollableContent scrollable = new ControlScrollableContent(this, 4.0F, 20.0F, w - 8, h - 8 - 16, 12.0F);
+
+ Control contents = new Control(scrollable, 0.0F, 0.0F, w - 8 - 12, h - 8 - 16);
+
+ int tw = w - 8 - 12;
+ int w1 = 55;
+ int w2 = tw - 50;
+ int y = 0;
+ int th = 14;
+ int th2 = 18;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), "Temp. : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), treeSpecies.getTemperature().getName(), TextJustification.MiddleLeft);
+
+ y += th;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), "Moist. : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), Binnie.Language.localise(treeSpecies.getMoisture()), TextJustification.MiddleLeft);
+
+
+ y += th;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), "pH. : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), Binnie.Language.localise(treeSpecies.getPH()), TextJustification.MiddleLeft);
+
+ y += th;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), "Fertility : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), genome.getFertility() + "x", TextJustification.MiddleLeft);
+ y += th;
+
+ float lifespan = genome.getLifespan() * 68.269997F / genome.getAgeChance() / 24000.0F;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), "Lifespan : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), "" + String.format("%.2f", new Object[] { Float.valueOf(lifespan) }) + " days", TextJustification.MiddleLeft);
+
+ y += th;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), "Nectar : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), TextJustification.MiddleLeft);
+
+
+ y += th;
+
+ int x = w1;
+ int tot = 0;
+ for (IIndividual vid : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
+ if (vid.getGenome().getPrimary() == treeSpecies)
+ {
+ if ((tot > 0) && (tot % 3 == 0))
+ {
+ x -= 54;
+ y += 18;
+ }
+ ItemStack stack = BotanyCore.getFlowerRoot().getMemberStack((IFlower)vid, EnumFlowerStage.FLOWER.ordinal());
+ ControlItemDisplay display = new ControlItemDisplay(contents, x, y);
+ display.setItemStack(stack);
+ tot++;
+ x += 18;
+ }
+ }
+ int numOfLines = 1 + (tot - 1) / 3;
+
+ new ControlText(contents, new IArea(0.0F, y - (numOfLines - 1) * 18, w1, 4 + 18 * numOfLines), "Varieties : ", TextJustification.MiddleRight);
+
+
+ y += th;
+
+ contents.setSize(new IPoint(contents.size().x(), y));
+
+ scrollable.setScrollableContent(contents);
+ }
+
+ public static String tolerated(boolean t)
+ {
+ if (t) {
+ return "Tolerated";
+ }
+ return "Not Tolerated";
+ }
+}
diff --git a/src/Java/binnie/craftgui/botany/WindowBotanistDatabase.java b/src/Java/binnie/craftgui/botany/WindowBotanistDatabase.java
new file mode 100644
index 0000000000..69a2a291ca
--- /dev/null
+++ b/src/Java/binnie/craftgui/botany/WindowBotanistDatabase.java
@@ -0,0 +1,103 @@
+package binnie.craftgui.botany;
+
+import binnie.Binnie;
+import binnie.botany.Botany;
+import binnie.botany.api.IFlowerColour;
+import binnie.botany.genetics.EnumFlowerColor;
+import binnie.botany.proxy.Proxy;
+import binnie.core.AbstractMod;
+import binnie.core.genetics.ManagerGenetics;
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlListBox;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.IDatabaseMode;
+import binnie.craftgui.mod.database.PageBranchOverview;
+import binnie.craftgui.mod.database.PageBranchSpecies;
+import binnie.craftgui.mod.database.PageBreeder;
+import binnie.craftgui.mod.database.PageSpeciesClassification;
+import binnie.craftgui.mod.database.PageSpeciesMutations;
+import binnie.craftgui.mod.database.PageSpeciesOverview;
+import binnie.craftgui.mod.database.PageSpeciesResultant;
+import binnie.craftgui.mod.database.WindowAbstractDatabase;
+import binnie.craftgui.mod.database.WindowAbstractDatabase.Mode;
+import binnie.craftgui.mod.database.WindowAbstractDatabase.ModeWidgets;
+import cpw.mods.fml.relauncher.Side;
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.entity.player.EntityPlayer;
+
+public class WindowBotanistDatabase
+ extends WindowAbstractDatabase
+{
+ ControlListBox<EnumFlowerColor> selectionBoxColors;
+
+ static enum FlowerMode
+ implements IDatabaseMode
+ {
+ Colour;
+
+ private FlowerMode() {}
+
+ public String getName()
+ {
+ return Botany.proxy.localise("gui.database.mode." + name().toLowerCase());
+ }
+ }
+
+ public WindowBotanistDatabase(EntityPlayer player, Side side, boolean nei)
+ {
+ super(player, side, nei, Binnie.Genetics.flowerBreedingSystem, 130.0F);
+ }
+
+ public static Window create(EntityPlayer player, Side side, boolean nei)
+ {
+ return new WindowBotanistDatabase(player, side, nei);
+ }
+
+ protected void addTabs()
+ {
+ new PageSpeciesOverview(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(Botany.instance, "species.overview", 0));
+ new PageSpeciesFlowerGenome(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(Botany.instance, "species.genome", 0));
+ new PageSpeciesClassification(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(Botany.instance, "species.classification", 0));
+ new PageSpeciesResultant(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(Botany.instance, "species.resultant", 0));
+ new PageSpeciesMutations(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(Botany.instance, "species.further", 0));
+
+ new PageBranchOverview(getInfoPages(WindowAbstractDatabase.Mode.Branches), new DatabaseTab(Botany.instance, "branches.overview", 0));
+ new PageBranchSpecies(getInfoPages(WindowAbstractDatabase.Mode.Branches), new DatabaseTab(Botany.instance, "branches.species", 0));
+
+ createMode(FlowerMode.Colour, new WindowAbstractDatabase.ModeWidgets(FlowerMode.Colour, this)
+ {
+ public void createListBox(IArea area)
+ {
+ this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0F)
+ {
+ public IWidget createOption(IFlowerColour value, int y)
+ {
+ return new ControlColourOption((ControlList)getContent(), value, y);
+ }
+ };
+ List<IFlowerColour> colors = new ArrayList();
+ for (IFlowerColour c : EnumFlowerColor.values()) {
+ colors.add(c);
+ }
+ this.listBox.setOptions(colors);
+ }
+ });
+ new PageColourMixResultant(getInfoPages(FlowerMode.Colour), new DatabaseTab(Botany.instance, "colour.resultant", 0));
+ new PageColourMix(getInfoPages(FlowerMode.Colour), new DatabaseTab(Botany.instance, "colour.further", 0));
+ new PageBreeder(getInfoPages(WindowAbstractDatabase.Mode.Breeder), getUsername(), new DatabaseTab(Botany.instance, "breeder", 0));
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Botany.instance;
+ }
+
+ protected String getName()
+ {
+ return "FlowerDatabase";
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/ControlCheckbox.java b/src/Java/binnie/craftgui/controls/ControlCheckbox.java
new file mode 100644
index 0000000000..edfeab631c
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/ControlCheckbox.java
@@ -0,0 +1,75 @@
+package binnie.craftgui.controls;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.events.EventValueChanged;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlCheckbox
+ extends Control
+ implements IControlValue<Boolean>
+{
+ boolean value;
+ String text;
+
+ public ControlCheckbox(IWidget parent, float x, float y, boolean bool)
+ {
+ this(parent, x, y, 0.0F, "", bool);
+ }
+
+ public ControlCheckbox(IWidget parent, float x, float y, float w, String text, 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);
+ }
+ addAttribute(Attribute.MouseOver);
+ addEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ ControlCheckbox.this.toggleValue();
+ }
+ }.setOrigin(EventHandler.Origin.Self, this));
+ }
+
+ protected void onValueChanged(boolean value) {}
+
+ public Boolean getValue()
+ {
+ return Boolean.valueOf(this.value);
+ }
+
+ public void setValue(Boolean value)
+ {
+ this.value = value.booleanValue();
+ onValueChanged(value.booleanValue());
+ callEvent(new EventValueChanged(this, value));
+ }
+
+ public void toggleValue()
+ {
+ setValue(Boolean.valueOf(!getValue().booleanValue()));
+ }
+
+ public void onRenderBackground()
+ {
+ Object texture = getValue().booleanValue() ? CraftGUITexture.CheckboxChecked : CraftGUITexture.Checkbox;
+ if (isMouseOver()) {
+ texture = getValue().booleanValue() ? CraftGUITexture.CheckboxCheckedHighlighted : CraftGUITexture.CheckboxHighlighted;
+ }
+ CraftGUI.Render.texture(texture, IPoint.ZERO);
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/ControlText.java b/src/Java/binnie/craftgui/controls/ControlText.java
new file mode 100644
index 0000000000..4df9c04db1
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/ControlText.java
@@ -0,0 +1,50 @@
+package binnie.craftgui.controls;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.core.renderer.Renderer;
+
+public class ControlText
+ extends Control
+ implements IControlValue<String>
+{
+ private String text;
+ private TextJustification align;
+
+ public ControlText(IWidget parent, IPoint pos, String text)
+ {
+ this(parent, new IArea(pos, new IPoint(500.0F, 0.0F)), text, TextJustification.TopLeft);
+ }
+
+ public ControlText(IWidget parent, String text, TextJustification align)
+ {
+ this(parent, parent.getArea(), text, align);
+ }
+
+ public ControlText(IWidget parent, IArea area, String text, TextJustification align)
+ {
+ super(parent, area.pos().x(), area.pos().y(), area.size().x(), area.size().y());
+ setValue(text);
+ this.align = align;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.text(getArea(), this.align, this.text, getColour());
+ }
+
+ public void setValue(String text)
+ {
+ this.text = text;
+ }
+
+ public String getValue()
+ {
+ return this.text;
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/ControlTextCentered.java b/src/Java/binnie/craftgui/controls/ControlTextCentered.java
new file mode 100644
index 0000000000..12434528db
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/ControlTextCentered.java
@@ -0,0 +1,15 @@
+package binnie.craftgui.controls;
+
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+
+public class ControlTextCentered
+ extends ControlText
+{
+ public ControlTextCentered(IWidget parent, float y, String text)
+ {
+ super(parent, new IArea(new IPoint(0.0F, y), new IPoint(parent.size().x(), 0.0F)), text, TextJustification.TopCenter);
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/ControlTextEdit.java b/src/Java/binnie/craftgui/controls/ControlTextEdit.java
new file mode 100644
index 0000000000..8c07a12d7c
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/ControlTextEdit.java
@@ -0,0 +1,154 @@
+package binnie.craftgui.controls;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventKey.Down;
+import binnie.craftgui.events.EventKey.Down.Handler;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.events.EventTextEdit;
+import binnie.craftgui.events.EventWidget.GainFocus;
+import binnie.craftgui.events.EventWidget.GainFocus.Handler;
+import binnie.craftgui.events.EventWidget.LoseFocus;
+import binnie.craftgui.events.EventWidget.LoseFocus.Handler;
+import binnie.craftgui.minecraft.GuiCraftGUI;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import net.minecraft.client.gui.GuiTextField;
+
+public class ControlTextEdit
+ extends Control
+ implements IControlValue<String>
+{
+ GuiTextField field;
+
+ public ControlTextEdit(IWidget parent, float x, float y, float width, float height)
+ {
+ super(parent, x, y, width, height);
+
+ this.field = new GuiTextField(getWindow().getGui().getFontRenderer(), 0, 0, 10, 10);
+ addAttribute(Attribute.CanFocus);
+ addAttribute(Attribute.MouseOver);
+ this.field.setEnableBackgroundDrawing(false);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ addEventHandler(new EventKey.Down.Handler()
+ {
+ public void onEvent(EventKey.Down event)
+ {
+ ControlTextEdit.this.field.textboxKeyTyped(event.getCharacter(), event.getKey());
+ 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));
+
+
+
+
+ addEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ ControlTextEdit.this.field.mouseClicked((int)ControlTextEdit.this.getRelativeMousePosition().x(), (int)ControlTextEdit.this.getRelativeMousePosition().y(), event.getButton());
+ }
+ }.setOrigin(EventHandler.Origin.Self, this));
+
+
+
+ addEventHandler(new EventWidget.GainFocus.Handler()
+ {
+ public void onEvent(EventWidget.GainFocus event)
+ {
+ ControlTextEdit.this.field.setFocused(true);
+ }
+ }.setOrigin(EventHandler.Origin.Self, this));
+
+
+
+ addEventHandler(new EventWidget.LoseFocus.Handler()
+ {
+ public void onEvent(EventWidget.LoseFocus event)
+ {
+ ControlTextEdit.this.field.setFocused(false);
+ }
+ }.setOrigin(EventHandler.Origin.Self, this));
+ }
+
+ public String getValue()
+ {
+ return this.field.getText() == null ? "" : this.field.getText();
+ }
+
+ public void setValue(String value)
+ {
+ if (!getValue().equals(value))
+ {
+ this.field.setText(value);
+ this.field.setCursorPosition(0);
+ }
+ }
+
+ private String cachedValue = "";
+
+ public void onUpdateClient() {}
+
+ protected void onTextEdit(String value) {}
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.Slot, getArea());
+ renderTextField();
+ }
+
+ protected void renderTextField()
+ {
+ this.field.width = ((int)w());
+ this.field.height = ((int)h());
+ this.field.xPosition = ((int)((h() - 8.0F) / 2.0F));
+ this.field.yPosition = ((int)((h() - 8.0F) / 2.0F));
+ this.field.drawTextBox();
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/IControlSelection.java b/src/Java/binnie/craftgui/controls/IControlSelection.java
new file mode 100644
index 0000000000..4648f49290
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/IControlSelection.java
@@ -0,0 +1,10 @@
+package binnie.craftgui.controls;
+
+public abstract interface IControlSelection<T>
+{
+ public abstract T getSelectedValue();
+
+ public abstract void setSelectedValue(T paramT);
+
+ public abstract boolean isSelected(IControlSelectionOption<T> paramIControlSelectionOption);
+}
diff --git a/src/Java/binnie/craftgui/controls/IControlSelectionOption.java b/src/Java/binnie/craftgui/controls/IControlSelectionOption.java
new file mode 100644
index 0000000000..9074a55541
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/IControlSelectionOption.java
@@ -0,0 +1,6 @@
+package binnie.craftgui.controls;
+
+public abstract interface IControlSelectionOption<T>
+{
+ public abstract T getValue();
+}
diff --git a/src/Java/binnie/craftgui/controls/button/ControlButton.java b/src/Java/binnie/craftgui/controls/button/ControlButton.java
new file mode 100644
index 0000000000..b41cb65116
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/button/ControlButton.java
@@ -0,0 +1,70 @@
+package binnie.craftgui.controls.button;
+
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventButtonClicked;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlButton
+ extends Control
+{
+ private ControlText textWidget;
+ private String text;
+
+ public ControlButton(IWidget parent, float x, float y, float width, float height)
+ {
+ super(parent, x, y, width, height);
+
+ addAttribute(Attribute.MouseOver);
+
+ addEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ ControlButton.this.callEvent(new EventButtonClicked(ControlButton.this.getWidget()));
+ ControlButton.this.onMouseClick(event);
+ }
+ }.setOrigin(EventHandler.Origin.Self, this));
+ }
+
+ protected void onMouseClick(EventMouse.Down event) {}
+
+ public ControlButton(IWidget parent, float x, float y, float width, float height, String text)
+ {
+ this(parent, x, y, width, height);
+
+ this.text = text;
+ this.textWidget = new ControlText(this, getArea(), text, TextJustification.MiddleCenter);
+ }
+
+ public void onUpdateClient()
+ {
+ if (this.textWidget != null) {
+ this.textWidget.setValue(getText());
+ }
+ }
+
+ public String getText()
+ {
+ return this.text;
+ }
+
+ public void onRenderBackground()
+ {
+ Object texture = CraftGUITexture.ButtonDisabled;
+ if (isMouseOver()) {
+ texture = CraftGUITexture.ButtonHighlighted;
+ } else if (isEnabled()) {
+ texture = CraftGUITexture.Button;
+ }
+ CraftGUI.Render.texture(texture, getArea());
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/button/ControlEnumButton.java b/src/Java/binnie/craftgui/controls/button/ControlEnumButton.java
new file mode 100644
index 0000000000..924bd8c110
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/button/ControlEnumButton.java
@@ -0,0 +1,61 @@
+package binnie.craftgui.controls.button;
+
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventValueChanged;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ControlEnumButton<T>
+ extends ControlButton
+ implements IControlValue<T>
+{
+ public static final String eventEnumChanged = "eventEnumButtonChanged";
+ private T currentSelection;
+
+ public String getText()
+ {
+ return this.currentSelection.toString();
+ }
+
+ public void onMouseClick(EventMouse.Down event)
+ {
+ int index = this.enumConstants.indexOf(this.currentSelection);
+ if (index < this.enumConstants.size() - 1) {
+ index++;
+ } else {
+ index = 0;
+ }
+ T newEnum = this.enumConstants.get(index);
+
+ setValue(newEnum);
+ }
+
+ public void setValue(T selection)
+ {
+ if (this.currentSelection != selection)
+ {
+ this.currentSelection = selection;
+ callEvent(new EventValueChanged(this, getValue()));
+ }
+ }
+
+ private List<T> enumConstants = new ArrayList();
+
+ public ControlEnumButton(IWidget parent, float x, float y, float width, float height, T[] values)
+ {
+ super(parent, x, y, width, height, "");
+ for (T value : values) {
+ this.enumConstants.add(value);
+ }
+ if (values.length > 0) {
+ this.currentSelection = values[0];
+ }
+ }
+
+ public T getValue()
+ {
+ return this.currentSelection;
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/button/ControlToggleButton.java b/src/Java/binnie/craftgui/controls/button/ControlToggleButton.java
new file mode 100644
index 0000000000..1a06801fbd
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/button/ControlToggleButton.java
@@ -0,0 +1,21 @@
+package binnie.craftgui.controls.button;
+
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventToggleButtonClicked;
+
+public class ControlToggleButton
+ extends ControlButton
+{
+ boolean toggled;
+
+ public void onMouseClick(EventMouse.Down event)
+ {
+ callEvent(new EventToggleButtonClicked(this, this.toggled));
+ }
+
+ public ControlToggleButton(IWidget parent, int x, int y, int width, int height)
+ {
+ super(parent, x, y, width, height);
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/core/Control.java b/src/Java/binnie/craftgui/controls/core/Control.java
new file mode 100644
index 0000000000..f5f7bddabb
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/core/Control.java
@@ -0,0 +1,85 @@
+package binnie.craftgui.controls.core;
+
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.ITooltipHelp;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Widget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.minecraft.Window;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Control
+ extends Widget
+ implements ITooltipHelp, ITooltip
+{
+ public Control(IWidget parent, float x, float y, float w, float h)
+ {
+ super(parent);
+ setPosition(new IPoint(x, y));
+ setSize(new IPoint(w, h));
+ initialise();
+ }
+
+ public Control(IWidget parent, IArea area)
+ {
+ this(parent, area.x(), area.y(), area.w(), area.h());
+ }
+
+ List<String> helpStrings = new ArrayList();
+ List<String> tooltipStrings = new ArrayList();
+
+ protected void initialise() {}
+
+ public void onUpdateClient() {}
+
+ public void addHelp(String string)
+ {
+ this.helpStrings.add(string);
+ }
+
+ public void addHelp(String[] strings)
+ {
+ for (String string : strings) {
+ addHelp(string);
+ }
+ }
+
+ public void addTooltip(String string)
+ {
+ addAttribute(Attribute.MouseOver);
+ this.tooltipStrings.add(string);
+ }
+
+ public void addTooltip(String[] strings)
+ {
+ for (String string : strings) {
+ addTooltip(string);
+ }
+ }
+
+ public int extraLevel = 0;
+
+ public int getLevel()
+ {
+ return this.extraLevel + super.getLevel();
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ tooltip.add(this.helpStrings);
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.add(this.tooltipStrings);
+ }
+
+ public Window getWindow()
+ {
+ return (Window)getSuperParent();
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/core/IControlIndexed.java b/src/Java/binnie/craftgui/controls/core/IControlIndexed.java
new file mode 100644
index 0000000000..a30bceb76c
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/core/IControlIndexed.java
@@ -0,0 +1,8 @@
+package binnie.craftgui.controls.core;
+
+public abstract interface IControlIndexed
+{
+ public abstract int getIndex();
+
+ public abstract void setIndex(int paramInt);
+}
diff --git a/src/Java/binnie/craftgui/controls/core/IControlValue.java b/src/Java/binnie/craftgui/controls/core/IControlValue.java
new file mode 100644
index 0000000000..9d44b8ad17
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/core/IControlValue.java
@@ -0,0 +1,11 @@
+package binnie.craftgui.controls.core;
+
+import binnie.craftgui.core.IWidget;
+
+public abstract interface IControlValue<T>
+ extends IWidget
+{
+ public abstract T getValue();
+
+ public abstract void setValue(T paramT);
+}
diff --git a/src/Java/binnie/craftgui/controls/core/IControlValues.java b/src/Java/binnie/craftgui/controls/core/IControlValues.java
new file mode 100644
index 0000000000..92bb5d1f13
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/core/IControlValues.java
@@ -0,0 +1,11 @@
+package binnie.craftgui.controls.core;
+
+import java.util.Collection;
+
+public abstract interface IControlValues<T>
+ extends IControlValue<T>
+{
+ public abstract Collection<T> getValues();
+
+ public abstract void setValues(Collection<T> paramCollection);
+}
diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlList.java b/src/Java/binnie/craftgui/controls/listbox/ControlList.java
new file mode 100644
index 0000000000..d1b6be8821
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/listbox/ControlList.java
@@ -0,0 +1,146 @@
+package binnie.craftgui.controls.listbox;
+
+import binnie.core.util.IValidator;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.events.EventValueChanged;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+public class ControlList<T>
+ extends Control
+ implements IControlValue<T>
+{
+ ControlListBox<T> parent;
+
+ protected ControlList(ControlListBox<T> parent, float x, float y, float w, float h)
+ {
+ super(parent, x, y, w, h);
+ this.parent = parent;
+ }
+
+ T value = null;
+ Map<T, IWidget> allOptions = new LinkedHashMap();
+ Map<T, IWidget> optionWidgets = new LinkedHashMap();
+
+ public T getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(T value)
+ {
+ if (value == this.value) {
+ return;
+ }
+ this.value = value;
+ if ((value != null) && (this.optionWidgets.containsKey(value)))
+ {
+ IWidget child = (IWidget)this.optionWidgets.get(value);
+ this.parent.ensureVisible(child.y(), child.y() + child.h(), h());
+ }
+ getParent().callEvent(new EventValueChanged(getParent(), value));
+ }
+
+ boolean creating = false;
+ IValidator<IWidget> validator;
+
+ public void setOptions(Collection<T> options)
+ {
+ deleteAllChildren();
+ this.allOptions.clear();
+ int i = 0;
+ for (T option : options)
+ {
+ IWidget optionWidget = ((ControlListBox)getParent()).createOption(option, 0);
+ if (optionWidget != null) {
+ this.allOptions.put(option, optionWidget);
+ }
+ i++;
+ }
+ filterOptions();
+ }
+
+ public void filterOptions()
+ {
+ int height = 0;
+ this.optionWidgets.clear();
+ for (Map.Entry<T, IWidget> entry : this.allOptions.entrySet()) {
+ if (isValidOption((IWidget)entry.getValue()))
+ {
+ ((IWidget)entry.getValue()).show();
+ this.optionWidgets.put(entry.getKey(), entry.getValue());
+ ((IWidget)entry.getValue()).setPosition(new IPoint(0.0F, height));
+ height = (int)(height + ((IWidget)entry.getValue()).getSize().y());
+ }
+ else
+ {
+ ((IWidget)entry.getValue()).hide();
+ }
+ }
+ this.creating = true;
+ setValue(getValue());
+ setSize(new IPoint(getSize().x(), height));
+ }
+
+ public Collection<T> getOptions()
+ {
+ return this.optionWidgets.keySet();
+ }
+
+ public Collection<T> getAllOptions()
+ {
+ return this.allOptions.keySet();
+ }
+
+ public int getIndexOf(T value)
+ {
+ int index = 0;
+ for (T option : getOptions())
+ {
+ if (option.equals(value)) {
+ return index;
+ }
+ index++;
+ }
+ return -1;
+ }
+
+ public int getCurrentIndex()
+ {
+ return getIndexOf(getValue());
+ }
+
+ public void setIndex(int currentIndex)
+ {
+ int index = 0;
+ for (T option : getOptions())
+ {
+ if (index == currentIndex)
+ {
+ setValue(option);
+ return;
+ }
+ index++;
+ }
+ setValue(null);
+ }
+
+ private boolean isValidOption(IWidget widget)
+ {
+ return this.validator == null ? true : this.validator.isValid(widget);
+ }
+
+ public void setValidator(IValidator<IWidget> validator)
+ {
+ if (this.validator != validator)
+ {
+ this.validator = validator;
+ filterOptions();
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlListBox.java b/src/Java/binnie/craftgui/controls/listbox/ControlListBox.java
new file mode 100644
index 0000000000..e9370daa3d
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/listbox/ControlListBox.java
@@ -0,0 +1,76 @@
+package binnie.craftgui.controls.listbox;
+
+import binnie.core.util.IValidator;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.controls.scroll.ControlScrollableContent;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.events.EventKey.Down;
+import binnie.craftgui.events.EventKey.Down.Handler;
+import java.util.Collection;
+
+public class ControlListBox<T>
+ extends ControlScrollableContent<ControlList<T>>
+ implements IControlValue<T>
+{
+ public ControlListBox(IWidget parent, float x, float y, float w, float h, float scrollBarSize)
+ {
+ super(parent, x, y, w, h, scrollBarSize);
+ }
+
+ public void initialise()
+ {
+ setScrollableContent(new ControlList(this, 1.0F, 1.0F, w() - 2.0F - this.scrollBarSize, h() - 2.0F));
+
+ addEventHandler(new EventKey.Down.Handler()
+ {
+ public void onEvent(EventKey.Down event)
+ {
+ EventKey.Down eventKey = event;
+ if (ControlListBox.this.calculateIsMouseOver())
+ {
+ int currentIndex = ((ControlList)ControlListBox.this.getContent()).getCurrentIndex();
+ if (eventKey.getKey() == 208)
+ {
+ currentIndex++;
+ if (currentIndex >= ((ControlList)ControlListBox.this.getContent()).getOptions().size()) {
+ currentIndex = 0;
+ }
+ }
+ else if (eventKey.getKey() == 200)
+ {
+ currentIndex--;
+ if (currentIndex < 0) {
+ currentIndex = ((ControlList)ControlListBox.this.getContent()).getOptions().size() - 1;
+ }
+ }
+ ((ControlList)ControlListBox.this.getContent()).setIndex(currentIndex);
+ }
+ }
+ });
+ }
+
+ public final T getValue()
+ {
+ return ((ControlList)getContent()).getValue();
+ }
+
+ public final void setValue(T value)
+ {
+ ((ControlList)getContent()).setValue(value);
+ }
+
+ public void setOptions(Collection<T> options)
+ {
+ ((ControlList)getContent()).setOptions(options);
+ }
+
+ public IWidget createOption(T value, int y)
+ {
+ return new ControlOption((ControlList)getContent(), value, y);
+ }
+
+ public void setValidator(IValidator<IWidget> validator)
+ {
+ ((ControlList)getContent()).setValidator(validator);
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlOption.java b/src/Java/binnie/craftgui/controls/listbox/ControlOption.java
new file mode 100644
index 0000000000..7a643101cf
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/listbox/ControlOption.java
@@ -0,0 +1,73 @@
+package binnie.craftgui.controls.listbox;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlOption<T>
+ extends Control
+ implements IControlValue<T>
+{
+ T value;
+
+ public void onUpdateClient()
+ {
+ if (getValue() == null) {
+ return;
+ }
+ int colour = 10526880;
+ if (isCurrentSelection()) {
+ colour = 16777215;
+ }
+ setColour(colour);
+ }
+
+ public ControlOption(ControlList<T> controlList, T option)
+ {
+ this(controlList, option, 16);
+ }
+
+ public ControlOption(ControlList<T> controlList, T option, int height)
+ {
+ super(controlList, 0.0F, height, controlList.getSize().x(), 20.0F);
+ this.value = option;
+ if (this.value != null) {
+ addAttribute(Attribute.MouseOver);
+ }
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ ((IControlValue)ControlOption.this.getParent()).setValue(ControlOption.this.getValue());
+ }
+ });
+ }
+
+ public T getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(T value)
+ {
+ this.value = value;
+ }
+
+ public boolean isCurrentSelection()
+ {
+ return (getValue() != null) && (getValue().equals(((IControlValue)getParent()).getValue()));
+ }
+
+ public void onRenderForeground()
+ {
+ if (isCurrentSelection()) {
+ CraftGUI.Render.texture(CraftGUITexture.Outline, getArea());
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlTextOption.java b/src/Java/binnie/craftgui/controls/listbox/ControlTextOption.java
new file mode 100644
index 0000000000..6a47ec5d41
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/listbox/ControlTextOption.java
@@ -0,0 +1,37 @@
+package binnie.craftgui.controls.listbox;
+
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventWidget.ChangeColour;
+import binnie.craftgui.events.EventWidget.ChangeColour.Handler;
+
+public class ControlTextOption<T>
+ extends ControlOption<T>
+{
+ public ControlTextOption(ControlList<T> controlList, T option, String optionName, int y)
+ {
+ super(controlList, option, y);
+ this.textWidget = new ControlText(this, getArea(), optionName, TextJustification.MiddleCenter);
+
+ addEventHandler(new EventWidget.ChangeColour.Handler()
+ {
+ public void onEvent(EventWidget.ChangeColour event)
+ {
+ ControlTextOption.this.textWidget.setColour(ControlTextOption.this.getColour());
+ }
+ }.setOrigin(EventHandler.Origin.Self, this));
+ }
+
+ public ControlTextOption(ControlList<T> controlList, T option, int y)
+ {
+ this(controlList, option, option.toString(), y);
+ }
+
+ protected ControlText textWidget = null;
+
+ public String getText()
+ {
+ return this.textWidget.getValue();
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/page/ControlPage.java b/src/Java/binnie/craftgui/controls/page/ControlPage.java
new file mode 100644
index 0000000000..0e5c89492e
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/page/ControlPage.java
@@ -0,0 +1,36 @@
+package binnie.craftgui.controls.page;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.IWidget;
+
+public class ControlPage<T>
+ extends Control
+ implements IControlValue<T>
+{
+ T value;
+
+ public ControlPage(IWidget parent, T value)
+ {
+ this(parent, 0.0F, 0.0F, parent.w(), parent.h(), value);
+ }
+
+ public ControlPage(IWidget parent, float x, float y, float w, float h, T value)
+ {
+ super(parent, x, y, w, h);
+ setValue(value);
+ if (((parent instanceof IControlValue)) && (((IControlValue)parent).getValue() == null)) {
+ ((IControlValue)parent).setValue(value);
+ }
+ }
+
+ public T getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(T value)
+ {
+ this.value = value;
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/page/ControlPages.java b/src/Java/binnie/craftgui/controls/page/ControlPages.java
new file mode 100644
index 0000000000..43a205e874
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/page/ControlPages.java
@@ -0,0 +1,57 @@
+package binnie.craftgui.controls.page;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.controls.core.IControlValues;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.events.EventValueChanged;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class ControlPages<T>
+ extends Control
+ implements IControlValues<T>, IControlValue<T>
+{
+ public boolean isChildVisible(IWidget child)
+ {
+ if (child == null) {
+ return false;
+ }
+ return this.value == ((IControlValue)child).getValue();
+ }
+
+ public ControlPages(IWidget parent, float x, float y, float w, float h)
+ {
+ super(parent, x, y, w, h);
+ }
+
+ T value = null;
+
+ public void onAddChild(IWidget widget) {}
+
+ public T getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(T value)
+ {
+ if (this.value != value)
+ {
+ this.value = value;
+ callEvent(new EventValueChanged(this, value));
+ }
+ }
+
+ public Collection<T> getValues()
+ {
+ List<T> list = new ArrayList();
+ for (IWidget child : getWidgets()) {
+ list.add(((IControlValue)child).getValue());
+ }
+ return list;
+ }
+
+ public void setValues(Collection<T> values) {}
+}
diff --git a/src/Java/binnie/craftgui/controls/scroll/ControlScroll.java b/src/Java/binnie/craftgui/controls/scroll/ControlScroll.java
new file mode 100644
index 0000000000..1d03f5fbc7
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/scroll/ControlScroll.java
@@ -0,0 +1,22 @@
+package binnie.craftgui.controls.scroll;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.IWidget;
+
+public class ControlScroll
+ extends Control
+{
+ private IControlScrollable scrollWidget;
+
+ public ControlScroll(IWidget parent, float x, float y, float width, float height, IControlScrollable scrollWidget)
+ {
+ super(parent, x, y, width, height);
+ this.scrollWidget = scrollWidget;
+ new ControlScrollBar(this);
+ }
+
+ public IControlScrollable getScrollableWidget()
+ {
+ return this.scrollWidget;
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/scroll/ControlScrollBar.java b/src/Java/binnie/craftgui/controls/scroll/ControlScrollBar.java
new file mode 100644
index 0000000000..a94705767d
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/scroll/ControlScrollBar.java
@@ -0,0 +1,94 @@
+package binnie.craftgui.controls.scroll;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.events.EventMouse.Drag;
+import binnie.craftgui.events.EventMouse.Drag.Handler;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlScrollBar
+ extends Control
+{
+ protected final IControlScrollable scrollable;
+
+ public ControlScrollBar(ControlScroll parent)
+ {
+ this(parent, 0.0F, 0.0F, parent.getSize().x(), parent.getSize().y(), parent.getScrollableWidget());
+ }
+
+ public ControlScrollBar(IWidget parent, float x, float y, float w, float h, IControlScrollable scrollable2)
+ {
+ super(parent, x, y, w, h);
+ this.scrollable = scrollable2;
+ addAttribute(Attribute.MouseOver);
+
+ addSelfEventHandler(new EventMouse.Drag.Handler()
+ {
+ public void onEvent(EventMouse.Drag event)
+ {
+ ControlScrollBar.this.scrollable.movePercentage(event.getDy() / (ControlScrollBar.this.h() - ControlScrollBar.this.getBarHeight()));
+ }
+ });
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ float shownPercentage = ControlScrollBar.this.scrollable.getPercentageShown();
+ float percentageIndex = ControlScrollBar.this.scrollable.getPercentageIndex();
+ float minPercent = (1.0F - shownPercentage) * percentageIndex;
+ 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));
+ }
+ }
+ });
+ }
+
+ public void onUpdateClient() {}
+
+ public boolean isEnabled()
+ {
+ return this.scrollable.getPercentageShown() < 0.99F;
+ }
+
+ public float getBarHeight()
+ {
+ return h() * this.scrollable.getPercentageShown();
+ }
+
+ protected IArea getRenderArea()
+ {
+ float height = getBarHeight();
+ if (height < 6.0F) {
+ height = 6.0F;
+ }
+ float yOffset = ((int)h() - (int)getBarHeight()) * this.scrollable.getPercentageIndex();
+
+ return new IArea(0.0F, yOffset, getSize().x(), height);
+ }
+
+ public void onRenderBackground()
+ {
+ IArea renderArea = getRenderArea();
+
+ Object texture = CraftGUITexture.ScrollDisabled;
+ if (isMouseOver()) {
+ texture = CraftGUITexture.ScrollHighlighted;
+ } else if (isEnabled()) {
+ texture = CraftGUITexture.Scroll;
+ }
+ CraftGUI.Render.texture(texture, renderArea);
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/scroll/ControlScrollableContent.java b/src/Java/binnie/craftgui/controls/scroll/ControlScrollableContent.java
new file mode 100644
index 0000000000..442c9d3226
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/scroll/ControlScrollableContent.java
@@ -0,0 +1,134 @@
+package binnie.craftgui.controls.scroll;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.events.EventMouse.Wheel;
+import binnie.craftgui.events.EventMouse.Wheel.Handler;
+import binnie.craftgui.events.EventWidget.ChangeSize;
+import binnie.craftgui.events.EventWidget.ChangeSize.Handler;
+
+public class ControlScrollableContent<T extends IWidget>
+ extends Control
+ implements IControlScrollable
+{
+ protected T controlChild;
+ protected float scrollBarSize;
+
+ public ControlScrollableContent(IWidget parent, float x, float y, float w, float h, float scrollBarSize)
+ {
+ super(parent, x, y, w, h);
+ if (scrollBarSize != 0.0F) {
+ new ControlScroll(this, getSize().x() - scrollBarSize, 0.0F, scrollBarSize, getSize().y(), this);
+ }
+ addEventHandler(new EventMouse.Wheel.Handler()
+ {
+ public void onEvent(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;
+ }
+ float percentageMove = 0.8F / ControlScrollableContent.this.getMovementRange();
+ ControlScrollableContent.this.movePercentage(percentageMove * -event.getDWheel());
+ }
+ }
+ });
+ this.scrollBarSize = scrollBarSize;
+ }
+
+ public void setScrollableContent(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()
+ {
+ public void onEvent(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;
+ }
+
+ public float getPercentageShown()
+ {
+ if ((this.controlChild == null) || (this.controlChild.getSize().y() == 0.0F)) {
+ return 1.0F;
+ }
+ float shown = getSize().y() / this.controlChild.getSize().y();
+ return Math.min(shown, 1.0F);
+ }
+
+ float percentageIndex = 0.0F;
+
+ public float getPercentageIndex()
+ {
+ return this.percentageIndex;
+ }
+
+ public void movePercentage(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 (getMovementRange() == 0.0F) {
+ this.percentageIndex = 0.0F;
+ }
+ this.controlChild.setOffset(new IPoint(0.0F, -this.percentageIndex * getMovementRange()));
+ }
+
+ public void setPercentageIndex(float index)
+ {
+ movePercentage(index - this.percentageIndex);
+ }
+
+ public float getMovementRange()
+ {
+ if (this.controlChild == null) {
+ return 0.0F;
+ }
+ float range = this.controlChild.getSize().y() - getSize().y();
+ return Math.max(range, 0.0F);
+ }
+
+ public void onUpdateClient()
+ {
+ setPercentageIndex(getPercentageIndex());
+ }
+
+ public void ensureVisible(float minY, float maxY, float totalY)
+ {
+ minY /= totalY;
+ maxY /= totalY;
+
+ float shownPercentage = getPercentageShown();
+ float percentageIndex = getPercentageIndex();
+ float minPercent = (1.0F - shownPercentage) * percentageIndex;
+ float maxPercent = minPercent + shownPercentage;
+ if (maxY > maxPercent) {
+ setPercentageIndex((maxY - shownPercentage) / (1.0F - shownPercentage));
+ }
+ if (minY < minPercent) {
+ setPercentageIndex(minY / (1.0F - shownPercentage));
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/scroll/IControlScrollable.java b/src/Java/binnie/craftgui/controls/scroll/IControlScrollable.java
new file mode 100644
index 0000000000..39154815e5
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/scroll/IControlScrollable.java
@@ -0,0 +1,17 @@
+package binnie.craftgui.controls.scroll;
+
+import binnie.craftgui.core.IWidget;
+
+public abstract interface IControlScrollable
+ extends IWidget
+{
+ public abstract float getPercentageShown();
+
+ public abstract float getPercentageIndex();
+
+ public abstract void movePercentage(float paramFloat);
+
+ public abstract void setPercentageIndex(float paramFloat);
+
+ public abstract float getMovementRange();
+}
diff --git a/src/Java/binnie/craftgui/controls/tab/ControlTab.java b/src/Java/binnie/craftgui/controls/tab/ControlTab.java
new file mode 100644
index 0000000000..e05b7ed01a
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/tab/ControlTab.java
@@ -0,0 +1,128 @@
+package binnie.craftgui.controls.tab;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.events.EventValueChanged;
+import binnie.craftgui.minecraft.control.ControlItemDisplay;
+import binnie.craftgui.minecraft.control.ControlTabIcon;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import java.util.List;
+
+public class ControlTab<T>
+ extends Control
+ implements ITooltip, IControlValue<T>
+{
+ private ControlTabBar<T> tabBar;
+ protected T value;
+
+ public ControlTab(ControlTabBar<T> parent, float x, float y, float w, float h, T value)
+ {
+ super(parent, x, y, w, h);
+ setValue(value);
+ this.tabBar = parent;
+ addAttribute(Attribute.MouseOver);
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ ControlTab.this.callEvent(new EventValueChanged(ControlTab.this.getWidget(), ControlTab.this.getValue()));
+ }
+ });
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ String name = getName();
+ if ((name != null) && (!name.isEmpty())) {
+ tooltip.add(getName());
+ }
+ if ((this.value instanceof ITooltip)) {
+ ((ITooltip)this.value).getTooltip(tooltip);
+ }
+ }
+
+ public T getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(T value)
+ {
+ this.value = value;
+ }
+
+ public boolean isCurrentSelection()
+ {
+ return (getValue() != null) && (getValue().equals(this.tabBar.getValue()));
+ }
+
+ public Position getTabPosition()
+ {
+ return this.tabBar.position;
+ }
+
+ public String getName()
+ {
+ return this.value.toString();
+ }
+
+ public void onRenderBackground()
+ {
+ Object texture = CraftGUITexture.TabDisabled;
+ if (isMouseOver()) {
+ texture = CraftGUITexture.TabHighlighted;
+ } else if (isCurrentSelection()) {
+ texture = CraftGUITexture.Tab;
+ }
+ Texture lTexture = CraftGUI.Render.getTexture(texture);
+ Position position = getTabPosition();
+
+ Texture iTexture = lTexture.crop(position, 8.0F);
+
+
+ IArea area = 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))
+ {
+ ControlTabIcon icon = (ControlTabIcon)this;
+ ControlItemDisplay item = (ControlItemDisplay)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));
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/controls/tab/ControlTabBar.java b/src/Java/binnie/craftgui/controls/tab/ControlTabBar.java
new file mode 100644
index 0000000000..d209887994
--- /dev/null
+++ b/src/Java/binnie/craftgui/controls/tab/ControlTabBar.java
@@ -0,0 +1,86 @@
+package binnie.craftgui.controls.tab;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventValueChanged;
+import binnie.craftgui.events.EventValueChanged.Handler;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+public class ControlTabBar<T>
+ extends Control
+ implements IControlValue<T>
+{
+ T value;
+ Position position;
+
+ public ControlTabBar(IWidget parent, float x, float y, float width, float height, Position position)
+ {
+ super(parent, x, y, width, height);
+ this.position = position;
+
+ addEventHandler(new EventValueChanged.Handler()
+ {
+ public void onEvent(EventValueChanged event)
+ {
+ ControlTabBar.this.setValue(event.getValue());
+ }
+ }.setOrigin(EventHandler.Origin.DirectChild, this));
+ }
+
+ public void setValues(Collection<T> values)
+ {
+ for (int i = 0; i < getWidgets().size();) {
+ deleteChild((IWidget)getWidgets().get(0));
+ }
+ float length = values.size();
+ int tabDimension = (int)(getSize().y() / length);
+ if ((this.position == Position.Top) || (this.position == Position.Bottom)) {
+ tabDimension = (int)(getSize().x() / length);
+ }
+ int i = 0;
+ for (T value : values)
+ {
+ IWidget tab;
+ IWidget tab;
+ if ((this.position == Position.Top) || (this.position == Position.Bottom)) {
+ tab = createTab(i * tabDimension, 0.0F, tabDimension, getSize().y(), value);
+ } else {
+ tab = createTab(0.0F, i * tabDimension, getSize().x(), tabDimension, value);
+ }
+ i++;
+ }
+ if ((this.value == null) && (!values.isEmpty())) {
+ setValue(values.iterator().next());
+ }
+ }
+
+ public ControlTab<T> createTab(float x, float y, float w, float h, T value)
+ {
+ return new ControlTab(this, x, y, w, h, value);
+ }
+
+ public T getValue()
+ {
+ return this.value;
+ }
+
+ public void setValue(T value)
+ {
+ boolean change = this.value != value;
+ this.value = value;
+ if (change) {
+ callEvent(new EventValueChanged(this, value));
+ }
+ }
+
+ public Position getDirection()
+ {
+ return this.position;
+ }
+}
diff --git a/src/Java/binnie/craftgui/core/Attribute.java b/src/Java/binnie/craftgui/core/Attribute.java
new file mode 100644
index 0000000000..5d73f58ae2
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/Attribute.java
@@ -0,0 +1,9 @@
+package binnie.craftgui.core;
+
+public enum Attribute
+ implements IWidgetAttribute
+{
+ MouseOver, CanFocus, NeedsDeletion, AlwaysOnTop, BlockTooltip;
+
+ private Attribute() {}
+}
diff --git a/src/Java/binnie/craftgui/core/CraftGUI.java b/src/Java/binnie/craftgui/core/CraftGUI.java
new file mode 100644
index 0000000000..3cce3493cf
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/CraftGUI.java
@@ -0,0 +1,10 @@
+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;
+}
diff --git a/src/Java/binnie/craftgui/core/ITooltip.java b/src/Java/binnie/craftgui/core/ITooltip.java
new file mode 100644
index 0000000000..634ce476d5
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/ITooltip.java
@@ -0,0 +1,6 @@
+package binnie.craftgui.core;
+
+public abstract interface ITooltip
+{
+ public abstract void getTooltip(Tooltip paramTooltip);
+}
diff --git a/src/Java/binnie/craftgui/core/ITooltipHelp.java b/src/Java/binnie/craftgui/core/ITooltipHelp.java
new file mode 100644
index 0000000000..f01744ab6f
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/ITooltipHelp.java
@@ -0,0 +1,6 @@
+package binnie.craftgui.core;
+
+public abstract interface ITooltipHelp
+{
+ public abstract void getHelpTooltip(Tooltip paramTooltip);
+}
diff --git a/src/Java/binnie/craftgui/core/ITopLevelWidget.java b/src/Java/binnie/craftgui/core/ITopLevelWidget.java
new file mode 100644
index 0000000000..2e209b3ea6
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/ITopLevelWidget.java
@@ -0,0 +1,29 @@
+package binnie.craftgui.core;
+
+import binnie.craftgui.core.geometry.IPoint;
+
+public abstract interface ITopLevelWidget
+ extends IWidget
+{
+ public abstract void setMousePosition(int paramInt1, int paramInt2);
+
+ public abstract IPoint getAbsoluteMousePosition();
+
+ public abstract IWidget getFocusedWidget();
+
+ public abstract IWidget getMousedOverWidget();
+
+ public abstract IWidget getDraggedWidget();
+
+ public abstract boolean isFocused(IWidget paramIWidget);
+
+ public abstract boolean isMouseOver(IWidget paramIWidget);
+
+ public abstract boolean isDragged(IWidget paramIWidget);
+
+ public abstract void updateTopLevel();
+
+ public abstract void widgetDeleted(IWidget paramIWidget);
+
+ public abstract IPoint getDragDistance();
+}
diff --git a/src/Java/binnie/craftgui/core/IWidget.java b/src/Java/binnie/craftgui/core/IWidget.java
new file mode 100644
index 0000000000..cd85fa7a40
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/IWidget.java
@@ -0,0 +1,138 @@
+package binnie.craftgui.core;
+
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.events.Event;
+import binnie.craftgui.events.EventHandler;
+import java.util.List;
+
+public abstract interface IWidget
+{
+ public abstract IWidget getParent();
+
+ public abstract void deleteChild(IWidget paramIWidget);
+
+ public abstract void deleteAllChildren();
+
+ public abstract ITopLevelWidget getSuperParent();
+
+ public abstract boolean isTopLevel();
+
+ public abstract IPoint getPosition();
+
+ public abstract IPoint pos();
+
+ public abstract void setPosition(IPoint paramIPoint);
+
+ public abstract IPoint getSize();
+
+ public abstract IPoint size();
+
+ public abstract void setSize(IPoint paramIPoint);
+
+ public abstract IPoint getOriginalPosition();
+
+ public abstract IPoint getAbsolutePosition();
+
+ public abstract IPoint getOriginalAbsolutePosition();
+
+ public abstract IPoint getOffset();
+
+ public abstract IArea getArea();
+
+ public abstract IArea area();
+
+ public abstract void setOffset(IPoint paramIPoint);
+
+ public abstract IPoint getMousePosition();
+
+ public abstract IPoint getRelativeMousePosition();
+
+ public abstract void setColour(int paramInt);
+
+ public abstract int getColour();
+
+ public abstract void render();
+
+ public abstract void updateClient();
+
+ public abstract void enable();
+
+ public abstract void disable();
+
+ public abstract void show();
+
+ public abstract void hide();
+
+ public abstract boolean calculateIsMouseOver();
+
+ public abstract boolean isEnabled();
+
+ public abstract boolean isVisible();
+
+ public abstract boolean isFocused();
+
+ public abstract boolean isMouseOver();
+
+ public abstract boolean isDragged();
+
+ public abstract boolean isChildVisible(IWidget paramIWidget);
+
+ public abstract boolean isChildEnabled(IWidget paramIWidget);
+
+ public abstract boolean canMouseOver();
+
+ public abstract boolean canFocus();
+
+ public abstract IWidget addWidget(IWidget paramIWidget);
+
+ public abstract List<IWidget> getWidgets();
+
+ public abstract void callEvent(Event paramEvent);
+
+ public abstract void recieveEvent(Event paramEvent);
+
+ public abstract void onUpdateClient();
+
+ public abstract void delete();
+
+ public abstract void onDelete();
+
+ public abstract <T> T getWidget(Class<T> paramClass);
+
+ public abstract IArea getCroppedZone();
+
+ public abstract void setCroppedZone(IWidget paramIWidget, IArea paramIArea);
+
+ public abstract boolean isCroppedWidet();
+
+ public abstract IWidget getCropWidget();
+
+ public abstract boolean isMouseOverWidget(IPoint paramIPoint);
+
+ public abstract int getLevel();
+
+ public abstract boolean isDescendant(IWidget paramIWidget);
+
+ public abstract List<IWidgetAttribute> getAttributes();
+
+ public abstract boolean hasAttribute(IWidgetAttribute paramIWidgetAttribute);
+
+ public abstract boolean addAttribute(IWidgetAttribute paramIWidgetAttribute);
+
+ public abstract <E extends Event> void addEventHandler(EventHandler<E> paramEventHandler);
+
+ public abstract <E extends Event> void addSelfEventHandler(EventHandler<E> paramEventHandler);
+
+ public abstract boolean contains(IPoint paramIPoint);
+
+ public abstract float x();
+
+ public abstract float y();
+
+ public abstract float w();
+
+ public abstract float h();
+
+ public abstract void onRender(RenderStage paramRenderStage);
+}
diff --git a/src/Java/binnie/craftgui/core/IWidgetAttribute.java b/src/Java/binnie/craftgui/core/IWidgetAttribute.java
new file mode 100644
index 0000000000..87d994ca43
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/IWidgetAttribute.java
@@ -0,0 +1,3 @@
+package binnie.craftgui.core;
+
+public abstract interface IWidgetAttribute {}
diff --git a/src/Java/binnie/craftgui/core/RenderStage.java b/src/Java/binnie/craftgui/core/RenderStage.java
new file mode 100644
index 0000000000..e710c833e6
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/RenderStage.java
@@ -0,0 +1,8 @@
+package binnie.craftgui.core;
+
+public enum RenderStage
+{
+ PreChildren, PostChildren, PostSiblings;
+
+ private RenderStage() {}
+}
diff --git a/src/Java/binnie/craftgui/core/Tooltip.java b/src/Java/binnie/craftgui/core/Tooltip.java
new file mode 100644
index 0000000000..4afb7f6bc5
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/Tooltip.java
@@ -0,0 +1,84 @@
+package binnie.craftgui.core;
+
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.fluids.FluidStack;
+
+public class Tooltip
+{
+ public void add(String string)
+ {
+ this.tooltip.add(string);
+ }
+
+ public String getLine(int index)
+ {
+ String string = (String)getList().get(index);
+ return string;
+ }
+
+ public void add(List list)
+ {
+ for (Object obj : list) {
+ this.tooltip.add((String)obj);
+ }
+ }
+
+ List<String> tooltip = new ArrayList();
+
+ public List<String> getList()
+ {
+ return this.tooltip;
+ }
+
+ public boolean exists()
+ {
+ return this.tooltip.size() > 0;
+ }
+
+ public static enum Type
+ implements Tooltip.ITooltipType
+ {
+ Standard, Help, Information, User, Power;
+
+ private Type() {}
+ }
+
+ public void setType(ITooltipType type)
+ {
+ this.type = type;
+ }
+
+ ITooltipType type = Type.Standard;
+ public int maxWidth = 256;
+
+ public void setMaxWidth(int w)
+ {
+ this.maxWidth = w;
+ }
+
+ public ITooltipType getType()
+ {
+ return this.type;
+ }
+
+ public void add(ItemStack item, String string)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ item.writeToNBT(nbt);
+ nbt.setByte("nbt-type", (byte)105);
+ add("~~~" + nbt.toString() + "~~~" + string);
+ }
+
+ public void add(FluidStack item, String string)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ item.writeToNBT(nbt);
+ nbt.setByte("nbt-type", (byte)102);
+ add("~~~" + nbt.toString() + "~~~" + string);
+ }
+
+ public static abstract interface ITooltipType {}
+}
diff --git a/src/Java/binnie/craftgui/core/TopLevelWidget.java b/src/Java/binnie/craftgui/core/TopLevelWidget.java
new file mode 100644
index 0000000000..6f2cdd18a6
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/TopLevelWidget.java
@@ -0,0 +1,248 @@
+package binnie.craftgui.core;
+
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.events.EventMouse.Drag;
+import binnie.craftgui.events.EventMouse.Move;
+import binnie.craftgui.events.EventMouse.Up;
+import binnie.craftgui.events.EventMouse.Up.Handler;
+import binnie.craftgui.events.EventWidget.EndDrag;
+import binnie.craftgui.events.EventWidget.EndMouseOver;
+import binnie.craftgui.events.EventWidget.GainFocus;
+import binnie.craftgui.events.EventWidget.LoseFocus;
+import binnie.craftgui.events.EventWidget.StartDrag;
+import binnie.craftgui.events.EventWidget.StartDrag.Handler;
+import binnie.craftgui.events.EventWidget.StartMouseOver;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Deque;
+import java.util.List;
+import java.util.ListIterator;
+import org.lwjgl.input.Mouse;
+
+public abstract class TopLevelWidget
+ extends Widget
+ implements ITopLevelWidget
+{
+ public TopLevelWidget()
+ {
+ super(null);
+
+ addEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ TopLevelWidget.this.setDraggedWidget(TopLevelWidget.this.mousedOverWidget, event.getButton());
+ TopLevelWidget.this.setFocusedWidget(TopLevelWidget.this.mousedOverWidget);
+ }
+ });
+ addEventHandler(new EventMouse.Up.Handler()
+ {
+ public void onEvent(EventMouse.Up event)
+ {
+ TopLevelWidget.this.setDraggedWidget(null);
+ }
+ });
+ addEventHandler(new EventWidget.StartDrag.Handler()
+ {
+ public void onEvent(EventWidget.StartDrag event)
+ {
+ TopLevelWidget.this.dragStart = TopLevelWidget.this.getRelativeMousePosition();
+ }
+ });
+ }
+
+ IWidget mousedOverWidget = null;
+ IWidget draggedWidget = null;
+ IWidget focusedWidget = null;
+
+ public void setMousedOverWidget(IWidget widget)
+ {
+ if (this.mousedOverWidget == widget) {
+ return;
+ }
+ if (this.mousedOverWidget != null) {
+ callEvent(new EventWidget.EndMouseOver(this.mousedOverWidget));
+ }
+ this.mousedOverWidget = widget;
+ if (this.mousedOverWidget != null) {
+ callEvent(new EventWidget.StartMouseOver(this.mousedOverWidget));
+ }
+ }
+
+ public void setDraggedWidget(IWidget widget)
+ {
+ setDraggedWidget(widget, -1);
+ }
+
+ public void setDraggedWidget(IWidget widget, int button)
+ {
+ if (this.draggedWidget == widget) {
+ return;
+ }
+ if (this.draggedWidget != null) {
+ callEvent(new EventWidget.EndDrag(this.draggedWidget));
+ }
+ this.draggedWidget = widget;
+ if (this.draggedWidget != null) {
+ callEvent(new EventWidget.StartDrag(this.draggedWidget, button));
+ }
+ }
+
+ public void setFocusedWidget(IWidget widget)
+ {
+ IWidget newWidget = widget;
+ if (this.focusedWidget == newWidget) {
+ return;
+ }
+ if ((newWidget != null) && (!newWidget.canFocus())) {
+ newWidget = null;
+ }
+ if (this.focusedWidget != null) {
+ callEvent(new EventWidget.LoseFocus(this.focusedWidget));
+ }
+ this.focusedWidget = newWidget;
+ if (this.focusedWidget != null) {
+ callEvent(new EventWidget.GainFocus(this.focusedWidget));
+ }
+ }
+
+ public IWidget getMousedOverWidget()
+ {
+ return this.mousedOverWidget;
+ }
+
+ public IWidget getDraggedWidget()
+ {
+ return this.draggedWidget;
+ }
+
+ public IWidget getFocusedWidget()
+ {
+ return this.focusedWidget;
+ }
+
+ public boolean isMouseOver(IWidget widget)
+ {
+ return getMousedOverWidget() == widget;
+ }
+
+ public boolean isDragged(IWidget widget)
+ {
+ return getDraggedWidget() == widget;
+ }
+
+ public boolean isFocused(IWidget widget)
+ {
+ return getFocusedWidget() == widget;
+ }
+
+ public void updateTopLevel()
+ {
+ setMousedOverWidget(calculateMousedOverWidget());
+ if ((getFocusedWidget() != null) && ((!getFocusedWidget().isVisible()) || (!getFocusedWidget().isEnabled()))) {
+ setFocusedWidget(null);
+ }
+ if (!Mouse.isButtonDown(0)) {
+ if (this.draggedWidget != null) {
+ setDraggedWidget(null);
+ }
+ }
+ }
+
+ private IWidget calculateMousedOverWidget()
+ {
+ Deque<IWidget> queue = calculateMousedOverWidgets();
+ while (!queue.isEmpty())
+ {
+ IWidget widget = (IWidget)queue.removeFirst();
+ if ((widget.isEnabled()) && (widget.isVisible()) && (widget.canMouseOver())) {
+ if ((widget.isEnabled()) && (widget.isVisible()) && (widget.canMouseOver()) && (widget.calculateIsMouseOver())) {
+ return widget;
+ }
+ }
+ }
+ return null;
+ }
+
+ public Deque<IWidget> calculateMousedOverWidgets()
+ {
+ Deque<IWidget> list = new ArrayDeque();
+ for (IWidget widget : getQueuedWidgets(this)) {
+ if (widget.calculateIsMouseOver()) {
+ list.addLast(widget);
+ }
+ }
+ return list;
+ }
+
+ private Collection<IWidget> getQueuedWidgets(IWidget widget)
+ {
+ List<IWidget> widgets = new ArrayList();
+
+ boolean addChildren = true;
+ if (widget.isCroppedWidet()) {
+ addChildren = widget.getCroppedZone().contains(widget.getCropWidget().getRelativeMousePosition());
+ }
+ if (addChildren)
+ {
+ ListIterator<IWidget> li = widget.getWidgets().listIterator(widget.getWidgets().size());
+ while (li.hasPrevious())
+ {
+ IWidget child = (IWidget)li.previous();
+ widgets.addAll(getQueuedWidgets(child));
+ }
+ }
+ widgets.add(widget);
+
+ return widgets;
+ }
+
+ protected IPoint mousePosition = new IPoint(0.0F, 0.0F);
+
+ public void setMousePosition(int x, int y)
+ {
+ float dx = x - this.mousePosition.x();
+ float dy = y - this.mousePosition.y();
+ if ((dx != 0.0F) || (dy != 0.0F)) {
+ if (getDraggedWidget() != null) {
+ callEvent(new EventMouse.Drag(getDraggedWidget(), dx, dy));
+ } else {
+ callEvent(new EventMouse.Move(this, dx, dy));
+ }
+ }
+ if ((this.mousePosition.x() != x) || (this.mousePosition.y() != y))
+ {
+ this.mousePosition = new IPoint(x, y);
+ setMousedOverWidget(calculateMousedOverWidget());
+ }
+ }
+
+ public IPoint getAbsoluteMousePosition()
+ {
+ return this.mousePosition;
+ }
+
+ public void widgetDeleted(IWidget widget)
+ {
+ if (isMouseOver(widget)) {
+ setMousedOverWidget(null);
+ }
+ if (isDragged(widget)) {
+ setDraggedWidget(null);
+ }
+ if (isFocused(widget)) {
+ setFocusedWidget(null);
+ }
+ }
+
+ IPoint dragStart = IPoint.ZERO;
+
+ public IPoint getDragDistance()
+ {
+ return getRelativeMousePosition().sub(this.dragStart);
+ }
+}
diff --git a/src/Java/binnie/craftgui/core/Widget.java b/src/Java/binnie/craftgui/core/Widget.java
new file mode 100644
index 0000000000..448bcbaed6
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/Widget.java
@@ -0,0 +1,499 @@
+package binnie.craftgui.core;
+
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.Event;
+import binnie.craftgui.events.EventHandler;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventWidget.ChangeColour;
+import binnie.craftgui.events.EventWidget.ChangeOffset;
+import binnie.craftgui.events.EventWidget.ChangePosition;
+import binnie.craftgui.events.EventWidget.ChangeSize;
+import binnie.craftgui.events.EventWidget.Disable;
+import binnie.craftgui.events.EventWidget.Enable;
+import binnie.craftgui.events.EventWidget.Hide;
+import binnie.craftgui.events.EventWidget.Show;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.ConcurrentModificationException;
+import java.util.List;
+
+public class Widget
+ implements IWidget
+{
+ public Widget(IWidget parent)
+ {
+ this.parent = parent;
+ if (parent != null) {
+ parent.addWidget(this);
+ }
+ }
+
+ private IWidget parent = null;
+ private List<IWidget> subWidgets = new ArrayList();
+ private List<IWidgetAttribute> attributes = new ArrayList();
+
+ public List<IWidgetAttribute> getAttributes()
+ {
+ return this.attributes;
+ }
+
+ public boolean hasAttribute(IWidgetAttribute attribute)
+ {
+ return this.attributes.contains(attribute);
+ }
+
+ public boolean addAttribute(IWidgetAttribute attribute)
+ {
+ return this.attributes.add(attribute);
+ }
+
+ public final void deleteChild(IWidget child)
+ {
+ if (child == null) {
+ return;
+ }
+ child.delete();
+ this.subWidgets.remove(child);
+ }
+
+ public final void deleteAllChildren()
+ {
+ while (!this.subWidgets.isEmpty()) {
+ deleteChild((IWidget)this.subWidgets.get(0));
+ }
+ }
+
+ public final IWidget getParent()
+ {
+ return this.parent;
+ }
+
+ public final ITopLevelWidget getSuperParent()
+ {
+ return isTopLevel() ? (ITopLevelWidget)this : this.parent.getSuperParent();
+ }
+
+ public final IWidget addWidget(IWidget widget)
+ {
+ if ((this.subWidgets.size() != 0) && (((IWidget)this.subWidgets.get(this.subWidgets.size() - 1)).hasAttribute(Attribute.AlwaysOnTop))) {
+ this.subWidgets.add(this.subWidgets.size() - 1, widget);
+ } else {
+ this.subWidgets.add(widget);
+ }
+ onAddChild(widget);
+ return widget;
+ }
+
+ protected void onAddChild(IWidget widget) {}
+
+ public final List<IWidget> getWidgets()
+ {
+ return this.subWidgets;
+ }
+
+ public final boolean isTopLevel()
+ {
+ return this instanceof ITopLevelWidget;
+ }
+
+ private IPoint position = new IPoint(0.0F, 0.0F);
+ private IPoint size = new IPoint(0.0F, 0.0F);
+ private IPoint offset = new IPoint(0.0F, 0.0F);
+ IArea cropArea;
+ IWidget cropWidget;
+
+ public final IPoint pos()
+ {
+ return this.position.add(this.offset);
+ }
+
+ public final IPoint size()
+ {
+ return this.size;
+ }
+
+ public final IArea area()
+ {
+ return getArea();
+ }
+
+ public final IPoint getPosition()
+ {
+ return pos();
+ }
+
+ public final IArea getArea()
+ {
+ return new IArea(IPoint.ZERO, size());
+ }
+
+ public final IPoint getOriginalPosition()
+ {
+ return this.position;
+ }
+
+ boolean cropped = false;
+
+ public IArea getCroppedZone()
+ {
+ return this.cropArea;
+ }
+
+ public void setCroppedZone(IWidget relative, IArea area)
+ {
+ this.cropArea = area;
+ this.cropped = true;
+ this.cropWidget = relative;
+ }
+
+ public final IPoint getAbsolutePosition()
+ {
+ return isTopLevel() ? getPosition() : getParent().getAbsolutePosition().add(getPosition());
+ }
+
+ public final IPoint getOriginalAbsolutePosition()
+ {
+ return isTopLevel() ? getOriginalPosition() : getParent().getOriginalPosition().sub(getOriginalPosition());
+ }
+
+ public final IPoint getSize()
+ {
+ return size();
+ }
+
+ public final IPoint getOffset()
+ {
+ return this.offset;
+ }
+
+ public final void setPosition(IPoint vector)
+ {
+ if (!vector.equals(this.position))
+ {
+ this.position = new IPoint(vector);
+ callEvent(new EventWidget.ChangePosition(this));
+ }
+ }
+
+ public final void setSize(IPoint vector)
+ {
+ if (!vector.equals(this.size))
+ {
+ this.size = new IPoint(vector);
+ callEvent(new EventWidget.ChangeSize(this));
+ }
+ }
+
+ public final void setOffset(IPoint vector)
+ {
+ if (vector != this.offset)
+ {
+ this.offset = new IPoint(vector);
+ callEvent(new EventWidget.ChangeOffset(this));
+ }
+ }
+
+ int colour = 16777215;
+
+ public final void setColour(int colour)
+ {
+ if (this.colour != colour)
+ {
+ this.colour = colour;
+ callEvent(new EventWidget.ChangeColour(this));
+ }
+ }
+
+ public final int getColour()
+ {
+ return this.colour;
+ }
+
+ public boolean canMouseOver()
+ {
+ return hasAttribute(Attribute.MouseOver);
+ }
+
+ public boolean canFocus()
+ {
+ return hasAttribute(Attribute.CanFocus);
+ }
+
+ private Collection<EventHandler> globalEventHandlers = new ArrayList();
+
+ public void addEventHandler(EventHandler handler)
+ {
+ this.globalEventHandlers.add(handler);
+ }
+
+ public void addSelfEventHandler(EventHandler handler)
+ {
+ addEventHandler(handler.setOrigin(EventHandler.Origin.Self, this));
+ }
+
+ public final void callEvent(Event event)
+ {
+ getSuperParent().recieveEvent(event);
+ }
+
+ public final void recieveEvent(Event event)
+ {
+ for (EventHandler handler : this.globalEventHandlers) {
+ if (handler.handles(event)) {
+ handler.onEvent(event);
+ }
+ }
+ try
+ {
+ for (IWidget child : getWidgets()) {
+ child.recieveEvent(event);
+ }
+ }
+ catch (ConcurrentModificationException e) {}
+ }
+
+ public final IPoint getMousePosition()
+ {
+ return getSuperParent().getAbsoluteMousePosition();
+ }
+
+ public final IPoint getRelativeMousePosition()
+ {
+ return isTopLevel() ? getMousePosition() : getParent().getRelativeMousePosition().sub(getPosition());
+ }
+
+ public boolean isCroppedWidet()
+ {
+ return this.cropped;
+ }
+
+ public final IWidget getCropWidget()
+ {
+ return this.cropWidget == null ? this : this.cropWidget;
+ }
+
+ public final void render()
+ {
+ if (isVisible())
+ {
+ CraftGUI.Render.preRender(this);
+ onRender(RenderStage.PreChildren);
+ for (IWidget widget : getWidgets()) {
+ widget.render();
+ }
+ for (IWidget widget : getWidgets())
+ {
+ CraftGUI.Render.preRender(widget);
+ widget.onRender(RenderStage.PostSiblings);
+ CraftGUI.Render.postRender(widget);
+ }
+ onRender(RenderStage.PostChildren);
+ CraftGUI.Render.postRender(this);
+ }
+ }
+
+ public final void updateClient()
+ {
+ if (!isVisible()) {
+ return;
+ }
+ if (getSuperParent() == this) {
+ ((ITopLevelWidget)this).updateTopLevel();
+ }
+ onUpdateClient();
+
+ List<IWidget> deletedWidgets = new ArrayList();
+ for (IWidget widget : getWidgets()) {
+ if (widget.hasAttribute(Attribute.NeedsDeletion)) {
+ deletedWidgets.add(widget);
+ } else {
+ widget.updateClient();
+ }
+ }
+ for (IWidget widget : deletedWidgets) {
+ deleteChild(widget);
+ }
+ }
+
+ public final boolean calculateIsMouseOver()
+ {
+ IPoint mouse = getRelativeMousePosition();
+ if (!this.cropped) {
+ return isMouseOverWidget(mouse);
+ }
+ IWidget cropRelative = this.cropWidget != null ? this.cropWidget : this;
+ IPoint pos = IPoint.sub(cropRelative.getAbsolutePosition(), getAbsolutePosition());
+ IPoint size = new IPoint(this.cropArea.size().x(), this.cropArea.size().y());
+ boolean inCrop = (mouse.x() > pos.x()) && (mouse.y() > pos.y()) && (mouse.x() < pos.x() + size.x()) && (mouse.y() < pos.y() + size.y());
+
+ return (inCrop) && (isMouseOverWidget(mouse));
+ }
+
+ public boolean isMouseOverWidget(IPoint relativeMouse)
+ {
+ return getArea().contains(relativeMouse);
+ }
+
+ private boolean enabled = true;
+ private boolean visible = true;
+
+ public final void enable()
+ {
+ this.enabled = true;
+ callEvent(new EventWidget.Enable(this));
+ }
+
+ public final void disable()
+ {
+ this.enabled = false;
+ callEvent(new EventWidget.Disable(this));
+ }
+
+ public final void show()
+ {
+ this.visible = true;
+ callEvent(new EventWidget.Show(this));
+ }
+
+ public final void hide()
+ {
+ this.visible = false;
+ callEvent(new EventWidget.Hide(this));
+ }
+
+ public boolean isEnabled()
+ {
+ return (this.enabled) && ((isTopLevel()) || ((getParent().isEnabled()) && (getParent().isChildEnabled(this))));
+ }
+
+ public final boolean isVisible()
+ {
+ return (this.visible) && ((isTopLevel()) || ((getParent().isVisible()) && (getParent().isChildVisible(this))));
+ }
+
+ public final boolean isFocused()
+ {
+ return getSuperParent().isFocused(this);
+ }
+
+ public final boolean isDragged()
+ {
+ return getSuperParent().isDragged(this);
+ }
+
+ public final boolean isMouseOver()
+ {
+ return getSuperParent().isMouseOver(this);
+ }
+
+ public boolean isChildVisible(IWidget child)
+ {
+ return true;
+ }
+
+ public boolean isChildEnabled(IWidget child)
+ {
+ return true;
+ }
+
+ public void onRender(RenderStage stage)
+ {
+ if (stage == RenderStage.PreChildren) {
+ onRenderBackground();
+ }
+ if (stage == RenderStage.PostChildren) {
+ onRenderForeground();
+ }
+ if (stage == RenderStage.PostSiblings) {
+ onRenderOverlay();
+ }
+ }
+
+ public void onRenderBackground() {}
+
+ public void onRenderForeground() {}
+
+ public void onRenderOverlay() {}
+
+ public void onUpdateClient() {}
+
+ public final void delete()
+ {
+ getSuperParent().widgetDeleted(this);
+ onDelete();
+ }
+
+ public void onDelete() {}
+
+ public <T> T getWidget(Class<T> x)
+ {
+ for (IWidget child : getWidgets())
+ {
+ if (x.isInstance(child)) {
+ return child;
+ }
+ T found = child.getWidget(x);
+ if (found != null) {
+ return found;
+ }
+ }
+ return null;
+ }
+
+ public final boolean contains(IPoint position)
+ {
+ return getArea().contains(position);
+ }
+
+ public void scheduleDeletion()
+ {
+ addAttribute(Attribute.NeedsDeletion);
+ }
+
+ public int getLevel()
+ {
+ int level = getParent() == null ? 0 : getParent().getLevel();
+ int index = getParent() == null ? 0 : getParent().getWidgets().indexOf(this);
+ return level + index;
+ }
+
+ public boolean isDescendant(IWidget widget)
+ {
+ IWidget clss = this;
+ do
+ {
+ if (clss == widget) {
+ return true;
+ }
+ clss = clss.getParent();
+ } while (clss != null);
+ return false;
+ }
+
+ public float x()
+ {
+ return pos().x();
+ }
+
+ public float y()
+ {
+ return pos().y();
+ }
+
+ public float w()
+ {
+ return size().x();
+ }
+
+ public float h()
+ {
+ return size().y();
+ }
+
+ public IWidget getWidget()
+ {
+ return this;
+ }
+}
diff --git a/src/Java/binnie/craftgui/core/geometry/CraftGUIUtil.java b/src/Java/binnie/craftgui/core/geometry/CraftGUIUtil.java
new file mode 100644
index 0000000000..5a21e313d4
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/geometry/CraftGUIUtil.java
@@ -0,0 +1,77 @@
+package binnie.craftgui.core.geometry;
+
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.events.EventValueChanged;
+import binnie.craftgui.events.EventValueChanged.Handler;
+
+public class CraftGUIUtil
+{
+ public static void alignToWidget(IWidget target, IWidget relativeTo)
+ {
+ IPoint startPos = target.getAbsolutePosition();
+ IPoint endPos = relativeTo.getAbsolutePosition();
+ moveWidget(target, endPos.sub(startPos));
+ }
+
+ public static void moveWidget(IWidget target, IPoint movement)
+ {
+ target.setPosition(target.getPosition().add(movement));
+ }
+
+ public static void horizontalGrid(float px, float py, IWidget... widgets)
+ {
+ horizontalGrid(px, py, TextJustification.MiddleCenter, 0.0F, widgets);
+ }
+
+ public static void horizontalGrid(float px, float py, TextJustification just, float spacing, IWidget... widgets)
+ {
+ float x = 0.0F;
+ float h = 0.0F;
+ for (IWidget widget : widgets) {
+ h = Math.max(h, widget.getSize().y());
+ }
+ for (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(float px, float py, IWidget... widgets)
+ {
+ horizontalGrid(px, py, TextJustification.MiddleCenter, 0.0F, widgets);
+ }
+
+ public static void verticalGrid(float px, float py, TextJustification just, float spacing, IWidget... widgets)
+ {
+ float y = 0.0F;
+ float w = 0.0F;
+ for (IWidget widget : widgets) {
+ w = Math.max(w, widget.getSize().x());
+ }
+ for (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(IControlValue<T> tab, IControlValue<T> target)
+ {
+ tab.addSelfEventHandler(new EventValueChanged.Handler()
+ {
+ public void onEvent(EventValueChanged event)
+ {
+ this.val$target.setValue(event.getValue());
+ }
+ });
+ target.addSelfEventHandler(new EventValueChanged.Handler()
+ {
+ public void onEvent(EventValueChanged event)
+ {
+ this.val$tab.setValue(event.getValue());
+ }
+ });
+ }
+}
diff --git a/src/Java/binnie/craftgui/core/geometry/IArea.java b/src/Java/binnie/craftgui/core/geometry/IArea.java
new file mode 100644
index 0000000000..c6b5511773
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/geometry/IArea.java
@@ -0,0 +1,143 @@
+package binnie.craftgui.core.geometry;
+
+public class IArea
+{
+ private IPoint pos;
+ private IPoint size;
+
+ public IArea(IArea area)
+ {
+ this(area.pos().x(), area.pos().y(), area.size().x(), area.size().y());
+ }
+
+ public IArea(IPoint pos, IPoint size)
+ {
+ this(pos.x(), pos.y(), size.x(), size.y());
+ }
+
+ public IArea(float xywh)
+ {
+ this(xywh, xywh, xywh, xywh);
+ }
+
+ public IArea(float xy, float wh)
+ {
+ this(xy, xy, wh, wh);
+ }
+
+ public IArea(float x, float y, float wh)
+ {
+ this(x, y, wh, wh);
+ }
+
+ public IArea(float x, float y, float w, float h)
+ {
+ setPosition(new IPoint(x, y));
+ setSize(new IPoint(w, h));
+ }
+
+ public IPoint pos()
+ {
+ return this.pos;
+ }
+
+ public IPoint getPosition()
+ {
+ return this.pos;
+ }
+
+ public void setPosition(IPoint position)
+ {
+ this.pos = position.copy();
+ }
+
+ public IPoint size()
+ {
+ return this.size;
+ }
+
+ public IPoint getSize()
+ {
+ return this.size;
+ }
+
+ public void setSize(IPoint size)
+ {
+ this.size = size.copy();
+ }
+
+ public boolean contains(IPoint position)
+ {
+ return (position.x() >= pos().x()) && (position.y() >= this.pos.y()) && (position.x() <= pos().x() + size().x()) && (position.y() <= pos().y() + size().y());
+ }
+
+ public float x()
+ {
+ return pos().x();
+ }
+
+ public float y()
+ {
+ return pos().y();
+ }
+
+ public float w()
+ {
+ return size().x();
+ }
+
+ public float h()
+ {
+ return size().y();
+ }
+
+ public float x(float n)
+ {
+ return this.pos.x(n);
+ }
+
+ public float y(float n)
+ {
+ return this.pos.y(n);
+ }
+
+ public float w(float n)
+ {
+ return this.size.x(n);
+ }
+
+ public float h(float n)
+ {
+ return this.size.y(n);
+ }
+
+ public IArea inset(IBorder border)
+ {
+ return new IArea(x() + border.l(), y() + border.t(), w() - border.l() - border.r(), h() - border.t() - border.b());
+ }
+
+ public IArea outset(int outset)
+ {
+ return outset(new IBorder(outset));
+ }
+
+ public IArea outset(IBorder border)
+ {
+ return new IArea(x() - border.l(), y() - border.t(), w() + border.l() + border.r(), h() + border.t() + border.b());
+ }
+
+ public IArea inset(int inset)
+ {
+ return inset(new IBorder(inset));
+ }
+
+ public String toString()
+ {
+ return w() + "x" + h() + "@" + x() + "," + y();
+ }
+
+ public IArea shift(float dx, float f)
+ {
+ return new IArea(x() + dx, y() + f, w(), h());
+ }
+}
diff --git a/src/Java/binnie/craftgui/core/geometry/IBorder.java b/src/Java/binnie/craftgui/core/geometry/IBorder.java
new file mode 100644
index 0000000000..e16b6d97f1
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/geometry/IBorder.java
@@ -0,0 +1,126 @@
+package binnie.craftgui.core.geometry;
+
+public class IBorder
+{
+ public static final IBorder ZERO = new IBorder(0.0F);
+ float t;
+ float b;
+ float l;
+ float r;
+
+ public IBorder(float pad)
+ {
+ this(pad, pad, pad, pad);
+ }
+
+ public IBorder(float tb, float rl)
+ {
+ this(tb, rl, tb, rl);
+ }
+
+ public IBorder(float t, float rl, float b)
+ {
+ this(t, rl, b, rl);
+ }
+
+ public IBorder(float t, float r, float b, float l)
+ {
+ this.t = t;
+ this.b = b;
+ this.l = l;
+ this.r = r;
+ }
+
+ public IBorder(Position edge, 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(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(float n)
+ {
+ this.t = n;
+ return this.t;
+ }
+
+ public float b(float n)
+ {
+ this.b = n;
+ return this.b;
+ }
+
+ public float l(float n)
+ {
+ this.l = n;
+ return this.l;
+ }
+
+ public float r(float n)
+ {
+ this.r = n;
+ return this.r;
+ }
+
+ 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(l(), t());
+ }
+
+ @Deprecated
+ public IPoint tr()
+ {
+ return new IPoint(r(), t());
+ }
+
+ @Deprecated
+ public IPoint bl()
+ {
+ return new IPoint(l(), b());
+ }
+
+ @Deprecated
+ public IPoint br()
+ {
+ return new IPoint(r(), b());
+ }
+
+ public IBorder add(IBorder o)
+ {
+ return new IBorder(t() + o.t(), r() + o.r(), b() + o.b(), l() + o.l());
+ }
+
+ public String toString()
+ {
+ return t() + "-" + r() + "-" + b() + "-" + l();
+ }
+}
diff --git a/src/Java/binnie/craftgui/core/geometry/IPoint.java b/src/Java/binnie/craftgui/core/geometry/IPoint.java
new file mode 100644
index 0000000000..53be8972fd
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/geometry/IPoint.java
@@ -0,0 +1,83 @@
+package binnie.craftgui.core.geometry;
+
+public class IPoint
+{
+ public static final IPoint ZERO = new IPoint(0.0F, 0.0F);
+ float x = 0.0F;
+ float y = 0.0F;
+
+ public IPoint(float x, float y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+
+ public IPoint(IPoint o)
+ {
+ this.x = o.x();
+ this.y = o.y();
+ }
+
+ public static IPoint add(IPoint a, IPoint b)
+ {
+ return new IPoint(a.x() + b.x(), a.y() + b.y());
+ }
+
+ public static IPoint sub(IPoint a, IPoint b)
+ {
+ return new IPoint(a.x() - b.x(), a.y() - b.y());
+ }
+
+ public IPoint sub(IPoint a)
+ {
+ return sub(this, a);
+ }
+
+ public IPoint add(IPoint other)
+ {
+ return add(this, other);
+ }
+
+ public IPoint add(float dx, 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(float x, float y)
+ {
+ x(x);
+ y(y);
+ }
+
+ public float x(float x)
+ {
+ this.x = x;
+ return x;
+ }
+
+ public float y(float y)
+ {
+ this.y = y;
+ return y;
+ }
+
+ public boolean equals(IPoint other)
+ {
+ return (x() == other.x()) && (y() == other.y());
+ }
+}
diff --git a/src/Java/binnie/craftgui/core/geometry/Position.java b/src/Java/binnie/craftgui/core/geometry/Position.java
new file mode 100644
index 0000000000..51b856f120
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/geometry/Position.java
@@ -0,0 +1,41 @@
+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(int x, int y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+
+ public int x()
+ {
+ return this.x;
+ }
+
+ public int y()
+ {
+ return this.y;
+ }
+
+ public Position opposite()
+ {
+ switch (1.$SwitchMap$binnie$craftgui$core$geometry$Position[ordinal()])
+ {
+ case 1:
+ return Top;
+ case 2:
+ return Right;
+ case 3:
+ return Left;
+ case 4:
+ return Bottom;
+ }
+ return null;
+ }
+}
diff --git a/src/Java/binnie/craftgui/core/geometry/TextJustification.java b/src/Java/binnie/craftgui/core/geometry/TextJustification.java
new file mode 100644
index 0000000000..99b759380b
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/geometry/TextJustification.java
@@ -0,0 +1,25 @@
+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(float xOffset, float yOffset)
+ {
+ this.xOffset = xOffset;
+ this.yOffset = yOffset;
+ }
+
+ public float getXOffset()
+ {
+ return this.xOffset;
+ }
+
+ public float getYOffset()
+ {
+ return this.yOffset;
+ }
+}
diff --git a/src/Java/binnie/craftgui/core/renderer/Renderer.java b/src/Java/binnie/craftgui/core/renderer/Renderer.java
new file mode 100644
index 0000000000..b1d099bf3a
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/renderer/Renderer.java
@@ -0,0 +1,252 @@
+package binnie.craftgui.core.renderer;
+
+import binnie.core.BinnieCore;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IBorder;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.minecraft.GuiCraftGUI;
+import binnie.craftgui.resource.IStyleSheet;
+import binnie.craftgui.resource.Texture;
+import java.util.List;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import org.lwjgl.opengl.GL11;
+
+public class Renderer
+{
+ GuiCraftGUI gui;
+
+ public Renderer(GuiCraftGUI gui)
+ {
+ this.gui = gui;
+ }
+
+ public final void preRender(IWidget widget)
+ {
+ GL11.glPushMatrix();
+ GL11.glTranslatef(widget.getPosition().x(), widget.getPosition().y(), 0.0F);
+ colour(widget.getColour());
+ if (widget.isCroppedWidet())
+ {
+ IWidget cropRelative = widget.getCropWidget() != null ? widget.getCropWidget() : widget;
+ IPoint pos = cropRelative.getAbsolutePosition();
+ IArea cropZone = widget.getCroppedZone();
+ limitArea(new IArea(pos.add(cropZone.pos()), cropZone.size()));
+ GL11.glEnable(3089);
+ }
+ GL11.glDisable(2929);
+ }
+
+ public final void postRender(IWidget widget)
+ {
+ if (widget.isCroppedWidet()) {
+ GL11.glDisable(3089);
+ }
+ GL11.glEnable(2929);
+ GL11.glPopMatrix();
+ }
+
+ int currentColour = 16777215;
+ Texture currentTexture;
+ IStyleSheet stylesheet;
+
+ public void colour(int hex)
+ {
+ this.currentColour = hex;
+ int a = (hex & 0xFF000000) >> 24;
+ int r = (hex & 0xFF0000) >> 16;
+ int g = (hex & 0xFF00) >> 8;
+ 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(Object key)
+ {
+ if ((key instanceof Texture)) {
+ return (Texture)key;
+ }
+ return this.stylesheet.getTexture(key);
+ }
+
+ public void setTexture(Texture texture)
+ {
+ if ((texture != this.currentTexture) && (texture != null)) {
+ BinnieCore.proxy.bindTexture(texture.getFilename());
+ }
+ colour(this.currentColour);
+ }
+
+ public void texture(Object texture, IPoint position)
+ {
+ texture(getTexture(texture), position);
+ }
+
+ public void texture(Texture texture, IPoint position)
+ {
+ if (texture == null) {
+ return;
+ }
+ setTexture(texture);
+ IPoint point = position.sub(new IPoint(texture.getBorder().l(), texture.getBorder().t()));
+ IArea textureArea = texture.getArea().outset(texture.getBorder());
+ this.gui.renderTexture(point, textureArea);
+ }
+
+ public void texture(Object window, IArea area)
+ {
+ texture(getTexture(window), area);
+ }
+
+ public void texture(Texture texture, IArea area)
+ {
+ if (texture == null) {
+ return;
+ }
+ setTexture(texture);
+ IArea textureArea = texture.getArea().outset(texture.getBorder());
+ 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(IStyleSheet sheet)
+ {
+ this.stylesheet = sheet;
+ }
+
+ public int textWidth(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(IPoint pos, String text, int colour)
+ {
+ text(new IArea(pos, new IPoint(500.0F, 500.0F)), TextJustification.TopLeft, text, colour);
+ }
+
+ public void text(IArea area, TextJustification justification, String text, int colour)
+ {
+ IPoint pos = area.pos();
+ if (area.size().x() <= 0.0F) {
+ return;
+ }
+ List<String> wrappedStrings = this.gui.getFontRenderer().listFormattedStringToWidth(text, (int)area.size().x());
+ float totalHeight = wrappedStrings.size() * textHeight();
+ float posY = area.pos().y();
+ if (area.size().y() > totalHeight) {
+ posY += (area.size().y() - totalHeight) * justification.getYOffset();
+ }
+ for (String string : wrappedStrings)
+ {
+ float stringWidth = 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 += textHeight();
+ }
+ GL11.glColor3f(1.0F, 1.0F, 1.0F);
+ }
+
+ public void solid(IArea area, 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(IArea area, 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(IArea area, int c1, 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(IPoint pos, ItemStack item)
+ {
+ this.gui.renderItem(pos, item, false);
+ }
+
+ public void item(IPoint pos, ItemStack item, boolean rotating)
+ {
+ this.gui.renderItem(pos, item, rotating);
+ }
+
+ public void iconBlock(IPoint pos, IIcon icon)
+ {
+ this.gui.renderIcon(pos, icon, TextureMap.locationBlocksTexture);
+ }
+
+ public void iconItem(IPoint pos, IIcon icon)
+ {
+ this.gui.renderIcon(pos, icon, TextureMap.locationItemsTexture);
+ }
+
+ public void limitArea(IArea area)
+ {
+ this.gui.limitArea(area);
+ }
+
+ public float textHeight(String text, float width)
+ {
+ return this.gui.getFontRenderer().listFormattedStringToWidth(text, (int)width).size() * textHeight();
+ }
+
+ public void texturePercentage(Texture texture, IArea area, Position direction, float percentage)
+ {
+ float dist = (direction == Position.Top) || (direction == Position.Bottom) ? percentage * texture.h() : percentage * texture.w();
+
+ 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 (1.$SwitchMap$binnie$craftgui$core$geometry$Position[direction.ordinal()])
+ {
+ case 1:
+ h *= percentage;
+ break;
+ case 2:
+ x += (1.0F - percentage) * w;
+ w *= percentage;
+ break;
+ case 3:
+ w *= percentage;
+ break;
+ case 4:
+ y += h - (int)(percentage * h);
+ h *= percentage;
+ }
+ texture(texture.crop(direction, dim - dist), new IArea(x, y, w, h));
+ }
+
+ public void test(IWidget widget) {}
+}
diff --git a/src/Java/binnie/craftgui/core/renderer/TextureType.java b/src/Java/binnie/craftgui/core/renderer/TextureType.java
new file mode 100644
index 0000000000..1c9b0e0d1c
--- /dev/null
+++ b/src/Java/binnie/craftgui/core/renderer/TextureType.java
@@ -0,0 +1,8 @@
+package binnie.craftgui.core.renderer;
+
+public enum TextureType
+{
+ Stretched, Tiled;
+
+ private TextureType() {}
+}
diff --git a/src/Java/binnie/craftgui/events/Event.java b/src/Java/binnie/craftgui/events/Event.java
new file mode 100644
index 0000000000..0b4a39426a
--- /dev/null
+++ b/src/Java/binnie/craftgui/events/Event.java
@@ -0,0 +1,23 @@
+package binnie.craftgui.events;
+
+import binnie.craftgui.core.IWidget;
+
+public class Event
+{
+ IWidget origin;
+
+ public Event(IWidget origin)
+ {
+ this.origin = origin;
+ }
+
+ public IWidget getOrigin()
+ {
+ return this.origin;
+ }
+
+ public boolean isOrigin(IWidget widget)
+ {
+ return this.origin == widget;
+ }
+}
diff --git a/src/Java/binnie/craftgui/events/EventButtonClicked.java b/src/Java/binnie/craftgui/events/EventButtonClicked.java
new file mode 100644
index 0000000000..1823e6d430
--- /dev/null
+++ b/src/Java/binnie/craftgui/events/EventButtonClicked.java
@@ -0,0 +1,21 @@
+package binnie.craftgui.events;
+
+import binnie.craftgui.core.IWidget;
+
+public class EventButtonClicked
+ extends Event
+{
+ public EventButtonClicked(IWidget origin)
+ {
+ super(origin);
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventButtonClicked>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/events/EventCycleChanged.java b/src/Java/binnie/craftgui/events/EventCycleChanged.java
new file mode 100644
index 0000000000..628a177449
--- /dev/null
+++ b/src/Java/binnie/craftgui/events/EventCycleChanged.java
@@ -0,0 +1,20 @@
+package binnie.craftgui.events;
+
+import binnie.craftgui.core.IWidget;
+
+public class EventCycleChanged
+ extends Event
+{
+ public int value;
+
+ public EventCycleChanged(IWidget origin, int value)
+ {
+ super(origin);
+ this.value = value;
+ }
+
+ public int getValue()
+ {
+ return this.value;
+ }
+}
diff --git a/src/Java/binnie/craftgui/events/EventHandler.java b/src/Java/binnie/craftgui/events/EventHandler.java
new file mode 100644
index 0000000000..9d2e5d2ad3
--- /dev/null
+++ b/src/Java/binnie/craftgui/events/EventHandler.java
@@ -0,0 +1,53 @@
+package binnie.craftgui.events;
+
+import binnie.craftgui.core.IWidget;
+import java.util.List;
+
+public abstract class EventHandler<E extends Event>
+{
+ Class<E> eventClass;
+ Origin origin = Origin.Any;
+ IWidget relative = null;
+
+ public EventHandler(Class<E> eventClass)
+ {
+ this.eventClass = eventClass;
+ }
+
+ public EventHandler setOrigin(Origin origin, IWidget relative)
+ {
+ this.origin = origin;
+ this.relative = relative;
+ return this;
+ }
+
+ public abstract void onEvent(E paramE);
+
+ public final boolean handles(Event e)
+ {
+ return (this.eventClass.isInstance(e)) && (this.origin.isOrigin(e.getOrigin(), this.relative));
+ }
+
+ public static enum Origin
+ {
+ Any, Self, Parent, DirectChild;
+
+ private Origin() {}
+
+ public boolean isOrigin(IWidget origin, IWidget test)
+ {
+ switch (EventHandler.1.$SwitchMap$binnie$craftgui$events$EventHandler$Origin[ordinal()])
+ {
+ case 1:
+ return true;
+ case 2:
+ return test.getWidgets().contains(origin);
+ case 3:
+ return test.getParent() == origin;
+ case 4:
+ return test == origin;
+ }
+ return false;
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/events/EventKey.java b/src/Java/binnie/craftgui/events/EventKey.java
new file mode 100644
index 0000000000..e49b736f43
--- /dev/null
+++ b/src/Java/binnie/craftgui/events/EventKey.java
@@ -0,0 +1,63 @@
+package binnie.craftgui.events;
+
+import binnie.craftgui.core.IWidget;
+
+public abstract class EventKey
+ extends Event
+{
+ char character;
+ int key;
+
+ public EventKey(IWidget origin, char character, 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(IWidget origin, char character, int key)
+ {
+ super(character, key);
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventKey.Down>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class Up
+ extends EventKey
+ {
+ public Up(IWidget origin, char character, int key)
+ {
+ super(character, key);
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventKey.Up>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/events/EventMouse.java b/src/Java/binnie/craftgui/events/EventMouse.java
new file mode 100644
index 0000000000..162552098a
--- /dev/null
+++ b/src/Java/binnie/craftgui/events/EventMouse.java
@@ -0,0 +1,156 @@
+package binnie.craftgui.events;
+
+import binnie.craftgui.core.IWidget;
+
+public abstract class EventMouse
+ extends Event
+{
+ public EventMouse(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(IWidget currentMousedOverWidget, int x, int y, int button)
+ {
+ super();
+ this.x = x;
+ this.y = y;
+ this.button = button;
+ }
+ }
+
+ public static class Down
+ extends EventMouse.Button
+ {
+ public Down(IWidget currentMousedOverWidget, int x, int y, int button)
+ {
+ super(x, y, button);
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventMouse.Down>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class Up
+ extends EventMouse.Button
+ {
+ public Up(IWidget currentMousedOverWidget, int x, int y, int button)
+ {
+ super(x, y, button);
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventMouse.Up>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class Move
+ extends EventMouse
+ {
+ float dx;
+ float dy;
+
+ public float getDx()
+ {
+ return this.dx;
+ }
+
+ public float getDy()
+ {
+ return this.dy;
+ }
+
+ public Move(IWidget origin, float dx, float dy)
+ {
+ super();
+ this.dx = dx;
+ this.dy = dy;
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventMouse.Move>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class Drag
+ extends EventMouse.Move
+ {
+ public Drag(IWidget draggedWidget, float dx, float dy)
+ {
+ super(dx, dy);
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventMouse.Drag>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class Wheel
+ extends EventMouse
+ {
+ int dWheel = 0;
+
+ public Wheel(IWidget origin, int dWheel)
+ {
+ super();
+ this.dWheel = (dWheel / 28);
+ }
+
+ public int getDWheel()
+ {
+ return this.dWheel;
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventMouse.Wheel>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/events/EventTextEdit.java b/src/Java/binnie/craftgui/events/EventTextEdit.java
new file mode 100644
index 0000000000..d61ae34008
--- /dev/null
+++ b/src/Java/binnie/craftgui/events/EventTextEdit.java
@@ -0,0 +1,21 @@
+package binnie.craftgui.events;
+
+import binnie.craftgui.core.IWidget;
+
+public class EventTextEdit
+ extends EventValueChanged<String>
+{
+ public EventTextEdit(IWidget origin, String text)
+ {
+ super(origin, text);
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventTextEdit>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/events/EventToggleButtonClicked.java b/src/Java/binnie/craftgui/events/EventToggleButtonClicked.java
new file mode 100644
index 0000000000..79ff26fa59
--- /dev/null
+++ b/src/Java/binnie/craftgui/events/EventToggleButtonClicked.java
@@ -0,0 +1,20 @@
+package binnie.craftgui.events;
+
+import binnie.craftgui.core.IWidget;
+
+public class EventToggleButtonClicked
+ extends Event
+{
+ boolean toggled;
+
+ public EventToggleButtonClicked(IWidget origin, boolean toggled)
+ {
+ super(origin);
+ this.toggled = toggled;
+ }
+
+ public boolean isActive()
+ {
+ return this.toggled;
+ }
+}
diff --git a/src/Java/binnie/craftgui/events/EventValueChanged.java b/src/Java/binnie/craftgui/events/EventValueChanged.java
new file mode 100644
index 0000000000..df804cbfa5
--- /dev/null
+++ b/src/Java/binnie/craftgui/events/EventValueChanged.java
@@ -0,0 +1,29 @@
+package binnie.craftgui.events;
+
+import binnie.craftgui.core.IWidget;
+
+public class EventValueChanged<T>
+ extends Event
+{
+ public T value;
+
+ public EventValueChanged(IWidget origin, T value)
+ {
+ super(origin);
+ this.value = value;
+ }
+
+ public T getValue()
+ {
+ return this.value;
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventValueChanged>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/events/EventValuesChanged.java b/src/Java/binnie/craftgui/events/EventValuesChanged.java
new file mode 100644
index 0000000000..e102487f14
--- /dev/null
+++ b/src/Java/binnie/craftgui/events/EventValuesChanged.java
@@ -0,0 +1,20 @@
+package binnie.craftgui.events;
+
+import binnie.craftgui.core.IWidget;
+
+public class EventValuesChanged<T>
+ extends Event
+{
+ public T[] values;
+
+ public EventValuesChanged(IWidget origin, T[] values)
+ {
+ super(origin);
+ this.values = values;
+ }
+
+ public T[] getValues()
+ {
+ return this.values;
+ }
+}
diff --git a/src/Java/binnie/craftgui/events/EventWidget.java b/src/Java/binnie/craftgui/events/EventWidget.java
new file mode 100644
index 0000000000..87ca98521f
--- /dev/null
+++ b/src/Java/binnie/craftgui/events/EventWidget.java
@@ -0,0 +1,272 @@
+package binnie.craftgui.events;
+
+import binnie.craftgui.core.IWidget;
+
+public class EventWidget
+ extends Event
+{
+ public EventWidget(IWidget origin)
+ {
+ super(origin);
+ }
+
+ public static class Enable
+ extends EventWidget
+ {
+ public Enable(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.Enable>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class Disable
+ extends EventWidget
+ {
+ public Disable(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.Disable>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class Show
+ extends EventWidget
+ {
+ public Show(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.Show>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class Hide
+ extends EventWidget
+ {
+ public Hide(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.Hide>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class ChangePosition
+ extends EventWidget
+ {
+ public ChangePosition(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.ChangePosition>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class ChangeSize
+ extends EventWidget
+ {
+ public ChangeSize(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.ChangeSize>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class ChangeOffset
+ extends EventWidget
+ {
+ public ChangeOffset(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.ChangeOffset>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class ChangeColour
+ extends EventWidget
+ {
+ public ChangeColour(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.ChangeColour>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class StartMouseOver
+ extends EventWidget
+ {
+ public StartMouseOver(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.StartMouseOver>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class EndMouseOver
+ extends EventWidget
+ {
+ public EndMouseOver(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.EndMouseOver>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class StartDrag
+ extends EventWidget
+ {
+ int button;
+
+ public StartDrag(IWidget origin, int button)
+ {
+ super();
+ this.button = button;
+ }
+
+ public int getButton()
+ {
+ return this.button;
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.StartDrag>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class EndDrag
+ extends EventWidget
+ {
+ public EndDrag(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.EndDrag>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class GainFocus
+ extends EventWidget
+ {
+ public GainFocus(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.GainFocus>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+
+ public static class LoseFocus
+ extends EventWidget
+ {
+ public LoseFocus(IWidget origin)
+ {
+ super();
+ }
+
+ public static abstract class Handler
+ extends EventHandler<EventWidget.LoseFocus>
+ {
+ public Handler()
+ {
+ super();
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/ControlBlockIconDisplay.java b/src/Java/binnie/craftgui/extratrees/dictionary/ControlBlockIconDisplay.java
new file mode 100644
index 0000000000..58b93a2782
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/ControlBlockIconDisplay.java
@@ -0,0 +1,25 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import net.minecraft.util.IIcon;
+
+public class ControlBlockIconDisplay
+ extends Control
+{
+ IIcon icon;
+
+ public ControlBlockIconDisplay(IWidget parent, float x, float y, IIcon icon)
+ {
+ super(parent, x, y, 18.0F, 18.0F);
+ this.icon = icon;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.iconBlock(IPoint.ZERO, this.icon);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/ControlBreweryProgress.java b/src/Java/binnie/craftgui/extratrees/dictionary/ControlBreweryProgress.java
new file mode 100644
index 0000000000..d6d18d3a69
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/ControlBreweryProgress.java
@@ -0,0 +1,115 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.machines.Machine;
+import binnie.core.util.ItemStackSet;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlProgressBase;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.extratrees.core.ExtraTreeTexture;
+import binnie.extratrees.machines.Brewery;
+import binnie.extratrees.machines.Brewery.BreweryCrafting;
+import binnie.extratrees.machines.Brewery.ComponentBreweryLogic;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.opengl.GL11;
+
+public class ControlBreweryProgress
+ extends ControlProgressBase
+{
+ static Texture Brewery = new StandardTexture(0, 69, 34, 39, ExtraTreeTexture.Gui);
+ static Texture BreweryOverlay = new StandardTexture(34, 69, 34, 39, ExtraTreeTexture.Gui);
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(Brewery, new IPoint(0.0F, 0.0F));
+
+ Brewery.ComponentBreweryLogic logic = (Brewery.ComponentBreweryLogic)Machine.getInterface(Brewery.ComponentBreweryLogic.class, Window.get(this).getInventory());
+ if (logic.currentCrafting == null) {
+ return;
+ }
+ if (logic.currentCrafting.currentInput == null) {
+ return;
+ }
+ int fermentedHeight = (int)(32.0F * logic.getProgress() / 100.0F);
+
+ CraftGUI.Render.limitArea(new IArea(new IPoint(1.0F, 6.0F).add(getAbsolutePosition()), new IPoint(32.0F, 32 - fermentedHeight)));
+
+ GL11.glEnable(3089);
+
+ renderFluid(logic.currentCrafting.currentInput, new IPoint(1.0F, 6.0F));
+ renderFluid(logic.currentCrafting.currentInput, new IPoint(17.0F, 6.0F));
+ renderFluid(logic.currentCrafting.currentInput, new IPoint(1.0F, 22.0F));
+ 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(getAbsolutePosition()), new IPoint(32.0F, fermentedHeight)));
+
+
+ GL11.glEnable(3089);
+
+ renderFluid(Brewery.getOutput(logic.currentCrafting), new IPoint(1.0F, 6.0F));
+ renderFluid(Brewery.getOutput(logic.currentCrafting), new IPoint(17.0F, 6.0F));
+ renderFluid(Brewery.getOutput(logic.currentCrafting), new IPoint(1.0F, 22.0F));
+ renderFluid(Brewery.getOutput(logic.currentCrafting), new IPoint(17.0F, 22.0F));
+
+ GL11.glDisable(3089);
+
+ ItemStackSet stacks = new ItemStackSet();
+ for (ItemStack stack : logic.currentCrafting.inputs) {
+ stacks.add(stack);
+ }
+ stacks.add(logic.currentCrafting.ingr);
+
+ int x = 1;
+ int y = 6;
+ for (ItemStack stack : stacks)
+ {
+ CraftGUI.Render.item(new IPoint(x, y), stack);
+ x += 16;
+ if (x > 18)
+ {
+ x = 1;
+ y += 16;
+ }
+ }
+ }
+
+ public void onRenderForeground() {}
+
+ protected ControlBreweryProgress(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, 34.0F, 39.0F);
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public void renderFluid(FluidStack fluid, IPoint pos)
+ {
+ int hex = fluid.getFluid().getColor(fluid);
+
+ int r = (hex & 0xFF0000) >> 16;
+ int g = (hex & 0xFF00) >> 8;
+ int b = hex & 0xFF;
+
+ 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);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/ControlDistilleryProgress.java b/src/Java/binnie/craftgui/extratrees/dictionary/ControlDistilleryProgress.java
new file mode 100644
index 0000000000..5a44b09ca3
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/ControlDistilleryProgress.java
@@ -0,0 +1,104 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.machines.Machine;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlProgressBase;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.extratrees.core.ExtraTreeTexture;
+import binnie.extratrees.machines.Distillery.ComponentDistilleryLogic;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.opengl.GL11;
+
+public class ControlDistilleryProgress
+ extends ControlProgressBase
+{
+ static Texture DistilleryBase = new StandardTexture(43, 0, 58, 66, ExtraTreeTexture.Gui);
+ static Texture DistilleryOverlay = new StandardTexture(139, 0, 18, 66, ExtraTreeTexture.Gui);
+ static Texture LiquidFlow = new StandardTexture(101, 0, 38, 66, ExtraTreeTexture.Gui);
+ static Texture Output = new StandardTexture(68, 66, 17, 7, ExtraTreeTexture.Gui);
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(DistilleryBase, new IPoint(0.0F, 0.0F));
+ CraftGUI.Render.texturePercentage(LiquidFlow, new IArea(18.0F, 0.0F, 38.0F, 66.0F), Position.Left, this.progress);
+
+ Distillery.ComponentDistilleryLogic component = (Distillery.ComponentDistilleryLogic)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++) {
+ renderFluid(stack, new IPoint(1.0F, 1 + y * 16));
+ }
+ }
+ }
+
+ public void onRenderForeground()
+ {
+ int level = ((Distillery.ComponentDistilleryLogic)Machine.getInterface(Distillery.ComponentDistilleryLogic.class, Window.get(this).getInventory())).level;
+ CraftGUI.Render.texture(Output, new IPoint(47.0F, 14 + level * 15));
+ CraftGUI.Render.texture(DistilleryOverlay, new IPoint(0.0F, 0.0F));
+ }
+
+ protected ControlDistilleryProgress(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, 58.0F, 66.0F);
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(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)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setByte("i", (byte)distillationLevel);
+ Window.get(ControlDistilleryProgress.this.getWidget()).sendClientAction("still-level", nbt);
+ }
+ }
+ });
+ }
+
+ public void renderFluid(FluidStack fluid, IPoint pos)
+ {
+ int hex = fluid.getFluid().getColor(fluid);
+
+ int r = (hex & 0xFF0000) >> 16;
+ int g = (hex & 0xFF00) >> 8;
+ int b = hex & 0xFF;
+
+ 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);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/ControlFruitPressProgress.java b/src/Java/binnie/craftgui/extratrees/dictionary/ControlFruitPressProgress.java
new file mode 100644
index 0000000000..79d21a3025
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/ControlFruitPressProgress.java
@@ -0,0 +1,90 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlProgressBase;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.extratrees.core.ExtraTreeTexture;
+import binnie.extratrees.machines.Press;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.opengl.GL11;
+
+public class ControlFruitPressProgress
+ extends ControlProgressBase
+{
+ static Texture PressTexture = new StandardTexture(6, 0, 24, 52, ExtraTreeTexture.Gui);
+ static Texture PressSlot = new StandardTexture(9, 52, 34, 17, ExtraTreeTexture.Gui);
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(PressSlot, new IPoint(3.0F, 52.0F));
+
+ ItemStack input = Window.get(this).getContainer().getSlotFromInventory(Window.get(this).getInventory(), Press.slotCurrent).getStack();
+ if ((input == null) || (Press.getOutput(input) == null)) {
+ return;
+ }
+ Fluid fluid = Press.getOutput(input).getFluid();
+
+ int hex = fluid.getColor(Press.getOutput(input));
+
+ int r = (hex & 0xFF0000) >> 16;
+ int g = (hex & 0xFF00) >> 8;
+ 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);
+ }
+
+ public void onRenderForeground()
+ {
+ CraftGUI.Render.texture(PressTexture, new IPoint(0.0F, 16.0F * this.progress));
+ }
+
+ protected ControlFruitPressProgress(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, 37.0F, 69.0F);
+ addAttribute(Attribute.MouseOver);
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ if (event.getButton() == 0)
+ {
+ NBTTagCompound action = new NBTTagCompound();
+ Window.get(ControlFruitPressProgress.this.getWidget()).sendClientAction("fruitpress-click", action);
+ }
+ else if (event.getButton() == 1)
+ {
+ NBTTagCompound action = new NBTTagCompound();
+ Window.get(ControlFruitPressProgress.this.getWidget()).sendClientAction("clear-fruit", action);
+ }
+ }
+ });
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/ControlLumbermillProgress.java b/src/Java/binnie/craftgui/extratrees/dictionary/ControlLumbermillProgress.java
new file mode 100644
index 0000000000..b315c23927
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/ControlLumbermillProgress.java
@@ -0,0 +1,96 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.MinecraftGUI.PanelType;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlProgressBase;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.craftgui.window.Panel;
+import binnie.extratrees.core.ExtraTreeTexture;
+import binnie.extratrees.machines.Lumbermill;
+import net.minecraft.block.Block;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import org.lwjgl.opengl.GL11;
+
+public class ControlLumbermillProgress
+ extends ControlProgressBase
+{
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+ if (this.oldProgress != this.progress)
+ {
+ this.oldProgress = this.progress;
+ this.animation += 5.0F;
+ }
+ }
+
+ float oldProgress = 0.0F;
+ float animation = 0.0F;
+ static Texture Saw = new StandardTexture(0, 0, 6, 32, ExtraTreeTexture.Gui);
+ static Texture Saw2 = new StandardTexture(2, 0, 4, 32, ExtraTreeTexture.Gui);
+
+ public void onRenderForeground()
+ {
+ GL11.glDisable(2896);
+ int sawX = (int)(63.0F * this.progress);
+
+ CraftGUI.Render.texture(Saw, new IPoint(sawX, -8.0F + 6.0F * (float)Math.sin(this.animation)));
+
+ 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;
+ }
+ 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);
+ }
+ 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;
+ }
+ IIcon icon2 = block2.getIcon(2, result.getItemDamage());
+
+ IPoint size = getSize();
+ IPoint pos = 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 i = 0; i < 4; i++) {
+ CraftGUI.Render.iconBlock(new IPoint(1 + i * 16, 1.0F), icon2);
+ }
+ GL11.glDisable(3089);
+
+ CraftGUI.Render.texture(Saw2, new IPoint(sawX + 2, -8.0F + 6.0F * (float)Math.sin(this.animation)));
+ }
+
+ protected ControlLumbermillProgress(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, 66.0F, 18.0F);
+ new Panel(this, 0.0F, 0.0F, 66.0F, 18.0F, MinecraftGUI.PanelType.Black);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/ControlRecipeSlot.java b/src/Java/binnie/craftgui/extratrees/dictionary/ControlRecipeSlot.java
new file mode 100644
index 0000000000..d65e825cb8
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/ControlRecipeSlot.java
@@ -0,0 +1,42 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.machines.Machine;
+import binnie.core.machines.TileEntityMachine;
+import binnie.core.machines.component.IComponentRecipe;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlSlotBase;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+
+public class ControlRecipeSlot
+ extends ControlSlotBase
+{
+ public ControlRecipeSlot(IWidget parent, int x, int y)
+ {
+ super(parent, x, y, 50);
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ TileEntity tile = (TileEntity)Window.get(ControlRecipeSlot.this.getWidget()).getInventory();
+ if ((tile == null) || (!(tile instanceof TileEntityMachine))) {
+ return;
+ }
+ NBTTagCompound nbt = new NBTTagCompound();
+ Window.get(ControlRecipeSlot.this.getWidget()).sendClientAction("recipe", nbt);
+ }
+ });
+ setRotating();
+ }
+
+ public ItemStack getItemStack()
+ {
+ IComponentRecipe recipe = (IComponentRecipe)Machine.getInterface(IComponentRecipe.class, Window.get(this).getInventory());
+ return recipe.isRecipe() ? recipe.getProduct() : null;
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/ControlTileSelect.java b/src/Java/binnie/craftgui/extratrees/dictionary/ControlTileSelect.java
new file mode 100644
index 0000000000..cc5c79c529
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/ControlTileSelect.java
@@ -0,0 +1,197 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.Binnie;
+import binnie.core.BinnieCore;
+import binnie.core.language.ManagerLanguage;
+import binnie.core.machines.Machine;
+import binnie.core.machines.TileEntityMachine;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.controls.scroll.IControlScrollable;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import binnie.extratrees.api.CarpentryManager;
+import binnie.extratrees.api.ICarpentryInterface;
+import binnie.extratrees.api.IDesign;
+import binnie.extratrees.api.IDesignCategory;
+import binnie.extratrees.carpentry.EnumDesign;
+import binnie.extratrees.machines.Designer.ComponentWoodworkerRecipe;
+import binnie.extratrees.machines.DesignerType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class ControlTileSelect
+ extends Control
+ implements IControlValue<IDesign>, IControlScrollable
+{
+ public static class ControlTile
+ extends Control
+ implements IControlValue<IDesign>, ITooltip
+ {
+ IDesign value;
+
+ protected ControlTile(IWidget parent, float x, float y, IDesign value)
+ {
+ super(x, y, 18.0F, 18.0F);
+ setValue(value);
+ addAttribute(Attribute.MouseOver);
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ TileEntityMachine tile = (TileEntityMachine)Window.get(ControlTileSelect.ControlTile.this.getWidget()).getInventory();
+ if (tile == null) {
+ return;
+ }
+ Designer.ComponentWoodworkerRecipe recipe = (Designer.ComponentWoodworkerRecipe)tile.getMachine().getComponent(Designer.ComponentWoodworkerRecipe.class);
+
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setShort("d", (short)CarpentryManager.carpentryInterface.getDesignIndex(ControlTileSelect.ControlTile.this.getValue()));
+
+ Window.get(ControlTileSelect.ControlTile.this.getWidget()).sendClientAction("design", nbt);
+ }
+ });
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.add(Binnie.Language.localise(BinnieCore.instance, "gui.designer.pattern", new Object[] { getValue().getName() }));
+ }
+
+ public IDesign getValue()
+ {
+ return this.value;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.Slot, IPoint.ZERO);
+ }
+
+ public void onRenderForeground()
+ {
+ ItemStack image = ((WindowWoodworker)getSuperParent()).getDesignerType().getDisplayStack(getValue());
+ CraftGUI.Render.item(new IPoint(1.0F, 1.0F), image);
+ if (((IControlValue)getParent()).getValue() != getValue()) {
+ if (Window.get(this).getMousedOverWidget() == this) {
+ CraftGUI.Render.gradientRect(getArea().inset(1), 1157627903, 1157627903);
+ } else {
+ CraftGUI.Render.gradientRect(getArea().inset(1), -1433892728, -1433892728);
+ }
+ }
+ }
+
+ public void setValue(IDesign value)
+ {
+ this.value = value;
+ }
+ }
+
+ IDesign value = EnumDesign.Blank;
+ float shownHeight = 92.0F;
+
+ protected ControlTileSelect(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, 102.0F, 20 * (CarpentryManager.carpentryInterface.getSortedDesigns().size() / 4) + 22);
+
+ refresh("");
+ }
+
+ public float getPercentageIndex()
+ {
+ return 0.0F;
+ }
+
+ public float getPercentageShown()
+ {
+ return 0.0F;
+ }
+
+ public IDesign getValue()
+ {
+ return this.value;
+ }
+
+ public void movePercentage(float percentage) {}
+
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+ TileEntityMachine tile = (TileEntityMachine)Window.get(this).getInventory();
+ if (tile == null) {
+ return;
+ }
+ Designer.ComponentWoodworkerRecipe recipe = (Designer.ComponentWoodworkerRecipe)tile.getMachine().getComponent(Designer.ComponentWoodworkerRecipe.class);
+
+ setValue(recipe.getDesign());
+ }
+
+ public void refresh(String filterText)
+ {
+ deleteAllChildren();
+ int cx = 2;
+ int cy = 2;
+
+ Map<IDesignCategory, List<IDesign>> designs = new HashMap();
+ for (IDesignCategory category : CarpentryManager.carpentryInterface.getAllDesignCategories())
+ {
+ designs.put(category, new ArrayList());
+ for (IDesign tile : category.getDesigns()) {
+ if ((filterText == "") || (tile.getName().toLowerCase().contains(filterText))) {
+ ((List)designs.get(category)).add(tile);
+ }
+ }
+ if (((List)designs.get(category)).isEmpty()) {
+ designs.remove(category);
+ }
+ }
+ for (IDesignCategory category : designs.keySet())
+ {
+ cx = 2;
+ new ControlText(this, new IPoint(cx, cy + 3), category.getName());
+ cy += 16;
+ for (IDesign tile : (List)designs.get(category))
+ {
+ if (cx > 90)
+ {
+ cx = 2;
+ cy += 20;
+ }
+ new ControlTile(this, cx, cy, tile);
+ cx += 20;
+ }
+ cy += 20;
+ }
+ int height = cy;
+
+ setSize(new IPoint(getSize().x(), height));
+ }
+
+ public void setPercentageIndex(float index) {}
+
+ public void setValue(IDesign value)
+ {
+ this.value = value;
+ }
+
+ public float getMovementRange()
+ {
+ return 0.0F;
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/DialogBreweryRecipe.java b/src/Java/binnie/craftgui/extratrees/dictionary/DialogBreweryRecipe.java
new file mode 100644
index 0000000000..f761aaea29
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/DialogBreweryRecipe.java
@@ -0,0 +1,17 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.minecraft.Dialog;
+
+public class DialogBreweryRecipe
+ extends Dialog
+{
+ public DialogBreweryRecipe(IWidget parent, float w, float h)
+ {
+ super(parent, w, h);
+ }
+
+ public void initialise() {}
+
+ public void onClose() {}
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/PageFruit.java b/src/Java/binnie/craftgui/extratrees/dictionary/PageFruit.java
new file mode 100644
index 0000000000..c6983deef9
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/PageFruit.java
@@ -0,0 +1,47 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.genetics.TreeBreedingSystem;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.mod.database.ControlSpeciesBox;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.PageAbstract;
+import binnie.craftgui.mod.database.WindowAbstractDatabase;
+import binnie.extratrees.ExtraTrees;
+import binnie.extratrees.proxy.Proxy;
+import forestry.api.genetics.IAlleleSpecies;
+import java.util.Collection;
+import net.minecraft.item.ItemStack;
+
+public class PageFruit
+ extends PageAbstract<ItemStack>
+{
+ boolean treesThatBearFruit;
+
+ public PageFruit(IWidget parent, DatabaseTab tab, boolean treesThatBearFruit)
+ {
+ super(parent, tab);
+ this.treesThatBearFruit = treesThatBearFruit;
+ }
+
+ public void onValueChanged(ItemStack species)
+ {
+ deleteAllChildren();
+ WindowAbstractDatabase database = (WindowAbstractDatabase)WindowAbstractDatabase.get(this);
+ new ControlText(this, new IArea(0.0F, 0.0F, size().x(), 24.0F), ExtraTrees.proxy.localise("gui.database.tab.fruit." + (this.treesThatBearFruit ? "natural" : "potential")), TextJustification.MiddleCenter);
+
+
+ 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, size().x() - 8.0F, size().y() - 4.0F - 24.0F).setOptions(trees);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/PagePlanksOverview.java b/src/Java/binnie/craftgui/extratrees/dictionary/PagePlanksOverview.java
new file mode 100644
index 0000000000..f27fa6967b
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/PagePlanksOverview.java
@@ -0,0 +1,103 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.BinnieCore;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.control.ControlItemDisplay;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.PageAbstract;
+import binnie.craftgui.mod.database.WindowAbstractDatabase;
+import binnie.extratrees.ExtraTrees;
+import binnie.extratrees.block.DoorType;
+import binnie.extratrees.block.IPlankType;
+import binnie.extratrees.block.WoodManager;
+import binnie.extratrees.block.decor.FenceType;
+import binnie.extratrees.proxy.Proxy;
+import net.minecraft.item.ItemStack;
+
+public class PagePlanksOverview
+ extends PageAbstract<ItemStack>
+{
+ public PagePlanksOverview(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+ }
+
+ public void onValueChanged(ItemStack species)
+ {
+ deleteAllChildren();
+ WindowAbstractDatabase database = (WindowAbstractDatabase)WindowAbstractDatabase.get(this);
+ new ControlText(this, new IArea(0.0F, 0.0F, size().x(), 24.0F), species.getDisplayName(), TextJustification.MiddleCenter);
+
+
+
+ new ControlText(this, new IArea(12.0F, 24.0F, size().x() - 24.0F, 24.0F), ExtraTrees.proxy.localise("gui.database.planks.use"), TextJustification.MiddleLeft);
+
+
+ IPlankType type = WoodManager.get(species);
+
+ int x = 12;
+ if (type != null)
+ {
+ ItemStack fence = WoodManager.getFence(type, new FenceType(0), 1);
+ ItemStack gate = WoodManager.getGate(type);
+ 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;
+ }
+ }
+ ControlText controlDescription = new ControlText(this, new IArea(8.0F, 84.0F, getSize().x() - 16.0F, 0.0F), "", TextJustification.MiddleCenter);
+
+
+ ControlText controlSignature = new ControlText(this, new IArea(8.0F, 84.0F, 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 = descBody + BinnieCore.proxy.localise("gui.database.nodescription");
+ }
+ else
+ {
+ String[] descStrings = desc.split("\\|");
+ descBody = descBody + descStrings[0];
+ for (int i = 1; i < descStrings.length - 1; i++) {
+ descBody = descBody + " " + descStrings[i];
+ }
+ if (descStrings.length > 1) {
+ descSig = descSig + descStrings[(descStrings.length - 1)];
+ }
+ }
+ controlDescription.setValue(descBody + "§r");
+ controlSignature.setValue(descSig + "§r");
+
+ float descHeight = CraftGUI.Render.textHeight(controlDescription.getValue(), controlDescription.getSize().x());
+
+
+ controlSignature.setPosition(new IPoint(controlSignature.pos().x(), controlDescription.getPosition().y() + descHeight + 10.0F));
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/PagePlanksTrees.java b/src/Java/binnie/craftgui/extratrees/dictionary/PagePlanksTrees.java
new file mode 100644
index 0000000000..8702edbe95
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/PagePlanksTrees.java
@@ -0,0 +1,40 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.genetics.TreeBreedingSystem;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.mod.database.ControlSpeciesBox;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.PageAbstract;
+import binnie.craftgui.mod.database.WindowAbstractDatabase;
+import forestry.api.genetics.IAlleleSpecies;
+import java.util.Collection;
+import net.minecraft.item.ItemStack;
+
+public class PagePlanksTrees
+ extends PageAbstract<ItemStack>
+{
+ public PagePlanksTrees(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+ }
+
+ public void onValueChanged(ItemStack species)
+ {
+ deleteAllChildren();
+ WindowAbstractDatabase database = (WindowAbstractDatabase)WindowAbstractDatabase.get(this);
+ new ControlText(this, new IArea(0.0F, 0.0F, size().x(), 24.0F), species.getDisplayName(), TextJustification.MiddleCenter);
+
+
+
+ Collection<IAlleleSpecies> trees = ((TreeBreedingSystem)database.getBreedingSystem()).getTreesThatMakePlanks(species, database.isNEI(), database.getWorld(), database.getUsername());
+
+
+
+
+ new ControlSpeciesBox(this, 4.0F, 24.0F, size().x() - 8.0F, size().y() - 4.0F - 24.0F).setOptions(trees);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/PageSpeciesImage.java b/src/Java/binnie/craftgui/extratrees/dictionary/PageSpeciesImage.java
new file mode 100644
index 0000000000..d6fd929447
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/PageSpeciesImage.java
@@ -0,0 +1,31 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.minecraft.MinecraftGUI.PanelType;
+import binnie.craftgui.mod.database.ControlDatabaseIndividualDisplay;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.EnumDiscoveryState;
+import binnie.craftgui.mod.database.PageSpecies;
+import binnie.craftgui.window.Panel;
+import forestry.api.genetics.IAlleleSpecies;
+
+public class PageSpeciesImage
+ extends PageSpecies
+{
+ ControlDatabaseIndividualDisplay display;
+
+ public PageSpeciesImage(IWidget parent, 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, ((DatabaseTab)getValue()).toString());
+ }
+
+ public void onValueChanged(IAlleleSpecies species)
+ {
+ this.display.setSpecies(species, EnumDiscoveryState.Show);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/PageSpeciesTreeGenome.java b/src/Java/binnie/craftgui/extratrees/dictionary/PageSpeciesTreeGenome.java
new file mode 100644
index 0000000000..22a1a67b29
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/PageSpeciesTreeGenome.java
@@ -0,0 +1,175 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.Binnie;
+import binnie.core.BinnieCore;
+import binnie.core.genetics.BreedingSystem;
+import binnie.core.genetics.ManagerGenetics;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.scroll.ControlScrollableContent;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.minecraft.control.ControlItemDisplay;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.PageSpecies;
+import binnie.extratrees.ExtraTrees;
+import binnie.extratrees.proxy.Proxy;
+import forestry.api.arboriculture.EnumTreeChromosome;
+import forestry.api.arboriculture.IAlleleTreeSpecies;
+import forestry.api.arboriculture.IFruitProvider;
+import forestry.api.arboriculture.IGrowthProvider;
+import forestry.api.arboriculture.ITree;
+import forestry.api.arboriculture.ITreeGenome;
+import forestry.api.arboriculture.ITreeRoot;
+import forestry.api.core.EnumTemperature;
+import forestry.api.core.ForestryAPI;
+import forestry.api.core.ITextureManager;
+import forestry.api.genetics.IAllele;
+import forestry.api.genetics.IAlleleSpecies;
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.common.EnumPlantType;
+
+public class PageSpeciesTreeGenome
+ extends PageSpecies
+{
+ public PageSpeciesTreeGenome(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+ }
+
+ public void onValueChanged(IAlleleSpecies species)
+ {
+ deleteAllChildren();
+ IAllele[] template = Binnie.Genetics.getTreeRoot().getTemplate(species.getUID());
+ if (template == null) {
+ return;
+ }
+ ITree tree = Binnie.Genetics.getTreeRoot().templateAsIndividual(template);
+ if (tree == null) {
+ return;
+ }
+ ITreeGenome genome = tree.getGenome();
+ IAlleleTreeSpecies treeSpecies = genome.getPrimary();
+
+ int w = 144;
+ int h = 176;
+
+ new ControlText(this, new IArea(0.0F, 4.0F, w, 16.0F), ((DatabaseTab)getValue()).toString(), TextJustification.MiddleCenter);
+
+ ControlScrollableContent scrollable = new ControlScrollableContent(this, 4.0F, 20.0F, w - 8, h - 8 - 16, 12.0F);
+
+ Control contents = new Control(scrollable, 0.0F, 0.0F, w - 8 - 12, h - 8 - 16);
+
+ int tw = w - 8 - 12;
+ int w1 = 65;
+ int w2 = tw - 50;
+ int y = 0;
+ int th = 14;
+ int th2 = 18;
+
+ BreedingSystem syst = Binnie.Genetics.treeBreedingSystem;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), syst.getChromosomeShortName(EnumTreeChromosome.PLANT) + " : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), treeSpecies.getPlantType().toString(), TextJustification.MiddleLeft);
+
+ y += th;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), BinnieCore.proxy.localise("gui.temperature.short") + " : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), treeSpecies.getTemperature().getName(), TextJustification.MiddleLeft);
+
+ y += th;
+
+ IIcon leaf = ForestryAPI.textureManager.getIcon(treeSpecies.getLeafIconIndex(tree, false));
+
+ IIcon fruit = null;
+ int fruitColour = 16777215;
+ try
+ {
+ fruit = ForestryAPI.textureManager.getIcon(genome.getFruitProvider().getIconIndex(genome, null, 0, 0, 0, 100, false));
+ fruitColour = genome.getFruitProvider().getColour(genome, null, 0, 0, 0, 100);
+ }
+ catch (Exception e) {}
+ if (leaf != null)
+ {
+ new ControlText(contents, new IArea(0.0F, y, w1, th2), ExtraTrees.proxy.localise("gui.database.leaves") + " : ", TextJustification.MiddleRight);
+
+ new ControlBlockIconDisplay(contents, w1, y, leaf).setColour(treeSpecies.getLeafColour(tree));
+ if ((fruit != null) && (!treeSpecies.getUID().equals("forestry.treeOak"))) {
+ new ControlBlockIconDisplay(contents, w1, y, fruit).setColour(fruitColour);
+ }
+ y += th2;
+ }
+ ItemStack log = treeSpecies.getLogStacks().length > 0 ? treeSpecies.getLogStacks()[0] : null;
+ if (log != null)
+ {
+ new ControlText(contents, new IArea(0.0F, y, w1, th2), ExtraTrees.proxy.localise("gui.database.log") + " : ", TextJustification.MiddleRight);
+
+ ControlItemDisplay display = new ControlItemDisplay(contents, w1, y);
+ display.setItemStack(log);
+ display.setTooltip();
+
+ y += th2;
+ }
+ new ControlText(contents, new IArea(0.0F, y, w1, th), syst.getChromosomeShortName(EnumTreeChromosome.GROWTH) + " : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), genome.getGrowthProvider().getDescription(), TextJustification.MiddleLeft);
+ y += th;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), syst.getChromosomeShortName(EnumTreeChromosome.HEIGHT) + " : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), genome.getHeight() + "x", TextJustification.MiddleLeft);
+ y += th;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), syst.getChromosomeShortName(EnumTreeChromosome.FERTILITY) + " : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), genome.getFertility() + "x", TextJustification.MiddleLeft);
+ y += th;
+
+ List<ItemStack> fruits = new ArrayList();
+ for (ItemStack stack : genome.getFruitProvider().getProducts()) {
+ fruits.add(stack);
+ }
+ if (!fruits.isEmpty())
+ {
+ new ControlText(contents, new IArea(0.0F, y, w1, th2), syst.getChromosomeShortName(EnumTreeChromosome.FRUITS) + " : ", TextJustification.MiddleRight);
+ for (ItemStack fruitw : fruits)
+ {
+ ControlItemDisplay display = new ControlItemDisplay(contents, w1, y);
+ display.setItemStack(fruitw);
+ display.setTooltip();
+
+ y += th2;
+ }
+ }
+ new ControlText(contents, new IArea(0.0F, y, w1, th), syst.getChromosomeShortName(EnumTreeChromosome.YIELD) + " : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), genome.getYield() + "x", TextJustification.MiddleLeft);
+ y += th;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), syst.getChromosomeShortName(EnumTreeChromosome.SAPPINESS) + " : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), genome.getSappiness() + "x", TextJustification.MiddleLeft);
+ y += th;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), syst.getChromosomeShortName(EnumTreeChromosome.MATURATION) + " : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, th), genome.getMaturationTime() + "x", TextJustification.MiddleLeft);
+ y += th;
+
+ new ControlText(contents, new IArea(0.0F, y, w1, th), syst.getChromosomeShortName(EnumTreeChromosome.GIRTH) + " : ", TextJustification.MiddleRight);
+ new ControlText(contents, new IArea(w1, y, w2, 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(boolean t)
+ {
+ if (t) {
+ return BinnieCore.proxy.localise("gui.tolerated");
+ }
+ return BinnieCore.proxy.localise("gui.nottolerated");
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/PageWood.java b/src/Java/binnie/craftgui/extratrees/dictionary/PageWood.java
new file mode 100644
index 0000000000..e7e80a1456
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/PageWood.java
@@ -0,0 +1,40 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.genetics.TreeBreedingSystem;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.mod.database.ControlSpeciesBox;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.PageAbstract;
+import binnie.craftgui.mod.database.WindowAbstractDatabase;
+import forestry.api.genetics.IAlleleSpecies;
+import java.util.Collection;
+import net.minecraft.item.ItemStack;
+
+public class PageWood
+ extends PageAbstract<ItemStack>
+{
+ public PageWood(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+ }
+
+ public void onValueChanged(ItemStack species)
+ {
+ deleteAllChildren();
+ WindowAbstractDatabase database = (WindowAbstractDatabase)WindowAbstractDatabase.get(this);
+ new ControlText(this, new IArea(0.0F, 0.0F, size().x(), 24.0F), ((DatabaseTab)getValue()).toString(), TextJustification.MiddleCenter);
+
+
+
+ Collection<IAlleleSpecies> trees = ((TreeBreedingSystem)database.getBreedingSystem()).getTreesThatHaveWood(species, database.isNEI(), database.getWorld(), database.getUsername());
+
+
+
+
+ new ControlSpeciesBox(this, 4.0F, 24.0F, size().x() - 8.0F, size().y() - 4.0F - 24.0F).setOptions(trees);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/WindowArboristDatabase.java b/src/Java/binnie/craftgui/extratrees/dictionary/WindowArboristDatabase.java
new file mode 100644
index 0000000000..e8096c6d77
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/WindowArboristDatabase.java
@@ -0,0 +1,133 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.Binnie;
+import binnie.core.AbstractMod;
+import binnie.core.genetics.ManagerGenetics;
+import binnie.core.genetics.TreeBreedingSystem;
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlListBox;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.mod.database.ControlItemStackOption;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.IDatabaseMode;
+import binnie.craftgui.mod.database.PageBranchOverview;
+import binnie.craftgui.mod.database.PageBranchSpecies;
+import binnie.craftgui.mod.database.PageBreeder;
+import binnie.craftgui.mod.database.PageSpeciesClassification;
+import binnie.craftgui.mod.database.PageSpeciesMutations;
+import binnie.craftgui.mod.database.PageSpeciesOverview;
+import binnie.craftgui.mod.database.PageSpeciesResultant;
+import binnie.craftgui.mod.database.WindowAbstractDatabase;
+import binnie.craftgui.mod.database.WindowAbstractDatabase.Mode;
+import binnie.craftgui.mod.database.WindowAbstractDatabase.ModeWidgets;
+import binnie.extratrees.ExtraTrees;
+import binnie.extratrees.proxy.Proxy;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+
+public class WindowArboristDatabase
+ extends WindowAbstractDatabase
+{
+ ControlListBox<ItemStack> selectionBoxFruit;
+ ControlListBox<ItemStack> selectionBoxWood;
+ ControlListBox<ItemStack> selectionBoxPlanks;
+
+ static enum TreeMode
+ implements IDatabaseMode
+ {
+ Fruit, Wood, Planks;
+
+ private TreeMode() {}
+
+ public String getName()
+ {
+ return ExtraTrees.proxy.localise("gui.database.mode." + name().toLowerCase());
+ }
+ }
+
+ public WindowArboristDatabase(EntityPlayer player, Side side, boolean nei)
+ {
+ super(player, side, nei, Binnie.Genetics.treeBreedingSystem, 120.0F);
+ }
+
+ public static Window create(EntityPlayer player, Side side, boolean nei)
+ {
+ return new WindowArboristDatabase(player, side, nei);
+ }
+
+ protected void addTabs()
+ {
+ new PageSpeciesOverview(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(ExtraTrees.instance, "species.overview", 0));
+ new PageSpeciesTreeGenome(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(ExtraTrees.instance, "species.genome", 0));
+ new PageSpeciesClassification(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(ExtraTrees.instance, "species.classification", 0));
+ new PageSpeciesResultant(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(ExtraTrees.instance, "species.resultant", 0));
+ new PageSpeciesMutations(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(ExtraTrees.instance, "species.further", 0));
+
+ new PageBranchOverview(getInfoPages(WindowAbstractDatabase.Mode.Branches), new DatabaseTab(ExtraTrees.instance, "branches.overview", 0));
+ new PageBranchSpecies(getInfoPages(WindowAbstractDatabase.Mode.Branches), new DatabaseTab(ExtraTrees.instance, "branches.species", 0));
+
+ new PageBreeder(getInfoPages(WindowAbstractDatabase.Mode.Breeder), getUsername(), new DatabaseTab(ExtraTrees.instance, "breeder", 0));
+
+ createMode(TreeMode.Fruit, new WindowAbstractDatabase.ModeWidgets(TreeMode.Fruit, this)
+ {
+ public void createListBox(IArea area)
+ {
+ this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0F)
+ {
+ public IWidget createOption(ItemStack value, int y)
+ {
+ return new ControlItemStackOption((ControlList)getContent(), value, y);
+ }
+ };
+ this.listBox.setOptions(((TreeBreedingSystem)WindowArboristDatabase.this.getBreedingSystem()).allFruits);
+ }
+ });
+ createMode(TreeMode.Wood, new WindowAbstractDatabase.ModeWidgets(TreeMode.Wood, this)
+ {
+ public void createListBox(IArea area)
+ {
+ this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0F)
+ {
+ public IWidget createOption(ItemStack value, int y)
+ {
+ return new ControlItemStackOption((ControlList)getContent(), value, y);
+ }
+ };
+ this.listBox.setOptions(((TreeBreedingSystem)WindowArboristDatabase.this.getBreedingSystem()).allWoods);
+ }
+ });
+ createMode(TreeMode.Planks, new WindowAbstractDatabase.ModeWidgets(TreeMode.Planks, this)
+ {
+ public void createListBox(IArea area)
+ {
+ this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0F)
+ {
+ public IWidget createOption(ItemStack value, int y)
+ {
+ return new ControlItemStackOption((ControlList)getContent(), value, y);
+ }
+ };
+ }
+ });
+ new PageFruit(getInfoPages(TreeMode.Fruit), new DatabaseTab(ExtraTrees.instance, "fruit.natural", 0), true);
+ new PageFruit(getInfoPages(TreeMode.Fruit), new DatabaseTab(ExtraTrees.instance, "fruit.potential", 0), false);
+
+ new PageWood(getInfoPages(TreeMode.Wood), new DatabaseTab(ExtraTrees.instance, "wood.natural", 0));
+
+ new PagePlanksOverview(getInfoPages(TreeMode.Planks), new DatabaseTab(ExtraTrees.instance, "planks.overview", 0));
+ new PagePlanksTrees(getInfoPages(TreeMode.Planks), new DatabaseTab(ExtraTrees.instance, "planks.natural", 1));
+ }
+
+ protected AbstractMod getMod()
+ {
+ return ExtraTrees.instance;
+ }
+
+ protected String getName()
+ {
+ return "TreeDatabase";
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/WindowBrewery.java b/src/Java/binnie/craftgui/extratrees/dictionary/WindowBrewery.java
new file mode 100644
index 0000000000..89e4118880
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/WindowBrewery.java
@@ -0,0 +1,61 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.AbstractMod;
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.MachinePackage;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlLiquidTank;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlSlotArray;
+import binnie.extratrees.ExtraTrees;
+import binnie.extratrees.machines.Brewery;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowBrewery
+ extends Window
+{
+ public WindowBrewery(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(228.0F, 218.0F, player, inventory, side);
+ }
+
+ protected AbstractMod getMod()
+ {
+ return ExtraTrees.instance;
+ }
+
+ protected String getName()
+ {
+ return "Brewery";
+ }
+
+ public void initialiseClient()
+ {
+ setTitle(Machine.getMachine(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)(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(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowBrewery(player, inventory, side);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/WindowDistillery.java b/src/Java/binnie/craftgui/extratrees/dictionary/WindowDistillery.java
new file mode 100644
index 0000000000..2d002c2755
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/WindowDistillery.java
@@ -0,0 +1,59 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.AbstractMod;
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.MachinePackage;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlLiquidTank;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.extratrees.ExtraTrees;
+import binnie.extratrees.machines.Distillery;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowDistillery
+ extends Window
+{
+ public WindowDistillery(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(224.0F, 192.0F, player, inventory, side);
+ }
+
+ protected AbstractMod getMod()
+ {
+ return ExtraTrees.instance;
+ }
+
+ protected String getName()
+ {
+ return "Distillery";
+ }
+
+ public void initialiseClient()
+ {
+ setTitle(Machine.getMachine(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(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowDistillery(player, inventory, side);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/WindowLepidopteristDatabase.java b/src/Java/binnie/craftgui/extratrees/dictionary/WindowLepidopteristDatabase.java
new file mode 100644
index 0000000000..5d5b6511ef
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/WindowLepidopteristDatabase.java
@@ -0,0 +1,57 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.Binnie;
+import binnie.core.AbstractMod;
+import binnie.core.genetics.ManagerGenetics;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.mod.database.DatabaseTab;
+import binnie.craftgui.mod.database.PageBranchOverview;
+import binnie.craftgui.mod.database.PageBranchSpecies;
+import binnie.craftgui.mod.database.PageBreeder;
+import binnie.craftgui.mod.database.PageSpeciesClassification;
+import binnie.craftgui.mod.database.PageSpeciesMutations;
+import binnie.craftgui.mod.database.PageSpeciesOverview;
+import binnie.craftgui.mod.database.PageSpeciesResultant;
+import binnie.craftgui.mod.database.WindowAbstractDatabase;
+import binnie.craftgui.mod.database.WindowAbstractDatabase.Mode;
+import binnie.extratrees.ExtraTrees;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+
+public class WindowLepidopteristDatabase
+ extends WindowAbstractDatabase
+{
+ public WindowLepidopteristDatabase(EntityPlayer player, Side side, boolean nei)
+ {
+ super(player, side, nei, Binnie.Genetics.mothBreedingSystem, 160.0F);
+ }
+
+ public static Window create(EntityPlayer player, Side side, boolean nei)
+ {
+ return new WindowLepidopteristDatabase(player, side, nei);
+ }
+
+ protected void addTabs()
+ {
+ new PageSpeciesOverview(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(ExtraTrees.instance, "butterfly.species.overview", 0));
+ new PageSpeciesClassification(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(ExtraTrees.instance, "butterfly.species.classification", 0));
+ new PageSpeciesImage(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(ExtraTrees.instance, "butterfly.species.specimen", 0));
+ new PageSpeciesResultant(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(ExtraTrees.instance, "butterfly.species.resultant", 0));
+ new PageSpeciesMutations(getInfoPages(WindowAbstractDatabase.Mode.Species), new DatabaseTab(ExtraTrees.instance, "butterfly.species.further", 0));
+
+ new PageBranchOverview(getInfoPages(WindowAbstractDatabase.Mode.Branches), new DatabaseTab(ExtraTrees.instance, "butterfly.branches.overview", 0));
+ new PageBranchSpecies(getInfoPages(WindowAbstractDatabase.Mode.Branches), new DatabaseTab(ExtraTrees.instance, "butterfly.branches.species", 0));
+
+ new PageBreeder(getInfoPages(WindowAbstractDatabase.Mode.Breeder), getUsername(), new DatabaseTab(ExtraTrees.instance, "butterfly.breeder", 0));
+ }
+
+ protected AbstractMod getMod()
+ {
+ return ExtraTrees.instance;
+ }
+
+ protected String getName()
+ {
+ return "MothDatabase";
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/WindowLumbermill.java b/src/Java/binnie/craftgui/extratrees/dictionary/WindowLumbermill.java
new file mode 100644
index 0000000000..dc9bca1253
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/WindowLumbermill.java
@@ -0,0 +1,56 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.AbstractMod;
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.MachinePackage;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlLiquidTank;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.extratrees.ExtraTrees;
+import binnie.extratrees.machines.Lumbermill;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowLumbermill
+ extends Window
+{
+ public WindowLumbermill(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(220.0F, 192.0F, player, inventory, side);
+ }
+
+ protected AbstractMod getMod()
+ {
+ return ExtraTrees.instance;
+ }
+
+ protected String getName()
+ {
+ return "Lumbermill";
+ }
+
+ public void initialiseClient()
+ {
+ setTitle(Machine.getMachine(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(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowLumbermill(player, inventory, side);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/WindowPress.java b/src/Java/binnie/craftgui/extratrees/dictionary/WindowPress.java
new file mode 100644
index 0000000000..773bc70323
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/WindowPress.java
@@ -0,0 +1,77 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.AbstractMod;
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.MachinePackage;
+import binnie.core.machines.power.ErrorState.InsufficientPower;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.InventoryType;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlLiquidTank;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.extratrees.ExtraTrees;
+import binnie.extratrees.machines.Press;
+import binnie.extratrees.machines.Press.ComponentFruitPressLogic;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class WindowPress
+ extends Window
+{
+ public WindowPress(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(194.0F, 192.0F, player, inventory, side);
+ }
+
+ protected AbstractMod getMod()
+ {
+ return ExtraTrees.instance;
+ }
+
+ protected String getName()
+ {
+ return "Press";
+ }
+
+ public void initialiseClient()
+ {
+ setTitle(Machine.getMachine(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)getSuperParent()).getContainer().getOrCreateSlot(InventoryType.Machine, Press.slotCurrent);
+ }
+
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowPress(player, inventory, side);
+ }
+
+ public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound action)
+ {
+ Press.ComponentFruitPressLogic logic = (Press.ComponentFruitPressLogic)Machine.getInterface(Press.ComponentFruitPressLogic.class, 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);
+ getInventory().setInventorySlotContents(Press.slotCurrent, null);
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/WindowSetSquare.java b/src/Java/binnie/craftgui/extratrees/dictionary/WindowSetSquare.java
new file mode 100644
index 0000000000..ba444d7b0f
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/WindowSetSquare.java
@@ -0,0 +1,35 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.minecraft.Window;
+import binnie.extratrees.ExtraTrees;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.world.World;
+
+public class WindowSetSquare
+ extends Window
+{
+ public WindowSetSquare(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(150.0F, 150.0F, player, inventory, side);
+ }
+
+ protected AbstractMod getMod()
+ {
+ return ExtraTrees.instance;
+ }
+
+ protected String getName()
+ {
+ return null;
+ }
+
+ public void initialiseClient() {}
+
+ public static Window create(EntityPlayer player, World world, int x, int y, int z, Side side)
+ {
+ return new WindowSetSquare(player, null, side);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/dictionary/WindowWoodworker.java b/src/Java/binnie/craftgui/extratrees/dictionary/WindowWoodworker.java
new file mode 100644
index 0000000000..9e9c6fb7d0
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/dictionary/WindowWoodworker.java
@@ -0,0 +1,110 @@
+package binnie.craftgui.extratrees.dictionary;
+
+import binnie.core.AbstractMod;
+import binnie.core.BinnieCore;
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.MachinePackage;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextEdit;
+import binnie.craftgui.controls.scroll.ControlScrollableContent;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventTextEdit;
+import binnie.craftgui.events.EventTextEdit.Handler;
+import binnie.craftgui.minecraft.MinecraftGUI.PanelType;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.window.Panel;
+import binnie.extratrees.ExtraTrees;
+import binnie.extratrees.machines.Designer;
+import binnie.extratrees.machines.Designer.ComponentWoodworkerRecipe;
+import binnie.extratrees.machines.DesignerType;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowWoodworker
+ extends Window
+{
+ ControlTextEdit textEdit;
+ ControlTileSelect tileSelect;
+
+ public void initialiseClient()
+ {
+ setTitle(Machine.getMachine(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);
+
+ ControlScrollableContent scroll = new ControlScrollableContent(this, 190.0F, 50.0F, 114.0F, 122.0F, 12.0F);
+
+
+
+ this.tileSelect = new ControlTileSelect(scroll, 0.0F, 0.0F);
+
+ scroll.setScrollableContent(this.tileSelect);
+
+
+
+
+
+ new ControlPlayerInventory(this).setPosition(new IPoint(14.0F, 96.0F));
+
+ new ControlErrorState(this, 76.0F, 65.0F);
+ ControlRecipeSlot slotFinished;
+ if (getInventory() != null)
+ {
+ ControlSlot slotWood1 = new ControlSlot(this, 22.0F, 34.0F);
+ slotWood1.assign(Designer.design1Slot);
+ ControlSlot slotWood2 = new ControlSlot(this, 62.0F, 34.0F);
+ slotWood2.assign(Designer.design2Slot);
+
+ ControlSlot slotBeeswax = new ControlSlot(this, 42.0F, 64.0F);
+ slotBeeswax.assign(Designer.beeswaxSlot);
+
+ slotFinished = new ControlRecipeSlot(this, 112, 34);
+ }
+ }
+
+ public WindowWoodworker(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(320.0F, 216.0F, player, inventory, side);
+
+ addEventHandler(new EventTextEdit.Handler()
+ {
+ public void onEvent(EventTextEdit event)
+ {
+ WindowWoodworker.this.tileSelect.refresh((String)event.getValue());
+ }
+ }.setOrigin(EventHandler.Origin.DirectChild, this));
+ }
+
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowWoodworker(player, inventory, side);
+ }
+
+ protected AbstractMod getMod()
+ {
+ return ExtraTrees.instance;
+ }
+
+ protected String getName()
+ {
+ return "Woodworker";
+ }
+
+ public DesignerType getDesignerType()
+ {
+ return ((Designer.ComponentWoodworkerRecipe)Machine.getInterface(Designer.ComponentWoodworkerRecipe.class, getInventory())).getDesignerType();
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/kitchen/ControlDropDownMenu.java b/src/Java/binnie/craftgui/extratrees/kitchen/ControlDropDownMenu.java
new file mode 100644
index 0000000000..0d9c982400
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/kitchen/ControlDropDownMenu.java
@@ -0,0 +1,18 @@
+package binnie.craftgui.extratrees.kitchen;
+
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.minecraft.MinecraftGUI.PanelType;
+import binnie.craftgui.window.Panel;
+
+public class ControlDropDownMenu
+ extends Panel
+{
+ public ControlDropDownMenu(IWidget parent, float x, float y, float width, float height)
+ {
+ super(parent, x, y, width, 2.0F, MinecraftGUI.PanelType.Gray);
+ addAttribute(Attribute.CanFocus);
+ }
+
+ public boolean stayOpenOnChildClick = false;
+}
diff --git a/src/Java/binnie/craftgui/extratrees/kitchen/ControlDropdownButton.java b/src/Java/binnie/craftgui/extratrees/kitchen/ControlDropdownButton.java
new file mode 100644
index 0000000000..069272b82a
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/kitchen/ControlDropdownButton.java
@@ -0,0 +1,36 @@
+package binnie.craftgui.extratrees.kitchen;
+
+import binnie.craftgui.controls.button.ControlButton;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.Window;
+
+public abstract class ControlDropdownButton
+ extends ControlButton
+{
+ public ControlDropdownButton(IWidget parent, float x, float y, float width, float height, String text)
+ {
+ super(parent, x, y, width, height, text);
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ ControlDropDownMenu menu = (ControlDropDownMenu)ControlDropdownButton.this.getWidget(ControlDropDownMenu.class);
+ ControlDropdownButton.this.deleteChild((IWidget)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((IWidget)ControlDropdownButton.this.getWidget(ControlDropDownMenu.class));
+ }
+ }
+ });
+ }
+
+ public abstract ControlDropDownMenu createDropDownMenu();
+}
diff --git a/src/Java/binnie/craftgui/extratrees/kitchen/ControlFluidDisplay.java b/src/Java/binnie/craftgui/extratrees/kitchen/ControlFluidDisplay.java
new file mode 100644
index 0000000000..7ec1124226
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/kitchen/ControlFluidDisplay.java
@@ -0,0 +1,103 @@
+package binnie.craftgui.extratrees.kitchen;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.ITopLevelWidget;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.Window;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.opengl.GL11;
+
+public class ControlFluidDisplay
+ extends Control
+ implements ITooltip
+{
+ FluidStack itemStack = null;
+ public boolean hastooltip = false;
+
+ public void setTooltip()
+ {
+ this.hastooltip = true;
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public ControlFluidDisplay(IWidget parent, float f, float y)
+ {
+ this(parent, f, y, 16.0F);
+ }
+
+ public ControlFluidDisplay(IWidget parent, float f, float y, FluidStack stack, boolean tooltip)
+ {
+ this(parent, f, y, 16.0F);
+ setItemStack(stack);
+ if (tooltip) {
+ setTooltip();
+ }
+ }
+
+ public ControlFluidDisplay(IWidget parent, float x, float y, float size)
+ {
+ super(parent, x, y, size, size);
+ }
+
+ public void onRenderForeground()
+ {
+ if (this.itemStack == null) {
+ return;
+ }
+ IPoint relativeToWindow = getAbsolutePosition().sub(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)
+ {
+ Fluid fluid = this.itemStack.getFluid();
+
+ int hex = fluid.getColor(this.itemStack);
+
+ int r = (hex & 0xFF0000) >> 16;
+ int g = (hex & 0xFF00) >> 8;
+ int b = hex & 0xFF;
+
+ 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 (getSize().x() != 16.0F)
+ {
+ GL11.glPushMatrix();
+ float scale = 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(FluidStack itemStack)
+ {
+ this.itemStack = itemStack;
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ if ((this.hastooltip) && (this.itemStack != null)) {
+ tooltip.add(this.itemStack.getLocalizedName());
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/kitchen/ControlSlotFluid.java b/src/Java/binnie/craftgui/extratrees/kitchen/ControlSlotFluid.java
new file mode 100644
index 0000000000..5cd82c39de
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/kitchen/ControlSlotFluid.java
@@ -0,0 +1,77 @@
+package binnie.craftgui.extratrees.kitchen;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.ITopLevelWidget;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventWidget.ChangeSize;
+import binnie.craftgui.events.EventWidget.ChangeSize.Handler;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+
+public class ControlSlotFluid
+ extends Control
+ implements ITooltip
+{
+ ControlFluidDisplay itemDisplay;
+ FluidStack fluidStack;
+
+ public ControlSlotFluid(IWidget parent, int x, int y, FluidStack fluid)
+ {
+ this(parent, x, y, 18, fluid);
+ }
+
+ public ControlSlotFluid(IWidget parent, int x, int y, int size, FluidStack fluid)
+ {
+ super(parent, x, y, size, size);
+ addAttribute(Attribute.MouseOver);
+ this.itemDisplay = new ControlFluidDisplay(this, 1.0F, 1.0F, size - 2);
+ this.fluidStack = fluid;
+
+ addSelfEventHandler(new EventWidget.ChangeSize.Handler()
+ {
+ public void onEvent(EventWidget.ChangeSize event)
+ {
+ if (ControlSlotFluid.this.itemDisplay != null) {
+ ControlSlotFluid.this.itemDisplay.setSize(ControlSlotFluid.this.getSize().sub(new IPoint(2.0F, 2.0F)));
+ }
+ }
+ });
+ }
+
+ public void onRenderBackground()
+ {
+ int size = (int)getSize().x();
+ CraftGUI.Render.texture(CraftGUITexture.Slot, getArea());
+ if (getSuperParent().getMousedOverWidget() == this) {
+ CraftGUI.Render.gradientRect(new IArea(new IPoint(1.0F, 1.0F), getArea().size().sub(new IPoint(2.0F, 2.0F))), -2130706433, -2130706433);
+ }
+ }
+
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+ this.itemDisplay.setItemStack(getFluidStack());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ FluidStack item = getFluidStack();
+ if (item == null) {
+ return;
+ }
+ tooltip.add(item.getFluid().getLocalizedName());
+ }
+
+ public FluidStack getFluidStack()
+ {
+ return this.fluidStack;
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/kitchen/ControlSlotGlassware.java b/src/Java/binnie/craftgui/extratrees/kitchen/ControlSlotGlassware.java
new file mode 100644
index 0000000000..fa7cd3df84
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/kitchen/ControlSlotGlassware.java
@@ -0,0 +1,35 @@
+package binnie.craftgui.extratrees.kitchen;
+
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.minecraft.control.ControlSlotBase;
+import binnie.extratrees.alcohol.Glassware;
+import net.minecraft.item.ItemStack;
+
+public class ControlSlotGlassware
+ extends ControlSlotBase
+ implements IControlValue<Glassware>
+{
+ Glassware glassware;
+
+ public ControlSlotGlassware(IWidget parent, int x, int y, Glassware glassware)
+ {
+ super(parent, x, y);
+ this.glassware = glassware;
+ }
+
+ public Glassware getValue()
+ {
+ return this.glassware;
+ }
+
+ public void setValue(Glassware value)
+ {
+ this.glassware = value;
+ }
+
+ public ItemStack getItemStack()
+ {
+ return this.glassware.get(1);
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/kitchen/ControlTankSlot.java b/src/Java/binnie/craftgui/extratrees/kitchen/ControlTankSlot.java
new file mode 100644
index 0000000000..c1caf1772f
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/kitchen/ControlTankSlot.java
@@ -0,0 +1,49 @@
+package binnie.craftgui.extratrees.kitchen;
+
+import binnie.core.machines.power.TankInfo;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.Window;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.fluids.FluidStack;
+
+public class ControlTankSlot
+ extends ControlSlotFluid
+{
+ int tankID = 0;
+
+ public ControlTankSlot(IWidget parent, int x, int y, int i)
+ {
+ super(parent, x, y, null);
+ this.tankID = i;
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ if (event.getButton() == 0)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setByte("id", (byte)ControlTankSlot.this.tankID);
+ Window.get(ControlTankSlot.this.getWidget()).sendClientAction("tank-click", nbt);
+ }
+ }
+ });
+ }
+
+ public void onUpdateClient()
+ {
+ this.fluidStack = Window.get(this).getContainer().getTankInfo(this.tankID).liquid;
+ 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();
+ }
+
+ public void onRenderBackground()
+ {
+ super.onRenderBackground();
+ }
+}
diff --git a/src/Java/binnie/craftgui/extratrees/kitchen/WindowBottleRack.java b/src/Java/binnie/craftgui/extratrees/kitchen/WindowBottleRack.java
new file mode 100644
index 0000000000..8fffff9ed2
--- /dev/null
+++ b/src/Java/binnie/craftgui/extratrees/kitchen/WindowBottleRack.java
@@ -0,0 +1,48 @@
+package binnie.craftgui.extratrees.kitchen;
+
+import binnie.core.AbstractMod;
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.MachinePackage;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.extratrees.ExtraTrees;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowBottleRack
+ extends Window
+{
+ public WindowBottleRack(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(248.0F, 180.0F, player, inventory, side);
+ }
+
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowBottleRack(player, inventory, side);
+ }
+
+ protected AbstractMod getMod()
+ {
+ return ExtraTrees.instance;
+ }
+
+ protected String getName()
+ {
+ return "BottleBank";
+ }
+
+ public void initialiseClient()
+ {
+ setTitle(Machine.getMachine(getInventory()).getPackage().getDisplayName());
+ for (int i = 0; i < 36; i++)
+ {
+ int x = i % 12;
+ int y = i / 12;
+ new ControlTankSlot(this, 16 + x * 18, 32 + y * 18, i);
+ }
+ new ControlPlayerInventory(this);
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/ControlGene.java b/src/Java/binnie/craftgui/genetics/machine/ControlGene.java
new file mode 100644
index 0000000000..a5c830154e
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/ControlGene.java
@@ -0,0 +1,101 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.Binnie;
+import binnie.core.genetics.BreedingSystem;
+import binnie.core.genetics.ManagerGenetics;
+import binnie.core.resource.BinnieIcon;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.Window;
+import binnie.genetics.api.IGene;
+import binnie.genetics.core.GeneticsTexture;
+import binnie.genetics.genetics.Engineering;
+import forestry.api.genetics.IChromosomeType;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class ControlGene
+ extends Control
+ implements IControlValue<IGene>, ITooltip
+{
+ IGene gene;
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ String cName = Binnie.Genetics.getSystem(this.gene.getSpeciesRoot()).getChromosomeName(this.gene.getChromosome());
+ tooltip.add(cName + ": " + this.gene.getName());
+ if ((isMouseOver()) && (canFill(Window.get(this).getHeldItemStack())))
+ {
+ tooltip.add("Left click to assign gene");
+ IGene existingGene = Engineering.getGene(Window.get(this).getHeldItemStack(), this.gene.getChromosome().ordinal());
+ if (existingGene == null) {
+ return;
+ }
+ String dName = Binnie.Genetics.getSystem(this.gene.getSpeciesRoot()).getChromosomeName(this.gene.getChromosome());
+ tooltip.add("Will replace " + dName + ": " + existingGene.getName());
+ }
+ }
+
+ private boolean canFill(ItemStack stack)
+ {
+ return (stack != null) && (stack.stackSize == 1) && (Engineering.isGeneAcceptor(stack)) && (Engineering.canAcceptGene(stack, getValue()));
+ }
+
+ protected ControlGene(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ if (ControlGene.this.canFill(Window.get(ControlGene.this.getWidget()).getHeldItemStack()))
+ {
+ NBTTagCompound action = new NBTTagCompound();
+
+ NBTTagCompound geneNBT = new NBTTagCompound();
+ ControlGene.this.getValue().writeToNBT(geneNBT);
+
+ action.setTag("gene", geneNBT);
+
+ Window.get(ControlGene.this.getWidget()).sendClientAction("gene-select", action);
+ }
+ }
+ });
+ }
+
+ public IGene getValue()
+ {
+ return this.gene;
+ }
+
+ public void setValue(IGene value)
+ {
+ this.gene = value;
+ }
+
+ public void onRenderForeground() {}
+
+ public void onRenderBackground()
+ {
+ if ((isMouseOver()) && (canFill(Window.get(this).getHeldItemStack())))
+ {
+ CraftGUI.Render.solid(getArea(), -1);
+ CraftGUI.Render.solid(getArea().inset(1), -12303292);
+ }
+ CraftGUI.Render.colour(-1);
+
+ CraftGUI.Render.iconItem(IPoint.ZERO, GeneticsTexture.dnaIcon.getIcon());
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/ControlGeneScroll.java b/src/Java/binnie/craftgui/genetics/machine/ControlGeneScroll.java
new file mode 100644
index 0000000000..a779933050
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/ControlGeneScroll.java
@@ -0,0 +1,97 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.Binnie;
+import binnie.core.genetics.BreedingSystem;
+import binnie.core.genetics.Gene;
+import binnie.core.genetics.ManagerGenetics;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.controls.core.IControlValue;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.minecraft.Window;
+import binnie.genetics.genetics.GeneTracker;
+import forestry.api.genetics.IAllele;
+import forestry.api.genetics.IChromosomeType;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+public class ControlGeneScroll
+ extends Control
+ implements IControlValue<BreedingSystem>
+{
+ protected ControlGeneScroll(IWidget parent, float x, float y, float w, float h)
+ {
+ super(parent, x, y, w, h);
+ }
+
+ private String filter = "";
+ private BreedingSystem system = null;
+
+ public void setFilter(String filter)
+ {
+ this.filter = filter.toLowerCase();
+ refresh();
+ }
+
+ public void setGenes(BreedingSystem system)
+ {
+ this.system = system;
+ refresh();
+ }
+
+ public void refresh()
+ {
+ deleteAllChildren();
+
+ GeneTracker tracker = GeneTracker.getTracker(Window.get(this).getWorld(), Window.get(this).getUsername());
+
+ Map<IChromosomeType, List<IAllele>> genes = Binnie.Genetics.getChromosomeMap(this.system.getSpeciesRoot());
+
+ int x = 0;
+ int y = 0;
+
+ boolean isNEI = ((WindowGeneBank)Window.get(this)).isNei;
+ for (Map.Entry<IChromosomeType, List<IAllele>> entry : genes.entrySet())
+ {
+ List<IAllele> discovered = new ArrayList();
+ for (IAllele allele : (List)entry.getValue())
+ {
+ Gene gene = new Gene(allele, (IChromosomeType)entry.getKey(), this.system.getSpeciesRoot());
+ if (((isNEI) || (tracker.isSequenced(new Gene(allele, (IChromosomeType)entry.getKey(), this.system.getSpeciesRoot())))) && (gene.getName().toLowerCase().contains(this.filter))) {
+ discovered.add(allele);
+ }
+ }
+ if (discovered.size() != 0)
+ {
+ x = 0;
+ new ControlText(this, new IPoint(x, y), this.system.getChromosomeName((IChromosomeType)entry.getKey()));
+ y += 12;
+ for (IAllele allele : discovered)
+ {
+ if (x + 18 > getSize().x())
+ {
+ y += 20;
+ x = 0;
+ }
+ new ControlGene(this, x, y).setValue(new Gene(allele, (IChromosomeType)entry.getKey(), this.system.getSpeciesRoot()));
+ x += 18;
+ }
+ y += 24;
+ }
+ }
+ setSize(new IPoint(getSize().x(), y));
+ }
+
+ public void setValue(BreedingSystem system)
+ {
+ setGenes(system);
+ }
+
+ public BreedingSystem getValue()
+ {
+ return this.system;
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/ControlProcessTemporary.java b/src/Java/binnie/craftgui/genetics/machine/ControlProcessTemporary.java
new file mode 100644
index 0000000000..43e32dc9ad
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/ControlProcessTemporary.java
@@ -0,0 +1,27 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.control.ControlMachineProgress;
+
+public class ControlProcessTemporary
+ extends ControlMachineProgress
+{
+ public ControlProcessTemporary(IWidget parent, int x, int y, int width, int height)
+ {
+ super(parent, x, y, null, null, null);
+ setSize(new IPoint(width, height));
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.solid(getArea(), -4868683);
+
+ float w = getSize().y() * this.progress / 100.0F;
+
+ CraftGUI.Render.solid(new IArea(getArea().x(), getArea().y(), w, getArea().h()), -65536);
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/ControlSequencerProgress.java b/src/Java/binnie/craftgui/genetics/machine/ControlSequencerProgress.java
new file mode 100644
index 0000000000..1a80f71676
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/ControlSequencerProgress.java
@@ -0,0 +1,64 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.MachineUtil;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.minecraft.MinecraftGUI.PanelType;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlProgressBase;
+import binnie.craftgui.window.Panel;
+import java.util.Random;
+import net.minecraft.item.ItemStack;
+
+public class ControlSequencerProgress
+ extends ControlProgressBase
+{
+ ControlText textControl;
+
+ public ControlSequencerProgress(IWidget parent, int x, int y)
+ {
+ super(parent, x, y, 100.0F, 52.0F);
+
+ 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);
+ }
+
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+
+ ItemStack stack = Machine.getMachine(Window.get(this).getInventory()).getMachineUtil().getStack(5);
+ if (stack == null)
+ {
+ this.textControl.setValue("");
+ }
+ else
+ {
+ Random rand = new Random(stack.getDisplayName().length());
+
+ String text = "";
+ String[] codes = { "A", "T", "G", "C" };
+ String[] colors = { "a", "d", "b", "c" };
+ for (int i = 0; i < 65; i++)
+ {
+ int k = rand.nextInt(4);
+ String code = codes[k];
+ if (rand.nextFloat() < this.progress)
+ {
+ String col = "§" + colors[k];
+ text = text + "§r" + col + "§l" + code;
+ }
+ else
+ {
+ text = text + "§r§7§k§l" + code;
+ }
+ }
+ this.textControl.setValue(text);
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/ControlSplicerProgress.java b/src/Java/binnie/craftgui/genetics/machine/ControlSplicerProgress.java
new file mode 100644
index 0000000000..7afa16f31f
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/ControlSplicerProgress.java
@@ -0,0 +1,60 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.machines.power.ProcessInfo;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.control.ControlProgressBase;
+
+public class ControlSplicerProgress
+ extends ControlProgressBase
+{
+ float strength = 0.0F;
+
+ public ControlSplicerProgress(IWidget parent, float x, float y, float w, float h)
+ {
+ super(parent, x, y, w, h);
+ this.strength = 0.0F;
+ }
+
+ public void onRenderBackground()
+ {
+ float progress = getProcess().getCurrentProgress() / 100.0F;
+
+ float n = getProcess().getProcessTime() / 12.0F;
+ float spacing = 10.0F;
+ float range = w();
+ float h = 8.0F;
+
+ float ooy = -((n - 1.0F) * spacing) - range / 2.0F;
+ float ddy = (n - 1.0F) * spacing + range;
+ float oy = ooy + ddy * progress;
+ for (int i = 0; i < n; i++)
+ {
+ int seed = 432523;
+ int[] colours = { 10027008, 30464, 255, 10057472 };
+ int c1 = colours[((int)Math.abs(13.0D * Math.sin(i) + 48.0D * Math.cos(i) + 25.0D * Math.sin(7 * i)) % 4)];
+ int c2 = colours[((int)Math.abs(23.0D * Math.sin(i) + 28.0D * Math.cos(i) + 15.0D * Math.sin(7 * i)) % 4)];
+ int c3 = colours[((int)Math.abs(43.0D * Math.sin(i) + 38.0D * Math.cos(i) + 55.0D * Math.sin(7 * i)) % 4)];
+ int c4 = colours[((int)Math.abs(3.0D * Math.sin(i) + 18.0D * Math.cos(i) + 35.0D * Math.sin(7 * i)) % 4)];
+
+ float y = oy + i * spacing;
+ if ((y > -range / 2.0F) && (y < range / 2.0F))
+ {
+ float percentView = (float)Math.sqrt(1.0F - Math.abs(2.0F * y / range));
+ float offMovement = (h() - 2.0F * h) / 2.0F;
+ int alpha = 16777216 * (int)(255.0F * percentView);
+ c1 += alpha;
+ c2 += alpha;
+ c3 += alpha;
+ c4 += alpha;
+ CraftGUI.Render.solidAlpha(new IArea(w() / 2.0F + y, offMovement * percentView, 4.0F, h / 2.0F), c1);
+ CraftGUI.Render.solidAlpha(new IArea(w() / 2.0F + y, offMovement * percentView + 4.0F, 4.0F, h / 2.0F), y < 0.0F ? c2 : c3);
+
+ CraftGUI.Render.solidAlpha(new IArea(w() / 2.0F + y, h() - offMovement * percentView - 8.0F, 4.0F, h / 2.0F), y < 0.0F ? c3 : c2);
+ CraftGUI.Render.solidAlpha(new IArea(w() / 2.0F + y, h() - offMovement * percentView - 4.0F, 4.0F, h / 2.0F), c4);
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowAcclimatiser.java b/src/Java/binnie/craftgui/genetics/machine/WindowAcclimatiser.java
new file mode 100644
index 0000000000..8ed95dd0ef
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowAcclimatiser.java
@@ -0,0 +1,80 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlSlotArray;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.extrabees.core.ExtraBeeTexture;
+import binnie.genetics.Genetics;
+import binnie.genetics.machine.Acclimatiser;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowAcclimatiser
+ extends WindowMachine
+{
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowAcclimatiser(player, inventory, side);
+ }
+
+ public WindowAcclimatiser(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(280, 198, player, inventory, side);
+ }
+
+ static Texture ProgressBase = new StandardTexture(64, 0, 130, 21, ExtraBeeTexture.GUIProgress.getTexture());
+ static Texture Progress = new StandardTexture(64, 21, 130, 21, ExtraBeeTexture.GUIProgress.getTexture());
+ public static final int[] slotReserve = { 0, 1, 2, 3 };
+ public static final int slotTarget = 4;
+ public static final int[] slotAcclimatiser = { 5, 6, 7 };
+ public static final int[] slotDone = { 8, 9, 10, 11 };
+
+ public void initialiseClient()
+ {
+ setTitle("Acclimatiser");
+
+ int x = 16;
+ int y = 32;
+
+ new ControlSlotArray(this, x, y, 2, 2).create(Acclimatiser.slotReserve);
+
+ x += 54;
+
+ new ControlSlot(this, x + 18, y).assign(4);
+ new ControlSlotArray(this, x, y + 18 + 18, 3, 1).create(Acclimatiser.slotAcclimatiser);
+
+ x += 72;
+
+ new ControlSlotArray(this, x, y, 2, 2).create(Acclimatiser.slotDone);
+
+
+ new ControlEnergyBar(this, 21, 115, 16, 60, Position.Bottom);
+
+ new ControlErrorState(this, 181.0F, 83.0F);
+
+ new ControlPlayerInventory(this);
+ }
+
+ public String getTitle()
+ {
+ return "Acclimatiser";
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "Acclimatiser";
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowAnalyser.java b/src/Java/binnie/craftgui/genetics/machine/WindowAnalyser.java
new file mode 100644
index 0000000000..c1a2ac5305
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowAnalyser.java
@@ -0,0 +1,110 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.minecraft.GUIIcon;
+import binnie.craftgui.minecraft.MinecraftGUI.PanelType;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlIconDisplay;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlProgress;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlSlotArray;
+import binnie.craftgui.minecraft.control.ControlSlotCharge;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.craftgui.window.Panel;
+import binnie.extrabees.core.ExtraBeeTexture;
+import binnie.genetics.Genetics;
+import binnie.genetics.core.GeneticsTexture;
+import binnie.genetics.machine.Analyser;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowAnalyser
+ extends WindowMachine
+{
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowAnalyser(player, inventory, side);
+ }
+
+ static Texture ProgressBase = new StandardTexture(0, 218, 142, 17, ExtraBeeTexture.GUIProgress.getTexture());
+ static Texture Progress = new StandardTexture(0, 201, 142, 17, ExtraBeeTexture.GUIProgress.getTexture());
+
+ public WindowAnalyser(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(220, 210, player, inventory, side);
+ }
+
+ public void initialiseClient()
+ {
+ ProgressBase = new StandardTexture(0, 51, 66, 40, GeneticsTexture.GUIProcess.getTexture());
+ Progress = new StandardTexture(66, 51, 66, 40, GeneticsTexture.GUIProcess.getTexture());
+
+
+
+
+ int x = 16;
+ int y = 32;
+
+ new ControlSlotArray(this, x, y, 2, 3).create(Analyser.slotReserve);
+
+
+ x += 28;
+
+ new ControlSlot(this, x, y + 54 + 8).assign(13);
+ new ControlSlotCharge(this, x + 20, y + 54 + 8, 13).setColour(10040319);
+ new ControlEnergyBar(this, x + 24 + 16, y + 54 + 8 + 1, 60, 16, Position.Left);
+ new ControlErrorState(this, x + 24 + 16 + 60 + 16, y + 54 + 8 + 1);
+
+
+ x -= 28;
+
+ new ControlIconDisplay(this, x + 36 + 2, y + 18, GUIIcon.ArrowRight.getIcon());
+
+
+ x += 56;
+
+ new Panel(this, x, y, 76.0F, 50.0F, MinecraftGUI.PanelType.Tinted);
+
+ new ControlProgress(this, x + 5, y + 5, ProgressBase, Progress, Position.Left);
+
+ new ControlSlot(this, x + 38 - 9, y + 25 - 9).assign(6);
+
+ new ControlIconDisplay(this, x + 76 + 2, y + 18, GUIIcon.ArrowRight.getIcon());
+
+
+ x += 96;
+
+
+
+ new ControlSlotArray(this, x, y, 2, 3).create(Analyser.slotFinished);
+
+
+ x += 52;
+
+ setTitle("Analyser");
+
+
+ new ControlPlayerInventory(this);
+ }
+
+ public String getTitle()
+ {
+ return "Analyser";
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "Analyser";
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowGeneBank.java b/src/Java/binnie/craftgui/genetics/machine/WindowGeneBank.java
new file mode 100644
index 0000000000..e13bca4ce5
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowGeneBank.java
@@ -0,0 +1,256 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.Binnie;
+import binnie.core.AbstractMod;
+import binnie.core.genetics.BreedingSystem;
+import binnie.core.genetics.Gene;
+import binnie.core.genetics.ManagerGenetics;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextEdit;
+import binnie.craftgui.controls.scroll.ControlScrollableContent;
+import binnie.craftgui.controls.tab.ControlTab;
+import binnie.craftgui.controls.tab.ControlTabBar;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventTextEdit;
+import binnie.craftgui.events.EventTextEdit.Handler;
+import binnie.craftgui.events.EventValueChanged;
+import binnie.craftgui.events.EventValueChanged.Handler;
+import binnie.craftgui.minecraft.MinecraftGUI.PanelType;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlTabIcon;
+import binnie.craftgui.window.Panel;
+import binnie.genetics.Genetics;
+import binnie.genetics.genetics.Engineering;
+import binnie.genetics.genetics.GeneTracker;
+import cpw.mods.fml.relauncher.Side;
+import forestry.api.genetics.IAllele;
+import forestry.api.genetics.IChromosomeType;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
+
+public class WindowGeneBank
+ extends WindowMachine
+{
+ public static IIcon[] iconsDNA;
+ public boolean isNei;
+ ControlGeneScroll genes;
+
+ public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound action)
+ {
+ super.recieveGuiNBT(side, player, name, action);
+ if ((side == Side.SERVER) && (name.equals("gene-select")))
+ {
+ Gene gene = new Gene(action.getCompoundTag("gene"));
+ if ((gene != null) && (!gene.isCorrupted()))
+ {
+ ItemStack held = getHeldItemStack();
+
+ ItemStack converted = Engineering.addGene(held, gene);
+
+ getPlayer().inventory.setItemStack(converted);
+
+ getPlayer().inventory.markDirty();
+ if ((getPlayer() instanceof EntityPlayerMP)) {
+ ((EntityPlayerMP)getPlayer()).sendContainerToPlayer(player.inventoryContainer);
+ }
+ }
+ }
+ }
+
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowGeneBank(player, inventory, side, false);
+ }
+
+ public WindowGeneBank(EntityPlayer player, IInventory inventory, Side side, boolean isNEI)
+ {
+ super(320, 224, player, inventory, side);
+ this.isNei = isNEI;
+ }
+
+ public void initialiseServer()
+ {
+ GeneTracker tracker = GeneTracker.getTracker(getWorld(), getUsername());
+ if (tracker != null) {
+ tracker.synchToPlayer(getPlayer());
+ }
+ }
+
+ public void initialiseClient()
+ {
+ setTitle("Gene Bank");
+
+ addEventHandler(new EventValueChanged.Handler()
+ {
+ public void onEvent(EventValueChanged event)
+ {
+ if ((event.value instanceof BreedingSystem)) {
+ WindowGeneBank.this.genes.setValue((BreedingSystem)event.value);
+ }
+ }
+ });
+ int boxX = 100;
+
+ int x = 16;
+ int y = 32;
+
+ new ControlPlayerInventory(this, x, y);
+
+ x += 124;
+
+ boxX = x;
+
+ int geneBoxWidth = 120;
+
+ new Panel(this, boxX + 24, 32.0F, geneBoxWidth, 120.0F, MinecraftGUI.PanelType.Black);
+ new Panel(this, boxX + 24 + geneBoxWidth, 32.0F, 14.0F, 120.0F, MinecraftGUI.PanelType.Gray);
+ ControlScrollableContent scroll = new ControlScrollableContent(this, boxX + 24 + 2, 34.0F, geneBoxWidth + 10, 116.0F, 12.0F);
+
+ ControlTextEdit edit = new ControlTextEdit(this, boxX + 27 + geneBoxWidth - 70, 18.0F, 80.0F, 12.0F);
+
+ addEventHandler(new EventTextEdit.Handler()
+ {
+ public void onEvent(EventTextEdit event)
+ {
+ WindowGeneBank.this.genes.setFilter((String)event.getValue());
+ }
+ }.setOrigin(EventHandler.Origin.Self, edit));
+
+
+
+ this.genes = new ControlGeneScroll(scroll, 1.0F, 1.0F, geneBoxWidth, 116.0F);
+ scroll.setScrollableContent(this.genes);
+
+
+
+
+
+ this.genes.setGenes(Binnie.Genetics.beeBreedingSystem);
+
+ ControlTabBar<BreedingSystem> tabBar = new ControlTabBar(this, boxX, 32.0F, 24.0F, 120.0F, Position.Left)
+ {
+ public ControlTab<BreedingSystem> createTab(float x, float y, float w, float h, BreedingSystem value)
+ {
+ new ControlTabIcon(this, x, y, w, h, value)
+ {
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.add(((BreedingSystem)getValue()).toString());
+
+ int totalGenes = 0;
+ int seqGenes = 0;
+
+ GeneTracker tracker = GeneTracker.getTracker(WindowGeneBank.this.getWorld(), WindowGeneBank.this.getUsername());
+
+ Map<IChromosomeType, List<IAllele>> genes = Binnie.Genetics.getChromosomeMap(((BreedingSystem)getValue()).getSpeciesRoot());
+ for (Iterator i$ = genes.entrySet().iterator(); i$.hasNext();)
+ {
+ entry = (Map.Entry)i$.next();
+ totalGenes += ((List)entry.getValue()).size();
+ for (IAllele allele : (List)entry.getValue())
+ {
+ Gene gene = new Gene(allele, (IChromosomeType)entry.getKey(), ((BreedingSystem)getValue()).getSpeciesRoot());
+ if (tracker.isSequenced(gene)) {
+ seqGenes++;
+ }
+ }
+ }
+ Map.Entry<IChromosomeType, List<IAllele>> entry;
+ tooltip.add("" + seqGenes + "/" + totalGenes + " Genes");
+ }
+ };
+ }
+ };
+ tabBar.setValues(Binnie.Genetics.getActiveSystems());
+
+ tabBar.setValue(Binnie.Genetics.beeBreedingSystem);
+
+ boxX -= 8;
+
+ ControlTabBar<String> infoTabs = new ControlTabBar(this, boxX + 8, 160.0F, 16.0F, 50.0F, Position.Left);
+
+ infoTabs.setValues(Arrays.asList(new String[] { "Stats", "Ranking" }));
+
+ infoTabs.setValue("Info");
+
+ Panel panelProject = new Panel(this, boxX + 24, 160.0F, geneBoxWidth + 20, 50.0F, MinecraftGUI.PanelType.Black);
+
+ int totalGenes = 0;
+ int seqGenes = 0;
+ for (Iterator i$ = Binnie.Genetics.getActiveSystems().iterator(); i$.hasNext();)
+ {
+ system = (BreedingSystem)i$.next();
+
+ tracker = GeneTracker.getTracker(getWorld(), getUsername());
+
+ Map<IChromosomeType, List<IAllele>> genes = Binnie.Genetics.getChromosomeMap(system.getSpeciesRoot());
+ for (i$ = genes.entrySet().iterator(); i$.hasNext();)
+ {
+ entry = (Map.Entry)i$.next();
+ totalGenes += ((List)entry.getValue()).size();
+ for (IAllele allele : (List)entry.getValue())
+ {
+ Gene gene = new Gene(allele, (IChromosomeType)entry.getKey(), system.getSpeciesRoot());
+ if (tracker.isSequenced(gene)) {
+ seqGenes++;
+ }
+ }
+ }
+ }
+ BreedingSystem system;
+ GeneTracker tracker;
+ Iterator i$;
+ Map.Entry<IChromosomeType, List<IAllele>> entry;
+ new ControlText(panelProject, new IPoint(4.0F, 4.0F), "§nFull Genome Project");
+ new ControlText(panelProject, new IPoint(4.0F, 18.0F), "§oSequenced §r" + seqGenes + "/" + totalGenes + " §oGenes");
+ }
+
+ public String getTitle()
+ {
+ return "Gene Bank";
+ }
+
+ public static class ChromosomeType
+ {
+ IChromosomeType chromosome;
+ BreedingSystem system;
+
+ public ChromosomeType(IChromosomeType chromosome, BreedingSystem system)
+ {
+ this.chromosome = chromosome;
+ this.system = system;
+ }
+
+ public String toString()
+ {
+ return this.system.getChromosomeName(this.chromosome);
+ }
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "GeneBank";
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowGeneBankNEI.java b/src/Java/binnie/craftgui/genetics/machine/WindowGeneBankNEI.java
new file mode 100644
index 0000000000..08e680c68d
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowGeneBankNEI.java
@@ -0,0 +1,14 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.craftgui.minecraft.Window;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowGeneBankNEI
+{
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowGeneBank(player, inventory, side, true);
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowGeneProject.java b/src/Java/binnie/craftgui/genetics/machine/WindowGeneProject.java
new file mode 100644
index 0000000000..c79e6f7d0c
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowGeneProject.java
@@ -0,0 +1,32 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.minecraft.Window;
+import binnie.genetics.Genetics;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowGeneProject
+ extends Window
+{
+ public WindowGeneProject(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(100.0F, 100.0F, player, inventory, side);
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "GeneProjects";
+ }
+
+ public void initialiseClient()
+ {
+ setTitle("Gene Projects");
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowGenepool.java b/src/Java/binnie/craftgui/genetics/machine/WindowGenepool.java
new file mode 100644
index 0000000000..c91b95c0bb
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowGenepool.java
@@ -0,0 +1,96 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.minecraft.GUIIcon;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlIconDisplay;
+import binnie.craftgui.minecraft.control.ControlLiquidTank;
+import binnie.craftgui.minecraft.control.ControlMachineProgress;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlSlotArray;
+import binnie.craftgui.minecraft.control.ControlSlotCharge;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.extrabees.core.ExtraBeeTexture;
+import binnie.genetics.Genetics;
+import binnie.genetics.machine.Genepool;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowGenepool
+ extends WindowMachine
+{
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowGenepool(player, inventory, side);
+ }
+
+ public WindowGenepool(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(280, 198, player, inventory, side);
+ }
+
+ static Texture ProgressBase = new StandardTexture(64, 0, 130, 21, ExtraBeeTexture.GUIProgress.getTexture());
+ static Texture Progress = new StandardTexture(64, 21, 130, 21, ExtraBeeTexture.GUIProgress.getTexture());
+
+ public void initialiseClient()
+ {
+ setTitle("Genepool");
+
+ int x = 16;
+ int y = 32;
+
+ new ControlLiquidTank(this, x, y).setTankID(1);
+
+ x += 26;
+
+ new ControlSlotArray(this, x, y + 3, 2, 3).create(Genepool.slotReserve);
+
+ x += 38;
+
+ new ControlIconDisplay(this, x, y + 3 + 18 + 1, GUIIcon.ArrowRight.getIcon());
+
+ x += 18;
+
+ new ControlSlot(this, x, y + 3 + 18).assign(0);
+
+ x += 18;
+
+ new ControlMachineProgress(this, x, y + 19, ProgressBase, Progress, Position.Left);
+
+ x += 130;
+
+ new ControlLiquidTank(this, x, y).setTankID(0);
+
+
+ new ControlEnergyBar(this, 21, 115, 16, 60, Position.Bottom);
+
+ new ControlSlot(this, 121.0F, 82.0F).assign(7);
+ new ControlSlotCharge(this, 143, 82, 7).setColour(15722671);
+
+
+ new ControlErrorState(this, 181.0F, 83.0F);
+
+ new ControlPlayerInventory(this);
+ }
+
+ public String getTitle()
+ {
+ return "Genepool";
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "Genepool";
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowGenomeAssembler.java b/src/Java/binnie/craftgui/genetics/machine/WindowGenomeAssembler.java
new file mode 100644
index 0000000000..d6e31c3c69
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowGenomeAssembler.java
@@ -0,0 +1,37 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.minecraft.Window;
+import binnie.genetics.Genetics;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowGenomeAssembler
+ extends WindowMachine
+{
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowGenomeAssembler(player, inventory, side);
+ }
+
+ public WindowGenomeAssembler(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(320, 240, player, inventory, side);
+ }
+
+ public String getTitle()
+ {
+ return "Genome Assembler";
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "GenomeAssembler";
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowIncubator.java b/src/Java/binnie/craftgui/genetics/machine/WindowIncubator.java
new file mode 100644
index 0000000000..f52a0b1717
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowIncubator.java
@@ -0,0 +1,99 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.minecraft.GUIIcon;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlIconDisplay;
+import binnie.craftgui.minecraft.control.ControlLiquidTank;
+import binnie.craftgui.minecraft.control.ControlMachineProgress;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlSlotArray;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.genetics.Genetics;
+import binnie.genetics.core.GeneticsTexture;
+import binnie.genetics.machine.Incubator;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowIncubator
+ extends WindowMachine
+{
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowIncubator(player, inventory, side);
+ }
+
+ public WindowIncubator(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(228, 196, player, inventory, side);
+ }
+
+ static Texture ProgressBase = new StandardTexture(0, 91, 38, 32, GeneticsTexture.GUIProcess);
+ static Texture Progress = new StandardTexture(38, 91, 38, 32, GeneticsTexture.GUIProcess);
+
+ public void initialiseClient()
+ {
+ setTitle("Incubator");
+
+ int x = 16;
+ int y = 32;
+
+
+ new ControlLiquidTank(this, x, y).setTankID(0);
+
+ x += 26;
+
+ new ControlSlotArray(this, x, y + 3, 1, 3).create(Incubator.slotQueue);
+
+ x += 20;
+
+ new ControlIconDisplay(this, x, y + 3 + 10, GUIIcon.ArrowRight.getIcon());
+
+ x += 18;
+
+ new ControlMachineProgress(this, x, y + 6, ProgressBase, Progress, Position.Left);
+
+ new ControlSlot(this, x + 11, y + 3 + 10).assign(3);
+
+ x += 40;
+
+ new ControlIconDisplay(this, x, y + 3 + 10, GUIIcon.ArrowRight.getIcon());
+
+ x += 18;
+
+ new ControlSlotArray(this, x, y + 3, 1, 3).create(Incubator.slotOutput);
+
+ x += 26;
+
+ new ControlLiquidTank(this, x, y).setTankID(1);
+
+ x += 34;
+
+ new ControlEnergyBar(this, x, y + 3, 16, 54, Position.Bottom);
+
+ new ControlErrorState(this, 91.0F, 82.0F);
+
+ new ControlPlayerInventory(this);
+ }
+
+ public String getTitle()
+ {
+ return "Incubator";
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "Incubator";
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowInoculator.java b/src/Java/binnie/craftgui/genetics/machine/WindowInoculator.java
new file mode 100644
index 0000000000..894170efd0
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowInoculator.java
@@ -0,0 +1,107 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.CraftGUIUtil;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.minecraft.GUIIcon;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlIconDisplay;
+import binnie.craftgui.minecraft.control.ControlLiquidTank;
+import binnie.craftgui.minecraft.control.ControlMachineProgress;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlSlotArray;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.genetics.Genetics;
+import binnie.genetics.core.GeneticsTexture;
+import binnie.genetics.machine.Inoculator;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowInoculator
+ extends WindowMachine
+{
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowInoculator(player, inventory, side);
+ }
+
+ public WindowInoculator(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(266, 240, player, inventory, side);
+ }
+
+ static Texture ProgressBase = new StandardTexture(0, 72, 142, 72, GeneticsTexture.GUIProcess2.getTexture());
+ static Texture Progress = new StandardTexture(0, 0, 142, 72, GeneticsTexture.GUIProcess2.getTexture());
+
+ public void initialiseClient()
+ {
+ setTitle("Inoculator");
+
+ int x = 16;
+ int y = 32;
+
+
+ new ControlLiquidTank(this, x, y + 18 + 16).setTankID(0);
+
+
+ CraftGUIUtil.horizontalGrid(x, y, new IWidget[] { new ControlSlotArray(this, 0, 0, 2, 1).create(Inoculator.slotSerumReserve), new ControlIconDisplay(this, 0.0F, 0.0F, GUIIcon.ArrowRight.getIcon()), new ControlSlot(this, 0.0F, 0.0F).assign(0), new ControlIconDisplay(this, 0.0F, 0.0F, GUIIcon.ArrowRight.getIcon()), new ControlSlotArray(this, 0, 0, 2, 1).create(Inoculator.slotSerumExpended) });
+
+
+
+
+
+
+
+
+ x += 18;
+
+ new ControlMachineProgress(this, x, y + 24, ProgressBase, Progress, Position.Left);
+
+
+ new ControlEnergyBar(this, 91, 118, 60, 16, Position.Left);
+ new ControlErrorState(this, 161.0F, 118.0F);
+
+
+ x += 142;
+
+
+ CraftGUIUtil.verticalGrid(x, y, TextJustification.MiddleLeft, 8.0F, new IWidget[] { new ControlSlotArray(this, x, y, 4, 1).create(Inoculator.slotReserve), new ControlSlot(this, x, y + 18 + 8).assign(9), new ControlSlotArray(this, x, y + 18 + 8 + 18 + 8, 4, 1).create(Inoculator.slotFinished) });
+
+
+
+
+
+ new ControlIconDisplay(this, x + 18, y + 18 + 2, GUIIcon.ArrowUpLeft.getIcon());
+ new ControlIconDisplay(this, x + 18, y + 18 + 18, GUIIcon.ArrowLeftDown.getIcon());
+
+
+
+
+
+
+
+ new ControlPlayerInventory(this);
+ }
+
+ public String getTitle()
+ {
+ return "Inoculator";
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "Inoculator";
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowIsolator.java b/src/Java/binnie/craftgui/genetics/machine/WindowIsolator.java
new file mode 100644
index 0000000000..6d494250ee
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowIsolator.java
@@ -0,0 +1,116 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.minecraft.GUIIcon;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlIconDisplay;
+import binnie.craftgui.minecraft.control.ControlLiquidTank;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlProgress;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlSlotArray;
+import binnie.craftgui.minecraft.control.ControlSlotCharge;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.extrabees.core.ExtraBeeTexture;
+import binnie.genetics.Genetics;
+import binnie.genetics.machine.Isolator;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowIsolator
+ extends WindowMachine
+{
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowIsolator(player, inventory, side);
+ }
+
+ static Texture ProgressBase = new StandardTexture(0, 218, 142, 17, ExtraBeeTexture.GUIProgress.getTexture());
+ static Texture Progress = new StandardTexture(0, 201, 142, 17, ExtraBeeTexture.GUIProgress.getTexture());
+
+ public WindowIsolator(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(330, 208, player, inventory, side);
+ }
+
+ public void initialiseClient()
+ {
+ setTitle("Isolator");
+
+ int x = 16;
+ int y = 32;
+
+ new ControlLiquidTank(this, x, y).setTankID(0);
+
+ x += 26;
+
+ new ControlSlotArray(this, x, y + 3, 1, 3).create(Isolator.slotReserve);
+
+ x += 20;
+
+ new ControlIconDisplay(this, x, y + 3 + 1, GUIIcon.ArrowRight.getIcon());
+
+ x += 18;
+
+ new ControlSlot(this, x, y + 3).assign(5);
+
+ new ControlSlot(this, x, y + 36 + 3).assign(0);
+ new ControlSlotCharge(this, x + 18 + 2, y + 36 + 3, 0).setColour(15722671);
+
+
+
+ x += 18;
+
+ new ControlProgress(this, x, y + 3, ProgressBase, Progress, Position.Left);
+
+ x += 142;
+
+ new ControlSlot(this, x, y + 3).assign(6);
+
+ new ControlSlot(this, x, y + 3 + 36).assign(1);
+
+ new ControlIconDisplay(this, x + 1, y + 3 + 19, GUIIcon.ArrowUp.getIcon());
+
+ x += 20;
+
+
+ new ControlIconDisplay(this, x, y + 3 + 1, GUIIcon.ArrowRight.getIcon());
+
+ x += 18;
+
+ new ControlSlotArray(this, x, y + 3, 2, 3).create(Isolator.slotFinished);
+
+
+ new ControlEnergyBar(this, 260, 130, 16, 60, Position.Bottom);
+
+
+
+
+
+
+
+ new ControlErrorState(this, 153.0F, 81.0F);
+
+ new ControlPlayerInventory(this);
+ }
+
+ public String getTitle()
+ {
+ return "Incubator";
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "Isolator";
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowMachine.java b/src/Java/binnie/craftgui/genetics/machine/WindowMachine.java
new file mode 100644
index 0000000000..6b357a36d7
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowMachine.java
@@ -0,0 +1,22 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.craftgui.minecraft.Window;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public abstract class WindowMachine
+ extends Window
+{
+ public WindowMachine(int width, int height, EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(width, height, player, inventory, side);
+ }
+
+ public abstract String getTitle();
+
+ public void initialiseClient()
+ {
+ setTitle(getTitle());
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowPolymeriser.java b/src/Java/binnie/craftgui/genetics/machine/WindowPolymeriser.java
new file mode 100644
index 0000000000..edf9e371f7
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowPolymeriser.java
@@ -0,0 +1,101 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.minecraft.GUIIcon;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlIconDisplay;
+import binnie.craftgui.minecraft.control.ControlLiquidTank;
+import binnie.craftgui.minecraft.control.ControlMachineProgress;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlSlotArray;
+import binnie.craftgui.minecraft.control.ControlSlotCharge;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.genetics.Genetics;
+import binnie.genetics.core.GeneticsTexture;
+import binnie.genetics.machine.Polymeriser;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowPolymeriser
+ extends WindowMachine
+{
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowPolymeriser(player, inventory, side);
+ }
+
+ public WindowPolymeriser(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(278, 212, player, inventory, side);
+ }
+
+ static Texture ProgressBase = new StandardTexture(76, 170, 160, 79, GeneticsTexture.GUIProcess.getTexture());
+ static Texture Progress = new StandardTexture(76, 91, 160, 79, GeneticsTexture.GUIProcess.getTexture());
+
+ public void initialiseClient()
+ {
+ super.initialiseClient();
+
+ int x = 16;
+ int y = 38;
+
+
+
+
+
+ new ControlSlotArray(this, x, y, 1, 4).create(Polymeriser.slotSerumReserve);
+ new ControlIconDisplay(this, x + 18, y + 1, GUIIcon.ArrowRight.getIcon());
+
+ x += 34;
+
+ new ControlMachineProgress(this, x + 18, y - 6, ProgressBase, Progress, Position.Left);
+
+
+ new ControlSlot(this, x, y).assign(0);
+
+
+ new ControlLiquidTank(this, x, y + 18 + 16, true).setTankID(0);
+
+ new ControlLiquidTank(this, x, y + 18 + 16 + 18 + 8, true).setTankID(1);
+
+ new ControlEnergyBar(this, x + 120, 96, 64, 16, Position.Left);
+
+ x += 40;
+
+ new ControlSlot(this, x + 30, y + 18 + 8).assign(1);
+ new ControlSlotCharge(this, x + 30 + 20, y + 18 + 8, 1).setColour(16766976);
+
+
+
+
+ x += 138;
+
+ new ControlSlotArray(this, x, y + 9, 2, 2).create(Polymeriser.slotSerumFinished);
+
+ ControlErrorState errorState = new ControlErrorState(this, 244.0F, 97.0F);
+
+
+ new ControlPlayerInventory(this);
+ }
+
+ public String getTitle()
+ {
+ return "Polymeriser";
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "Polymeriser";
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowSequencer.java b/src/Java/binnie/craftgui/genetics/machine/WindowSequencer.java
new file mode 100644
index 0000000000..9e2f580b53
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowSequencer.java
@@ -0,0 +1,116 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.CraftGUIUtil;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.minecraft.GUIIcon;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlIconDisplay;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlSlotArray;
+import binnie.craftgui.minecraft.control.ControlSlotCharge;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.extrabees.core.ExtraBeeTexture;
+import binnie.genetics.Genetics;
+import binnie.genetics.machine.Sequencer;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class WindowSequencer
+ extends WindowMachine
+{
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowSequencer(player, inventory, side);
+ }
+
+ public WindowSequencer(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(226, 224, player, inventory, side);
+ }
+
+ static Texture ProgressBase = new StandardTexture(64, 114, 98, 9, ExtraBeeTexture.GUIProgress.getTexture());
+ static Texture Progress = new StandardTexture(64, 123, 98, 9, ExtraBeeTexture.GUIProgress.getTexture());
+ ControlText slotText;
+
+ public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound action)
+ {
+ if ((side == Side.CLIENT) && (name.equals("username"))) {
+ this.slotText.setValue("§8Genes will be sequenced by " + action.getString("username"));
+ }
+ super.recieveGuiNBT(side, player, name, action);
+ }
+
+ public void initialiseClient()
+ {
+ setTitle("Sequencer");
+
+
+ int x = 16;
+ int y = 32;
+
+
+
+
+ CraftGUIUtil.horizontalGrid(x, y, TextJustification.MiddleCenter, 2.0F, new IWidget[] { new ControlSlotArray(this, 0, 0, 2, 2).create(Sequencer.slotReserve), new ControlIconDisplay(this, 0.0F, 0.0F, GUIIcon.ArrowRight.getIcon()), new ControlSequencerProgress(this, 0, 0), new ControlIconDisplay(this, 0.0F, 0.0F, GUIIcon.ArrowRight.getIcon()), new ControlSlot(this, 0.0F, 0.0F).assign(6) });
+
+
+
+
+
+
+
+
+ ControlSlot slotTarget = new ControlSlot(this, x + 96, y + 16);
+ slotTarget.assign(5);
+
+ x = 34;
+ y = 92;
+
+ this.slotText = new ControlText(this, new IArea(0.0F, y, w(), 12.0F), "§8Userless. Will not save sequences", TextJustification.MiddleCenter);
+
+
+
+ y += 20;
+
+ ControlSlot slotDye = new ControlSlot(this, x, y);
+ slotDye.assign(0);
+ x += 20;
+ new ControlSlotCharge(this, x, y, 0).setColour(16750848);
+
+ x += 32;
+ new ControlEnergyBar(this, x, y, 60, 16, Position.Left);
+
+ x += 92;
+ ControlErrorState errorState = new ControlErrorState(this, x, y + 1);
+
+
+
+ new ControlPlayerInventory(this);
+ }
+
+ public String getTitle()
+ {
+ return "Incubator";
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "Sequencer";
+ }
+}
diff --git a/src/Java/binnie/craftgui/genetics/machine/WindowSplicer.java b/src/Java/binnie/craftgui/genetics/machine/WindowSplicer.java
new file mode 100644
index 0000000000..23d7cd8015
--- /dev/null
+++ b/src/Java/binnie/craftgui/genetics/machine/WindowSplicer.java
@@ -0,0 +1,93 @@
+package binnie.craftgui.genetics.machine;
+
+import binnie.core.AbstractMod;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.CraftGUIUtil;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.minecraft.GUIIcon;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlEnergyBar;
+import binnie.craftgui.minecraft.control.ControlErrorState;
+import binnie.craftgui.minecraft.control.ControlIconDisplay;
+import binnie.craftgui.minecraft.control.ControlPlayerInventory;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlSlotArray;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import binnie.genetics.Genetics;
+import binnie.genetics.core.GeneticsTexture;
+import binnie.genetics.machine.Inoculator;
+import binnie.genetics.machine.Splicer;
+import cpw.mods.fml.relauncher.Side;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+
+public class WindowSplicer
+ extends WindowMachine
+{
+ public static Window create(EntityPlayer player, IInventory inventory, Side side)
+ {
+ return new WindowSplicer(player, inventory, side);
+ }
+
+ public WindowSplicer(EntityPlayer player, IInventory inventory, Side side)
+ {
+ super(280, 240, player, inventory, side);
+ }
+
+ static Texture ProgressBase = new StandardTexture(0, 72, 142, 72, GeneticsTexture.GUIProcess2.getTexture());
+ static Texture Progress = new StandardTexture(0, 0, 142, 72, GeneticsTexture.GUIProcess2.getTexture());
+
+ public void initialiseClient()
+ {
+ setTitle("Splicer");
+
+ int x = 16;
+
+
+
+
+ new ControlSplicerProgress(this, 84.0F, 32.0F, w() - 172.0F, 102.0F);
+
+ CraftGUIUtil.horizontalGrid(x, 62.0F, new IWidget[] { new ControlSlotArray(this, 0, 0, 2, 1).create(Splicer.slotSerumReserve), new ControlIconDisplay(this, 0.0F, 0.0F, GUIIcon.ArrowRight.getIcon()), new ControlSlot(this, 0.0F, 0.0F).assign(0) });
+
+
+
+
+ new ControlSlotArray(this, x + 12, 84, 2, 1).create(Splicer.slotSerumExpended);
+
+ new ControlIconDisplay(this, x + 12 + 36 + 4, 86.0F, GUIIcon.ArrowUpLeft.getIcon());
+
+
+
+ new ControlEnergyBar(this, 196, 64, 60, 16, Position.Left);
+ new ControlErrorState(this, 218.0F, 86.0F);
+
+ x += 142;
+
+ CraftGUIUtil.verticalGrid((w() - 72.0F) / 2.0F, 32.0F, TextJustification.MiddleCenter, 4.0F, new IWidget[] { new ControlSlotArray(this, 0, 0, 4, 1).create(Inoculator.slotReserve), new ControlIconDisplay(this, 0.0F, 0.0F, GUIIcon.ArrowDown.getIcon()), new ControlSlot(this, 0.0F, 0.0F).assign(9), new ControlIconDisplay(this, 0.0F, 0.0F, GUIIcon.ArrowDown.getIcon()), new ControlSlotArray(this, 0, 0, 4, 1).create(Inoculator.slotFinished) });
+
+
+
+
+
+
+ new ControlPlayerInventory(this);
+ }
+
+ public String getTitle()
+ {
+ return "Inoculator";
+ }
+
+ protected AbstractMod getMod()
+ {
+ return Genetics.instance;
+ }
+
+ protected String getName()
+ {
+ return "Inoculator";
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java b/src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java
new file mode 100644
index 0000000000..9b6a2809d9
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/ContainerCraftGUI.java
@@ -0,0 +1,549 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.BinnieCore;
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.network.INetwork.RecieveGuiNBT;
+import binnie.core.machines.network.INetwork.SendGuiNBT;
+import binnie.core.machines.power.ErrorState;
+import binnie.core.machines.power.IErrorStateSource;
+import binnie.core.machines.power.IPoweredMachine;
+import binnie.core.machines.power.IProcess;
+import binnie.core.machines.power.ITankMachine;
+import binnie.core.machines.power.PowerInfo;
+import binnie.core.machines.power.ProcessInfo;
+import binnie.core.machines.power.TankInfo;
+import binnie.core.machines.transfer.TransferRequest;
+import binnie.core.machines.transfer.TransferRequest.TransferSlot;
+import binnie.core.network.packet.MessageContainerUpdate;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.EnumHighlighting;
+import com.mojang.authlib.GameProfile;
+import cpw.mods.fml.relauncher.Side;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class ContainerCraftGUI
+ extends Container
+{
+ private Window window;
+
+ public ContainerCraftGUI(Window window)
+ {
+ this.window = window;
+ IMachine machine = Machine.getMachine(window.getInventory());
+ if (getSide() == Side.SERVER)
+ {
+ this.inventoryItemStacks = new ListMap();
+ this.inventorySlots = new ListMap();
+ if (machine != null)
+ {
+ GameProfile user = machine.getOwner();
+ if (user != null)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setString("username", user.getName());
+ sendNBTToClient("username", nbt);
+ }
+ }
+ }
+ }
+
+ protected Slot addSlotToContainer(Slot slot)
+ {
+ return super.addSlotToContainer(slot);
+ }
+
+ private Side getSide()
+ {
+ return this.window.isServer() ? Side.SERVER : Side.CLIENT;
+ }
+
+ public Slot getSlot(int par1)
+ {
+ if ((par1 < 0) || (par1 >= this.inventorySlots.size())) {
+ return null;
+ }
+ return (Slot)this.inventorySlots.get(par1);
+ }
+
+ public void putStackInSlot(int par1, ItemStack par2ItemStack)
+ {
+ if (getSlot(par1) != null) {
+ getSlot(par1).putStack(par2ItemStack);
+ }
+ }
+
+ public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack)
+ {
+ for (int i = 0; i < par1ArrayOfItemStack.length; i++) {
+ if (getSlot(i) != null) {
+ getSlot(i).putStack(par1ArrayOfItemStack[i]);
+ }
+ }
+ }
+
+ public void onContainerClosed(EntityPlayer par1EntityPlayer)
+ {
+ super.onContainerClosed(par1EntityPlayer);
+
+ WindowInventory inventory = this.window.getWindowInventory();
+ for (int i = 0; i < inventory.getSizeInventory(); i++) {
+ if (inventory.dispenseOnClose(i))
+ {
+ ItemStack stack = inventory.getStackInSlot(i);
+ if (stack != null)
+ {
+ stack = new TransferRequest(stack, par1EntityPlayer.inventory).transfer(true);
+ if (stack != null) {
+ par1EntityPlayer.dropPlayerItemWithRandomChoice(stack, false);
+ }
+ }
+ }
+ }
+ }
+
+ public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player)
+ {
+ Slot slot = getSlot(slotNum);
+ if (((slot instanceof CustomSlot)) && (((CustomSlot)slot).handleClick()))
+ {
+ ((CustomSlot)slot).onSlotClick(this, mouseButton, modifier, player);
+ return player.inventory.getItemStack();
+ }
+ ItemStack stack = super.slotClick(slotNum, mouseButton, modifier, player);
+ return stack;
+ }
+
+ public void sendNBTToClient(String key, NBTTagCompound nbt)
+ {
+ this.syncedNBT.put(key, nbt);
+ }
+
+ public boolean canInteractWith(EntityPlayer var1)
+ {
+ return true;
+ }
+
+ public final ItemStack transferStackInSlot(EntityPlayer player, int slotID)
+ {
+ return shiftClick(player, slotID);
+ }
+
+ private ItemStack shiftClick(EntityPlayer player, int slotnumber)
+ {
+ TransferRequest request = getShiftClickRequest(player, slotnumber);
+ if (request == null) {
+ return null;
+ }
+ ItemStack itemstack = request.transfer(true);
+ Slot shiftClickedSlot = (Slot)this.inventorySlots.get(slotnumber);
+
+ shiftClickedSlot.putStack(itemstack);
+ shiftClickedSlot.onSlotChanged();
+
+ return null;
+ }
+
+ private TransferRequest getShiftClickRequest(EntityPlayer player, int slotnumber)
+ {
+ if (slotnumber < 0) {
+ return null;
+ }
+ Slot shiftClickedSlot = (Slot)this.inventorySlots.get(slotnumber);
+
+ ItemStack itemstack = null;
+ if (shiftClickedSlot.getHasStack()) {
+ itemstack = shiftClickedSlot.getStack().copy();
+ }
+ IInventory playerInventory = player.inventory;
+ IInventory containerInventory = this.window.getInventory();
+ IInventory windowInventory = this.window.getWindowInventory();
+
+ IInventory fromPlayer = containerInventory == null ? windowInventory : containerInventory;
+
+ int[] target = new int[36];
+ for (int i = 0; i < 36; i++) {
+ target[i] = i;
+ }
+ TransferRequest request;
+ TransferRequest request;
+ if (shiftClickedSlot.inventory == playerInventory) {
+ request = new TransferRequest(itemstack, fromPlayer).setOrigin(shiftClickedSlot.inventory);
+ } else {
+ request = new TransferRequest(itemstack, playerInventory).setOrigin(shiftClickedSlot.inventory).setTargetSlots(target);
+ }
+ if ((this.window instanceof IWindowAffectsShiftClick)) {
+ ((IWindowAffectsShiftClick)this.window).alterRequest(request);
+ }
+ return request;
+ }
+
+ public final ItemStack tankClick(EntityPlayer player, int slotID)
+ {
+ if (player.inventory.getItemStack() == null) {
+ return null;
+ }
+ ItemStack heldItem = player.inventory.getItemStack().copy();
+
+ heldItem = new TransferRequest(heldItem, this.window.getInventory()).setOrigin(player.inventory).setTargetSlots(new int[0]).setTargetTanks(new int[] { slotID }).transfer(true);
+
+
+ player.inventory.setItemStack(heldItem);
+ if ((player instanceof EntityPlayerMP)) {
+ ((EntityPlayerMP)player).updateHeldItem();
+ }
+ return heldItem;
+ }
+
+ public boolean handleNBT(Side side, EntityPlayer player, String name, NBTTagCompound action)
+ {
+ if (side == Side.SERVER)
+ {
+ if (name.equals("tank-click")) {
+ tankClick(player, action.getByte("id"));
+ }
+ if (name.equals("slot-reg"))
+ {
+ int type = action.getByte("t");
+ int index = action.getShort("i");
+ int slotNumber = action.getShort("n");
+ getOrCreateSlot(InventoryType.values()[(type % 4)], index, slotNumber);
+ }
+ }
+ if (name.contains("tank-update")) {
+ onTankUpdate(action);
+ } else if (name.equals("power-update")) {
+ onPowerUpdate(action);
+ } else if (name.equals("process-update")) {
+ onProcessUpdate(action);
+ } else if (name.equals("error-update")) {
+ onErrorUpdate(action);
+ } else if (name.equals("mouse-over-slot")) {
+ onMouseOverSlot(player, action);
+ } else if (name.equals("shift-click-info")) {
+ onRecieveShiftClickHighlights(player, action);
+ }
+ return false;
+ }
+
+ private Map<String, NBTTagCompound> syncedNBT = new HashMap();
+ private Map<String, NBTTagCompound> sentNBT = new HashMap();
+
+ public void detectAndSendChanges()
+ {
+ super.detectAndSendChanges();
+
+
+
+
+ ITankMachine tanks = (ITankMachine)Machine.getInterface(ITankMachine.class, this.window.getInventory());
+ IPoweredMachine powered = (IPoweredMachine)Machine.getInterface(IPoweredMachine.class, this.window.getInventory());
+ IErrorStateSource error = (IErrorStateSource)Machine.getInterface(IErrorStateSource.class, this.window.getInventory());
+ IProcess process = (IProcess)Machine.getInterface(IProcess.class, this.window.getInventory());
+ if ((tanks != null) && (this.window.isServer())) {
+ for (int i = 0; i < tanks.getTankInfos().length; i++)
+ {
+ TankInfo tank = tanks.getTankInfos()[i];
+ if (!getTankInfo(i).equals(tank))
+ {
+ this.syncedNBT.put("tank-update-" + i, createTankNBT(i, tank));
+
+ this.syncedTanks.put(Integer.valueOf(i), tank);
+ }
+ }
+ }
+ if ((powered != null) && (this.window.isServer())) {
+ this.syncedNBT.put("power-update", createPowerNBT(powered.getPowerInfo()));
+ }
+ if ((process != null) && (this.window.isServer())) {
+ this.syncedNBT.put("process-update", createProcessNBT(process.getInfo()));
+ }
+ if ((error != null) && (this.window.isServer())) {
+ this.syncedNBT.put("error-update", createErrorNBT(error));
+ }
+ INetwork.SendGuiNBT machineSync = (INetwork.SendGuiNBT)Machine.getInterface(INetwork.SendGuiNBT.class, this.window.getInventory());
+ if (machineSync != null) {
+ machineSync.sendGuiNBT(this.syncedNBT);
+ }
+ Map<String, NBTTagCompound> sentThisTime = new HashMap();
+ for (Map.Entry<String, NBTTagCompound> nbt : this.syncedNBT.entrySet())
+ {
+ ((NBTTagCompound)nbt.getValue()).setString("type", (String)nbt.getKey());
+
+
+
+
+
+
+ boolean shouldSend = true;
+ NBTTagCompound lastSent = (NBTTagCompound)this.sentNBT.get(nbt.getKey());
+ if (lastSent != null) {
+ shouldSend = !lastSent.equals(nbt.getValue());
+ }
+ if (shouldSend)
+ {
+ for (int j = 0; j < this.crafters.size(); j++) {
+ if ((this.crafters.get(j) instanceof EntityPlayerMP))
+ {
+ EntityPlayerMP player = (EntityPlayerMP)this.crafters.get(j);
+ BinnieCore.proxy.sendToPlayer(new MessageContainerUpdate((NBTTagCompound)nbt.getValue()), player);
+ }
+ }
+ sentThisTime.put(nbt.getKey(), nbt.getValue());
+ }
+ }
+ this.sentNBT.putAll(sentThisTime);
+
+ this.syncedNBT.clear();
+ }
+
+ private NBTTagCompound createErrorNBT(IErrorStateSource error)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ ErrorState state = null;
+ if (error.canWork() != null)
+ {
+ nbt.setByte("type", (byte)0);
+ state = error.canWork();
+ }
+ else if (error.canProgress() != null)
+ {
+ nbt.setByte("type", (byte)1);
+ state = error.canProgress();
+ }
+ if (state != null) {
+ state.writeToNBT(nbt);
+ }
+ return nbt;
+ }
+
+ public NBTTagCompound createPowerNBT(PowerInfo powerInfo)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ powerInfo.writeToNBT(nbt);
+ return nbt;
+ }
+
+ public NBTTagCompound createProcessNBT(ProcessInfo powerInfo)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ powerInfo.writeToNBT(nbt);
+ return nbt;
+ }
+
+ public NBTTagCompound createTankNBT(int tank, TankInfo tankInfo)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ tankInfo.writeToNBT(nbt);
+ nbt.setByte("tank", (byte)tank);
+ return nbt;
+ }
+
+ private Map<Integer, TankInfo> syncedTanks = new HashMap();
+ private PowerInfo syncedPower = new PowerInfo();
+ private ProcessInfo syncedProcess = new ProcessInfo();
+ private int errorType = 0;
+ private ErrorState error = null;
+
+ public void onTankUpdate(NBTTagCompound nbt)
+ {
+ int tankID = nbt.getByte("tank");
+ TankInfo tank = new TankInfo();
+ tank.readFromNBT(nbt);
+ this.syncedTanks.put(Integer.valueOf(tankID), tank);
+ }
+
+ public void onProcessUpdate(NBTTagCompound nbt)
+ {
+ this.syncedProcess = new ProcessInfo();
+ this.syncedProcess.readFromNBT(nbt);
+ }
+
+ public void onPowerUpdate(NBTTagCompound nbt)
+ {
+ this.syncedPower = new PowerInfo();
+ this.syncedPower.readFromNBT(nbt);
+ }
+
+ public PowerInfo getPowerInfo()
+ {
+ return this.syncedPower;
+ }
+
+ public ProcessInfo getProcessInfo()
+ {
+ return this.syncedProcess;
+ }
+
+ public TankInfo getTankInfo(int tank)
+ {
+ return this.syncedTanks.containsKey(Integer.valueOf(tank)) ? (TankInfo)this.syncedTanks.get(Integer.valueOf(tank)) : new TankInfo();
+ }
+
+ public void onErrorUpdate(NBTTagCompound nbt)
+ {
+ this.errorType = nbt.getByte("type");
+ if (nbt.hasKey("name"))
+ {
+ this.error = new ErrorState("", "");
+ this.error.readFromNBT(nbt);
+ }
+ else
+ {
+ this.error = null;
+ }
+ }
+
+ public ErrorState getErrorState()
+ {
+ return this.error;
+ }
+
+ public int getErrorType()
+ {
+ return this.errorType;
+ }
+
+ public CustomSlot[] getCustomSlots()
+ {
+ List<CustomSlot> slots = new ArrayList();
+ for (Object object : this.inventorySlots) {
+ if ((object instanceof CustomSlot)) {
+ slots.add((CustomSlot)object);
+ }
+ }
+ return (CustomSlot[])slots.toArray(new CustomSlot[0]);
+ }
+
+ private int mousedOverSlotNumber = -1;
+
+ public void setMouseOverSlot(Slot slot)
+ {
+ if (slot.slotNumber != this.mousedOverSlotNumber)
+ {
+ this.mousedOverSlotNumber = slot.slotNumber;
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.ShiftClick)).clear();
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setShort("slot", (short)slot.slotNumber);
+ this.window.sendClientAction("mouse-over-slot", nbt);
+ }
+ }
+
+ private void onMouseOverSlot(EntityPlayer player, NBTTagCompound data)
+ {
+ int slotnumber = data.getShort("slot");
+ TransferRequest request = getShiftClickRequest(player, slotnumber);
+ if (request == null) {
+ return;
+ }
+ request.transfer(false);
+ NBTTagCompound nbt = new NBTTagCompound();
+
+ List<Integer> slots = new ArrayList();
+ for (TransferRequest.TransferSlot tslot : request.getInsertedSlots())
+ {
+ Slot slot = getSlot(tslot.inventory, tslot.id);
+ if (slot != null) {
+ slots.add(Integer.valueOf(slot.slotNumber));
+ }
+ }
+ int[] array = new int[slots.size()];
+ for (int i = 0; i < slots.size(); i++) {
+ array[i] = ((Integer)slots.get(i)).intValue();
+ }
+ nbt.setIntArray("slots", array);
+ nbt.setShort("origin", (short)slotnumber);
+
+ this.syncedNBT.put("shift-click-info", nbt);
+ }
+
+ private void onRecieveShiftClickHighlights(EntityPlayer player, NBTTagCompound data)
+ {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.ShiftClick)).clear();
+ for (int slotnumber : data.getIntArray("slots")) {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.ShiftClick)).add(Integer.valueOf(slotnumber));
+ }
+ }
+
+ private CustomSlot getSlot(IInventory inventory, int id)
+ {
+ for (Object o : this.inventorySlots)
+ {
+ CustomSlot slot = (CustomSlot)o;
+ if ((slot.inventory == inventory) && (slot.getSlotIndex() == id)) {
+ return slot;
+ }
+ }
+ return null;
+ }
+
+ public void recieveNBT(Side side, EntityPlayer player, NBTTagCompound action)
+ {
+ String name = action.getString("type");
+ if (handleNBT(side, player, name, action)) {
+ return;
+ }
+ this.window.recieveGuiNBT(getSide(), player, name, action);
+ INetwork.RecieveGuiNBT machine = (INetwork.RecieveGuiNBT)Machine.getInterface(INetwork.RecieveGuiNBT.class, this.window.getInventory());
+ if (machine != null) {
+ machine.recieveGuiNBT(getSide(), player, name, action);
+ }
+ }
+
+ public Slot getOrCreateSlot(InventoryType type, int index)
+ {
+ IInventory inventory = getInventory(type);
+ Slot slot = getSlot(inventory, index);
+ if (slot == null)
+ {
+ slot = new CustomSlot(inventory, index);
+ addSlotToContainer(slot);
+ }
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setByte("t", (byte)type.ordinal());
+ nbt.setShort("i", (short)index);
+ nbt.setShort("n", (short)slot.slotNumber);
+ this.window.sendClientAction("slot-reg", nbt);
+ return slot;
+ }
+
+ protected IInventory getInventory(InventoryType type)
+ {
+ if (type == InventoryType.Machine) {
+ return this.window.getInventory();
+ }
+ if (type == InventoryType.Player) {
+ return this.window.getPlayer().inventory;
+ }
+ if (type == InventoryType.Window) {
+ return this.window.getWindowInventory();
+ }
+ return null;
+ }
+
+ private Slot getOrCreateSlot(InventoryType type, int index, int slotNumber)
+ {
+ IInventory inventory = getInventory(type);
+ if (this.inventorySlots.get(slotNumber) != null) {
+ return null;
+ }
+ Slot slot = new CustomSlot(inventory, index);
+ slot.slotNumber = slotNumber;
+ this.inventorySlots.add(slotNumber, slot);
+ this.inventoryItemStacks.add(slotNumber, (Object)null);
+ return slot;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/CustomSlot.java b/src/Java/binnie/craftgui/minecraft/CustomSlot.java
new file mode 100644
index 0000000000..ae45ffb3fd
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/CustomSlot.java
@@ -0,0 +1,54 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.machines.Machine;
+import binnie.core.machines.inventory.IInventorySlots;
+import binnie.core.machines.inventory.InventorySlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class CustomSlot
+ extends Slot
+{
+ public boolean isItemValid(ItemStack par1ItemStack)
+ {
+ return this.inventory.isItemValidForSlot(getSlotIndex(), par1ItemStack);
+ }
+
+ public CustomSlot(IInventory inventory, int index)
+ {
+ super(inventory, index, 0, 0);
+ }
+
+ public InventorySlot getInventorySlot()
+ {
+ IInventorySlots slots = (IInventorySlots)Machine.getInterface(IInventorySlots.class, this.inventory);
+ if (slots != null) {
+ return slots.getSlot(getSlotIndex());
+ }
+ return null;
+ }
+
+ public boolean handleClick()
+ {
+ InventorySlot slot = getInventorySlot();
+ return (slot != null) && (slot.isRecipe());
+ }
+
+ public void onSlotClick(ContainerCraftGUI container, int mouseButton, int modifier, EntityPlayer player)
+ {
+ ItemStack stack = player.inventory.getItemStack();
+ if ((stack == null) || (mouseButton == 2))
+ {
+ putStack(null);
+ }
+ else
+ {
+ stack = stack.copy();
+ stack.stackSize = 1;
+ putStack(stack);
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/Dialog.java b/src/Java/binnie/craftgui/minecraft/Dialog.java
new file mode 100644
index 0000000000..efd67dec25
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/Dialog.java
@@ -0,0 +1,53 @@
+package binnie.craftgui.minecraft;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public abstract class Dialog
+ extends Control
+{
+ public Dialog(IWidget parent, float w, float h)
+ {
+ super(parent, (parent.w() - w) / 2.0F, (parent.h() - h) / 2.0F, w, h);
+ addAttribute(Attribute.MouseOver);
+ addAttribute(Attribute.AlwaysOnTop);
+ addAttribute(Attribute.BlockTooltip);
+ initialise();
+ addEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ if (!Dialog.this.getArea().contains(Dialog.this.getRelativeMousePosition()))
+ {
+ Dialog.this.onClose();
+ Dialog.this.getParent().deleteChild(Dialog.this);
+ }
+ }
+ }.setOrigin(EventHandler.Origin.Any, this));
+ }
+
+ public abstract void initialise();
+
+ public abstract void onClose();
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.gradientRect(getArea().outset(400), -1442840576, -1442840576);
+ CraftGUI.Render.texture(CraftGUITexture.Window, getArea());
+ CraftGUI.Render.texture(CraftGUITexture.TabOutline, getArea().inset(4));
+ }
+
+ public boolean isMouseOverWidget(IPoint relativeMouse)
+ {
+ return true;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/EnumColor.java b/src/Java/binnie/craftgui/minecraft/EnumColor.java
new file mode 100644
index 0000000000..e778cf31c8
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/EnumColor.java
@@ -0,0 +1,32 @@
+package binnie.craftgui.minecraft;
+
+public enum EnumColor
+{
+ Black("Black", 0, '0'), DarkBlue("Dark Blue", 170, '1'), DarkGreen("Dark Green", 43520, '2'), DarkAqua("Dark Aqua", 43690, '3'), DarkRed("Dark Red", 11141120, '4'), Purple("Purple", 11141290, '5'), Gold("Gold", 16755200, '6'), Grey("Grey", 11184810, '7'), DarkGrey("Dark Grey", 5592405, '8'), Blue("Blue", 5592575, '9'), Green("Green", 5635925, 'a'), Aqua("Aqua", 5636095, 'b'), Red("Red", 16733525, 'c'), Pink("Pink", 16733695, 'd'), Yellow("Yellow", 16777045, 'e'), White("White", 16777215, 'f');
+
+ int colour;
+ String name;
+ char code;
+
+ private EnumColor(String name, int colour, char code)
+ {
+ this.name = name;
+ this.colour = colour;
+ this.code = code;
+ }
+
+ public int getColour()
+ {
+ return this.colour;
+ }
+
+ public String getCode()
+ {
+ return "§" + this.code;
+ }
+
+ public String toString()
+ {
+ return this.name;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/GUIIcon.java b/src/Java/binnie/craftgui/minecraft/GUIIcon.java
new file mode 100644
index 0000000000..96338b2551
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/GUIIcon.java
@@ -0,0 +1,30 @@
+package binnie.craftgui.minecraft;
+
+import binnie.Binnie;
+import binnie.core.BinnieCore;
+import binnie.core.resource.BinnieIcon;
+import binnie.core.resource.ManagerResource;
+import net.minecraft.util.IIcon;
+
+public enum GUIIcon
+{
+ ArrowUp("arrow-up"), ArrowDown("arrow-down"), ArrowLeft("arrow-left"), ArrowRight("arrow-right"), ArrowUpLeft("arrow-upleft"), ArrowUpRight("arrow-upright"), ArrowRightUp("arrow-rightup"), ArrowRightDown("arrow-rightdown"), ArrowDownRight("arrow-downright"), ArrowDownLeft("arrow-downleft"), ArrowLeftDown("arrow-leftdown"), ArrowLeftUp("arrow-leftup");
+
+ String path;
+ BinnieIcon icon;
+
+ private GUIIcon(String path)
+ {
+ this.path = path;
+ }
+
+ public void register()
+ {
+ this.icon = Binnie.Resource.getItemIcon(BinnieCore.instance, "gui/" + this.path);
+ }
+
+ public IIcon getIcon()
+ {
+ return this.icon.getIcon();
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/GuiCraftGUI.java b/src/Java/binnie/craftgui/minecraft/GuiCraftGUI.java
new file mode 100644
index 0000000000..bfd4a5f876
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/GuiCraftGUI.java
@@ -0,0 +1,605 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.BinnieCore;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IBorder;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventKey.Down;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Up;
+import binnie.craftgui.events.EventMouse.Wheel;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityClientPlayerMP;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.RenderHelper;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.client.settings.GameSettings;
+import net.minecraft.client.settings.KeyBinding;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.JsonToNBT;
+import net.minecraft.nbt.NBTException;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+
+@SideOnly(Side.CLIENT)
+public class GuiCraftGUI
+ extends GuiContainer
+{
+ IPoint mousePos = new IPoint(0.0F, 0.0F);
+ private Window window;
+ private ItemStack draggedItem;
+
+ public void updateScreen()
+ {
+ this.window.updateClient();
+ }
+
+ public Minecraft getMinecraft()
+ {
+ return this.mc;
+ }
+
+ public GuiCraftGUI(Window window)
+ {
+ super(window.getContainer());
+ this.window = window;
+ resize(window.getSize());
+ }
+
+ protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {}
+
+ public void initGui()
+ {
+ super.initGui();
+ this.mc.thePlayer.openContainer = this.inventorySlots;
+ this.guiLeft = ((this.width - this.xSize) / 2);
+ this.guiTop = ((this.height - this.ySize) / 2);
+ this.window.setSize(new IPoint(this.xSize, this.ySize));
+ this.window.setPosition(new IPoint(this.guiLeft, this.guiTop));
+ this.window.initGui();
+ }
+
+ public ItemStack getDraggedItem()
+ {
+ return this.draggedItem;
+ }
+
+ public void drawScreen(int mouseX, int mouseY, float par3)
+ {
+ this.window.setMousePosition(mouseX - (int)this.window.getPosition().x(), mouseY - (int)this.window.getPosition().y());
+
+
+ drawDefaultBackground();
+
+
+ GL11.glDisable(32826);
+ RenderHelper.disableStandardItemLighting();
+ GL11.glDisable(2896);
+ GL11.glDisable(2929);
+
+ this.zLevel = 10.0F;
+ itemRender.zLevel = this.zLevel;
+
+ this.window.render();
+
+
+ RenderHelper.enableGUIStandardItemLighting();
+ GL11.glPushMatrix();
+ GL11.glEnable(32826);
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
+
+
+
+
+
+ InventoryPlayer playerInventory = this.mc.thePlayer.inventory;
+ this.draggedItem = playerInventory.getItemStack();
+ if (this.draggedItem != null)
+ {
+ renderItem(new IPoint(mouseX - 8, mouseY - 8), this.draggedItem, 200, false);
+ renderItem(new IPoint(mouseX - 8, mouseY - 8), this.draggedItem, 200, false);
+ }
+ GL11.glDisable(32826);
+ GL11.glPopMatrix();
+
+
+
+
+
+ GL11.glDisable(2896);
+ GL11.glDisable(2929);
+
+
+ MinecraftTooltip tooltip = new MinecraftTooltip();
+ if (isHelpMode())
+ {
+ tooltip.setType(Tooltip.Type.Help);
+ this.window.getHelpTooltip(tooltip);
+ }
+ else
+ {
+ tooltip.setType(Tooltip.Type.Standard);
+ this.window.getTooltip(tooltip);
+ }
+ if (tooltip.exists()) {
+ renderTooltip(new IPoint(mouseX, mouseY), tooltip);
+ }
+ this.zLevel = 0.0F;
+
+ GL11.glEnable(2896);
+ GL11.glEnable(2929);
+ }
+
+ public void renderTooltip(IPoint mousePosition, MinecraftTooltip tooltip)
+ {
+ int mouseX = (int)mousePosition.x();
+ int mouseY = (int)mousePosition.y();
+ FontRenderer font = getFontRenderer();
+ GL11.glDisable(32826);
+ RenderHelper.disableStandardItemLighting();
+ GL11.glDisable(2896);
+ GL11.glDisable(2929);
+ int k = 0;
+
+ List<String> strings = new ArrayList();
+ for (String string : tooltip.getList()) {
+ if (string != null) {
+ if (!string.contains("~~~")) {
+ strings.addAll(font.listFormattedStringToWidth(string, tooltip.maxWidth));
+ } else {
+ strings.add(string);
+ }
+ }
+ }
+ Iterator iterator = strings.iterator();
+ while (iterator.hasNext())
+ {
+ String s = (String)iterator.next();
+ int l = font.getStringWidth(s);
+ if (s.contains("~~~")) {
+ l = 12 + font.getStringWidth(s.replaceAll("~~~(.*?)~~~", ""));
+ }
+ if (l > k) {
+ k = l;
+ }
+ }
+ int i1 = mouseX + 12;
+ int j1 = mouseY - 12;
+ int k1 = 8;
+ if (strings.size() > 1) {
+ k1 += 2 + (strings.size() - 1) * 10;
+ }
+ if (i1 + k > this.width) {
+ i1 -= 28 + k;
+ }
+ if (j1 + k1 + 6 > this.height) {
+ j1 = this.height - k1 - 6;
+ }
+ this.zLevel = 300.0F;
+ itemRender.zLevel = 300.0F;
+ int l1 = -267386864;
+ int i2 = 1342177280 + MinecraftTooltip.getOutline(tooltip.getType());
+ int j2 = i2;
+ drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l1, l1);
+ drawGradientRect(i1 - 3, j1 + k1 + 3, i1 + k + 3, j1 + k1 + 4, l1, l1);
+ drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k1 + 3, l1, l1);
+ drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k1 + 3, l1, l1);
+ drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k1 + 3, l1, l1);
+
+ drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2);
+ drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2);
+ drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
+ drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2);
+ for (int k2 = 0; k2 < strings.size(); k2++)
+ {
+ String s1 = (String)strings.get(k2);
+ if (k2 == 0) {
+ s1 = MinecraftTooltip.getTitle(tooltip.getType()) + s1;
+ } else {
+ s1 = MinecraftTooltip.getBody(tooltip.getType()) + s1;
+ }
+ if (s1.contains("~~~"))
+ {
+ String split = s1.split("~~~")[1];
+ try
+ {
+ NBTTagCompound nbt = (NBTTagCompound)JsonToNBT.func_150315_a(split);
+ ItemStack stack = ItemStack.loadItemStackFromNBT(nbt);
+ GL11.glPushMatrix();
+ GL11.glTranslatef(i1, j1 - 1.5F, 0.0F);
+ GL11.glScalef(0.6F, 0.6F, 1.0F);
+ renderItem(new IPoint(0.0F, 0.0F), stack, false);
+ GL11.glPopMatrix();
+ }
+ catch (NBTException e)
+ {
+ e.printStackTrace();
+ }
+ s1 = " " + s1.replaceAll("~~~(.*?)~~~", "");
+ }
+ font.drawStringWithShadow(s1, i1, j1, -1);
+ if (k2 == 0) {
+ j1 += 2;
+ }
+ j1 += 10;
+ }
+ this.zLevel = 0.0F;
+ itemRender.zLevel = 0.0F;
+ GL11.glEnable(2896);
+ GL11.glEnable(2929);
+ RenderHelper.enableStandardItemLighting();
+ GL11.glEnable(32826);
+ }
+
+ protected void mouseClicked(int x, int y, int button)
+ {
+ IWidget origin = this.window;
+ if (this.window.getMousedOverWidget() != null) {
+ origin = this.window.getMousedOverWidget();
+ }
+ this.window.callEvent(new EventMouse.Down(origin, x, y, button));
+ }
+
+ public boolean isShiftDown()
+ {
+ return Keyboard.isKeyDown(this.mc.gameSettings.keyBindSneak.getKeyCode());
+ }
+
+ protected void keyTyped(char c, int key)
+ {
+ if ((key == 1) || ((key == this.mc.gameSettings.keyBindInventory.getKeyCode()) && (this.window.getFocusedWidget() == null))) {
+ this.mc.thePlayer.closeScreen();
+ }
+ IWidget origin = this.window.getFocusedWidget() == null ? this.window : this.window.getFocusedWidget();
+
+ this.window.callEvent(new EventKey.Down(origin, c, key));
+ }
+
+ protected void mouseMovedOrUp(int x, int y, int button)
+ {
+ IWidget origin = this.window.getMousedOverWidget() == null ? this.window : this.window.getMousedOverWidget();
+ float dy;
+ if (button == -1)
+ {
+ float dx = Mouse.getEventDX() * this.width / this.mc.displayWidth;
+ dy = -(Mouse.getEventDY() * this.height / this.mc.displayHeight);
+ }
+ else
+ {
+ this.window.callEvent(new EventMouse.Up(origin, x, y, button));
+ }
+ }
+
+ public void handleMouseInput()
+ {
+ super.handleMouseInput();
+ int dWheel = Mouse.getDWheel();
+ IWidget origin = this.window.getFocusedWidget() == null ? this.window : this.window.getFocusedWidget();
+ if (dWheel != 0) {
+ this.window.callEvent(new EventMouse.Wheel(this.window, dWheel));
+ }
+ }
+
+ public void onGuiClosed()
+ {
+ this.window.onClose();
+ }
+
+ public void renderTexturedRect(float x, float y, float u, float v, float w, float h)
+ {
+ drawTexturedModalRect((int)x, (int)y, (int)u, (int)v, (int)w, (int)h);
+ }
+
+ public void renderTexture(IPoint position, IArea textureArea)
+ {
+ drawTexturedModalRect((int)position.x(), (int)position.y(), (int)textureArea.pos().x(), (int)textureArea.pos().y(), (int)textureArea.size().x(), (int)textureArea.size().y());
+ }
+
+ private void renderTexturedRect(IArea area, IPoint uv)
+ {
+ renderTexturedRect(area.pos().x(), area.pos().y(), uv.x(), uv.y(), area.size().x(), area.size().y());
+ }
+
+ public void renderTexturePadded(IArea area, IArea texture, IBorder padding)
+ {
+ int borderLeft = (int)padding.l();
+ int borderRight = (int)padding.r();
+ int borderTop = (int)padding.t();
+ int borderBottom = (int)padding.b();
+
+ int posX = (int)area.pos().x();
+ int posY = (int)area.pos().y();
+ int width = (int)area.size().x();
+ int height = (int)area.size().y();
+
+ int textWidth = (int)texture.w();
+ int textHeight = (int)texture.h();
+
+ int u = (int)texture.x();
+ int v = (int)texture.y();
+ if (borderTop + borderBottom > height)
+ {
+ borderTop = height / 2;
+ borderBottom = height / 2;
+ }
+ if (borderLeft + borderRight > width)
+ {
+ borderLeft = width / 2;
+ borderRight = width / 2;
+ }
+ IPoint origin = area.pos();
+
+ drawTexturedModalRect(posX, posY, u, v, borderLeft, borderTop);
+
+
+ drawTexturedModalRect(posX + width - borderRight, posY, u + textWidth - borderRight, v, borderRight, borderTop);
+
+
+ drawTexturedModalRect(posX, posY + height - borderBottom, u, v + textHeight - borderBottom, borderLeft, borderBottom);
+
+
+ drawTexturedModalRect(posX + width - borderRight, posY + height - borderBottom, u + textWidth - borderRight, v + textHeight - borderBottom, borderRight, borderBottom);
+
+
+
+ int currentXPos = borderLeft;
+ while (currentXPos < width - borderRight)
+ {
+ int distanceXRemaining = width - borderRight - currentXPos;
+
+
+ int texturingWidth = textWidth - borderLeft - borderRight;
+ if (texturingWidth > distanceXRemaining) {
+ texturingWidth = distanceXRemaining;
+ }
+ if (texturingWidth <= 0) {
+ break;
+ }
+ drawTexturedModalRect(posX + currentXPos, posY, u + borderLeft, v, texturingWidth, borderTop);
+
+ drawTexturedModalRect(posX + currentXPos, posY + height - borderBottom, u + borderLeft, v + textHeight - borderBottom, texturingWidth, borderBottom);
+
+
+ int currentYPos = borderTop;
+ while (currentYPos < height - borderBottom)
+ {
+ int distanceYRemaining = height - borderBottom - currentYPos;
+
+
+ int texturingHeight = textHeight - borderTop - borderBottom;
+ if (texturingHeight > distanceYRemaining) {
+ texturingHeight = distanceYRemaining;
+ }
+ if (texturingHeight <= 0) {
+ break;
+ }
+ drawTexturedModalRect(posX + currentXPos, posY + currentYPos, u + borderLeft, v + borderTop, texturingWidth, texturingHeight);
+
+ currentYPos += texturingHeight;
+ }
+ currentXPos += texturingWidth;
+ }
+ int currentYPos = borderTop;
+ while (currentYPos < height - borderBottom)
+ {
+ int distanceYRemaining = height - borderBottom - currentYPos;
+
+
+ int texturingHeight = textHeight - borderTop - borderBottom;
+ if (texturingHeight > distanceYRemaining) {
+ texturingHeight = distanceYRemaining;
+ }
+ if (texturingHeight <= 0) {
+ break;
+ }
+ drawTexturedModalRect(posX, posY + currentYPos, u, v + borderTop, borderLeft, texturingHeight);
+
+ drawTexturedModalRect(posX + width - borderRight, posY + currentYPos, u + textWidth - borderRight, v + borderTop, borderRight, texturingHeight);
+ currentYPos += texturingHeight;
+ }
+ }
+
+ public void drawGradientArea(float p_73733_1_, float p_73733_2_, float p_73733_3_, float p_73733_4_, int p_73733_5_, int p_73733_6_)
+ {
+ float f = (p_73733_5_ >> 24 & 0xFF) / 255.0F;
+ float f1 = (p_73733_5_ >> 16 & 0xFF) / 255.0F;
+ float f2 = (p_73733_5_ >> 8 & 0xFF) / 255.0F;
+ float f3 = (p_73733_5_ & 0xFF) / 255.0F;
+ float f4 = (p_73733_6_ >> 24 & 0xFF) / 255.0F;
+ float f5 = (p_73733_6_ >> 16 & 0xFF) / 255.0F;
+ float f6 = (p_73733_6_ >> 8 & 0xFF) / 255.0F;
+ float f7 = (p_73733_6_ & 0xFF) / 255.0F;
+ GL11.glDisable(3553);
+ GL11.glEnable(3042);
+ GL11.glDisable(3008);
+ OpenGlHelper.glBlendFunc(770, 771, 1, 0);
+ GL11.glShadeModel(7425);
+ Tessellator tessellator = Tessellator.instance;
+ tessellator.startDrawingQuads();
+ tessellator.setColorRGBA_F(f1, f2, f3, f);
+ tessellator.addVertex(p_73733_3_, p_73733_2_, this.zLevel);
+ tessellator.addVertex(p_73733_1_, p_73733_2_, this.zLevel);
+ tessellator.setColorRGBA_F(f5, f6, f7, f4);
+ tessellator.addVertex(p_73733_1_, p_73733_4_, this.zLevel);
+ tessellator.addVertex(p_73733_3_, p_73733_4_, this.zLevel);
+ tessellator.draw();
+ GL11.glShadeModel(7424);
+ GL11.glDisable(3042);
+ GL11.glEnable(3008);
+ GL11.glEnable(3553);
+ }
+
+ public void renderItem(IPoint pos, ItemStack item, boolean rotating)
+ {
+ renderItem(pos, item, (int)this.zLevel + 3, rotating);
+ }
+
+ private void renderItem(IPoint pos, ItemStack item, int zLevel, boolean rotating)
+ {
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
+
+ GL11.glPushMatrix();
+
+ RenderHelper.enableGUIStandardItemLighting();
+ GL11.glEnable(32826);
+ GL11.glEnable(2929);
+
+
+
+
+
+
+
+ FontRenderer font = item.getItem().getFontRenderer(item);
+ if (font == null) {
+ font = getFontRenderer();
+ }
+ if (item != null)
+ {
+ BinnieCore.proxy.getMinecraftInstance();float phase = (float)Minecraft.getSystemTime() / 20.0F;
+
+ GL11.glPushMatrix();
+ if (rotating)
+ {
+ GL11.glTranslatef(8.0F, 8.0F, 0.0F);
+ GL11.glRotatef(phase, 0.0F, -0.866F, 0.5F);
+ GL11.glTranslatef(-8.0F, -8.0F, -67.099998F);
+ }
+ itemRender.renderItemAndEffectIntoGUI(font, this.mc.renderEngine, item, (int)pos.x(), (int)pos.y());
+ GL11.glPopMatrix();
+ itemRender.renderItemOverlayIntoGUI(font, this.mc.renderEngine, item, (int)pos.x(), (int)pos.y(), null);
+ }
+ GL11.glClear(256);
+ GL11.glEnable(3042);
+
+ OpenGlHelper.glBlendFunc(770, 771, 1, 0);
+
+
+ RenderHelper.disableStandardItemLighting();
+
+ CraftGUI.Render.colour(-1);
+
+ GL11.glEnable(32826);
+ GL11.glPopMatrix();
+ }
+
+ public void renderIcon(IPoint pos, IIcon icon, ResourceLocation map)
+ {
+ if (icon == null) {
+ return;
+ }
+ GL11.glPushMatrix();
+ GL11.glEnable(32826);
+
+
+ BinnieCore.proxy.bindTexture(map);
+
+
+ itemRender.zLevel = this.zLevel;
+
+ itemRender.renderIcon((int)pos.x(), (int)pos.y(), icon, 16, 16);
+
+
+
+ GL11.glEnable(32826);
+ GL11.glPopMatrix();
+ }
+
+ public boolean isHelpMode()
+ {
+ return Keyboard.isKeyDown(15);
+ }
+
+ public FontRenderer getFontRenderer()
+ {
+ return this.fontRendererObj;
+ }
+
+ public void resize(IPoint size)
+ {
+ this.xSize = ((int)size.x());
+ this.ySize = ((int)size.y());
+ this.guiLeft = ((this.width - this.xSize) / 2);
+ this.guiTop = ((this.height - this.ySize) / 2);
+ this.window.setPosition(new IPoint(this.guiLeft, this.guiTop));
+ }
+
+ public void limitArea(IArea area)
+ {
+ float x = area.pos().x();
+ float y = area.pos().y();
+ float w = area.size().x();
+ float h = area.size().y();
+
+ y = this.height - (y + h);
+ float k = this.xSize;
+ float scaleX = this.width / this.mc.displayWidth;
+ float scaleY = this.height / this.mc.displayHeight;
+
+ x += 0.0F;
+ y += 0.0F;
+ w += 0.0F;
+ h += 0.0F;
+
+
+
+ GL11.glScissor((int)(x / scaleX), (int)(y / scaleY), (int)(w / scaleX), (int)(h / scaleY));
+ }
+
+ public int getZLevel()
+ {
+ return (int)this.zLevel;
+ }
+
+ public void drawRect(float p_73734_0_, float p_73734_1_, float p_73734_2_, float p_73734_3_, int p_73734_4_)
+ {
+ if (p_73734_0_ < p_73734_2_)
+ {
+ float j1 = p_73734_0_;
+ p_73734_0_ = p_73734_2_;
+ p_73734_2_ = j1;
+ }
+ if (p_73734_1_ < p_73734_3_)
+ {
+ float j1 = p_73734_1_;
+ p_73734_1_ = p_73734_3_;
+ p_73734_3_ = j1;
+ }
+ float f3 = (p_73734_4_ >> 24 & 0xFF) / 255.0F;
+ float f = (p_73734_4_ >> 16 & 0xFF) / 255.0F;
+ float f1 = (p_73734_4_ >> 8 & 0xFF) / 255.0F;
+ float f2 = (p_73734_4_ & 0xFF) / 255.0F;
+ Tessellator tessellator = Tessellator.instance;
+ GL11.glEnable(3042);
+ GL11.glDisable(3553);
+ OpenGlHelper.glBlendFunc(770, 771, 1, 0);
+ GL11.glColor4f(f, f1, f2, f3);
+ tessellator.startDrawingQuads();
+ tessellator.addVertex(p_73734_0_, p_73734_3_, 0.0D);
+ tessellator.addVertex(p_73734_2_, p_73734_3_, 0.0D);
+ tessellator.addVertex(p_73734_2_, p_73734_1_, 0.0D);
+ tessellator.addVertex(p_73734_0_, p_73734_1_, 0.0D);
+ tessellator.draw();
+ GL11.glEnable(3553);
+ GL11.glDisable(3042);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/IMachineInformation.java b/src/Java/binnie/craftgui/minecraft/IMachineInformation.java
new file mode 100644
index 0000000000..cd709bbf8a
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/IMachineInformation.java
@@ -0,0 +1,6 @@
+package binnie.craftgui.minecraft;
+
+public abstract interface IMachineInformation
+{
+ public abstract String getInformation();
+}
diff --git a/src/Java/binnie/craftgui/minecraft/IMinecraftTooltip.java b/src/Java/binnie/craftgui/minecraft/IMinecraftTooltip.java
new file mode 100644
index 0000000000..5bdec6e4ae
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/IMinecraftTooltip.java
@@ -0,0 +1,9 @@
+package binnie.craftgui.minecraft;
+
+import binnie.craftgui.core.ITooltip;
+
+public abstract interface IMinecraftTooltip
+ extends ITooltip
+{
+ public abstract void getTooltip(MinecraftTooltip paramMinecraftTooltip);
+}
diff --git a/src/Java/binnie/craftgui/minecraft/IWindowAffectsShiftClick.java b/src/Java/binnie/craftgui/minecraft/IWindowAffectsShiftClick.java
new file mode 100644
index 0000000000..ced88aa028
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/IWindowAffectsShiftClick.java
@@ -0,0 +1,8 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.machines.transfer.TransferRequest;
+
+public abstract interface IWindowAffectsShiftClick
+{
+ public abstract void alterRequest(TransferRequest paramTransferRequest);
+}
diff --git a/src/Java/binnie/craftgui/minecraft/InventoryType.java b/src/Java/binnie/craftgui/minecraft/InventoryType.java
new file mode 100644
index 0000000000..f10a065a99
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/InventoryType.java
@@ -0,0 +1,8 @@
+package binnie.craftgui.minecraft;
+
+public enum InventoryType
+{
+ Player, Machine, Window, Custom;
+
+ private InventoryType() {}
+}
diff --git a/src/Java/binnie/craftgui/minecraft/ListMap.java b/src/Java/binnie/craftgui/minecraft/ListMap.java
new file mode 100644
index 0000000000..7c0fbf37dd
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/ListMap.java
@@ -0,0 +1,149 @@
+package binnie.craftgui.minecraft;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map.Entry;
+import java.util.Set;
+
+class ListMap<T>
+ implements List<T>
+{
+ private LinkedHashMap<Integer, T> map = new LinkedHashMap();
+
+ public int size()
+ {
+ int i = -1;
+ for (Iterator i$ = this.map.keySet().iterator(); i$.hasNext();)
+ {
+ int k = ((Integer)i$.next()).intValue();
+ if (k > i) {
+ i = k;
+ }
+ }
+ return i + 1;
+ }
+
+ public boolean isEmpty()
+ {
+ return this.map.isEmpty();
+ }
+
+ public boolean contains(Object o)
+ {
+ return this.map.containsValue(o);
+ }
+
+ public Iterator<T> iterator()
+ {
+ return this.map.values().iterator();
+ }
+
+ public Object[] toArray()
+ {
+ return this.map.values().toArray();
+ }
+
+ public <P> P[] toArray(P[] a)
+ {
+ return this.map.values().toArray(a);
+ }
+
+ public boolean add(T e)
+ {
+ if (get(size()) == null)
+ {
+ add(size(), e);
+ return true;
+ }
+ return false;
+ }
+
+ public boolean remove(Object o)
+ {
+ return false;
+ }
+
+ public boolean containsAll(Collection<?> c)
+ {
+ return this.map.values().containsAll(c);
+ }
+
+ public boolean addAll(Collection<? extends T> c)
+ {
+ return false;
+ }
+
+ public boolean addAll(int index, Collection<? extends T> c)
+ {
+ return false;
+ }
+
+ public boolean removeAll(Collection<?> c)
+ {
+ return false;
+ }
+
+ public boolean retainAll(Collection<?> c)
+ {
+ return false;
+ }
+
+ public void clear()
+ {
+ this.map.clear();
+ }
+
+ public T get(int index)
+ {
+ return this.map.get(Integer.valueOf(index));
+ }
+
+ public T set(int index, T element)
+ {
+ this.map.put(Integer.valueOf(index), element);
+ return element;
+ }
+
+ public void add(int index, T element)
+ {
+ this.map.put(Integer.valueOf(index), element);
+ }
+
+ public T remove(int index)
+ {
+ return null;
+ }
+
+ public int indexOf(Object o)
+ {
+ for (Map.Entry<Integer, T> entry : this.map.entrySet()) {
+ if (entry.getValue() == o) {
+ return ((Integer)entry.getKey()).intValue();
+ }
+ }
+ return 0;
+ }
+
+ public int lastIndexOf(Object o)
+ {
+ return indexOf(o);
+ }
+
+ public ListIterator<T> listIterator()
+ {
+ return null;
+ }
+
+ public ListIterator<T> listIterator(int index)
+ {
+ return null;
+ }
+
+ public List<T> subList(int fromIndex, int toIndex)
+ {
+ return null;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/MinecraftGUI.java b/src/Java/binnie/craftgui/minecraft/MinecraftGUI.java
new file mode 100644
index 0000000000..a87b4deeb8
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/MinecraftGUI.java
@@ -0,0 +1,14 @@
+package binnie.craftgui.minecraft;
+
+import binnie.craftgui.window.Panel.IPanelType;
+
+public class MinecraftGUI
+{
+ public static enum PanelType
+ implements Panel.IPanelType
+ {
+ Black, Gray, Tinted, Coloured, Outline, TabOutline;
+
+ private PanelType() {}
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/MinecraftTooltip.java b/src/Java/binnie/craftgui/minecraft/MinecraftTooltip.java
new file mode 100644
index 0000000000..4b48e33e6d
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/MinecraftTooltip.java
@@ -0,0 +1,63 @@
+package binnie.craftgui.minecraft;
+
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.ITooltipType;
+import net.minecraft.util.EnumChatFormatting;
+
+public class MinecraftTooltip
+ extends Tooltip
+{
+ public static enum Type
+ implements Tooltip.ITooltipType
+ {
+ Error, Warning;
+
+ private Type() {}
+ }
+
+ public static int getOutline(Tooltip.ITooltipType type)
+ {
+ return TypeColour.valueOf(type.toString()).getOutline();
+ }
+
+ public static String getTitle(Tooltip.ITooltipType type)
+ {
+ return TypeColour.valueOf(type.toString()).getTitle();
+ }
+
+ public static String getBody(Tooltip.ITooltipType type)
+ {
+ return TypeColour.valueOf(type.toString()).getBody();
+ }
+
+ private static enum TypeColour
+ {
+ Standard(5243135, EnumChatFormatting.WHITE, EnumChatFormatting.GRAY), Help(5046016, EnumChatFormatting.GREEN, EnumChatFormatting.DARK_GREEN), Information(49151, EnumChatFormatting.AQUA, EnumChatFormatting.DARK_AQUA), Error(16724224, EnumChatFormatting.RED, EnumChatFormatting.DARK_RED), Warning(16752384, EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD), User(9839667, EnumChatFormatting.RED, EnumChatFormatting.DARK_RED), Power(9006592, EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD);
+
+ int outline;
+ String mainText;
+ String bodyText;
+
+ private TypeColour(int outline, EnumChatFormatting mainText, EnumChatFormatting bodyText)
+ {
+ this.outline = outline;
+ this.mainText = mainText.toString();
+ this.bodyText = bodyText.toString();
+ }
+
+ public int getOutline()
+ {
+ return this.outline;
+ }
+
+ public String getTitle()
+ {
+ return this.mainText;
+ }
+
+ public String getBody()
+ {
+ return this.bodyText;
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/ModuleCraftGUI.java b/src/Java/binnie/craftgui/minecraft/ModuleCraftGUI.java
new file mode 100644
index 0000000000..d2655dc2fc
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/ModuleCraftGUI.java
@@ -0,0 +1,18 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.IInitializable;
+
+public class ModuleCraftGUI
+ implements IInitializable
+{
+ public void preInit() {}
+
+ public void init() {}
+
+ public void postInit()
+ {
+ for (GUIIcon icon : ) {
+ icon.register();
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/Window.java b/src/Java/binnie/craftgui/minecraft/Window.java
new file mode 100644
index 0000000000..e09cf1e376
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/Window.java
@@ -0,0 +1,338 @@
+package binnie.craftgui.minecraft;
+
+import binnie.Binnie;
+import binnie.core.AbstractMod;
+import binnie.core.BinnieCore;
+import binnie.core.machines.Machine;
+import binnie.core.machines.inventory.IInventoryMachine;
+import binnie.core.machines.network.INetwork.RecieveGuiNBT;
+import binnie.core.machines.power.PowerSystem;
+import binnie.core.network.packet.MessageCraftGUI;
+import binnie.core.proxy.BinnieProxy;
+import binnie.core.resource.BinnieResource;
+import binnie.core.resource.ManagerResource;
+import binnie.core.resource.ResourceType;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.ITooltipHelp;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.TopLevelWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventWidget.ChangeSize;
+import binnie.craftgui.events.EventWidget.ChangeSize.Handler;
+import binnie.craftgui.minecraft.control.ControlHelp;
+import binnie.craftgui.minecraft.control.ControlInfo;
+import binnie.craftgui.minecraft.control.ControlPowerSystem;
+import binnie.craftgui.minecraft.control.ControlSlot;
+import binnie.craftgui.minecraft.control.ControlUser;
+import binnie.craftgui.minecraft.control.EnumHighlighting;
+import binnie.craftgui.resource.StyleSheetManager;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import com.mojang.authlib.GameProfile;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.List;
+import java.util.Map;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.world.World;
+
+public abstract class Window
+ extends TopLevelWidget
+ implements INetwork.RecieveGuiNBT
+{
+ private GuiCraftGUI gui;
+ private ContainerCraftGUI container;
+ private WindowInventory windowInventory;
+ private ControlText title;
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ Deque<IWidget> queue = calculateMousedOverWidgets();
+ while (!queue.isEmpty())
+ {
+ IWidget widget = (IWidget)queue.removeFirst();
+ if ((widget.isEnabled()) && (widget.isVisible()) && (widget.calculateIsMouseOver()))
+ {
+ if ((widget instanceof ITooltip))
+ {
+ ((ITooltip)widget).getTooltip(tooltip);
+ if (tooltip.exists()) {
+ return;
+ }
+ }
+ if (widget.hasAttribute(Attribute.BlockTooltip)) {
+ return;
+ }
+ }
+ }
+ }
+
+ public void getHelpTooltip(MinecraftTooltip tooltip)
+ {
+ Deque<IWidget> queue = calculateMousedOverWidgets();
+ while (!queue.isEmpty())
+ {
+ IWidget widget = (IWidget)queue.removeFirst();
+ if ((widget.isEnabled()) && (widget.isVisible()) && (widget.calculateIsMouseOver()))
+ {
+ if ((widget instanceof ITooltipHelp))
+ {
+ ((ITooltipHelp)widget).getHelpTooltip(tooltip);
+ if (tooltip.exists()) {
+ return;
+ }
+ }
+ if (widget.hasAttribute(Attribute.BlockTooltip)) {
+ return;
+ }
+ }
+ }
+ }
+
+ protected abstract AbstractMod getMod();
+
+ protected abstract String getName();
+
+ public BinnieResource getBackgroundTextureFile(int i)
+ {
+ return Binnie.Resource.getPNG(getMod(), ResourceType.GUI, getName() + (i == 1 ? "" : Integer.valueOf(i)));
+ }
+
+ public boolean showHelpButton()
+ {
+ return Machine.getInterface(IInventoryMachine.class, getInventory()) != null;
+ }
+
+ public String showInfoButton()
+ {
+ if (Machine.getInterface(IMachineInformation.class, getInventory()) != null) {
+ return ((IMachineInformation)Machine.getInterface(IMachineInformation.class, getInventory())).getInformation();
+ }
+ return null;
+ }
+
+ public Window(float width, float height, EntityPlayer player, IInventory inventory, Side side)
+ {
+ this.side = side;
+ setInventories(player, inventory);
+ this.container = new ContainerCraftGUI(this);
+ this.windowInventory = new WindowInventory(this);
+ if (side == Side.SERVER) {
+ return;
+ }
+ setSize(new IPoint(width, height));
+ this.gui = new GuiCraftGUI(this);
+ for (EnumHighlighting h : EnumHighlighting.values()) {
+ ControlSlot.highlighting.put(h, new ArrayList());
+ }
+ CraftGUI.Render = new Renderer(this.gui);
+ CraftGUI.Render.stylesheet(StyleSheetManager.getDefault());
+
+ this.titleButtonLeft = -14.0F;
+ if (showHelpButton()) {
+ new ControlHelp(this, this.titleButtonLeft += 22.0F, 8.0F);
+ }
+ if (showInfoButton() != null) {
+ new ControlInfo(this, this.titleButtonLeft += 22.0F, 8.0F, showInfoButton());
+ }
+ Window wind = this;
+
+ addSelfEventHandler(new EventWidget.ChangeSize.Handler()
+ {
+ public void onEvent(EventWidget.ChangeSize event)
+ {
+ if ((Window.this.isClient()) && (Window.this.getGui() != null))
+ {
+ Window.this.getGui().resize(Window.this.getSize());
+ if (Window.this.title != null) {
+ Window.this.title.setSize(new IPoint(Window.this.w(), Window.this.title.h()));
+ }
+ }
+ }
+ });
+ }
+
+ protected float titleButtonLeft = 8.0F;
+ protected float titleButtonRight = 8.0F;
+
+ public void setTitle(String title)
+ {
+ this.title = new ControlTextCentered(this, 12.0F, title);
+ this.title.setColour(4210752);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public final GuiCraftGUI getGui()
+ {
+ return this.gui;
+ }
+
+ public final ContainerCraftGUI getContainer()
+ {
+ return this.container;
+ }
+
+ public final WindowInventory getWindowInventory()
+ {
+ return this.windowInventory;
+ }
+
+ private StandardTexture bgText1 = null;
+ private StandardTexture bgText2 = null;
+ private boolean hasBeenInitialised = false;
+ private EntityPlayer player;
+ private IInventory entityInventory;
+
+ public final void initGui()
+ {
+ if (this.hasBeenInitialised) {
+ return;
+ }
+ this.bgText1 = new StandardTexture(0, 0, 256, 256, getBackgroundTextureFile(1));
+ if (getSize().x() > 256.0F) {
+ this.bgText2 = new StandardTexture(0, 0, 256, 256, getBackgroundTextureFile(2));
+ }
+ if (!BinnieCore.proxy.checkTexture(this.bgText1.getTexture()))
+ {
+ this.bgText1 = null;
+ this.bgText2 = null;
+ }
+ initialiseClient();
+ this.hasBeenInitialised = true;
+ }
+
+ public abstract void initialiseClient();
+
+ public void initialiseServer() {}
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.colour(16777215);
+ if (getBackground1() != null) {
+ CraftGUI.Render.texture(getBackground1(), IPoint.ZERO);
+ }
+ if (getBackground2() != null) {
+ CraftGUI.Render.texture(getBackground2(), new IPoint(256.0F, 0.0F));
+ }
+ CraftGUI.Render.colour(getColour());
+ CraftGUI.Render.texture(CraftGUITexture.Window, getArea());
+ }
+
+ public void onUpdateClient()
+ {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.Help)).clear();
+
+ ControlSlot.shiftClickActive = false;
+ }
+
+ public EntityPlayer getPlayer()
+ {
+ return this.player;
+ }
+
+ public GameProfile getUsername()
+ {
+ return getPlayer().getGameProfile();
+ }
+
+ public ItemStack getHeldItemStack()
+ {
+ if (this.player != null) {
+ return this.player.inventory.getItemStack();
+ }
+ return null;
+ }
+
+ public IInventory getInventory()
+ {
+ return this.entityInventory;
+ }
+
+ public void setInventories(EntityPlayer player2, IInventory inventory)
+ {
+ this.player = player2;
+ this.entityInventory = inventory;
+ }
+
+ public void onClose() {}
+
+ public void setHeldItemStack(ItemStack stack)
+ {
+ if (this.player != null) {
+ this.player.inventory.setItemStack(stack);
+ }
+ }
+
+ private Side side = Side.CLIENT;
+
+ public boolean isServer()
+ {
+ return !isClient();
+ }
+
+ public boolean isClient()
+ {
+ return this.side == Side.CLIENT;
+ }
+
+ public World getWorld()
+ {
+ if (getPlayer() != null) {
+ return getPlayer().worldObj;
+ }
+ return BinnieCore.proxy.getWorld();
+ }
+
+ public void onInventoryUpdate() {}
+
+ public void sendClientAction(String name, NBTTagCompound action)
+ {
+ action.setString("type", name);
+ MessageCraftGUI packet = new MessageCraftGUI(action);
+ BinnieCore.proxy.sendToServer(packet);
+ }
+
+ public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound action)
+ {
+ if ((side == Side.CLIENT) && (name.equals("username")))
+ {
+ new ControlUser(this, w() - (this.titleButtonRight += 16.0F), 8.0F, action.getString("username"));
+ this.titleButtonRight += 6.0F;
+ }
+ if ((side == Side.CLIENT) && (name.equals("power-system")))
+ {
+ new ControlPowerSystem(this, w() - (this.titleButtonRight += 16.0F), 8.0F, PowerSystem.get(action.getByte("system")));
+ this.titleButtonRight += 6.0F;
+ }
+ }
+
+ public void onWindowInventoryChanged() {}
+
+ public Texture getBackground1()
+ {
+ return this.bgText1;
+ }
+
+ public Texture getBackground2()
+ {
+ return this.bgText2;
+ }
+
+ public static <T extends Window> T get(IWidget widget)
+ {
+ return (Window)widget.getSuperParent();
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/WindowInventory.java b/src/Java/binnie/craftgui/minecraft/WindowInventory.java
new file mode 100644
index 0000000000..9c38bf1a9b
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/WindowInventory.java
@@ -0,0 +1,144 @@
+package binnie.craftgui.minecraft;
+
+import binnie.core.machines.inventory.SlotValidator;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+
+public class WindowInventory
+ implements IInventory
+{
+ private Window window;
+
+ public WindowInventory(Window window)
+ {
+ this.window = window;
+ }
+
+ private Map<Integer, ItemStack> inventory = new HashMap();
+ private Map<Integer, SlotValidator> validators = new HashMap();
+ private List<Integer> disabledAutoDispenses = new ArrayList();
+
+ public int getSizeInventory()
+ {
+ if (this.inventory.size() == 0) {
+ return 0;
+ }
+ int max = 0;
+ for (Iterator i$ = this.inventory.keySet().iterator(); i$.hasNext();)
+ {
+ int i = ((Integer)i$.next()).intValue();
+ if (i > max) {
+ max = i;
+ }
+ }
+ return max + 1;
+ }
+
+ public ItemStack getStackInSlot(int var1)
+ {
+ if (this.inventory.containsKey(Integer.valueOf(var1))) {
+ return (ItemStack)this.inventory.get(Integer.valueOf(var1));
+ }
+ return null;
+ }
+
+ public ItemStack decrStackSize(int index, int amount)
+ {
+ if (this.inventory.containsKey(Integer.valueOf(index)))
+ {
+ ItemStack item = (ItemStack)this.inventory.get(Integer.valueOf(index));
+ ItemStack output = item.copy();
+ int available = item.stackSize;
+ if (amount > available) {
+ amount = available;
+ }
+ item.stackSize -= amount;
+ output.stackSize = amount;
+ if (item.stackSize == 0) {
+ setInventorySlotContents(index, null);
+ }
+ return output;
+ }
+ return null;
+ }
+
+ public ItemStack getStackInSlotOnClosing(int var1)
+ {
+ return null;
+ }
+
+ public void setInventorySlotContents(int var1, ItemStack var2)
+ {
+ this.inventory.put(Integer.valueOf(var1), var2);
+ markDirty();
+ }
+
+ public String getInventoryName()
+ {
+ return "window.inventory";
+ }
+
+ public int getInventoryStackLimit()
+ {
+ return 64;
+ }
+
+ public void markDirty()
+ {
+ this.window.onWindowInventoryChanged();
+ }
+
+ public boolean isUseableByPlayer(EntityPlayer var1)
+ {
+ return true;
+ }
+
+ public void openInventory() {}
+
+ public void closeInventory() {}
+
+ public boolean hasCustomInventoryName()
+ {
+ return false;
+ }
+
+ public boolean isItemValidForSlot(int i, ItemStack itemstack)
+ {
+ if (this.validators.containsKey(Integer.valueOf(i))) {
+ return ((SlotValidator)this.validators.get(Integer.valueOf(i))).isValid(itemstack);
+ }
+ return true;
+ }
+
+ public void createSlot(int slot)
+ {
+ this.inventory.put(Integer.valueOf(slot), null);
+ }
+
+ public void setValidator(int slot, SlotValidator validator)
+ {
+ this.validators.put(Integer.valueOf(slot), validator);
+ }
+
+ public void disableAutoDispense(int i)
+ {
+ this.disabledAutoDispenses.add(Integer.valueOf(i));
+ }
+
+ public boolean dispenseOnClose(int i)
+ {
+ return !this.disabledAutoDispenses.contains(Integer.valueOf(i));
+ }
+
+ public SlotValidator getValidator(int i)
+ {
+ return (SlotValidator)this.validators.get(Integer.valueOf(i));
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlEnergyBar.java b/src/Java/binnie/craftgui/minecraft/control/ControlEnergyBar.java
new file mode 100644
index 0000000000..0337b154c1
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlEnergyBar.java
@@ -0,0 +1,161 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.Machine;
+import binnie.core.machines.TileEntityMachine;
+import binnie.core.machines.power.IPoweredMachine;
+import binnie.core.machines.power.IProcess;
+import binnie.core.machines.power.PowerInfo;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.GuiCraftGUI;
+import binnie.craftgui.minecraft.MinecraftTooltip;
+import binnie.craftgui.minecraft.MinecraftTooltip.Type;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import net.minecraft.inventory.IInventory;
+import org.lwjgl.opengl.GL11;
+
+public class ControlEnergyBar
+ extends Control
+ implements ITooltip
+{
+ public static boolean isError;
+ private Position direction;
+
+ public ControlEnergyBar(IWidget parent, int x, int y, int width, int height, Position direction)
+ {
+ super(parent, x, y, width, height);
+ this.direction = direction;
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public IPoweredMachine getClientPower()
+ {
+ IInventory inventory = Window.get(this).getInventory();
+ TileEntityMachine machine = (TileEntityMachine)((inventory instanceof TileEntityMachine) ? inventory : null);
+ if (machine == null) {
+ return null;
+ }
+ IPoweredMachine clientPower = (IPoweredMachine)machine.getMachine().getInterface(IPoweredMachine.class);
+ return clientPower;
+ }
+
+ public float getPercentage()
+ {
+ float percentage = 100.0F * getStoredEnergy() / getMaxEnergy();
+ if (percentage > 100.0F) {
+ percentage = 100.0F;
+ }
+ return percentage;
+ }
+
+ private float getStoredEnergy()
+ {
+ return Window.get(this).getContainer().getPowerInfo().getStoredEnergy();
+ }
+
+ private float getMaxEnergy()
+ {
+ return Window.get(this).getContainer().getPowerInfo().getMaxEnergy();
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.add((int)getPercentage() + "% charged");
+
+ tooltip.add(getStoredEnergy() + "/" + getMaxEnergy() + " RF");
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ tooltip.add("Energy Bar");
+ tooltip.add("Current: " + getStoredEnergy() + " RF (" + (int)getPercentage() + "%)");
+ tooltip.add("Capacity: " + getMaxEnergy() + " RF");
+
+ IProcess process = (IProcess)Machine.getInterface(IProcess.class, Window.get(this).getInventory());
+ if (process != null) {
+ tooltip.add("Usage: " + (int)process.getEnergyPerTick() + " RF");
+ }
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.EnergyBarBack, getArea());
+
+ float percentage = getPercentage() / 100.0F;
+
+ CraftGUI.Render.colour(getColourFromPercentage(percentage));
+
+ IArea area = getArea();
+ switch (1.$SwitchMap$binnie$craftgui$core$geometry$Position[this.direction.ordinal()])
+ {
+ case 1:
+ case 2:
+ float height = area.size().y() * percentage;
+ area.setSize(new IPoint(area.size().x(), height));
+
+ break;
+ case 3:
+ case 4:
+ float width = area.size().x() * percentage;
+ area.setSize(new IPoint(width, area.size().y()));
+ }
+ if ((isMouseOver()) && (Window.get(this).getGui().isHelpMode()))
+ {
+ int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.Help);
+ CraftGUI.Render.gradientRect(getArea().inset(1), c, c);
+ }
+ else if (isError)
+ {
+ int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
+ CraftGUI.Render.gradientRect(getArea().inset(1), c, c);
+ }
+ CraftGUI.Render.texture(CraftGUITexture.EnergyBarGlow, area);
+
+ GL11.glColor3d(1.0D, 1.0D, 1.0D);
+
+ CraftGUI.Render.texture(CraftGUITexture.EnergyBarGlass, getArea());
+ }
+
+ public void onRenderForeground()
+ {
+ if ((isMouseOver()) && (Window.get(this).getGui().isHelpMode()))
+ {
+ IArea area = getArea();
+ CraftGUI.Render.colour(MinecraftTooltip.getOutline(Tooltip.Type.Help));
+ CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
+ }
+ else if (isError)
+ {
+ IArea area = getArea();
+ CraftGUI.Render.colour(MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error));
+ CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
+ }
+ }
+
+ public int getColourFromPercentage(float percentage)
+ {
+ int colour = 16777215;
+ if (percentage > 0.5D)
+ {
+ int r = (int)((1.0D - 2.0D * (percentage - 0.5D)) * 255.0D);
+ colour = (r << 16) + 65280;
+ }
+ else
+ {
+ int g = (int)(255.0F * (2.0F * percentage));
+ colour = 16711680 + (g << 8);
+ }
+ return colour;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlErrorState.java b/src/Java/binnie/craftgui/minecraft/control/ControlErrorState.java
new file mode 100644
index 0000000000..6027371297
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlErrorState.java
@@ -0,0 +1,113 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.power.ErrorState;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.CustomSlot;
+import binnie.craftgui.minecraft.MinecraftTooltip;
+import binnie.craftgui.minecraft.MinecraftTooltip.Type;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import java.util.List;
+import java.util.Map;
+import net.minecraft.entity.player.InventoryPlayer;
+
+public class ControlErrorState
+ extends Control
+ implements ITooltip
+{
+ private ErrorState errorState;
+
+ public void onRenderBackground()
+ {
+ Object texture = CraftGUITexture.StateWarning;
+ if (this.errorState == null) {
+ texture = CraftGUITexture.StateNone;
+ } else if (this.type == 0) {
+ texture = CraftGUITexture.StateError;
+ }
+ CraftGUI.Render.texture(texture, IPoint.ZERO);
+
+ super.onRenderBackground();
+ }
+
+ public ErrorState getError()
+ {
+ return Window.get(this).getContainer().getErrorState();
+ }
+
+ public final void onUpdateClient()
+ {
+ this.errorState = getError();
+ this.type = Window.get(this).getContainer().getErrorType();
+
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.Error)).clear();
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.Warning)).clear();
+ ControlLiquidTank.tankError.clear();
+ ControlEnergyBar.isError = false;
+ if ((!isMouseOver()) || (this.errorState == null)) {
+ return;
+ }
+ ControlEnergyBar.isError = this.errorState.isPowerError();
+ if (this.errorState.isItemError()) {
+ for (int slot : this.errorState.getData())
+ {
+ int id = -1;
+ for (CustomSlot cslot : Window.get(this).getContainer().getCustomSlots()) {
+ if ((!(cslot.inventory instanceof InventoryPlayer)) && (cslot.getSlotIndex() == slot)) {
+ id = cslot.slotNumber;
+ }
+ }
+ if (id >= 0) {
+ if (this.type == 0) {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.Error)).add(Integer.valueOf(id));
+ } else {
+ ((List)ControlSlot.highlighting.get(EnumHighlighting.Warning)).add(Integer.valueOf(id));
+ }
+ }
+ }
+ }
+ if (this.errorState.isTankError()) {
+ for (int slot : this.errorState.getData()) {
+ ControlLiquidTank.tankError.add(Integer.valueOf(slot));
+ }
+ }
+ }
+
+ private int type = 0;
+
+ public ControlErrorState(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public void getTooltip(Tooltip tooltipOrig)
+ {
+ MinecraftTooltip tooltip = (MinecraftTooltip)tooltipOrig;
+ if (this.errorState != null)
+ {
+ if (this.type == 0) {
+ tooltip.setType(MinecraftTooltip.Type.Error);
+ } else {
+ tooltip.setType(MinecraftTooltip.Type.Warning);
+ }
+ tooltip.add(this.errorState.toString());
+ if (this.errorState.getTooltip().length() > 0) {
+ tooltip.add(this.errorState.getTooltip());
+ }
+ }
+ }
+
+ public ErrorState getErrorState()
+ {
+ return this.errorState;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlHelp.java b/src/Java/binnie/craftgui/minecraft/control/ControlHelp.java
new file mode 100644
index 0000000000..d2027747f2
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlHelp.java
@@ -0,0 +1,41 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlHelp
+ extends Control
+ implements ITooltip
+{
+ public ControlHelp(IWidget parent, float x, float y)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.HelpButton, getArea());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.setType(Tooltip.Type.Help);
+ tooltip.add("Help");
+ tooltip.add("To activate help tooltips,");
+ tooltip.add("hold down the tab key and");
+ tooltip.add("mouse over controls.");
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ getTooltip(tooltip);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlIconDisplay.java b/src/Java/binnie/craftgui/minecraft/control/ControlIconDisplay.java
new file mode 100644
index 0000000000..071e8ee888
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlIconDisplay.java
@@ -0,0 +1,25 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import net.minecraft.util.IIcon;
+
+public class ControlIconDisplay
+ extends Control
+{
+ private IIcon icon = null;
+
+ public ControlIconDisplay(IWidget parent, float x, float y, IIcon icon)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ this.icon = icon;
+ }
+
+ public void onRenderForeground()
+ {
+ CraftGUI.Render.iconItem(IPoint.ZERO, this.icon);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlImage.java b/src/Java/binnie/craftgui/minecraft/control/ControlImage.java
new file mode 100644
index 0000000000..0d08626852
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlImage.java
@@ -0,0 +1,25 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.Texture;
+
+public class ControlImage
+ extends Control
+{
+ private Object key = null;
+
+ public ControlImage(IWidget parent, float x, float y, Texture text)
+ {
+ super(parent, x, y, text.w(), text.h());
+ this.key = text;
+ }
+
+ public void onRenderForeground()
+ {
+ CraftGUI.Render.texture(this.key, IPoint.ZERO);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlInfo.java b/src/Java/binnie/craftgui/minecraft/control/ControlInfo.java
new file mode 100644
index 0000000000..8d9c8e95b6
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlInfo.java
@@ -0,0 +1,38 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlInfo
+ extends Control
+ implements ITooltip
+{
+ private String info;
+
+ public ControlInfo(IWidget parent, float x, float y, String info)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+ this.info = info;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.InfoButton, getArea());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.setType(Tooltip.Type.Information);
+ tooltip.add("Info");
+ tooltip.add(this.info);
+ tooltip.setMaxWidth(200);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlItemDisplay.java b/src/Java/binnie/craftgui/minecraft/control/ControlItemDisplay.java
new file mode 100644
index 0000000000..8db438bcc3
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlItemDisplay.java
@@ -0,0 +1,98 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.BinnieCore;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.ITopLevelWidget;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.Window;
+import net.minecraft.client.Minecraft;
+import net.minecraft.item.ItemStack;
+import org.lwjgl.opengl.GL11;
+
+public class ControlItemDisplay
+ extends Control
+ implements ITooltip
+{
+ private ItemStack itemStack = null;
+ public boolean hastooltip = false;
+
+ public void setTooltip()
+ {
+ this.hastooltip = true;
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public ControlItemDisplay(IWidget parent, float x, float y)
+ {
+ this(parent, x, y, 16.0F);
+ }
+
+ public ControlItemDisplay(IWidget parent, float f, float y, ItemStack stack, boolean tooltip)
+ {
+ this(parent, f, y, 16.0F);
+ setItemStack(stack);
+ if (tooltip) {
+ setTooltip();
+ }
+ }
+
+ public ControlItemDisplay(IWidget parent, float x, float y, float size)
+ {
+ super(parent, x, y, size, size);
+ }
+
+ public void onRenderBackground()
+ {
+ IPoint relativeToWindow = getAbsolutePosition().sub(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) {
+ if (getSize().x() != 16.0F)
+ {
+ GL11.glPushMatrix();
+ float scale = getSize().x() / 16.0F;
+ GL11.glScalef(scale, scale, 1.0F);
+ BinnieCore.proxy.getMinecraftInstance();float phase = (float)Minecraft.getSystemTime() / 20.0F;
+ CraftGUI.Render.item(IPoint.ZERO, this.itemStack, this.rotating);
+ GL11.glPopMatrix();
+ }
+ else
+ {
+ CraftGUI.Render.item(IPoint.ZERO, this.itemStack, this.rotating);
+ }
+ }
+ }
+
+ public void setItemStack(ItemStack itemStack)
+ {
+ this.itemStack = itemStack;
+ }
+
+ public ItemStack getItemStack()
+ {
+ return this.itemStack;
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ if ((this.hastooltip) && (this.itemStack != null)) {
+ tooltip.add(this.itemStack.getTooltip(((Window)getSuperParent()).getPlayer(), false));
+ }
+ super.getTooltip(tooltip);
+ }
+
+ private boolean rotating = false;
+
+ public void setRotating()
+ {
+ this.rotating = true;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlLiquidTank.java b/src/Java/binnie/craftgui/minecraft/control/ControlLiquidTank.java
new file mode 100644
index 0000000000..d69c61136d
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlLiquidTank.java
@@ -0,0 +1,223 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.BinnieCore;
+import binnie.core.machines.Machine;
+import binnie.core.machines.inventory.MachineSide;
+import binnie.core.machines.inventory.TankSlot;
+import binnie.core.machines.inventory.Validator;
+import binnie.core.machines.power.ITankMachine;
+import binnie.core.machines.power.TankInfo;
+import binnie.core.proxy.BinnieProxy;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.ITopLevelWidget;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.GuiCraftGUI;
+import binnie.craftgui.minecraft.MinecraftTooltip;
+import binnie.craftgui.minecraft.MinecraftTooltip.Type;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import org.lwjgl.opengl.GL11;
+
+public class ControlLiquidTank
+ extends Control
+ implements ITooltip
+{
+ public static List<Integer> tankError = new ArrayList();
+ private int tankID = 0;
+ private boolean horizontal = false;
+
+ public ControlLiquidTank(IWidget parent, int x, int y)
+ {
+ this(parent, x, y, false);
+ }
+
+ public ControlLiquidTank(IWidget parent, int x, int y, boolean horizontal)
+ {
+ super(parent, x, y, horizontal ? 60.0F : 18.0F, horizontal ? 18.0F : 60.0F);
+ this.horizontal = horizontal;
+ addAttribute(Attribute.MouseOver);
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ if (event.getButton() == 0)
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ nbt.setByte("id", (byte)ControlLiquidTank.this.tankID);
+ Window.get(ControlLiquidTank.this.getWidget()).sendClientAction("tank-click", nbt);
+ }
+ }
+ });
+ }
+
+ public void setTankID(int tank)
+ {
+ this.tankID = tank;
+ }
+
+ public TankInfo getTank()
+ {
+ return Window.get(this).getContainer().getTankInfo(this.tankID);
+ }
+
+ public boolean isTankValid()
+ {
+ return !getTank().isEmpty();
+ }
+
+ public int getTankCapacity()
+ {
+ return (int)getTank().getCapacity();
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTank : CraftGUITexture.LiquidTank, IPoint.ZERO);
+ if ((isMouseOver()) && (Window.get(this).getGui().isHelpMode()))
+ {
+ int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.Help);
+ CraftGUI.Render.gradientRect(getArea().inset(1), c, c);
+ }
+ else if (tankError.contains(Integer.valueOf(this.tankID)))
+ {
+ int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
+ CraftGUI.Render.gradientRect(getArea().inset(1), c, c);
+ }
+ else if (getSuperParent().getMousedOverWidget() == this)
+ {
+ if (Window.get(this).getGui().getDraggedItem() != null) {
+ CraftGUI.Render.gradientRect(getArea().inset(1), -1426089575, -1426089575);
+ } else {
+ CraftGUI.Render.gradientRect(getArea().inset(1), -2130706433, -2130706433);
+ }
+ }
+ if (isTankValid())
+ {
+ Object content = null;
+
+ float height = this.horizontal ? 16.0F : 58.0F;
+
+ int squaled = (int)(height * (getTank().getAmount() / getTank().getCapacity()));
+
+
+
+ int yPos = (int)height + 1;
+
+ Fluid fluid = getTank().liquid.getFluid();
+
+ int hex = fluid.getColor(getTank().liquid);
+
+ int r = (hex & 0xFF0000) >> 16;
+ int g = (hex & 0xFF00) >> 8;
+ int b = hex & 0xFF;
+
+ GL11.glColor4f(r / 255.0F, g / 255.0F, b / 255.0F, 1.0F);
+
+ GL11.glEnable(3042);
+
+ GL11.glBlendFunc(770, 771);
+
+ IPoint pos = getAbsolutePosition();
+ IPoint offset = new IPoint(0.0F, height - squaled);
+ IArea limited = getArea().inset(1);
+ if (this.horizontal) {
+ limited.setSize(new IPoint(limited.w() - 1.0F, limited.h()));
+ }
+ CraftGUI.Render.limitArea(new IArea(limited.pos().add(pos).add(offset), limited.size().sub(offset)));
+
+
+ GL11.glEnable(3089);
+
+ BinnieCore.proxy.bindTexture(TextureMap.locationItemsTexture);
+ for (int y = 0; y < height; y += 16) {
+ for (int x = 0; x < (this.horizontal ? 58 : 16); x += 16)
+ {
+ IIcon icon = fluid.getIcon();
+
+ CraftGUI.Render.iconBlock(new IPoint(1 + x, 1 + y), icon);
+ }
+ }
+ GL11.glDisable(3089);
+ GL11.glDisable(3042);
+ }
+ }
+
+ public void onRenderForeground()
+ {
+ CraftGUI.Render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTankOverlay : CraftGUITexture.LiquidTankOverlay, IPoint.ZERO);
+ if ((isMouseOver()) && (Window.get(this).getGui().isHelpMode()))
+ {
+ IArea area = getArea();
+ CraftGUI.Render.colour(MinecraftTooltip.getOutline(Tooltip.Type.Help));
+ CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
+ }
+ if (tankError.contains(Integer.valueOf(this.tankID)))
+ {
+ IArea area = getArea();
+ CraftGUI.Render.colour(MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error));
+ CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
+ }
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ if (getTankSlot() != null)
+ {
+ TankSlot slot = getTankSlot();
+ tooltip.add(slot.getName());
+ tooltip.add("Capacity: " + getTankCapacity() + " mB");
+ tooltip.add("Insert Side: " + MachineSide.asString(slot.getInputSides()));
+ tooltip.add("Extract Side: " + MachineSide.asString(slot.getOutputSides()));
+ if (slot.isReadOnly()) {
+ tooltip.add("Output Only Tank");
+ }
+ tooltip.add("Accepts: " + (slot.getValidator() == null ? "Any Item" : slot.getValidator().getTooltip()));
+
+ return;
+ }
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ if (isTankValid())
+ {
+ int percentage = (int)(100.0D * getTank().getAmount() / getTankCapacity());
+
+ tooltip.add(getTank().getName());
+
+ tooltip.add(percentage + "% full");
+ tooltip.add((int)getTank().getAmount() + " mB");
+
+
+
+ return;
+ }
+ tooltip.add("Empty");
+ }
+
+ private TankSlot getTankSlot()
+ {
+ ITankMachine tank = (ITankMachine)Machine.getInterface(ITankMachine.class, Window.get(this).getInventory());
+
+ return tank != null ? tank.getTankSlot(this.tankID) : null;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlMachineProgress.java b/src/Java/binnie/craftgui/minecraft/control/ControlMachineProgress.java
new file mode 100644
index 0000000000..f2a64e3e38
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlMachineProgress.java
@@ -0,0 +1,14 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.resource.Texture;
+
+public class ControlMachineProgress
+ extends ControlProgress
+{
+ public ControlMachineProgress(IWidget parent, int x, int y, Texture base, Texture progress, Position dir)
+ {
+ super(parent, x, y, base, progress, dir);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java b/src/Java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java
new file mode 100644
index 0000000000..f15d102789
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlPlayerInventory.java
@@ -0,0 +1,108 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.minecraft.InventoryType;
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class ControlPlayerInventory
+ extends Control
+{
+ private List<ControlSlot> slots = new ArrayList();
+
+ public ControlPlayerInventory(IWidget parent, boolean wide)
+ {
+ super(parent, (int)(parent.getSize().x() / 2.0F) - (wide ? 110 : 81), (int)parent.getSize().y() - (wide ? 54 : 76) - 12, wide ? 'Ü' : '¢', wide ? 54 : 76);
+ for (int row = 0; row < 3; row++) {
+ for (int column = 0; column < 9; column++)
+ {
+ ControlSlot slot = new ControlSlot(this, (wide ? 58 : 0) + column * 18, row * 18);
+ this.slots.add(slot);
+ }
+ }
+ if (wide) {
+ for (int i1 = 0; i1 < 9; i1++)
+ {
+ ControlSlot slot = new ControlSlot(this, i1 % 3 * 18, i1 / 3 * 18);
+ this.slots.add(slot);
+ }
+ } else {
+ for (int i1 = 0; i1 < 9; i1++)
+ {
+ ControlSlot slot = new ControlSlot(this, i1 * 18, 58.0F);
+ this.slots.add(slot);
+ }
+ }
+ create();
+ }
+
+ public ControlPlayerInventory(IWidget parent)
+ {
+ this(parent, false);
+ }
+
+ public ControlPlayerInventory(IWidget parent, int x, int y)
+ {
+ super(parent, x, y, 54.0F, 220.0F);
+ for (int row = 0; row < 6; row++) {
+ for (int column = 0; column < 6; column++)
+ {
+ ControlSlot slot = new ControlSlot(this, column * 18, row * 18);
+ this.slots.add(slot);
+ }
+ }
+ create();
+ }
+
+ public void create()
+ {
+ for (int row = 0; row < 3; row++) {
+ for (int column = 0; column < 9; column++)
+ {
+ ControlSlot slot = (ControlSlot)this.slots.get(column + row * 9);
+ slot.assign(InventoryType.Player, 9 + column + row * 9);
+ }
+ }
+ for (int i1 = 0; i1 < 9; i1++)
+ {
+ ControlSlot slot = (ControlSlot)this.slots.get(27 + i1);
+ slot.assign(InventoryType.Player, i1);
+ }
+ }
+
+ public void addItem(ItemStack item)
+ {
+ if (item == null) {
+ return;
+ }
+ for (ControlSlot slot : this.slots) {
+ if (!slot.slot.getHasStack())
+ {
+ slot.slot.putStack(item);
+ return;
+ }
+ }
+ }
+
+ public void addInventory(IInventory inventory)
+ {
+ for (int i = 0; i < inventory.getSizeInventory(); i++) {
+ addItem(inventory.getStackInSlot(i));
+ }
+ }
+
+ public ControlSlot getSlot(int i)
+ {
+ if ((i < 0) || (i >= this.slots.size())) {
+ return null;
+ }
+ return (ControlSlot)this.slots.get(i);
+ }
+
+ public void onUpdateClient() {}
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlPowerSystem.java b/src/Java/binnie/craftgui/minecraft/control/ControlPowerSystem.java
new file mode 100644
index 0000000000..b0f522b180
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlPowerSystem.java
@@ -0,0 +1,39 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.power.PowerSystem;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlPowerSystem
+ extends Control
+ implements ITooltip
+{
+ private PowerSystem system;
+
+ public ControlPowerSystem(IWidget parent, float x, float y, PowerSystem system)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+ this.system = system;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.PowerButton, getArea());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.setType(Tooltip.Type.Power);
+ tooltip.add("Power Supply");
+ tooltip.add("Powered by " + this.system.getUnitName());
+ tooltip.setMaxWidth(200);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlProgress.java b/src/Java/binnie/craftgui/minecraft/control/ControlProgress.java
new file mode 100644
index 0000000000..6508c84107
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlProgress.java
@@ -0,0 +1,30 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.Texture;
+
+public class ControlProgress
+ extends ControlProgressBase
+{
+ private Texture progressBlank;
+ private Texture progressBar;
+ private Position direction;
+
+ public ControlProgress(IWidget parent, int x, int y, Texture progressBlank, Texture progressBar, Position dir)
+ {
+ super(parent, x, y, progressBlank == null ? 0.0F : progressBlank.w(), progressBlank == null ? 0.0F : progressBlank.h());
+ this.progressBlank = progressBlank;
+ this.progressBar = progressBar;
+ this.progress = 0.0F;
+ this.direction = dir;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(this.progressBlank, getArea());
+ CraftGUI.Render.texturePercentage(this.progressBar, getArea(), this.direction, this.progress);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlProgressBase.java b/src/Java/binnie/craftgui/minecraft/control/ControlProgressBase.java
new file mode 100644
index 0000000000..f7e2ef4f39
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlProgressBase.java
@@ -0,0 +1,100 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.IMachine;
+import binnie.core.machines.Machine;
+import binnie.core.machines.power.IProcess;
+import binnie.core.machines.power.ProcessInfo;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.Window;
+
+public class ControlProgressBase
+ extends Control
+{
+ protected float progress;
+
+ public ControlProgressBase(IWidget parent, float x, float y, float w, float h)
+ {
+ super(parent, x, y, w, h);
+ this.progress = 0.0F;
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public void setProgress(float progress)
+ {
+ this.progress = progress;
+ if (this.progress < 0.0F) {
+ this.progress = 0.0F;
+ } else if (this.progress > 1.0F) {
+ this.progress = 1.0F;
+ }
+ }
+
+ protected ProcessInfo getProcess()
+ {
+ return Window.get(this).getContainer().getProcessInfo();
+ }
+
+ public void onUpdateClient()
+ {
+ ProcessInfo process = getProcess();
+ if (process != null) {
+ setProgress(process.getCurrentProgress() / 100.0F);
+ }
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ ProcessInfo process = getProcess();
+
+ IProcess machineProcess = (IProcess)Machine.getMachine(Window.get(this).getInventory()).getInterface(IProcess.class);
+ if (process != null)
+ {
+ tooltip.add("Progress");
+ if (this.progress == 0.0F) {
+ tooltip.add("Not in Progress");
+ } else if (process.getProcessTime() > 0) {
+ tooltip.add(machineProcess.getTooltip() + " (" + (int)process.getCurrentProgress() + "%)");
+ } else {
+ tooltip.add("In Progress");
+ }
+ if (process.getProcessTime() > 0)
+ {
+ tooltip.add("Time Left: " + convertTime((int)((1.0F - this.progress) * process.getProcessTime())));
+
+ tooltip.add("Total Time: " + convertTime(process.getProcessTime()));
+ tooltip.add("Energy Cost: " + process.getProcessEnergy() * 10 + " RF");
+ }
+ else
+ {
+ tooltip.add("Energy Cost: " + process.getEnergyPerTick() * 10.0F + " RF / tick");
+ }
+ }
+ }
+
+ public static String convertTime(int time)
+ {
+ int seconds = (int)(time / 20.0F);
+ int minutes = 0;
+ while (seconds >= 60)
+ {
+ minutes++;
+ seconds -= 60;
+ }
+ String ts = "";
+ if (minutes > 0) {
+ ts = ts + minutes + " minute" + (minutes == 1 ? "" : "s");
+ }
+ if (seconds > 0)
+ {
+ if (ts.length() > 0) {
+ ts = ts + " ";
+ }
+ ts = ts + seconds + " second" + (seconds == 1 ? "" : "s");
+ }
+ return ts;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlSlide.java b/src/Java/binnie/craftgui/minecraft/control/ControlSlide.java
new file mode 100644
index 0000000000..44cfe0fd37
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlSlide.java
@@ -0,0 +1,113 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IBorder;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import org.lwjgl.opengl.GL11;
+
+public class ControlSlide
+ extends Control
+{
+ private IArea expanded;
+ private IArea shrunk;
+ private boolean slideActive = true;
+ private Position anchor;
+ private String label = null;
+
+ public ControlSlide(IWidget parent, float x, float y, float w, float h, Position anchor2)
+ {
+ super(parent, x, y, w, h);
+ addAttribute(Attribute.MouseOver);
+ addAttribute(Attribute.BlockTooltip);
+ this.expanded = new IArea(getPosition(), getSize());
+ this.anchor = anchor2.opposite();
+ float border = this.anchor.x() != 0 ? this.expanded.w() - 6.0F : this.expanded.h() - 6.0F;
+ this.shrunk = this.expanded.inset(new IBorder(this.anchor, border));
+
+
+ this.slideActive = false;
+ }
+
+ public void onRenderBackground()
+ {
+ super.onRenderBackground();
+ if (this.label != null)
+ {
+ float lw = CraftGUI.Render.textWidth(this.label) + 16;
+ float lh = CraftGUI.Render.textHeight() + 16;
+ boolean hor = this.anchor.x() != 0;
+ IArea ar = isSlideActive() ? this.expanded : this.shrunk;
+ IArea tabArea = new IArea(hor ? -lh / 2.0F : -lw / 2.0F, hor ? -lw / 2.0F : -lh / 2.0F, hor ? lh : lw, hor ? lw : lh);
+ IPoint shift = new IPoint(ar.w() * (1 - this.anchor.x()) / 2.0F, ar.h() * (1 - this.anchor.y()) / 2.0F);
+
+
+
+
+ tabArea = tabArea.shift(shift.x() - (-3.0F + lh / 2.0F) * this.anchor.x(), shift.y() - (-3.0F + lh / 2.0F) * this.anchor.y());
+ Texture texture = CraftGUI.Render.getTexture(isSlideActive() ? CraftGUITexture.Tab : CraftGUITexture.TabDisabled).crop(this.anchor.opposite(), 8.0F);
+ CraftGUI.Render.texture(texture, tabArea);
+ texture = CraftGUI.Render.getTexture(CraftGUITexture.TabOutline).crop(this.anchor.opposite(), 8.0F);
+ CraftGUI.Render.texture(texture, tabArea.inset(2));
+ IArea labelArea = new IArea(-lw / 2.0F, 0.0F, lw, lh);
+ GL11.glPushMatrix();
+ GL11.glTranslatef(shift.x() + this.anchor.x() * 2.0F, shift.y() + this.anchor.y() * 2.0F, 0.0F);
+ if (this.anchor.x() != 0) {
+ GL11.glRotatef(90.0F, 0.0F, 0.0F, this.anchor.x());
+ }
+ if (this.anchor.y() > 0) {
+ GL11.glTranslatef(0.0F, -lh, 0.0F);
+ }
+ CraftGUI.Render.text(labelArea, TextJustification.MiddleCenter, this.label, 16777215);
+ GL11.glPopMatrix();
+ }
+ CraftGUI.Render.texture(CraftGUITexture.Window, getArea());
+ Object slideTexture = this.anchor == Position.Left ? CraftGUITexture.SlideLeft : this.anchor == Position.Top ? CraftGUITexture.SlideUp : this.anchor == Position.Bottom ? CraftGUITexture.SlideDown : CraftGUITexture.SlideRight;
+
+ CraftGUI.Render.texture(slideTexture, new IPoint((this.anchor.x() + 1.0F) * w() / 2.0F - 8.0F, (this.anchor.y() + 1.0F) * h() / 2.0F - 8.0F));
+ }
+
+ public boolean isSlideActive()
+ {
+ return this.slideActive;
+ }
+
+ public void onUpdateClient()
+ {
+ boolean mouseOver = isMouseOverWidget(getRelativeMousePosition());
+ if (mouseOver != this.slideActive) {
+ setSlide(mouseOver);
+ }
+ }
+
+ public boolean isMouseOverWidget(IPoint relativeMouse)
+ {
+ return getArea().outset(isSlideActive() ? 16 : 8).outset(new IBorder(this.anchor.opposite(), 16.0F)).contains(relativeMouse);
+ }
+
+ public boolean isChildVisible(IWidget child)
+ {
+ return this.slideActive;
+ }
+
+ public void setSlide(boolean b)
+ {
+ this.slideActive = b;
+ IArea area = isSlideActive() ? this.expanded : this.shrunk;
+ setSize(area.size());
+ setPosition(area.pos());
+ }
+
+ public void setLabel(String l)
+ {
+ this.label = l;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlSlot.java b/src/Java/binnie/craftgui/minecraft/control/ControlSlot.java
new file mode 100644
index 0000000000..c3de12acaa
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlSlot.java
@@ -0,0 +1,221 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.inventory.InventorySlot;
+import binnie.core.machines.inventory.MachineSide;
+import binnie.core.machines.inventory.SlotValidator;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITopLevelWidget;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.ContainerCraftGUI;
+import binnie.craftgui.minecraft.CustomSlot;
+import binnie.craftgui.minecraft.GuiCraftGUI;
+import binnie.craftgui.minecraft.InventoryType;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.WindowInventory;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.multiplayer.PlayerControllerMP;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+
+public class ControlSlot
+ extends ControlSlotBase
+{
+ public static Map<EnumHighlighting, List<Integer>> highlighting = new HashMap();
+ public static boolean shiftClickActive = false;
+
+ static
+ {
+ for (EnumHighlighting h : EnumHighlighting.values()) {
+ highlighting.put(h, new ArrayList());
+ }
+ }
+
+ public Slot slot = null;
+
+ public ControlSlot(IWidget parent, float x, float y)
+ {
+ super(parent, x, y);
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ if (ControlSlot.this.slot != null)
+ {
+ Window.get(ControlSlot.this.getWidget()).getGui();((Window)ControlSlot.this.getSuperParent()).getGui().getMinecraft().playerController.windowClick(((Window)ControlSlot.this.getSuperParent()).getContainer().windowId, ControlSlot.this.slot.slotNumber, event.getButton(), GuiCraftGUI.isShiftKeyDown() ? 1 : 0, ((Window)ControlSlot.this.getSuperParent()).getGui().getMinecraft().thePlayer);
+ }
+ }
+ });
+ }
+
+ public ControlSlot(IWidget parent, int x, int y, Slot slot)
+ {
+ super(parent, x, y);
+ this.slot = slot;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.Slot, IPoint.ZERO);
+ if (this.slot == null) {
+ return;
+ }
+ InventorySlot islot = getInventorySlot();
+ if ((islot != null) && (islot.getValidator() != null))
+ {
+ IIcon icon = islot.getValidator().getIcon(!islot.getInputSides().isEmpty());
+ if (icon != null) {
+ CraftGUI.Render.iconItem(new IPoint(1.0F, 1.0F), icon);
+ }
+ }
+ boolean highlighted = false;
+ for (Map.Entry<EnumHighlighting, List<Integer>> highlight : highlighting.entrySet()) {
+ if ((highlight.getKey() != EnumHighlighting.ShiftClick) || (shiftClickActive)) {
+ if ((!highlighted) && (((List)highlight.getValue()).contains(Integer.valueOf(this.slot.slotNumber))))
+ {
+ highlighted = true;
+
+ int c = -1442840576 + Math.min(((EnumHighlighting)highlight.getKey()).getColour(), 16777215);
+ CraftGUI.Render.gradientRect(new IArea(1.0F, 1.0F, 16.0F, 16.0F), c, c);
+ }
+ }
+ }
+ if ((!highlighted) && (getSuperParent().getMousedOverWidget() == this)) {
+ if ((Window.get(this).getGui().getDraggedItem() != null) && (!this.slot.isItemValid(Window.get(this).getGui().getDraggedItem()))) {
+ CraftGUI.Render.gradientRect(new IArea(1.0F, 1.0F, 16.0F, 16.0F), -1426089575, -1426089575);
+ } else {
+ CraftGUI.Render.gradientRect(new IArea(1.0F, 1.0F, 16.0F, 16.0F), -2130706433, -2130706433);
+ }
+ }
+ }
+
+ public void onRenderOverlay()
+ {
+ if (this.slot == null) {
+ return;
+ }
+ boolean highlighted = false;
+ for (Map.Entry<EnumHighlighting, List<Integer>> highlight : highlighting.entrySet()) {
+ if ((highlight.getKey() != EnumHighlighting.ShiftClick) || (shiftClickActive)) {
+ if ((!highlighted) && (((List)highlight.getValue()).contains(Integer.valueOf(this.slot.slotNumber))))
+ {
+ highlighted = true;
+ int c = ((EnumHighlighting)highlight.getKey()).getColour();
+ IArea area = getArea();
+ if (((getParent() instanceof ControlSlotArray)) || ((getParent() instanceof ControlPlayerInventory)))
+ {
+ area = getParent().getArea();
+ area.setPosition(IPoint.ZERO.sub(getPosition()));
+ }
+ CraftGUI.Render.colour(c);
+ CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
+ }
+ }
+ }
+ }
+
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+ if (this.slot == null) {
+ return;
+ }
+ if ((isMouseOver()) && (GuiScreen.isShiftKeyDown()))
+ {
+ Window.get(this).getContainer().setMouseOverSlot(this.slot);
+ shiftClickActive = true;
+ }
+ if (Window.get(this).getGui().isHelpMode()) {
+ if (isMouseOver()) {
+ for (ControlSlot slot2 : getControlSlots()) {
+ if (slot2.slot != null) {
+ ((List)highlighting.get(EnumHighlighting.Help)).add(Integer.valueOf(slot2.slot.slotNumber));
+ }
+ }
+ }
+ }
+ }
+
+ private List<ControlSlot> getControlSlots()
+ {
+ List<ControlSlot> slots = new ArrayList();
+ if (((getParent() instanceof ControlSlotArray)) || ((getParent() instanceof ControlPlayerInventory))) {
+ for (IWidget child : getParent().getWidgets()) {
+ slots.add((ControlSlot)child);
+ }
+ } else {
+ slots.add(this);
+ }
+ return slots;
+ }
+
+ public ItemStack getItemStack()
+ {
+ if (this.slot != null) {
+ return this.slot.getStack();
+ }
+ return null;
+ }
+
+ public ControlSlot assign(int index)
+ {
+ return assign(InventoryType.Machine, index);
+ }
+
+ public ControlSlot assign(InventoryType inventory, int index)
+ {
+ if (this.slot != null) {
+ return this;
+ }
+ this.slot = ((Window)getSuperParent()).getContainer().getOrCreateSlot(inventory, index);
+ return this;
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ if (this.slot == null) {
+ return;
+ }
+ InventorySlot slot = getInventorySlot();
+ if (getInventorySlot() != null)
+ {
+ tooltip.add(slot.getName());
+ tooltip.add("Insert Side: " + MachineSide.asString(slot.getInputSides()));
+ tooltip.add("Extract Side: " + MachineSide.asString(slot.getOutputSides()));
+ if (slot.isReadOnly()) {
+ tooltip.add("Pickup Only Slot");
+ }
+ tooltip.add("Accepts: " + (slot.getValidator() == null ? "Any Item" : slot.getValidator().getTooltip()));
+ }
+ else if ((this.slot.inventory instanceof WindowInventory))
+ {
+ SlotValidator s = ((WindowInventory)this.slot.inventory).getValidator(this.slot.getSlotIndex());
+ tooltip.add("Accepts: " + (s == null ? "Any Item" : s.getTooltip()));
+ }
+ else if ((this.slot.inventory instanceof InventoryPlayer))
+ {
+ tooltip.add("Player Inventory");
+ }
+ }
+
+ public InventorySlot getInventorySlot()
+ {
+ return (this.slot instanceof CustomSlot) ? ((CustomSlot)this.slot).getInventorySlot() : null;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlSlotArray.java b/src/Java/binnie/craftgui/minecraft/control/ControlSlotArray.java
new file mode 100644
index 0000000000..772b9a5f85
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlSlotArray.java
@@ -0,0 +1,76 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.minecraft.InventoryType;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class ControlSlotArray
+ extends Control
+ implements Iterable<ControlSlot>
+{
+ private int rows;
+ private int columns;
+ private List<ControlSlot> slots = new ArrayList();
+
+ public ControlSlotArray(IWidget parent, int x, int y, int columns, int rows)
+ {
+ super(parent, x, y, columns * 18, rows * 18);
+ this.rows = rows;
+ this.columns = columns;
+ for (int row = 0; row < rows; row++) {
+ for (int column = 0; column < columns; column++) {
+ this.slots.add(createSlot(column * 18, row * 18));
+ }
+ }
+ }
+
+ public ControlSlot createSlot(int x, int y)
+ {
+ return new ControlSlot(this, x, y);
+ }
+
+ public void setItemStacks(ItemStack[] array)
+ {
+ int i = 0;
+ for (ItemStack item : array)
+ {
+ if (i >= this.slots.size()) {
+ return;
+ }
+ ((ControlSlot)this.slots.get(i)).slot.putStack(item);
+ i++;
+ }
+ }
+
+ public ControlSlot getControlSlot(int i)
+ {
+ if ((i < 0) || (i >= this.slots.size())) {
+ return null;
+ }
+ return (ControlSlot)this.slots.get(i);
+ }
+
+ public ControlSlotArray create(int[] index)
+ {
+ return create(InventoryType.Machine, index);
+ }
+
+ public ControlSlotArray create(InventoryType type, int[] index)
+ {
+ int i = 0;
+ for (ControlSlot slot : this.slots) {
+ slot.assign(type, index[(i++)]);
+ }
+ return this;
+ }
+
+ public Iterator<ControlSlot> iterator()
+ {
+ return this.slots.iterator();
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlSlotBase.java b/src/Java/binnie/craftgui/minecraft/control/ControlSlotBase.java
new file mode 100644
index 0000000000..db7b9fa973
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlSlotBase.java
@@ -0,0 +1,77 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.ITopLevelWidget;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventWidget.ChangeSize;
+import binnie.craftgui.events.EventWidget.ChangeSize.Handler;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import net.minecraft.item.ItemStack;
+
+public abstract class ControlSlotBase
+ extends Control
+ implements ITooltip
+{
+ private ControlItemDisplay itemDisplay;
+
+ public ControlSlotBase(IWidget parent, float x, float y)
+ {
+ this(parent, x, y, 18);
+ }
+
+ public ControlSlotBase(IWidget parent, float x, float y, int size)
+ {
+ super(parent, x, y, size, size);
+ addAttribute(Attribute.MouseOver);
+ this.itemDisplay = new ControlItemDisplay(this, 1.0F, 1.0F, size - 2);
+
+ addSelfEventHandler(new EventWidget.ChangeSize.Handler()
+ {
+ public void onEvent(EventWidget.ChangeSize event)
+ {
+ if (ControlSlotBase.this.itemDisplay != null) {
+ ControlSlotBase.this.itemDisplay.setSize(ControlSlotBase.this.getSize().sub(new IPoint(2.0F, 2.0F)));
+ }
+ }
+ });
+ }
+
+ protected void setRotating()
+ {
+ this.itemDisplay.setRotating();
+ }
+
+ public void onRenderBackground()
+ {
+ int size = (int)getSize().x();
+ CraftGUI.Render.texture(CraftGUITexture.Slot, getArea());
+ if (getSuperParent().getMousedOverWidget() == this) {
+ CraftGUI.Render.gradientRect(new IArea(new IPoint(1.0F, 1.0F), getArea().size().sub(new IPoint(2.0F, 2.0F))), -2130706433, -2130706433);
+ }
+ }
+
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+ this.itemDisplay.setItemStack(getItemStack());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ ItemStack item = getItemStack();
+ if (item == null) {
+ return;
+ }
+ tooltip.add(item.getTooltip(((Window)getSuperParent()).getPlayer(), false));
+ }
+
+ public abstract ItemStack getItemStack();
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlSlotCharge.java b/src/Java/binnie/craftgui/minecraft/control/ControlSlotCharge.java
new file mode 100644
index 0000000000..eb14237a4d
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlSlotCharge.java
@@ -0,0 +1,43 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.machines.Machine;
+import binnie.core.machines.inventory.IChargedSlots;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlSlotCharge
+ extends Control
+{
+ private int slot;
+
+ float getCharge()
+ {
+ IChargedSlots slots = (IChargedSlots)Machine.getInterface(IChargedSlots.class, Window.get(this).getInventory());
+ return slots == null ? 0.0F : slots.getCharge(this.slot);
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.PanelBlack, getArea());
+
+ CraftGUI.Render.texturePercentage(CraftGUI.Render.getTexture(CraftGUITexture.SlotCharge), getArea().inset(1), Position.Bottom, getCharge());
+ }
+
+ public ControlSlotCharge(IWidget parent, int x, int y, int slot)
+ {
+ super(parent, x, y, 4.0F, 18.0F);
+ this.slot = slot;
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ tooltip.add("Charge Remaining: " + (int)(getCharge() * 100.0F) + "%");
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlTabIcon.java b/src/Java/binnie/craftgui/minecraft/control/ControlTabIcon.java
new file mode 100644
index 0000000000..8337dc23fc
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlTabIcon.java
@@ -0,0 +1,47 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.core.genetics.IItemStackRepresentitive;
+import binnie.craftgui.controls.tab.ControlTab;
+import binnie.craftgui.controls.tab.ControlTabBar;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import net.minecraft.item.ItemStack;
+
+public class ControlTabIcon<T>
+ extends ControlTab<T>
+{
+ private ControlItemDisplay item;
+
+ public ControlTabIcon(ControlTabBar<T> parent, float x, float y, float w, float h, T value)
+ {
+ super(parent, x, y, w, h, value);
+ this.item = new ControlItemDisplay(this, -8.0F + w / 2.0F, -8.0F + h / 2.0F);
+ this.item.hastooltip = false;
+ }
+
+ public ItemStack getItemStack()
+ {
+ if ((this.value instanceof IItemStackRepresentitive)) {
+ return ((IItemStackRepresentitive)this.value).getItemStackRepresentitive();
+ }
+ return null;
+ }
+
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+ this.item.setItemStack(getItemStack());
+ float x = ((ControlTabBar)getParent()).getDirection().x();
+ this.item.setOffset(new IPoint((isCurrentSelection()) || (isMouseOver()) ? 0.0F : -4.0F * x, 0.0F));
+ }
+
+ public boolean hasOutline()
+ {
+ return false;
+ }
+
+ public int getOutlineColour()
+ {
+ return 16777215;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/ControlUser.java b/src/Java/binnie/craftgui/minecraft/control/ControlUser.java
new file mode 100644
index 0000000000..41c5a3c0bd
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/ControlUser.java
@@ -0,0 +1,41 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class ControlUser
+ extends Control
+ implements ITooltip
+{
+ private String username = "";
+ String team = "";
+
+ public ControlUser(IWidget parent, float x, float y, String username)
+ {
+ super(parent, x, y, 16.0F, 16.0F);
+ addAttribute(Attribute.MouseOver);
+ this.username = username;
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.UserButton, getArea());
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ tooltip.setType(Tooltip.Type.User);
+ tooltip.add("Owner");
+ if (this.username != "") {
+ tooltip.add(this.username);
+ }
+ tooltip.setMaxWidth(200);
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/control/EnumHighlighting.java b/src/Java/binnie/craftgui/minecraft/control/EnumHighlighting.java
new file mode 100644
index 0000000000..7eb1f2d988
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/control/EnumHighlighting.java
@@ -0,0 +1,28 @@
+package binnie.craftgui.minecraft.control;
+
+import binnie.craftgui.core.Tooltip.Type;
+import binnie.craftgui.minecraft.MinecraftTooltip;
+import binnie.craftgui.minecraft.MinecraftTooltip.Type;
+
+public enum EnumHighlighting
+{
+ Error, Warning, Help, ShiftClick;
+
+ private EnumHighlighting() {}
+
+ int getColour()
+ {
+ switch (1.$SwitchMap$binnie$craftgui$minecraft$control$EnumHighlighting[ordinal()])
+ {
+ case 1:
+ return MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
+ case 2:
+ return MinecraftTooltip.getOutline(Tooltip.Type.Help);
+ case 3:
+ return 16776960;
+ case 4:
+ return MinecraftTooltip.getOutline(MinecraftTooltip.Type.Warning);
+ }
+ return 0;
+ }
+}
diff --git a/src/Java/binnie/craftgui/minecraft/render/MinecraftTexture.java b/src/Java/binnie/craftgui/minecraft/render/MinecraftTexture.java
new file mode 100644
index 0000000000..51addcd1db
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/render/MinecraftTexture.java
@@ -0,0 +1,10 @@
+package binnie.craftgui.minecraft.render;
+
+import binnie.core.resource.IBinnieTexture;
+import binnie.craftgui.core.geometry.IArea;
+
+public class MinecraftTexture
+{
+ IArea textureArea = new IArea(0.0F, 0.0F, 0.0F, 0.0F);
+ IBinnieTexture texture;
+}
diff --git a/src/Java/binnie/craftgui/minecraft/render/RenderCommand.java b/src/Java/binnie/craftgui/minecraft/render/RenderCommand.java
new file mode 100644
index 0000000000..2cfa60f08a
--- /dev/null
+++ b/src/Java/binnie/craftgui/minecraft/render/RenderCommand.java
@@ -0,0 +1,16 @@
+package binnie.craftgui.minecraft.render;
+
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.minecraft.GuiCraftGUI;
+
+public abstract class RenderCommand
+{
+ IWidget widget;
+
+ public RenderCommand(IWidget widget)
+ {
+ this.widget = widget;
+ }
+
+ public abstract void render(GuiCraftGUI paramGuiCraftGUI);
+}
diff --git a/src/Java/binnie/craftgui/mod/database/ControlBranchBox.java b/src/Java/binnie/craftgui/mod/database/ControlBranchBox.java
new file mode 100644
index 0000000000..3aaf90d53a
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/ControlBranchBox.java
@@ -0,0 +1,20 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlListBox;
+import binnie.craftgui.core.IWidget;
+import forestry.api.genetics.IClassification;
+
+class ControlBranchBox
+ extends ControlListBox<IClassification>
+{
+ public IWidget createOption(IClassification value, int y)
+ {
+ return new ControlBranchBoxOption((ControlList)getContent(), value, y);
+ }
+
+ public ControlBranchBox(IWidget parent, float x, float y, float width, float height)
+ {
+ super(parent, x, y, width, height, 12.0F);
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/ControlBranchBoxOption.java b/src/Java/binnie/craftgui/mod/database/ControlBranchBoxOption.java
new file mode 100644
index 0000000000..a3f83f403f
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/ControlBranchBoxOption.java
@@ -0,0 +1,14 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlTextOption;
+import forestry.api.genetics.IClassification;
+
+class ControlBranchBoxOption
+ extends ControlTextOption<IClassification>
+{
+ public ControlBranchBoxOption(ControlList<IClassification> controlList, IClassification option, int y)
+ {
+ super(controlList, option, option.getName().contains(".") ? option.getScientific() : option.getName() == null ? option.getScientific() : option.getName(), y);
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/ControlBreedingProgress.java b/src/Java/binnie/craftgui/mod/database/ControlBreedingProgress.java
new file mode 100644
index 0000000000..9340a66752
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/ControlBreedingProgress.java
@@ -0,0 +1,41 @@
+package binnie.craftgui.mod.database;
+
+import binnie.core.genetics.BreedingSystem;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+import binnie.craftgui.resource.minecraft.CraftGUITextureSheet;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+
+class ControlBreedingProgress
+ extends Control
+{
+ private static Texture Progress = new StandardTexture(80, 22, 4, 4, CraftGUITextureSheet.Controls2);
+ private float percentage;
+ private int colour;
+
+ public ControlBreedingProgress(IWidget parent, int x, int y, int width, int height, BreedingSystem system, float percentage)
+ {
+ super(parent, x, y, width, height);
+ this.percentage = percentage;
+ this.colour = system.getColour();
+ }
+
+ public void onRenderBackground()
+ {
+ CraftGUI.Render.texture(CraftGUITexture.PanelBlack, getArea());
+
+ IArea area = getArea().inset(1);
+
+ area.setSize(new IPoint(area.size().x() * this.percentage, area.size().y()));
+
+ CraftGUI.Render.colour(this.colour);
+
+ CraftGUI.Render.texture(Progress, area);
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/ControlDatabaseIndividualDisplay.java b/src/Java/binnie/craftgui/mod/database/ControlDatabaseIndividualDisplay.java
new file mode 100644
index 0000000000..e46cf94df7
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/ControlDatabaseIndividualDisplay.java
@@ -0,0 +1,120 @@
+package binnie.craftgui.mod.database;
+
+import binnie.Binnie;
+import binnie.core.genetics.BreedingSystem;
+import binnie.core.genetics.ManagerGenetics;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.events.EventMouse.Down;
+import binnie.craftgui.events.EventMouse.Down.Handler;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlItemDisplay;
+import com.mojang.authlib.GameProfile;
+import forestry.api.genetics.IAlleleSpecies;
+import forestry.api.genetics.IIndividual;
+import forestry.api.genetics.ISpeciesRoot;
+import net.minecraft.util.IIcon;
+
+public class ControlDatabaseIndividualDisplay
+ extends ControlItemDisplay
+ implements ITooltip
+{
+ public void setSpecies(IAlleleSpecies species)
+ {
+ setSpecies(species, EnumDiscoveryState.Show);
+ }
+
+ public void setSpecies(IAlleleSpecies species, EnumDiscoveryState state)
+ {
+ ISpeciesRoot speciesRoot = Binnie.Genetics.getSpeciesRoot(species);
+
+ BreedingSystem system = Binnie.Genetics.getSystem(speciesRoot.getUID());
+
+ IIndividual ind = system.getSpeciesRoot().templateAsIndividual(system.getSpeciesRoot().getTemplate(species.getUID()));
+
+ super.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
+ this.species = species;
+
+ GameProfile username = Window.get(this).getUsername();
+ if (state == EnumDiscoveryState.Undetermined) {
+ state = system.isSpeciesDiscovered(species, Window.get(this).getWorld(), username) ? EnumDiscoveryState.Discovered : EnumDiscoveryState.Undiscovered;
+ }
+ if (((Window.get(this) instanceof WindowAbstractDatabase)) &&
+ (((WindowAbstractDatabase)Window.get(this)).isNEI)) {
+ state = EnumDiscoveryState.Show;
+ }
+ this.discovered = state;
+
+ addAttribute(Attribute.MouseOver);
+ }
+
+ private IAlleleSpecies species = null;
+ EnumDiscoveryState discovered = EnumDiscoveryState.Show;
+
+ public ControlDatabaseIndividualDisplay(IWidget parent, float x, float y)
+ {
+ this(parent, x, y, 16.0F);
+ }
+
+ public ControlDatabaseIndividualDisplay(IWidget parent, float x, float y, float size)
+ {
+ super(parent, x, y, size);
+
+
+ addSelfEventHandler(new EventMouse.Down.Handler()
+ {
+ public void onEvent(EventMouse.Down event)
+ {
+ if ((event.getButton() == 0) && (ControlDatabaseIndividualDisplay.this.species != null) && (EnumDiscoveryState.Show == ControlDatabaseIndividualDisplay.this.discovered)) {
+ ((WindowAbstractDatabase)ControlDatabaseIndividualDisplay.this.getSuperParent()).gotoSpeciesDelayed(ControlDatabaseIndividualDisplay.this.species);
+ }
+ }
+ });
+ }
+
+ public void onRenderForeground()
+ {
+ IIcon icon = null;
+ if (this.species == null) {
+ return;
+ }
+ BreedingSystem system = Binnie.Genetics.getSystem(this.species.getRoot());
+ switch (2.$SwitchMap$binnie$craftgui$mod$database$EnumDiscoveryState[this.discovered.ordinal()])
+ {
+ case 1:
+ super.onRenderForeground();
+ return;
+ case 2:
+ icon = system.getDiscoveredIcon();
+ break;
+ case 3:
+ icon = system.getUndiscoveredIcon();
+ break;
+ }
+ if (icon != null) {
+ CraftGUI.Render.iconItem(IPoint.ZERO, icon);
+ }
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ if (this.species != null) {
+ switch (2.$SwitchMap$binnie$craftgui$mod$database$EnumDiscoveryState[this.discovered.ordinal()])
+ {
+ case 1:
+ tooltip.add(this.species.getName());
+ break;
+ case 2:
+ tooltip.add("Discovered Species");
+ break;
+ case 3:
+ tooltip.add("Undiscovered Species");
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/ControlItemStackOption.java b/src/Java/binnie/craftgui/mod/database/ControlItemStackOption.java
new file mode 100644
index 0000000000..2dfa33b083
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/ControlItemStackOption.java
@@ -0,0 +1,38 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlTextOption;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.geometry.CraftGUIUtil;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.control.ControlItemDisplay;
+import net.minecraft.item.ItemStack;
+
+public class ControlItemStackOption
+ extends ControlTextOption<ItemStack>
+{
+ private ControlItemDisplay controlBee;
+
+ public ControlItemStackOption(ControlList<ItemStack> controlList, ItemStack option, int y)
+ {
+ super(controlList, option, option.getDisplayName(), y);
+ setSize(new IPoint(getSize().x(), 20.0F));
+
+ this.controlBee = new ControlItemDisplay(this, 2.0F, 2.0F);
+ this.controlBee.setItemStack(option);
+
+ 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)));
+
+ int th = (int)CraftGUI.Render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x());
+ int height = Math.max(20, th + 6);
+ setSize(new IPoint(size().x(), height));
+ this.textWidget.setSize(new IPoint(this.textWidget.getSize().x(), height));
+ this.controlBee.setPosition(new IPoint(this.controlBee.pos().x(), (height - 18) / 2));
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/ControlMutationBox.java b/src/Java/binnie/craftgui/mod/database/ControlMutationBox.java
new file mode 100644
index 0000000000..62cdda8dcf
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/ControlMutationBox.java
@@ -0,0 +1,71 @@
+package binnie.craftgui.mod.database;
+
+import binnie.core.genetics.BreedingSystem;
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlListBox;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.minecraft.Window;
+import forestry.api.genetics.IAlleleSpecies;
+import forestry.api.genetics.IMutation;
+import java.util.List;
+
+class ControlMutationBox
+ extends ControlListBox<IMutation>
+{
+ private int index;
+ private Type type;
+
+ public IWidget createOption(IMutation value, int y)
+ {
+ return new ControlMutationItem((ControlList)getContent(), value, this.species, y);
+ }
+
+ static enum Type
+ {
+ Resultant, Further;
+
+ private Type() {}
+ }
+
+ public ControlMutationBox(IWidget parent, int x, int y, int width, int height, Type type)
+ {
+ super(parent, x, y, width, height, 12.0F);
+ this.type = type;
+ }
+
+ private IAlleleSpecies species = null;
+
+ public void setSpecies(IAlleleSpecies species)
+ {
+ if (species != this.species)
+ {
+ this.species = species;
+ this.index = 0;
+ movePercentage(-100.0F);
+
+ BreedingSystem system = ((WindowAbstractDatabase)getSuperParent()).getBreedingSystem();
+
+ List<IMutation> discovered = system.getDiscoveredMutations(Window.get(this).getWorld(), Window.get(this).getUsername());
+ if (species != null) {
+ if (this.type == Type.Resultant)
+ {
+ setOptions(system.getResultantMutations(species));
+ }
+ else
+ {
+ List<IMutation> mutations = system.getFurtherMutations(species);
+ for (int i = 0; i < mutations.size();)
+ {
+ IMutation mutation = (IMutation)mutations.get(i);
+ if ((!discovered.contains(mutations)) && (!((IAlleleSpecies)mutation.getTemplate()[0]).isCounted())) {
+ mutations.remove(i);
+ } else {
+ i++;
+ }
+ }
+ setOptions(mutations);
+ }
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/ControlMutationItem.java b/src/Java/binnie/craftgui/mod/database/ControlMutationItem.java
new file mode 100644
index 0000000000..630294e458
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/ControlMutationItem.java
@@ -0,0 +1,51 @@
+package binnie.craftgui.mod.database;
+
+import binnie.core.genetics.BreedingSystem;
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlOption;
+import binnie.craftgui.minecraft.Window;
+import forestry.api.genetics.IAlleleSpecies;
+import forestry.api.genetics.IMutation;
+
+class ControlMutationItem
+ extends ControlOption<IMutation>
+{
+ private ControlDatabaseIndividualDisplay itemWidget1;
+ private ControlDatabaseIndividualDisplay itemWidget2;
+ private ControlDatabaseIndividualDisplay itemWidget3;
+ private ControlMutationSymbol addSymbol;
+ private ControlMutationSymbol arrowSymbol;
+
+ public ControlMutationItem(ControlList<IMutation> controlList, IMutation option, IAlleleSpecies species, int y)
+ {
+ super(controlList, option, y);
+ this.itemWidget1 = new ControlDatabaseIndividualDisplay(this, 4.0F, 4.0F);
+ this.itemWidget2 = new ControlDatabaseIndividualDisplay(this, 44.0F, 4.0F);
+ this.itemWidget3 = new ControlDatabaseIndividualDisplay(this, 104.0F, 4.0F);
+ this.addSymbol = new ControlMutationSymbol(this, 24, 4, 0);
+ this.arrowSymbol = new ControlMutationSymbol(this, 64, 4, 1);
+
+ boolean isNEI = ((WindowAbstractDatabase)getSuperParent()).isNEI();
+ BreedingSystem system = ((WindowAbstractDatabase)getSuperParent()).getBreedingSystem();
+ if (getValue() != null)
+ {
+ boolean isMutationDiscovered = system.isMutationDiscovered((IMutation)getValue(), Window.get(this).getWorld(), Window.get(this).getUsername());
+
+
+ IAlleleSpecies allele = null;
+ EnumDiscoveryState state = null;
+
+ allele = (IAlleleSpecies)((IMutation)getValue()).getAllele0();
+ state = species == allele ? EnumDiscoveryState.Show : (isNEI) || (isMutationDiscovered) ? EnumDiscoveryState.Show : EnumDiscoveryState.Undetermined;
+ this.itemWidget1.setSpecies(allele, state);
+ allele = (IAlleleSpecies)((IMutation)getValue()).getAllele1();
+ state = species == allele ? EnumDiscoveryState.Show : (isNEI) || (isMutationDiscovered) ? EnumDiscoveryState.Show : EnumDiscoveryState.Undetermined;
+ this.itemWidget2.setSpecies(allele, state);
+ allele = (IAlleleSpecies)((IMutation)getValue()).getTemplate()[0];
+ state = species == allele ? EnumDiscoveryState.Show : (isNEI) || (isMutationDiscovered) ? EnumDiscoveryState.Show : EnumDiscoveryState.Undetermined;
+ this.itemWidget3.setSpecies(allele, state);
+ this.addSymbol.setValue((IMutation)getValue());
+ this.arrowSymbol.setValue((IMutation)getValue());
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/ControlMutationSymbol.java b/src/Java/binnie/craftgui/mod/database/ControlMutationSymbol.java
new file mode 100644
index 0000000000..5c8bdc0aed
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/ControlMutationSymbol.java
@@ -0,0 +1,80 @@
+package binnie.craftgui.mod.database;
+
+import binnie.core.genetics.BreedingSystem;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.ITooltip;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.Tooltip;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.resource.Texture;
+import binnie.craftgui.resource.minecraft.CraftGUITextureSheet;
+import binnie.craftgui.resource.minecraft.StandardTexture;
+import forestry.api.genetics.IAllele;
+import forestry.api.genetics.IMutation;
+
+class ControlMutationSymbol
+ extends Control
+ implements ITooltip
+{
+ private static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
+ private static Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
+ private IMutation value;
+ private boolean discovered;
+ private int type;
+
+ public void onRenderBackground()
+ {
+ super.onRenderBackground();
+ if (this.type == 0) {
+ CraftGUI.Render.texture(MutationPlus, IPoint.ZERO);
+ } else {
+ CraftGUI.Render.texture(MutationArrow, IPoint.ZERO);
+ }
+ }
+
+ protected ControlMutationSymbol(IWidget parent, int x, int y, int type)
+ {
+ super(parent, x, y, 16 + type * 16, 16.0F);
+ this.value = null;
+ this.type = type;
+ addAttribute(Attribute.MouseOver);
+ }
+
+ public void setValue(IMutation value)
+ {
+ this.value = value;
+
+ boolean isNEI = ((WindowAbstractDatabase)getSuperParent()).isNEI();
+ BreedingSystem system = ((WindowAbstractDatabase)getSuperParent()).getBreedingSystem();
+
+ this.discovered = (isNEI ? true : system.isMutationDiscovered(value, Window.get(this).getWorld(), Window.get(this).getUsername()));
+ if (this.discovered) {
+ setColour(16777215);
+ } else {
+ setColour(7829367);
+ }
+ }
+
+ public void getTooltip(Tooltip tooltip)
+ {
+ if ((this.type == 1) && (this.discovered))
+ {
+ IAllele species1 = this.value.getAllele0();
+ IAllele species2 = this.value.getAllele1();
+
+ BreedingSystem system = ((WindowAbstractDatabase)getSuperParent()).getBreedingSystem();
+
+ float chance = system.getChance(this.value, Window.get(this).getPlayer(), species1, species2);
+ tooltip.add("Current Chance - " + chance + "%");
+ if (this.value.getSpecialConditions() != null) {
+ for (String string : this.value.getSpecialConditions()) {
+ tooltip.add(string);
+ }
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/ControlSpeciesBox.java b/src/Java/binnie/craftgui/mod/database/ControlSpeciesBox.java
new file mode 100644
index 0000000000..4f184b0064
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/ControlSpeciesBox.java
@@ -0,0 +1,55 @@
+package binnie.craftgui.mod.database;
+
+import binnie.core.genetics.BreedingSystem;
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlListBox;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.minecraft.Window;
+import com.mojang.authlib.GameProfile;
+import forestry.api.genetics.IAlleleSpecies;
+import forestry.api.genetics.IClassification;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import net.minecraft.entity.player.EntityPlayer;
+
+public class ControlSpeciesBox
+ extends ControlListBox<IAlleleSpecies>
+{
+ public IWidget createOption(IAlleleSpecies value, int y)
+ {
+ return new ControlSpeciexBoxOption((ControlList)getContent(), value, y);
+ }
+
+ public ControlSpeciesBox(IWidget parent, float x, float y, float width, float height)
+ {
+ super(parent, x, y, width, height, 12.0F);
+ }
+
+ private IClassification branch = null;
+
+ public void setBranch(IClassification branch)
+ {
+ if (branch != this.branch)
+ {
+ this.branch = branch;
+ List<IAlleleSpecies> speciesList2 = new ArrayList();
+ movePercentage(-100.0F);
+ setOptions(speciesList2);
+
+ EntityPlayer player = Window.get(this).getPlayer();
+ GameProfile playerName = Window.get(this).getUsername();
+ WindowAbstractDatabase db = (WindowAbstractDatabase)Window.get(this);
+
+ Collection<IAlleleSpecies> speciesList = !db.isNEI ? db.getBreedingSystem().getDiscoveredSpecies(db.getWorld(), playerName) : db.getBreedingSystem().getAllSpecies();
+ if (branch != null) {
+ for (IAlleleSpecies species : branch.getMemberSpecies()) {
+ if (speciesList.contains(species)) {
+ speciesList2.add(species);
+ }
+ }
+ }
+ setOptions(speciesList2);
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/ControlSpeciexBoxOption.java b/src/Java/binnie/craftgui/mod/database/ControlSpeciexBoxOption.java
new file mode 100644
index 0000000000..36ac5446b2
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/ControlSpeciexBoxOption.java
@@ -0,0 +1,42 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.listbox.ControlList;
+import binnie.craftgui.controls.listbox.ControlTextOption;
+import binnie.craftgui.core.Attribute;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.geometry.CraftGUIUtil;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.renderer.Renderer;
+import forestry.api.genetics.IAlleleSpecies;
+
+class ControlSpeciexBoxOption
+ extends ControlTextOption<IAlleleSpecies>
+{
+ private ControlDatabaseIndividualDisplay controlBee;
+
+ public ControlSpeciexBoxOption(ControlList<IAlleleSpecies> controlList, IAlleleSpecies option, int y)
+ {
+ super(controlList, option, option.getName(), y);
+ setSize(new IPoint(getSize().x(), 20.0F));
+
+ this.controlBee = new ControlDatabaseIndividualDisplay(this, 2.0F, 2.0F);
+
+ this.controlBee.setSpecies((IAlleleSpecies)getValue(), EnumDiscoveryState.Undetermined);
+ if (this.controlBee.discovered == EnumDiscoveryState.Discovered) {
+ this.controlBee.discovered = EnumDiscoveryState.Show;
+ }
+ this.textWidget.setValue(this.controlBee.discovered == EnumDiscoveryState.Show ? option.getName() : "Undiscovered");
+ if (this.controlBee.discovered == EnumDiscoveryState.Show) {
+ 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)));
+
+ int th = (int)CraftGUI.Render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x());
+ int height = Math.max(20, th + 6);
+ setSize(new IPoint(size().x(), height));
+ this.textWidget.setSize(new IPoint(this.textWidget.getSize().x(), height));
+ this.controlBee.setPosition(new IPoint(this.controlBee.pos().x(), (height - 18) / 2));
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/DatabaseTab.java b/src/Java/binnie/craftgui/mod/database/DatabaseTab.java
new file mode 100644
index 0000000000..aee8ea5bf2
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/DatabaseTab.java
@@ -0,0 +1,32 @@
+package binnie.craftgui.mod.database;
+
+import binnie.Binnie;
+import binnie.core.AbstractMod;
+import binnie.core.language.ManagerLanguage;
+import binnie.craftgui.core.ITooltipHelp;
+import binnie.craftgui.core.Tooltip;
+
+public class DatabaseTab
+ implements ITooltipHelp
+{
+ private AbstractMod mod;
+ private String unloc;
+ private int colour;
+
+ public DatabaseTab(AbstractMod mod, String unloc, int colour)
+ {
+ this.mod = mod;
+ this.unloc = unloc;
+ this.colour = colour;
+ }
+
+ public String toString()
+ {
+ return Binnie.Language.localise(this.mod, "gui.database.tab." + this.unloc);
+ }
+
+ public void getHelpTooltip(Tooltip tooltip)
+ {
+ tooltip.add(Binnie.Language.localiseOrBlank(this.mod, "gui.database.tab." + this.unloc + ".help"));
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/EnumDiscoveryState.java b/src/Java/binnie/craftgui/mod/database/EnumDiscoveryState.java
new file mode 100644
index 0000000000..fe98cff136
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/EnumDiscoveryState.java
@@ -0,0 +1,8 @@
+package binnie.craftgui.mod.database;
+
+public enum EnumDiscoveryState
+{
+ Show, Undetermined, Discovered, Undiscovered;
+
+ private EnumDiscoveryState() {}
+}
diff --git a/src/Java/binnie/craftgui/mod/database/IDatabaseMode.java b/src/Java/binnie/craftgui/mod/database/IDatabaseMode.java
new file mode 100644
index 0000000000..8744a2f0b7
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/IDatabaseMode.java
@@ -0,0 +1,6 @@
+package binnie.craftgui.mod.database;
+
+public abstract interface IDatabaseMode
+{
+ public abstract String getName();
+}
diff --git a/src/Java/binnie/craftgui/mod/database/PageAbstract.java b/src/Java/binnie/craftgui/mod/database/PageAbstract.java
new file mode 100644
index 0000000000..9219dca0a7
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/PageAbstract.java
@@ -0,0 +1,16 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.controls.page.ControlPage;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+
+public abstract class PageAbstract<T>
+ extends ControlPage<DatabaseTab>
+{
+ public PageAbstract(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, 0.0F, 0.0F, parent.getSize().x(), parent.getSize().y(), tab);
+ }
+
+ public abstract void onValueChanged(T paramT);
+}
diff --git a/src/Java/binnie/craftgui/mod/database/PageBranch.java b/src/Java/binnie/craftgui/mod/database/PageBranch.java
new file mode 100644
index 0000000000..57af5128e5
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/PageBranch.java
@@ -0,0 +1,13 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.core.IWidget;
+import forestry.api.genetics.IClassification;
+
+abstract class PageBranch
+ extends PageAbstract<IClassification>
+{
+ public PageBranch(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/PageBranchOverview.java b/src/Java/binnie/craftgui/mod/database/PageBranchOverview.java
new file mode 100644
index 0000000000..57ddc63fab
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/PageBranchOverview.java
@@ -0,0 +1,67 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.renderer.Renderer;
+import forestry.api.genetics.IAlleleSpecies;
+import forestry.api.genetics.IClassification;
+import java.util.ArrayList;
+import java.util.List;
+
+public class PageBranchOverview
+ extends PageBranch
+{
+ private ControlText pageBranchOverview_branchName;
+ private ControlText pageBranchOverview_branchScientific;
+ private ControlText pageBranchOverview_branchAuthority;
+
+ public PageBranchOverview(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+
+ this.pageBranchOverview_branchName = new ControlTextCentered(this, 8.0F, "");
+
+ this.pageBranchOverview_branchScientific = new ControlTextCentered(this, 32.0F, "");
+ this.pageBranchOverview_branchAuthority = new ControlTextCentered(this, 44.0F, "");
+ }
+
+ private List<ControlText> pageBranchOverview_branchDescription = new ArrayList();
+
+ public void onValueChanged(IClassification branch)
+ {
+ this.pageBranchOverview_branchName.setValue("§n" + branch.getName() + " Branch§r");
+
+ this.pageBranchOverview_branchScientific.setValue("§oApidae " + branch.getScientific() + "§r");
+
+ this.pageBranchOverview_branchAuthority.setValue("Discovered by §l" + branch.getMemberSpecies()[0].getAuthority() + "§r");
+ for (IWidget widget : this.pageBranchOverview_branchDescription) {
+ deleteChild(widget);
+ }
+ this.pageBranchOverview_branchDescription.clear();
+
+ String desc = branch.getDescription();
+ if ((desc == null) || (desc == "")) {
+ desc = "No Description Provided.";
+ }
+ String line = "";
+
+ List<String> descLines = new ArrayList();
+ for (String str : desc.split(" "))
+ {
+ if (CraftGUI.Render.textWidth(line + " " + str) > 134)
+ {
+ descLines.add("§o" + line + "§r");
+ line = "";
+ }
+ line = line + " " + str;
+ }
+ descLines.add(line);
+
+ int i = 0;
+ for (String dLine : descLines) {
+ this.pageBranchOverview_branchDescription.add(new ControlTextCentered(this, 84 + 12 * i++, dLine));
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/PageBranchSpecies.java b/src/Java/binnie/craftgui/mod/database/PageBranchSpecies.java
new file mode 100644
index 0000000000..600ca66674
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/PageBranchSpecies.java
@@ -0,0 +1,43 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.events.EventValueChanged;
+import binnie.craftgui.events.EventValueChanged.Handler;
+import cpw.mods.fml.common.Mod.EventHandler;
+import forestry.api.genetics.IAlleleSpecies;
+import forestry.api.genetics.IClassification;
+
+public class PageBranchSpecies
+ extends PageBranch
+{
+ private ControlText pageBranchSpecies_title;
+ private ControlSpeciesBox pageBranchSpecies_speciesList;
+
+ @Mod.EventHandler
+ public void onHandleEvent(EventValueChanged<IAlleleSpecies> event) {}
+
+ public PageBranchSpecies(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+
+ this.pageBranchSpecies_title = new ControlTextCentered(this, 8.0F, "Species");
+
+ addEventHandler(new EventValueChanged.Handler()
+ {
+ public void onEvent(EventValueChanged event)
+ {
+ if (event.isOrigin(PageBranchSpecies.this.pageBranchSpecies_speciesList)) {
+ ((WindowAbstractDatabase)PageBranchSpecies.this.getSuperParent()).gotoSpecies((IAlleleSpecies)event.getValue());
+ }
+ }
+ });
+ this.pageBranchSpecies_speciesList = new ControlSpeciesBox(this, 4.0F, 20.0F, 136.0F, 152.0F);
+ }
+
+ public void onValueChanged(IClassification branch)
+ {
+ this.pageBranchSpecies_speciesList.setBranch(branch);
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/PageBreeder.java b/src/Java/binnie/craftgui/mod/database/PageBreeder.java
new file mode 100644
index 0000000000..d3f0b7b617
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/PageBreeder.java
@@ -0,0 +1,51 @@
+package binnie.craftgui.mod.database;
+
+import binnie.core.genetics.BreedingSystem;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.controls.page.ControlPage;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.minecraft.Window;
+import com.mojang.authlib.GameProfile;
+import java.util.List;
+
+public class PageBreeder
+ extends ControlPage<DatabaseTab>
+{
+ private GameProfile player;
+
+ public PageBreeder(IWidget parent, GameProfile player, DatabaseTab tab)
+ {
+ super(parent, 0.0F, 0.0F, parent.getSize().x(), parent.getSize().y(), tab);
+
+ this.player = player;
+ onPageRefresh();
+ }
+
+ public void onPageRefresh()
+ {
+ while (getWidgets().size() > 0) {
+ deleteChild((IWidget)getWidgets().get(0));
+ }
+ BreedingSystem system = ((WindowAbstractDatabase)Window.get(this)).getBreedingSystem();
+
+ String descriptor = system.getDescriptor();
+
+ new ControlTextCentered(this, 8.0F, "§n" + system.getDescriptor() + " Profile§r");
+
+ new ControlTextCentered(this, 75.0F, "" + system.discoveredSpeciesCount + "/" + system.totalSpeciesCount + " Species");
+
+
+ new ControlBreedingProgress(this, 20, 87, 102, 14, system, system.discoveredSpeciesPercentage);
+
+ new ControlTextCentered(this, 115.0F, "" + system.discoveredBranchCount + "/" + system.totalBranchCount + " Branches");
+
+
+ new ControlBreedingProgress(this, 20, 127, 102, 14, system, system.discoveredBranchPercentage);
+ if (system.discoveredSecretCount > 0) {
+ new ControlTextCentered(this, 155.0F, "" + system.discoveredSecretCount + "/" + system.totalSecretCount + " Secret Species");
+ }
+ new ControlTextCentered(this, 32.0F, this.player.getName());
+ new ControlTextCentered(this, 44.0F, "§o" + system.getEpitome() + "§r");
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/PageBreederStats.java b/src/Java/binnie/craftgui/mod/database/PageBreederStats.java
new file mode 100644
index 0000000000..18c1f288d5
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/PageBreederStats.java
@@ -0,0 +1,23 @@
+package binnie.craftgui.mod.database;
+
+import binnie.core.genetics.BreedingSystem;
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.IWidget;
+
+public class PageBreederStats
+ extends Control
+{
+ String player;
+
+ public PageBreederStats(IWidget parent, int w, int h, String player)
+ {
+ super(parent, 0.0F, 0.0F, w, h);
+ this.player = player;
+
+ ControlText pageBranchOverview_branchName = new ControlTextCentered(this, 8.0F, "§nStats§r");
+
+ BreedingSystem system = ((WindowAbstractDatabase)getSuperParent()).getBreedingSystem();
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/PageSpecies.java b/src/Java/binnie/craftgui/mod/database/PageSpecies.java
new file mode 100644
index 0000000000..c94984bd3a
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/PageSpecies.java
@@ -0,0 +1,13 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.core.IWidget;
+import forestry.api.genetics.IAlleleSpecies;
+
+public abstract class PageSpecies
+ extends PageAbstract<IAlleleSpecies>
+{
+ public PageSpecies(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/PageSpeciesClassification.java b/src/Java/binnie/craftgui/mod/database/PageSpeciesClassification.java
new file mode 100644
index 0000000000..3db09e32cf
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/PageSpeciesClassification.java
@@ -0,0 +1,54 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.core.IWidget;
+import forestry.api.genetics.IAlleleSpecies;
+import forestry.api.genetics.IClassification;
+import forestry.api.genetics.IClassification.EnumClassLevel;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class PageSpeciesClassification
+ extends PageSpecies
+{
+ private Map<IClassification.EnumClassLevel, ControlText> levels = new LinkedHashMap();
+ private ControlText genus;
+
+ public PageSpeciesClassification(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+ int y = 16;
+ for (IClassification.EnumClassLevel level : IClassification.EnumClassLevel.values())
+ {
+ ControlText text = new ControlTextCentered(this, y, "");
+ text.setColour(level.getColour());
+ this.levels.put(level, text);
+ y += 12;
+ }
+ this.genus = new ControlTextCentered(this, y, "");
+ this.genus.setColour(16759415);
+ }
+
+ public void onValueChanged(IAlleleSpecies species)
+ {
+ if (species != null)
+ {
+ for (ControlText text : this.levels.values()) {
+ text.setValue("- - -");
+ }
+ this.genus.setValue(species.getBinomial());
+
+ IClassification classification = species.getBranch();
+ while (classification != null)
+ {
+ IClassification.EnumClassLevel level = classification.getLevel();
+ String text = "";
+ int n = level.ordinal();
+ text = text + classification.getScientific();
+ ((ControlText)this.levels.get(level)).setValue(text);
+ classification = classification.getParent();
+ }
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/PageSpeciesMutations.java b/src/Java/binnie/craftgui/mod/database/PageSpeciesMutations.java
new file mode 100644
index 0000000000..16a6e6673a
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/PageSpeciesMutations.java
@@ -0,0 +1,27 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.core.IWidget;
+import forestry.api.genetics.IAlleleSpecies;
+
+public class PageSpeciesMutations
+ extends PageSpecies
+{
+ private ControlText pageSpeciesFurther_Title;
+ private ControlMutationBox pageSpeciesFurther_List;
+
+ public PageSpeciesMutations(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+
+ this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8.0F, "Further Mutations");
+
+ this.pageSpeciesFurther_List = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.Further);
+ }
+
+ public void onValueChanged(IAlleleSpecies species)
+ {
+ this.pageSpeciesFurther_List.setSpecies(species);
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/PageSpeciesOverview.java b/src/Java/binnie/craftgui/mod/database/PageSpeciesOverview.java
new file mode 100644
index 0000000000..083162e902
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/PageSpeciesOverview.java
@@ -0,0 +1,88 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.TextJustification;
+import binnie.craftgui.core.renderer.Renderer;
+import forestry.api.genetics.IAlleleSpecies;
+import forestry.api.genetics.IClassification;
+
+public class PageSpeciesOverview
+ extends PageSpecies
+{
+ private ControlText controlName;
+ private ControlText controlScientific;
+ private ControlText controlAuthority;
+ private ControlText controlComplexity;
+ private ControlText controlDescription;
+ private ControlText controlSignature;
+ private ControlDatabaseIndividualDisplay controlInd1;
+ private ControlDatabaseIndividualDisplay controlInd2;
+
+ public PageSpeciesOverview(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+
+ this.controlInd1 = new ControlDatabaseIndividualDisplay(this, 5.0F, 5.0F);
+ this.controlInd2 = new ControlDatabaseIndividualDisplay(this, 123.0F, 5.0F);
+
+ this.controlName = new ControlTextCentered(this, 8.0F, "");
+
+ this.controlScientific = new ControlTextCentered(this, 32.0F, "");
+ this.controlAuthority = new ControlTextCentered(this, 44.0F, "");
+ this.controlComplexity = new ControlTextCentered(this, 56.0F, "");
+
+ this.controlDescription = new ControlText(this, new IArea(8.0F, 84.0F, getSize().x() - 16.0F, 0.0F), "", TextJustification.MiddleCenter);
+
+ this.controlSignature = new ControlText(this, new IArea(8.0F, 84.0F, getSize().x() - 16.0F, 0.0F), "", TextJustification.BottomRight);
+ }
+
+ public void onValueChanged(IAlleleSpecies species)
+ {
+ this.controlInd1.setSpecies(species, EnumDiscoveryState.Show);
+ this.controlInd2.setSpecies(species, EnumDiscoveryState.Show);
+ String branchBinomial = species.getBranch() != null ? species.getBranch().getScientific() : "<Unknown>";
+
+ String branchName = species.getBranch() != null ? species.getBranch().getName() : "Unknown";
+
+
+ this.controlName.setValue("§n" + species.getName() + "§r");
+ this.controlScientific.setValue("§o" + branchBinomial + " " + species.getBinomial() + "§r");
+
+ this.controlAuthority.setValue("Discovered by §l" + species.getAuthority() + "§r");
+
+ this.controlComplexity.setValue("Complexity: " + species.getComplexity());
+
+
+
+ String desc = species.getDescription();
+
+ String descBody = "§o";
+ String descSig = "";
+ if ((desc == null) || (desc == ""))
+ {
+ descBody = descBody + "No Description Provided.";
+ }
+ else
+ {
+ String[] descStrings = desc.split("\\|");
+ descBody = descBody + descStrings[0];
+ for (int i = 1; i < descStrings.length - 1; i++) {
+ descBody = descBody + " " + descStrings[i];
+ }
+ if (descStrings.length > 1) {
+ descSig = descSig + descStrings[(descStrings.length - 1)];
+ }
+ }
+ this.controlDescription.setValue(descBody + "§r");
+ this.controlSignature.setValue(descSig + "§r");
+
+ float descHeight = CraftGUI.Render.textHeight(this.controlDescription.getValue(), this.controlDescription.getSize().x());
+
+ this.controlSignature.setPosition(new IPoint(this.controlSignature.pos().x(), this.controlDescription.getPosition().y() + descHeight + 10.0F));
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/PageSpeciesResultant.java b/src/Java/binnie/craftgui/mod/database/PageSpeciesResultant.java
new file mode 100644
index 0000000000..f6f2d487c0
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/PageSpeciesResultant.java
@@ -0,0 +1,27 @@
+package binnie.craftgui.mod.database;
+
+import binnie.craftgui.controls.ControlText;
+import binnie.craftgui.controls.ControlTextCentered;
+import binnie.craftgui.core.IWidget;
+import forestry.api.genetics.IAlleleSpecies;
+
+public class PageSpeciesResultant
+ extends PageSpecies
+{
+ private ControlText pageSpeciesResultant_Title;
+ private ControlMutationBox pageSpeciesResultant_List;
+
+ public PageSpeciesResultant(IWidget parent, DatabaseTab tab)
+ {
+ super(parent, tab);
+
+ this.pageSpeciesResultant_Title = new ControlTextCentered(this, 8.0F, "Resultant Mutations");
+
+ this.pageSpeciesResultant_List = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.Resultant);
+ }
+
+ public void onValueChanged(IAlleleSpecies species)
+ {
+ this.pageSpeciesResultant_List.setSpecies(species);
+ }
+}
diff --git a/src/Java/binnie/craftgui/mod/database/WindowAbstractDatabase.java b/src/Java/binnie/craftgui/mod/database/WindowAbstractDatabase.java
new file mode 100644
index 0000000000..54ca5a4aca
--- /dev/null
+++ b/src/Java/binnie/craftgui/mod/database/WindowAbstractDatabase.java
@@ -0,0 +1,314 @@
+package binnie.craftgui.mod.database;
+
+import binnie.core.BinnieCore;
+import binnie.core.genetics.BreedingSystem;
+import binnie.core.proxy.BinnieProxy;
+import binnie.core.util.IValidator;
+import binnie.craftgui.controls.ControlTextEdit;
+import binnie.craftgui.controls.listbox.ControlListBox;
+import binnie.craftgui.controls.listbox.ControlTextOption;
+import binnie.craftgui.controls.page.ControlPage;
+import binnie.craftgui.controls.page.ControlPages;
+import binnie.craftgui.controls.tab.ControlTab;
+import binnie.craftgui.controls.tab.ControlTabBar;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.CraftGUIUtil;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IPoint;
+import binnie.craftgui.core.geometry.Position;
+import binnie.craftgui.events.EventHandler.Origin;
+import binnie.craftgui.events.EventTextEdit;
+import binnie.craftgui.events.EventTextEdit.Handler;
+import binnie.craftgui.events.EventValueChanged;
+import binnie.craftgui.events.EventValueChanged.Handler;
+import binnie.craftgui.minecraft.MinecraftGUI.PanelType;
+import binnie.craftgui.minecraft.Window;
+import binnie.craftgui.minecraft.control.ControlHelp;
+import binnie.craftgui.window.Panel;
+import com.mojang.authlib.GameProfile;
+import cpw.mods.fml.relauncher.Side;
+import forestry.api.genetics.IAlleleSpecies;
+import forestry.api.genetics.IBreedingTracker;
+import forestry.api.genetics.IClassification;
+import forestry.api.genetics.ISpeciesRoot;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import net.minecraft.entity.player.EntityPlayer;
+
+public abstract class WindowAbstractDatabase
+ extends Window
+{
+ private float selectionBoxWidth = 95.0F;
+ private final float infoBoxWidth = 144.0F;
+ private final float infoBoxHeight = 176.0F;
+ private final float infoTabWidth = 16.0F;
+ private final float modeTabWidth = 22.0F;
+ private final float searchBoxHeight = 16.0F;
+
+ public void changeMode(IDatabaseMode mode)
+ {
+ this.modePages.setValue(mode);
+ }
+
+ public WindowAbstractDatabase(EntityPlayer player, Side side, boolean nei, BreedingSystem system, float wid)
+ {
+ super(100.0F, 192.0F, player, null, side);
+ this.isNEI = nei;
+ this.system = system;
+ this.selectionBoxWidth = wid;
+ }
+
+ public static enum Mode
+ implements IDatabaseMode
+ {
+ Species, Branches, Breeder;
+
+ private Mode() {}
+
+ public String getName()
+ {
+ return BinnieCore.proxy.localise("gui.database.mode." + name().toLowerCase());
+ }
+ }
+
+ public static abstract class ModeWidgets
+ {
+ public WindowAbstractDatabase database;
+ public ControlPage<IDatabaseMode> modePage;
+ private ControlPages<DatabaseTab> infoPages;
+ public ControlListBox listBox;
+ private ControlTabBar<DatabaseTab> infoTabs;
+
+ public ModeWidgets(IDatabaseMode mode, WindowAbstractDatabase database)
+ {
+ this.database = database;
+ this.modePage = new ControlPage(database.modePages, 0.0F, 0.0F, database.getSize().x(), database.getSize().y(), mode);
+
+ IArea listBoxArea = database.panelSearch.area().inset(2);
+
+ createListBox(listBoxArea);
+
+ CraftGUIUtil.alignToWidget(this.listBox, database.panelSearch);
+ CraftGUIUtil.moveWidget(this.listBox, new IPoint(2.0F, 2.0F));
+
+ this.infoPages = new ControlPages(this.modePage, 0.0F, 0.0F, 144.0F, 176.0F);
+
+ CraftGUIUtil.alignToWidget(this.infoPages, database.panelInformation);
+ }
+
+ public abstract void createListBox(IArea paramIArea);
+ }
+
+ public ControlPages<DatabaseTab> getInfoPages(IDatabaseMode mode)
+ {
+ return ((ModeWidgets)this.modes.get(mode)).infoPages;
+ }
+
+ private Map<IDatabaseMode, ModeWidgets> modes = new HashMap();
+ boolean isNEI;
+ private BreedingSystem system;
+
+ public boolean isNEI()
+ {
+ return this.isNEI;
+ }
+
+ public BreedingSystem getBreedingSystem()
+ {
+ return this.system;
+ }
+
+ public WindowAbstractDatabase(EntityPlayer player, Side side, boolean nei, BreedingSystem system)
+ {
+ this(player, side, nei, system, 95.0F);
+ }
+
+ private Panel panelInformation = null;
+ private Panel panelSearch = null;
+ private ControlPages<IDatabaseMode> modePages = null;
+
+ protected ModeWidgets createMode(IDatabaseMode mode, ModeWidgets widgets)
+ {
+ this.modes.put(mode, widgets);
+
+ return widgets;
+ }
+
+ public void initialiseClient()
+ {
+ setSize(new IPoint(176.0F + this.selectionBoxWidth + 22.0F + 8.0F, 208.0F));
+
+ addEventHandler(new EventValueChanged.Handler()
+ {
+ public void onEvent(EventValueChanged event)
+ {
+ if (((event.getOrigin().getParent() instanceof ControlPage)) && (!(event.getValue() instanceof DatabaseTab)))
+ {
+ ControlPage parent = (ControlPage)event.getOrigin().getParent();
+ if ((parent.getValue() instanceof IDatabaseMode)) {
+ for (IWidget widget : parent.getWidgets()) {
+ if ((widget instanceof ControlPages)) {
+ if (event.getValue() == null)
+ {
+ widget.hide();
+ }
+ else
+ {
+ widget.show();
+ for (IWidget widget2 : widget.getWidgets()) {
+ if ((widget2 instanceof PageAbstract)) {
+ ((PageAbstract)widget2).onValueChanged(event.getValue());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ });
+ addEventHandler(new EventTextEdit.Handler()
+ {
+ public void onEvent(final EventTextEdit event)
+ {
+ for (WindowAbstractDatabase.ModeWidgets widgets : WindowAbstractDatabase.this.modes.values()) {
+ widgets.listBox.setValidator(new IValidator()
+ {
+ public boolean isValid(IWidget object)
+ {
+ return (event.getValue() == "") || (((ControlTextOption)object).getText().toLowerCase().contains(((String)event.getValue()).toLowerCase()));
+ }
+ });
+ }
+ }
+ }.setOrigin(EventHandler.Origin.DirectChild, this));
+
+
+
+
+
+
+
+
+
+
+
+
+ new ControlHelp(this, 4.0F, 4.0F);
+
+ this.panelInformation = new Panel(this, 24.0F, 24.0F, 144.0F, 176.0F, MinecraftGUI.PanelType.Black);
+ this.panelInformation.setColour(860416);
+
+ this.panelSearch = new Panel(this, 176.0F, 24.0F, this.selectionBoxWidth, 160.0F, MinecraftGUI.PanelType.Black);
+
+ this.panelSearch.setColour(860416);
+
+ this.modePages = new ControlPages(this, 0.0F, 0.0F, getSize().x(), getSize().y());
+
+ new ControlTextEdit(this, 176.0F, 184.0F, this.selectionBoxWidth, 16.0F);
+
+
+ createMode(Mode.Species, new ModeWidgets(Mode.Species, this)
+ {
+ public void createListBox(IArea area)
+ {
+ GameProfile playerName = WindowAbstractDatabase.this.getUsername();
+
+ Collection<IAlleleSpecies> speciesList = !this.database.isNEI ? this.database.system.getDiscoveredSpecies(this.database.getWorld(), playerName) : this.database.system.getAllSpecies();
+
+
+ this.listBox = new ControlSpeciesBox(this.modePage, area.x(), area.y(), area.w(), area.h());
+ this.listBox.setOptions(speciesList);
+ }
+ });
+ createMode(Mode.Branches, new ModeWidgets(Mode.Branches, this)
+ {
+ public void createListBox(IArea area)
+ {
+ EntityPlayer player = this.database.getPlayer();
+ GameProfile playerName = WindowAbstractDatabase.this.getUsername();
+
+ Collection<IClassification> speciesList = !this.database.isNEI ? this.database.system.getDiscoveredBranches(this.database.getWorld(), playerName) : this.database.system.getAllBranches();
+
+
+ this.listBox = new ControlBranchBox(this.modePage, area.x(), area.y(), area.w(), area.h());
+ this.listBox.setOptions(speciesList);
+ }
+ });
+ createMode(Mode.Breeder, new ModeWidgets(Mode.Breeder, this)
+ {
+ public void createListBox(IArea area)
+ {
+ this.listBox = new ControlListBox(this.modePage, area.x(), area.y(), area.w(), area.h(), 12.0F);
+ }
+ });
+ addTabs();
+
+ ControlTabBar<IDatabaseMode> tab = new ControlTabBar(this, 176.0F + this.selectionBoxWidth, 24.0F, 22.0F, 176.0F, Position.Right)
+ {
+ public ControlTab<IDatabaseMode> createTab(float x, float y, float w, float h, IDatabaseMode value)
+ {
+ new ControlTab(this, x, y, w, h, value)
+ {
+ public String getName()
+ {
+ return ((IDatabaseMode)this.value).getName();
+ }
+ };
+ }
+ };
+ tab.setValues(this.modePages.getValues());
+
+ CraftGUIUtil.linkWidgets(tab, this.modePages);
+
+
+ changeMode(Mode.Species);
+ for (IDatabaseMode mode : this.modes.keySet())
+ {
+ ((ModeWidgets)this.modes.get(mode)).infoTabs = new ControlTabBar(((ModeWidgets)this.modes.get(mode)).modePage, 8.0F, 24.0F, 16.0F, 176.0F, Position.Left);
+
+
+ ((ModeWidgets)this.modes.get(mode)).infoTabs.setValues(((ModeWidgets)this.modes.get(mode)).infoPages.getValues());
+
+ CraftGUIUtil.linkWidgets(((ModeWidgets)this.modes.get(mode)).infoTabs, ((ModeWidgets)this.modes.get(mode)).infoPages);
+ }
+ }
+
+ public void initialiseServer()
+ {
+ IBreedingTracker tracker = this.system.getSpeciesRoot().getBreedingTracker(getWorld(), getUsername());
+ if (tracker != null) {
+ tracker.synchToPlayer(getPlayer());
+ }
+ }
+
+ protected void addTabs() {}
+
+ public void gotoSpecies(IAlleleSpecies value)
+ {
+ if (value != null)
+ {
+ this.modePages.setValue(Mode.Species);
+ changeMode(Mode.Species);
+ ((ModeWidgets)this.modes.get(this.modePages.getValue())).listBox.setValue(value);
+ }
+ }
+
+ public void gotoSpeciesDelayed(IAlleleSpecies species)
+ {
+ this.gotoSpecies = species;
+ }
+
+ private IAlleleSpecies gotoSpecies = null;
+
+ public void onUpdateClient()
+ {
+ super.onUpdateClient();
+ if (this.gotoSpecies != null)
+ {
+ ((WindowAbstractDatabase)getSuperParent()).gotoSpecies(this.gotoSpecies);
+ this.gotoSpecies = null;
+ }
+ }
+}
diff --git a/src/Java/binnie/craftgui/resource/IStyleSheet.java b/src/Java/binnie/craftgui/resource/IStyleSheet.java
new file mode 100644
index 0000000000..1ce8e7da2c
--- /dev/null
+++ b/src/Java/binnie/craftgui/resource/IStyleSheet.java
@@ -0,0 +1,6 @@
+package binnie.craftgui.resource;
+
+public abstract interface IStyleSheet
+{
+ public abstract Texture getTexture(Object paramObject);
+}
diff --git a/src/Java/binnie/craftgui/resource/StyleSheet.java b/src/Java/binnie/craftgui/resource/StyleSheet.java
new file mode 100644
index 0000000000..8685abd5be
--- /dev/null
+++ b/src/Java/binnie/craftgui/resource/StyleSheet.java
@@ -0,0 +1,18 @@
+package binnie.craftgui.resource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class StyleSheet
+ implements IStyleSheet
+{
+ protected Map<Object, Texture> textures = new HashMap();
+
+ public Texture getTexture(Object key)
+ {
+ if (!this.textures.containsKey(key)) {
+ return StyleSheetManager.getTexture(key);
+ }
+ return (Texture)this.textures.get(key);
+ }
+}
diff --git a/src/Java/binnie/craftgui/resource/StyleSheetManager.java b/src/Java/binnie/craftgui/resource/StyleSheetManager.java
new file mode 100644
index 0000000000..b1bbd50272
--- /dev/null
+++ b/src/Java/binnie/craftgui/resource/StyleSheetManager.java
@@ -0,0 +1,28 @@
+package binnie.craftgui.resource;
+
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.resource.minecraft.CraftGUIResourceManager;
+
+public class StyleSheetManager
+{
+ static IStyleSheet defaultSS = new DefaultStyleSheet(null);
+
+ public static Texture getTexture(Object key)
+ {
+ return defaultSS.getTexture(key);
+ }
+
+ private static class DefaultStyleSheet
+ implements IStyleSheet
+ {
+ public Texture getTexture(Object key)
+ {
+ return CraftGUI.ResourceManager.getTexture(key.toString());
+ }
+ }
+
+ public static IStyleSheet getDefault()
+ {
+ return defaultSS;
+ }
+}
diff --git a/src/Java/binnie/craftgui/resource/Texture.java b/src/Java/binnie/craftgui/resource/Texture.java
new file mode 100644
index 0000000000..249be8f257
--- /dev/null
+++ b/src/Java/binnie/craftgui/resource/Texture.java
@@ -0,0 +1,128 @@
+package binnie.craftgui.resource;
+
+import binnie.core.resource.BinnieResource;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IBorder;
+import binnie.craftgui.core.geometry.Position;
+
+public class Texture
+{
+ public static final Texture NULL = null;
+ IArea area;
+ IBorder padding = IBorder.ZERO;
+ IBorder border = IBorder.ZERO;
+ BinnieResource filename;
+
+ public Texture(IArea area, BinnieResource filename)
+ {
+ this(area, IBorder.ZERO, IBorder.ZERO, filename);
+ }
+
+ public Texture(IArea area, IBorder padding, BinnieResource filename)
+ {
+ this(area, padding, IBorder.ZERO, filename);
+ }
+
+ public Texture(IArea area, IBorder padding, IBorder border, BinnieResource filename)
+ {
+ this.area = new IArea(area);
+ this.padding = new IBorder(padding);
+ this.border = new IBorder(border);
+ this.filename = filename;
+ }
+
+ public IArea getArea()
+ {
+ return this.area;
+ }
+
+ public IBorder getPadding()
+ {
+ return this.padding;
+ }
+
+ public IBorder getBorder()
+ {
+ return this.border;
+ }
+
+ public BinnieResource getFilename()
+ {
+ return this.filename;
+ }
+
+ public IBorder getTotalPadding()
+ {
+ return this.padding.add(this.border);
+ }
+
+ public float w()
+ {
+ return getArea().w();
+ }
+
+ public float h()
+ {
+ return getArea().h();
+ }
+
+ public float u()
+ {
+ return getArea().x();
+ }
+
+ public float v()
+ {
+ return getArea().y();
+ }
+
+ public Texture crop(Position anchor, float dist)
+ {
+ return crop(new IBorder(anchor.opposite(), dist));
+ }
+
+ public Texture crop(IBorder crop)
+ {
+ Texture copy = new Texture(this.area, this.padding, this.border, this.filename);
+ if (crop.b() > 0.0F)
+ {
+ copy.border.b(0.0F);
+ copy.padding.b(copy.padding.b() - Math.min(crop.b(), copy.padding.b()));
+ copy.area.h(copy.area.h() - crop.b());
+ }
+ if (crop.t() > 0.0F)
+ {
+ copy.border.t(0.0F);
+ copy.padding.t(copy.padding.t() - Math.min(crop.t(), copy.padding.t()));
+ copy.area.h(copy.area.h() - crop.t());
+ copy.area.y(copy.area.y() + crop.t());
+ }
+ if (crop.r() > 0.0F)
+ {
+ copy.border.r(0.0F);
+ copy.padding.r(copy.padding.r() - Math.min(crop.r(), copy.padding.r()));
+ copy.area.w(copy.area.w() - crop.r());
+ }
+ if (crop.l() > 0.0F)
+ {
+ copy.border.l(0.0F);
+ copy.padding.l(copy.padding.l() - Math.min(crop.l(), copy.padding.l()));
+ copy.area.w(copy.area.w() - crop.l());
+ copy.area.x(copy.area.x() + crop.l());
+ }
+ return copy;
+ }
+
+ public String toString()
+ {
+ String out = "Texture[";
+ out = out + this.area.toString();
+ if (!this.padding.isNonZero()) {
+ out = out + " padding:" + this.padding.toString();
+ }
+ if (!this.border.isNonZero()) {
+ out = out + " border:" + this.border.toString();
+ }
+ return out + "]";
+ }
+}
diff --git a/src/Java/binnie/craftgui/resource/minecraft/CraftGUIResourceManager.java b/src/Java/binnie/craftgui/resource/minecraft/CraftGUIResourceManager.java
new file mode 100644
index 0000000000..42ff445f92
--- /dev/null
+++ b/src/Java/binnie/craftgui/resource/minecraft/CraftGUIResourceManager.java
@@ -0,0 +1,155 @@
+package binnie.craftgui.resource.minecraft;
+
+import binnie.core.resource.IBinnieTexture;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IBorder;
+import binnie.craftgui.resource.Texture;
+import com.google.common.base.Charsets;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonParser;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import net.minecraft.client.resources.IResource;
+import net.minecraft.client.resources.IResourceManager;
+import net.minecraft.client.resources.IResourceManagerReloadListener;
+import net.minecraft.util.ResourceLocation;
+import org.apache.commons.io.IOUtils;
+
+@SideOnly(Side.CLIENT)
+public class CraftGUIResourceManager
+ implements IResourceManagerReloadListener
+{
+ private Map<String, ParsedTextureSheet> textureSheets = new HashMap();
+ private Map<String, Texture> textures = new HashMap();
+
+ public CraftGUIResourceManager()
+ {
+ binnie.craftgui.core.CraftGUI.ResourceManager = this;
+ }
+
+ public void onResourceManagerReload(IResourceManager manager)
+ {
+ this.textureSheets.clear();
+ try
+ {
+ IResource res = manager.getResource(new ResourceLocation("binniecore", "gui/stylesheet.json"));
+
+ JsonObject jsonobject = null;
+ BufferedReader bufferedreader = null;
+ try
+ {
+ bufferedreader = new BufferedReader(new InputStreamReader(res.getInputStream(), Charsets.UTF_8));
+ jsonobject = new JsonParser().parse(bufferedreader).getAsJsonObject();
+ for (JsonElement el : jsonobject.get("texture-sheets").getAsJsonArray()) {
+ if ((el instanceof JsonObject))
+ {
+ JsonObject sheet = (JsonObject)el;
+ String name = sheet.get("name").getAsString();
+ String modid = sheet.get("modid").getAsString();
+ String path = sheet.get("path").getAsString();
+ this.textureSheets.put(name, new ParsedTextureSheet(name, modid, path));
+ }
+ }
+ for (JsonElement el : jsonobject.get("textures").getAsJsonArray()) {
+ if ((el instanceof JsonObject))
+ {
+ JsonObject sheet = (JsonObject)el;
+ String name = sheet.get("name").getAsString();
+ IBinnieTexture textureSheet = getTextureSheet(sheet.get("sheet").getAsString());
+ IArea uv = getArea(sheet.get("uv").getAsString());
+ IBorder border = IBorder.ZERO;
+ IBorder padding = IBorder.ZERO;
+ if (sheet.has("border")) {
+ border = getBorder(sheet.get("border").getAsString());
+ }
+ if (sheet.has("padding")) {
+ padding = getBorder(sheet.get("padding").getAsString());
+ }
+ this.textures.put(name, new Texture(uv, padding, border, textureSheet.getTexture()));
+ }
+ }
+ }
+ catch (RuntimeException runtimeexception)
+ {
+ throw new JsonParseException("Failed to parse stylesheet for Binnie's Mods", runtimeexception);
+ }
+ finally
+ {
+ IOUtils.closeQuietly(bufferedreader);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Failed to load default stylesheet for Binnie's Mods.", e);
+ }
+ }
+
+ public IArea getArea(String name)
+ {
+ String[] split = name.split(" ");
+ if ((split.length < 1) || (split.length > 4)) {
+ throw new RuntimeException("Parameter must have between one and four numbers");
+ }
+ List<Float> f = new ArrayList();
+ for (String string : split) {
+ f.add(Float.valueOf(Float.parseFloat(string)));
+ }
+ if (f.size() == 1) {
+ return new IArea(((Float)f.get(0)).floatValue());
+ }
+ if (f.size() == 2) {
+ return new IArea(((Float)f.get(0)).floatValue(), ((Float)f.get(1)).floatValue());
+ }
+ if (f.size() == 3) {
+ return new IArea(((Float)f.get(0)).floatValue(), ((Float)f.get(1)).floatValue(), ((Float)f.get(2)).floatValue());
+ }
+ return new IArea(((Float)f.get(0)).floatValue(), ((Float)f.get(1)).floatValue(), ((Float)f.get(2)).floatValue(), ((Float)f.get(3)).floatValue());
+ }
+
+ public IBorder getBorder(String name)
+ {
+ String[] split = name.split(" ");
+ if ((split.length < 1) || (split.length > 4)) {
+ throw new RuntimeException("Parameter must have between one and four numbers");
+ }
+ List<Float> f = new ArrayList();
+ for (String string : split) {
+ f.add(Float.valueOf(Float.parseFloat(string)));
+ }
+ if (f.size() == 1) {
+ return new IBorder(((Float)f.get(0)).floatValue());
+ }
+ if (f.size() == 2) {
+ return new IBorder(((Float)f.get(0)).floatValue(), ((Float)f.get(1)).floatValue());
+ }
+ if (f.size() == 3) {
+ return new IBorder(((Float)f.get(0)).floatValue(), ((Float)f.get(1)).floatValue(), ((Float)f.get(2)).floatValue());
+ }
+ return new IBorder(((Float)f.get(0)).floatValue(), ((Float)f.get(1)).floatValue(), ((Float)f.get(2)).floatValue(), ((Float)f.get(3)).floatValue());
+ }
+
+ public IBinnieTexture getTextureSheet(String name)
+ {
+ if (!this.textureSheets.containsKey(name)) {
+ throw new RuntimeException("Missing GUI texture sheet for Binnie Mods: " + name);
+ }
+ return (IBinnieTexture)this.textureSheets.get(name);
+ }
+
+ public Texture getTexture(String name)
+ {
+ if (!this.textures.containsKey(name)) {
+ throw new RuntimeException("Missing GUI texture Binnie Mods: " + name);
+ }
+ return (Texture)this.textures.get(name);
+ }
+}
diff --git a/src/Java/binnie/craftgui/resource/minecraft/CraftGUITexture.java b/src/Java/binnie/craftgui/resource/minecraft/CraftGUITexture.java
new file mode 100644
index 0000000000..cb1ca27bd5
--- /dev/null
+++ b/src/Java/binnie/craftgui/resource/minecraft/CraftGUITexture.java
@@ -0,0 +1,18 @@
+package binnie.craftgui.resource.minecraft;
+
+public enum CraftGUITexture
+{
+ Window("window"), PanelGray("panel.gray"), PanelBlack("panel.black"), PanelTinted("panel.tinted"), ButtonDisabled("button.disabled"), Button("button"), ButtonHighlighted("button.highlighted"), Slot("slot"), SlotBorder("slot.border"), SlotOverlay("slot.overlay"), SlotCharge("slot.charge"), LiquidTank("liquidtank"), LiquidTankOverlay("liquidtank.overlay"), StateError("errorstate.error"), StateWarning("errorstate.warning"), StateNone("errorstate.none"), EnergyBarBack("energybar.back"), EnergyBarGlow("energybar.glow"), EnergyBarGlass("energybar.glass"), TabDisabled("tab.disabled"), Tab("tab"), TabHighlighted("tab.highlighted"), TabOutline("tab.outline"), TabSolid("tab.solid"), ScrollDisabled("scroll.disabled"), Scroll("scroll"), ScrollHighlighted("scroll.highlighted"), Outline("outline"), HelpButton("button.help"), InfoButton("button.info"), UserButton("button.user"), PowerButton("button.power"), HorizontalLiquidTank("horizontalliquidtank"), HorizontalLiquidTankOverlay("horizontalliquidtank.overlay"), SlideUp("slide.up"), SlideDown("slide.down"), SlideLeft("slide.left"), SlideRight("slide.right"), Checkbox("checkbox"), CheckboxHighlighted("checkbox.highlighted"), CheckboxChecked("checkbox.checked"), CheckboxCheckedHighlighted("checkbox.checked.highlighted");
+
+ String name;
+
+ private CraftGUITexture(String name)
+ {
+ this.name = name;
+ }
+
+ public String toString()
+ {
+ return this.name;
+ }
+}
diff --git a/src/Java/binnie/craftgui/resource/minecraft/CraftGUITextureSheet.java b/src/Java/binnie/craftgui/resource/minecraft/CraftGUITextureSheet.java
new file mode 100644
index 0000000000..816a422749
--- /dev/null
+++ b/src/Java/binnie/craftgui/resource/minecraft/CraftGUITextureSheet.java
@@ -0,0 +1,33 @@
+package binnie.craftgui.resource.minecraft;
+
+import binnie.core.BinnieCore;
+import binnie.core.proxy.BinnieProxy;
+import binnie.core.resource.BinnieResource;
+import binnie.core.resource.IBinnieTexture;
+import binnie.craftgui.core.CraftGUI;
+
+public enum CraftGUITextureSheet
+ implements IBinnieTexture
+{
+ Controls2("controls"), Panel2("panels"), Slots("slots");
+
+ String name;
+
+ private CraftGUITextureSheet(String name)
+ {
+ this.name = name;
+ }
+
+ public String toString()
+ {
+ return this.name;
+ }
+
+ public BinnieResource getTexture()
+ {
+ if (BinnieCore.proxy.isServer()) {
+ return null;
+ }
+ return CraftGUI.ResourceManager.getTextureSheet(this.name).getTexture();
+ }
+}
diff --git a/src/Java/binnie/craftgui/resource/minecraft/PaddedTexture.java b/src/Java/binnie/craftgui/resource/minecraft/PaddedTexture.java
new file mode 100644
index 0000000000..a682d0b37d
--- /dev/null
+++ b/src/Java/binnie/craftgui/resource/minecraft/PaddedTexture.java
@@ -0,0 +1,21 @@
+package binnie.craftgui.resource.minecraft;
+
+import binnie.core.resource.BinnieResource;
+import binnie.core.resource.IBinnieTexture;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IBorder;
+import binnie.craftgui.resource.Texture;
+
+public class PaddedTexture
+ extends Texture
+{
+ public PaddedTexture(int u, int v, int w, int h, int offset, IBinnieTexture textureFile, int leftPadding, int rightPadding, int topPadding, int bottomPadding)
+ {
+ this(u, v, w, h, offset, textureFile.getTexture(), leftPadding, rightPadding, topPadding, bottomPadding);
+ }
+
+ public PaddedTexture(int u, int v, int w, int h, int offset, BinnieResource textureFile, int leftPadding, int rightPadding, int topPadding, int bottomPadding)
+ {
+ super(new IArea(u, v, w, h), new IBorder(topPadding, rightPadding, bottomPadding, leftPadding), new IBorder(offset), textureFile);
+ }
+}
diff --git a/src/Java/binnie/craftgui/resource/minecraft/ParsedTextureSheet.java b/src/Java/binnie/craftgui/resource/minecraft/ParsedTextureSheet.java
new file mode 100644
index 0000000000..4a10017b7c
--- /dev/null
+++ b/src/Java/binnie/craftgui/resource/minecraft/ParsedTextureSheet.java
@@ -0,0 +1,25 @@
+package binnie.craftgui.resource.minecraft;
+
+import binnie.core.resource.BinnieResource;
+import binnie.core.resource.IBinnieTexture;
+import binnie.core.resource.ResourceType;
+
+class ParsedTextureSheet
+ implements IBinnieTexture
+{
+ private String name;
+ private String modid;
+ private String path;
+
+ public ParsedTextureSheet(String name, String modid, String path)
+ {
+ this.name = name;
+ this.modid = modid;
+ this.path = path;
+ }
+
+ public BinnieResource getTexture()
+ {
+ return new BinnieResource(this.modid, ResourceType.GUI, this.path);
+ }
+}
diff --git a/src/Java/binnie/craftgui/resource/minecraft/StandardTexture.java b/src/Java/binnie/craftgui/resource/minecraft/StandardTexture.java
new file mode 100644
index 0000000000..b98facb505
--- /dev/null
+++ b/src/Java/binnie/craftgui/resource/minecraft/StandardTexture.java
@@ -0,0 +1,36 @@
+package binnie.craftgui.resource.minecraft;
+
+import binnie.core.resource.BinnieResource;
+import binnie.core.resource.IBinnieTexture;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.geometry.IBorder;
+import binnie.craftgui.resource.Texture;
+
+public class StandardTexture
+ extends Texture
+{
+ public StandardTexture(int u, int v, int w, int h, IBinnieTexture textureFile)
+ {
+ this(u, v, w, h, 0, textureFile.getTexture());
+ }
+
+ public StandardTexture(int u, int v, int w, int h, int offset, IBinnieTexture textureFile)
+ {
+ this(u, v, w, h, offset, textureFile.getTexture());
+ }
+
+ public StandardTexture(int u, int v, int w, int h, BinnieResource textureFile)
+ {
+ this(u, v, w, h, 0, textureFile);
+ }
+
+ public StandardTexture(int u, int v, int w, int h, int padding, BinnieResource textureFile)
+ {
+ super(new IArea(u, v, w, h), IBorder.ZERO, new IBorder(padding), textureFile);
+ }
+
+ public BinnieResource getTexture()
+ {
+ return getFilename();
+ }
+}
diff --git a/src/Java/binnie/craftgui/window/Panel.java b/src/Java/binnie/craftgui/window/Panel.java
new file mode 100644
index 0000000000..3b305f6d69
--- /dev/null
+++ b/src/Java/binnie/craftgui/window/Panel.java
@@ -0,0 +1,58 @@
+package binnie.craftgui.window;
+
+import binnie.craftgui.controls.core.Control;
+import binnie.craftgui.core.CraftGUI;
+import binnie.craftgui.core.IWidget;
+import binnie.craftgui.core.geometry.IArea;
+import binnie.craftgui.core.renderer.Renderer;
+import binnie.craftgui.minecraft.MinecraftGUI.PanelType;
+import binnie.craftgui.resource.minecraft.CraftGUITexture;
+
+public class Panel
+ extends Control
+{
+ IPanelType type;
+
+ public Panel(IWidget parent, float x, float y, float width, float height, IPanelType type)
+ {
+ super(parent, x, y, width, height);
+ this.type = type;
+ }
+
+ public Panel(IWidget parent, IArea area, IPanelType type)
+ {
+ this(parent, area.x(), area.y(), area.w(), area.h(), type);
+ }
+
+ public IPanelType getType()
+ {
+ return this.type;
+ }
+
+ public void onRenderBackground()
+ {
+ IPanelType panelType = getType();
+ if ((panelType instanceof MinecraftGUI.PanelType)) {
+ switch (1.$SwitchMap$binnie$craftgui$minecraft$MinecraftGUI$PanelType[((MinecraftGUI.PanelType)panelType).ordinal()])
+ {
+ case 1:
+ CraftGUI.Render.texture(CraftGUITexture.PanelBlack, getArea());
+ break;
+ case 2:
+ CraftGUI.Render.texture(CraftGUITexture.PanelGray, getArea());
+ break;
+ case 3:
+ CraftGUI.Render.texture(CraftGUITexture.PanelTinted, getArea());
+ break;
+ case 4:
+ CraftGUI.Render.texture(CraftGUITexture.Outline, getArea());
+ break;
+ case 5:
+ CraftGUI.Render.texture(CraftGUITexture.TabOutline, getArea());
+ break;
+ }
+ }
+ }
+
+ public static abstract interface IPanelType {}
+}