mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-21 12:42:53 +00:00
Clean Up Gui
This commit is contained in:
1 parent
1a717e2e2c
commit
78687099cd
23 files changed
+312
-281
No files matched your search
@@ -19,11 +19,11 @@ public class Widget implements IWidget {
|
||||
@Nullable
|
||||
private final IWidget parent;
|
||||
@Nullable
|
||||
Area cropArea;
|
||||
private Area cropArea;
|
||||
@Nullable
|
||||
IWidget cropWidget;
|
||||
boolean cropped;
|
||||
int colour;
|
||||
private IWidget cropWidget;
|
||||
private boolean cropped;
|
||||
private int color;
|
||||
private List<IWidget> children;
|
||||
private List<IWidgetAttribute> attributes;
|
||||
private Point position;
|
||||
@@ -39,7 +39,7 @@ public class Widget implements IWidget {
|
||||
this.size = Point.ZERO;
|
||||
this.offset = Point.ZERO;
|
||||
this.cropped = false;
|
||||
this.colour = 0xffffff;
|
||||
this.color = 0xffffff;
|
||||
this.eventHandlers = new ArrayList<>();
|
||||
this.visible = true;
|
||||
this.parent = parent;
|
||||
@@ -219,13 +219,13 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public final int getColor() {
|
||||
return this.colour;
|
||||
return this.color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setColor(final int colour) {
|
||||
if (this.colour != colour) {
|
||||
this.colour = colour;
|
||||
if (this.color != colour) {
|
||||
this.color = colour;
|
||||
this.callEvent(new EventWidget.ChangeColour(this));
|
||||
}
|
||||
}
|
||||
@@ -354,14 +354,23 @@ public class Widget implements IWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before the children of this widget are rendered.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the children of this widget are rendered.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderForeground(int guiWidth, int guiHeight) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the siblings of this widget are rendered.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderOverlay() {
|
||||
}
|
||||
@@ -370,10 +379,8 @@ public class Widget implements IWidget {
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
IWidget parent = this.getParent();
|
||||
if (parent != null) {
|
||||
if (!parent.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
if (parent != null && !parent.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -410,10 +417,17 @@ public class Widget implements IWidget {
|
||||
}
|
||||
|
||||
/* UPDATE */
|
||||
|
||||
/**
|
||||
* Called if this widget get updated on the client side.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onUpdateClient() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to update this widget on the client side.
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final void updateClient() {
|
||||
@@ -435,6 +449,7 @@ public class Widget implements IWidget {
|
||||
this.getTopParent().widgetDeleted(this);
|
||||
}
|
||||
|
||||
//TODO: Why not use this ?
|
||||
public IWidget getWidget() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ import binnie.core.gui.minecraft.Window;
|
||||
|
||||
public class Control extends Widget implements ITooltipHelp, ITooltip {
|
||||
public int extraLevel;
|
||||
List<String> helpStrings;
|
||||
List<String> tooltipStrings;
|
||||
private List<String> helpStrings;
|
||||
private List<String> tooltipStrings;
|
||||
|
||||
public Control(IWidget parent, int xPos, int yPos, int width, int height) {
|
||||
super(parent);
|
||||
@@ -37,14 +37,12 @@ public class Control extends Widget implements ITooltipHelp, ITooltip {
|
||||
this(parent, area.xPos(), area.yPos(), area.width(), area.height());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at the end of the constructor of control class.
|
||||
*/
|
||||
protected void initialise() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onUpdateClient() {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IWidget getParent() {
|
||||
|
||||
+27
-19
@@ -2,12 +2,11 @@ package binnie.core.gui.database;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import binnie.core.api.genetics.IBreedingSystem;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -17,6 +16,7 @@ import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
import binnie.core.Binnie;
|
||||
import binnie.core.api.genetics.IBreedingSystem;
|
||||
import binnie.core.gui.Attribute;
|
||||
import binnie.core.gui.ITooltip;
|
||||
import binnie.core.gui.IWidget;
|
||||
@@ -28,28 +28,28 @@ import binnie.core.gui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.core.gui.renderer.RenderUtil;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class ControlDatabaseIndividualDisplay extends ControlItemDisplay implements ITooltip {
|
||||
EnumDiscoveryState discovered;
|
||||
public class ControlIndividualDisplay extends ControlItemDisplay implements ITooltip {
|
||||
private EnumDiscoveryState discovered;
|
||||
@Nullable
|
||||
private IAlleleSpecies species;
|
||||
|
||||
public ControlDatabaseIndividualDisplay(final IWidget parent, final int x, final int y) {
|
||||
public ControlIndividualDisplay(final IWidget parent, final int x, final int y) {
|
||||
this(parent, x, y, 16);
|
||||
}
|
||||
|
||||
public ControlDatabaseIndividualDisplay(final IWidget parent, final int x, final int y, final int size) {
|
||||
public ControlIndividualDisplay(final IWidget parent, final int x, final int y, final int size) {
|
||||
super(parent, x, y, size);
|
||||
this.species = null;
|
||||
this.discovered = EnumDiscoveryState.Show;
|
||||
this.discovered = EnumDiscoveryState.SHOW;
|
||||
this.addSelfEventHandler(EventMouse.Down.class, event -> {
|
||||
if (event.getButton() == 0 && ControlDatabaseIndividualDisplay.this.species != null && EnumDiscoveryState.Show == ControlDatabaseIndividualDisplay.this.discovered) {
|
||||
((WindowAbstractDatabase) ControlDatabaseIndividualDisplay.this.getTopParent()).gotoSpeciesDelayed(ControlDatabaseIndividualDisplay.this.species);
|
||||
if (event.getButton() == 0 && ControlIndividualDisplay.this.species != null && EnumDiscoveryState.SHOW == ControlIndividualDisplay.this.discovered) {
|
||||
((WindowAbstractDatabase) ControlIndividualDisplay.this.getTopParent()).gotoSpeciesDelayed(ControlIndividualDisplay.this.species);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setSpecies(final IAlleleSpecies species) {
|
||||
this.setSpecies(species, EnumDiscoveryState.Show);
|
||||
this.setSpecies(species, EnumDiscoveryState.SHOW);
|
||||
}
|
||||
|
||||
public void setSpecies(final IAlleleSpecies species, EnumDiscoveryState state) {
|
||||
@@ -60,11 +60,11 @@ public class ControlDatabaseIndividualDisplay extends ControlItemDisplay impleme
|
||||
super.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
|
||||
this.species = species;
|
||||
final GameProfile username = Window.get(this).getUsername();
|
||||
if (state == EnumDiscoveryState.Undetermined) {
|
||||
state = (system.isSpeciesDiscovered(species, Window.get(this).getWorld(), username) ? EnumDiscoveryState.Discovered : EnumDiscoveryState.Undiscovered);
|
||||
if (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;
|
||||
state = EnumDiscoveryState.SHOW;
|
||||
}
|
||||
this.discovered = state;
|
||||
this.addAttribute(Attribute.MOUSE_OVER);
|
||||
@@ -80,15 +80,15 @@ public class ControlDatabaseIndividualDisplay extends ControlItemDisplay impleme
|
||||
}
|
||||
IBreedingSystem system = Binnie.GENETICS.getSystem(this.species.getRoot());
|
||||
switch (this.discovered) {
|
||||
case Show: {
|
||||
case SHOW: {
|
||||
super.onRenderForeground(guiWidth, guiHeight);
|
||||
return;
|
||||
}
|
||||
case Discovered: {
|
||||
case DISCOVERED: {
|
||||
icon = system.getDiscoveredIcon();
|
||||
break;
|
||||
}
|
||||
case Undiscovered: {
|
||||
case UNDISCOVERED: {
|
||||
icon = system.getUndiscoveredIcon();
|
||||
break;
|
||||
}
|
||||
@@ -102,19 +102,27 @@ public class ControlDatabaseIndividualDisplay extends ControlItemDisplay impleme
|
||||
public void getTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) {
|
||||
if (this.species != null) {
|
||||
switch (this.discovered) {
|
||||
case Show: {
|
||||
case SHOW: {
|
||||
tooltip.add(this.species.getAlleleName());
|
||||
break;
|
||||
}
|
||||
case Discovered: {
|
||||
case DISCOVERED: {
|
||||
tooltip.add(I18N.localise(DatabaseConstants.DISCOVERED_KEY + ".discovered"));
|
||||
break;
|
||||
}
|
||||
case Undiscovered: {
|
||||
case UNDISCOVERED: {
|
||||
tooltip.add(I18N.localise(DatabaseConstants.DISCOVERED_KEY + ".undiscovered"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDiscovered(EnumDiscoveryState discovered) {
|
||||
this.discovered = discovered;
|
||||
}
|
||||
|
||||
public EnumDiscoveryState getDiscovered() {
|
||||
return discovered;
|
||||
}
|
||||
}
|
||||
@@ -2,45 +2,38 @@ package binnie.core.gui.database;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import binnie.core.api.genetics.IBreedingSystem;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IMutation;
|
||||
|
||||
import binnie.core.api.genetics.IBreedingSystem;
|
||||
import binnie.core.gui.controls.listbox.ControlList;
|
||||
import binnie.core.gui.controls.listbox.ControlOption;
|
||||
import binnie.core.gui.minecraft.Window;
|
||||
|
||||
class ControlMutationItem extends ControlOption<IMutation> {
|
||||
private ControlDatabaseIndividualDisplay itemWidget1;
|
||||
private ControlDatabaseIndividualDisplay itemWidget2;
|
||||
private ControlDatabaseIndividualDisplay itemWidget3;
|
||||
private ControlMutationSymbol addSymbol;
|
||||
private ControlMutationSymbol arrowSymbol;
|
||||
|
||||
public ControlMutationItem(final ControlList<IMutation> controlList, final IMutation option, @Nullable final IAlleleSpecies species, final int y) {
|
||||
super(controlList, option, y);
|
||||
this.itemWidget1 = new ControlDatabaseIndividualDisplay(this, 4, 4);
|
||||
this.itemWidget2 = new ControlDatabaseIndividualDisplay(this, 44, 4);
|
||||
this.itemWidget3 = new ControlDatabaseIndividualDisplay(this, 104, 4);
|
||||
this.addSymbol = new ControlMutationSymbol(this, 24, 4, 0);
|
||||
this.arrowSymbol = new ControlMutationSymbol(this, 64, 4, 1);
|
||||
ControlIndividualDisplay firstIndividual = new ControlIndividualDisplay(this, 4, 4);
|
||||
ControlIndividualDisplay secondIndividual = new ControlIndividualDisplay(this, 44, 4);
|
||||
ControlIndividualDisplay resultIndividual = new ControlIndividualDisplay(this, 104, 4);
|
||||
ControlMutationSymbol addSymbol = new ControlMutationSymbol(this, 24, 4, 0);
|
||||
ControlMutationSymbol arrowSymbol = new ControlMutationSymbol(this, 64, 4, 1);
|
||||
final boolean isNEI = ((WindowAbstractDatabase) this.getTopParent()).isNEI();
|
||||
final IBreedingSystem system = ((WindowAbstractDatabase) this.getTopParent()).getBreedingSystem();
|
||||
if (this.getValue() != null) {
|
||||
final boolean isMutationDiscovered = system.isMutationDiscovered(this.getValue(), Window.get(this).getWorld(), Window.get(this).getUsername());
|
||||
IAlleleSpecies allele = null;
|
||||
EnumDiscoveryState state = null;
|
||||
allele = this.getValue().getAllele0();
|
||||
state = ((isNEI || isMutationDiscovered) ? EnumDiscoveryState.Show : ((species == allele) ? EnumDiscoveryState.Show : EnumDiscoveryState.Undetermined));
|
||||
this.itemWidget1.setSpecies(allele, state);
|
||||
IAlleleSpecies allele = this.getValue().getAllele0();
|
||||
EnumDiscoveryState state = ((isNEI || isMutationDiscovered) ? EnumDiscoveryState.SHOW : ((species.equals(allele)) ? EnumDiscoveryState.SHOW : EnumDiscoveryState.UNDETERMINED));
|
||||
firstIndividual.setSpecies(allele, state);
|
||||
allele = this.getValue().getAllele1();
|
||||
state = ((isNEI || isMutationDiscovered) ? EnumDiscoveryState.Show : ((species == allele) ? EnumDiscoveryState.Show : EnumDiscoveryState.Undetermined));
|
||||
this.itemWidget2.setSpecies(allele, state);
|
||||
state = ((isNEI || isMutationDiscovered) ? EnumDiscoveryState.SHOW : ((species.equals(allele)) ? EnumDiscoveryState.SHOW : EnumDiscoveryState.UNDETERMINED));
|
||||
secondIndividual.setSpecies(allele, state);
|
||||
allele = (IAlleleSpecies) this.getValue().getTemplate()[0];
|
||||
state = ((isNEI || isMutationDiscovered) ? EnumDiscoveryState.Show : ((species == allele) ? EnumDiscoveryState.Show : EnumDiscoveryState.Undetermined));
|
||||
this.itemWidget3.setSpecies(allele, state);
|
||||
this.addSymbol.setValue(this.getValue());
|
||||
this.arrowSymbol.setValue(this.getValue());
|
||||
state = ((isNEI || isMutationDiscovered) ? EnumDiscoveryState.SHOW : ((species.equals(allele)) ? EnumDiscoveryState.SHOW : EnumDiscoveryState.UNDETERMINED));
|
||||
resultIndividual.setSpecies(allele, state);
|
||||
addSymbol.setValue(this.getValue());
|
||||
arrowSymbol.setValue(this.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,17 +14,18 @@ import binnie.core.gui.geometry.Point;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
class ControlSpeciesBoxOption extends ControlTextOption<IAlleleSpecies> {
|
||||
private ControlDatabaseIndividualDisplay controlBee;
|
||||
private ControlIndividualDisplay controlBee;
|
||||
|
||||
public ControlSpeciesBoxOption(final ControlList<IAlleleSpecies> controlList, final IAlleleSpecies option, final int y) {
|
||||
super(controlList, option, option.getAlleleName(), y);
|
||||
this.setSize(new Point(this.getSize().xPos(), 20));
|
||||
(this.controlBee = new ControlDatabaseIndividualDisplay(this, 2, 2)).setSpecies(this.getValue(), EnumDiscoveryState.Undetermined);
|
||||
if (this.controlBee.discovered == EnumDiscoveryState.Discovered) {
|
||||
this.controlBee.discovered = EnumDiscoveryState.Show;
|
||||
(this.controlBee = new ControlIndividualDisplay(this, 2, 2)).setSpecies(this.getValue(), EnumDiscoveryState.UNDETERMINED);
|
||||
EnumDiscoveryState discovered = controlBee.getDiscovered();
|
||||
if (discovered == EnumDiscoveryState.DISCOVERED) {
|
||||
this.controlBee.setDiscovered(discovered = EnumDiscoveryState.SHOW);
|
||||
}
|
||||
this.textWidget.setValue((this.controlBee.discovered == EnumDiscoveryState.Show) ? option.getAlleleName() : DatabaseConstants.CONTROL_KEY + ".undiscovered");
|
||||
if (this.controlBee.discovered == EnumDiscoveryState.Show) {
|
||||
this.textWidget.setValue((discovered == EnumDiscoveryState.SHOW) ? option.getAlleleName() : DatabaseConstants.CONTROL_KEY + ".undiscovered");
|
||||
if (discovered == EnumDiscoveryState.SHOW) {
|
||||
this.addAttribute(Attribute.MOUSE_OVER);
|
||||
}
|
||||
CraftGUIUtil.moveWidget(this.textWidget, new Point(22, 0));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package binnie.core.gui.database;
|
||||
|
||||
public enum EnumDiscoveryState {
|
||||
Show,
|
||||
Undetermined,
|
||||
Discovered,
|
||||
Undiscovered
|
||||
SHOW,
|
||||
UNDETERMINED,
|
||||
DISCOVERED,
|
||||
UNDISCOVERED
|
||||
}
|
||||
@@ -26,13 +26,13 @@ public class PageSpeciesOverview extends PageSpecies {
|
||||
private ControlText controlComplexity;
|
||||
private ControlText controlDescription;
|
||||
private ControlText controlSignature;
|
||||
private ControlDatabaseIndividualDisplay controlInd1;
|
||||
private ControlDatabaseIndividualDisplay controlInd2;
|
||||
private ControlIndividualDisplay controlInd1;
|
||||
private ControlIndividualDisplay controlInd2;
|
||||
|
||||
public PageSpeciesOverview(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.controlInd1 = new ControlDatabaseIndividualDisplay(this, 5, 5);
|
||||
this.controlInd2 = new ControlDatabaseIndividualDisplay(this, 123, 5);
|
||||
this.controlInd1 = new ControlIndividualDisplay(this, 5, 5);
|
||||
this.controlInd2 = new ControlIndividualDisplay(this, 123, 5);
|
||||
this.controlName = new ControlTextCentered(this, 8, "");
|
||||
this.controlScientific = new ControlTextCentered(this, 32, "");
|
||||
this.controlAuthority = new ControlTextCentered(this, 44, "");
|
||||
@@ -43,8 +43,8 @@ public class PageSpeciesOverview extends PageSpecies {
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
this.controlInd1.setSpecies(species, EnumDiscoveryState.Show);
|
||||
this.controlInd2.setSpecies(species, EnumDiscoveryState.Show);
|
||||
this.controlInd1.setSpecies(species, EnumDiscoveryState.SHOW);
|
||||
this.controlInd2.setSpecies(species, EnumDiscoveryState.SHOW);
|
||||
final String branchBinomial = species.getBranch().getScientific();
|
||||
this.controlName.setValue(TextFormatting.UNDERLINE + species.getAlleleName());
|
||||
this.controlScientific.setValue(TextFormatting.ITALIC + branchBinomial + " " + species.getBinomial());
|
||||
|
||||
@@ -8,9 +8,9 @@ public abstract class EventMouse extends Event {
|
||||
}
|
||||
|
||||
public static class Button extends EventMouse {
|
||||
int x;
|
||||
int y;
|
||||
int button;
|
||||
private int x;
|
||||
private int y;
|
||||
private int button;
|
||||
|
||||
public Button(final IWidget currentMousedOverWidget, final int x, final int y, final int button) {
|
||||
super(currentMousedOverWidget);
|
||||
@@ -45,8 +45,8 @@ public abstract class EventMouse extends Event {
|
||||
}
|
||||
|
||||
public static class Move extends EventMouse {
|
||||
float dx;
|
||||
float dy;
|
||||
private float dx;
|
||||
private float dy;
|
||||
|
||||
public Move(final IWidget origin, final float dx, final float dy) {
|
||||
super(origin);
|
||||
@@ -70,7 +70,7 @@ public abstract class EventMouse extends Event {
|
||||
}
|
||||
|
||||
public static class Wheel extends EventMouse {
|
||||
int dWheel;
|
||||
private int dWheel;
|
||||
|
||||
public Wheel(final IWidget origin, final int dWheel) {
|
||||
super(origin);
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
package binnie.core.gui.fieldkit;
|
||||
|
||||
import binnie.botany.api.BotanyAPI;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.lepidopterology.ButterflyManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.lepidopterology.ButterflyManager;
|
||||
import forestry.api.lepidopterology.EnumButterflyChromosome;
|
||||
|
||||
import binnie.botany.api.BotanyAPI;
|
||||
import binnie.botany.api.genetics.EnumFlowerChromosome;
|
||||
import binnie.core.gui.CraftGUI;
|
||||
import binnie.core.gui.IWidget;
|
||||
@@ -28,14 +28,14 @@ import binnie.core.gui.resource.minecraft.StandardTexture;
|
||||
import binnie.core.texture.BinnieCoreTexture;
|
||||
|
||||
public class ControlChromosome extends Control implements IControlValue<IChromosomeType> {
|
||||
Texture BeeTexture;
|
||||
Texture TreeTexture;
|
||||
Texture MothTexture;
|
||||
Texture FlowerTexture;
|
||||
private Texture BeeTexture;
|
||||
private Texture TreeTexture;
|
||||
private Texture MothTexture;
|
||||
private Texture FlowerTexture;
|
||||
@Nullable
|
||||
IChromosomeType chromo;
|
||||
private IChromosomeType chromo;
|
||||
@Nullable
|
||||
ISpeciesRoot species;
|
||||
private ISpeciesRoot species;
|
||||
|
||||
public ControlChromosome(IWidget parent, int x, int y) {
|
||||
super(parent, x, y, 96, 96);
|
||||
|
||||
@@ -67,14 +67,12 @@ public class ContainerCraftGUI extends Container {
|
||||
this.mousedOverSlotNumber = -1;
|
||||
this.window = window;
|
||||
final IMachine machine = Machine.getMachine(window.getInventory());
|
||||
if (this.getSide() == Side.SERVER) {
|
||||
if (machine != null) {
|
||||
final GameProfile user = machine.getOwner();
|
||||
if (user != null) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("username", user.getName());
|
||||
this.sendNBTToClient("username", nbt);
|
||||
}
|
||||
if (this.getSide() == Side.SERVER && machine != null) {
|
||||
final GameProfile user = machine.getOwner();
|
||||
if (user != null) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setString("username", user.getName());
|
||||
this.sendNBTToClient("username", nbt);
|
||||
}
|
||||
}
|
||||
detectAndSendChanges();
|
||||
@@ -219,7 +217,7 @@ public class ContainerCraftGUI extends Container {
|
||||
} else if (name.equals("mouse-over-slot")) {
|
||||
this.onMouseOverSlot(player, action);
|
||||
} else if (name.equals("shift-click-info")) {
|
||||
this.onRecieveShiftClickHighlights(player, action);
|
||||
this.onRecieveShiftClickHighlights(action);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -230,19 +228,10 @@ public class ContainerCraftGUI extends Container {
|
||||
if (crafters.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
final ITankMachine tanks = Machine.getInterface(ITankMachine.class, this.window.getInventory());
|
||||
sendTankChanges();
|
||||
final IPoweredMachine powered = Machine.getInterface(IPoweredMachine.class, this.window.getInventory());
|
||||
final IErrorStateSource error = Machine.getInterface(IErrorStateSource.class, this.window.getInventory());
|
||||
final IProcess process = Machine.getInterface(IProcess.class, this.window.getInventory());
|
||||
if (tanks != null && this.window.isServer()) {
|
||||
for (int i = 0; i < tanks.getTankInfos().length; ++i) {
|
||||
final TankInfo tank = tanks.getTankInfos()[i];
|
||||
if (!this.getTankInfo(i).equals(tank)) {
|
||||
this.syncedNBT.put("tank-update-" + i, this.createTankNBT(i, tank));
|
||||
this.syncedTanks.put(i, tank);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (powered != null && this.window.isServer()) {
|
||||
this.syncedNBT.put("power-update", this.createPowerNBT(powered.getPowerInfo()));
|
||||
}
|
||||
@@ -256,6 +245,23 @@ public class ContainerCraftGUI extends Container {
|
||||
if (machineSync != null) {
|
||||
machineSync.sendGuiNBTToClient(this.syncedNBT);
|
||||
}
|
||||
sendChangesToPlayers();
|
||||
}
|
||||
|
||||
private void sendTankChanges(){
|
||||
ITankMachine tanks = Machine.getInterface(ITankMachine.class, this.window.getInventory());
|
||||
if (tanks != null && this.window.isServer()) {
|
||||
for (int i = 0; i < tanks.getTankInfos().length; ++i) {
|
||||
final TankInfo tank = tanks.getTankInfos()[i];
|
||||
if (!this.getTankInfo(i).equals(tank)) {
|
||||
this.syncedNBT.put("tank-update-" + i, this.createTankNBT(i, tank));
|
||||
this.syncedTanks.put(i, tank);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendChangesToPlayers(){
|
||||
final Map<String, NBTTagCompound> sentThisTime = new HashMap<>();
|
||||
for (final Map.Entry<String, NBTTagCompound> nbt : this.syncedNBT.entrySet()) {
|
||||
nbt.getValue().setString("type", nbt.getKey());
|
||||
@@ -266,8 +272,11 @@ public class ContainerCraftGUI extends Container {
|
||||
}
|
||||
if (shouldSend) {
|
||||
//TODO INVENTORY
|
||||
this.crafters.stream().filter(Objects::nonNull).forEach(entityPlayer ->
|
||||
BinnieCore.getBinnieProxy().sendToPlayer(new MessageContainerUpdate(nbt.getValue()), entityPlayer));
|
||||
this.crafters.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(
|
||||
entityPlayer -> BinnieCore.getBinnieProxy().sendToPlayer(new MessageContainerUpdate(nbt.getValue()), entityPlayer)
|
||||
);
|
||||
sentThisTime.put(nbt.getKey(), nbt.getValue());
|
||||
}
|
||||
}
|
||||
@@ -398,7 +407,7 @@ public class ContainerCraftGUI extends Container {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void onRecieveShiftClickHighlights(final EntityPlayer player, final NBTTagCompound data) {
|
||||
private void onRecieveShiftClickHighlights(NBTTagCompound data) {
|
||||
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).clear();
|
||||
for (final int slotnumber : data.getIntArray("slots")) {
|
||||
ControlSlot.highlighting.get(EnumHighlighting.SHIFT_CLICK).add(slotnumber);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package binnie.core.gui.minecraft;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -33,7 +34,7 @@ import binnie.core.gui.renderer.RenderUtil;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiCraftGUI extends GuiContainer {
|
||||
Point mousePos;
|
||||
private Point mousePos;
|
||||
private Window window;
|
||||
private ItemStack draggedItem;
|
||||
|
||||
@@ -123,100 +124,162 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
final int mouseX = mousePosition.xPos();
|
||||
final int mouseY = mousePosition.yPos();
|
||||
final FontRenderer font = this.getFontRenderer();
|
||||
ItemStack itemStack = tooltip.getItemStack();
|
||||
|
||||
boolean containsItemRender = false;
|
||||
|
||||
int k = 0;
|
||||
final List<String> strings = new ArrayList<>();
|
||||
List<String> textLines = new ArrayList<>();
|
||||
for (final String string : tooltip.getList()) {
|
||||
if (string != null) {
|
||||
if (!string.contains(Tooltip.NBT_SEPARATOR)) {
|
||||
strings.addAll(font.listFormattedStringToWidth(string, tooltip.maxWidth));
|
||||
textLines.addAll(font.listFormattedStringToWidth(string, tooltip.maxWidth));
|
||||
} else {
|
||||
strings.add(string);
|
||||
textLines.add(string);
|
||||
containsItemRender = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final String s : strings) {
|
||||
int l = font.getStringWidth(s);
|
||||
if (s.contains(Tooltip.NBT_SEPARATOR)) {
|
||||
l = 12 + font.getStringWidth(s.replaceAll(Tooltip.NBT_SEPARATOR + "(.*?)" + Tooltip.NBT_SEPARATOR, ""));
|
||||
int tooltipTextWidth = 0;
|
||||
for (String textLine : textLines) {
|
||||
int textLineWidth = font.getStringWidth(textLine);
|
||||
if (textLine.contains(Tooltip.NBT_SEPARATOR)) {
|
||||
textLineWidth = 12 + font.getStringWidth(textLine.replaceAll(Tooltip.NBT_SEPARATOR + "(.*?)" + Tooltip.NBT_SEPARATOR, ""));
|
||||
}
|
||||
if (l > k) {
|
||||
k = l;
|
||||
if (textLineWidth > tooltipTextWidth) {
|
||||
tooltipTextWidth = textLineWidth;
|
||||
}
|
||||
}
|
||||
|
||||
if (!containsItemRender) {
|
||||
ItemStack itemStack = tooltip.getItemStack();
|
||||
GuiUtils.drawHoveringText(itemStack, strings, mouseX, mouseY, width, height, tooltip.maxWidth, font);
|
||||
GuiUtils.drawHoveringText(itemStack, textLines, mouseX, mouseY, width, height, tooltip.maxWidth, font);
|
||||
} else {
|
||||
GlStateManager.disableRescaleNormal();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableDepth();
|
||||
drawHoveringText(itemStack, textLines, mouseX, mouseY, font, tooltipTextWidth, tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
int i1 = mouseX + 12;
|
||||
int j1 = mouseY - 12;
|
||||
int k2 = 8;
|
||||
if (strings.size() > 1) {
|
||||
k2 += 2 + (strings.size() - 1) * 10;
|
||||
}
|
||||
if (i1 + k > this.width) {
|
||||
i1 -= 28 + k;
|
||||
}
|
||||
if (j1 + k2 + 6 > this.height) {
|
||||
j1 = this.height - k2 - 6;
|
||||
}
|
||||
this.zLevel = 300.0f;
|
||||
//GuiScreen.itemRender.zLevel = 300.0f;
|
||||
final int l2 = -267386864;
|
||||
final int j2;
|
||||
final int i2 = j2 = 1342177280 + MinecraftTooltip.getOutline(tooltip.getType());
|
||||
this.drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l2, l2);
|
||||
this.drawGradientRect(i1 - 3, j1 + k2 + 3, i1 + k + 3, j1 + k2 + 4, l2, l2);
|
||||
this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k2 + 3, l2, l2);
|
||||
this.drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k2 + 3, l2, l2);
|
||||
this.drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k2 + 3, l2, l2);
|
||||
this.drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k2 + 3 - 1, i2, j2);
|
||||
this.drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k2 + 3 - 1, i2, j2);
|
||||
this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
|
||||
this.drawGradientRect(i1 - 3, j1 + k2 + 2, i1 + k + 3, j1 + k2 + 3, j2, j2);
|
||||
for (int k3 = 0; k3 < strings.size(); ++k3) {
|
||||
String s2 = strings.get(k3);
|
||||
if (k3 == 0) {
|
||||
s2 = MinecraftTooltip.getTitle(tooltip.getType()) + s2;
|
||||
private void drawHoveringText(@Nonnull ItemStack itemStack, List<String> textLines, int mouseX, int mouseY, FontRenderer font, int tooltipTextWidth, MinecraftTooltip tooltip){
|
||||
GlStateManager.disableRescaleNormal();
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableDepth();
|
||||
|
||||
boolean needsWrap = false;
|
||||
|
||||
int maxTextWidth = tooltip.maxWidth;
|
||||
int titleLinesCount = 1;
|
||||
int tooltipX = mouseX + 12;
|
||||
if (tooltipX + tooltipTextWidth + 4 > width) {
|
||||
tooltipX = mouseX - 16 - tooltipTextWidth;
|
||||
if (tooltipX < 4) { // if the tooltip doesn't fit on the screen
|
||||
if (mouseX > width / 2) {
|
||||
tooltipTextWidth = mouseX - 12 - 8;
|
||||
} else {
|
||||
s2 = MinecraftTooltip.getBody(tooltip.getType()) + s2;
|
||||
tooltipTextWidth = width - 16 - mouseX;
|
||||
}
|
||||
if (s2.contains(Tooltip.NBT_SEPARATOR)) {
|
||||
final String split = s2.split(Tooltip.NBT_SEPARATOR)[1];
|
||||
try {
|
||||
final NBTTagCompound nbt = JsonToNBT.getTagFromJson(split);
|
||||
final ItemStack stack = new ItemStack(nbt);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(i1, j1 - 1.5f, 0.0f);
|
||||
GlStateManager.scale(0.6f, 0.6f, 1.0f);
|
||||
RenderUtil.drawItem(Point.ZERO, stack, false);
|
||||
GlStateManager.popMatrix();
|
||||
} catch (NBTException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
s2 = " " + s2.replaceAll(Tooltip.NBT_SEPARATOR + "(.*?)" + Tooltip.NBT_SEPARATOR, "");
|
||||
}
|
||||
font.drawStringWithShadow(s2, i1, j1, -1);
|
||||
if (k3 == 0) {
|
||||
j1 += 2;
|
||||
}
|
||||
j1 += 10;
|
||||
needsWrap = true;
|
||||
}
|
||||
this.zLevel = 0.0f;
|
||||
//GuiScreen.itemRender.zLevel = 0.0f;
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.enableDepth();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GlStateManager.enableRescaleNormal();
|
||||
}
|
||||
|
||||
if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) {
|
||||
tooltipTextWidth = maxTextWidth;
|
||||
needsWrap = true;
|
||||
}
|
||||
|
||||
if (needsWrap) {
|
||||
int wrappedTooltipWidth = 0;
|
||||
List<String> wrappedTextLines = new ArrayList<String>();
|
||||
for (int i = 0; i < textLines.size(); i++) {
|
||||
String textLine = textLines.get(i);
|
||||
List<String> wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth);
|
||||
if (i == 0) {
|
||||
titleLinesCount = wrappedLine.size();
|
||||
}
|
||||
|
||||
for (String line : wrappedLine) {
|
||||
int lineWidth = font.getStringWidth(line);
|
||||
if (textLine.contains(Tooltip.NBT_SEPARATOR)) {
|
||||
lineWidth = 12 + font.getStringWidth(textLine.replaceAll(Tooltip.NBT_SEPARATOR + "(.*?)" + Tooltip.NBT_SEPARATOR, ""));
|
||||
}
|
||||
if (lineWidth > wrappedTooltipWidth) {
|
||||
wrappedTooltipWidth = lineWidth;
|
||||
}
|
||||
wrappedTextLines.add(line);
|
||||
}
|
||||
}
|
||||
tooltipTextWidth = wrappedTooltipWidth;
|
||||
textLines = wrappedTextLines;
|
||||
|
||||
if (mouseX > width / 2) {
|
||||
tooltipX = mouseX - 16 - tooltipTextWidth;
|
||||
} else {
|
||||
tooltipX = mouseX + 12;
|
||||
}
|
||||
}
|
||||
|
||||
int tooltipY = mouseY - 12;
|
||||
int tooltipHeight = 8;
|
||||
|
||||
if (textLines.size() > 1) {
|
||||
tooltipHeight += 2 + (textLines.size() - 1) * 10;
|
||||
if (textLines.size() > titleLinesCount) {
|
||||
tooltipHeight += 2; // gap between title lines and next lines
|
||||
}
|
||||
}
|
||||
/*if (tooltipX + tooltipTextWidth > this.width) {
|
||||
tooltipX -= 28 + tooltipTextWidth;
|
||||
}*/
|
||||
if (tooltipY + tooltipHeight + 6 > this.height) {
|
||||
tooltipY = this.height - tooltipHeight - 6;
|
||||
}
|
||||
this.zLevel = 300.0f;
|
||||
final int backgroundColor = 0xF0100010;
|
||||
drawGradientRect(tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor);
|
||||
drawGradientRect(tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(tooltipX + tooltipTextWidth + 3, tooltipY - 3, tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
final int borderColorStart = 0x50000000 + MinecraftTooltip.getOutline(tooltip.getType());
|
||||
final int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
|
||||
drawGradientRect(tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
drawGradientRect(tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
drawGradientRect(tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart);
|
||||
drawGradientRect(tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd);
|
||||
for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber) {
|
||||
String line = textLines.get(lineNumber);
|
||||
if (lineNumber == 0) {
|
||||
line = MinecraftTooltip.getTitle(tooltip.getType()) + line;
|
||||
} else {
|
||||
line = MinecraftTooltip.getBody(tooltip.getType()) + line;
|
||||
}
|
||||
if (line.contains(Tooltip.NBT_SEPARATOR)) {
|
||||
drawItem(line, tooltipX, tooltipY);
|
||||
line = " " + line.replaceAll(Tooltip.NBT_SEPARATOR + "(.*?)" + Tooltip.NBT_SEPARATOR, "");
|
||||
}
|
||||
font.drawStringWithShadow(line, tooltipX, tooltipY, -1);
|
||||
if (lineNumber + 1 == titleLinesCount) {
|
||||
tooltipY += 2;
|
||||
}
|
||||
tooltipY += 10;
|
||||
}
|
||||
this.zLevel = 0.0f;
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.enableDepth();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GlStateManager.enableRescaleNormal();
|
||||
}
|
||||
|
||||
private void drawItem(String line, int tooltipX, int tooltipY){
|
||||
String itemTag = line.split(Tooltip.NBT_SEPARATOR)[1];
|
||||
try {
|
||||
NBTTagCompound nbt = JsonToNBT.getTagFromJson(itemTag);
|
||||
ItemStack stack = new ItemStack(nbt);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(tooltipX, tooltipY - 1.5f, 0.0f);
|
||||
GlStateManager.scale(0.6f, 0.6f, 1.0f);
|
||||
RenderUtil.drawItem(Point.ZERO, stack, false);
|
||||
GlStateManager.popMatrix();
|
||||
} catch (NBTException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,10 +316,7 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
//@Override
|
||||
protected void mouseMovedOrUp(final int x, final int y, final int button) {
|
||||
final IWidget origin = (this.window.getMousedOverWidget() == null) ? this.window : this.window.getMousedOverWidget();
|
||||
if (button == 0) {
|
||||
final float dx = Mouse.getEventDX() * this.width / (float) this.mc.displayWidth;
|
||||
final float dy = -(Mouse.getEventDY() * this.height / (float) this.mc.displayHeight);
|
||||
} else {
|
||||
if (button != 0) {
|
||||
this.window.callEvent(new EventMouse.Up(origin, x, y, button));
|
||||
}
|
||||
}
|
||||
@@ -265,7 +325,6 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
public void handleMouseInput() throws IOException {
|
||||
super.handleMouseInput();
|
||||
final int dWheel = Mouse.getDWheel();
|
||||
final IWidget origin = (this.window.getFocusedWidget() == null) ? this.window : this.window.getFocusedWidget();
|
||||
if (dWheel != 0) {
|
||||
this.window.callEvent(new EventMouse.Wheel(this.window, dWheel));
|
||||
}
|
||||
|
||||
@@ -212,9 +212,15 @@ public abstract class Window extends TopLevelWidget implements INetwork.ReceiveG
|
||||
this.hasBeenInitialised = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the window on the client side.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract void initialiseClient();
|
||||
|
||||
/**
|
||||
* Initialise the window on the server side.
|
||||
*/
|
||||
public void initialiseServer() {
|
||||
}
|
||||
|
||||
@@ -257,6 +263,9 @@ public abstract class Window extends TopLevelWidget implements INetwork.ReceiveG
|
||||
return this.entityInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called if the player closes the window.
|
||||
*/
|
||||
public void onClose() {
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ public class TextureRenderer {
|
||||
|
||||
public void setTexture(@Nullable final Texture texture) {
|
||||
if (texture != null) {
|
||||
BinnieCore.getBinnieProxy().bindTexture(texture.getFilename());
|
||||
BinnieCore.getBinnieProxy().bindTexture(texture.getFilename().getResourceLocation());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ public class CraftGUIResourceManager implements IResourceManagerReloadListener {
|
||||
CraftGUI.resourceManager = this;
|
||||
}
|
||||
|
||||
//TODO: Clean Up
|
||||
@Override
|
||||
public void onResourceManagerReload(final IResourceManager manager) {
|
||||
this.textureSheets.clear();
|
||||
|
||||
@@ -27,7 +27,7 @@ class BinnieFluid extends Fluid {
|
||||
return color;
|
||||
}
|
||||
|
||||
FluidType getDefinition() {
|
||||
public FluidType getType() {
|
||||
return this.fluidType;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class FluidHandlerItemBinnie extends FluidHandlerItemStackSimple {
|
||||
|
||||
if (fluid instanceof BinnieFluid) {
|
||||
BinnieFluid binnieFluid = (BinnieFluid) fluid;
|
||||
FluidType definition = binnieFluid.getDefinition();
|
||||
FluidType definition = binnieFluid.getType();
|
||||
return definition.canPlaceIn(containerType);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ItemFluidContainer extends ItemFood implements IItemModelRegister {
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
|
||||
super.getSubItems(tab, items);
|
||||
if (this.isInCreativeTab(tab)) {
|
||||
for (FluidType type : Binnie.LIQUID.fluids.values()) {
|
||||
for (FluidType type : Binnie.LIQUID.getFluids().values()) {
|
||||
if (!type.canPlaceIn(this.container)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import forestry.core.utils.OreDictUtil;
|
||||
|
||||
import binnie.core.Constants;
|
||||
import binnie.core.ManagerBase;
|
||||
import binnie.core.util.Log;
|
||||
import binnie.core.util.RecipeUtil;
|
||||
|
||||
public class ManagerLiquid extends ManagerBase {
|
||||
@@ -29,7 +30,7 @@ public class ManagerLiquid extends ManagerBase {
|
||||
//TODO: test if the name is "Creosote Oil" and not "fluid.creosote"
|
||||
public static final String CREOSOTE = "fluid.creosote";
|
||||
|
||||
Map<String, FluidType> fluids;
|
||||
private Map<String, FluidType> fluids;
|
||||
|
||||
public ManagerLiquid() {
|
||||
this.fluids = new LinkedHashMap<>();
|
||||
@@ -40,7 +41,7 @@ public class ManagerLiquid extends ManagerBase {
|
||||
FluidType type = liquid.getType();
|
||||
final BinnieFluid fluid = this.createLiquid(type);
|
||||
if (fluid == null) {
|
||||
throw new RuntimeException("Liquid registered incorrectly - " + type.getIdentifier());
|
||||
Log.error("Liquid registered incorrectly - {} ", type.getIdentifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,4 +88,8 @@ public class ManagerLiquid extends ManagerBase {
|
||||
textureMap.registerSprite(definition.getStill());
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, FluidType> getFluids() {
|
||||
return fluids;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import binnie.core.gui.window.WindowMachine;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -59,12 +58,12 @@ import binnie.core.gui.renderer.RenderUtil;
|
||||
import binnie.core.gui.resource.Texture;
|
||||
import binnie.core.gui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.core.gui.window.Panel;
|
||||
import binnie.core.gui.window.WindowMachine;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.transfer.TransferRequest;
|
||||
|
||||
public class WindowCompartment extends WindowMachine implements IWindowAffectsShiftClick {
|
||||
private final Map<Panel, Integer> panels;
|
||||
boolean dueUpdate;
|
||||
private ControlTextEdit tabName;
|
||||
private ControlItemDisplay tabIcon;
|
||||
private ControlColourSelector tabColour;
|
||||
@@ -76,6 +75,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
|
||||
this.currentTab = 0;
|
||||
}
|
||||
|
||||
//TODO: Clean Up, Localise
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void initialiseClient() {
|
||||
|
||||
@@ -22,29 +22,13 @@ import binnie.core.network.INetworkedEntity;
|
||||
import binnie.core.network.packet.MessageUpdate;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
|
||||
public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
public abstract class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
private short uniqueTextureUID;
|
||||
|
||||
public BinnieProxy() {
|
||||
this.uniqueTextureUID = 1200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTexture(final BinnieResource texture) {
|
||||
}
|
||||
|
||||
public boolean checkTexture(final BinnieResource location) {
|
||||
return false;
|
||||
}
|
||||
@@ -98,19 +82,6 @@ public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
GameRegistry.registerTileEntity(tile, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPipe(final Item pipe) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
return System.getenv().containsKey("BINNIE_DEBUG");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockRenderer(final Object renderer) {
|
||||
}
|
||||
|
||||
public void sendNetworkEntityPacket(final INetworkedEntity entity) {
|
||||
final MessageUpdate packet = new MessageUpdate(BinnieCorePacketID.NETWORK_ENTITY_UPDATE.ordinal(), entity);
|
||||
this.sendToAll(packet);
|
||||
@@ -120,27 +91,22 @@ public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public IIcon getIcon(final IIconRegister register, final String mod, final String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void handleTextureRefresh(final IIconRegister register, final int type) {
|
||||
}
|
||||
|
||||
public void handlePostTextureRefresh(final IIconRegister register, final int type) {
|
||||
}*/
|
||||
|
||||
public short getUniqueTextureUID() {
|
||||
final short uniqueTextureUID = this.uniqueTextureUID;
|
||||
this.uniqueTextureUID = (short) (uniqueTextureUID + 1);
|
||||
return uniqueTextureUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds GL to this texture location.
|
||||
*/
|
||||
@Override
|
||||
public void bindTexture(final ResourceLocation location) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the sprites on the client side.
|
||||
*/
|
||||
public void reloadSprites() {
|
||||
}
|
||||
|
||||
|
||||
@@ -76,11 +76,6 @@ public final class BinnieProxyClient extends BinnieProxy implements IBinnieProxy
|
||||
ModelLoader.setCustomModelResourceLocation(item, meta, modelResourceLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTexture(final BinnieResource texture) {
|
||||
this.bindTexture(texture.getResourceLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTexture(final ResourceLocation location) {
|
||||
this.getMinecraftInstance().getTextureManager().bindTexture(location);
|
||||
@@ -131,17 +126,6 @@ public final class BinnieProxyClient extends BinnieProxy implements IBinnieProxy
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockRenderer(final Object renderer) {
|
||||
//if (renderer != null && renderer instanceof FastTESR) {
|
||||
//ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachine.class, new RendererMachine());//.registerBlockHandler((ISimpleBlockRenderingHandler) renderer);
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPipe(final Item pipe) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getTextureAtlasSprite(ResourceLocation location) {
|
||||
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
|
||||
|
||||
@@ -12,7 +12,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
|
||||
public interface IBinnieProxy extends IProxyCore {
|
||||
boolean isClient();
|
||||
@@ -21,33 +20,17 @@ public interface IBinnieProxy extends IProxyCore {
|
||||
|
||||
File getDirectory();
|
||||
|
||||
void bindTexture(final BinnieResource p0);
|
||||
|
||||
void bindTexture(final ResourceLocation p0);
|
||||
|
||||
//int getUniqueRenderID();
|
||||
|
||||
//void registerCustomItemRenderer(final Item p0, final IItemRenderer p1);
|
||||
void bindTexture(ResourceLocation location);
|
||||
|
||||
void openGui(final AbstractMod p0, final int p1, final EntityPlayer p2, final BlockPos pos);
|
||||
|
||||
World getWorld();
|
||||
|
||||
//EntityPlayer getPlayer();
|
||||
|
||||
//MinecraftServer getServer();
|
||||
|
||||
Minecraft getMinecraftInstance();
|
||||
|
||||
boolean needsTagCompoundSynched(final Item p0);
|
||||
boolean needsTagCompoundSynched(Item item);
|
||||
|
||||
void registerTileEntity(final Class<? extends TileEntity> tile, final String id, @Nullable final Object renderer);
|
||||
|
||||
void registerTileEntity(final Class<? extends TileEntity> tile, final String id);
|
||||
|
||||
void createPipe(final Item p0);
|
||||
|
||||
boolean isDebug();
|
||||
|
||||
void registerBlockRenderer(final Object p0);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import forestry.api.genetics.IAlleleSpecies;
|
||||
|
||||
import binnie.core.gui.IWidget;
|
||||
import binnie.core.gui.controls.ControlTextCentered;
|
||||
import binnie.core.gui.database.ControlDatabaseIndividualDisplay;
|
||||
import binnie.core.gui.database.ControlIndividualDisplay;
|
||||
import binnie.core.gui.database.DatabaseTab;
|
||||
import binnie.core.gui.database.EnumDiscoveryState;
|
||||
import binnie.core.gui.database.PageSpecies;
|
||||
@@ -12,18 +12,18 @@ import binnie.core.gui.minecraft.MinecraftGUI;
|
||||
import binnie.core.gui.window.Panel;
|
||||
|
||||
public class PageSpeciesImage extends PageSpecies {
|
||||
ControlDatabaseIndividualDisplay display;
|
||||
ControlIndividualDisplay display;
|
||||
|
||||
public PageSpeciesImage(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
new Panel(this, 7, 25, 130, 120, MinecraftGUI.PanelType.GRAY);
|
||||
this.display = new ControlDatabaseIndividualDisplay(this, 12, 25, 120);
|
||||
this.display = new ControlIndividualDisplay(this, 12, 25, 120);
|
||||
this.display.hastooltip = false;
|
||||
new ControlTextCentered(this, 8, this.getValue().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
this.display.setSpecies(species, EnumDiscoveryState.Show);
|
||||
this.display.setSpecies(species, EnumDiscoveryState.SHOW);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user