pick 97420a31d The big reformat of 2020
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,12 +18,10 @@
|
||||
|
||||
package appeng.client.gui;
|
||||
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
@@ -33,75 +31,66 @@ import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
public abstract class AEBaseMEGui<T extends AEBaseContainer> extends AEBaseGui<T> {
|
||||
|
||||
public abstract class AEBaseMEGui<T extends AEBaseContainer> extends AEBaseGui<T>
|
||||
{
|
||||
public AEBaseMEGui(T container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
public AEBaseMEGui(T container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
@Override
|
||||
protected void renderTooltip(final ItemStack stack, final int x, final int y) {
|
||||
final Slot s = this.getSlot(x, y);
|
||||
|
||||
@Override
|
||||
protected void renderTooltip( final ItemStack stack, final int x, final int y )
|
||||
{
|
||||
final Slot s = this.getSlot( x, y );
|
||||
if (s instanceof SlotME && !stack.isEmpty()) {
|
||||
final int bigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999;
|
||||
|
||||
if( s instanceof SlotME && !stack.isEmpty() )
|
||||
{
|
||||
final int bigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999;
|
||||
IAEItemStack myStack = null;
|
||||
final List<String> currentToolTip = this.getTooltipFromItem(stack);
|
||||
|
||||
IAEItemStack myStack = null;
|
||||
final List<String> currentToolTip = this.getTooltipFromItem( stack );
|
||||
try {
|
||||
final SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
} catch (final Throwable ignore) {
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch( final Throwable ignore )
|
||||
{
|
||||
}
|
||||
if (myStack != null) {
|
||||
if (myStack.getStackSize() > bigNumber || (myStack.getStackSize() > 1 && stack.isDamaged())) {
|
||||
final String local = ButtonToolTips.ItemsStored.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US)
|
||||
.format(myStack.getStackSize());
|
||||
final String format = String.format(local, formattedAmount);
|
||||
|
||||
if( myStack != null )
|
||||
{
|
||||
if( myStack.getStackSize() > bigNumber || ( myStack.getStackSize() > 1 && stack.isDamaged() ) )
|
||||
{
|
||||
final String local = ButtonToolTips.ItemsStored.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() );
|
||||
final String format = String.format( local, formattedAmount );
|
||||
currentToolTip.add(TextFormatting.GRAY + format);
|
||||
}
|
||||
|
||||
currentToolTip.add( TextFormatting.GRAY + format );
|
||||
}
|
||||
if (myStack.getCountRequestable() > 0) {
|
||||
final String local = ButtonToolTips.ItemsRequestable.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US)
|
||||
.format(myStack.getCountRequestable());
|
||||
final String format = String.format(local, formattedAmount);
|
||||
|
||||
if( myStack.getCountRequestable() > 0 )
|
||||
{
|
||||
final String local = ButtonToolTips.ItemsRequestable.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() );
|
||||
final String format = String.format( local, formattedAmount );
|
||||
currentToolTip.add(format);
|
||||
}
|
||||
this.renderTooltip(currentToolTip, x, y, this.font);
|
||||
|
||||
currentToolTip.add( format );
|
||||
}
|
||||
this.renderTooltip( currentToolTip, x, y, this.font );
|
||||
return;
|
||||
} else if (stack.getCount() > bigNumber) {
|
||||
final String local = ButtonToolTips.ItemsStored.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(stack.getCount());
|
||||
final String format = String.format(local, formattedAmount);
|
||||
|
||||
return;
|
||||
}
|
||||
else if( stack.getCount() > bigNumber )
|
||||
{
|
||||
final String local = ButtonToolTips.ItemsStored.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( stack.getCount() );
|
||||
final String format = String.format( local, formattedAmount );
|
||||
currentToolTip.add(TextFormatting.GRAY + format);
|
||||
|
||||
currentToolTip.add( TextFormatting.GRAY + format );
|
||||
this.renderTooltip(currentToolTip, x, y, this.font);
|
||||
|
||||
this.renderTooltip( currentToolTip, x, y, this.font );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
super.renderTooltip( stack, x, y );
|
||||
}
|
||||
super.renderTooltip(stack, x, y);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
package appeng.client.gui;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -11,77 +10,66 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
|
||||
/**
|
||||
* A proxy for a slot that will always return an itemstack with size 1, if there is an item in the slot.
|
||||
* Used to prevent the default item count from rendering.
|
||||
* A proxy for a slot that will always return an itemstack with size 1, if there
|
||||
* is an item in the slot. Used to prevent the default item count from
|
||||
* rendering.
|
||||
*/
|
||||
class Size1Slot extends SlotItemHandler
|
||||
{
|
||||
class Size1Slot extends SlotItemHandler {
|
||||
|
||||
private final SlotItemHandler delegate;
|
||||
private final SlotItemHandler delegate;
|
||||
|
||||
public Size1Slot( SlotItemHandler delegate )
|
||||
{
|
||||
super( delegate.getItemHandler(), delegate.getSlotIndex(), delegate.xPos, delegate.yPos );
|
||||
this.delegate = delegate;
|
||||
}
|
||||
public Size1Slot(SlotItemHandler delegate) {
|
||||
super(delegate.getItemHandler(), delegate.getSlotIndex(), delegate.xPos, delegate.yPos);
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack()
|
||||
{
|
||||
ItemStack orgStack = this.delegate.getStack();
|
||||
if( !orgStack.isEmpty() )
|
||||
{
|
||||
ItemStack modifiedStack = orgStack.copy();
|
||||
modifiedStack.setCount( 1 );
|
||||
return modifiedStack;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack() {
|
||||
ItemStack orgStack = this.delegate.getStack();
|
||||
if (!orgStack.isEmpty()) {
|
||||
ItemStack modifiedStack = orgStack.copy();
|
||||
modifiedStack.setCount(1);
|
||||
return modifiedStack;
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack()
|
||||
{
|
||||
return this.delegate.getHasStack();
|
||||
}
|
||||
@Override
|
||||
public boolean getHasStack() {
|
||||
return this.delegate.getHasStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return this.delegate.getSlotStackLimit();
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return this.delegate.getSlotStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemStackLimit( ItemStack stack )
|
||||
{
|
||||
return this.delegate.getItemStackLimit( stack );
|
||||
}
|
||||
@Override
|
||||
public int getItemStackLimit(ItemStack stack) {
|
||||
return this.delegate.getItemStackLimit(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( PlayerEntity playerIn )
|
||||
{
|
||||
return this.delegate.canTakeStack( playerIn );
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(PlayerEntity playerIn) {
|
||||
return this.delegate.canTakeStack(playerIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return this.delegate.isEnabled();
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public boolean isEnabled() {
|
||||
return this.delegate.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotIndex()
|
||||
{
|
||||
return this.delegate.getSlotIndex();
|
||||
}
|
||||
@Override
|
||||
public int getSlotIndex() {
|
||||
return this.delegate.getSlotIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameInventory( Slot other )
|
||||
{
|
||||
return this.delegate.isSameInventory( other );
|
||||
}
|
||||
@Override
|
||||
public boolean isSameInventory(Slot other) {
|
||||
return this.delegate.isSameInventory(other);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
@@ -14,15 +22,10 @@ import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Utility class for sub-screens of other containers that allow returning to the primary container UI.
|
||||
* Utility class for sub-screens of other containers that allow returning to the
|
||||
* primary container UI.
|
||||
*/
|
||||
final class AESubGui {
|
||||
|
||||
@@ -31,8 +34,8 @@ final class AESubGui {
|
||||
private final ItemStack previousContainerIcon;
|
||||
|
||||
/**
|
||||
* Based on the container we're opening for, try to determine what it's "primary" GUI would be
|
||||
* so that we can go back to it.
|
||||
* Based on the container we're opening for, try to determine what it's
|
||||
* "primary" GUI would be so that we can go back to it.
|
||||
*/
|
||||
public AESubGui(AEBaseGui<?> gui, Object containerTarget) {
|
||||
this.gui = gui;
|
||||
@@ -41,7 +44,8 @@ final class AESubGui {
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if (containerTarget instanceof TileChest) {
|
||||
// A chest is also a priority host, but the priority _interface_ can only be opened from the
|
||||
// A chest is also a priority host, but the priority _interface_ can only be
|
||||
// opened from the
|
||||
// chest ui that doesn't actually show the contents of the inserted cell.
|
||||
IPriorityHost priorityHost = (IPriorityHost) containerTarget;
|
||||
this.previousContainerIcon = priorityHost.getItemStackRepresentation();
|
||||
@@ -54,31 +58,27 @@ final class AESubGui {
|
||||
this.previousContainerType = priorityHost.getContainerType();
|
||||
}
|
||||
|
||||
else if( containerTarget instanceof WirelessTerminalGuiObject)
|
||||
{
|
||||
this.previousContainerIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
else if (containerTarget instanceof WirelessTerminalGuiObject) {
|
||||
this.previousContainerIcon = definitions.items().wirelessTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
this.previousContainerType = ContainerWirelessTerm.TYPE;
|
||||
}
|
||||
|
||||
else if( containerTarget instanceof PartTerminal)
|
||||
{
|
||||
this.previousContainerIcon = parts.terminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
else if (containerTarget instanceof PartTerminal) {
|
||||
this.previousContainerIcon = parts.terminal().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
this.previousContainerType = ContainerMEMonitorable.TYPE;
|
||||
}
|
||||
|
||||
else if( containerTarget instanceof PartCraftingTerminal)
|
||||
{
|
||||
this.previousContainerIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
else if (containerTarget instanceof PartCraftingTerminal) {
|
||||
this.previousContainerIcon = parts.craftingTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
this.previousContainerType = ContainerCraftingTerm.TYPE;
|
||||
}
|
||||
|
||||
else if( containerTarget instanceof PartPatternTerminal)
|
||||
{
|
||||
this.previousContainerIcon = parts.patternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
else if (containerTarget instanceof PartPatternTerminal) {
|
||||
this.previousContainerIcon = parts.patternTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
this.previousContainerType = ContainerPatternTerm.TYPE;
|
||||
}
|
||||
|
||||
else {
|
||||
else {
|
||||
this.previousContainerIcon = null;
|
||||
this.previousContainerType = null;
|
||||
}
|
||||
@@ -89,13 +89,13 @@ final class AESubGui {
|
||||
}
|
||||
|
||||
public final GuiTabButton addBackButton(Consumer<GuiTabButton> buttonAdder, int x, int y, @Nullable String label) {
|
||||
if( this.previousContainerType != null && !previousContainerIcon.isEmpty() )
|
||||
{
|
||||
if (this.previousContainerType != null && !previousContainerIcon.isEmpty()) {
|
||||
if (label == null) {
|
||||
label = previousContainerIcon.getDisplayName().getString();
|
||||
}
|
||||
ItemRenderer itemRenderer = gui.getMinecraft().getItemRenderer();
|
||||
GuiTabButton button = new GuiTabButton( gui.getGuiLeft() + x, gui.getGuiTop() + y, previousContainerIcon, label, itemRenderer, btn -> goBack() );
|
||||
GuiTabButton button = new GuiTabButton(gui.getGuiLeft() + x, gui.getGuiTop() + y, previousContainerIcon,
|
||||
label, itemRenderer, btn -> goBack());
|
||||
buttonAdder.accept(button);
|
||||
return button;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.client.gui.widgets.GuiActionButton;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
@@ -33,6 +30,7 @@ import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.client.gui.widgets.GuiActionButton;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
@@ -40,129 +38,120 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class GuiCellWorkbench extends GuiUpgradeable<ContainerCellWorkbench> {
|
||||
|
||||
public class GuiCellWorkbench extends GuiUpgradeable<ContainerCellWorkbench>
|
||||
{
|
||||
private GuiToggleButton copyMode;
|
||||
|
||||
private GuiToggleButton copyMode;
|
||||
public GuiCellWorkbench(ContainerCellWorkbench container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
public GuiCellWorkbench(ContainerCellWorkbench container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 251;
|
||||
}
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.fuzzyMode = this.addButton(new GuiSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68,
|
||||
Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::toggleFuzzyMode));
|
||||
this.addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH,
|
||||
act1 -> action("Partition")));
|
||||
this.addButton(
|
||||
new GuiActionButton(this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, act -> action("Clear")));
|
||||
this.copyMode = this.addButton(new GuiToggleButton(this.guiLeft - 18, this.guiTop + 48, 11 * 16 + 5,
|
||||
12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc.getLocal(), act -> action("CopyMode")));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.fuzzyMode = this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::toggleFuzzyMode ) );
|
||||
this.addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, act1 -> action("Partition")));
|
||||
this.addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, act -> action("Clear")));
|
||||
this.copyMode = this.addButton( new GuiToggleButton( this.guiLeft - 18, this.guiTop + 48, 11 * 16 + 5, 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc
|
||||
.getLocal(), act -> action("CopyMode") ) );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.handleButtonVisibility();
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.handleButtonVisibility();
|
||||
this.bindTexture(this.getBackground());
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset());
|
||||
if (this.drawUpgrades()) {
|
||||
if (this.container.availableUpgrades() <= 8) {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35,
|
||||
7 + this.container.availableUpgrades() * 18, getBlitOffset());
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY + (7 + (this.container.availableUpgrades()) * 18),
|
||||
177, 151, 35, 7, getBlitOffset());
|
||||
} else if (this.container.availableUpgrades() <= 16) {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18, getBlitOffset());
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7,
|
||||
getBlitOffset());
|
||||
|
||||
this.bindTexture( this.getBackground() );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset() );
|
||||
if( this.drawUpgrades() )
|
||||
{
|
||||
if( this.container.availableUpgrades() <= 8 )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + this.container.availableUpgrades() * 18, getBlitOffset() );
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( this.container.availableUpgrades() ) * 18 ), 177, 151, 35, 7, getBlitOffset() );
|
||||
}
|
||||
else if( this.container.availableUpgrades() <= 16 )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18, getBlitOffset() );
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( 8 ) * 18 ), 177, 151, 35, 7, getBlitOffset() );
|
||||
final int dx = this.container.availableUpgrades() - 8;
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + dx * 18,
|
||||
getBlitOffset());
|
||||
if (dx == 8) {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177 + 27, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, 7,
|
||||
getBlitOffset());
|
||||
} else {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177 + 27 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151,
|
||||
35 - 8, 7, getBlitOffset());
|
||||
}
|
||||
} else {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18, getBlitOffset());
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7,
|
||||
getBlitOffset());
|
||||
|
||||
final int dx = this.container.availableUpgrades() - 8;
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + dx * 18, getBlitOffset() );
|
||||
if( dx == 8 )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177 + 27, offsetY + ( 7 + ( dx ) * 18 ), 186, 151, 35 - 8, 7, getBlitOffset() );
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177 + 27 + 4, offsetY + ( 7 + ( dx ) * 18 ), 186 + 4, 151, 35 - 8, 7, getBlitOffset() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18, getBlitOffset() );
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( 8 ) * 18 ), 177, 151, 35, 7, getBlitOffset() );
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + 8 * 18,
|
||||
getBlitOffset());
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177 + 27, offsetY + (7 + (8) * 18), 186, 151, 35 - 8, 7,
|
||||
getBlitOffset());
|
||||
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + 8 * 18, getBlitOffset() );
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177 + 27, offsetY + ( 7 + ( 8 ) * 18 ), 186, 151, 35 - 8, 7, getBlitOffset() );
|
||||
final int dx = this.container.availableUpgrades() - 16;
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177 + 27 + 18, offsetY, 186, 0, 35 - 8, 7 + dx * 18,
|
||||
getBlitOffset());
|
||||
if (dx == 8) {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177 + 27 + 18, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8,
|
||||
7, getBlitOffset());
|
||||
} else {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177 + 27 + 18 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151,
|
||||
35 - 8, 7, getBlitOffset());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.hasToolbox()) {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, 161, 68, 68, getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
final int dx = this.container.availableUpgrades() - 16;
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY, 186, 0, 35 - 8, 7 + dx * 18, getBlitOffset() );
|
||||
if( dx == 8 )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY + ( 7 + ( dx ) * 18 ), 186, 151, 35 - 8, 7, getBlitOffset() );
|
||||
}
|
||||
else
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177 + 27 + 18 + 4, offsetY + ( 7 + ( dx ) * 18 ), 186 + 4, 151, 35 - 8, 7, getBlitOffset() );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( this.hasToolbox() )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, 161, 68, 68, getBlitOffset() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void handleButtonVisibility() {
|
||||
this.copyMode.setState(this.container.getCopyMode() == CopyMode.CLEAR_ON_REMOVE);
|
||||
|
||||
@Override
|
||||
protected void handleButtonVisibility()
|
||||
{
|
||||
this.copyMode.setState( this.container.getCopyMode() == CopyMode.CLEAR_ON_REMOVE );
|
||||
boolean hasFuzzy = false;
|
||||
final IItemHandler inv = this.container.getCellUpgradeInventory();
|
||||
for (int x = 0; x < inv.getSlots(); x++) {
|
||||
final ItemStack is = inv.getStackInSlot(x);
|
||||
if (!is.isEmpty() && is.getItem() instanceof IUpgradeModule) {
|
||||
if (((IUpgradeModule) is.getItem()).getType(is) == Upgrades.FUZZY) {
|
||||
hasFuzzy = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.fuzzyMode.setVisibility(hasFuzzy);
|
||||
}
|
||||
|
||||
boolean hasFuzzy = false;
|
||||
final IItemHandler inv = this.container.getCellUpgradeInventory();
|
||||
for( int x = 0; x < inv.getSlots(); x++ )
|
||||
{
|
||||
final ItemStack is = inv.getStackInSlot( x );
|
||||
if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule )
|
||||
{
|
||||
if( ( (IUpgradeModule) is.getItem() ).getType( is ) == Upgrades.FUZZY )
|
||||
{
|
||||
hasFuzzy = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.fuzzyMode.setVisibility( hasFuzzy );
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/cellworkbench.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/cellworkbench.png";
|
||||
}
|
||||
@Override
|
||||
protected boolean drawUpgrades() {
|
||||
return this.container.availableUpgrades() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawUpgrades()
|
||||
{
|
||||
return this.container.availableUpgrades() > 0;
|
||||
}
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.CellWorkbench;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.CellWorkbench;
|
||||
}
|
||||
private void action(String type) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("CellWorkbench.Action", type));
|
||||
}
|
||||
|
||||
private void action(String type) {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", type ) );
|
||||
}
|
||||
|
||||
private void toggleFuzzyMode(GuiSettingToggleButton<FuzzyMode> button, boolean backwards) {
|
||||
FuzzyMode fz = button.getNextValue(backwards);
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Fuzzy", fz.name() ) );
|
||||
}
|
||||
private void toggleFuzzyMode(GuiSettingToggleButton<FuzzyMode> button, boolean backwards) {
|
||||
FuzzyMode fz = button.getNextValue(backwards);
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("CellWorkbench.Fuzzy", fz.name()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,53 +18,47 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerChest;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiChest extends AEBaseGui<ContainerChest> {
|
||||
|
||||
public class GuiChest extends AEBaseGui<ContainerChest>
|
||||
{
|
||||
public GuiChest(ContainerChest container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
public GuiChest(ContainerChest container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(),
|
||||
this.itemRenderer, btn -> openPriority()));
|
||||
}
|
||||
|
||||
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriority() ) );
|
||||
}
|
||||
private void openPriority() {
|
||||
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE));
|
||||
}
|
||||
|
||||
private void openPriority() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.Chest.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.Chest.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/chest.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/chest.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,60 +18,54 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.container.implementations.ContainerCondenser;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class GuiCondenser extends AEBaseGui<ContainerCondenser> {
|
||||
|
||||
public class GuiCondenser extends AEBaseGui<ContainerCondenser>
|
||||
{
|
||||
private GuiSettingToggleButton<CondenserOutput> mode;
|
||||
|
||||
private GuiSettingToggleButton<CondenserOutput> mode;
|
||||
public GuiCondenser(ContainerCondenser container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 197;
|
||||
}
|
||||
|
||||
public GuiCondenser(ContainerCondenser container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 197;
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.mode = new GuiServerSettingToggleButton<>(128 + this.guiLeft, 52 + this.guiTop, Settings.CONDENSER_OUTPUT,
|
||||
this.container.getOutput());
|
||||
|
||||
this.mode = new GuiServerSettingToggleButton<>( 128 + this.guiLeft, 52 + this.guiTop, Settings.CONDENSER_OUTPUT, this.container.getOutput());
|
||||
this.addButton(new GuiProgressBar(this.container, "guis/condenser.png", 120 + this.guiLeft, 25 + this.guiTop,
|
||||
178, 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy.getLocal()));
|
||||
this.addButton(this.mode);
|
||||
}
|
||||
|
||||
this.addButton(new GuiProgressBar(this.container, "guis/condenser.png", 120 + this.guiLeft, 25 + this.guiTop, 178, 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy
|
||||
.getLocal()));
|
||||
this.addButton( this.mode );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.Condenser.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.Condenser.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
this.mode.set(this.container.getOutput());
|
||||
this.mode.setFillVar(String.valueOf(this.container.getOutput().requiredPower));
|
||||
}
|
||||
|
||||
this.mode.set( this.container.getOutput() );
|
||||
this.mode.setFillVar( String.valueOf( this.container.getOutput().requiredPower ) );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/condenser.png");
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/condenser.png" );
|
||||
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,11 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
@@ -26,193 +31,163 @@ import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCraftRequest;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiCraftAmount extends AEBaseGui<ContainerCraftAmount> {
|
||||
private final AESubGui subGui;
|
||||
|
||||
public class GuiCraftAmount extends AEBaseGui<ContainerCraftAmount>
|
||||
{
|
||||
private final AESubGui subGui;
|
||||
private GuiNumberBox amountToCraft;
|
||||
|
||||
private GuiNumberBox amountToCraft;
|
||||
private Button next;
|
||||
|
||||
private Button next;
|
||||
public GuiCraftAmount(ContainerCraftAmount container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubGui(this, container.getTarget());
|
||||
}
|
||||
|
||||
public GuiCraftAmount(ContainerCraftAmount container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubGui(this, container.getTarget());
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
final int a = AEConfig.instance().craftItemsByStackAmounts(0);
|
||||
final int b = AEConfig.instance().craftItemsByStackAmounts(1);
|
||||
final int c = AEConfig.instance().craftItemsByStackAmounts(2);
|
||||
final int d = AEConfig.instance().craftItemsByStackAmounts(3);
|
||||
|
||||
final int a = AEConfig.instance().craftItemsByStackAmounts( 0 );
|
||||
final int b = AEConfig.instance().craftItemsByStackAmounts( 1 );
|
||||
final int c = AEConfig.instance().craftItemsByStackAmounts( 2 );
|
||||
final int d = AEConfig.instance().craftItemsByStackAmounts( 3 );
|
||||
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a, btn -> addQty(a)));
|
||||
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b, btn -> addQty(b)));
|
||||
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c, btn -> addQty(c)));
|
||||
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d, btn -> addQty(d)));
|
||||
|
||||
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a, btn -> addQty(a) ) );
|
||||
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b, btn -> addQty(b) ) );
|
||||
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c, btn -> addQty(c) ) );
|
||||
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d, btn -> addQty(d) ) );
|
||||
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a, btn -> addQty(-a)));
|
||||
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b, btn -> addQty(-b)));
|
||||
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c, btn -> addQty(-c)));
|
||||
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d, btn -> addQty(-d)));
|
||||
|
||||
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a, btn -> addQty(-a) ) );
|
||||
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b, btn -> addQty(-b) ) );
|
||||
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c, btn -> addQty(-c) ) );
|
||||
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d, btn -> addQty(-d) ) );
|
||||
this.next = this.addButton(
|
||||
new Button(this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal(), this::confirm));
|
||||
|
||||
this.next = this.addButton(new Button(this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal(), this::confirm ));
|
||||
subGui.addBackButton(this::addButton, 154, 0);
|
||||
|
||||
subGui.addBackButton(this::addButton, 154, 0);
|
||||
this.amountToCraft = new GuiNumberBox(this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT,
|
||||
Integer.class);
|
||||
this.amountToCraft.setEnableBackgroundDrawing(false);
|
||||
this.amountToCraft.setMaxStringLength(16);
|
||||
this.amountToCraft.setTextColor(0xFFFFFF);
|
||||
this.amountToCraft.setVisible(true);
|
||||
this.amountToCraft.setFocused2(true);
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
|
||||
this.amountToCraft = new GuiNumberBox( this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT, Integer.class );
|
||||
this.amountToCraft.setEnableBackgroundDrawing( false );
|
||||
this.amountToCraft.setMaxStringLength( 16 );
|
||||
this.amountToCraft.setTextColor( 0xFFFFFF );
|
||||
this.amountToCraft.setVisible( true );
|
||||
this.amountToCraft.setFocused2( true );
|
||||
this.amountToCraft.setText( "1" );
|
||||
}
|
||||
private void confirm(Button button) {
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new PacketCraftRequest(Integer.parseInt(this.amountToCraft.getText()), hasShiftDown()));
|
||||
}
|
||||
|
||||
private void confirm(Button button) {
|
||||
NetworkHandler.instance().sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), hasShiftDown() ) );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.next.setMessage(hasShiftDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal());
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.next.setMessage(hasShiftDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal());
|
||||
this.bindTexture("guis/craft_amt.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
|
||||
this.bindTexture( "guis/craft_amt.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
try {
|
||||
Long.parseLong(this.amountToCraft.getText());
|
||||
this.next.active = !this.amountToCraft.getText().isEmpty();
|
||||
} catch (final NumberFormatException e) {
|
||||
this.next.active = false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Long.parseLong( this.amountToCraft.getText() );
|
||||
this.next.active = !this.amountToCraft.getText().isEmpty();
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
this.next.active = false;
|
||||
}
|
||||
this.amountToCraft.render(offsetX, offsetY, partialTicks);
|
||||
}
|
||||
|
||||
this.amountToCraft.render(offsetX, offsetY, partialTicks);
|
||||
}
|
||||
@Override
|
||||
public boolean charTyped(char ch, int p_charTyped_2_) {
|
||||
// Forward entered text to the craft amount text-field
|
||||
return this.amountToCraft.charTyped(ch, p_charTyped_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char ch, int p_charTyped_2_) {
|
||||
// Forward entered text to the craft amount text-field
|
||||
return this.amountToCraft.charTyped(ch, p_charTyped_2_);
|
||||
}
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) {
|
||||
if (keyCode == 28) {
|
||||
this.next.onPress();
|
||||
}
|
||||
if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14)
|
||||
&& this.amountToCraft.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) )
|
||||
{
|
||||
if( keyCode == 28 )
|
||||
{
|
||||
this.next.onPress();
|
||||
}
|
||||
if( ( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 )
|
||||
&& this.amountToCraft.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
String out = this.amountToCraft.getText();
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
boolean fixed = false;
|
||||
while( out.startsWith( "0" ) && out.length() > 1 )
|
||||
{
|
||||
out = out.substring( 1 );
|
||||
fixed = true;
|
||||
}
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
|
||||
if( fixed )
|
||||
{
|
||||
this.amountToCraft.setText( out );
|
||||
}
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
if( out.isEmpty() )
|
||||
{
|
||||
out = "0";
|
||||
}
|
||||
final long result = Long.parseLong(out);
|
||||
if (result < 0) {
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
final long result = Long.parseLong( out );
|
||||
if( result < 0 )
|
||||
{
|
||||
this.amountToCraft.setText( "1" );
|
||||
}
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
return super.keyPressed( keyCode, scanCode, p_keyPressed_3_ );
|
||||
}
|
||||
private void addQty(final int i) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
|
||||
private void addQty( final int i )
|
||||
{
|
||||
try
|
||||
{
|
||||
String out = this.amountToCraft.getText();
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
boolean fixed = false;
|
||||
while( out.startsWith( "0" ) && out.length() > 1 )
|
||||
{
|
||||
out = out.substring( 1 );
|
||||
fixed = true;
|
||||
}
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
|
||||
if( fixed )
|
||||
{
|
||||
this.amountToCraft.setText( out );
|
||||
}
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
if( out.isEmpty() )
|
||||
{
|
||||
out = "0";
|
||||
}
|
||||
long result = Integer.parseInt(out);
|
||||
|
||||
long result = Integer.parseInt( out );
|
||||
if (result == 1 && i > 1) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
if( result == 1 && i > 1 )
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
result += i;
|
||||
if (result < 1) {
|
||||
result = 1;
|
||||
}
|
||||
|
||||
result += i;
|
||||
if( result < 1 )
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
out = Long.toString(result);
|
||||
Integer.parseInt(out);
|
||||
this.amountToCraft.setText(out);
|
||||
} catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
out = Long.toString( result );
|
||||
Integer.parseInt( out );
|
||||
this.amountToCraft.setText( out );
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
protected String getBackground() {
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,21 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
@@ -31,493 +46,420 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class GuiCraftConfirm extends AEBaseGui<ContainerCraftConfirm>
|
||||
{
|
||||
|
||||
private final AESubGui subGui;
|
||||
|
||||
private final int rows = 5;
|
||||
|
||||
private final IItemList<IAEItemStack> storage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
private final IItemList<IAEItemStack> pending = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
private final IItemList<IAEItemStack> missing = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
|
||||
private final List<IAEItemStack> visual = new ArrayList<>();
|
||||
|
||||
private Button cancel;
|
||||
private Button start;
|
||||
private Button selectCPU;
|
||||
private int tooltip = -1;
|
||||
|
||||
public GuiCraftConfirm(ContainerCraftConfirm container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubGui(this, container.getTarget());
|
||||
this.xSize = 238;
|
||||
this.ySize = 206;
|
||||
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar( scrollbar );
|
||||
}
|
||||
|
||||
boolean isAutoStart()
|
||||
{
|
||||
return this.container.isAutoStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.start = new Button(this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal(), btn -> start() );
|
||||
this.start.active = false;
|
||||
this.addButton( this.start );
|
||||
|
||||
this.selectCPU = new Button(this.guiLeft + ( 219 - 180 ) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU
|
||||
.getLocal() + ": " + GuiText.Automatic, btn -> selectNextCpu() );
|
||||
this.selectCPU.active = false;
|
||||
this.addButton( this.selectCPU );
|
||||
|
||||
subGui.addBackButton(this::addButton, 6, this.ySize - 25, GuiText.Cancel.getLocal());
|
||||
|
||||
this.addButton( this.cancel );
|
||||
}
|
||||
@Override
|
||||
public void render(final int mouseX, final int mouseY, final float btn )
|
||||
{
|
||||
this.updateCPUButtonText();
|
||||
|
||||
this.start.active = !( this.container.hasNoCPU() || this.isSimulation() );
|
||||
this.selectCPU.active = !this.isSimulation();
|
||||
|
||||
final int gx = ( this.width - this.xSize ) / 2;
|
||||
final int gy = ( this.height - this.ySize ) / 2;
|
||||
|
||||
this.tooltip = -1;
|
||||
|
||||
final int offY = 23;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for( int z = 0; z <= 4 * 5; z++ )
|
||||
{
|
||||
final int minX = gx + 9 + x * 67;
|
||||
final int minY = gy + 22 + y * offY;
|
||||
|
||||
if( minX < mouseX && minX + 67 > mouseX )
|
||||
{
|
||||
if( minY < mouseY && minY + offY - 2 > mouseY )
|
||||
{
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.render( mouseX, mouseY, btn );
|
||||
}
|
||||
|
||||
private void updateCPUButtonText()
|
||||
{
|
||||
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
|
||||
if( this.container.getSelectedCpu() >= 0 )// && status.selectedCpu < status.cpus.size() )
|
||||
{
|
||||
if( this.container.getName().length() > 0 )
|
||||
{
|
||||
final String name = this.container.getName().substring( 0, Math.min( 20, this.container.getName().length() ) );
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
|
||||
}
|
||||
else
|
||||
{
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.container.getSelectedCpu();
|
||||
}
|
||||
}
|
||||
|
||||
if( this.container.hasNoCPU() )
|
||||
{
|
||||
btnTextText = GuiText.NoCraftingCPUs.getLocal();
|
||||
}
|
||||
|
||||
this.selectCPU.setMessage(btnTextText);
|
||||
}
|
||||
|
||||
private boolean isSimulation()
|
||||
{
|
||||
return this.container.isSimulation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
final long BytesUsed = this.container.getUsedBytes();
|
||||
final String byteUsed = NumberFormat.getInstance().format( BytesUsed );
|
||||
final String Add = BytesUsed > 0 ? ( byteUsed + ' ' + GuiText.BytesUsed.getLocal() ) : GuiText.CalculatingWait.getLocal();
|
||||
this.font.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 );
|
||||
|
||||
String dsp = null;
|
||||
|
||||
if( this.isSimulation() )
|
||||
{
|
||||
dsp = GuiText.Simulation.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
dsp = this.container.getCpuAvailableBytes() > 0 ? ( GuiText.Bytes.getLocal() + ": " + this.container.getCpuAvailableBytes() + " : " + GuiText.CoProcessors
|
||||
.getLocal() + ": " + this.container.getCpuCoProcessors() ) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
|
||||
}
|
||||
|
||||
final int offset = ( 219 - this.font.getStringWidth( dsp ) ) / 2;
|
||||
this.font.drawString( dsp, offset, 165, 4210752 );
|
||||
|
||||
final int sectionLength = 67;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int xo = 9;
|
||||
final int yo = 22;
|
||||
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
|
||||
final int viewEnd = viewStart + 3 * this.rows;
|
||||
|
||||
String dspToolTip = "";
|
||||
final List<String> lineList = new ArrayList<>();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
final int offY = 23;
|
||||
|
||||
for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ )
|
||||
{
|
||||
final IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
|
||||
if( refStack != null )
|
||||
{
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef( 0.5f, 0.5f, 0.5f );
|
||||
|
||||
final IAEItemStack stored = this.storage.findPrecise( refStack );
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise( refStack );
|
||||
final IAEItemStack missingStack = this.missing.findPrecise( refStack );
|
||||
|
||||
int lines = 0;
|
||||
|
||||
if( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
}
|
||||
if( missingStack != null && missingStack.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
}
|
||||
if( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
}
|
||||
|
||||
final int negY = ( ( lines - 1 ) * 5 ) / 2;
|
||||
int downY = 0;
|
||||
|
||||
if( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( stored.getStackSize() );
|
||||
if( stored.getStackSize() >= 10000 )
|
||||
{
|
||||
str = Long.toString( stored.getStackSize() / 1000 ) + 'k';
|
||||
}
|
||||
if( stored.getStackSize() >= 10000000 )
|
||||
{
|
||||
str = Long.toString( stored.getStackSize() / 1000000 ) + 'm';
|
||||
}
|
||||
|
||||
str = GuiText.FromStorage.getLocal() + ": " + str;
|
||||
final int w = 4 + this.font.getStringWidth( str );
|
||||
this.font.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ),
|
||||
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
boolean red = false;
|
||||
if( missingStack != null && missingStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( missingStack.getStackSize() );
|
||||
if( missingStack.getStackSize() >= 10000 )
|
||||
{
|
||||
str = Long.toString( missingStack.getStackSize() / 1000 ) + 'k';
|
||||
}
|
||||
if( missingStack.getStackSize() >= 10000000 )
|
||||
{
|
||||
str = Long.toString( missingStack.getStackSize() / 1000000 ) + 'm';
|
||||
}
|
||||
|
||||
str = GuiText.Missing.getLocal() + ": " + str;
|
||||
final int w = 4 + this.font.getStringWidth( str );
|
||||
this.font.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ),
|
||||
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) );
|
||||
}
|
||||
|
||||
red = true;
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( pendingStack.getStackSize() );
|
||||
if( pendingStack.getStackSize() >= 10000 )
|
||||
{
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000 ) + 'k';
|
||||
}
|
||||
if( pendingStack.getStackSize() >= 10000000 )
|
||||
{
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + 'm';
|
||||
}
|
||||
|
||||
str = GuiText.ToCraft.getLocal() + ": " + str;
|
||||
final int w = 4 + this.font.getStringWidth( str );
|
||||
this.font.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ),
|
||||
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
|
||||
}
|
||||
}
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
|
||||
final int posY = y * offY + yo;
|
||||
|
||||
final ItemStack is = refStack.asItemStackRepresentation();
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
dspToolTip = Platform.getItemDisplayName( refStack ).getFormattedText();
|
||||
|
||||
if( lineList.size() > 0 )
|
||||
{
|
||||
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
|
||||
}
|
||||
|
||||
toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8;
|
||||
toolPosY = y * offY + yo;
|
||||
}
|
||||
|
||||
this.drawItem( posX, posY, is );
|
||||
|
||||
if( red )
|
||||
{
|
||||
final int startX = x * ( 1 + sectionLength ) + xo;
|
||||
final int startY = posY - 4;
|
||||
fill( startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000 );
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.tooltip >= 0 && !dspToolTip.isEmpty() )
|
||||
{
|
||||
this.drawTooltip( toolPosX, toolPosY + 10, dspToolTip );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.setScrollBar();
|
||||
this.bindTexture( "guis/craftingreport.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
final int size = this.visual.size();
|
||||
|
||||
this.getScrollBar().setTop( 19 ).setLeft( 218 ).setHeight( 114 );
|
||||
this.getScrollBar().setRange( 0, ( size + 2 ) / 3 - this.rows, 1 );
|
||||
}
|
||||
|
||||
public void postUpdate( final List<IAEItemStack> list, final byte ref )
|
||||
{
|
||||
switch( ref )
|
||||
{
|
||||
case 0:
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
this.handleInput( this.storage, l );
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
this.handleInput( this.pending, l );
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
this.handleInput( this.missing, l );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
final long amt = this.getTotal( l );
|
||||
|
||||
if( amt <= 0 )
|
||||
{
|
||||
this.deleteVisualStack( l );
|
||||
}
|
||||
else
|
||||
{
|
||||
final IAEItemStack is = this.findVisualStack( l );
|
||||
is.setStackSize( amt );
|
||||
}
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput( final IItemList<IAEItemStack> s, final IAEItemStack l )
|
||||
{
|
||||
IAEItemStack a = s.findPrecise( l );
|
||||
|
||||
if( l.getStackSize() <= 0 )
|
||||
{
|
||||
if( a != null )
|
||||
{
|
||||
a.reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( a == null )
|
||||
{
|
||||
s.add( l.copy() );
|
||||
a = s.findPrecise( l );
|
||||
}
|
||||
|
||||
if( a != null )
|
||||
{
|
||||
a.setStackSize( l.getStackSize() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long getTotal( final IAEItemStack is )
|
||||
{
|
||||
final IAEItemStack a = this.storage.findPrecise( is );
|
||||
final IAEItemStack c = this.pending.findPrecise( is );
|
||||
final IAEItemStack m = this.missing.findPrecise( is );
|
||||
|
||||
long total = 0;
|
||||
|
||||
if( a != null )
|
||||
{
|
||||
total += a.getStackSize();
|
||||
}
|
||||
|
||||
if( c != null )
|
||||
{
|
||||
total += c.getStackSize();
|
||||
}
|
||||
|
||||
if( m != null )
|
||||
{
|
||||
total += m.getStackSize();
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
private void deleteVisualStack( final IAEItemStack l )
|
||||
{
|
||||
final Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
final IAEItemStack o = i.next();
|
||||
if( o.equals( l ) )
|
||||
{
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack( final IAEItemStack l )
|
||||
{
|
||||
for( final IAEItemStack o : this.visual )
|
||||
{
|
||||
if( o.equals( l ) )
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
final IAEItemStack stack = l.copy();
|
||||
this.visual.add( stack );
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) )
|
||||
{
|
||||
if( keyCode == 28 )
|
||||
{
|
||||
this.start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
private void selectNextCpu() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
|
||||
private void start() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) );
|
||||
}
|
||||
|
||||
public class GuiCraftConfirm extends AEBaseGui<ContainerCraftConfirm> {
|
||||
|
||||
private final AESubGui subGui;
|
||||
|
||||
private final int rows = 5;
|
||||
|
||||
private final IItemList<IAEItemStack> storage = AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private final IItemList<IAEItemStack> pending = AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private final IItemList<IAEItemStack> missing = AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
private final List<IAEItemStack> visual = new ArrayList<>();
|
||||
|
||||
private Button cancel;
|
||||
private Button start;
|
||||
private Button selectCPU;
|
||||
private int tooltip = -1;
|
||||
|
||||
public GuiCraftConfirm(ContainerCraftConfirm container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubGui(this, container.getTarget());
|
||||
this.xSize = 238;
|
||||
this.ySize = 206;
|
||||
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
}
|
||||
|
||||
boolean isAutoStart() {
|
||||
return this.container.isAutoStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.start = new Button(this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal(),
|
||||
btn -> start());
|
||||
this.start.active = false;
|
||||
this.addButton(this.start);
|
||||
|
||||
this.selectCPU = new Button(this.guiLeft + (219 - 180) / 2, this.guiTop + this.ySize - 68, 180, 20,
|
||||
GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic, btn -> selectNextCpu());
|
||||
this.selectCPU.active = false;
|
||||
this.addButton(this.selectCPU);
|
||||
|
||||
subGui.addBackButton(this::addButton, 6, this.ySize - 25, GuiText.Cancel.getLocal());
|
||||
|
||||
this.addButton(this.cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final int mouseX, final int mouseY, final float btn) {
|
||||
this.updateCPUButtonText();
|
||||
|
||||
this.start.active = !(this.container.hasNoCPU() || this.isSimulation());
|
||||
this.selectCPU.active = !this.isSimulation();
|
||||
|
||||
final int gx = (this.width - this.xSize) / 2;
|
||||
final int gy = (this.height - this.ySize) / 2;
|
||||
|
||||
this.tooltip = -1;
|
||||
|
||||
final int offY = 23;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for (int z = 0; z <= 4 * 5; z++) {
|
||||
final int minX = gx + 9 + x * 67;
|
||||
final int minY = gy + 22 + y * offY;
|
||||
|
||||
if (minX < mouseX && minX + 67 > mouseX) {
|
||||
if (minY < mouseY && minY + offY - 2 > mouseY) {
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.render(mouseX, mouseY, btn);
|
||||
}
|
||||
|
||||
private void updateCPUButtonText() {
|
||||
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
|
||||
if (this.container.getSelectedCpu() >= 0)// && status.selectedCpu < status.cpus.size() )
|
||||
{
|
||||
if (this.container.getName().length() > 0) {
|
||||
final String name = this.container.getName().substring(0,
|
||||
Math.min(20, this.container.getName().length()));
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
|
||||
} else {
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.container.getSelectedCpu();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.container.hasNoCPU()) {
|
||||
btnTextText = GuiText.NoCraftingCPUs.getLocal();
|
||||
}
|
||||
|
||||
this.selectCPU.setMessage(btnTextText);
|
||||
}
|
||||
|
||||
private boolean isSimulation() {
|
||||
return this.container.isSimulation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
final long BytesUsed = this.container.getUsedBytes();
|
||||
final String byteUsed = NumberFormat.getInstance().format(BytesUsed);
|
||||
final String Add = BytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal())
|
||||
: GuiText.CalculatingWait.getLocal();
|
||||
this.font.drawString(GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752);
|
||||
|
||||
String dsp = null;
|
||||
|
||||
if (this.isSimulation()) {
|
||||
dsp = GuiText.Simulation.getLocal();
|
||||
} else {
|
||||
dsp = this.container.getCpuAvailableBytes() > 0
|
||||
? (GuiText.Bytes.getLocal() + ": " + this.container.getCpuAvailableBytes() + " : "
|
||||
+ GuiText.CoProcessors.getLocal() + ": " + this.container.getCpuCoProcessors())
|
||||
: GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
|
||||
}
|
||||
|
||||
final int offset = (219 - this.font.getStringWidth(dsp)) / 2;
|
||||
this.font.drawString(dsp, offset, 165, 4210752);
|
||||
|
||||
final int sectionLength = 67;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int xo = 9;
|
||||
final int yo = 22;
|
||||
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
|
||||
final int viewEnd = viewStart + 3 * this.rows;
|
||||
|
||||
String dspToolTip = "";
|
||||
final List<String> lineList = new ArrayList<>();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
final int offY = 23;
|
||||
|
||||
for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) {
|
||||
final IAEItemStack refStack = this.visual.get(z);// repo.getReferenceItem( z );
|
||||
if (refStack != null) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
final IAEItemStack stored = this.storage.findPrecise(refStack);
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise(refStack);
|
||||
final IAEItemStack missingStack = this.missing.findPrecise(refStack);
|
||||
|
||||
int lines = 0;
|
||||
|
||||
if (stored != null && stored.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
if (missingStack != null && missingStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
|
||||
final int negY = ((lines - 1) * 5) / 2;
|
||||
int downY = 0;
|
||||
|
||||
if (stored != null && stored.getStackSize() > 0) {
|
||||
String str = Long.toString(stored.getStackSize());
|
||||
if (stored.getStackSize() >= 10000) {
|
||||
str = Long.toString(stored.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (stored.getStackSize() >= 10000000) {
|
||||
str = Long.toString(stored.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
|
||||
str = GuiText.FromStorage.getLocal() + ": " + str;
|
||||
final int w = 4 + this.font.getStringWidth(str);
|
||||
this.font.drawString(str,
|
||||
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
|
||||
(y * offY + yo + 6 - negY + downY) * 2, 4210752);
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.FromStorage.getLocal() + ": " + Long.toString(stored.getStackSize()));
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
boolean red = false;
|
||||
if (missingStack != null && missingStack.getStackSize() > 0) {
|
||||
String str = Long.toString(missingStack.getStackSize());
|
||||
if (missingStack.getStackSize() >= 10000) {
|
||||
str = Long.toString(missingStack.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (missingStack.getStackSize() >= 10000000) {
|
||||
str = Long.toString(missingStack.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
|
||||
str = GuiText.Missing.getLocal() + ": " + str;
|
||||
final int w = 4 + this.font.getStringWidth(str);
|
||||
this.font.drawString(str,
|
||||
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
|
||||
(y * offY + yo + 6 - negY + downY) * 2, 4210752);
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.Missing.getLocal() + ": " + Long.toString(missingStack.getStackSize()));
|
||||
}
|
||||
|
||||
red = true;
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
String str = Long.toString(pendingStack.getStackSize());
|
||||
if (pendingStack.getStackSize() >= 10000) {
|
||||
str = Long.toString(pendingStack.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
if (pendingStack.getStackSize() >= 10000000) {
|
||||
str = Long.toString(pendingStack.getStackSize() / 1000000) + 'm';
|
||||
}
|
||||
|
||||
str = GuiText.ToCraft.getLocal() + ": " + str;
|
||||
final int w = 4 + this.font.getStringWidth(str);
|
||||
this.font.drawString(str,
|
||||
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
|
||||
(y * offY + yo + 6 - negY + downY) * 2, 4210752);
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.ToCraft.getLocal() + ": " + Long.toString(pendingStack.getStackSize()));
|
||||
}
|
||||
}
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
|
||||
final int posY = y * offY + yo;
|
||||
|
||||
final ItemStack is = refStack.asItemStackRepresentation();
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
dspToolTip = Platform.getItemDisplayName(refStack).getFormattedText();
|
||||
|
||||
if (lineList.size() > 0) {
|
||||
dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
|
||||
}
|
||||
|
||||
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
|
||||
toolPosY = y * offY + yo;
|
||||
}
|
||||
|
||||
this.drawItem(posX, posY, is);
|
||||
|
||||
if (red) {
|
||||
final int startX = x * (1 + sectionLength) + xo;
|
||||
final int startY = posY - 4;
|
||||
fill(startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000);
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tooltip >= 0 && !dspToolTip.isEmpty()) {
|
||||
this.drawTooltip(toolPosX, toolPosY + 10, dspToolTip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.setScrollBar();
|
||||
this.bindTexture("guis/craftingreport.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
final int size = this.visual.size();
|
||||
|
||||
this.getScrollBar().setTop(19).setLeft(218).setHeight(114);
|
||||
this.getScrollBar().setRange(0, (size + 2) / 3 - this.rows, 1);
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
|
||||
switch (ref) {
|
||||
case 0:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.storage, l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.pending, l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.missing, l);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (final IAEItemStack l : list) {
|
||||
final long amt = this.getTotal(l);
|
||||
|
||||
if (amt <= 0) {
|
||||
this.deleteVisualStack(l);
|
||||
} else {
|
||||
final IAEItemStack is = this.findVisualStack(l);
|
||||
is.setStackSize(amt);
|
||||
}
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput(final IItemList<IAEItemStack> s, final IAEItemStack l) {
|
||||
IAEItemStack a = s.findPrecise(l);
|
||||
|
||||
if (l.getStackSize() <= 0) {
|
||||
if (a != null) {
|
||||
a.reset();
|
||||
}
|
||||
} else {
|
||||
if (a == null) {
|
||||
s.add(l.copy());
|
||||
a = s.findPrecise(l);
|
||||
}
|
||||
|
||||
if (a != null) {
|
||||
a.setStackSize(l.getStackSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long getTotal(final IAEItemStack is) {
|
||||
final IAEItemStack a = this.storage.findPrecise(is);
|
||||
final IAEItemStack c = this.pending.findPrecise(is);
|
||||
final IAEItemStack m = this.missing.findPrecise(is);
|
||||
|
||||
long total = 0;
|
||||
|
||||
if (a != null) {
|
||||
total += a.getStackSize();
|
||||
}
|
||||
|
||||
if (c != null) {
|
||||
total += c.getStackSize();
|
||||
}
|
||||
|
||||
if (m != null) {
|
||||
total += m.getStackSize();
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
private void deleteVisualStack(final IAEItemStack l) {
|
||||
final Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
while (i.hasNext()) {
|
||||
final IAEItemStack o = i.next();
|
||||
if (o.equals(l)) {
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack(final IAEItemStack l) {
|
||||
for (final IAEItemStack o : this.visual) {
|
||||
if (o.equals(l)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
final IAEItemStack stack = l.copy();
|
||||
this.visual.add(stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) {
|
||||
if (keyCode == 28) {
|
||||
this.start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
private void selectNextCpu() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("Terminal.Cpu", backwards ? "Prev" : "Next"));
|
||||
}
|
||||
|
||||
private void start() {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("Terminal.Start", "Start"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,21 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SortDir;
|
||||
@@ -37,434 +52,378 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
public class GuiCraftingCPU<T extends ContainerCraftingCPU> extends AEBaseGui<T> implements ISortSource
|
||||
{
|
||||
private static final int GUI_HEIGHT = 184;
|
||||
private static final int GUI_WIDTH = 238;
|
||||
|
||||
private static final int DISPLAYED_ROWS = 6;
|
||||
|
||||
private static final int TEXT_COLOR = 0x404040;
|
||||
private static final int BACKGROUND_ALPHA = 0x5A000000;
|
||||
|
||||
private static final int SECTION_LENGTH = 67;
|
||||
|
||||
private static final int SCROLLBAR_TOP = 19;
|
||||
private static final int SCROLLBAR_LEFT = 218;
|
||||
private static final int SCROLLBAR_HEIGHT = 137;
|
||||
|
||||
private static final int CANCEL_LEFT_OFFSET = 163;
|
||||
private static final int CANCEL_TOP_OFFSET = 25;
|
||||
private static final int CANCEL_HEIGHT = 20;
|
||||
private static final int CANCEL_WIDTH = 50;
|
||||
|
||||
private static final int TITLE_TOP_OFFSET = 7;
|
||||
private static final int TITLE_LEFT_OFFSET = 8;
|
||||
|
||||
private static final int ITEMSTACK_LEFT_OFFSET = 9;
|
||||
private static final int ITEMSTACK_TOP_OFFSET = 22;
|
||||
|
||||
private IItemList<IAEItemStack> storage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
private IItemList<IAEItemStack> active = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
private IItemList<IAEItemStack> pending = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
|
||||
private List<IAEItemStack> visual = new ArrayList<>();
|
||||
private Button cancel;
|
||||
private int tooltip = -1;
|
||||
|
||||
public GuiCraftingCPU(T container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = GUI_HEIGHT;
|
||||
this.xSize = GUI_WIDTH;
|
||||
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar( scrollbar );
|
||||
}
|
||||
|
||||
public void clearItems()
|
||||
{
|
||||
this.storage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
this.active = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
this.pending = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
this.visual = new ArrayList<>();
|
||||
}
|
||||
|
||||
private void cancel() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.setScrollBar();
|
||||
this.cancel = new Button(this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET, CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel
|
||||
.getLocal(), btn -> cancel() );
|
||||
this.addButton( this.cancel );
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
final int size = this.visual.size();
|
||||
|
||||
this.getScrollBar().setTop( SCROLLBAR_TOP ).setLeft( SCROLLBAR_LEFT ).setHeight( SCROLLBAR_HEIGHT );
|
||||
this.getScrollBar().setRange( 0, ( size + 2 ) / 3 - DISPLAYED_ROWS, 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final int mouseX, final int mouseY, final float btn )
|
||||
{
|
||||
this.cancel.active = !this.visual.isEmpty();
|
||||
|
||||
final int gx = ( this.width - this.xSize ) / 2;
|
||||
final int gy = ( this.height - this.ySize ) / 2;
|
||||
|
||||
this.tooltip = -1;
|
||||
|
||||
final int offY = 23;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for( int z = 0; z <= 4 * 5; z++ )
|
||||
{
|
||||
final int minX = gx + 9 + x * 67;
|
||||
final int minY = gy + 22 + y * offY;
|
||||
|
||||
if( minX < mouseX && minX + 67 > mouseX )
|
||||
{
|
||||
if( minY < mouseY && minY + offY - 2 > mouseY )
|
||||
{
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.render( mouseX, mouseY, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
String title = this.getGuiDisplayName( GuiText.CraftingStatus.getLocal() );
|
||||
|
||||
if( this.container.getEstimatedTime() > 0 && !this.visual.isEmpty() )
|
||||
{
|
||||
final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert( this.container.getEstimatedTime(), TimeUnit.NANOSECONDS );
|
||||
final String etaTimeText = DurationFormatUtils.formatDuration( etaInMilliseconds, GuiText.ETAFormat.getLocal() );
|
||||
title += " - " + etaTimeText;
|
||||
}
|
||||
|
||||
this.font.drawString( title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR );
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
|
||||
final int viewEnd = viewStart + 3 * 6;
|
||||
|
||||
String dspToolTip = "";
|
||||
final List<String> lineList = new ArrayList<>();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
final int offY = 23;
|
||||
|
||||
final ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE;
|
||||
for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ )
|
||||
{
|
||||
final IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
|
||||
if( refStack != null )
|
||||
{
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef( 0.5f, 0.5f, 0.5f );
|
||||
|
||||
final IAEItemStack stored = this.storage.findPrecise( refStack );
|
||||
final IAEItemStack activeStack = this.active.findPrecise( refStack );
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise( refStack );
|
||||
|
||||
int lines = 0;
|
||||
|
||||
if( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
}
|
||||
boolean active = false;
|
||||
if( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
active = true;
|
||||
}
|
||||
boolean scheduled = false;
|
||||
if( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
scheduled = true;
|
||||
}
|
||||
|
||||
if( AEConfig.instance().isUseColoredCraftingStatus() && ( active || scheduled ) )
|
||||
{
|
||||
final int bgColor = ( active ? AEColor.GREEN.blackVariant : AEColor.YELLOW.blackVariant ) | BACKGROUND_ALPHA;
|
||||
final int startX = ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET ) * 2;
|
||||
final int startY = ( ( y * offY + ITEMSTACK_TOP_OFFSET ) - 3 ) * 2;
|
||||
fill( startX, startY, startX + ( SECTION_LENGTH * 2 ), startY + ( offY * 2 ) - 2, bgColor );
|
||||
}
|
||||
|
||||
final int negY = ( ( lines - 1 ) * 5 ) / 2;
|
||||
int downY = 0;
|
||||
|
||||
if( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
final String str = GuiText.Stored.getLocal() + ": " + converter.toWideReadableForm( stored.getStackSize() );
|
||||
final int w = 4 + this.font.getStringWidth( str );
|
||||
this.font.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ),
|
||||
( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
{
|
||||
final String str = GuiText.Crafting.getLocal() + ": " + converter.toWideReadableForm( activeStack.getStackSize() );
|
||||
final int w = 4 + this.font.getStringWidth( str );
|
||||
|
||||
this.font.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ),
|
||||
( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) );
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
final String str = GuiText.Scheduled.getLocal() + ": " + converter.toWideReadableForm( pendingStack.getStackSize() );
|
||||
final int w = 4 + this.font.getStringWidth( str );
|
||||
|
||||
this.font.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ),
|
||||
( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
|
||||
}
|
||||
}
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
|
||||
final int posY = y * offY + ITEMSTACK_TOP_OFFSET;
|
||||
|
||||
final ItemStack is = refStack.asItemStackRepresentation();
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
dspToolTip = Platform.getItemDisplayName( refStack ).getFormattedText();
|
||||
|
||||
if( lineList.size() > 0 )
|
||||
{
|
||||
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
|
||||
}
|
||||
|
||||
toolPosX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8;
|
||||
toolPosY = y * offY + ITEMSTACK_TOP_OFFSET;
|
||||
}
|
||||
|
||||
this.drawItem( posX, posY, is );
|
||||
|
||||
x++;
|
||||
|
||||
if( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.tooltip >= 0 && !dspToolTip.isEmpty() )
|
||||
{
|
||||
this.drawTooltip( toolPosX, toolPosY + 10, dspToolTip );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/craftingcpu.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
|
||||
public void postUpdate( final List<IAEItemStack> list, final byte ref )
|
||||
{
|
||||
switch( ref )
|
||||
{
|
||||
case 0:
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
this.handleInput( this.storage, l );
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
this.handleInput( this.active, l );
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
this.handleInput( this.pending, l );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for( final IAEItemStack l : list )
|
||||
{
|
||||
final long amt = this.getTotal( l );
|
||||
|
||||
if( amt <= 0 )
|
||||
{
|
||||
this.deleteVisualStack( l );
|
||||
}
|
||||
else
|
||||
{
|
||||
final IAEItemStack is = this.findVisualStack( l );
|
||||
is.setStackSize( amt );
|
||||
}
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput( final IItemList<IAEItemStack> s, final IAEItemStack l )
|
||||
{
|
||||
IAEItemStack a = s.findPrecise( l );
|
||||
|
||||
if( l.getStackSize() <= 0 )
|
||||
{
|
||||
if( a != null )
|
||||
{
|
||||
a.reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( a == null )
|
||||
{
|
||||
s.add( l.copy() );
|
||||
a = s.findPrecise( l );
|
||||
}
|
||||
|
||||
if( a != null )
|
||||
{
|
||||
a.setStackSize( l.getStackSize() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long getTotal( final IAEItemStack is )
|
||||
{
|
||||
final IAEItemStack a = this.storage.findPrecise( is );
|
||||
final IAEItemStack b = this.active.findPrecise( is );
|
||||
final IAEItemStack c = this.pending.findPrecise( is );
|
||||
|
||||
long total = 0;
|
||||
|
||||
if( a != null )
|
||||
{
|
||||
total += a.getStackSize();
|
||||
}
|
||||
|
||||
if( b != null )
|
||||
{
|
||||
total += b.getStackSize();
|
||||
}
|
||||
|
||||
if( c != null )
|
||||
{
|
||||
total += c.getStackSize();
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
private void deleteVisualStack( final IAEItemStack l )
|
||||
{
|
||||
final Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
|
||||
while( i.hasNext() )
|
||||
{
|
||||
final IAEItemStack o = i.next();
|
||||
if( o.equals( l ) )
|
||||
{
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack( final IAEItemStack l )
|
||||
{
|
||||
for( final IAEItemStack o : this.visual )
|
||||
{
|
||||
if( o.equals( l ) )
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
final IAEItemStack stack = l.copy();
|
||||
this.visual.add( stack );
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortOrder getSortBy()
|
||||
{
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortDir getSortDir()
|
||||
{
|
||||
return SortDir.ASCENDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewItems getSortDisplay()
|
||||
{
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
|
||||
public class GuiCraftingCPU<T extends ContainerCraftingCPU> extends AEBaseGui<T> implements ISortSource {
|
||||
private static final int GUI_HEIGHT = 184;
|
||||
private static final int GUI_WIDTH = 238;
|
||||
|
||||
private static final int DISPLAYED_ROWS = 6;
|
||||
|
||||
private static final int TEXT_COLOR = 0x404040;
|
||||
private static final int BACKGROUND_ALPHA = 0x5A000000;
|
||||
|
||||
private static final int SECTION_LENGTH = 67;
|
||||
|
||||
private static final int SCROLLBAR_TOP = 19;
|
||||
private static final int SCROLLBAR_LEFT = 218;
|
||||
private static final int SCROLLBAR_HEIGHT = 137;
|
||||
|
||||
private static final int CANCEL_LEFT_OFFSET = 163;
|
||||
private static final int CANCEL_TOP_OFFSET = 25;
|
||||
private static final int CANCEL_HEIGHT = 20;
|
||||
private static final int CANCEL_WIDTH = 50;
|
||||
|
||||
private static final int TITLE_TOP_OFFSET = 7;
|
||||
private static final int TITLE_LEFT_OFFSET = 8;
|
||||
|
||||
private static final int ITEMSTACK_LEFT_OFFSET = 9;
|
||||
private static final int ITEMSTACK_TOP_OFFSET = 22;
|
||||
|
||||
private IItemList<IAEItemStack> storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createList();
|
||||
private IItemList<IAEItemStack> active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createList();
|
||||
private IItemList<IAEItemStack> pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createList();
|
||||
|
||||
private List<IAEItemStack> visual = new ArrayList<>();
|
||||
private Button cancel;
|
||||
private int tooltip = -1;
|
||||
|
||||
public GuiCraftingCPU(T container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = GUI_HEIGHT;
|
||||
this.xSize = GUI_WIDTH;
|
||||
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
this.storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.visual = new ArrayList<>();
|
||||
}
|
||||
|
||||
private void cancel() {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("TileCrafting.Cancel", "Cancel"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
this.setScrollBar();
|
||||
this.cancel = new Button(this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET,
|
||||
CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel.getLocal(), btn -> cancel());
|
||||
this.addButton(this.cancel);
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
final int size = this.visual.size();
|
||||
|
||||
this.getScrollBar().setTop(SCROLLBAR_TOP).setLeft(SCROLLBAR_LEFT).setHeight(SCROLLBAR_HEIGHT);
|
||||
this.getScrollBar().setRange(0, (size + 2) / 3 - DISPLAYED_ROWS, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final int mouseX, final int mouseY, final float btn) {
|
||||
this.cancel.active = !this.visual.isEmpty();
|
||||
|
||||
final int gx = (this.width - this.xSize) / 2;
|
||||
final int gy = (this.height - this.ySize) / 2;
|
||||
|
||||
this.tooltip = -1;
|
||||
|
||||
final int offY = 23;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for (int z = 0; z <= 4 * 5; z++) {
|
||||
final int minX = gx + 9 + x * 67;
|
||||
final int minY = gy + 22 + y * offY;
|
||||
|
||||
if (minX < mouseX && minX + 67 > mouseX) {
|
||||
if (minY < mouseY && minY + offY - 2 > mouseY) {
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.render(mouseX, mouseY, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
String title = this.getGuiDisplayName(GuiText.CraftingStatus.getLocal());
|
||||
|
||||
if (this.container.getEstimatedTime() > 0 && !this.visual.isEmpty()) {
|
||||
final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert(this.container.getEstimatedTime(),
|
||||
TimeUnit.NANOSECONDS);
|
||||
final String etaTimeText = DurationFormatUtils.formatDuration(etaInMilliseconds,
|
||||
GuiText.ETAFormat.getLocal());
|
||||
title += " - " + etaTimeText;
|
||||
}
|
||||
|
||||
this.font.drawString(title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR);
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
|
||||
final int viewEnd = viewStart + 3 * 6;
|
||||
|
||||
String dspToolTip = "";
|
||||
final List<String> lineList = new ArrayList<>();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
final int offY = 23;
|
||||
|
||||
final ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE;
|
||||
for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) {
|
||||
final IAEItemStack refStack = this.visual.get(z);// repo.getReferenceItem( z );
|
||||
if (refStack != null) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
final IAEItemStack stored = this.storage.findPrecise(refStack);
|
||||
final IAEItemStack activeStack = this.active.findPrecise(refStack);
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise(refStack);
|
||||
|
||||
int lines = 0;
|
||||
|
||||
if (stored != null && stored.getStackSize() > 0) {
|
||||
lines++;
|
||||
}
|
||||
boolean active = false;
|
||||
if (activeStack != null && activeStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
active = true;
|
||||
}
|
||||
boolean scheduled = false;
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
lines++;
|
||||
scheduled = true;
|
||||
}
|
||||
|
||||
if (AEConfig.instance().isUseColoredCraftingStatus() && (active || scheduled)) {
|
||||
final int bgColor = (active ? AEColor.GREEN.blackVariant : AEColor.YELLOW.blackVariant)
|
||||
| BACKGROUND_ALPHA;
|
||||
final int startX = (x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET) * 2;
|
||||
final int startY = ((y * offY + ITEMSTACK_TOP_OFFSET) - 3) * 2;
|
||||
fill(startX, startY, startX + (SECTION_LENGTH * 2), startY + (offY * 2) - 2, bgColor);
|
||||
}
|
||||
|
||||
final int negY = ((lines - 1) * 5) / 2;
|
||||
int downY = 0;
|
||||
|
||||
if (stored != null && stored.getStackSize() > 0) {
|
||||
final String str = GuiText.Stored.getLocal() + ": "
|
||||
+ converter.toWideReadableForm(stored.getStackSize());
|
||||
final int w = 4 + this.font.getStringWidth(str);
|
||||
this.font.drawString(str,
|
||||
(int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5))
|
||||
* 2),
|
||||
(y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.Stored.getLocal() + ": " + Long.toString(stored.getStackSize()));
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if (activeStack != null && activeStack.getStackSize() > 0) {
|
||||
final String str = GuiText.Crafting.getLocal() + ": "
|
||||
+ converter.toWideReadableForm(activeStack.getStackSize());
|
||||
final int w = 4 + this.font.getStringWidth(str);
|
||||
|
||||
this.font.drawString(str,
|
||||
(int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5))
|
||||
* 2),
|
||||
(y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.Crafting.getLocal() + ": " + Long.toString(activeStack.getStackSize()));
|
||||
}
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if (pendingStack != null && pendingStack.getStackSize() > 0) {
|
||||
final String str = GuiText.Scheduled.getLocal() + ": "
|
||||
+ converter.toWideReadableForm(pendingStack.getStackSize());
|
||||
final int w = 4 + this.font.getStringWidth(str);
|
||||
|
||||
this.font.drawString(str,
|
||||
(int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - (w * 0.5))
|
||||
* 2),
|
||||
(y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
lineList.add(GuiText.Scheduled.getLocal() + ": " + Long.toString(pendingStack.getStackSize()));
|
||||
}
|
||||
}
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
|
||||
final int posY = y * offY + ITEMSTACK_TOP_OFFSET;
|
||||
|
||||
final ItemStack is = refStack.asItemStackRepresentation();
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
dspToolTip = Platform.getItemDisplayName(refStack).getFormattedText();
|
||||
|
||||
if (lineList.size() > 0) {
|
||||
dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
|
||||
}
|
||||
|
||||
toolPosX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8;
|
||||
toolPosY = y * offY + ITEMSTACK_TOP_OFFSET;
|
||||
}
|
||||
|
||||
this.drawItem(posX, posY, is);
|
||||
|
||||
x++;
|
||||
|
||||
if (x > 2) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tooltip >= 0 && !dspToolTip.isEmpty()) {
|
||||
this.drawTooltip(toolPosX, toolPosY + 10, dspToolTip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/craftingcpu.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
|
||||
switch (ref) {
|
||||
case 0:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.storage, l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.active, l);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.pending, l);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (final IAEItemStack l : list) {
|
||||
final long amt = this.getTotal(l);
|
||||
|
||||
if (amt <= 0) {
|
||||
this.deleteVisualStack(l);
|
||||
} else {
|
||||
final IAEItemStack is = this.findVisualStack(l);
|
||||
is.setStackSize(amt);
|
||||
}
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput(final IItemList<IAEItemStack> s, final IAEItemStack l) {
|
||||
IAEItemStack a = s.findPrecise(l);
|
||||
|
||||
if (l.getStackSize() <= 0) {
|
||||
if (a != null) {
|
||||
a.reset();
|
||||
}
|
||||
} else {
|
||||
if (a == null) {
|
||||
s.add(l.copy());
|
||||
a = s.findPrecise(l);
|
||||
}
|
||||
|
||||
if (a != null) {
|
||||
a.setStackSize(l.getStackSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long getTotal(final IAEItemStack is) {
|
||||
final IAEItemStack a = this.storage.findPrecise(is);
|
||||
final IAEItemStack b = this.active.findPrecise(is);
|
||||
final IAEItemStack c = this.pending.findPrecise(is);
|
||||
|
||||
long total = 0;
|
||||
|
||||
if (a != null) {
|
||||
total += a.getStackSize();
|
||||
}
|
||||
|
||||
if (b != null) {
|
||||
total += b.getStackSize();
|
||||
}
|
||||
|
||||
if (c != null) {
|
||||
total += c.getStackSize();
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
private void deleteVisualStack(final IAEItemStack l) {
|
||||
final Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
final IAEItemStack o = i.next();
|
||||
if (o.equals(l)) {
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack(final IAEItemStack l) {
|
||||
for (final IAEItemStack o : this.visual) {
|
||||
if (o.equals(l)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
final IAEItemStack stack = l.copy();
|
||||
this.visual.add(stack);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortOrder getSortBy() {
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortDir getSortDir() {
|
||||
return SortDir.ASCENDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewItems getSortDisplay() {
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,88 +22,78 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.io.IOException;
|
||||
public class GuiCraftingStatus extends GuiCraftingCPU<ContainerCraftingStatus> {
|
||||
|
||||
private final AESubGui subGui;
|
||||
|
||||
public class GuiCraftingStatus extends GuiCraftingCPU<ContainerCraftingStatus>
|
||||
{
|
||||
private Button selectCPU;
|
||||
|
||||
private final AESubGui subGui;
|
||||
public GuiCraftingStatus(ContainerCraftingStatus container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubGui(this, container.getTarget());
|
||||
}
|
||||
|
||||
private Button selectCPU;
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
public GuiCraftingStatus(ContainerCraftingStatus container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubGui(this, container.getTarget());
|
||||
}
|
||||
this.selectCPU = new Button(this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20,
|
||||
GuiText.CraftingCPU.getLocal() + ": " + GuiText.NoCraftingCPUs, btn -> selectNextCpu());
|
||||
this.addButton(this.selectCPU);
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
subGui.addBackButton(btn -> {
|
||||
addButton(btn);
|
||||
btn.setHideEdge(13);
|
||||
}, 213, -4);
|
||||
}
|
||||
|
||||
this.selectCPU = new Button(this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20, GuiText.CraftingCPU
|
||||
.getLocal() + ": " + GuiText.NoCraftingCPUs, btn -> selectNextCpu() );
|
||||
this.addButton( this.selectCPU );
|
||||
@Override
|
||||
public void render(final int mouseX, final int mouseY, final float btn) {
|
||||
this.updateCPUButtonText();
|
||||
super.render(mouseX, mouseY, btn);
|
||||
}
|
||||
|
||||
subGui.addBackButton(btn -> {
|
||||
addButton(btn);
|
||||
btn.setHideEdge( 13 );
|
||||
}, 213, -4);
|
||||
}
|
||||
private void updateCPUButtonText() {
|
||||
String btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
|
||||
@Override
|
||||
public void render(final int mouseX, final int mouseY, final float btn )
|
||||
{
|
||||
this.updateCPUButtonText();
|
||||
super.render( mouseX, mouseY, btn );
|
||||
}
|
||||
if (this.container.selectedCpu >= 0)// && status.selectedCpu < status.cpus.size() )
|
||||
{
|
||||
if (this.container.myName.length() > 0) {
|
||||
final String name = this.container.myName.substring(0, Math.min(20, this.container.myName.length()));
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
|
||||
} else {
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": #" + this.container.selectedCpu;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCPUButtonText()
|
||||
{
|
||||
String btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
if (this.container.noCPU) {
|
||||
btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
}
|
||||
|
||||
if( this.container.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() )
|
||||
{
|
||||
if( this.container.myName.length() > 0 )
|
||||
{
|
||||
final String name = this.container.myName.substring( 0, Math.min( 20, this.container.myName.length() ) );
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
|
||||
}
|
||||
else
|
||||
{
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": #" + this.container.selectedCpu;
|
||||
}
|
||||
}
|
||||
this.selectCPU.setMessage(btnTextText);
|
||||
}
|
||||
|
||||
if( this.container.noCPU )
|
||||
{
|
||||
btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
}
|
||||
@Override
|
||||
protected String getGuiDisplayName(final String in) {
|
||||
return in; // the cup name is on the button
|
||||
}
|
||||
|
||||
this.selectCPU.setMessage(btnTextText);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGuiDisplayName( final String in )
|
||||
{
|
||||
return in; // the cup name is on the button
|
||||
}
|
||||
|
||||
// FIXME: Extract to separate class? Shared with GuiCraftConfirm
|
||||
private void selectNextCpu() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
// FIXME: Extract to separate class? Shared with GuiCraftConfirm
|
||||
private void selectNextCpu() {
|
||||
final boolean backwards = minecraft.mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("Terminal.Cpu", backwards ? "Prev" : "Next"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,12 +18,13 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.client.gui.widgets.GuiActionButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.widgets.GuiActionButton;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
@@ -31,53 +32,45 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiCraftingTerm extends GuiMEMonitorable<ContainerCraftingTerm> {
|
||||
|
||||
public class GuiCraftingTerm extends GuiMEMonitorable<ContainerCraftingTerm>
|
||||
{
|
||||
public GuiCraftingTerm(ContainerCraftingTerm container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.setReservedSpace(73);
|
||||
}
|
||||
|
||||
public GuiCraftingTerm(ContainerCraftingTerm container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.setReservedSpace( 73 );
|
||||
}
|
||||
private void clear() {
|
||||
Slot s = null;
|
||||
for (final Object j : this.container.inventorySlots) {
|
||||
if (j instanceof SlotCraftingMatrix) {
|
||||
s = (Slot) j;
|
||||
}
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
Slot s = null;
|
||||
for( final Object j : this.container.inventorySlots )
|
||||
{
|
||||
if( j instanceof SlotCraftingMatrix )
|
||||
{
|
||||
s = (Slot) j;
|
||||
}
|
||||
}
|
||||
if (s != null) {
|
||||
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, s.slotNumber, 0);
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
}
|
||||
|
||||
if( s != null )
|
||||
{
|
||||
final PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, s.slotNumber, 0 );
|
||||
NetworkHandler.instance().sendToServer( p );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
GuiActionButton clearBtn = this.addButton(new GuiActionButton(this.guiLeft + 92, this.guiTop + this.ySize - 156,
|
||||
ActionItems.STASH, btn -> clear()));
|
||||
clearBtn.setHalfSize(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
GuiActionButton clearBtn = this.addButton( new GuiActionButton( this.guiLeft + 92, this.guiTop + this.ySize - 156, ActionItems.STASH, btn -> clear() ));
|
||||
clearBtn.setHalfSize( true );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
||||
this.font.drawString(GuiText.CraftingTerminal.getLocal(), 8, this.ySize - 96 + 1 - this.getReservedSpace(),
|
||||
4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
this.font.drawString( GuiText.CraftingTerminal.getLocal(), 8, this.ySize - 96 + 1 - this.getReservedSpace(), 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/crafting.png";
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/crafting.png";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
@@ -26,42 +29,35 @@ import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiDrive extends AEBaseGui<ContainerDrive> {
|
||||
|
||||
public class GuiDrive extends AEBaseGui<ContainerDrive>
|
||||
{
|
||||
public GuiDrive(ContainerDrive container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 199;
|
||||
}
|
||||
|
||||
public GuiDrive(ContainerDrive container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 199;
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(),
|
||||
this.itemRenderer, btn -> openPriorityGui()));
|
||||
}
|
||||
|
||||
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
|
||||
}
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE));
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.Drive.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.Drive.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/drive.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/drive.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
@@ -30,57 +32,51 @@ import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiFormationPlane extends GuiUpgradeable<ContainerFormationPlane> {
|
||||
|
||||
public class GuiFormationPlane extends GuiUpgradeable<ContainerFormationPlane>
|
||||
{
|
||||
private GuiSettingToggleButton<YesNo> placeMode;
|
||||
|
||||
private GuiSettingToggleButton<YesNo> placeMode;
|
||||
public GuiFormationPlane(ContainerFormationPlane container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
public GuiFormationPlane(ContainerFormationPlane container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 251;
|
||||
}
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.placeMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK,
|
||||
YesNo.YES);
|
||||
this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE,
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.placeMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK, YesNo.YES );
|
||||
this.fuzzyMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(),
|
||||
this.itemRenderer, btn -> openPriorityGui()));
|
||||
|
||||
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
|
||||
this.addButton(this.placeMode);
|
||||
this.addButton(this.fuzzyMode);
|
||||
}
|
||||
|
||||
this.addButton( this.placeMode );
|
||||
this.addButton( this.fuzzyMode );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.FormationPlane.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.FormationPlane.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
if (this.fuzzyMode != null) {
|
||||
this.fuzzyMode.set(this.cvb.getFuzzyMode());
|
||||
}
|
||||
|
||||
if( this.fuzzyMode != null )
|
||||
{
|
||||
this.fuzzyMode.set( this.cvb.getFuzzyMode() );
|
||||
}
|
||||
if (this.placeMode != null) {
|
||||
this.placeMode.set(((ContainerFormationPlane) this.cvb).getPlaceMode());
|
||||
}
|
||||
}
|
||||
|
||||
if( this.placeMode != null )
|
||||
{
|
||||
this.placeMode.set( ( (ContainerFormationPlane) this.cvb ).getPlaceMode() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,35 +18,30 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerGrinder;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiGrinder extends AEBaseGui<ContainerGrinder> {
|
||||
|
||||
public class GuiGrinder extends AEBaseGui<ContainerGrinder>
|
||||
{
|
||||
public GuiGrinder(ContainerGrinder container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 176;
|
||||
}
|
||||
|
||||
public GuiGrinder(ContainerGrinder container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 176;
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.GrindStone.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.GrindStone.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/grinder.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/grinder.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FullnessMode;
|
||||
@@ -29,71 +31,65 @@ import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.container.implementations.ContainerIOPort;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiIOPort extends GuiUpgradeable<ContainerIOPort> {
|
||||
|
||||
public class GuiIOPort extends GuiUpgradeable<ContainerIOPort>
|
||||
{
|
||||
private GuiSettingToggleButton<FullnessMode> fullMode;
|
||||
private GuiSettingToggleButton<OperationMode> operationMode;
|
||||
|
||||
private GuiSettingToggleButton<FullnessMode> fullMode;
|
||||
private GuiSettingToggleButton<OperationMode> operationMode;
|
||||
public GuiIOPort(ContainerIOPort container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
public GuiIOPort(ContainerIOPort container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.fullMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.FULLNESS_MODE,
|
||||
FullnessMode.EMPTY);
|
||||
this.operationMode = new GuiServerSettingToggleButton<>(this.guiLeft + 80, this.guiTop + 17,
|
||||
Settings.OPERATION_MODE, OperationMode.EMPTY);
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.fullMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY );
|
||||
this.operationMode = new GuiServerSettingToggleButton<>( this.guiLeft + 80, this.guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY );
|
||||
this.addButton(this.operationMode);
|
||||
this.addButton(this.fullMode);
|
||||
this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28,
|
||||
Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
|
||||
addButton(this.redstoneMode);
|
||||
}
|
||||
|
||||
this.addButton( this.operationMode );
|
||||
this.addButton( this.fullMode );
|
||||
this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
addButton(this.redstoneMode);
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.IOPort.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.IOPort.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
if (this.redstoneMode != null) {
|
||||
this.redstoneMode.set(this.cvb.getRedStoneMode());
|
||||
}
|
||||
|
||||
if( this.redstoneMode != null )
|
||||
{
|
||||
this.redstoneMode.set( this.cvb.getRedStoneMode() );
|
||||
}
|
||||
if (this.operationMode != null) {
|
||||
this.operationMode.set(((ContainerIOPort) this.cvb).getOperationMode());
|
||||
}
|
||||
|
||||
if( this.operationMode != null )
|
||||
{
|
||||
this.operationMode.set( ( (ContainerIOPort) this.cvb ).getOperationMode() );
|
||||
}
|
||||
if (this.fullMode != null) {
|
||||
this.fullMode.set(((ContainerIOPort) this.cvb).getFullMode());
|
||||
}
|
||||
}
|
||||
|
||||
if( this.fullMode != null )
|
||||
{
|
||||
this.fullMode.set( ( (ContainerIOPort) this.cvb ).getFullMode() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
super.drawBG(offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
definitions.items().cell1k().maybeStack(1)
|
||||
.ifPresent(cell1kStack -> this.drawItem(offsetX + 66 - 8, offsetY + 17, cell1kStack));
|
||||
|
||||
definitions.items().cell1k().maybeStack( 1 ).ifPresent( cell1kStack -> this.drawItem( offsetX + 66 - 8, offsetY + 17, cell1kStack ) );
|
||||
definitions.blocks().drive().maybeStack(1)
|
||||
.ifPresent(driveStack -> this.drawItem(offsetX + 94 + 8, offsetY + 17, driveStack));
|
||||
}
|
||||
|
||||
definitions.blocks().drive().maybeStack( 1 ).ifPresent( driveStack -> this.drawItem( offsetX + 94 + 8, offsetY + 17, driveStack ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/io_port.png";
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/io_port.png";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,73 +18,66 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiInscriber extends AEBaseGui<ContainerInscriber> {
|
||||
|
||||
public class GuiInscriber extends AEBaseGui<ContainerInscriber>
|
||||
{
|
||||
private GuiProgressBar pb;
|
||||
|
||||
private GuiProgressBar pb;
|
||||
public GuiInscriber(ContainerInscriber container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 176;
|
||||
this.xSize = this.hasToolbox() ? 246 : 211;
|
||||
}
|
||||
|
||||
public GuiInscriber(ContainerInscriber container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 176;
|
||||
this.xSize = this.hasToolbox() ? 246 : 211;
|
||||
}
|
||||
private boolean hasToolbox() {
|
||||
return this.container.hasToolbox();
|
||||
}
|
||||
|
||||
private boolean hasToolbox()
|
||||
{
|
||||
return this.container.hasToolbox();
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.pb = new GuiProgressBar(this.container, "guis/inscriber.png", 135, 39, 135, 177, 6, 18,
|
||||
Direction.VERTICAL);
|
||||
this.addButton(this.pb);
|
||||
}
|
||||
|
||||
this.pb = new GuiProgressBar( this.container, "guis/inscriber.png", 135, 39, 135, 177, 6, 18, Direction.VERTICAL );
|
||||
this.addButton( this.pb );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.pb.setFullMsg(this.container.getCurrentProgress() * 100 / this.container.getMaxProgress() + "%");
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.pb.setFullMsg( this.container.getCurrentProgress() * 100 / this.container.getMaxProgress() + "%" );
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.Inscriber.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.Inscriber.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/inscriber.png");
|
||||
this.pb.x = 135 + this.guiLeft;
|
||||
this.pb.y = 39 + this.guiTop;
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/inscriber.png" );
|
||||
this.pb.x = 135 + this.guiLeft;
|
||||
this.pb.y = 39 + this.guiTop;
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset());
|
||||
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset() );
|
||||
if (this.drawUpgrades()) {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35,
|
||||
14 + this.container.availableUpgrades() * 18, getBlitOffset());
|
||||
}
|
||||
if (this.hasToolbox()) {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68,
|
||||
getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
if( this.drawUpgrades() )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.container.availableUpgrades() * 18, getBlitOffset() );
|
||||
}
|
||||
if( this.hasToolbox() )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68, getBlitOffset() );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean drawUpgrades()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
private boolean drawUpgrades() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
@@ -31,69 +33,63 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiInterface extends GuiUpgradeable<ContainerInterface> {
|
||||
|
||||
public class GuiInterface extends GuiUpgradeable<ContainerInterface>
|
||||
{
|
||||
private GuiSettingToggleButton<YesNo> blockMode;
|
||||
private GuiToggleButton interfaceMode;
|
||||
|
||||
private GuiSettingToggleButton<YesNo> blockMode;
|
||||
private GuiToggleButton interfaceMode;
|
||||
public GuiInterface(ContainerInterface container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 211;
|
||||
}
|
||||
|
||||
public GuiInterface(ContainerInterface container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 211;
|
||||
}
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(),
|
||||
this.itemRenderer, btn -> openPriorityGui()));
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
|
||||
this.blockMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK,
|
||||
YesNo.NO);
|
||||
this.addButton(this.blockMode);
|
||||
|
||||
this.blockMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO );
|
||||
this.addButton( this.blockMode);
|
||||
this.interfaceMode = new GuiToggleButton(this.guiLeft - 18, this.guiTop + 26, 84, 85,
|
||||
GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal(),
|
||||
btn -> selectNextInterfaceMode());
|
||||
this.addButton(this.interfaceMode);
|
||||
}
|
||||
|
||||
this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal
|
||||
.getLocal(), GuiText.InterfaceTerminalHint.getLocal(), btn -> selectNextInterfaceMode() );
|
||||
this.addButton( this.interfaceMode );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
if (this.blockMode != null) {
|
||||
this.blockMode.set(((ContainerInterface) this.cvb).getBlockingMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
if( this.blockMode != null )
|
||||
{
|
||||
this.blockMode.set( ( (ContainerInterface) this.cvb ).getBlockingMode() );
|
||||
}
|
||||
if (this.interfaceMode != null) {
|
||||
this.interfaceMode.setState(((ContainerInterface) this.cvb).getInterfaceTerminalMode() == YesNo.YES);
|
||||
}
|
||||
|
||||
if( this.interfaceMode != null )
|
||||
{
|
||||
this.interfaceMode.setState( ( (ContainerInterface) this.cvb ).getInterfaceTerminalMode() == YesNo.YES );
|
||||
}
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.Interface.getLocal()), 8, 6, 4210752);
|
||||
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.Interface.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString(GuiText.Config.getLocal(), 8, 6 + 11 + 7, 4210752);
|
||||
this.font.drawString(GuiText.StoredItems.getLocal(), 8, 6 + 60 + 7, 4210752);
|
||||
this.font.drawString(GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752);
|
||||
|
||||
this.font.drawString( GuiText.Config.getLocal(), 8, 6 + 11 + 7, 4210752 );
|
||||
this.font.drawString( GuiText.StoredItems.getLocal(), 8, 6 + 60 + 7, 4210752 );
|
||||
this.font.drawString( GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752 );
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/interface.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/interface.png";
|
||||
}
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE));
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
|
||||
private void selectNextInterfaceMode() {
|
||||
final boolean backwards = getMinecraft().mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
|
||||
}
|
||||
private void selectNextInterfaceMode() {
|
||||
final boolean backwards = getMinecraft().mouseHelper.isRightDown();
|
||||
NetworkHandler.instance().sendToServer(new PacketConfigButton(Settings.INTERFACE_TERMINAL, backwards));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,18 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
@@ -29,368 +41,310 @@ import appeng.client.me.SlotDisconnected;
|
||||
import appeng.container.implementations.ContainerInterfaceTerminal;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.util.*;
|
||||
public class GuiInterfaceTerminal extends AEBaseGui<ContainerInterfaceTerminal> {
|
||||
|
||||
private static final int LINES_ON_PAGE = 6;
|
||||
|
||||
public class GuiInterfaceTerminal extends AEBaseGui<ContainerInterfaceTerminal>
|
||||
{
|
||||
// TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded?
|
||||
private final int offsetX = 9;
|
||||
|
||||
private static final int LINES_ON_PAGE = 6;
|
||||
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
|
||||
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
|
||||
private final ArrayList<String> names = new ArrayList<>();
|
||||
private final ArrayList<Object> lines = new ArrayList<>();
|
||||
|
||||
// TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded?
|
||||
private final int offsetX = 9;
|
||||
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
|
||||
|
||||
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
|
||||
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
|
||||
private final ArrayList<String> names = new ArrayList<>();
|
||||
private final ArrayList<Object> lines = new ArrayList<>();
|
||||
private boolean refreshList = false;
|
||||
private MEGuiTextField searchField;
|
||||
|
||||
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
|
||||
public GuiInterfaceTerminal(ContainerInterfaceTerminal container, PlayerInventory playerInventory,
|
||||
ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
this.xSize = 195;
|
||||
this.ySize = 222;
|
||||
}
|
||||
|
||||
private boolean refreshList = false;
|
||||
private MEGuiTextField searchField;
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
public GuiInterfaceTerminal(ContainerInterfaceTerminal container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar( scrollbar );
|
||||
this.xSize = 195;
|
||||
this.ySize = 222;
|
||||
}
|
||||
this.getScrollBar().setLeft(175);
|
||||
this.getScrollBar().setHeight(106);
|
||||
this.getScrollBar().setTop(18);
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.searchField = new MEGuiTextField(this.font, this.guiLeft + Math.max(104, this.offsetX), this.guiTop + 4,
|
||||
65, 12);
|
||||
this.searchField.setEnableBackgroundDrawing(false);
|
||||
this.searchField.setMaxStringLength(25);
|
||||
this.searchField.setTextColor(0xFFFFFF);
|
||||
this.searchField.setVisible(true);
|
||||
this.searchField.setFocused2(true);
|
||||
}
|
||||
|
||||
this.getScrollBar().setLeft( 175 );
|
||||
this.getScrollBar().setHeight( 106 );
|
||||
this.getScrollBar().setTop( 18 );
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
|
||||
this.searchField = new MEGuiTextField( this.font, this.guiLeft + Math.max( 104, this.offsetX ), this.guiTop + 4, 65, 12 );
|
||||
this.searchField.setEnableBackgroundDrawing( false );
|
||||
this.searchField.setMaxStringLength( 25 );
|
||||
this.searchField.setTextColor( 0xFFFFFF );
|
||||
this.searchField.setVisible( true );
|
||||
this.searchField.setFocused2( true );
|
||||
}
|
||||
final int ex = this.getScrollBar().getCurrentScroll();
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.InterfaceTerminal.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
final Iterator<Slot> o = this.container.inventorySlots.iterator();
|
||||
while (o.hasNext()) {
|
||||
if (o.next() instanceof SlotDisconnected) {
|
||||
o.remove();
|
||||
}
|
||||
}
|
||||
|
||||
final int ex = this.getScrollBar().getCurrentScroll();
|
||||
int offset = 17;
|
||||
for (int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++) {
|
||||
final Object lineObj = this.lines.get(ex + x);
|
||||
if (lineObj instanceof ClientDCInternalInv) {
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
for (int z = 0; z < inv.getInventory().getSlots(); z++) {
|
||||
this.container.inventorySlots.add(new SlotDisconnected(inv, z, z * 18 + 8, 1 + offset));
|
||||
}
|
||||
} else if (lineObj instanceof String) {
|
||||
String name = (String) lineObj;
|
||||
final int rows = this.byName.get(name).size();
|
||||
if (rows > 1) {
|
||||
name = name + " (" + rows + ')';
|
||||
}
|
||||
|
||||
final Iterator<Slot> o = this.container.inventorySlots.iterator();
|
||||
while( o.hasNext() )
|
||||
{
|
||||
if( o.next() instanceof SlotDisconnected )
|
||||
{
|
||||
o.remove();
|
||||
}
|
||||
}
|
||||
while (name.length() > 2 && this.font.getStringWidth(name) > 155) {
|
||||
name = name.substring(0, name.length() - 1);
|
||||
}
|
||||
|
||||
int offset = 17;
|
||||
for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ )
|
||||
{
|
||||
final Object lineObj = this.lines.get( ex + x );
|
||||
if( lineObj instanceof ClientDCInternalInv )
|
||||
{
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
for( int z = 0; z < inv.getInventory().getSlots(); z++ )
|
||||
{
|
||||
this.container.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 1 + offset ) );
|
||||
}
|
||||
}
|
||||
else if( lineObj instanceof String )
|
||||
{
|
||||
String name = (String) lineObj;
|
||||
final int rows = this.byName.get( name ).size();
|
||||
if( rows > 1 )
|
||||
{
|
||||
name = name + " (" + rows + ')';
|
||||
}
|
||||
this.font.drawString(name, 10, 6 + offset, 4210752);
|
||||
}
|
||||
offset += 18;
|
||||
}
|
||||
}
|
||||
|
||||
while( name.length() > 2 && this.font.getStringWidth( name ) > 155 )
|
||||
{
|
||||
name = name.substring( 0, name.length() - 1 );
|
||||
}
|
||||
@Override
|
||||
public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) {
|
||||
if (this.searchField.mouseClicked(xCoord, yCoord, btn)) {
|
||||
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.refreshList();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
this.font.drawString( name, 10, 6 + offset, 4210752 );
|
||||
}
|
||||
offset += 18;
|
||||
}
|
||||
}
|
||||
return super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked( final double xCoord, final double yCoord, final int btn )
|
||||
{
|
||||
if (this.searchField.mouseClicked( xCoord, yCoord, btn )) {
|
||||
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.refreshList();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/interfaceterminal.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
|
||||
return super.mouseClicked( xCoord, yCoord, btn );
|
||||
}
|
||||
int offset = 17;
|
||||
final int ex = this.getScrollBar().getCurrentScroll();
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/interfaceterminal.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
for (int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++) {
|
||||
final Object lineObj = this.lines.get(ex + x);
|
||||
if (lineObj instanceof ClientDCInternalInv) {
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
|
||||
int offset = 17;
|
||||
final int ex = this.getScrollBar().getCurrentScroll();
|
||||
RenderSystem.color4f(1, 1, 1, 1);
|
||||
final int width = inv.getInventory().getSlots() * 18;
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 7, offsetY + offset, 7, 139, width, 18, getBlitOffset());
|
||||
}
|
||||
offset += 18;
|
||||
}
|
||||
|
||||
for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ )
|
||||
{
|
||||
final Object lineObj = this.lines.get( ex + x );
|
||||
if( lineObj instanceof ClientDCInternalInv )
|
||||
{
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
if (this.searchField != null) {
|
||||
this.searchField.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
RenderSystem.color4f( 1, 1, 1, 1 );
|
||||
final int width = inv.getInventory().getSlots() * 18;
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 7, offsetY + offset, 7, 139, width, 18, getBlitOffset() );
|
||||
}
|
||||
offset += 18;
|
||||
}
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
if (character == ' ' && this.searchField.getText().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (this.searchField.charTyped(character, key)) {
|
||||
this.refreshList();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if( this.searchField != null )
|
||||
{
|
||||
this.searchField.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
public void postUpdate(final CompoundNBT in) {
|
||||
if (in.getBoolean("clear")) {
|
||||
this.byId.clear();
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
if( character == ' ' && this.searchField.getText().isEmpty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if( this.searchField.charTyped( character, key ) )
|
||||
{
|
||||
this.refreshList();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
for (final Object oKey : in.keySet()) {
|
||||
final String key = (String) oKey;
|
||||
if (key.startsWith("=")) {
|
||||
try {
|
||||
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
|
||||
final CompoundNBT invData = in.getCompound(key);
|
||||
final ClientDCInternalInv current = this.getById(id, invData.getLong("sortBy"),
|
||||
invData.getString("un"));
|
||||
|
||||
public void postUpdate( final CompoundNBT in )
|
||||
{
|
||||
if( in.getBoolean( "clear" ) )
|
||||
{
|
||||
this.byId.clear();
|
||||
this.refreshList = true;
|
||||
}
|
||||
for (int x = 0; x < current.getInventory().getSlots(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
if (invData.contains(which)) {
|
||||
current.getInventory().setStackInSlot(x, ItemStack.read(invData.getCompound(which)));
|
||||
}
|
||||
}
|
||||
} catch (final NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( final Object oKey : in.keySet() )
|
||||
{
|
||||
final String key = (String) oKey;
|
||||
if( key.startsWith( "=" ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
final long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX );
|
||||
final CompoundNBT invData = in.getCompound( key );
|
||||
final ClientDCInternalInv current = this.getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
|
||||
if (this.refreshList) {
|
||||
this.refreshList = false;
|
||||
// invalid caches on refresh
|
||||
this.cachedSearches.clear();
|
||||
this.refreshList();
|
||||
}
|
||||
}
|
||||
|
||||
for( int x = 0; x < current.getInventory().getSlots(); x++ )
|
||||
{
|
||||
final String which = Integer.toString( x );
|
||||
if( invData.contains(which) )
|
||||
{
|
||||
current.getInventory().setStackInSlot( x, ItemStack.read( invData.getCompound( which ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final NumberFormatException ignored )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Rebuilds the list of interfaces.
|
||||
*
|
||||
* Respects a search term if present (ignores case) and adding only matching
|
||||
* patterns.
|
||||
*/
|
||||
private void refreshList() {
|
||||
this.byName.clear();
|
||||
|
||||
if( this.refreshList )
|
||||
{
|
||||
this.refreshList = false;
|
||||
// invalid caches on refresh
|
||||
this.cachedSearches.clear();
|
||||
this.refreshList();
|
||||
}
|
||||
}
|
||||
final String searchFilterLowerCase = this.searchField.getText().toLowerCase();
|
||||
|
||||
/**
|
||||
* Rebuilds the list of interfaces.
|
||||
*
|
||||
* Respects a search term if present (ignores case) and adding only matching patterns.
|
||||
*/
|
||||
private void refreshList()
|
||||
{
|
||||
this.byName.clear();
|
||||
final Set<Object> cachedSearch = this.getCacheForSearchTerm(searchFilterLowerCase);
|
||||
final boolean rebuild = cachedSearch.isEmpty();
|
||||
|
||||
final String searchFilterLowerCase = this.searchField.getText().toLowerCase();
|
||||
for (final ClientDCInternalInv entry : this.byId.values()) {
|
||||
// ignore inventory if not doing a full rebuild or cache already marks it as
|
||||
// miss.
|
||||
if (!rebuild && !cachedSearch.contains(entry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final Set<Object> cachedSearch = this.getCacheForSearchTerm( searchFilterLowerCase );
|
||||
final boolean rebuild = cachedSearch.isEmpty();
|
||||
// Shortcut to skip any filter if search term is ""/empty
|
||||
boolean found = searchFilterLowerCase.isEmpty();
|
||||
|
||||
for( final ClientDCInternalInv entry : this.byId.values() )
|
||||
{
|
||||
// ignore inventory if not doing a full rebuild or cache already marks it as miss.
|
||||
if( !rebuild && !cachedSearch.contains( entry ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Search if the current inventory holds a pattern containing the search term.
|
||||
if (!found && !searchFilterLowerCase.isEmpty()) {
|
||||
for (final ItemStack itemStack : entry.getInventory()) {
|
||||
found = this.itemStackMatchesSearchTerm(itemStack, searchFilterLowerCase);
|
||||
if (found) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shortcut to skip any filter if search term is ""/empty
|
||||
boolean found = searchFilterLowerCase.isEmpty();
|
||||
// if found, filter skipped or machine name matching the search term, add it
|
||||
if (found || entry.getName().toLowerCase().contains(searchFilterLowerCase)) {
|
||||
this.byName.put(entry.getName(), entry);
|
||||
cachedSearch.add(entry);
|
||||
} else {
|
||||
cachedSearch.remove(entry);
|
||||
}
|
||||
}
|
||||
|
||||
// Search if the current inventory holds a pattern containing the search term.
|
||||
if( !found && !searchFilterLowerCase.isEmpty() )
|
||||
{
|
||||
for( final ItemStack itemStack : entry.getInventory() )
|
||||
{
|
||||
found = this.itemStackMatchesSearchTerm( itemStack, searchFilterLowerCase );
|
||||
if( found )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.names.clear();
|
||||
this.names.addAll(this.byName.keySet());
|
||||
|
||||
// if found, filter skipped or machine name matching the search term, add it
|
||||
if( found || entry.getName().toLowerCase().contains( searchFilterLowerCase ) )
|
||||
{
|
||||
this.byName.put( entry.getName(), entry );
|
||||
cachedSearch.add( entry );
|
||||
}
|
||||
else
|
||||
{
|
||||
cachedSearch.remove( entry );
|
||||
}
|
||||
}
|
||||
Collections.sort(this.names);
|
||||
|
||||
this.names.clear();
|
||||
this.names.addAll( this.byName.keySet() );
|
||||
this.lines.clear();
|
||||
this.lines.ensureCapacity(this.getMaxRows());
|
||||
|
||||
Collections.sort( this.names );
|
||||
for (final String n : this.names) {
|
||||
this.lines.add(n);
|
||||
|
||||
this.lines.clear();
|
||||
this.lines.ensureCapacity( this.getMaxRows() );
|
||||
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>();
|
||||
clientInventories.addAll(this.byName.get(n));
|
||||
|
||||
for( final String n : this.names )
|
||||
{
|
||||
this.lines.add( n );
|
||||
Collections.sort(clientInventories);
|
||||
this.lines.addAll(clientInventories);
|
||||
}
|
||||
|
||||
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>();
|
||||
clientInventories.addAll( this.byName.get( n ) );
|
||||
this.getScrollBar().setRange(0, this.lines.size() - LINES_ON_PAGE, 2);
|
||||
}
|
||||
|
||||
Collections.sort( clientInventories );
|
||||
this.lines.addAll( clientInventories );
|
||||
}
|
||||
private boolean itemStackMatchesSearchTerm(final ItemStack itemStack, final String searchTerm) {
|
||||
if (itemStack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.getScrollBar().setRange( 0, this.lines.size() - LINES_ON_PAGE, 2 );
|
||||
}
|
||||
final CompoundNBT encodedValue = itemStack.getTag();
|
||||
|
||||
private boolean itemStackMatchesSearchTerm( final ItemStack itemStack, final String searchTerm )
|
||||
{
|
||||
if( itemStack.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (encodedValue == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final CompoundNBT encodedValue = itemStack.getTag();
|
||||
// Potential later use to filter by input
|
||||
// ListNBT inTag = encodedValue.getTagList( "in", 10 );
|
||||
final ListNBT outTag = encodedValue.getList("out", 10);
|
||||
|
||||
if( encodedValue == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < outTag.size(); i++) {
|
||||
|
||||
// Potential later use to filter by input
|
||||
// ListNBT inTag = encodedValue.getTagList( "in", 10 );
|
||||
final ListNBT outTag = encodedValue.getList( "out", 10 );
|
||||
final ItemStack parsedItemStack = ItemStack.read(outTag.getCompound(i));
|
||||
if (!parsedItemStack.isEmpty()) {
|
||||
final String displayName = Platform.getItemDisplayName(AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createStack(parsedItemStack)).getString()
|
||||
.toLowerCase();
|
||||
if (displayName.contains(searchTerm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
for( int i = 0; i < outTag.size(); i++ )
|
||||
{
|
||||
/**
|
||||
* Tries to retrieve a cache for a with search term as keyword.
|
||||
*
|
||||
* If this cache should be empty, it will populate it with an earlier cache if
|
||||
* available or at least the cache for the empty string.
|
||||
*
|
||||
* @param searchTerm the corresponding search
|
||||
*
|
||||
* @return a Set matching a superset of the search term
|
||||
*/
|
||||
private Set<Object> getCacheForSearchTerm(final String searchTerm) {
|
||||
if (!this.cachedSearches.containsKey(searchTerm)) {
|
||||
this.cachedSearches.put(searchTerm, new HashSet<>());
|
||||
}
|
||||
|
||||
final ItemStack parsedItemStack = ItemStack.read( outTag.getCompound( i ) );
|
||||
if( !parsedItemStack.isEmpty() )
|
||||
{
|
||||
final String displayName = Platform
|
||||
.getItemDisplayName( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( parsedItemStack ) )
|
||||
.getString()
|
||||
.toLowerCase();
|
||||
if( displayName.contains( searchTerm ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Set<Object> cache = this.cachedSearches.get(searchTerm);
|
||||
|
||||
/**
|
||||
* Tries to retrieve a cache for a with search term as keyword.
|
||||
*
|
||||
* If this cache should be empty, it will populate it with an earlier cache if available or at least the cache for
|
||||
* the empty string.
|
||||
*
|
||||
* @param searchTerm the corresponding search
|
||||
*
|
||||
* @return a Set matching a superset of the search term
|
||||
*/
|
||||
private Set<Object> getCacheForSearchTerm( final String searchTerm )
|
||||
{
|
||||
if( !this.cachedSearches.containsKey( searchTerm ) )
|
||||
{
|
||||
this.cachedSearches.put( searchTerm, new HashSet<>() );
|
||||
}
|
||||
if (cache.isEmpty() && searchTerm.length() > 1) {
|
||||
cache.addAll(this.getCacheForSearchTerm(searchTerm.substring(0, searchTerm.length() - 1)));
|
||||
return cache;
|
||||
}
|
||||
|
||||
final Set<Object> cache = this.cachedSearches.get( searchTerm );
|
||||
return cache;
|
||||
}
|
||||
|
||||
if( cache.isEmpty() && searchTerm.length() > 1 )
|
||||
{
|
||||
cache.addAll( this.getCacheForSearchTerm( searchTerm.substring( 0, searchTerm.length() - 1 ) ) );
|
||||
return cache;
|
||||
}
|
||||
/**
|
||||
* The max amount of unique names and each inv row. Not affected by the
|
||||
* filtering.
|
||||
*
|
||||
* @return max amount of unique names and each inv row
|
||||
*/
|
||||
private int getMaxRows() {
|
||||
return this.names.size() + this.byId.size();
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
private ClientDCInternalInv getById(final long id, final long sortBy, final String string) {
|
||||
ClientDCInternalInv o = this.byId.get(id);
|
||||
|
||||
/**
|
||||
* The max amount of unique names and each inv row. Not affected by the filtering.
|
||||
*
|
||||
* @return max amount of unique names and each inv row
|
||||
*/
|
||||
private int getMaxRows()
|
||||
{
|
||||
return this.names.size() + this.byId.size();
|
||||
}
|
||||
if (o == null) {
|
||||
this.byId.put(id, o = new ClientDCInternalInv(9, id, sortBy, string));
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
private ClientDCInternalInv getById( final long id, final long sortBy, final String string )
|
||||
{
|
||||
ClientDCInternalInv o = this.byId.get( id );
|
||||
|
||||
if( o == null )
|
||||
{
|
||||
this.byId.put( id, o = new ClientDCInternalInv( 9, id, sortBy, string ) );
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.LevelType;
|
||||
@@ -32,213 +29,201 @@ import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.container.implementations.ContainerLevelEmitter;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter> {
|
||||
|
||||
public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
|
||||
{
|
||||
private GuiNumberBox level;
|
||||
|
||||
private GuiNumberBox level;
|
||||
private Button plus1;
|
||||
private Button plus10;
|
||||
private Button plus100;
|
||||
private Button plus1000;
|
||||
private Button minus1;
|
||||
private Button minus10;
|
||||
private Button minus100;
|
||||
private Button minus1000;
|
||||
|
||||
private Button plus1;
|
||||
private Button plus10;
|
||||
private Button plus100;
|
||||
private Button plus1000;
|
||||
private Button minus1;
|
||||
private Button minus10;
|
||||
private Button minus100;
|
||||
private Button minus1000;
|
||||
private GuiSettingToggleButton<LevelType> levelMode;
|
||||
private GuiSettingToggleButton<YesNo> craftingMode;
|
||||
|
||||
private GuiSettingToggleButton<LevelType> levelMode;
|
||||
private GuiSettingToggleButton<YesNo> craftingMode;
|
||||
public GuiLevelEmitter(ContainerLevelEmitter container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
public GuiLevelEmitter(ContainerLevelEmitter container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.level = new GuiNumberBox(this.font, this.guiLeft + 24, this.guiTop + 43, 79, this.font.FONT_HEIGHT,
|
||||
Long.class);
|
||||
this.level.setEnableBackgroundDrawing(false);
|
||||
this.level.setMaxStringLength(16);
|
||||
this.level.setTextColor(0xFFFFFF);
|
||||
this.level.setVisible(true);
|
||||
this.level.setFocused2(true);
|
||||
container.setTextField(this.level);
|
||||
}
|
||||
|
||||
this.level = new GuiNumberBox( this.font, this.guiLeft + 24, this.guiTop + 43, 79, this.font.FONT_HEIGHT, Long.class );
|
||||
this.level.setEnableBackgroundDrawing( false );
|
||||
this.level.setMaxStringLength( 16 );
|
||||
this.level.setTextColor( 0xFFFFFF );
|
||||
this.level.setVisible( true );
|
||||
this.level.setFocused2( true );
|
||||
container.setTextField( this.level );
|
||||
}
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.levelMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.LEVEL_TYPE,
|
||||
LevelType.ITEM_LEVEL);
|
||||
this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28,
|
||||
Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL);
|
||||
this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE,
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
this.craftingMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48,
|
||||
Settings.CRAFT_VIA_REDSTONE, YesNo.NO);
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.levelMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL );
|
||||
this.redstoneMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL );
|
||||
this.fuzzyMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.craftingMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_VIA_REDSTONE, YesNo.NO );
|
||||
final int a = AEConfig.instance().levelByStackAmounts(0);
|
||||
final int b = AEConfig.instance().levelByStackAmounts(1);
|
||||
final int c = AEConfig.instance().levelByStackAmounts(2);
|
||||
final int d = AEConfig.instance().levelByStackAmounts(3);
|
||||
|
||||
final int a = AEConfig.instance().levelByStackAmounts( 0 );
|
||||
final int b = AEConfig.instance().levelByStackAmounts( 1 );
|
||||
final int c = AEConfig.instance().levelByStackAmounts( 2 );
|
||||
final int d = AEConfig.instance().levelByStackAmounts( 3 );
|
||||
this.addButton(this.plus1 = new Button(this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a, btn -> addQty(a)));
|
||||
this.addButton(
|
||||
this.plus10 = new Button(this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b, btn -> addQty(b)));
|
||||
this.addButton(
|
||||
this.plus100 = new Button(this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c, btn -> addQty(c)));
|
||||
this.addButton(
|
||||
this.plus1000 = new Button(this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d, btn -> addQty(d)));
|
||||
|
||||
this.addButton( this.plus1 = new Button(this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a, btn -> addQty(a) ) );
|
||||
this.addButton( this.plus10 = new Button(this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b, btn -> addQty(b) ) );
|
||||
this.addButton( this.plus100 = new Button(this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c, btn -> addQty(c) ) );
|
||||
this.addButton( this.plus1000 = new Button(this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d, btn -> addQty(d) ) );
|
||||
this.addButton(
|
||||
this.minus1 = new Button(this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a, btn -> addQty(-a)));
|
||||
this.addButton(
|
||||
this.minus10 = new Button(this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b, btn -> addQty(-b)));
|
||||
this.addButton(
|
||||
this.minus100 = new Button(this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c, btn -> addQty(-c)));
|
||||
this.addButton(
|
||||
this.minus1000 = new Button(this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d, btn -> addQty(-d)));
|
||||
|
||||
this.addButton( this.minus1 = new Button(this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a, btn -> addQty(-a) ) );
|
||||
this.addButton( this.minus10 = new Button(this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b, btn -> addQty(-b) ) );
|
||||
this.addButton( this.minus100 = new Button(this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c, btn -> addQty(-c) ) );
|
||||
this.addButton( this.minus1000 = new Button(this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d, btn -> addQty(-d) ) );
|
||||
this.addButton(this.levelMode);
|
||||
this.addButton(this.redstoneMode);
|
||||
this.addButton(this.craftingMode);
|
||||
}
|
||||
|
||||
this.addButton( this.levelMode );
|
||||
this.addButton( this.redstoneMode );
|
||||
this.addButton( this.craftingMode );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
final boolean notCraftingMode = this.bc.getInstalledUpgrades(Upgrades.CRAFTING) == 0;
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
final boolean notCraftingMode = this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) == 0;
|
||||
// configure enabled status...
|
||||
this.level.setEnabled(notCraftingMode);
|
||||
this.plus1.active = notCraftingMode;
|
||||
this.plus10.active = notCraftingMode;
|
||||
this.plus100.active = notCraftingMode;
|
||||
this.plus1000.active = notCraftingMode;
|
||||
this.minus1.active = notCraftingMode;
|
||||
this.minus10.active = notCraftingMode;
|
||||
this.minus100.active = notCraftingMode;
|
||||
this.minus1000.active = notCraftingMode;
|
||||
this.levelMode.active = notCraftingMode;
|
||||
this.redstoneMode.active = notCraftingMode;
|
||||
|
||||
// configure enabled status...
|
||||
this.level.setEnabled( notCraftingMode );
|
||||
this.plus1.active = notCraftingMode;
|
||||
this.plus10.active = notCraftingMode;
|
||||
this.plus100.active = notCraftingMode;
|
||||
this.plus1000.active = notCraftingMode;
|
||||
this.minus1.active = notCraftingMode;
|
||||
this.minus10.active = notCraftingMode;
|
||||
this.minus100.active = notCraftingMode;
|
||||
this.minus1000.active = notCraftingMode;
|
||||
this.levelMode.active = notCraftingMode;
|
||||
this.redstoneMode.active = notCraftingMode;
|
||||
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
if (this.craftingMode != null) {
|
||||
this.craftingMode.set(this.cvb.getCraftingMode());
|
||||
}
|
||||
|
||||
if( this.craftingMode != null )
|
||||
{
|
||||
this.craftingMode.set( this.cvb.getCraftingMode() );
|
||||
}
|
||||
if (this.levelMode != null) {
|
||||
this.levelMode.set(((ContainerLevelEmitter) this.cvb).getLevelMode());
|
||||
}
|
||||
}
|
||||
|
||||
if( this.levelMode != null )
|
||||
{
|
||||
this.levelMode.set( ( (ContainerLevelEmitter) this.cvb ).getLevelMode() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
super.drawBG(offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
this.level.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
this.level.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
@Override
|
||||
protected void handleButtonVisibility() {
|
||||
this.craftingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.CRAFTING) > 0);
|
||||
this.fuzzyMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.FUZZY) > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleButtonVisibility()
|
||||
{
|
||||
this.craftingMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
|
||||
this.fuzzyMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/lvlemitter.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/lvlemitter.png";
|
||||
}
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.LevelEmitter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.LevelEmitter;
|
||||
}
|
||||
private void addQty(final long i) {
|
||||
try {
|
||||
String Out = this.level.getText();
|
||||
|
||||
private void addQty( final long i )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = this.level.getText();
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
boolean Fixed = false;
|
||||
while( Out.startsWith( "0" ) && Out.length() > 1 )
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if( Fixed )
|
||||
{
|
||||
this.level.setText( Out );
|
||||
}
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
if( Out.isEmpty() )
|
||||
{
|
||||
Out = "0";
|
||||
}
|
||||
long result = Long.parseLong(Out);
|
||||
result += i;
|
||||
if (result < 0) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
long result = Long.parseLong( Out );
|
||||
result += i;
|
||||
if( result < 0 )
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
this.level.setText(Out = Long.toString(result));
|
||||
|
||||
this.level.setText( Out = Long.toString( result ) );
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("LevelEmitter.Value", Out));
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.level.setText("0");
|
||||
}
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
// nope..
|
||||
this.level.setText( "0" );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
// Forward entered characters to the number-text-field
|
||||
return level.charTyped(character, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
// Forward entered characters to the number-text-field
|
||||
return level.charTyped(character, key);
|
||||
}
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) {
|
||||
if (keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14) {
|
||||
String Out = this.level.getText();
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_)
|
||||
{
|
||||
if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) )
|
||||
{
|
||||
if( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 )
|
||||
{
|
||||
String Out = this.level.getText();
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
boolean Fixed = false;
|
||||
while( Out.startsWith( "0" ) && Out.length() > 1 )
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if( Fixed )
|
||||
{
|
||||
this.level.setText( Out );
|
||||
}
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
if( Out.isEmpty() )
|
||||
{
|
||||
Out = "0";
|
||||
}
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("LevelEmitter.Value", Out));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed( keyCode, scanCode, p_keyPressed_3_ );
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,69 +18,61 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import appeng.container.implementations.ContainerMAC;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiMAC extends GuiUpgradeable<ContainerMAC> {
|
||||
|
||||
public class GuiMAC extends GuiUpgradeable<ContainerMAC>
|
||||
{
|
||||
private GuiProgressBar pb;
|
||||
|
||||
private GuiProgressBar pb;
|
||||
public GuiMAC(ContainerMAC container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 197;
|
||||
}
|
||||
|
||||
public GuiMAC(ContainerMAC container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 197;
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.pb = new GuiProgressBar(this.container, "guis/mac.png", 139, 36, 148, 201, 6, 18, Direction.VERTICAL);
|
||||
this.addButton(this.pb);
|
||||
}
|
||||
|
||||
this.pb = new GuiProgressBar( this.container, "guis/mac.png", 139, 36, 148, 201, 6, 18, Direction.VERTICAL );
|
||||
this.addButton( this.pb );
|
||||
}
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8,
|
||||
Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
|
||||
addButton(this.redstoneMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
addButton(this.redstoneMode);
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.pb.setFullMsg(this.container.getCurrentProgress() + "%");
|
||||
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.pb.setFullMsg( this.container.getCurrentProgress() + "%" );
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.pb.x = 148 + this.guiLeft;
|
||||
this.pb.y = 48 + this.guiTop;
|
||||
super.drawBG(offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.pb.x = 148 + this.guiLeft;
|
||||
this.pb.y = 48 + this.guiTop;
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/mac.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/mac.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.MolecularAssembler;
|
||||
}
|
||||
@Override
|
||||
protected GuiText getName() {
|
||||
return GuiText.MolecularAssembler;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,24 +18,20 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiMEPortableCell extends GuiMEMonitorable<ContainerMEPortableCell> {
|
||||
|
||||
public class GuiMEPortableCell extends GuiMEMonitorable<ContainerMEPortableCell>
|
||||
{
|
||||
public GuiMEPortableCell(ContainerMEPortableCell container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
public GuiMEPortableCell(ContainerMEPortableCell container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
@Override
|
||||
int getMaxRows() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,15 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
@@ -32,237 +41,207 @@ import appeng.client.me.SlotME;
|
||||
import appeng.container.implementations.ContainerNetworkStatus;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.util.List;
|
||||
public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implements ISortSource {
|
||||
|
||||
private final ItemRepo repo;
|
||||
private final int rows = 4;
|
||||
private int tooltip = -1;
|
||||
|
||||
public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implements ISortSource
|
||||
{
|
||||
public GuiNetworkStatus(ContainerNetworkStatus container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
|
||||
private final ItemRepo repo;
|
||||
private final int rows = 4;
|
||||
private int tooltip = -1;
|
||||
this.setScrollBar(scrollbar);
|
||||
this.repo = new ItemRepo(scrollbar, this);
|
||||
this.ySize = 153;
|
||||
this.xSize = 195;
|
||||
this.repo.setRowSize(5);
|
||||
}
|
||||
|
||||
public GuiNetworkStatus(ContainerNetworkStatus container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.setScrollBar( scrollbar );
|
||||
this.repo = new ItemRepo( scrollbar, this );
|
||||
this.ySize = 153;
|
||||
this.xSize = 195;
|
||||
this.repo.setRowSize( 5 );
|
||||
}
|
||||
this.addButton(CommonButtons.togglePowerUnit(this.guiLeft - 18, this.guiTop + 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
@Override
|
||||
public void render(final int mouseX, final int mouseY, final float btn) {
|
||||
|
||||
this.addButton( CommonButtons.togglePowerUnit( this.guiLeft - 18, this.guiTop + 8 ) );
|
||||
}
|
||||
final int gx = (this.width - this.xSize) / 2;
|
||||
final int gy = (this.height - this.ySize) / 2;
|
||||
|
||||
@Override
|
||||
public void render(final int mouseX, final int mouseY, final float btn )
|
||||
{
|
||||
this.tooltip = -1;
|
||||
|
||||
final int gx = ( this.width - this.xSize ) / 2;
|
||||
final int gy = ( this.height - this.ySize ) / 2;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for (int z = 0; z <= 4 * 5; z++) {
|
||||
final int minX = gx + 14 + x * 31;
|
||||
final int minY = gy + 41 + y * 18;
|
||||
|
||||
this.tooltip = -1;
|
||||
if (minX < mouseX && minX + 28 > mouseX) {
|
||||
if (minY < mouseY && minY + 20 > mouseY) {
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
for( int z = 0; z <= 4 * 5; z++ )
|
||||
{
|
||||
final int minX = gx + 14 + x * 31;
|
||||
final int minY = gy + 41 + y * 18;
|
||||
x++;
|
||||
|
||||
if( minX < mouseX && minX + 28 > mouseX )
|
||||
{
|
||||
if( minY < mouseY && minY + 20 > mouseY )
|
||||
{
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (x > 4) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
super.render(mouseX, mouseY, btn);
|
||||
}
|
||||
|
||||
if( x > 4 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(GuiText.NetworkDetails.getLocal(), 8, 6, 4210752);
|
||||
|
||||
super.render( mouseX, mouseY, btn );
|
||||
}
|
||||
this.font.drawString(
|
||||
GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong(container.getCurrentPower(), false),
|
||||
13, 16, 4210752);
|
||||
this.font.drawString(
|
||||
GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong(container.getMaxPower(), false), 13, 26,
|
||||
4210752);
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 );
|
||||
this.font.drawString(GuiText.PowerInputRate.getLocal() + ": "
|
||||
+ Platform.formatPowerLong(container.getAverageAddition(), true), 13, 143 - 10, 4210752);
|
||||
this.font.drawString(
|
||||
GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong(container.getPowerUsage(), true),
|
||||
13, 143 - 20, 4210752);
|
||||
|
||||
this.font.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( container.getCurrentPower(), false ), 13, 16, 4210752 );
|
||||
this.font.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( container.getMaxPower(), false ), 13, 26, 4210752 );
|
||||
final int sectionLength = 30;
|
||||
|
||||
this.font.drawString( GuiText.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong( container.getAverageAddition(), true ), 13, 143 - 10,
|
||||
4210752 );
|
||||
this.font.drawString( GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( container.getPowerUsage(), true ), 13, 143 - 20, 4210752 );
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int xo = 12;
|
||||
final int yo = 42;
|
||||
final int viewStart = 0;// myScrollBar.getCurrentScroll() * 5;
|
||||
final int viewEnd = viewStart + 5 * 4;
|
||||
|
||||
final int sectionLength = 30;
|
||||
String toolTip = "";
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
final int xo = 12;
|
||||
final int yo = 42;
|
||||
final int viewStart = 0;// myScrollBar.getCurrentScroll() * 5;
|
||||
final int viewEnd = viewStart + 5 * 4;
|
||||
for (int z = viewStart; z < Math.min(viewEnd, this.repo.size()); z++) {
|
||||
final IAEItemStack refStack = this.repo.getReferenceItem(z);
|
||||
if (refStack != null) {
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
String toolTip = "";
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
String str = Long.toString(refStack.getStackSize());
|
||||
if (refStack.getStackSize() >= 10000) {
|
||||
str = Long.toString(refStack.getStackSize() / 1000) + 'k';
|
||||
}
|
||||
|
||||
for( int z = viewStart; z < Math.min( viewEnd, this.repo.size() ); z++ )
|
||||
{
|
||||
final IAEItemStack refStack = this.repo.getReferenceItem( z );
|
||||
if( refStack != null )
|
||||
{
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef( 0.5f, 0.5f, 0.5f );
|
||||
final int w = this.font.getStringWidth(str);
|
||||
this.font.drawString(str, (int) ((x * sectionLength + xo + sectionLength - 19 - (w * 0.5)) * 2),
|
||||
(y * 18 + yo + 6) * 2, 4210752);
|
||||
|
||||
String str = Long.toString( refStack.getStackSize() );
|
||||
if( refStack.getStackSize() >= 10000 )
|
||||
{
|
||||
str = Long.toString( refStack.getStackSize() / 1000 ) + 'k';
|
||||
}
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * sectionLength + xo + sectionLength - 18;
|
||||
final int posY = y * 18 + yo;
|
||||
|
||||
final int w = this.font.getStringWidth( str );
|
||||
this.font.drawString( str, (int) ( ( x * sectionLength + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * 18 + yo + 6 ) * 2,
|
||||
4210752 );
|
||||
if (this.tooltip == z - viewStart) {
|
||||
toolTip = Platform.getItemDisplayName(refStack).getFormattedText();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
final int posX = x * sectionLength + xo + sectionLength - 18;
|
||||
final int posY = y * 18 + yo;
|
||||
toolTip += ('\n' + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
|
||||
if (refStack.getCountRequestable() > 0) {
|
||||
toolTip += ('\n' + GuiText.EnergyDrain.getLocal() + ": "
|
||||
+ Platform.formatPowerLong(refStack.getCountRequestable(), true));
|
||||
}
|
||||
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
toolTip = Platform.getItemDisplayName( refStack ).getFormattedText();
|
||||
toolPosX = x * sectionLength + xo + sectionLength - 8;
|
||||
toolPosY = y * 18 + yo;
|
||||
}
|
||||
|
||||
toolTip += ( '\n' + GuiText.Installed.getLocal() + ": " + ( refStack.getStackSize() ) );
|
||||
if( refStack.getCountRequestable() > 0 )
|
||||
{
|
||||
toolTip += ( '\n' + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( refStack.getCountRequestable(), true ) );
|
||||
}
|
||||
this.drawItem(posX, posY, refStack.asItemStackRepresentation());
|
||||
|
||||
toolPosX = x * sectionLength + xo + sectionLength - 8;
|
||||
toolPosY = y * 18 + yo;
|
||||
}
|
||||
x++;
|
||||
|
||||
this.drawItem( posX, posY, refStack.asItemStackRepresentation() );
|
||||
if (x > 4) {
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
x++;
|
||||
if (this.tooltip >= 0 && toolTip.length() > 0) {
|
||||
this.drawTooltip(toolPosX, toolPosY + 10, toolTip);
|
||||
}
|
||||
}
|
||||
|
||||
if( x > 4 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/networkstatus.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
|
||||
if( this.tooltip >= 0 && toolTip.length() > 0 )
|
||||
{
|
||||
this.drawTooltip( toolPosX, toolPosY + 10, toolTip );
|
||||
}
|
||||
}
|
||||
public void postUpdate(final List<IAEItemStack> list) {
|
||||
this.repo.clear();
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/networkstatus.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
for (final IAEItemStack is : list) {
|
||||
this.repo.postUpdate(is);
|
||||
}
|
||||
|
||||
public void postUpdate( final List<IAEItemStack> list )
|
||||
{
|
||||
this.repo.clear();
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
for( final IAEItemStack is : list )
|
||||
{
|
||||
this.repo.postUpdate( is );
|
||||
}
|
||||
private void setScrollBar() {
|
||||
final int size = this.repo.size();
|
||||
this.getScrollBar().setTop(39).setLeft(175).setHeight(78);
|
||||
this.getScrollBar().setRange(0, (size + 4) / 5 - this.rows, 1);
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
@Override
|
||||
protected void renderTooltip(final ItemStack stack, final int x, final int y) {
|
||||
final Slot s = this.getSlot(x, y);
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
final int size = this.repo.size();
|
||||
this.getScrollBar().setTop( 39 ).setLeft( 175 ).setHeight( 78 );
|
||||
this.getScrollBar().setRange( 0, ( size + 4 ) / 5 - this.rows, 1 );
|
||||
}
|
||||
if (s instanceof SlotME && !stack.isEmpty()) {
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
@Override
|
||||
protected void renderTooltip( final ItemStack stack, final int x, final int y )
|
||||
{
|
||||
final Slot s = this.getSlot( x, y );
|
||||
try {
|
||||
final SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
} catch (final Throwable ignore) {
|
||||
}
|
||||
|
||||
if( s instanceof SlotME && !stack.isEmpty() )
|
||||
{
|
||||
IAEItemStack myStack = null;
|
||||
if (myStack != null) {
|
||||
List<String> currentToolTip = getTooltipFromItem(stack);
|
||||
|
||||
try
|
||||
{
|
||||
final SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch( final Throwable ignore )
|
||||
{
|
||||
}
|
||||
while (currentToolTip.size() > 1) {
|
||||
currentToolTip.remove(1);
|
||||
}
|
||||
|
||||
if( myStack != null )
|
||||
{
|
||||
List<String> currentToolTip = getTooltipFromItem(stack);
|
||||
currentToolTip.add(GuiText.Installed.getLocal() + ": " + (myStack.getStackSize()));
|
||||
currentToolTip.add(GuiText.EnergyDrain.getLocal() + ": "
|
||||
+ Platform.formatPowerLong(myStack.getCountRequestable(), true));
|
||||
|
||||
while( currentToolTip.size() > 1 )
|
||||
{
|
||||
currentToolTip.remove( 1 );
|
||||
}
|
||||
this.drawTooltip(x, y, currentToolTip);
|
||||
}
|
||||
}
|
||||
|
||||
currentToolTip.add( GuiText.Installed.getLocal() + ": " + ( myStack.getStackSize() ) );
|
||||
currentToolTip.add( GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( myStack.getCountRequestable(), true ) );
|
||||
super.renderTooltip(stack, x, y);
|
||||
}
|
||||
|
||||
this.drawTooltip( x, y, currentToolTip );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public SortOrder getSortBy() {
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
super.renderTooltip( stack, x, y );
|
||||
}
|
||||
@Override
|
||||
public SortDir getSortDir() {
|
||||
return SortDir.ASCENDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortOrder getSortBy()
|
||||
{
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortDir getSortDir()
|
||||
{
|
||||
return SortDir.ASCENDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewItems getSortDisplay()
|
||||
{
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
@Override
|
||||
public ViewItems getSortDisplay() {
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
@@ -25,52 +28,44 @@ import appeng.container.implementations.ContainerNetworkTool;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiNetworkTool extends AEBaseGui<ContainerNetworkTool> {
|
||||
|
||||
public class GuiNetworkTool extends AEBaseGui<ContainerNetworkTool>
|
||||
{
|
||||
private GuiToggleButton tFacades;
|
||||
|
||||
private GuiToggleButton tFacades;
|
||||
public GuiNetworkTool(ContainerNetworkTool container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
public GuiNetworkTool(ContainerNetworkTool container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.tFacades = new GuiToggleButton(this.guiLeft - 18, this.guiTop + 8, 23, 22,
|
||||
GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint.getLocal(),
|
||||
btn -> toggleFacades());
|
||||
|
||||
this.tFacades = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 8, 23, 22, GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint
|
||||
.getLocal(), btn -> toggleFacades() );
|
||||
this.addButton(this.tFacades);
|
||||
}
|
||||
|
||||
this.addButton( this.tFacades );
|
||||
}
|
||||
private void toggleFacades() {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("NetworkTool", "Toggle"));
|
||||
}
|
||||
|
||||
private void toggleFacades() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "NetworkTool", "Toggle" ) );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
if (this.tFacades != null) {
|
||||
this.tFacades.setState(container.isFacadeMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
if( this.tFacades != null )
|
||||
{
|
||||
this.tFacades.setState( container.isFacadeMode() );
|
||||
}
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.NetworkTool.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.NetworkTool.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/toolbox.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/toolbox.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.client.gui.widgets.GuiActionButton;
|
||||
@@ -27,127 +31,117 @@ import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiPatternTerm extends GuiMEMonitorable<ContainerPatternTerm> {
|
||||
|
||||
public class GuiPatternTerm extends GuiMEMonitorable<ContainerPatternTerm>
|
||||
{
|
||||
private static final String BACKGROUND_CRAFTING_MODE = "guis/pattern.png";
|
||||
private static final String BACKGROUND_PROCESSING_MODE = "guis/pattern2.png";
|
||||
|
||||
private static final String BACKGROUND_CRAFTING_MODE = "guis/pattern.png";
|
||||
private static final String BACKGROUND_PROCESSING_MODE = "guis/pattern2.png";
|
||||
private static final String SUBSITUTION_DISABLE = "0";
|
||||
private static final String SUBSITUTION_ENABLE = "1";
|
||||
|
||||
private static final String SUBSITUTION_DISABLE = "0";
|
||||
private static final String SUBSITUTION_ENABLE = "1";
|
||||
private static final String CRAFTMODE_CRFTING = "1";
|
||||
private static final String CRAFTMODE_PROCESSING = "0";
|
||||
|
||||
private static final String CRAFTMODE_CRFTING = "1";
|
||||
private static final String CRAFTMODE_PROCESSING = "0";
|
||||
private GuiTabButton tabCraftButton;
|
||||
private GuiTabButton tabProcessButton;
|
||||
private GuiActionButton substitutionsEnabledBtn;
|
||||
private GuiActionButton substitutionsDisabledBtn;
|
||||
|
||||
private GuiTabButton tabCraftButton;
|
||||
private GuiTabButton tabProcessButton;
|
||||
private GuiActionButton substitutionsEnabledBtn;
|
||||
private GuiActionButton substitutionsDisabledBtn;
|
||||
public GuiPatternTerm(ContainerPatternTerm container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.setReservedSpace(81);
|
||||
}
|
||||
|
||||
public GuiPatternTerm(ContainerPatternTerm container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.setReservedSpace( 81 );
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.tabCraftButton = new GuiTabButton(this.guiLeft + 173, this.guiTop + this.ySize - 177,
|
||||
new ItemStack(Blocks.CRAFTING_TABLE), GuiText.CraftingPattern.getLocal(), this.itemRenderer,
|
||||
btn -> toggleCraftMode(CRAFTMODE_PROCESSING));
|
||||
this.addButton(this.tabCraftButton);
|
||||
|
||||
this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.CRAFTING_TABLE ), GuiText.CraftingPattern
|
||||
.getLocal(), this.itemRenderer, btn -> toggleCraftMode(CRAFTMODE_PROCESSING) );
|
||||
this.addButton( this.tabCraftButton );
|
||||
this.tabProcessButton = new GuiTabButton(this.guiLeft + 173, this.guiTop + this.ySize - 177,
|
||||
new ItemStack(Blocks.FURNACE), GuiText.ProcessingPattern.getLocal(), this.itemRenderer,
|
||||
btn -> toggleCraftMode(CRAFTMODE_CRFTING));
|
||||
this.addButton(this.tabProcessButton);
|
||||
|
||||
this.tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.FURNACE ), GuiText.ProcessingPattern
|
||||
.getLocal(), this.itemRenderer, btn -> toggleCraftMode(CRAFTMODE_CRFTING) );
|
||||
this.addButton( this.tabProcessButton );
|
||||
this.substitutionsEnabledBtn = new GuiActionButton(this.guiLeft + 84, this.guiTop + this.ySize - 163,
|
||||
ActionItems.ENABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_DISABLE));
|
||||
this.substitutionsEnabledBtn.setHalfSize(true);
|
||||
this.addButton(this.substitutionsEnabledBtn);
|
||||
|
||||
this.substitutionsEnabledBtn = new GuiActionButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, ActionItems.ENABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_DISABLE) );
|
||||
this.substitutionsEnabledBtn.setHalfSize( true );
|
||||
this.addButton( this.substitutionsEnabledBtn );
|
||||
this.substitutionsDisabledBtn = new GuiActionButton(this.guiLeft + 84, this.guiTop + this.ySize - 163,
|
||||
ActionItems.DISABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_ENABLE));
|
||||
this.substitutionsDisabledBtn.setHalfSize(true);
|
||||
this.addButton(this.substitutionsDisabledBtn);
|
||||
|
||||
this.substitutionsDisabledBtn = new GuiActionButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, ActionItems.DISABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_ENABLE) );
|
||||
this.substitutionsDisabledBtn.setHalfSize( true );
|
||||
this.addButton( this.substitutionsDisabledBtn );
|
||||
GuiActionButton clearBtn = new GuiActionButton(this.guiLeft + 74, this.guiTop + this.ySize - 163,
|
||||
ActionItems.CLOSE, act -> clear());
|
||||
clearBtn.setHalfSize(true);
|
||||
this.addButton(clearBtn);
|
||||
|
||||
GuiActionButton clearBtn = new GuiActionButton(this.guiLeft + 74, this.guiTop + this.ySize - 163, ActionItems.CLOSE, act -> clear());
|
||||
clearBtn.setHalfSize( true );
|
||||
this.addButton(clearBtn);
|
||||
GuiActionButton encodeBtn = new GuiActionButton(this.guiLeft + 147, this.guiTop + this.ySize - 142,
|
||||
ActionItems.ENCODE, act -> encode());
|
||||
this.addButton(encodeBtn);
|
||||
}
|
||||
|
||||
GuiActionButton encodeBtn = new GuiActionButton(this.guiLeft + 147, this.guiTop + this.ySize - 142, ActionItems.ENCODE, act -> encode());
|
||||
this.addButton(encodeBtn);
|
||||
}
|
||||
private void toggleCraftMode(String mode) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", mode));
|
||||
}
|
||||
|
||||
private void toggleCraftMode(String mode) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig( "PatternTerminal.CraftMode", mode ) );
|
||||
}
|
||||
private void toggleSubstitutions(String mode) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Substitute", mode));
|
||||
}
|
||||
|
||||
private void toggleSubstitutions(String mode) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig( "PatternTerminal.Substitute", mode ) );
|
||||
}
|
||||
private void encode() {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Encode", "1"));
|
||||
}
|
||||
|
||||
private void encode() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
|
||||
}
|
||||
private void clear() {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Clear", "1"));
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
if (this.container.isCraftingMode()) {
|
||||
this.tabCraftButton.visible = true;
|
||||
this.tabProcessButton.visible = false;
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
if( this.container.isCraftingMode() )
|
||||
{
|
||||
this.tabCraftButton.visible = true;
|
||||
this.tabProcessButton.visible = false;
|
||||
if (this.container.substitute) {
|
||||
this.substitutionsEnabledBtn.visible = true;
|
||||
this.substitutionsDisabledBtn.visible = false;
|
||||
} else {
|
||||
this.substitutionsEnabledBtn.visible = false;
|
||||
this.substitutionsDisabledBtn.visible = true;
|
||||
}
|
||||
} else {
|
||||
this.tabCraftButton.visible = false;
|
||||
this.tabProcessButton.visible = true;
|
||||
this.substitutionsEnabledBtn.visible = false;
|
||||
this.substitutionsDisabledBtn.visible = false;
|
||||
}
|
||||
|
||||
if( this.container.substitute )
|
||||
{
|
||||
this.substitutionsEnabledBtn.visible = true;
|
||||
this.substitutionsDisabledBtn.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.substitutionsEnabledBtn.visible = false;
|
||||
this.substitutionsDisabledBtn.visible = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tabCraftButton.visible = false;
|
||||
this.tabProcessButton.visible = true;
|
||||
this.substitutionsEnabledBtn.visible = false;
|
||||
this.substitutionsDisabledBtn.visible = false;
|
||||
}
|
||||
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
||||
this.font.drawString(GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - this.getReservedSpace(),
|
||||
4210752);
|
||||
}
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
this.font.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - this.getReservedSpace(), 4210752 );
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
if (this.container.isCraftingMode()) {
|
||||
return BACKGROUND_CRAFTING_MODE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
if( this.container.isCraftingMode() )
|
||||
{
|
||||
return BACKGROUND_CRAFTING_MODE;
|
||||
}
|
||||
return BACKGROUND_PROCESSING_MODE;
|
||||
}
|
||||
|
||||
return BACKGROUND_PROCESSING_MODE;
|
||||
}
|
||||
@Override
|
||||
protected void repositionSlot(final AppEngSlot s) {
|
||||
final int offsetPlayerSide = s.isPlayerSide() ? 5 : 3;
|
||||
|
||||
@Override
|
||||
protected void repositionSlot( final AppEngSlot s )
|
||||
{
|
||||
final int offsetPlayerSide = s.isPlayerSide() ? 5 : 3;
|
||||
|
||||
s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide;
|
||||
}
|
||||
s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
@@ -26,172 +30,147 @@ import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiPriority extends AEBaseGui<ContainerPriority> {
|
||||
|
||||
public class GuiPriority extends AEBaseGui<ContainerPriority>
|
||||
{
|
||||
private final AESubGui subGui;
|
||||
|
||||
private final AESubGui subGui;
|
||||
private GuiNumberBox priority;
|
||||
|
||||
private GuiNumberBox priority;
|
||||
public GuiPriority(ContainerPriority container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubGui(this, container.getPriorityHost());
|
||||
}
|
||||
|
||||
public GuiPriority(ContainerPriority container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.subGui = new AESubGui(this, container.getPriorityHost());
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
final int a = AEConfig.instance().priorityByStacksAmounts(0);
|
||||
final int b = AEConfig.instance().priorityByStacksAmounts(1);
|
||||
final int c = AEConfig.instance().priorityByStacksAmounts(2);
|
||||
final int d = AEConfig.instance().priorityByStacksAmounts(3);
|
||||
|
||||
final int a = AEConfig.instance().priorityByStacksAmounts( 0 );
|
||||
final int b = AEConfig.instance().priorityByStacksAmounts( 1 );
|
||||
final int c = AEConfig.instance().priorityByStacksAmounts( 2 );
|
||||
final int d = AEConfig.instance().priorityByStacksAmounts( 3 );
|
||||
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a, btn -> addQty(a)));
|
||||
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b, btn -> addQty(b)));
|
||||
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c, btn -> addQty(c)));
|
||||
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d, btn -> addQty(d)));
|
||||
|
||||
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a, btn -> addQty(a) ) );
|
||||
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b, btn -> addQty(b) ) );
|
||||
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c, btn -> addQty(c) ) );
|
||||
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d, btn -> addQty(d) ) );
|
||||
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a, btn -> addQty(-a)));
|
||||
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b, btn -> addQty(-b)));
|
||||
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c, btn -> addQty(-c)));
|
||||
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d, btn -> addQty(-d)));
|
||||
|
||||
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a, btn -> addQty(-a) ) );
|
||||
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b, btn -> addQty(-b) ) );
|
||||
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c, btn -> addQty(-c) ) );
|
||||
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d, btn -> addQty(-d) ) );
|
||||
this.subGui.addBackButton(this::addButton, 154, 0);
|
||||
|
||||
this.subGui.addBackButton(this::addButton, 154, 0);
|
||||
this.priority = new GuiNumberBox(this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT,
|
||||
Long.class);
|
||||
this.priority.setEnableBackgroundDrawing(false);
|
||||
this.priority.setMaxStringLength(16);
|
||||
this.priority.setTextColor(0xFFFFFF);
|
||||
this.priority.setVisible(true);
|
||||
this.priority.setFocused2(true);
|
||||
container.setTextField(this.priority);
|
||||
}
|
||||
|
||||
this.priority = new GuiNumberBox( this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT, Long.class );
|
||||
this.priority.setEnableBackgroundDrawing( false );
|
||||
this.priority.setMaxStringLength( 16 );
|
||||
this.priority.setTextColor( 0xFFFFFF );
|
||||
this.priority.setVisible( true );
|
||||
this.priority.setFocused2( true );
|
||||
container.setTextField( this.priority );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(GuiText.Priority.getLocal(), 8, 6, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture(getBackground());
|
||||
blit(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( getBackground() );
|
||||
blit( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
|
||||
this.priority.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
this.priority.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
private void addQty(final int i) {
|
||||
try {
|
||||
String out = this.priority.getText();
|
||||
|
||||
private void addQty( final int i )
|
||||
{
|
||||
try
|
||||
{
|
||||
String out = this.priority.getText();
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
boolean fixed = false;
|
||||
while( out.startsWith( "0" ) && out.length() > 1 )
|
||||
{
|
||||
out = out.substring( 1 );
|
||||
fixed = true;
|
||||
}
|
||||
if (fixed) {
|
||||
this.priority.setText(out);
|
||||
}
|
||||
|
||||
if( fixed )
|
||||
{
|
||||
this.priority.setText( out );
|
||||
}
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
if( out.isEmpty() )
|
||||
{
|
||||
out = "0";
|
||||
}
|
||||
long result = Long.parseLong(out);
|
||||
result += i;
|
||||
|
||||
long result = Long.parseLong( out );
|
||||
result += i;
|
||||
this.priority.setText(out = Long.toString(result));
|
||||
|
||||
this.priority.setText( out = Long.toString( result ) );
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PriorityHost.Priority", out));
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.priority.setText("0");
|
||||
}
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
// nope..
|
||||
this.priority.setText( "0" );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
if (priority.charTyped(character, key)) {
|
||||
String out = this.priority.getText();
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
if (priority.charTyped(character, key)) {
|
||||
String out = this.priority.getText();
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
boolean fixed = false;
|
||||
while( out.startsWith( "0" ) && out.length() > 1 )
|
||||
{
|
||||
out = out.substring( 1 );
|
||||
fixed = true;
|
||||
}
|
||||
if (fixed) {
|
||||
this.priority.setText(out);
|
||||
}
|
||||
|
||||
if( fixed )
|
||||
{
|
||||
this.priority.setText( out );
|
||||
}
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
if( out.isEmpty() )
|
||||
{
|
||||
out = "0";
|
||||
}
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PriorityHost.Priority", out));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) {
|
||||
if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14)
|
||||
&& this.priority.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
String out = this.priority.getText();
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_)
|
||||
{
|
||||
if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) )
|
||||
{
|
||||
if( ( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 ) && this.priority
|
||||
.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
|
||||
{
|
||||
String out = this.priority.getText();
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
boolean fixed = false;
|
||||
while( out.startsWith( "0" ) && out.length() > 1 )
|
||||
{
|
||||
out = out.substring( 1 );
|
||||
fixed = true;
|
||||
}
|
||||
if (fixed) {
|
||||
this.priority.setText(out);
|
||||
}
|
||||
|
||||
if( fixed )
|
||||
{
|
||||
this.priority.setText( out );
|
||||
}
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
if( out.isEmpty() )
|
||||
{
|
||||
out = "0";
|
||||
}
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PriorityHost.Priority", out));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/priority.png";
|
||||
}
|
||||
protected String getBackground() {
|
||||
return "guis/priority.png";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,35 +18,30 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiQNB extends AEBaseGui<ContainerQNB> {
|
||||
|
||||
public class GuiQNB extends AEBaseGui<ContainerQNB>
|
||||
{
|
||||
public GuiQNB(ContainerQNB container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
public GuiQNB(ContainerQNB container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.QuantumLinkChamber.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.QuantumLinkChamber.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/chest.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/chest.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
@@ -30,72 +31,62 @@ import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiQuartzKnife extends AEBaseGui<ContainerQuartzKnife> {
|
||||
|
||||
public class GuiQuartzKnife extends AEBaseGui<ContainerQuartzKnife>
|
||||
{
|
||||
private TextFieldWidget name;
|
||||
|
||||
private TextFieldWidget name;
|
||||
public GuiQuartzKnife(ContainerQuartzKnife container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 184;
|
||||
}
|
||||
|
||||
public GuiQuartzKnife(ContainerQuartzKnife container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 184;
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.name = new TextFieldWidget(this.font, this.guiLeft + 24, this.guiTop + 32, 79, this.font.FONT_HEIGHT, "");
|
||||
this.name.setEnableBackgroundDrawing(false);
|
||||
this.name.setMaxStringLength(32);
|
||||
this.name.setTextColor(0xFFFFFF);
|
||||
this.name.setVisible(true);
|
||||
this.name.setFocused2(true);
|
||||
}
|
||||
|
||||
this.name = new TextFieldWidget( this.font, this.guiLeft + 24, this.guiTop + 32, 79, this.font.FONT_HEIGHT, "" );
|
||||
this.name.setEnableBackgroundDrawing( false );
|
||||
this.name.setMaxStringLength( 32 );
|
||||
this.name.setTextColor( 0xFFFFFF );
|
||||
this.name.setVisible( true );
|
||||
this.name.setFocused2( true );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.QuartzCuttingKnife.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.QuartzCuttingKnife.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/quartzknife.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
this.name.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/quartzknife.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
this.name.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
if (this.name.charTyped(character, key)) {
|
||||
final String Out = this.name.getText();
|
||||
container.setName(Out);
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("QuartzKnife.Name", Out));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
if( this.name.charTyped( character, key ) )
|
||||
{
|
||||
final String Out = this.name.getText();
|
||||
container.setName( Out );
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) );
|
||||
return true;
|
||||
}
|
||||
return super.charTyped(character, key);
|
||||
}
|
||||
|
||||
return super.charTyped(character, key);
|
||||
}
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (this.name.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
final String Out = this.name.getText();
|
||||
container.setName(Out);
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("QuartzKnife.Name", Out));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_)
|
||||
{
|
||||
if( this.name.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
|
||||
{
|
||||
final String Out = this.name.getText();
|
||||
container.setName( Out );
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.SortOrder;
|
||||
@@ -28,76 +28,77 @@ import appeng.container.implementations.ContainerSecurityStation;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiSecurityStation extends GuiMEMonitorable<ContainerSecurityStation> {
|
||||
|
||||
public class GuiSecurityStation extends GuiMEMonitorable<ContainerSecurityStation>
|
||||
{
|
||||
private GuiToggleButton inject;
|
||||
private GuiToggleButton extract;
|
||||
private GuiToggleButton craft;
|
||||
private GuiToggleButton build;
|
||||
private GuiToggleButton security;
|
||||
|
||||
private GuiToggleButton inject;
|
||||
private GuiToggleButton extract;
|
||||
private GuiToggleButton craft;
|
||||
private GuiToggleButton build;
|
||||
private GuiToggleButton security;
|
||||
public GuiSecurityStation(ContainerSecurityStation container, PlayerInventory playerInventory,
|
||||
ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.setCustomSortOrder(false);
|
||||
this.setReservedSpace(33);
|
||||
|
||||
public GuiSecurityStation(ContainerSecurityStation container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.setCustomSortOrder( false );
|
||||
this.setReservedSpace( 33 );
|
||||
// increase size so that the slot is over the gui.
|
||||
this.xSize += 56;
|
||||
this.setStandardSize(this.xSize);
|
||||
}
|
||||
|
||||
// increase size so that the slot is over the gui.
|
||||
this.xSize += 56;
|
||||
this.setStandardSize( this.xSize );
|
||||
}
|
||||
private void toggleOption(SecurityPermissions permission) {
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new PacketValueConfig("TileSecurityStation.ToggleOption", permission.name()));
|
||||
}
|
||||
|
||||
private void toggleOption(SecurityPermissions permission) {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "TileSecurityStation.ToggleOption", permission.name() ) );
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
final int top = this.guiTop + this.ySize - 116;
|
||||
this.inject = this.addButton(new GuiToggleButton(this.guiLeft + 56, top, 11 * 16, 12 * 16,
|
||||
SecurityPermissions.INJECT.getTranslatedName(), SecurityPermissions.INJECT.getTranslatedTip(),
|
||||
btn -> toggleOption(SecurityPermissions.INJECT)));
|
||||
|
||||
final int top = this.guiTop + this.ySize - 116;
|
||||
this.inject = this.addButton( new GuiToggleButton( this.guiLeft + 56, top, 11 * 16, 12 * 16, SecurityPermissions.INJECT
|
||||
.getTranslatedName(), SecurityPermissions.INJECT.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.INJECT) ) );
|
||||
this.extract = this.addButton(new GuiToggleButton(this.guiLeft + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1,
|
||||
SecurityPermissions.EXTRACT.getTranslatedName(), SecurityPermissions.EXTRACT.getTranslatedTip(),
|
||||
btn -> toggleOption(SecurityPermissions.EXTRACT)));
|
||||
|
||||
this.extract = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
|
||||
.getTranslatedName(), SecurityPermissions.EXTRACT.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.EXTRACT ) ) );
|
||||
this.craft = this.addButton(new GuiToggleButton(this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2,
|
||||
SecurityPermissions.CRAFT.getTranslatedName(), SecurityPermissions.CRAFT.getTranslatedTip(),
|
||||
btn -> toggleOption(SecurityPermissions.CRAFT)));
|
||||
|
||||
this.craft = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT
|
||||
.getTranslatedName(), SecurityPermissions.CRAFT.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.CRAFT ) ) );
|
||||
this.build = this.addButton(new GuiToggleButton(this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3,
|
||||
SecurityPermissions.BUILD.getTranslatedName(), SecurityPermissions.BUILD.getTranslatedTip(),
|
||||
btn -> toggleOption(SecurityPermissions.BUILD)));
|
||||
|
||||
this.build = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD
|
||||
.getTranslatedName(), SecurityPermissions.BUILD.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.BUILD ) ) );
|
||||
this.security = this.addButton(new GuiToggleButton(this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4,
|
||||
SecurityPermissions.SECURITY.getTranslatedName(), SecurityPermissions.SECURITY.getTranslatedTip(),
|
||||
btn -> toggleOption(SecurityPermissions.SECURITY)));
|
||||
}
|
||||
|
||||
this.security = this.addButton( new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
|
||||
.getTranslatedName(), SecurityPermissions.SECURITY.getTranslatedTip(), btn -> toggleOption(SecurityPermissions.SECURITY ) ) );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
||||
this.font.drawString(GuiText.SecurityCardEditor.getLocal(), 8, this.ySize - 96 + 1 - this.getReservedSpace(),
|
||||
4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
this.font.drawString( GuiText.SecurityCardEditor.getLocal(), 8, this.ySize - 96 + 1 - this.getReservedSpace(), 4210752 );
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
this.inject.setState((container.getPermissionMode() & (1 << SecurityPermissions.INJECT.ordinal())) > 0);
|
||||
this.extract.setState((container.getPermissionMode() & (1 << SecurityPermissions.EXTRACT.ordinal())) > 0);
|
||||
this.craft.setState((container.getPermissionMode() & (1 << SecurityPermissions.CRAFT.ordinal())) > 0);
|
||||
this.build.setState((container.getPermissionMode() & (1 << SecurityPermissions.BUILD.ordinal())) > 0);
|
||||
this.security.setState((container.getPermissionMode() & (1 << SecurityPermissions.SECURITY.ordinal())) > 0);
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
this.inject.setState( ( container.getPermissionMode() & ( 1 << SecurityPermissions.INJECT.ordinal() ) ) > 0 );
|
||||
this.extract.setState( ( container.getPermissionMode() & ( 1 << SecurityPermissions.EXTRACT.ordinal() ) ) > 0 );
|
||||
this.craft.setState( ( container.getPermissionMode() & ( 1 << SecurityPermissions.CRAFT.ordinal() ) ) > 0 );
|
||||
this.build.setState( ( container.getPermissionMode() & ( 1 << SecurityPermissions.BUILD.ordinal() ) ) > 0 );
|
||||
this.security.setState( ( container.getPermissionMode() & ( 1 << SecurityPermissions.SECURITY.ordinal() ) ) > 0 );
|
||||
return "guis/security_station.png";
|
||||
}
|
||||
|
||||
return "guis/security_station.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortOrder getSortBy()
|
||||
{
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
@Override
|
||||
public SortOrder getSortBy() {
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,47 +18,40 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class GuiSkyChest extends AEBaseGui<ContainerSkyChest>
|
||||
{
|
||||
public class GuiSkyChest extends AEBaseGui<ContainerSkyChest> {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(AppEng.MOD_ID, "textures/guis/skychest.png");
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(AppEng.MOD_ID, "textures/guis/skychest.png");
|
||||
|
||||
public GuiSkyChest( ContainerSkyChest container, PlayerInventory playerInv, ITextComponent title )
|
||||
{
|
||||
super( container, playerInv, title );
|
||||
this.ySize = 195;
|
||||
}
|
||||
public GuiSkyChest(ContainerSkyChest container, PlayerInventory playerInv, ITextComponent title) {
|
||||
super(container, playerInv, title);
|
||||
this.ySize = 195;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.SkyChest.getLocal() ), 8, 8, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 2, 4210752 );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.SkyChest.getLocal()), 8, 8, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
bindTexture(TEXTURE);
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
bindTexture(TEXTURE);
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean enableSpaceClicking()
|
||||
{
|
||||
// FIXME return !Integrations.invTweaks().isEnabled();
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean enableSpaceClicking() {
|
||||
// FIXME return !Integrations.invTweaks().isEnabled();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,61 +18,58 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.CommonButtons;
|
||||
import appeng.container.implementations.ContainerSpatialIOPort;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiSpatialIOPort extends AEBaseGui<ContainerSpatialIOPort> {
|
||||
|
||||
public class GuiSpatialIOPort extends AEBaseGui<ContainerSpatialIOPort>
|
||||
{
|
||||
public GuiSpatialIOPort(ContainerSpatialIOPort container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 199;
|
||||
}
|
||||
|
||||
public GuiSpatialIOPort(ContainerSpatialIOPort container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 199;
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
this.addButton(CommonButtons.togglePowerUnit(this.guiLeft - 18, this.guiTop + 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.addButton( CommonButtons.togglePowerUnit( this.guiLeft - 18, this.guiTop + 8 ) );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(GuiText.StoredPower.getLocal() + ": "
|
||||
+ Platform.formatPowerLong(this.container.getCurrentPower(), false), 13, 21, 4210752);
|
||||
this.font.drawString(
|
||||
GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong(this.container.getMaxPower(), false), 13,
|
||||
31, 4210752);
|
||||
this.font.drawString(GuiText.RequiredPower.getLocal() + ": "
|
||||
+ Platform.formatPowerLong(this.container.getRequiredPower(), false), 13, 73, 4210752);
|
||||
this.font.drawString(
|
||||
GuiText.Efficiency.getLocal() + ": " + (((float) this.container.getEfficency()) / 100) + '%', 13, 83,
|
||||
4210752);
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getCurrentPower(), false ), 13, 21,
|
||||
4210752 );
|
||||
this.font.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getMaxPower(), false ), 13, 31, 4210752 );
|
||||
this.font.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getRequiredPower(), false ), 13, 73,
|
||||
4210752 );
|
||||
this.font.drawString( GuiText.Efficiency.getLocal() + ": " + ( ( (float) this.container.getEfficency() ) / 100 ) + '%', 13, 83, 4210752 );
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.SpatialIOPort.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96, 4210752);
|
||||
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96, 4210752 );
|
||||
if (this.container.xSize != 0 && this.container.ySize != 0 && this.container.zSize != 0) {
|
||||
final String text = GuiText.SCSSize.getLocal() + ": " + this.container.xSize + "x" + this.container.ySize
|
||||
+ "x" + this.container.zSize;
|
||||
this.font.drawString(text, 13, 93, 4210752);
|
||||
} else {
|
||||
this.font.drawString(GuiText.SCSSize.getLocal() + ": " + GuiText.SCSInvalid.getLocal(), 13, 93, 4210752);
|
||||
}
|
||||
|
||||
if( this.container.xSize != 0 && this.container.ySize != 0 && this.container.zSize != 0 )
|
||||
{
|
||||
final String text = GuiText.SCSSize.getLocal() + ": " + this.container.xSize + "x" + this.container.ySize + "x" + this.container.zSize;
|
||||
this.font.drawString( text, 13, 93, 4210752 );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.font.drawString( GuiText.SCSSize.getLocal() + ": " + GuiText.SCSInvalid.getLocal(), 13, 93, 4210752 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/spatialio.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/spatialio.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.client.gui.widgets.GuiActionButton;
|
||||
@@ -30,75 +32,69 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiStorageBus extends GuiUpgradeable<ContainerStorageBus> {
|
||||
|
||||
public class GuiStorageBus extends GuiUpgradeable<ContainerStorageBus>
|
||||
{
|
||||
private GuiSettingToggleButton<AccessRestriction> rwMode;
|
||||
private GuiSettingToggleButton<StorageFilter> storageFilter;
|
||||
|
||||
private GuiSettingToggleButton<AccessRestriction> rwMode;
|
||||
private GuiSettingToggleButton<StorageFilter> storageFilter;
|
||||
public GuiStorageBus(ContainerStorageBus container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
public GuiStorageBus(ContainerStorageBus container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 251;
|
||||
}
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, btn -> clear()));
|
||||
addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, btn -> partition()));
|
||||
this.rwMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS,
|
||||
AccessRestriction.READ_WRITE);
|
||||
this.storageFilter = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68,
|
||||
Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
|
||||
this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE,
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
addButton( new GuiActionButton( this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, btn -> clear() ) );
|
||||
addButton( new GuiActionButton( this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, btn -> partition() ) );
|
||||
this.rwMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE );
|
||||
this.storageFilter = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
|
||||
this.fuzzyMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.addButton(new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(),
|
||||
this.itemRenderer, btn -> openPriorityGui()));
|
||||
|
||||
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
|
||||
this.addButton(this.storageFilter);
|
||||
this.addButton(this.fuzzyMode);
|
||||
this.addButton(this.rwMode);
|
||||
}
|
||||
|
||||
this.addButton( this.storageFilter );
|
||||
this.addButton( this.fuzzyMode );
|
||||
this.addButton( this.rwMode );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.StorageBus.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.StorageBus.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
if (this.fuzzyMode != null) {
|
||||
this.fuzzyMode.set(this.cvb.getFuzzyMode());
|
||||
}
|
||||
|
||||
if( this.fuzzyMode != null )
|
||||
{
|
||||
this.fuzzyMode.set( this.cvb.getFuzzyMode() );
|
||||
}
|
||||
if (this.storageFilter != null) {
|
||||
this.storageFilter.set(((ContainerStorageBus) this.cvb).getStorageFilter());
|
||||
}
|
||||
|
||||
if( this.storageFilter != null )
|
||||
{
|
||||
this.storageFilter.set( ( (ContainerStorageBus) this.cvb ).getStorageFilter() );
|
||||
}
|
||||
if (this.rwMode != null) {
|
||||
this.rwMode.set(((ContainerStorageBus) this.cvb).getReadWriteMode());
|
||||
}
|
||||
}
|
||||
|
||||
if( this.rwMode != null )
|
||||
{
|
||||
this.rwMode.set( ( (ContainerStorageBus) this.cvb ).getReadWriteMode() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
private void partition() {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("StorageBus.Action", "Partition"));
|
||||
}
|
||||
|
||||
private void partition() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
|
||||
}
|
||||
private void clear() {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("StorageBus.Action", "Clear"));
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
|
||||
}
|
||||
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
|
||||
}
|
||||
private void openPriorityGui() {
|
||||
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(ContainerPriority.TYPE));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
@@ -30,136 +30,121 @@ import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.GuiSettingToggleButton;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.parts.automation.PartExportBus;
|
||||
import appeng.parts.automation.PartImportBus;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiUpgradeable<T extends ContainerUpgradeable> extends AEBaseGui<T> {
|
||||
|
||||
public class GuiUpgradeable<T extends ContainerUpgradeable> extends AEBaseGui<T>
|
||||
{
|
||||
protected final ContainerUpgradeable cvb;
|
||||
protected final IUpgradeableHost bc;
|
||||
|
||||
protected final ContainerUpgradeable cvb;
|
||||
protected final IUpgradeableHost bc;
|
||||
protected GuiSettingToggleButton<RedstoneMode> redstoneMode;
|
||||
protected GuiSettingToggleButton<FuzzyMode> fuzzyMode;
|
||||
protected GuiSettingToggleButton<YesNo> craftMode;
|
||||
protected GuiSettingToggleButton<SchedulingMode> schedulingMode;
|
||||
|
||||
protected GuiSettingToggleButton<RedstoneMode> redstoneMode;
|
||||
protected GuiSettingToggleButton<FuzzyMode> fuzzyMode;
|
||||
protected GuiSettingToggleButton<YesNo> craftMode;
|
||||
protected GuiSettingToggleButton<SchedulingMode> schedulingMode;
|
||||
public GuiUpgradeable(T container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.cvb = container;
|
||||
|
||||
public GuiUpgradeable(T container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.cvb = container;
|
||||
this.bc = (IUpgradeableHost) container.getTarget();
|
||||
this.xSize = this.hasToolbox() ? 246 : 211;
|
||||
this.ySize = 184;
|
||||
}
|
||||
|
||||
this.bc = (IUpgradeableHost) container.getTarget();
|
||||
this.xSize = this.hasToolbox() ? 246 : 211;
|
||||
this.ySize = 184;
|
||||
}
|
||||
protected boolean hasToolbox() {
|
||||
return (this.container).hasToolbox();
|
||||
}
|
||||
|
||||
protected boolean hasToolbox()
|
||||
{
|
||||
return ( this.container ).hasToolbox();
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
this.addButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.addButtons();
|
||||
}
|
||||
protected void addButtons() {
|
||||
this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8,
|
||||
Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
|
||||
addButton(this.redstoneMode);
|
||||
this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE,
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
addButton(this.fuzzyMode);
|
||||
this.craftMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY,
|
||||
YesNo.NO);
|
||||
addButton(this.craftMode);
|
||||
this.schedulingMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68,
|
||||
Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT);
|
||||
addButton(this.schedulingMode);
|
||||
}
|
||||
|
||||
protected void addButtons()
|
||||
{
|
||||
this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
addButton(this.redstoneMode);
|
||||
this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
addButton(this.fuzzyMode);
|
||||
this.craftMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO );
|
||||
addButton(this.craftMode);
|
||||
this.schedulingMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
|
||||
addButton(this.schedulingMode);
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(this.getName().getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( this.getName().getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
if (this.redstoneMode != null) {
|
||||
this.redstoneMode.set(this.cvb.getRedStoneMode());
|
||||
}
|
||||
|
||||
if( this.redstoneMode != null )
|
||||
{
|
||||
this.redstoneMode.set( this.cvb.getRedStoneMode() );
|
||||
}
|
||||
if (this.fuzzyMode != null) {
|
||||
this.fuzzyMode.set(this.cvb.getFuzzyMode());
|
||||
}
|
||||
|
||||
if( this.fuzzyMode != null )
|
||||
{
|
||||
this.fuzzyMode.set( this.cvb.getFuzzyMode() );
|
||||
}
|
||||
if (this.craftMode != null) {
|
||||
this.craftMode.set(this.cvb.getCraftingMode());
|
||||
}
|
||||
|
||||
if( this.craftMode != null )
|
||||
{
|
||||
this.craftMode.set( this.cvb.getCraftingMode() );
|
||||
}
|
||||
if (this.schedulingMode != null) {
|
||||
this.schedulingMode.set(this.cvb.getSchedulingMode());
|
||||
}
|
||||
}
|
||||
|
||||
if( this.schedulingMode != null )
|
||||
{
|
||||
this.schedulingMode.set( this.cvb.getSchedulingMode() );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.handleButtonVisibility();
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.handleButtonVisibility();
|
||||
this.bindTexture(this.getBackground());
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset());
|
||||
if (this.drawUpgrades()) {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvb.availableUpgrades() * 18,
|
||||
getBlitOffset());
|
||||
}
|
||||
if (this.hasToolbox()) {
|
||||
GuiUtils.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68,
|
||||
getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
this.bindTexture( this.getBackground() );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize, getBlitOffset() );
|
||||
if( this.drawUpgrades() )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvb.availableUpgrades() * 18, getBlitOffset() );
|
||||
}
|
||||
if( this.hasToolbox() )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68, getBlitOffset() );
|
||||
}
|
||||
}
|
||||
protected void handleButtonVisibility() {
|
||||
if (this.redstoneMode != null) {
|
||||
this.redstoneMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.REDSTONE) > 0);
|
||||
}
|
||||
if (this.fuzzyMode != null) {
|
||||
this.fuzzyMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.FUZZY) > 0);
|
||||
}
|
||||
if (this.craftMode != null) {
|
||||
this.craftMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.CRAFTING) > 0);
|
||||
}
|
||||
if (this.schedulingMode != null) {
|
||||
this.schedulingMode.setVisibility(
|
||||
this.bc.getInstalledUpgrades(Upgrades.CAPACITY) > 0 && this.bc instanceof PartExportBus);
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleButtonVisibility()
|
||||
{
|
||||
if( this.redstoneMode != null )
|
||||
{
|
||||
this.redstoneMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 );
|
||||
}
|
||||
if( this.fuzzyMode != null )
|
||||
{
|
||||
this.fuzzyMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
|
||||
}
|
||||
if( this.craftMode != null )
|
||||
{
|
||||
this.craftMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
|
||||
}
|
||||
if( this.schedulingMode != null )
|
||||
{
|
||||
this.schedulingMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CAPACITY ) > 0 && this.bc instanceof PartExportBus );
|
||||
}
|
||||
}
|
||||
protected String getBackground() {
|
||||
return "guis/bus.png";
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/bus.png";
|
||||
}
|
||||
protected boolean drawUpgrades() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean drawUpgrades()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected GuiText getName()
|
||||
{
|
||||
return this.bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus;
|
||||
}
|
||||
protected GuiText getName() {
|
||||
return this.bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
@@ -28,54 +30,48 @@ import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.container.implementations.ContainerVibrationChamber;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.misc.TileVibrationChamber;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiVibrationChamber extends AEBaseGui<ContainerVibrationChamber> {
|
||||
|
||||
public class GuiVibrationChamber extends AEBaseGui<ContainerVibrationChamber>
|
||||
{
|
||||
private GuiProgressBar pb;
|
||||
|
||||
private GuiProgressBar pb;
|
||||
public GuiVibrationChamber(ContainerVibrationChamber container, PlayerInventory playerInventory,
|
||||
ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
public GuiVibrationChamber(ContainerVibrationChamber container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.pb = new GuiProgressBar(this.container, "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL);
|
||||
this.addButton(this.pb);
|
||||
}
|
||||
|
||||
this.pb = new GuiProgressBar( this.container, "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL );
|
||||
this.addButton( this.pb );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.VibrationChamber.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.VibrationChamber.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
this.pb.setFullMsg(TileVibrationChamber.POWER_PER_TICK * this.container.getCurrentProgress()
|
||||
/ TileVibrationChamber.DILATION_SCALING + " AE/t");
|
||||
|
||||
this.pb.setFullMsg( TileVibrationChamber.POWER_PER_TICK * this.container.getCurrentProgress() / TileVibrationChamber.DILATION_SCALING + " AE/t" );
|
||||
if (this.container.getRemainingBurnTime() > 0) {
|
||||
final int i1 = this.container.getRemainingBurnTime() * 12 / 100;
|
||||
this.bindTexture("guis/vibchamber.png");
|
||||
RenderSystem.color3f(1, 1, 1);
|
||||
final int l = -15;
|
||||
final int k = 25;
|
||||
GuiUtils.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2, getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
if( this.container.getRemainingBurnTime() > 0 )
|
||||
{
|
||||
final int i1 = this.container.getRemainingBurnTime() * 12 / 100;
|
||||
this.bindTexture( "guis/vibchamber.png" );
|
||||
RenderSystem.color3f( 1, 1, 1 );
|
||||
final int l = -15;
|
||||
final int k = 25;
|
||||
GuiUtils.drawTexturedModalRect( k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2, getBlitOffset() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/vibchamber.png" );
|
||||
this.pb.x = 99 + this.guiLeft;
|
||||
this.pb.y = 36 + this.guiTop;
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/vibchamber.png");
|
||||
this.pb.x = 99 + this.guiLeft;
|
||||
this.pb.y = 36 + this.guiTop;
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
@@ -27,49 +30,42 @@ import appeng.container.implementations.ContainerWireless;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiWireless extends AEBaseGui<ContainerWireless> {
|
||||
|
||||
public class GuiWireless extends AEBaseGui<ContainerWireless>
|
||||
{
|
||||
public GuiWireless(ContainerWireless container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
public GuiWireless(ContainerWireless container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
this.ySize = 166;
|
||||
}
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
this.addButton(CommonButtons.togglePowerUnit(this.guiLeft - 18, this.guiTop + 8));
|
||||
}
|
||||
|
||||
this.addButton( CommonButtons.togglePowerUnit( this.guiLeft - 18, this.guiTop + 8 ) );
|
||||
}
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.font.drawString(this.getGuiDisplayName(GuiText.Wireless.getLocal()), 8, 6, 4210752);
|
||||
this.font.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.font.drawString( this.getGuiDisplayName( GuiText.Wireless.getLocal() ), 8, 6, 4210752 );
|
||||
this.font.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
if (container.getRange() > 0) {
|
||||
final String firstMessage = GuiText.Range.getLocal() + ": " + (container.getRange() / 10.0) + " m";
|
||||
final String secondMessage = GuiText.PowerUsageRate.getLocal() + ": "
|
||||
+ Platform.formatPowerLong(container.getDrain(), true);
|
||||
|
||||
if( container.getRange() > 0 )
|
||||
{
|
||||
final String firstMessage = GuiText.Range.getLocal() + ": " + ( container.getRange() / 10.0 ) + " m";
|
||||
final String secondMessage = GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( container.getDrain(), true );
|
||||
final int strWidth = Math.max(this.font.getStringWidth(firstMessage),
|
||||
this.font.getStringWidth(secondMessage));
|
||||
final int cOffset = (this.xSize / 2) - (strWidth / 2);
|
||||
this.font.drawString(firstMessage, cOffset, 20, 4210752);
|
||||
this.font.drawString(secondMessage, cOffset, 20 + 12, 4210752);
|
||||
}
|
||||
}
|
||||
|
||||
final int strWidth = Math.max( this.font.getStringWidth( firstMessage ), this.font.getStringWidth( secondMessage ) );
|
||||
final int cOffset = ( this.xSize / 2 ) - ( strWidth / 2 );
|
||||
this.font.drawString( firstMessage, cOffset, 20, 4210752 );
|
||||
this.font.drawString( secondMessage, cOffset, 20 + 12, 4210752 );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
|
||||
{
|
||||
this.bindTexture( "guis/wireless.png" );
|
||||
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset() );
|
||||
}
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
this.bindTexture("guis/wireless.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,18 +18,16 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
// FIXME: Extended from GuiPortableCell before... Why?
|
||||
public class GuiWirelessTerm extends GuiMEMonitorable<ContainerMEPortableCell>
|
||||
{
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
|
||||
public GuiWirelessTerm(ContainerMEPortableCell container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
// FIXME: Extended from GuiPortableCell before... Why?
|
||||
public class GuiWirelessTerm extends GuiMEMonitorable<ContainerMEPortableCell> {
|
||||
|
||||
public GuiWirelessTerm(ContainerMEPortableCell container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,12 +12,13 @@ public final class CommonButtons {
|
||||
}
|
||||
|
||||
public static GuiSettingToggleButton<PowerUnits> togglePowerUnit(int x, int y) {
|
||||
return new GuiSettingToggleButton<>( x, y, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(), CommonButtons::togglePowerUnit );
|
||||
return new GuiSettingToggleButton<>(x, y, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(),
|
||||
CommonButtons::togglePowerUnit);
|
||||
}
|
||||
|
||||
private static void togglePowerUnit(GuiSettingToggleButton<PowerUnits> button, boolean backwards) {
|
||||
AEConfig.instance().nextPowerUnit( backwards );
|
||||
button.set( AEConfig.instance().selectedPowerUnit() );
|
||||
AEConfig.instance().nextPowerUnit(backwards);
|
||||
button.set(AEConfig.instance().selectedPowerUnit());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,14 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
@@ -29,87 +33,77 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
public class GuiActionButton extends GuiIconButton implements ITooltip {
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
|
||||
private final int iconIndex;
|
||||
|
||||
public class GuiActionButton extends GuiIconButton implements ITooltip
|
||||
{
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
|
||||
private final int iconIndex;
|
||||
public GuiActionButton(final int x, final int y, final ActionItems action, Consumer<ActionItems> onPress) {
|
||||
super(x, y, btn -> onPress.accept(action));
|
||||
|
||||
public GuiActionButton(final int x, final int y, final ActionItems action, Consumer<ActionItems> onPress )
|
||||
{
|
||||
super( x, y, btn -> onPress.accept(action) );
|
||||
ButtonToolTips displayName;
|
||||
ButtonToolTips displayValue;
|
||||
switch (action) {
|
||||
case WRENCH:
|
||||
iconIndex = 66;
|
||||
displayName = ButtonToolTips.PartitionStorage;
|
||||
displayValue = ButtonToolTips.PartitionStorageHint;
|
||||
break;
|
||||
case CLOSE:
|
||||
iconIndex = 6;
|
||||
displayName = ButtonToolTips.Clear;
|
||||
displayValue = ButtonToolTips.ClearSettings;
|
||||
break;
|
||||
case STASH:
|
||||
iconIndex = 6;
|
||||
displayName = ButtonToolTips.Stash;
|
||||
displayValue = ButtonToolTips.StashDesc;
|
||||
break;
|
||||
case ENCODE:
|
||||
iconIndex = 8;
|
||||
displayName = ButtonToolTips.Encode;
|
||||
displayValue = ButtonToolTips.EncodeDescription;
|
||||
break;
|
||||
case ENABLE_SUBSTITUTION:
|
||||
iconIndex = 4 + 3 * 16;
|
||||
displayName = ButtonToolTips.Substitutions;
|
||||
displayValue = ButtonToolTips.SubstitutionsDescEnabled;
|
||||
break;
|
||||
case DISABLE_SUBSTITUTION:
|
||||
iconIndex = 7 + 3 * 16;
|
||||
displayName = ButtonToolTips.Substitutions;
|
||||
displayValue = ButtonToolTips.SubstitutionsDescDisabled;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown ActionItem: " + action);
|
||||
}
|
||||
|
||||
ButtonToolTips displayName;
|
||||
ButtonToolTips displayValue;
|
||||
switch (action) {
|
||||
case WRENCH:
|
||||
iconIndex = 66;
|
||||
displayName = ButtonToolTips.PartitionStorage;
|
||||
displayValue = ButtonToolTips.PartitionStorageHint;
|
||||
break;
|
||||
case CLOSE:
|
||||
iconIndex = 6;
|
||||
displayName = ButtonToolTips.Clear;
|
||||
displayValue = ButtonToolTips.ClearSettings;
|
||||
break;
|
||||
case STASH:
|
||||
iconIndex = 6;
|
||||
displayName = ButtonToolTips.Stash;
|
||||
displayValue = ButtonToolTips.StashDesc;
|
||||
break;
|
||||
case ENCODE:
|
||||
iconIndex = 8;
|
||||
displayName = ButtonToolTips.Encode;
|
||||
displayValue = ButtonToolTips.EncodeDescription;
|
||||
break;
|
||||
case ENABLE_SUBSTITUTION:
|
||||
iconIndex = 4 + 3 * 16;
|
||||
displayName = ButtonToolTips.Substitutions;
|
||||
displayValue = ButtonToolTips.SubstitutionsDescEnabled;
|
||||
break;
|
||||
case DISABLE_SUBSTITUTION:
|
||||
iconIndex = 7 + 3 * 16;
|
||||
displayName = ButtonToolTips.Substitutions;
|
||||
displayValue = ButtonToolTips.SubstitutionsDescDisabled;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown ActionItem: " + action);
|
||||
}
|
||||
setMessage(buildMessage(displayName, displayValue));
|
||||
}
|
||||
|
||||
setMessage(buildMessage(displayName, displayValue));
|
||||
}
|
||||
@Override
|
||||
protected int getIconIndex() {
|
||||
return iconIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIconIndex()
|
||||
{
|
||||
return iconIndex;
|
||||
}
|
||||
private String buildMessage(ButtonToolTips displayName, ButtonToolTips displayValue) {
|
||||
String name = displayName.getTranslationKey().getString();
|
||||
String value = displayValue.getTranslationKey().getString();
|
||||
|
||||
private String buildMessage(ButtonToolTips displayName, ButtonToolTips displayValue)
|
||||
{
|
||||
String name = displayName.getTranslationKey().getString();
|
||||
String value = displayValue.getTranslationKey().getString();
|
||||
value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n");
|
||||
final StringBuilder sb = new StringBuilder(value);
|
||||
|
||||
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
|
||||
final StringBuilder sb = new StringBuilder( value );
|
||||
int i = sb.lastIndexOf("\n");
|
||||
if (i <= 0) {
|
||||
i = 0;
|
||||
}
|
||||
while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) {
|
||||
sb.replace(i, i + 1, "\n");
|
||||
}
|
||||
|
||||
int i = sb.lastIndexOf( "\n" );
|
||||
if( i <= 0 )
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
|
||||
{
|
||||
sb.replace( i, i + 1, "\n" );
|
||||
}
|
||||
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,85 +1,70 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class GuiCustomSlot extends AbstractGui implements ITooltip {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int id;
|
||||
|
||||
public abstract class GuiCustomSlot extends AbstractGui implements ITooltip
|
||||
{
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int id;
|
||||
public GuiCustomSlot(final int id, final int x, final int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public GuiCustomSlot( final int id, final int x, final int y )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.id = id;
|
||||
}
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
public boolean canClick(final PlayerEntity player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canClick( final PlayerEntity player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public void slotClicked(final ItemStack clickStack, final int mouseButton) {
|
||||
}
|
||||
|
||||
public void slotClicked( final ItemStack clickStack, final int mouseButton )
|
||||
{
|
||||
}
|
||||
public abstract void drawContent(final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks);
|
||||
|
||||
public abstract void drawContent( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks );
|
||||
public void drawBackground(int guileft, int guitop, int currentZIndex) {
|
||||
}
|
||||
|
||||
public void drawBackground( int guileft, int guitop, int currentZIndex )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public boolean isSlotEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
@@ -29,128 +31,108 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
public abstract class GuiIconButton extends Button implements ITooltip {
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2",
|
||||
"textures/guis/states.png");
|
||||
|
||||
public abstract class GuiIconButton extends Button implements ITooltip
|
||||
{
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private boolean halfSize = false;
|
||||
|
||||
private boolean halfSize = false;
|
||||
public GuiIconButton(final int x, final int y, IPressable onPress) {
|
||||
super(x, y, 16, 16, "", onPress);
|
||||
}
|
||||
|
||||
public GuiIconButton(final int x, final int y, IPressable onPress )
|
||||
{
|
||||
super( x, y, 16, 16, "", onPress );
|
||||
}
|
||||
public void setVisibility(final boolean vis) {
|
||||
this.visible = vis;
|
||||
this.active = vis;
|
||||
}
|
||||
|
||||
public void setVisibility( final boolean vis )
|
||||
{
|
||||
this.visible = vis;
|
||||
this.active = vis;
|
||||
}
|
||||
@Override
|
||||
public void renderButton(final int mouseX, final int mouseY, float partial) {
|
||||
|
||||
@Override
|
||||
public void renderButton(final int mouseX, final int mouseY, float partial) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
if (this.visible) {
|
||||
final int iconIndex = this.getIconIndex();
|
||||
|
||||
if( this.visible )
|
||||
{
|
||||
final int iconIndex = this.getIconIndex();
|
||||
TextureManager textureManager = minecraft.getTextureManager();
|
||||
textureManager.bindTexture(TEXTURE_STATES);
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.enableBlend(); // FIXME: This should be the _default_ state, but some vanilla widget disables
|
||||
// it :|
|
||||
if (this.halfSize) {
|
||||
this.width = 8;
|
||||
this.height = 8;
|
||||
|
||||
TextureManager textureManager = minecraft.getTextureManager();
|
||||
textureManager.bindTexture(TEXTURE_STATES);
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.enableBlend(); // FIXME: This should be the _default_ state, but some vanilla widget disables it :|
|
||||
if( this.halfSize )
|
||||
{
|
||||
this.width = 8;
|
||||
this.height = 8;
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef(this.x, this.y, 0.0F);
|
||||
RenderSystem.scalef(0.5f, 0.5f, 0.5f);
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef( this.x, this.y, 0.0F );
|
||||
RenderSystem.scalef( 0.5f, 0.5f, 0.5f );
|
||||
if (this.active) {
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
} else {
|
||||
RenderSystem.color4f(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
if( this.active )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
}
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
GuiUtils.drawTexturedModalRect(0, 0, 256 - 16, 256 - 16, 16, 16, 0);
|
||||
GuiUtils.drawTexturedModalRect(0, 0, uv_x * 16, uv_y * 16, 16, 16, 0);
|
||||
RenderSystem.popMatrix();
|
||||
} else {
|
||||
if (this.active) {
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
} else {
|
||||
RenderSystem.color4f(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
GuiUtils.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( this.active )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
}
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0);
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0);
|
||||
}
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
}
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
protected abstract int getIconIndex();
|
||||
|
||||
protected abstract int getIconIndex();
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return this.visible;
|
||||
}
|
||||
public boolean isHalfSize() {
|
||||
return this.halfSize;
|
||||
}
|
||||
|
||||
public boolean isHalfSize()
|
||||
{
|
||||
return this.halfSize;
|
||||
}
|
||||
|
||||
public void setHalfSize( final boolean halfSize )
|
||||
{
|
||||
this.halfSize = halfSize;
|
||||
}
|
||||
public void setHalfSize(final boolean halfSize) {
|
||||
this.halfSize = halfSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,46 +18,35 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
|
||||
// FIXME: Fix this piece of crap (i.e. onChange listener)
|
||||
public class GuiNumberBox extends TextFieldWidget
|
||||
{
|
||||
public class GuiNumberBox extends TextFieldWidget {
|
||||
|
||||
private final Class type;
|
||||
private final Class type;
|
||||
|
||||
public GuiNumberBox( final FontRenderer fontRenderer, final int x, final int y, final int width, final int height, final Class type )
|
||||
{
|
||||
super( fontRenderer, x, y, width, height, "0" );
|
||||
this.type = type;
|
||||
}
|
||||
public GuiNumberBox(final FontRenderer fontRenderer, final int x, final int y, final int width, final int height,
|
||||
final Class type) {
|
||||
super(fontRenderer, x, y, width, height, "0");
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeText( final String selectedText )
|
||||
{
|
||||
final String original = this.getText();
|
||||
super.writeText( selectedText );
|
||||
@Override
|
||||
public void writeText(final String selectedText) {
|
||||
final String original = this.getText();
|
||||
super.writeText(selectedText);
|
||||
|
||||
try
|
||||
{
|
||||
if( this.type == int.class || this.type == Integer.class )
|
||||
{
|
||||
Integer.parseInt( this.getText() );
|
||||
}
|
||||
else if( this.type == long.class || this.type == Long.class )
|
||||
{
|
||||
Long.parseLong( this.getText() );
|
||||
}
|
||||
else if( this.type == double.class || this.type == Double.class )
|
||||
{
|
||||
Double.parseDouble( this.getText() );
|
||||
}
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
this.setText( original );
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (this.type == int.class || this.type == Integer.class) {
|
||||
Integer.parseInt(this.getText());
|
||||
} else if (this.type == long.class || this.type == Long.class) {
|
||||
Long.parseLong(this.getText());
|
||||
} else if (this.type == double.class || this.type == Double.class) {
|
||||
Double.parseDouble(this.getText());
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
this.setText(original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,115 +18,100 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.container.interfaces.IProgressProvider;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiProgressBar extends Widget implements ITooltip {
|
||||
|
||||
public class GuiProgressBar extends Widget implements ITooltip
|
||||
{
|
||||
private final IProgressProvider source;
|
||||
private final ResourceLocation texture;
|
||||
private final int fill_u;
|
||||
private final int fill_v;
|
||||
private final Direction layout;
|
||||
private final String titleName;
|
||||
private String fullMsg;
|
||||
|
||||
private final IProgressProvider source;
|
||||
private final ResourceLocation texture;
|
||||
private final int fill_u;
|
||||
private final int fill_v;
|
||||
private final Direction layout;
|
||||
private final String titleName;
|
||||
private String fullMsg;
|
||||
public GuiProgressBar(final IProgressProvider source, final String texture, final int posX, final int posY,
|
||||
final int u, final int y, final int width, final int height, final Direction dir) {
|
||||
this(source, texture, posX, posY, u, y, width, height, dir, null);
|
||||
}
|
||||
|
||||
public GuiProgressBar( final IProgressProvider source, final String texture, final int posX, final int posY, final int u, final int y, final int width, final int height, final Direction dir )
|
||||
{
|
||||
this( source, texture, posX, posY, u, y, width, height, dir, null );
|
||||
}
|
||||
public GuiProgressBar(final IProgressProvider source, final String texture, final int posX, final int posY,
|
||||
final int u, final int y, final int width, final int height, final Direction dir, final String title) {
|
||||
super(posX, posY, width, height, "");
|
||||
this.source = source;
|
||||
this.texture = new ResourceLocation("appliedenergistics2", "textures/" + texture);
|
||||
this.fill_u = u;
|
||||
this.fill_v = y;
|
||||
this.layout = dir;
|
||||
this.titleName = title;
|
||||
}
|
||||
|
||||
public GuiProgressBar( final IProgressProvider source, final String texture, final int posX, final int posY, final int u, final int y, final int width, final int height, final Direction dir, final String title )
|
||||
{
|
||||
super( posX, posY, width, height, "" );
|
||||
this.source = source;
|
||||
this.texture = new ResourceLocation( "appliedenergistics2", "textures/" + texture );
|
||||
this.fill_u = u;
|
||||
this.fill_v = y;
|
||||
this.layout = dir;
|
||||
this.titleName = title;
|
||||
}
|
||||
@Override
|
||||
public void renderButton(final int par2, final int par3, final float partial) {
|
||||
if (this.visible) {
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(this.texture);
|
||||
final int max = this.source.getMaxProgress();
|
||||
final int current = this.source.getCurrentProgress();
|
||||
|
||||
@Override
|
||||
public void renderButton( final int par2, final int par3, final float partial )
|
||||
{
|
||||
if( this.visible )
|
||||
{
|
||||
Minecraft.getInstance().getTextureManager().bindTexture( this.texture );
|
||||
final int max = this.source.getMaxProgress();
|
||||
final int current = this.source.getCurrentProgress();
|
||||
if (this.layout == Direction.VERTICAL) {
|
||||
final int diff = this.height - (max > 0 ? (this.height * current) / max : 0);
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width,
|
||||
this.height - diff, 0);
|
||||
} else {
|
||||
final int diff = this.width - (max > 0 ? (this.width * current) / max : 0);
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff,
|
||||
this.height, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.layout == Direction.VERTICAL )
|
||||
{
|
||||
final int diff = this.height - ( max > 0 ? ( this.height * current ) / max : 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width, this.height - diff, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
final int diff = this.width - ( max > 0 ? ( this.width * current ) / max : 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff, this.height, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setFullMsg(final String msg) {
|
||||
this.fullMsg = msg;
|
||||
}
|
||||
|
||||
public void setFullMsg( final String msg )
|
||||
{
|
||||
this.fullMsg = msg;
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
if (this.fullMsg != null) {
|
||||
return this.fullMsg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
if( this.fullMsg != null )
|
||||
{
|
||||
return this.fullMsg;
|
||||
}
|
||||
return (this.titleName != null ? this.titleName : "") + '\n' + this.source.getCurrentProgress() + ' '
|
||||
+ GuiText.Of.getLocal() + ' ' + this.source.getMaxProgress();
|
||||
}
|
||||
|
||||
return ( this.titleName != null ? this.titleName : "" ) + '\n' + this.source.getCurrentProgress() + ' ' + GuiText.Of.getLocal() + ' ' + this.source
|
||||
.getMaxProgress();
|
||||
}
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x - 2;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y - 2;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return this.width + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return this.width + 4;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return this.height + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return this.height + 4;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public enum Direction
|
||||
{
|
||||
HORIZONTAL, VERTICAL
|
||||
}
|
||||
public enum Direction {
|
||||
HORIZONTAL, VERTICAL
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,139 +18,117 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
|
||||
public class GuiScrollbar implements IScrollSource
|
||||
{
|
||||
public class GuiScrollbar implements IScrollSource {
|
||||
|
||||
private int displayX = 0;
|
||||
private int displayY = 0;
|
||||
private int width = 12;
|
||||
private int height = 16;
|
||||
private int pageSize = 1;
|
||||
private int displayX = 0;
|
||||
private int displayY = 0;
|
||||
private int width = 12;
|
||||
private int height = 16;
|
||||
private int pageSize = 1;
|
||||
|
||||
private int maxScroll = 0;
|
||||
private int minScroll = 0;
|
||||
private int currentScroll = 0;
|
||||
private int maxScroll = 0;
|
||||
private int minScroll = 0;
|
||||
private int currentScroll = 0;
|
||||
|
||||
public void draw( final AEBaseGui g )
|
||||
{
|
||||
g.bindTexture( "minecraft", "gui/container/creative_inventory/tabs.png" );
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
public void draw(final AEBaseGui g) {
|
||||
g.bindTexture("minecraft", "gui/container/creative_inventory/tabs.png");
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if( this.getRange() == 0 )
|
||||
{
|
||||
GuiUtils.drawTexturedModalRect( this.displayX, this.displayY, 232 + this.width, 0, this.width, 15, 0 /* FIXME: this used the GUI's zIndex before */ );
|
||||
}
|
||||
else
|
||||
{
|
||||
final int offset = ( this.currentScroll - this.minScroll ) * ( this.height - 15 ) / this.getRange();
|
||||
GuiUtils.drawTexturedModalRect( this.displayX, offset + this.displayY, 232, 0, this.width, 15, 0 /* FIXME: this used the GUI's zIndex before */ );
|
||||
}
|
||||
}
|
||||
if (this.getRange() == 0) {
|
||||
GuiUtils.drawTexturedModalRect(this.displayX, this.displayY, 232 + this.width, 0, this.width, 15,
|
||||
0 /* FIXME: this used the GUI's zIndex before */ );
|
||||
} else {
|
||||
final int offset = (this.currentScroll - this.minScroll) * (this.height - 15) / this.getRange();
|
||||
GuiUtils.drawTexturedModalRect(this.displayX, offset + this.displayY, 232, 0, this.width, 15,
|
||||
0 /* FIXME: this used the GUI's zIndex before */ );
|
||||
}
|
||||
}
|
||||
|
||||
private int getRange()
|
||||
{
|
||||
return this.maxScroll - this.minScroll;
|
||||
}
|
||||
private int getRange() {
|
||||
return this.maxScroll - this.minScroll;
|
||||
}
|
||||
|
||||
public int getLeft()
|
||||
{
|
||||
return this.displayX;
|
||||
}
|
||||
public int getLeft() {
|
||||
return this.displayX;
|
||||
}
|
||||
|
||||
public GuiScrollbar setLeft( final int v )
|
||||
{
|
||||
this.displayX = v;
|
||||
return this;
|
||||
}
|
||||
public GuiScrollbar setLeft(final int v) {
|
||||
this.displayX = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTop()
|
||||
{
|
||||
return this.displayY;
|
||||
}
|
||||
public int getTop() {
|
||||
return this.displayY;
|
||||
}
|
||||
|
||||
public GuiScrollbar setTop( final int v )
|
||||
{
|
||||
this.displayY = v;
|
||||
return this;
|
||||
}
|
||||
public GuiScrollbar setTop(final int v) {
|
||||
this.displayY = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return this.width;
|
||||
}
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public GuiScrollbar setWidth( final int v )
|
||||
{
|
||||
this.width = v;
|
||||
return this;
|
||||
}
|
||||
public GuiScrollbar setWidth(final int v) {
|
||||
this.width = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return this.height;
|
||||
}
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public GuiScrollbar setHeight( final int v )
|
||||
{
|
||||
this.height = v;
|
||||
return this;
|
||||
}
|
||||
public GuiScrollbar setHeight(final int v) {
|
||||
this.height = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setRange( final int min, final int max, final int pageSize )
|
||||
{
|
||||
this.minScroll = min;
|
||||
this.maxScroll = max;
|
||||
this.pageSize = pageSize;
|
||||
public void setRange(final int min, final int max, final int pageSize) {
|
||||
this.minScroll = min;
|
||||
this.maxScroll = max;
|
||||
this.pageSize = pageSize;
|
||||
|
||||
if( this.minScroll > this.maxScroll )
|
||||
{
|
||||
this.maxScroll = this.minScroll;
|
||||
}
|
||||
if (this.minScroll > this.maxScroll) {
|
||||
this.maxScroll = this.minScroll;
|
||||
}
|
||||
|
||||
this.applyRange();
|
||||
}
|
||||
this.applyRange();
|
||||
}
|
||||
|
||||
private void applyRange()
|
||||
{
|
||||
this.currentScroll = Math.max( Math.min( this.currentScroll, this.maxScroll ), this.minScroll );
|
||||
}
|
||||
private void applyRange() {
|
||||
this.currentScroll = Math.max(Math.min(this.currentScroll, this.maxScroll), this.minScroll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentScroll()
|
||||
{
|
||||
return this.currentScroll;
|
||||
}
|
||||
@Override
|
||||
public int getCurrentScroll() {
|
||||
return this.currentScroll;
|
||||
}
|
||||
|
||||
public void click(final double x, final double y)
|
||||
{
|
||||
if( this.getRange() == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
public void click(final double x, final double y) {
|
||||
if (this.getRange() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( x > this.displayX && x <= this.displayX + this.width )
|
||||
{
|
||||
if( y > this.displayY && y <= this.displayY + this.height )
|
||||
{
|
||||
this.currentScroll = (int) ( y - this.displayY );
|
||||
this.currentScroll = this.minScroll + ( ( this.currentScroll * 2 * this.getRange() / this.height ) );
|
||||
this.currentScroll = ( this.currentScroll + 1 ) >> 1;
|
||||
this.applyRange();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x > this.displayX && x <= this.displayX + this.width) {
|
||||
if (y > this.displayY && y <= this.displayY + this.height) {
|
||||
this.currentScroll = (int) (y - this.displayY);
|
||||
this.currentScroll = this.minScroll + ((this.currentScroll * 2 * this.getRange() / this.height));
|
||||
this.currentScroll = (this.currentScroll + 1) >> 1;
|
||||
this.applyRange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void wheel( double delta )
|
||||
{
|
||||
delta = Math.max( Math.min( -delta, 1 ), -1 );
|
||||
this.currentScroll += delta * this.pageSize;
|
||||
this.applyRange();
|
||||
}
|
||||
public void wheel(double delta) {
|
||||
delta = Math.max(Math.min(-delta, 1), -1);
|
||||
this.currentScroll += delta * this.pageSize;
|
||||
this.applyRange();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,32 +18,30 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Convenience button that automatically sends settings changes to the server.
|
||||
*/
|
||||
public class GuiServerSettingToggleButton<T extends Enum<T>> extends GuiSettingToggleButton<T>
|
||||
{
|
||||
public class GuiServerSettingToggleButton<T extends Enum<T>> extends GuiSettingToggleButton<T> {
|
||||
|
||||
public GuiServerSettingToggleButton(final int x, final int y, final Settings setting, final T val )
|
||||
{
|
||||
super( x, y, setting, val, GuiServerSettingToggleButton::sendToServer );
|
||||
}
|
||||
public GuiServerSettingToggleButton(final int x, final int y, final Settings setting, final T val) {
|
||||
super(x, y, setting, val, GuiServerSettingToggleButton::sendToServer);
|
||||
}
|
||||
|
||||
private static <T extends Enum<T>> void sendToServer(GuiSettingToggleButton<T> button, boolean backwards) {
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( button.getSetting(), backwards ) );
|
||||
}
|
||||
private static <T extends Enum<T>> void sendToServer(GuiSettingToggleButton<T> button, boolean backwards) {
|
||||
NetworkHandler.instance().sendToServer(new PacketConfigButton(button.getSetting(), backwards));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,308 +18,328 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.util.EnumCycler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class GuiSettingToggleButton<T extends Enum<T>> extends GuiIconButton
|
||||
{
|
||||
private static final Pattern COMPILE = Pattern.compile( "%s" );
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
|
||||
private static Map<EnumPair, ButtonAppearance> appearances;
|
||||
private final Settings buttonSetting;
|
||||
private final IHandler<GuiSettingToggleButton<T>> onPress;
|
||||
private final EnumSet<T> validValues;
|
||||
private String fillVar;
|
||||
private T currentValue;
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.util.EnumCycler;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IHandler<T extends GuiSettingToggleButton<?>> {
|
||||
void handle(T button, boolean backwards);
|
||||
}
|
||||
public class GuiSettingToggleButton<T extends Enum<T>> extends GuiIconButton {
|
||||
private static final Pattern COMPILE = Pattern.compile("%s");
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
|
||||
private static Map<EnumPair, ButtonAppearance> appearances;
|
||||
private final Settings buttonSetting;
|
||||
private final IHandler<GuiSettingToggleButton<T>> onPress;
|
||||
private final EnumSet<T> validValues;
|
||||
private String fillVar;
|
||||
private T currentValue;
|
||||
|
||||
public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val, IHandler<GuiSettingToggleButton<T>> onPress )
|
||||
{
|
||||
this(x, y, setting, val, t -> true, onPress);
|
||||
}
|
||||
@FunctionalInterface
|
||||
public interface IHandler<T extends GuiSettingToggleButton<?>> {
|
||||
void handle(T button, boolean backwards);
|
||||
}
|
||||
|
||||
public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val, Predicate<T> isValidValue, IHandler<GuiSettingToggleButton<T>> onPress )
|
||||
{
|
||||
super( x, y, GuiSettingToggleButton::onPress );
|
||||
this.onPress = onPress;
|
||||
public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val,
|
||||
IHandler<GuiSettingToggleButton<T>> onPress) {
|
||||
this(x, y, setting, val, t -> true, onPress);
|
||||
}
|
||||
|
||||
// Build a list of values (in order) that are valid w.r.t. the given predicate
|
||||
EnumSet<T> validValues = EnumSet.allOf(val.getDeclaringClass());
|
||||
validValues.removeIf(isValidValue.negate());
|
||||
validValues.removeIf(s -> !setting.getPossibleValues().contains(s));
|
||||
this.validValues = validValues;
|
||||
public GuiSettingToggleButton(final int x, final int y, final Settings setting, final T val,
|
||||
Predicate<T> isValidValue, IHandler<GuiSettingToggleButton<T>> onPress) {
|
||||
super(x, y, GuiSettingToggleButton::onPress);
|
||||
this.onPress = onPress;
|
||||
|
||||
this.buttonSetting = setting;
|
||||
this.currentValue = val;
|
||||
// Build a list of values (in order) that are valid w.r.t. the given predicate
|
||||
EnumSet<T> validValues = EnumSet.allOf(val.getDeclaringClass());
|
||||
validValues.removeIf(isValidValue.negate());
|
||||
validValues.removeIf(s -> !setting.getPossibleValues().contains(s));
|
||||
this.validValues = validValues;
|
||||
|
||||
if( appearances == null )
|
||||
{
|
||||
appearances = new HashMap<>();
|
||||
registerApp( 16 * 7, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput, ButtonToolTips.Trash );
|
||||
registerApp( 16 * 7 + 1, Settings.CONDENSER_OUTPUT, CondenserOutput.MATTER_BALLS, ButtonToolTips.CondenserOutput, ButtonToolTips.MatterBalls );
|
||||
registerApp( 16 * 7 + 2, Settings.CONDENSER_OUTPUT, CondenserOutput.SINGULARITY, ButtonToolTips.CondenserOutput, ButtonToolTips.Singularity );
|
||||
this.buttonSetting = setting;
|
||||
this.currentValue = val;
|
||||
|
||||
registerApp( 16 * 9 + 1, Settings.ACCESS, AccessRestriction.READ, ButtonToolTips.IOMode, ButtonToolTips.Read );
|
||||
registerApp( 16 * 9, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write );
|
||||
registerApp( 16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode, ButtonToolTips.ReadWrite );
|
||||
if (appearances == null) {
|
||||
appearances = new HashMap<>();
|
||||
registerApp(16 * 7, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput,
|
||||
ButtonToolTips.Trash);
|
||||
registerApp(16 * 7 + 1, Settings.CONDENSER_OUTPUT, CondenserOutput.MATTER_BALLS,
|
||||
ButtonToolTips.CondenserOutput, ButtonToolTips.MatterBalls);
|
||||
registerApp(16 * 7 + 2, Settings.CONDENSER_OUTPUT, CondenserOutput.SINGULARITY,
|
||||
ButtonToolTips.CondenserOutput, ButtonToolTips.Singularity);
|
||||
|
||||
registerApp( 16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.textComponent() );
|
||||
registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.textComponent() );
|
||||
registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.textComponent() );
|
||||
registerApp(16 * 9 + 1, Settings.ACCESS, AccessRestriction.READ, ButtonToolTips.IOMode,
|
||||
ButtonToolTips.Read);
|
||||
registerApp(16 * 9, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write);
|
||||
registerApp(16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode,
|
||||
ButtonToolTips.ReadWrite);
|
||||
|
||||
registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive );
|
||||
registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal );
|
||||
registerApp( 1, Settings.REDSTONE_CONTROLLED, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithSignal );
|
||||
registerApp( 2, Settings.REDSTONE_CONTROLLED, RedstoneMode.SIGNAL_PULSE, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveOnPulse );
|
||||
registerApp(16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits,
|
||||
PowerUnits.AE.textComponent());
|
||||
registerApp(16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits,
|
||||
PowerUnits.EU.textComponent());
|
||||
registerApp(16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits,
|
||||
PowerUnits.RF.textComponent());
|
||||
|
||||
registerApp( 0, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelsBelow );
|
||||
registerApp( 1, Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelAbove );
|
||||
registerApp(3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.AlwaysActive);
|
||||
registerApp(0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.ActiveWithoutSignal);
|
||||
registerApp(1, Settings.REDSTONE_CONTROLLED, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.ActiveWithSignal);
|
||||
registerApp(2, Settings.REDSTONE_CONTROLLED, RedstoneMode.SIGNAL_PULSE, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.ActiveOnPulse);
|
||||
|
||||
registerApp( 51, Settings.OPERATION_MODE, OperationMode.FILL, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
|
||||
registerApp( 50, Settings.OPERATION_MODE, OperationMode.EMPTY, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
|
||||
registerApp(0, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.EmitLevelsBelow);
|
||||
registerApp(1, Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode,
|
||||
ButtonToolTips.EmitLevelAbove);
|
||||
|
||||
registerApp( 51, Settings.IO_DIRECTION, RelativeDirection.LEFT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
|
||||
registerApp( 50, Settings.IO_DIRECTION, RelativeDirection.RIGHT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
|
||||
registerApp(51, Settings.OPERATION_MODE, OperationMode.FILL, ButtonToolTips.TransferDirection,
|
||||
ButtonToolTips.TransferToStorageCell);
|
||||
registerApp(50, Settings.OPERATION_MODE, OperationMode.EMPTY, ButtonToolTips.TransferDirection,
|
||||
ButtonToolTips.TransferToNetwork);
|
||||
|
||||
registerApp( 48, Settings.SORT_DIRECTION, SortDir.ASCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
|
||||
registerApp( 49, Settings.SORT_DIRECTION, SortDir.DESCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
|
||||
registerApp(51, Settings.IO_DIRECTION, RelativeDirection.LEFT, ButtonToolTips.TransferDirection,
|
||||
ButtonToolTips.TransferToStorageCell);
|
||||
registerApp(50, Settings.IO_DIRECTION, RelativeDirection.RIGHT, ButtonToolTips.TransferDirection,
|
||||
ButtonToolTips.TransferToNetwork);
|
||||
|
||||
registerApp( 16 * 2 + 3, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Auto );
|
||||
registerApp( 16 * 2 + 4, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Standard );
|
||||
registerApp( 16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIAuto );
|
||||
registerApp( 16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIStandard );
|
||||
registerApp( 16 * 2 + 7, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_AutoKeep );
|
||||
registerApp( 16 * 2 + 8, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_StandardKeep );
|
||||
registerApp( 16 * 2 + 9, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIAutoKeep );
|
||||
registerApp( 16 * 2 + 10, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIStandardKeep );
|
||||
registerApp(48, Settings.SORT_DIRECTION, SortDir.ASCENDING, ButtonToolTips.SortOrder,
|
||||
ButtonToolTips.ToggleSortDirection);
|
||||
registerApp(49, Settings.SORT_DIRECTION, SortDir.DESCENDING, ButtonToolTips.SortOrder,
|
||||
ButtonToolTips.ToggleSortDirection);
|
||||
|
||||
registerApp( 16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Energy );
|
||||
registerApp( 16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Item );
|
||||
registerApp(16 * 2 + 3, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_Auto);
|
||||
registerApp(16 * 2 + 4, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_Standard);
|
||||
registerApp(16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIAuto);
|
||||
registerApp(16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIStandard);
|
||||
registerApp(16 * 2 + 7, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_AutoKeep);
|
||||
registerApp(16 * 2 + 8, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_StandardKeep);
|
||||
registerApp(16 * 2 + 9, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH_KEEP, ButtonToolTips.SearchMode,
|
||||
ButtonToolTips.SearchMode_JEIAutoKeep);
|
||||
registerApp(16 * 2 + 10, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH_KEEP,
|
||||
ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIStandardKeep);
|
||||
|
||||
registerApp( 16 * 13, Settings.TERMINAL_STYLE, TerminalStyle.TALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Tall );
|
||||
registerApp( 16 * 13 + 1, Settings.TERMINAL_STYLE, TerminalStyle.SMALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Small );
|
||||
registerApp( 16 * 13 + 2, Settings.TERMINAL_STYLE, TerminalStyle.FULL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Full );
|
||||
registerApp(16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType,
|
||||
ButtonToolTips.LevelType_Energy);
|
||||
registerApp(16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType,
|
||||
ButtonToolTips.LevelType_Item);
|
||||
|
||||
registerApp( 64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName );
|
||||
registerApp( 65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems );
|
||||
registerApp( 68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy, ButtonToolTips.InventoryTweaks );
|
||||
registerApp( 69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod );
|
||||
registerApp(16 * 13, Settings.TERMINAL_STYLE, TerminalStyle.TALL, ButtonToolTips.TerminalStyle,
|
||||
ButtonToolTips.TerminalStyle_Tall);
|
||||
registerApp(16 * 13 + 1, Settings.TERMINAL_STYLE, TerminalStyle.SMALL, ButtonToolTips.TerminalStyle,
|
||||
ButtonToolTips.TerminalStyle_Small);
|
||||
registerApp(16 * 13 + 2, Settings.TERMINAL_STYLE, TerminalStyle.FULL, ButtonToolTips.TerminalStyle,
|
||||
ButtonToolTips.TerminalStyle_Full);
|
||||
|
||||
registerApp( 16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems );
|
||||
registerApp( 18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable );
|
||||
registerApp( 19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable );
|
||||
registerApp(64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName);
|
||||
registerApp(65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems);
|
||||
registerApp(68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy,
|
||||
ButtonToolTips.InventoryTweaks);
|
||||
registerApp(69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod);
|
||||
|
||||
registerApp( 16 * 6, Settings.FUZZY_MODE, FuzzyMode.PERCENT_25, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_25 );
|
||||
registerApp( 16 * 6 + 1, Settings.FUZZY_MODE, FuzzyMode.PERCENT_50, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_50 );
|
||||
registerApp( 16 * 6 + 2, Settings.FUZZY_MODE, FuzzyMode.PERCENT_75, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_75 );
|
||||
registerApp( 16 * 6 + 3, Settings.FUZZY_MODE, FuzzyMode.PERCENT_99, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_99 );
|
||||
registerApp( 16 * 6 + 4, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, ButtonToolTips.FuzzyMode, ButtonToolTips.FZIgnoreAll );
|
||||
registerApp(16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems);
|
||||
registerApp(18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable);
|
||||
registerApp(19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable);
|
||||
|
||||
registerApp( 80, Settings.FULLNESS_MODE, FullnessMode.EMPTY, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenEmpty );
|
||||
registerApp( 81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenWorkIsDone );
|
||||
registerApp( 82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenFull );
|
||||
registerApp(16 * 6, Settings.FUZZY_MODE, FuzzyMode.PERCENT_25, ButtonToolTips.FuzzyMode,
|
||||
ButtonToolTips.FZPercent_25);
|
||||
registerApp(16 * 6 + 1, Settings.FUZZY_MODE, FuzzyMode.PERCENT_50, ButtonToolTips.FuzzyMode,
|
||||
ButtonToolTips.FZPercent_50);
|
||||
registerApp(16 * 6 + 2, Settings.FUZZY_MODE, FuzzyMode.PERCENT_75, ButtonToolTips.FuzzyMode,
|
||||
ButtonToolTips.FZPercent_75);
|
||||
registerApp(16 * 6 + 3, Settings.FUZZY_MODE, FuzzyMode.PERCENT_99, ButtonToolTips.FuzzyMode,
|
||||
ButtonToolTips.FZPercent_99);
|
||||
registerApp(16 * 6 + 4, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, ButtonToolTips.FuzzyMode,
|
||||
ButtonToolTips.FZIgnoreAll);
|
||||
|
||||
registerApp( 16 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.Blocking );
|
||||
registerApp( 16 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.NonBlocking );
|
||||
registerApp(80, Settings.FULLNESS_MODE, FullnessMode.EMPTY, ButtonToolTips.OperationMode,
|
||||
ButtonToolTips.MoveWhenEmpty);
|
||||
registerApp(81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode,
|
||||
ButtonToolTips.MoveWhenWorkIsDone);
|
||||
registerApp(82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode,
|
||||
ButtonToolTips.MoveWhenFull);
|
||||
|
||||
registerApp( 16 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly );
|
||||
registerApp( 16 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither );
|
||||
registerApp(16 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode,
|
||||
ButtonToolTips.Blocking);
|
||||
registerApp(16 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode,
|
||||
ButtonToolTips.NonBlocking);
|
||||
|
||||
registerApp( 16 * 11 + 2, Settings.CRAFT_VIA_REDSTONE, YesNo.YES, ButtonToolTips.EmitterMode, ButtonToolTips.CraftViaRedstone );
|
||||
registerApp( 16 * 11 + 1, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, ButtonToolTips.EmitterMode, ButtonToolTips.EmitWhenCrafting );
|
||||
registerApp(16 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly);
|
||||
registerApp(16 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither);
|
||||
|
||||
registerApp( 16 * 3 + 5, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, ButtonToolTips.ReportInaccessibleItems,
|
||||
ButtonToolTips.ReportInaccessibleItemsNo );
|
||||
registerApp( 16 * 3 + 6, Settings.STORAGE_FILTER, StorageFilter.NONE, ButtonToolTips.ReportInaccessibleItems,
|
||||
ButtonToolTips.ReportInaccessibleItemsYes );
|
||||
registerApp(16 * 11 + 2, Settings.CRAFT_VIA_REDSTONE, YesNo.YES, ButtonToolTips.EmitterMode,
|
||||
ButtonToolTips.CraftViaRedstone);
|
||||
registerApp(16 * 11 + 1, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, ButtonToolTips.EmitterMode,
|
||||
ButtonToolTips.EmitWhenCrafting);
|
||||
|
||||
registerApp( 16 * 14, Settings.PLACE_BLOCK, YesNo.YES, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementYes );
|
||||
registerApp( 16 * 14 + 1, Settings.PLACE_BLOCK, YesNo.NO, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementNo );
|
||||
registerApp(16 * 3 + 5, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY,
|
||||
ButtonToolTips.ReportInaccessibleItems, ButtonToolTips.ReportInaccessibleItemsNo);
|
||||
registerApp(16 * 3 + 6, Settings.STORAGE_FILTER, StorageFilter.NONE, ButtonToolTips.ReportInaccessibleItems,
|
||||
ButtonToolTips.ReportInaccessibleItemsYes);
|
||||
|
||||
registerApp( 16 * 15, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeDefault );
|
||||
registerApp( 16 * 15 + 1, Settings.SCHEDULING_MODE, SchedulingMode.ROUNDROBIN, ButtonToolTips.SchedulingMode,
|
||||
ButtonToolTips.SchedulingModeRoundRobin );
|
||||
registerApp( 16 * 15 + 2, Settings.SCHEDULING_MODE, SchedulingMode.RANDOM, ButtonToolTips.SchedulingMode,
|
||||
ButtonToolTips.SchedulingModeRandom );
|
||||
}
|
||||
}
|
||||
registerApp(16 * 14, Settings.PLACE_BLOCK, YesNo.YES, ButtonToolTips.BlockPlacement,
|
||||
ButtonToolTips.BlockPlacementYes);
|
||||
registerApp(16 * 14 + 1, Settings.PLACE_BLOCK, YesNo.NO, ButtonToolTips.BlockPlacement,
|
||||
ButtonToolTips.BlockPlacementNo);
|
||||
|
||||
private static void onPress(Button btn) {
|
||||
if (btn instanceof GuiSettingToggleButton) {
|
||||
((GuiSettingToggleButton<?>) btn).triggerPress();
|
||||
}
|
||||
}
|
||||
registerApp(16 * 15, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, ButtonToolTips.SchedulingMode,
|
||||
ButtonToolTips.SchedulingModeDefault);
|
||||
registerApp(16 * 15 + 1, Settings.SCHEDULING_MODE, SchedulingMode.ROUNDROBIN, ButtonToolTips.SchedulingMode,
|
||||
ButtonToolTips.SchedulingModeRoundRobin);
|
||||
registerApp(16 * 15 + 2, Settings.SCHEDULING_MODE, SchedulingMode.RANDOM, ButtonToolTips.SchedulingMode,
|
||||
ButtonToolTips.SchedulingModeRandom);
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerPress() {
|
||||
boolean backwards = Minecraft.getInstance().mouseHelper.isRightDown();
|
||||
onPress.handle(this, backwards);
|
||||
}
|
||||
private static void onPress(Button btn) {
|
||||
if (btn instanceof GuiSettingToggleButton) {
|
||||
((GuiSettingToggleButton<?>) btn).triggerPress();
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerApp( final int iconIndex, final Settings setting, final Enum<?> val, final ButtonToolTips title, final ITextComponent hint )
|
||||
{
|
||||
final ButtonAppearance a = new ButtonAppearance();
|
||||
a.displayName = title.getTranslationKey();
|
||||
a.displayValue = hint;
|
||||
a.index = iconIndex;
|
||||
appearances.put( new EnumPair( setting, val ), a );
|
||||
}
|
||||
private void triggerPress() {
|
||||
boolean backwards = Minecraft.getInstance().mouseHelper.isRightDown();
|
||||
onPress.handle(this, backwards);
|
||||
}
|
||||
|
||||
private static void registerApp( final int iconIndex, final Settings setting, final Enum<?> val, final ButtonToolTips title, final ButtonToolTips hint )
|
||||
{
|
||||
registerApp(iconIndex, setting, val, title, hint.getTranslationKey());
|
||||
}
|
||||
private static void registerApp(final int iconIndex, final Settings setting, final Enum<?> val,
|
||||
final ButtonToolTips title, final ITextComponent hint) {
|
||||
final ButtonAppearance a = new ButtonAppearance();
|
||||
a.displayName = title.getTranslationKey();
|
||||
a.displayValue = hint;
|
||||
a.index = iconIndex;
|
||||
appearances.put(new EnumPair(setting, val), a);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIconIndex()
|
||||
{
|
||||
if( this.buttonSetting != null && this.currentValue != null )
|
||||
{
|
||||
final ButtonAppearance app = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) );
|
||||
if( app == null )
|
||||
{
|
||||
return 256 - 1;
|
||||
}
|
||||
return app.index;
|
||||
}
|
||||
return 256 - 1;
|
||||
}
|
||||
private static void registerApp(final int iconIndex, final Settings setting, final Enum<?> val,
|
||||
final ButtonToolTips title, final ButtonToolTips hint) {
|
||||
registerApp(iconIndex, setting, val, title, hint.getTranslationKey());
|
||||
}
|
||||
|
||||
public Settings getSetting()
|
||||
{
|
||||
return this.buttonSetting;
|
||||
}
|
||||
@Override
|
||||
protected int getIconIndex() {
|
||||
if (this.buttonSetting != null && this.currentValue != null) {
|
||||
final ButtonAppearance app = appearances.get(new EnumPair(this.buttonSetting, this.currentValue));
|
||||
if (app == null) {
|
||||
return 256 - 1;
|
||||
}
|
||||
return app.index;
|
||||
}
|
||||
return 256 - 1;
|
||||
}
|
||||
|
||||
public T getCurrentValue()
|
||||
{
|
||||
return this.currentValue;
|
||||
}
|
||||
public Settings getSetting() {
|
||||
return this.buttonSetting;
|
||||
}
|
||||
|
||||
public void set( final T e )
|
||||
{
|
||||
if( this.currentValue != e )
|
||||
{
|
||||
this.currentValue = e;
|
||||
}
|
||||
}
|
||||
public T getCurrentValue() {
|
||||
return this.currentValue;
|
||||
}
|
||||
|
||||
public T getNextValue(boolean backwards) {
|
||||
return EnumCycler.rotateEnum(currentValue, backwards, validValues);
|
||||
}
|
||||
public void set(final T e) {
|
||||
if (this.currentValue != e) {
|
||||
this.currentValue = e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
ITextComponent displayName = null;
|
||||
ITextComponent displayValue = null;
|
||||
public T getNextValue(boolean backwards) {
|
||||
return EnumCycler.rotateEnum(currentValue, backwards, validValues);
|
||||
}
|
||||
|
||||
if( this.buttonSetting != null && this.currentValue != null )
|
||||
{
|
||||
final ButtonAppearance buttonAppearance = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) );
|
||||
if( buttonAppearance == null )
|
||||
{
|
||||
return "No Such Message";
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
ITextComponent displayName = null;
|
||||
ITextComponent displayValue = null;
|
||||
|
||||
displayName = buttonAppearance.displayName;
|
||||
displayValue = buttonAppearance.displayValue;
|
||||
}
|
||||
if (this.buttonSetting != null && this.currentValue != null) {
|
||||
final ButtonAppearance buttonAppearance = appearances
|
||||
.get(new EnumPair(this.buttonSetting, this.currentValue));
|
||||
if (buttonAppearance == null) {
|
||||
return "No Such Message";
|
||||
}
|
||||
|
||||
if( displayName != null )
|
||||
{
|
||||
String name = displayName.getString();
|
||||
String value = displayValue.getString();
|
||||
displayName = buttonAppearance.displayName;
|
||||
displayValue = buttonAppearance.displayValue;
|
||||
}
|
||||
|
||||
if( this.fillVar != null )
|
||||
{
|
||||
value = COMPILE.matcher( value ).replaceFirst( this.fillVar );
|
||||
}
|
||||
if (displayName != null) {
|
||||
String name = displayName.getString();
|
||||
String value = displayValue.getString();
|
||||
|
||||
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
|
||||
final StringBuilder sb = new StringBuilder( value );
|
||||
if (this.fillVar != null) {
|
||||
value = COMPILE.matcher(value).replaceFirst(this.fillVar);
|
||||
}
|
||||
|
||||
int i = sb.lastIndexOf( "\n" );
|
||||
if( i <= 0 )
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
|
||||
{
|
||||
sb.replace( i, i + 1, "\n" );
|
||||
}
|
||||
value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n");
|
||||
final StringBuilder sb = new StringBuilder(value);
|
||||
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
int i = sb.lastIndexOf("\n");
|
||||
if (i <= 0) {
|
||||
i = 0;
|
||||
}
|
||||
while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) {
|
||||
sb.replace(i, i + 1, "\n");
|
||||
}
|
||||
|
||||
public String getFillVar()
|
||||
{
|
||||
return this.fillVar;
|
||||
}
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setFillVar( final String fillVar )
|
||||
{
|
||||
this.fillVar = fillVar;
|
||||
}
|
||||
public String getFillVar() {
|
||||
return this.fillVar;
|
||||
}
|
||||
|
||||
private static final class EnumPair
|
||||
{
|
||||
public void setFillVar(final String fillVar) {
|
||||
this.fillVar = fillVar;
|
||||
}
|
||||
|
||||
final Settings setting;
|
||||
final Enum<?> value;
|
||||
private static final class EnumPair {
|
||||
|
||||
EnumPair( final Settings a, final Enum<?> b )
|
||||
{
|
||||
this.setting = a;
|
||||
this.value = b;
|
||||
}
|
||||
final Settings setting;
|
||||
final Enum<?> value;
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return this.setting.hashCode() ^ this.value.hashCode();
|
||||
}
|
||||
EnumPair(final Settings a, final Enum<?> b) {
|
||||
this.setting = a;
|
||||
this.value = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( final Object obj )
|
||||
{
|
||||
if( obj == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( this.getClass() != obj.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final EnumPair other = (EnumPair) obj;
|
||||
return other.setting == this.setting && other.value == this.value;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.setting.hashCode() ^ this.value.hashCode();
|
||||
}
|
||||
|
||||
private static class ButtonAppearance
|
||||
{
|
||||
public int index;
|
||||
public ITextComponent displayName;
|
||||
public ITextComponent displayValue;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final EnumPair other = (EnumPair) obj;
|
||||
return other.setting == this.setting && other.value == this.value;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ButtonAppearance {
|
||||
public int index;
|
||||
public ITextComponent displayName;
|
||||
public ITextComponent displayValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
@@ -30,117 +30,105 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiTabButton extends Button implements ITooltip {
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2",
|
||||
"textures/guis/states.png");
|
||||
private final ItemRenderer itemRenderer;
|
||||
private int hideEdge = 0;
|
||||
private int myIcon = -1;
|
||||
private ItemStack myItem;
|
||||
|
||||
public class GuiTabButton extends Button implements ITooltip
|
||||
{
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private final ItemRenderer itemRenderer;
|
||||
private int hideEdge = 0;
|
||||
private int myIcon = -1;
|
||||
private ItemStack myItem;
|
||||
public GuiTabButton(final int x, final int y, final int ico, final String message, final ItemRenderer ir,
|
||||
IPressable onPress) {
|
||||
super(x, y, 22, 22, message, onPress);
|
||||
|
||||
public GuiTabButton( final int x, final int y, final int ico, final String message, final ItemRenderer ir, IPressable onPress )
|
||||
{
|
||||
super( x, y, 22, 22, message, onPress );
|
||||
this.myIcon = ico;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
this.myIcon = ico;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
/**
|
||||
* Using itemstack as an icon
|
||||
*
|
||||
* @param x x pos of button
|
||||
* @param y y pos of button
|
||||
* @param ico used icon
|
||||
* @param message mouse over message
|
||||
* @param ir renderer
|
||||
*/
|
||||
public GuiTabButton(final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir,
|
||||
IPressable onPress) {
|
||||
super(x, y, 22, 22, message, onPress);
|
||||
this.myItem = ico;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Using itemstack as an icon
|
||||
*
|
||||
* @param x x pos of button
|
||||
* @param y y pos of button
|
||||
* @param ico used icon
|
||||
* @param message mouse over message
|
||||
* @param ir renderer
|
||||
*/
|
||||
public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir, IPressable onPress )
|
||||
{
|
||||
super( x, y, 22, 22, message, onPress );
|
||||
this.myItem = ico;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
@Override
|
||||
public void renderButton(final int x, final int y, float partial) {
|
||||
final Minecraft minecraft = Minecraft.getInstance();
|
||||
|
||||
@Override
|
||||
public void renderButton( final int x, final int y, float partial )
|
||||
{
|
||||
final Minecraft minecraft = Minecraft.getInstance();
|
||||
if (this.visible) {
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
minecraft.textureManager.bindTexture(TEXTURE_STATES);
|
||||
|
||||
if( this.visible )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
minecraft.textureManager.bindTexture(TEXTURE_STATES);
|
||||
RenderSystem.enableAlphaTest();
|
||||
|
||||
RenderSystem.enableAlphaTest();
|
||||
int uv_x = (this.hideEdge > 0 ? 11 : 13);
|
||||
|
||||
int uv_x = ( this.hideEdge > 0 ? 11 : 13 );
|
||||
final int offsetX = this.hideEdge > 0 ? 1 : 0;
|
||||
|
||||
final int offsetX = this.hideEdge > 0 ? 1 : 0;
|
||||
blit(this.x, this.y, uv_x * 16, 0, 25, 22);
|
||||
|
||||
blit( this.x, this.y, uv_x * 16, 0, 25, 22 );
|
||||
if (this.myIcon >= 0) {
|
||||
final int uv_y = this.myIcon / 16;
|
||||
uv_x = this.myIcon - uv_y * 16;
|
||||
|
||||
if( this.myIcon >= 0 )
|
||||
{
|
||||
final int uv_y = this.myIcon / 16;
|
||||
uv_x = this.myIcon - uv_y * 16;
|
||||
blit(offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16);
|
||||
}
|
||||
|
||||
blit( offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
}
|
||||
RenderSystem.disableAlphaTest();
|
||||
|
||||
RenderSystem.disableAlphaTest();
|
||||
if (this.myItem != null) {
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
|
||||
if( this.myItem != null )
|
||||
{
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
this.itemRenderer.renderItemAndEffectIntoGUI(this.myItem, offsetX + this.x + 3, this.y + 3);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
this.itemRenderer.renderItemAndEffectIntoGUI( this.myItem, offsetX + this.x + 3, this.y + 3 );
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return this.visible;
|
||||
}
|
||||
public int getHideEdge() {
|
||||
return this.hideEdge;
|
||||
}
|
||||
|
||||
public int getHideEdge()
|
||||
{
|
||||
return this.hideEdge;
|
||||
}
|
||||
|
||||
public void setHideEdge( final int hideEdge )
|
||||
{
|
||||
this.hideEdge = hideEdge;
|
||||
}
|
||||
public void setHideEdge(final int hideEdge) {
|
||||
this.hideEdge = hideEdge;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,128 +18,112 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
public class GuiToggleButton extends Button implements ITooltip {
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2",
|
||||
"textures/guis/states.png");
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
|
||||
private final int iconIdxOn;
|
||||
private final int iconIdxOff;
|
||||
|
||||
public class GuiToggleButton extends Button implements ITooltip
|
||||
{
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
|
||||
private final int iconIdxOn;
|
||||
private final int iconIdxOff;
|
||||
private final String displayName;
|
||||
private final String displayHint;
|
||||
|
||||
private final String displayName;
|
||||
private final String displayHint;
|
||||
private boolean isActive;
|
||||
|
||||
private boolean isActive;
|
||||
public GuiToggleButton(final int x, final int y, final int on, final int off, final String displayName,
|
||||
final String displayHint, IPressable onPress) {
|
||||
super(x, y, 16, 16, "", onPress);
|
||||
this.iconIdxOn = on;
|
||||
this.iconIdxOff = off;
|
||||
this.displayName = displayName;
|
||||
this.displayHint = displayHint;
|
||||
}
|
||||
|
||||
public GuiToggleButton( final int x, final int y, final int on, final int off, final String displayName, final String displayHint, IPressable onPress )
|
||||
{
|
||||
super( x, y, 16, 16, "", onPress );
|
||||
this.iconIdxOn = on;
|
||||
this.iconIdxOff = off;
|
||||
this.displayName = displayName;
|
||||
this.displayHint = displayHint;
|
||||
}
|
||||
public void setState(final boolean isOn) {
|
||||
this.isActive = isOn;
|
||||
}
|
||||
|
||||
public void setState( final boolean isOn )
|
||||
{
|
||||
this.isActive = isOn;
|
||||
}
|
||||
@Override
|
||||
public void renderButton(final int mouseX, final int mouseY, final float partial) {
|
||||
if (this.visible) {
|
||||
final int iconIndex = this.getIconIndex();
|
||||
|
||||
@Override
|
||||
public void renderButton( final int mouseX, final int mouseY, final float partial )
|
||||
{
|
||||
if( this.visible )
|
||||
{
|
||||
final int iconIndex = this.getIconIndex();
|
||||
RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
Minecraft.getInstance().textureManager.bindTexture(TEXTURE_STATES);
|
||||
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
Minecraft.getInstance().textureManager.bindTexture( TEXTURE_STATES );
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
final int uv_y = iconIndex / 16;
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0);
|
||||
GuiUtils.drawTexturedModalRect(this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0);
|
||||
}
|
||||
}
|
||||
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
}
|
||||
}
|
||||
private int getIconIndex() {
|
||||
return this.isActive ? this.iconIdxOn : this.iconIdxOff;
|
||||
}
|
||||
|
||||
private int getIconIndex()
|
||||
{
|
||||
return this.isActive ? this.iconIdxOn : this.iconIdxOff;
|
||||
}
|
||||
@Override
|
||||
public String getMessage() {
|
||||
if (this.displayName != null) {
|
||||
String name = I18n.format(this.displayName);
|
||||
String value = I18n.format(this.displayHint);
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
if( this.displayName != null )
|
||||
{
|
||||
String name = I18n.format( this.displayName );
|
||||
String value = I18n.format( this.displayHint );
|
||||
if (name == null || name.isEmpty()) {
|
||||
name = this.displayName;
|
||||
}
|
||||
if (value == null || value.isEmpty()) {
|
||||
value = this.displayHint;
|
||||
}
|
||||
|
||||
if( name == null || name.isEmpty() )
|
||||
{
|
||||
name = this.displayName;
|
||||
}
|
||||
if( value == null || value.isEmpty() )
|
||||
{
|
||||
value = this.displayHint;
|
||||
}
|
||||
value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n");
|
||||
final StringBuilder sb = new StringBuilder(value);
|
||||
|
||||
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
|
||||
final StringBuilder sb = new StringBuilder( value );
|
||||
int i = sb.lastIndexOf("\n");
|
||||
if (i <= 0) {
|
||||
i = 0;
|
||||
}
|
||||
while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) {
|
||||
sb.replace(i, i + 1, "\n");
|
||||
}
|
||||
|
||||
int i = sb.lastIndexOf( "\n" );
|
||||
if( i <= 0 )
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
|
||||
{
|
||||
sb.replace( i, i + 1, "\n" );
|
||||
}
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return this.visible;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
public interface IScrollSource {
|
||||
|
||||
public interface IScrollSource
|
||||
{
|
||||
|
||||
int getCurrentScroll();
|
||||
int getCurrentScroll();
|
||||
}
|
||||
|
||||
@@ -18,15 +18,14 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
|
||||
public interface ISortSource {
|
||||
SortOrder getSortBy();
|
||||
|
||||
public interface ISortSource
|
||||
{
|
||||
SortOrder getSortBy();
|
||||
SortDir getSortDir();
|
||||
ViewItems getSortDisplay();
|
||||
SortDir getSortDir();
|
||||
|
||||
ViewItems getSortDisplay();
|
||||
}
|
||||
|
||||
@@ -18,50 +18,48 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
/**
|
||||
* AEBaseGui controlled Tooltip Interface.
|
||||
*/
|
||||
public interface ITooltip
|
||||
{
|
||||
public interface ITooltip {
|
||||
|
||||
/**
|
||||
* returns the tooltip message.
|
||||
*
|
||||
* @return tooltip message
|
||||
*/
|
||||
String getMessage();
|
||||
/**
|
||||
* returns the tooltip message.
|
||||
*
|
||||
* @return tooltip message
|
||||
*/
|
||||
String getMessage();
|
||||
|
||||
/**
|
||||
* x Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return xPosition
|
||||
*/
|
||||
int xPos();
|
||||
/**
|
||||
* x Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return xPosition
|
||||
*/
|
||||
int xPos();
|
||||
|
||||
/**
|
||||
* y Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return yPosition
|
||||
*/
|
||||
int yPos();
|
||||
/**
|
||||
* y Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return yPosition
|
||||
*/
|
||||
int yPos();
|
||||
|
||||
/**
|
||||
* Width of the object that triggers the tooltip.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
int getWidth();
|
||||
/**
|
||||
* Width of the object that triggers the tooltip.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
* Height for the object that triggers the tooltip.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
int getHeight();
|
||||
/**
|
||||
* Height for the object that triggers the tooltip.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
* @return true if button being drawn
|
||||
*/
|
||||
boolean isVisible();
|
||||
/**
|
||||
* @return true if button being drawn
|
||||
*/
|
||||
boolean isVisible();
|
||||
}
|
||||
|
||||
@@ -18,152 +18,135 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
|
||||
|
||||
/**
|
||||
* A modified version of the Minecraft text field.
|
||||
* You can initialize it over the full element span.
|
||||
* The mouse click area is increased to the full element
|
||||
* A modified version of the Minecraft text field. You can initialize it over
|
||||
* the full element span. The mouse click area is increased to the full element
|
||||
* subtracted with the defined padding.
|
||||
*
|
||||
* The rendering does pay attention to the size of the '_' caret.
|
||||
*/
|
||||
public class MEGuiTextField extends TextFieldWidget
|
||||
{
|
||||
private static final int PADDING = 2;
|
||||
public class MEGuiTextField extends TextFieldWidget {
|
||||
private static final int PADDING = 2;
|
||||
|
||||
private final int _fontPad;
|
||||
private int selectionColor = 0xFF00FF00;
|
||||
private final int _fontPad;
|
||||
private int selectionColor = 0xFF00FF00;
|
||||
|
||||
/**
|
||||
* Uses the values to instantiate a padded version of a text field.
|
||||
* Pays attention to the '_' caret.
|
||||
*
|
||||
* @param fontRenderer renderer for the strings
|
||||
* @param xPos absolute left position
|
||||
* @param yPos absolute top position
|
||||
* @param width absolute width
|
||||
* @param height absolute height
|
||||
*/
|
||||
public MEGuiTextField( final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height )
|
||||
{
|
||||
super( fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - (int) fontRenderer.getCharWidth( '_' ), height - 2 * PADDING, "" );
|
||||
/**
|
||||
* Uses the values to instantiate a padded version of a text field. Pays
|
||||
* attention to the '_' caret.
|
||||
*
|
||||
* @param fontRenderer renderer for the strings
|
||||
* @param xPos absolute left position
|
||||
* @param yPos absolute top position
|
||||
* @param width absolute width
|
||||
* @param height absolute height
|
||||
*/
|
||||
public MEGuiTextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width,
|
||||
final int height) {
|
||||
super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - (int) fontRenderer.getCharWidth('_'),
|
||||
height - 2 * PADDING, "");
|
||||
|
||||
this._fontPad = (int) fontRenderer.getCharWidth( '_' );
|
||||
}
|
||||
this._fontPad = (int) fontRenderer.getCharWidth('_');
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked( final double xPos, final double yPos, final int button )
|
||||
{
|
||||
if (!super.mouseClicked( xPos, yPos, button )) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean mouseClicked(final double xPos, final double yPos, final int button) {
|
||||
if (!super.mouseClicked(xPos, yPos, button)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean requiresFocus = this.isMouseOver( xPos, yPos );
|
||||
if( !this.isFocused() )
|
||||
{
|
||||
this.setFocused2( requiresFocus );
|
||||
}
|
||||
final boolean requiresFocus = this.isMouseOver(xPos, yPos);
|
||||
if (!this.isFocused()) {
|
||||
this.setFocused2(requiresFocus);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void selectAll()
|
||||
{
|
||||
this.setCursorPosition( 0 );
|
||||
this.setSelectionPos( this.getMaxStringLength() );
|
||||
}
|
||||
public void selectAll() {
|
||||
this.setCursorPosition(0);
|
||||
this.setSelectionPos(this.getMaxStringLength());
|
||||
}
|
||||
|
||||
public void setSelectionColor( int color )
|
||||
{
|
||||
this.selectionColor = color;
|
||||
}
|
||||
public void setSelectionColor(int color) {
|
||||
this.selectionColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(int mouseX, int mouseY, float partial)
|
||||
{
|
||||
if( this.getVisible() )
|
||||
{
|
||||
if( this.isFocused() )
|
||||
{
|
||||
fill( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
|
||||
0xFF606060 );
|
||||
}
|
||||
else
|
||||
{
|
||||
fill( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
|
||||
0xFFA8A8A8 );
|
||||
}
|
||||
super.renderButton(mouseX, mouseY, partial);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void renderButton(int mouseX, int mouseY, float partial) {
|
||||
if (this.getVisible()) {
|
||||
if (this.isFocused()) {
|
||||
fill(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1,
|
||||
this.y + this.height + PADDING - 1, 0xFF606060);
|
||||
} else {
|
||||
fill(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1,
|
||||
this.y + this.height + PADDING - 1, 0xFFA8A8A8);
|
||||
}
|
||||
super.renderButton(mouseX, mouseY, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelectionBox( int startX, int startY, int endX, int endY )
|
||||
{
|
||||
if( !this.isFocused() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void drawSelectionBox(int startX, int startY, int endX, int endY) {
|
||||
if (!this.isFocused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( startX < endX )
|
||||
{
|
||||
int i = startX;
|
||||
startX = endX;
|
||||
endX = i;
|
||||
}
|
||||
if (startX < endX) {
|
||||
int i = startX;
|
||||
startX = endX;
|
||||
endX = i;
|
||||
}
|
||||
|
||||
startX += 1;
|
||||
endX -= 1;
|
||||
startX += 1;
|
||||
endX -= 1;
|
||||
|
||||
if( startY < endY )
|
||||
{
|
||||
int j = startY;
|
||||
startY = endY;
|
||||
endY = j;
|
||||
}
|
||||
if (startY < endY) {
|
||||
int j = startY;
|
||||
startY = endY;
|
||||
endY = j;
|
||||
}
|
||||
|
||||
startY -= PADDING;
|
||||
startY -= PADDING;
|
||||
|
||||
if( endX > this.x + this.width )
|
||||
{
|
||||
endX = this.x + this.width;
|
||||
}
|
||||
if (endX > this.x + this.width) {
|
||||
endX = this.x + this.width;
|
||||
}
|
||||
|
||||
if( startX > this.x + this.width )
|
||||
{
|
||||
startX = this.x + this.width;
|
||||
}
|
||||
if (startX > this.x + this.width) {
|
||||
startX = this.x + this.width;
|
||||
}
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder bufferbuilder = tessellator.getBuffer();
|
||||
|
||||
float red = ( this.selectionColor >> 16 & 255 ) / 255.0F;
|
||||
float blue = ( this.selectionColor >> 8 & 255 ) / 255.0F;
|
||||
float green = ( this.selectionColor & 255 ) / 255.0F;
|
||||
float alpha = ( this.selectionColor >> 24 & 255 ) / 255.0F;
|
||||
float red = (this.selectionColor >> 16 & 255) / 255.0F;
|
||||
float blue = (this.selectionColor >> 8 & 255) / 255.0F;
|
||||
float green = (this.selectionColor & 255) / 255.0F;
|
||||
float alpha = (this.selectionColor >> 24 & 255) / 255.0F;
|
||||
|
||||
RenderSystem.color4f( red, green, blue, alpha );
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.enableColorLogicOp();
|
||||
RenderSystem.logicOp( GlStateManager.LogicOp.OR_REVERSE );
|
||||
bufferbuilder.begin( 7, DefaultVertexFormats.POSITION );
|
||||
bufferbuilder.pos( startX, endY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( endX, endY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( endX, startY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( startX, startY, 0.0D ).endVertex();
|
||||
tessellator.draw();
|
||||
RenderSystem.disableColorLogicOp();
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.color4f( 1, 1, 1, 1 );
|
||||
}
|
||||
RenderSystem.color4f(red, green, blue, alpha);
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.enableColorLogicOp();
|
||||
RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
|
||||
bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
|
||||
bufferbuilder.pos(startX, endY, 0.0D).endVertex();
|
||||
bufferbuilder.pos(endX, endY, 0.0D).endVertex();
|
||||
bufferbuilder.pos(endX, startY, 0.0D).endVertex();
|
||||
bufferbuilder.pos(startX, startY, 0.0D).endVertex();
|
||||
tessellator.draw();
|
||||
RenderSystem.disableColorLogicOp();
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.color4f(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user