reformatted all src files (#141)

This commit is contained in:
YoungOnion
2022-09-17 05:08:02 -06:00
committed by GitHub
parent 3328bfcda2
commit 9011273229
1056 changed files with 88127 additions and 110597 deletions
File diff suppressed because it is too large Load Diff
@@ -19,88 +19,75 @@
package appeng.client.gui;
import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.core.AEConfig;
import appeng.core.localization.ButtonToolTips;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.core.AEConfig;
import appeng.core.localization.ButtonToolTips;
import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
public abstract class AEBaseMEGui extends AEBaseGui
{
public abstract class AEBaseMEGui extends AEBaseGui {
public AEBaseMEGui( final Container container )
{
super( container );
}
public AEBaseMEGui(final Container container) {
super(container);
}
@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.getItemToolTip( stack );
IAEItemStack myStack = null;
final List<String> currentToolTip = this.getItemToolTip(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.isItemDamaged() ) )
{
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.isItemDamaged())) {
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 );
}
currentToolTip.add(format);
}
this.drawHoveringText( currentToolTip, x, y, this.fontRenderer );
this.drawHoveringText(currentToolTip, x, y, this.fontRenderer);
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.drawHoveringText( currentToolTip, x, y, this.fontRenderer );
this.drawHoveringText(currentToolTip, x, y, this.fontRenderer);
return;
}
}
return;
}
}
super.renderToolTip( stack, x, y );
}
super.renderToolTip(stack, x, y);
}
}
@@ -1,7 +1,5 @@
package appeng.client.gui;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.implementations.*;
import appeng.container.interfaces.IJEIGhostIngredients;
@@ -12,119 +10,95 @@ import mezz.jei.api.gui.IGhostIngredientHandler;
import net.minecraft.client.gui.GuiScreen;
import org.lwjgl.input.Mouse;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngredientHandler<AEBaseGui>
{
public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngredientHandler<AEBaseGui> {
@Override
@Nonnull
public Class<AEBaseGui> getGuiContainerClass()
{
public Class<AEBaseGui> getGuiContainerClass() {
return AEBaseGui.class;
}
@Nullable
@Override
public List<Rectangle> getGuiExtraAreas( @Nonnull AEBaseGui guiContainer )
{
public List<Rectangle> getGuiExtraAreas(@Nonnull AEBaseGui guiContainer) {
return guiContainer.getJEIExclusionArea();
}
@Nullable
@Override
public Object getIngredientUnderMouse( @Nonnull AEBaseGui guiContainer, int mouseX, int mouseY )
{
public Object getIngredientUnderMouse(@Nonnull AEBaseGui guiContainer, int mouseX, int mouseY) {
List<IAEItemStack> visual;
int guiSlotIdx;
Object result = null;
if( guiContainer instanceof GuiCraftConfirm )
{
guiSlotIdx = getSlotidx( guiContainer, mouseX, mouseY, ( (GuiCraftConfirm) guiContainer ).getDisplayedRows() );
visual = ( (GuiCraftConfirm) guiContainer ).getVisual();
if( guiSlotIdx < visual.size() && guiSlotIdx != -1 )
{
result = visual.get( guiSlotIdx ).getDefinition();
}
else
{
if (guiContainer instanceof GuiCraftConfirm) {
guiSlotIdx = getSlotidx(guiContainer, mouseX, mouseY, ((GuiCraftConfirm) guiContainer).getDisplayedRows());
visual = ((GuiCraftConfirm) guiContainer).getVisual();
if (guiSlotIdx < visual.size() && guiSlotIdx != -1) {
result = visual.get(guiSlotIdx).getDefinition();
} else {
return null;
}
}
if( guiContainer instanceof GuiCraftingCPU )
{
guiSlotIdx = getSlotidx( guiContainer, mouseX, mouseY, ( (GuiCraftingCPU) guiContainer ).getDisplayedRows() );
visual = ( (GuiCraftingCPU) guiContainer ).getVisual();
if( guiSlotIdx < visual.size() && guiSlotIdx != -1 )
{
result = visual.get( guiSlotIdx ).getDefinition();
}
else
{
if (guiContainer instanceof GuiCraftingCPU) {
guiSlotIdx = getSlotidx(guiContainer, mouseX, mouseY, ((GuiCraftingCPU) guiContainer).getDisplayedRows());
visual = ((GuiCraftingCPU) guiContainer).getVisual();
if (guiSlotIdx < visual.size() && guiSlotIdx != -1) {
result = visual.get(guiSlotIdx).getDefinition();
} else {
return null;
}
}
if( guiContainer instanceof GuiCraftAmount )
{
if( guiContainer.getSlotUnderMouse() != null )
{
if (guiContainer instanceof GuiCraftAmount) {
if (guiContainer.getSlotUnderMouse() != null) {
result = guiContainer.getSlotUnderMouse().getStack();
}
}
return result;
}
private int getSlotidx(AEBaseGui guiContainer, int mouseX, int mouseY, int rows)
{
private int getSlotidx(AEBaseGui guiContainer, int mouseX, int mouseY, int rows) {
int guileft = guiContainer.getGuiLeft();
int guitop = guiContainer.getGuiTop();
int currentScroll = guiContainer.getScrollBar().getCurrentScroll();
final int xo = 9;
final int yo = 19;
int guiSlotx = ( mouseX - guileft - xo ) / 67;
if( guiSlotx > 2 || mouseX < guileft + xo ) return -1;
int guiSloty = ( mouseY - guitop - yo ) / 23;
if( guiSloty > ( rows - 1 ) || mouseY < guitop + yo ) return -1;
return ( guiSloty * 3 ) + guiSlotx + ( currentScroll * 3 );
int guiSlotx = (mouseX - guileft - xo) / 67;
if (guiSlotx > 2 || mouseX < guileft + xo) return -1;
int guiSloty = (mouseY - guitop - yo) / 23;
if (guiSloty > (rows - 1) || mouseY < guitop + yo) return -1;
return (guiSloty * 3) + guiSlotx + (currentScroll * 3);
}
@Override
@Nonnull
public <I> List<Target<I>> getTargets( @Nonnull AEBaseGui gui, @Nonnull I ingredient, boolean doStart )
{
public <I> List<Target<I>> getTargets(@Nonnull AEBaseGui gui, @Nonnull I ingredient, boolean doStart) {
ArrayList<Target<I>> targets = new ArrayList<>();
if( gui instanceof IJEIGhostIngredients )
{
if (gui instanceof IJEIGhostIngredients) {
IJEIGhostIngredients g = (IJEIGhostIngredients) gui;
List<Target<?>> phantomTargets = g.getPhantomTargets( ingredient );
targets.addAll( (List<Target<I>>) (Object) phantomTargets );
List<Target<?>> phantomTargets = g.getPhantomTargets(ingredient);
targets.addAll((List<Target<I>>) (Object) phantomTargets);
}
if( doStart && GuiScreen.isShiftKeyDown() && Mouse.isButtonDown( 0 ) )
{
if( gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm || gui instanceof GuiExpandedProcessingPatternTerm )
{
IJEIGhostIngredients ghostGui = ( (IJEIGhostIngredients) gui );
for( Target<I> target : targets )
{
if( ghostGui.getFakeSlotTargetMap().get( target ) instanceof SlotFake )
{
if( ( (SlotFake) ghostGui.getFakeSlotTargetMap().get( target ) ).getStack().isEmpty() )
{
target.accept( ingredient );
if (doStart && GuiScreen.isShiftKeyDown() && Mouse.isButtonDown(0)) {
if (gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm || gui instanceof GuiExpandedProcessingPatternTerm) {
IJEIGhostIngredients ghostGui = ((IJEIGhostIngredients) gui);
for (Target<I> target : targets) {
if (ghostGui.getFakeSlotTargetMap().get(target) instanceof SlotFake) {
if (((SlotFake) ghostGui.getFakeSlotTargetMap().get(target)).getStack().isEmpty()) {
target.accept(ingredient);
break;
}
}
else if( ghostGui.getFakeSlotTargetMap().get( target ) instanceof GuiFluidSlot )
{
if( ( (GuiFluidSlot) ghostGui.getFakeSlotTargetMap().get( target ) ).getFluidStack() == null )
{
target.accept( ingredient );
} else if (ghostGui.getFakeSlotTargetMap().get(target) instanceof GuiFluidSlot) {
if (((GuiFluidSlot) ghostGui.getFakeSlotTargetMap().get(target)).getFluidStack() == null) {
target.accept(ingredient);
break;
}
}
@@ -135,12 +109,11 @@ public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>, IGhostIngre
}
@Override
public void onComplete(){
public void onComplete() {
}
@Override
public boolean shouldHighlightTargets()
{
public boolean shouldHighlightTargets() {
return true;
}
+10 -14
View File
@@ -22,22 +22,18 @@ package appeng.client.gui;
import net.minecraft.inventory.Container;
public class GuiNull extends AEBaseGui
{
public class GuiNull extends AEBaseGui {
public GuiNull( final Container container )
{
super( container );
}
public GuiNull(final Container container) {
super(container);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
}
}
}
+69 -85
View File
@@ -1,10 +1,6 @@
package appeng.client.gui;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
@@ -15,105 +11,93 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.SlotItemHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* 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 boolean isHere( IInventory inv, int slotIn )
{
return this.delegate.isHere( inv, slotIn );
}
@Override
public boolean isHere(IInventory inv, int slotIn) {
return this.delegate.isHere(inv, slotIn);
}
@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
@Nullable
@SideOnly( Side.CLIENT )
public String getSlotTexture()
{
return this.delegate.getSlotTexture();
}
@Override
@Nullable
@SideOnly(Side.CLIENT)
public String getSlotTexture() {
return this.delegate.getSlotTexture();
}
@Override
public boolean canTakeStack( EntityPlayer playerIn )
{
return this.delegate.canTakeStack( playerIn );
}
@Override
public boolean canTakeStack(EntityPlayer playerIn) {
return this.delegate.canTakeStack(playerIn);
}
@Override
@SideOnly( Side.CLIENT )
public boolean isEnabled()
{
return this.delegate.isEnabled();
}
@Override
@SideOnly(Side.CLIENT)
public boolean isEnabled() {
return this.delegate.isEnabled();
}
@Override
@SideOnly( Side.CLIENT )
public ResourceLocation getBackgroundLocation()
{
return this.delegate.getBackgroundLocation();
}
@Override
@SideOnly(Side.CLIENT)
public ResourceLocation getBackgroundLocation() {
return this.delegate.getBackgroundLocation();
}
@Override
@SideOnly( Side.CLIENT )
public TextureAtlasSprite getBackgroundSprite()
{
return this.delegate.getBackgroundSprite();
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getBackgroundSprite() {
return this.delegate.getBackgroundSprite();
}
@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);
}
}
@@ -19,54 +19,46 @@
package appeng.client.gui.config;
import java.util.ArrayList;
import java.util.List;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.fml.client.config.GuiConfig;
import net.minecraftforge.fml.client.config.IConfigElement;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import java.util.ArrayList;
import java.util.List;
public class AEConfigGui extends GuiConfig
{
public class AEConfigGui extends GuiConfig {
public AEConfigGui( final GuiScreen parent )
{
super( parent, getConfigElements(), AppEng.MOD_ID, false, false, GuiConfig.getAbridgedConfigPath( AEConfig.instance().getFilePath() ) );
}
public AEConfigGui(final GuiScreen parent) {
super(parent, getConfigElements(), AppEng.MOD_ID, false, false, GuiConfig.getAbridgedConfigPath(AEConfig.instance().getFilePath()));
}
private static List<IConfigElement> getConfigElements()
{
final List<IConfigElement> list = new ArrayList<>();
private static List<IConfigElement> getConfigElements() {
final List<IConfigElement> list = new ArrayList<>();
for( final String cat : AEConfig.instance().getCategoryNames() )
{
if( cat.equals( "versionchecker" ) )
{
continue;
}
for (final String cat : AEConfig.instance().getCategoryNames()) {
if (cat.equals("versionchecker")) {
continue;
}
if( cat.equals( "settings" ) )
{
continue;
}
if (cat.equals("settings")) {
continue;
}
final ConfigCategory cc = AEConfig.instance().getCategory( cat );
final ConfigCategory cc = AEConfig.instance().getCategory(cat);
if( cc.isChild() )
{
continue;
}
if (cc.isChild()) {
continue;
}
final ConfigElement ce = new ConfigElement( cc );
list.add( ce );
}
final ConfigElement ce = new ConfigElement(cc);
list.add(ce);
}
return list;
}
return list;
}
}
@@ -19,63 +19,58 @@
package appeng.client.gui.config;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.client.IModGuiFactory;
import java.util.Set;
public class AEConfigGuiFactory implements IModGuiFactory
{
@Override
public void initialize( final Minecraft minecraftInstance )
{
public class AEConfigGuiFactory implements IModGuiFactory {
}
@Override
public void initialize(final Minecraft minecraftInstance) {
/**
* If this method returns false, the config button in the mod list will be disabled
*
* @return true if this object provides a config gui screen, false otherwise
*/
@Override
public boolean hasConfigGui()
{
return false;
}
}
/**
* Return an initialized {@link GuiScreen}. This screen will be displayed
* when the "config" button is pressed in the mod list. It will
* have a single argument constructor - the "parent" screen, the same as all
* Minecraft GUIs. The expected behaviour is that this screen will replace the
* "mod list" screen completely, and will return to the mod list screen through
* the parent link, once the appropriate action is taken from the config screen.
* <p>
* This config GUI is anticipated to provide configuration to the mod in a friendly
* visual way. It should not be abused to set internals such as IDs (they're gonna
* keep disappearing anyway), but rather, interesting behaviours. This config GUI
* is never run when a server game is running, and should be used to configure
* desired behaviours that affect server state. Costs, mod game modes, stuff like that
* can be changed here.
*
* @param parentScreen The screen to which must be returned when closing the
* returned screen.
* @return A class that will be instantiated on clicks on the config button
* or null if no GUI is desired.
*/
@Override
public GuiScreen createConfigGui( GuiScreen parentScreen )
{
return new AEConfigGui( parentScreen );
}
/**
* If this method returns false, the config button in the mod list will be disabled
*
* @return true if this object provides a config gui screen, false otherwise
*/
@Override
public boolean hasConfigGui() {
return false;
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
{
return null;
}
/**
* Return an initialized {@link GuiScreen}. This screen will be displayed
* when the "config" button is pressed in the mod list. It will
* have a single argument constructor - the "parent" screen, the same as all
* Minecraft GUIs. The expected behaviour is that this screen will replace the
* "mod list" screen completely, and will return to the mod list screen through
* the parent link, once the appropriate action is taken from the config screen.
* <p>
* This config GUI is anticipated to provide configuration to the mod in a friendly
* visual way. It should not be abused to set internals such as IDs (they're gonna
* keep disappearing anyway), but rather, interesting behaviours. This config GUI
* is never run when a server game is running, and should be used to configure
* desired behaviours that affect server state. Costs, mod game modes, stuff like that
* can be changed here.
*
* @param parentScreen The screen to which must be returned when closing the
* returned screen.
* @return A class that will be instantiated on clicks on the config button
* or null if no GUI is desired.
*/
@Override
public GuiScreen createConfigGui(GuiScreen parentScreen) {
return new AEConfigGui(parentScreen);
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
return null;
}
}
@@ -19,20 +19,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.ActionItems;
import appeng.api.config.CopyMode;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.*;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiToggleButton;
@@ -42,167 +29,137 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import org.lwjgl.input.Mouse;
import java.io.IOException;
public class GuiCellWorkbench extends GuiUpgradeable
{
public class GuiCellWorkbench extends GuiUpgradeable {
private final ContainerCellWorkbench workbench;
private final ContainerCellWorkbench workbench;
private GuiImgButton clear;
private GuiImgButton partition;
private GuiToggleButton copyMode;
private GuiImgButton clear;
private GuiImgButton partition;
private GuiToggleButton copyMode;
public GuiCellWorkbench( final InventoryPlayer inventoryPlayer, final TileCellWorkbench te )
{
super( new ContainerCellWorkbench( inventoryPlayer, te ) );
this.workbench = (ContainerCellWorkbench) this.inventorySlots;
this.ySize = 251;
}
public GuiCellWorkbench(final InventoryPlayer inventoryPlayer, final TileCellWorkbench te) {
super(new ContainerCellWorkbench(inventoryPlayer, te));
this.workbench = (ContainerCellWorkbench) this.inventorySlots;
this.ySize = 251;
}
@Override
protected void addButtons()
{
this.clear = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
this.partition = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
this.copyMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 48, 11 * 16 + 5, 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc
.getLocal() );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
@Override
protected void addButtons() {
this.clear = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE);
this.partition = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH);
this.copyMode = new GuiToggleButton(this.guiLeft - 18, this.guiTop + 48, 11 * 16 + 5, 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc
.getLocal());
this.fuzzyMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
this.buttonList.add( this.fuzzyMode );
this.buttonList.add( this.partition );
this.buttonList.add( this.clear );
this.buttonList.add( this.copyMode );
}
this.buttonList.add(this.fuzzyMode);
this.buttonList.add(this.partition);
this.buttonList.add(this.clear);
this.buttonList.add(this.copyMode);
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.handleButtonVisibility();
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.handleButtonVisibility();
this.bindTexture( this.getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize );
if( this.drawUpgrades() )
{
if( this.workbench.availableUpgrades() <= 8 )
{
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + this.workbench.availableUpgrades() * 18 );
this.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( this.workbench.availableUpgrades() ) * 18 ), 177, 151, 35, 7 );
}
else if( this.workbench.availableUpgrades() <= 16 )
{
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18 );
this.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( 8 ) * 18 ), 177, 151, 35, 7 );
this.bindTexture(this.getBackground());
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, 211 - 34, this.ySize);
if (this.drawUpgrades()) {
if (this.workbench.availableUpgrades() <= 8) {
this.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 7 + this.workbench.availableUpgrades() * 18);
this.drawTexturedModalRect(offsetX + 177, offsetY + (7 + (this.workbench.availableUpgrades()) * 18), 177, 151, 35, 7);
} else if (this.workbench.availableUpgrades() <= 16) {
this.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18);
this.drawTexturedModalRect(offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7);
final int dx = this.workbench.availableUpgrades() - 8;
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + dx * 18 );
if( dx == 8 )
{
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY + ( 7 + ( dx ) * 18 ), 186, 151, 35 - 8, 7 );
}
else
{
this.drawTexturedModalRect( offsetX + 177 + 27 + 4, offsetY + ( 7 + ( dx ) * 18 ), 186 + 4, 151, 35 - 8, 7 );
}
}
else
{
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18 );
this.drawTexturedModalRect( offsetX + 177, offsetY + ( 7 + ( 8 ) * 18 ), 177, 151, 35, 7 );
final int dx = this.workbench.availableUpgrades() - 8;
this.drawTexturedModalRect(offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + dx * 18);
if (dx == 8) {
this.drawTexturedModalRect(offsetX + 177 + 27, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, 7);
} else {
this.drawTexturedModalRect(offsetX + 177 + 27 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151, 35 - 8, 7);
}
} else {
this.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18);
this.drawTexturedModalRect(offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7);
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + 8 * 18 );
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY + ( 7 + ( 8 ) * 18 ), 186, 151, 35 - 8, 7 );
this.drawTexturedModalRect(offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + 8 * 18);
this.drawTexturedModalRect(offsetX + 177 + 27, offsetY + (7 + (8) * 18), 186, 151, 35 - 8, 7);
final int dx = this.workbench.availableUpgrades() - 16;
this.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY, 186, 0, 35 - 8, 7 + dx * 18 );
if( dx == 8 )
{
this.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY + ( 7 + ( dx ) * 18 ), 186, 151, 35 - 8, 7 );
}
else
{
this.drawTexturedModalRect( offsetX + 177 + 27 + 18 + 4, offsetY + ( 7 + ( dx ) * 18 ), 186 + 4, 151, 35 - 8, 7 );
}
}
}
if( this.hasToolbox() )
{
this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, 161, 68, 68 );
}
}
final int dx = this.workbench.availableUpgrades() - 16;
this.drawTexturedModalRect(offsetX + 177 + 27 + 18, offsetY, 186, 0, 35 - 8, 7 + dx * 18);
if (dx == 8) {
this.drawTexturedModalRect(offsetX + 177 + 27 + 18, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, 7);
} else {
this.drawTexturedModalRect(offsetX + 177 + 27 + 18 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151, 35 - 8, 7);
}
}
}
if (this.hasToolbox()) {
this.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, 161, 68, 68);
}
}
@Override
protected void handleButtonVisibility()
{
this.copyMode.setState( this.workbench.getCopyMode() == CopyMode.CLEAR_ON_REMOVE );
@Override
protected void handleButtonVisibility() {
this.copyMode.setState(this.workbench.getCopyMode() == CopyMode.CLEAR_ON_REMOVE);
boolean hasFuzzy = false;
final IItemHandler inv = this.workbench.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.workbench.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.workbench.availableUpgrades() > 0;
}
@Override
protected boolean drawUpgrades() {
return this.workbench.availableUpgrades() > 0;
}
@Override
protected GuiText getName()
{
return GuiText.CellWorkbench;
}
@Override
protected GuiText getName() {
return GuiText.CellWorkbench;
}
@Override
protected void actionPerformed( final GuiButton btn )
{
try
{
if( btn == this.copyMode )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "CopyMode" ) );
}
else if( btn == this.partition )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Partition" ) );
}
else if( btn == this.clear )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Clear" ) );
}
else if( btn == this.fuzzyMode )
{
final boolean backwards = Mouse.isButtonDown( 1 );
@Override
protected void actionPerformed(final GuiButton btn) {
try {
if (btn == this.copyMode) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("CellWorkbench.Action", "CopyMode"));
} else if (btn == this.partition) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("CellWorkbench.Action", "Partition"));
} else if (btn == this.clear) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("CellWorkbench.Action", "Clear"));
} else if (btn == this.fuzzyMode) {
final boolean backwards = Mouse.isButtonDown(1);
FuzzyMode fz = (FuzzyMode) this.fuzzyMode.getCurrentValue();
fz = Platform.rotateEnum( fz, backwards, Settings.FUZZY_MODE.getPossibleValues() );
FuzzyMode fz = (FuzzyMode) this.fuzzyMode.getCurrentValue();
fz = Platform.rotateEnum(fz, backwards, Settings.FUZZY_MODE.getPossibleValues());
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Fuzzy", fz.name() ) );
}
else
{
super.actionPerformed( btn );
}
}
catch( final IOException ignored )
{
}
}
NetworkHandler.instance().sendToServer(new PacketValueConfig("CellWorkbench.Fuzzy", fz.name()));
} else {
super.actionPerformed(btn);
}
} catch (final IOException ignored) {
}
}
}
@@ -19,11 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerChest;
@@ -32,49 +27,46 @@ import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.tile.storage.TileChest;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import java.io.IOException;
public class GuiChest extends AEBaseGui
{
public class GuiChest extends AEBaseGui {
private GuiTabButton priority;
private GuiTabButton priority;
public GuiChest( final InventoryPlayer inventoryPlayer, final TileChest te )
{
super( new ContainerChest( inventoryPlayer, te ) );
this.ySize = 166;
}
public GuiChest(final InventoryPlayer inventoryPlayer, final TileChest te) {
super(new ContainerChest(inventoryPlayer, te));
this.ySize = 166;
}
@Override
protected void actionPerformed( final GuiButton par1GuiButton ) throws IOException
{
super.actionPerformed( par1GuiButton );
@Override
protected void actionPerformed(final GuiButton par1GuiButton) throws IOException {
super.actionPerformed(par1GuiButton);
if( par1GuiButton == this.priority )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
}
if (par1GuiButton == this.priority) {
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PRIORITY));
}
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.buttonList.add( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
}
this.buttonList.add(this.priority = new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender));
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.Chest.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.Chest.getLocal()), 8, 6, 4210752);
this.fontRenderer.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 )
{
this.bindTexture( "guis/chest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/chest.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}
@@ -19,13 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.Settings;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
@@ -36,64 +29,62 @@ import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.tile.misc.TileCondenser;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import java.io.IOException;
public class GuiCondenser extends AEBaseGui
{
public class GuiCondenser extends AEBaseGui {
private final ContainerCondenser cvc;
private GuiProgressBar pb;
private GuiImgButton mode;
private final ContainerCondenser cvc;
private GuiProgressBar pb;
private GuiImgButton mode;
public GuiCondenser( final InventoryPlayer inventoryPlayer, final TileCondenser te )
{
super( new ContainerCondenser( inventoryPlayer, te ) );
this.cvc = (ContainerCondenser) this.inventorySlots;
this.ySize = 197;
}
public GuiCondenser(final InventoryPlayer inventoryPlayer, final TileCondenser te) {
super(new ContainerCondenser(inventoryPlayer, te));
this.cvc = (ContainerCondenser) this.inventorySlots;
this.ySize = 197;
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
if( this.mode == btn )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( Settings.CONDENSER_OUTPUT, backwards ) );
}
}
if (this.mode == btn) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(Settings.CONDENSER_OUTPUT, backwards));
}
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.pb = new GuiProgressBar( this.cvc, "guis/condenser.png", 120 + this.guiLeft, 25 + this.guiTop, 178, 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy
.getLocal() );
this.pb = new GuiProgressBar(this.cvc, "guis/condenser.png", 120 + this.guiLeft, 25 + this.guiTop, 178, 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy
.getLocal());
this.mode = new GuiImgButton( 128 + this.guiLeft, 52 + this.guiTop, Settings.CONDENSER_OUTPUT, this.cvc.getOutput() );
this.mode = new GuiImgButton(128 + this.guiLeft, 52 + this.guiTop, Settings.CONDENSER_OUTPUT, this.cvc.getOutput());
this.buttonList.add( this.pb );
this.buttonList.add( this.mode );
}
this.buttonList.add(this.pb);
this.buttonList.add(this.mode);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.Condenser.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.Condenser.getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
this.mode.set( this.cvc.getOutput() );
this.mode.setFillVar( String.valueOf( this.cvc.getOutput().requiredPower ) );
}
this.mode.set(this.cvc.getOutput());
this.mode.setFillVar(String.valueOf(this.cvc.getOutput().requiredPower));
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.bindTexture( "guis/condenser.png" );
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/condenser.png");
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}
@@ -19,13 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import appeng.parts.reporting.PartExpandedProcessingPatternTerminal;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
@@ -44,267 +37,229 @@ import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.helpers.Reflected;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartExpandedProcessingPatternTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import java.io.IOException;
public class GuiCraftAmount extends AEBaseGui
{
private GuiNumberBox amountToCraft;
private GuiTabButton originalGuiBtn;
private GuiButton next;
public class GuiCraftAmount extends AEBaseGui {
private GuiNumberBox amountToCraft;
private GuiTabButton originalGuiBtn;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiButton next;
private GuiBridge originalGui;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
@Reflected
public GuiCraftAmount( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( new ContainerCraftAmount( inventoryPlayer, te ) );
}
private GuiBridge originalGui;
@Override
public void initGui()
{
super.initGui();
@Reflected
public GuiCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerCraftAmount(inventoryPlayer, te));
}
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 );
@Override
public void initGui() {
super.initGui();
this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a ) );
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b ) );
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c ) );
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d ) );
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.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a ) );
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b ) );
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c ) );
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d ) );
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
this.buttonList.add( this.next = new GuiButton( 0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal() ) );
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
ItemStack myIcon = null;
final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
this.buttonList.add(this.next = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
if( target instanceof WirelessTerminalGuiObject )
{
myIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( myIcon );
ItemStack myIcon = null;
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
}
if (target instanceof WirelessTerminalGuiObject) {
myIcon = definitions.items().wirelessTerminal().maybeStack(1).orElse(myIcon);
if( target instanceof PartTerminal )
{
myIcon = parts.terminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_ME;
}
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
}
if( target instanceof PartCraftingTerminal )
{
myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}
if (target instanceof PartTerminal) {
myIcon = parts.terminal().maybeStack(1).orElse(ItemStack.EMPTY);
this.originalGui = GuiBridge.GUI_ME;
}
if( target instanceof PartPatternTerminal )
{
myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
if (target instanceof PartCraftingTerminal) {
myIcon = parts.craftingTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}
if( target instanceof PartExpandedProcessingPatternTerminal )
{
myIcon = parts.expandedProcessingPatternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL;
}
if (target instanceof PartPatternTerminal) {
myIcon = parts.patternTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
if( this.originalGui != null && !myIcon.isEmpty() )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), this.itemRender ) );
}
if (target instanceof PartExpandedProcessingPatternTerminal) {
myIcon = parts.expandedProcessingPatternTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
this.originalGui = GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL;
}
this.amountToCraft = new GuiNumberBox( this.fontRenderer, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRenderer.FONT_HEIGHT, Integer.class );
this.amountToCraft.setEnableBackgroundDrawing( false );
this.amountToCraft.setMaxStringLength( 16 );
this.amountToCraft.setTextColor( 0xFFFFFF );
this.amountToCraft.setVisible( true );
this.amountToCraft.setFocused( true );
this.amountToCraft.setText( "1" );
this.amountToCraft.setSelectionPos( 0 );
}
if (this.originalGui != null && !myIcon.isEmpty()) {
this.buttonList.add(this.originalGuiBtn = new GuiTabButton(this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), this.itemRender));
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 );
}
this.amountToCraft = new GuiNumberBox(this.fontRenderer, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRenderer.FONT_HEIGHT, Integer.class);
this.amountToCraft.setEnableBackgroundDrawing(false);
this.amountToCraft.setMaxStringLength(16);
this.amountToCraft.setTextColor(0xFFFFFF);
this.amountToCraft.setVisible(true);
this.amountToCraft.setFocused(true);
this.amountToCraft.setText("1");
this.amountToCraft.setSelectionPos(0);
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRenderer.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 4210752);
}
this.bindTexture( "guis/craft_amt.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
try
{
long amt = Long.parseLong( this.amountToCraft.getText() );
this.next.enabled = ( !this.amountToCraft.getText().isEmpty() && amt > 0 );
}
catch( final NumberFormatException e )
{
this.next.enabled = false;
}
this.bindTexture("guis/craft_amt.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
this.amountToCraft.drawTextBox();
}
try {
long amt = Long.parseLong(this.amountToCraft.getText());
this.next.enabled = (!this.amountToCraft.getText().isEmpty() && amt > 0);
} catch (final NumberFormatException e) {
this.next.enabled = false;
}
@Override
protected void keyTyped( final char character, final int key ) throws IOException
{
if( !this.checkHotbarKeys( key ) )
{
if( key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER )
{
this.actionPerformed( this.next );
}
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.amountToCraft
.textboxKeyTyped( character, key ) )
{
try
{
String out = this.amountToCraft.getText();
this.amountToCraft.drawTextBox();
}
boolean fixed = false;
while ( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
@Override
protected void keyTyped(final char character, final int key) throws IOException {
if (!this.checkHotbarKeys(key)) {
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
this.actionPerformed(this.next);
}
if ((key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit(character)) && this.amountToCraft
.textboxKeyTyped(character, key)) {
try {
String out = this.amountToCraft.getText();
if( fixed )
{
this.amountToCraft.setText( out );
}
boolean fixed = false;
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if( out.isEmpty() )
{
out = "0";
}
if (fixed) {
this.amountToCraft.setText(out);
}
final long result = Long.parseLong( out );
if( result < 0 )
{
this.amountToCraft.setText( "1" );
}
}
catch( final NumberFormatException e )
{
// :P
}
}
else
{
super.keyTyped( character, key );
}
}
}
if (out.isEmpty()) {
out = "0";
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
final long result = Long.parseLong(out);
if (result < 0) {
this.amountToCraft.setText("1");
}
} catch (final NumberFormatException e) {
// :P
}
} else {
super.keyTyped(character, key);
}
}
}
try
{
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
if( btn == this.originalGuiBtn )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( this.originalGui ) );
}
try {
if( btn == this.next )
{
NetworkHandler.instance().sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
}
}
catch( final NumberFormatException e )
{
// nope..
this.amountToCraft.setText( "1" );
}
if (btn == this.originalGuiBtn) {
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(this.originalGui));
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if (btn == this.next) {
NetworkHandler.instance().sendToServer(new PacketCraftRequest(Integer.parseInt(this.amountToCraft.getText()), isShiftKeyDown()));
}
} catch (final NumberFormatException e) {
// nope..
this.amountToCraft.setText("1");
}
if( isPlus || isMinus )
{
this.addQty( this.getQty( btn ) );
}
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
private void addQty( final int i )
{
try
{
String out = this.amountToCraft.getText();
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
}
}
boolean fixed = false;
while ( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
private void addQty(final int i) {
try {
String out = this.amountToCraft.getText();
if( fixed )
{
this.amountToCraft.setText( out );
}
boolean fixed = false;
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if( out.isEmpty() )
{
out = "0";
}
if (fixed) {
this.amountToCraft.setText(out);
}
long result = Integer.parseInt( out );
if (out.isEmpty()) {
out = "0";
}
if( result == 1 && i > 1 )
{
result = 0;
}
long result = Integer.parseInt(out);
result += i;
if( result < 1 )
{
result = 1;
}
if (result == 1 && i > 1) {
result = 0;
}
out = Long.toString( result );
Integer.parseInt( out );
this.amountToCraft.setText( out );
}
catch( final NumberFormatException e )
{
// :P
}
}
result += i;
if (result < 1) {
result = 1;
}
protected String getBackground()
{
return "guis/craftAmt.png";
}
out = Long.toString(result);
Integer.parseInt(out);
this.amountToCraft.setText(out);
} catch (final NumberFormatException e) {
// :P
}
}
protected String getBackground() {
return "guis/craftAmt.png";
}
}
File diff suppressed because it is too large Load Diff
@@ -19,21 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.google.common.base.Joiner;
import org.apache.commons.lang3.time.DurationFormatUtils;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
@@ -53,454 +38,400 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
public class GuiCraftingCPU extends AEBaseGui 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 final ContainerCraftingCPU craftingCpu;
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 GuiButton cancel;
private int tooltip = -1;
public GuiCraftingCPU( final InventoryPlayer inventoryPlayer, final Object te )
{
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
}
protected GuiCraftingCPU( final ContainerCraftingCPU container )
{
super( container );
this.craftingCpu = container;
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<>();
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
if( this.cancel == btn )
{
try
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
}
@Override
public void initGui()
{
super.initGui();
this.setScrollBar();
this.cancel = new GuiButton( 0, this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET, CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel
.getLocal() );
this.buttonList.add( 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 drawScreen( final int mouseX, final int mouseY, final float btn )
{
this.cancel.enabled = !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.drawScreen( 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.craftingCpu.getEstimatedTime() > 0 && !this.visual.isEmpty() )
{
final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert( this.craftingCpu.getEstimatedTime(), TimeUnit.NANOSECONDS );
final String etaTimeText = DurationFormatUtils.formatDuration( etaInMilliseconds, GuiText.ETAFormat.getLocal() );
title += " - " + etaTimeText;
}
this.fontRenderer.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 )
{
GlStateManager.pushMatrix();
GlStateManager.scale( 0.5, 0.5, 0.5 );
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;
drawRect( 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.fontRenderer.getStringWidth( str );
this.fontRenderer.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.fontRenderer.getStringWidth( str );
this.fontRenderer.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.fontRenderer.getStringWidth( str );
this.fontRenderer.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() ) );
}
}
GlStateManager.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 );
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 )
{
this.bindTexture( "guis/craftingcpu.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
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 Enum getSortBy()
{
return SortOrder.NAME;
}
@Override
public Enum getSortDir()
{
return SortDir.ASCENDING;
}
@Override
public Enum getSortDisplay()
{
return ViewItems.ALL;
}
public List<IAEItemStack> getVisual()
{
return visual;
}
public int getDisplayedRows()
{
return DISPLAYED_ROWS;
}
import com.google.common.base.Joiner;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.time.DurationFormatUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class GuiCraftingCPU extends AEBaseGui 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 final ContainerCraftingCPU craftingCpu;
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 GuiButton cancel;
private int tooltip = -1;
public GuiCraftingCPU(final InventoryPlayer inventoryPlayer, final Object te) {
this(new ContainerCraftingCPU(inventoryPlayer, te));
}
protected GuiCraftingCPU(final ContainerCraftingCPU container) {
super(container);
this.craftingCpu = container;
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<>();
}
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
if (this.cancel == btn) {
try {
NetworkHandler.instance().sendToServer(new PacketValueConfig("TileCrafting.Cancel", "Cancel"));
} catch (final IOException e) {
AELog.debug(e);
}
}
}
@Override
public void initGui() {
super.initGui();
this.setScrollBar();
this.cancel = new GuiButton(0, this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET, CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel
.getLocal());
this.buttonList.add(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 drawScreen(final int mouseX, final int mouseY, final float btn) {
this.cancel.enabled = !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.drawScreen(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.craftingCpu.getEstimatedTime() > 0 && !this.visual.isEmpty()) {
final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert(this.craftingCpu.getEstimatedTime(), TimeUnit.NANOSECONDS);
final String etaTimeText = DurationFormatUtils.formatDuration(etaInMilliseconds, GuiText.ETAFormat.getLocal());
title += " - " + etaTimeText;
}
this.fontRenderer.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) {
GlStateManager.pushMatrix();
GlStateManager.scale(0.5, 0.5, 0.5);
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;
drawRect(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.fontRenderer.getStringWidth(str);
this.fontRenderer.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() + ": " + 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.fontRenderer.getStringWidth(str);
this.fontRenderer.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() + ": " + 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.fontRenderer.getStringWidth(str);
this.fontRenderer.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() + ": " + pendingStack.getStackSize());
}
}
GlStateManager.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);
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) {
this.bindTexture("guis/craftingcpu.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
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 Enum getSortBy() {
return SortOrder.NAME;
}
@Override
public Enum getSortDir() {
return SortDir.ASCENDING;
}
@Override
public Enum getSortDisplay() {
return ViewItems.ALL;
}
public List<IAEItemStack> getVisual() {
return visual;
}
public int getDisplayedRows() {
return DISPLAYED_ROWS;
}
}
@@ -23,29 +23,15 @@
package appeng.client.gui.implementations;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.container.implementations.CraftingCPUStatus;
import appeng.parts.reporting.PartExpandedProcessingPatternTerminal;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerCraftingStatus;
import appeng.container.implementations.CraftingCPUStatus;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
@@ -54,393 +40,349 @@ import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartExpandedProcessingPatternTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class GuiCraftingStatus extends GuiCraftingCPU
{
private static final int CPU_TABLE_WIDTH = 94;
private static final int CPU_TABLE_HEIGHT = 164;
private static final int CPU_TABLE_SLOT_XOFF = 100;
private static final int CPU_TABLE_SLOT_YOFF = 0;
private static final int CPU_TABLE_SLOT_WIDTH = 67;
private static final int CPU_TABLE_SLOT_HEIGHT = 23;
public class GuiCraftingStatus extends GuiCraftingCPU {
private final ContainerCraftingStatus status;
private GuiButton selectCPU;
private GuiScrollbar cpuScrollbar;
private static final int CPU_TABLE_WIDTH = 94;
private static final int CPU_TABLE_HEIGHT = 164;
private static final int CPU_TABLE_SLOT_XOFF = 100;
private static final int CPU_TABLE_SLOT_YOFF = 0;
private static final int CPU_TABLE_SLOT_WIDTH = 67;
private static final int CPU_TABLE_SLOT_HEIGHT = 23;
private GuiTabButton originalGuiBtn;
private GuiBridge originalGui;
private ItemStack myIcon = ItemStack.EMPTY;
private String selectedCPUName = "";
private final ContainerCraftingStatus status;
private GuiButton selectCPU;
private GuiScrollbar cpuScrollbar;
public GuiCraftingStatus( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( new ContainerCraftingStatus( inventoryPlayer, te ) );
private GuiTabButton originalGuiBtn;
private GuiBridge originalGui;
private ItemStack myIcon = ItemStack.EMPTY;
private String selectedCPUName = "";
this.status = (ContainerCraftingStatus) this.inventorySlots;
final Object target = this.status.getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
public GuiCraftingStatus(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerCraftingStatus(inventoryPlayer, te));
if( target instanceof WirelessTerminalGuiObject )
{
this.myIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.status = (ContainerCraftingStatus) this.inventorySlots;
final Object target = this.status.getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
}
if (target instanceof WirelessTerminalGuiObject) {
this.myIcon = definitions.items().wirelessTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
if( target instanceof PartTerminal )
{
this.myIcon = parts.terminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
}
this.originalGui = GuiBridge.GUI_ME;
}
if (target instanceof PartTerminal) {
this.myIcon = parts.terminal().maybeStack(1).orElse(ItemStack.EMPTY);
if( target instanceof PartCraftingTerminal )
{
this.myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_ME;
}
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}
if (target instanceof PartCraftingTerminal) {
this.myIcon = parts.craftingTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
if( target instanceof PartPatternTerminal )
{
this.myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
if (target instanceof PartPatternTerminal) {
this.myIcon = parts.patternTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
if( target instanceof PartExpandedProcessingPatternTerminal )
{
myIcon = parts.expandedProcessingPatternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL;
}
}
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
if (target instanceof PartExpandedProcessingPatternTerminal) {
myIcon = parts.expandedProcessingPatternTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
this.originalGui = GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL;
}
}
final boolean backwards = Mouse.isButtonDown( 1 );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
if( btn == this.originalGuiBtn )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( this.originalGui ) );
}
}
final boolean backwards = Mouse.isButtonDown(1);
@Override
public void initGui()
{
super.initGui();
if (btn == this.originalGuiBtn) {
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(this.originalGui));
}
}
this.selectCPU = new GuiButton( 0, this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20, GuiText.CraftingCPU
.getLocal() + ": " + GuiText.NoCraftingCPUs );
selectCPU.enabled = false;
this.buttonList.add( this.selectCPU );
@Override
public void initGui() {
super.initGui();
this.cpuScrollbar = new GuiScrollbar();
this.cpuScrollbar.setLeft( -16 );
this.cpuScrollbar.setTop( 19 );
this.cpuScrollbar.setWidth( 12 );
this.cpuScrollbar.setHeight( 137 );
this.selectCPU = new GuiButton(0, this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20, GuiText.CraftingCPU
.getLocal() + ": " + GuiText.NoCraftingCPUs);
selectCPU.enabled = false;
this.buttonList.add(this.selectCPU);
if( !this.myIcon.isEmpty() )
{
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, this.myIcon, this.myIcon.getDisplayName(), this.itemRender ) );
this.originalGuiBtn.setHideEdge( 13 );
}
}
this.cpuScrollbar = new GuiScrollbar();
this.cpuScrollbar.setLeft(-16);
this.cpuScrollbar.setTop(19);
this.cpuScrollbar.setWidth(12);
this.cpuScrollbar.setHeight(137);
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn )
{
List<CraftingCPUStatus> cpus = this.status.getCPUs();
this.selectedCPUName = null;
this.cpuScrollbar.setRange( 0, Integer.max(0, cpus.size() - 6), 1 );
for (CraftingCPUStatus cpu : cpus)
{
if (cpu.getSerial() == this.status.selectedCpuSerial)
{
this.selectedCPUName = cpu.getName();
}
}
this.updateCPUButtonText();
super.drawScreen( mouseX, mouseY, btn );
}
if (!this.myIcon.isEmpty()) {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(this.guiLeft + 213, this.guiTop - 4, this.myIcon, this.myIcon.getDisplayName(), this.itemRender));
this.originalGuiBtn.setHideEdge(13);
}
}
@Override
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
List<CraftingCPUStatus> cpus = this.status.getCPUs();
final int firstCpu = this.cpuScrollbar.getCurrentScroll();
CraftingCPUStatus hoveredCpu = hitCpu( mouseX, mouseY );
{
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
final int TEXT_COLOR = 0x202020;
for( int i = firstCpu; i < firstCpu + 6; i++ )
{
if( i < 0 || i >= cpus.size() )
{
continue;
}
CraftingCPUStatus cpu = cpus.get( i );
if( cpu == null )
{
continue;
}
int x = -CPU_TABLE_WIDTH + 9;
int y = 19 + ( i - firstCpu ) * CPU_TABLE_SLOT_HEIGHT;
if( cpu.getSerial() == this.status.selectedCpuSerial )
{
GL11.glColor4f( 0.0F, 0.8352F, 1.0F, 1.0F );
}
else if( hoveredCpu != null && hoveredCpu.getSerial() == cpu.getSerial() )
{
GL11.glColor4f( 0.65F, 0.9F, 1.0F, 1.0F );
} else
{
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
}
this.bindTexture( "guis/cpu_selector.png" );
this.drawTexturedModalRect( x, y, CPU_TABLE_SLOT_XOFF, CPU_TABLE_SLOT_YOFF, CPU_TABLE_SLOT_WIDTH, CPU_TABLE_SLOT_HEIGHT );
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
List<CraftingCPUStatus> cpus = this.status.getCPUs();
this.selectedCPUName = null;
this.cpuScrollbar.setRange(0, Integer.max(0, cpus.size() - 6), 1);
for (CraftingCPUStatus cpu : cpus) {
if (cpu.getSerial() == this.status.selectedCpuSerial) {
this.selectedCPUName = cpu.getName();
}
}
this.updateCPUButtonText();
super.drawScreen(mouseX, mouseY, btn);
}
String name = cpu.getName();
if( name == null || name.isEmpty() )
{
name = GuiText.CPUs.getLocal() + " #" + cpu.getSerial();
}
if( name.length() > 12 )
{
name = name.substring( 0, 11 ) + "..";
}
GL11.glPushMatrix();
GL11.glTranslatef( x + 3, y + 3, 0 );
GL11.glScalef( 0.8f, 0.8f, 1.0f );
font.drawString( name, 0, 0, TEXT_COLOR );
GL11.glPopMatrix();
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
List<CraftingCPUStatus> cpus = this.status.getCPUs();
final int firstCpu = this.cpuScrollbar.getCurrentScroll();
CraftingCPUStatus hoveredCpu = hitCpu(mouseX, mouseY);
{
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
final int TEXT_COLOR = 0x202020;
for (int i = firstCpu; i < firstCpu + 6; i++) {
if (i < 0 || i >= cpus.size()) {
continue;
}
CraftingCPUStatus cpu = cpus.get(i);
if (cpu == null) {
continue;
}
int x = -CPU_TABLE_WIDTH + 9;
int y = 19 + (i - firstCpu) * CPU_TABLE_SLOT_HEIGHT;
if (cpu.getSerial() == this.status.selectedCpuSerial) {
GL11.glColor4f(0.0F, 0.8352F, 1.0F, 1.0F);
} else if (hoveredCpu != null && hoveredCpu.getSerial() == cpu.getSerial()) {
GL11.glColor4f(0.65F, 0.9F, 1.0F, 1.0F);
} else {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
this.bindTexture("guis/cpu_selector.png");
this.drawTexturedModalRect(x, y, CPU_TABLE_SLOT_XOFF, CPU_TABLE_SLOT_YOFF, CPU_TABLE_SLOT_WIDTH, CPU_TABLE_SLOT_HEIGHT);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix();
GL11.glTranslatef( x + 3, y + 11, 0 );
final IAEItemStack craftingStack = cpu.getCrafting();
if( craftingStack != null )
{
final int iconIndex = 16 * 11 + 2;
this.bindTexture( "guis/states.png" );
final int uv_y = iconIndex / 16;
final int uv_x = iconIndex - uv_y * 16;
String name = cpu.getName();
if (name == null || name.isEmpty()) {
name = GuiText.CPUs.getLocal() + " #" + cpu.getSerial();
}
if (name.length() > 12) {
name = name.substring(0, 11) + "..";
}
GL11.glPushMatrix();
GL11.glTranslatef(x + 3, y + 3, 0);
GL11.glScalef(0.8f, 0.8f, 1.0f);
font.drawString(name, 0, 0, TEXT_COLOR);
GL11.glPopMatrix();
GL11.glScalef( 0.5f, 0.5f, 1.0f );
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
this.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16 );
GL11.glTranslatef( 18.0f, 2.0f, 0.0f );
String amount = Long.toString( craftingStack.getStackSize() );
if( amount.length() > 5 )
{
amount = amount.substring( 0, 5 ) + "..";
}
GL11.glScalef( 1.5f, 1.5f, 1.0f );
font.drawString( amount, 0, 0, 0x009000 );
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslatef( x + CPU_TABLE_SLOT_WIDTH - 19, y + 3, 0 );
this.drawItem( 0, 0, craftingStack.createItemStack() );
}
else
{
final int iconIndex = 16 * 4 + 3;
this.bindTexture( "guis/states.png" );
final int uv_y = iconIndex / 16;
final int uv_x = iconIndex - uv_y * 16;
GL11.glPushMatrix();
GL11.glTranslatef(x + 3, y + 11, 0);
final IAEItemStack craftingStack = cpu.getCrafting();
if (craftingStack != null) {
final int iconIndex = 16 * 11 + 2;
this.bindTexture("guis/states.png");
final int uv_y = iconIndex / 16;
final int uv_x = iconIndex - uv_y * 16;
GL11.glScalef( 0.5f, 0.5f, 1.0f );
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
this.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16 );
GL11.glTranslatef( 18.0f, 2.0f, 0.0f );
GL11.glScalef( 1.5f, 1.5f, 1.0f );
font.drawString( cpu.formatStorage(), 0, 0, TEXT_COLOR );
}
GL11.glPopMatrix();
}
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
}
StringBuilder tooltip = new StringBuilder();
if( hoveredCpu != null )
{
String name = hoveredCpu.getName();
if( name != null && !name.isEmpty() )
{
tooltip.append( name );
tooltip.append( '\n' );
}
else
{
tooltip.append ( GuiText.CPUs.getLocal() );
tooltip.append ( " #" );
tooltip.append ( hoveredCpu.getSerial() );
tooltip.append ( '\n' );
}
IAEItemStack crafting = hoveredCpu.getCrafting();
if( crafting != null && crafting.getStackSize() > 0 )
{
tooltip.append( GuiText.Crafting.getLocal() );
tooltip.append( ": " );
tooltip.append( crafting.getStackSize() );
tooltip.append( ' ' );
tooltip.append( crafting.createItemStack().getDisplayName() );
tooltip.append( '\n' );
tooltip.append( hoveredCpu.getRemainingItems() );
tooltip.append( " / " );
tooltip.append( hoveredCpu.getTotalItems() );
tooltip.append( '\n' );
}
if ( hoveredCpu.getStorage() > 0 )
{
tooltip.append( GuiText.Bytes.getLocal() );
tooltip.append( ": " );
tooltip.append( hoveredCpu.formatStorage() );
tooltip.append( '\n' );
}
if ( hoveredCpu.getCoprocessors() > 0 )
{
tooltip.append( GuiText.CoProcessors.getLocal() );
tooltip.append( ": " );
tooltip.append( hoveredCpu.getCoprocessors() );
tooltip.append( '\n' );
}
}
if (this.cpuScrollbar != null)
{
this.cpuScrollbar.draw( this );
}
super.drawFG( offsetX, offsetY, mouseX, mouseY );
if (tooltip.length() > 0)
{
this.drawTooltip( mouseX - offsetX, mouseY - offsetY, tooltip.toString() );
}
}
GL11.glScalef(0.5f, 0.5f, 1.0f);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(0, 0, uv_x * 16, uv_y * 16, 16, 16);
GL11.glTranslatef(18.0f, 2.0f, 0.0f);
String amount = Long.toString(craftingStack.getStackSize());
if (amount.length() > 5) {
amount = amount.substring(0, 5) + "..";
}
GL11.glScalef(1.5f, 1.5f, 1.0f);
font.drawString(amount, 0, 0, 0x009000);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslatef(x + CPU_TABLE_SLOT_WIDTH - 19, y + 3, 0);
this.drawItem(0, 0, craftingStack.createItemStack());
} else {
final int iconIndex = 16 * 4 + 3;
this.bindTexture("guis/states.png");
final int uv_y = iconIndex / 16;
final int uv_x = iconIndex - uv_y * 16;
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
this.bindTexture( "guis/cpu_selector.png" );
this.drawTexturedModalRect( offsetX - CPU_TABLE_WIDTH, offsetY, 0, 0, CPU_TABLE_WIDTH, CPU_TABLE_HEIGHT );
}
GL11.glScalef(0.5f, 0.5f, 1.0f);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(0, 0, uv_x * 16, uv_y * 16, 16, 16);
GL11.glTranslatef(18.0f, 2.0f, 0.0f);
GL11.glScalef(1.5f, 1.5f, 1.0f);
font.drawString(cpu.formatStorage(), 0, 0, TEXT_COLOR);
}
GL11.glPopMatrix();
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
StringBuilder tooltip = new StringBuilder();
if (hoveredCpu != null) {
String name = hoveredCpu.getName();
if (name != null && !name.isEmpty()) {
tooltip.append(name);
tooltip.append('\n');
} else {
tooltip.append(GuiText.CPUs.getLocal());
tooltip.append(" #");
tooltip.append(hoveredCpu.getSerial());
tooltip.append('\n');
}
IAEItemStack crafting = hoveredCpu.getCrafting();
if (crafting != null && crafting.getStackSize() > 0) {
tooltip.append(GuiText.Crafting.getLocal());
tooltip.append(": ");
tooltip.append(crafting.getStackSize());
tooltip.append(' ');
tooltip.append(crafting.createItemStack().getDisplayName());
tooltip.append('\n');
tooltip.append(hoveredCpu.getRemainingItems());
tooltip.append(" / ");
tooltip.append(hoveredCpu.getTotalItems());
tooltip.append('\n');
}
if (hoveredCpu.getStorage() > 0) {
tooltip.append(GuiText.Bytes.getLocal());
tooltip.append(": ");
tooltip.append(hoveredCpu.formatStorage());
tooltip.append('\n');
}
if (hoveredCpu.getCoprocessors() > 0) {
tooltip.append(GuiText.CoProcessors.getLocal());
tooltip.append(": ");
tooltip.append(hoveredCpu.getCoprocessors());
tooltip.append('\n');
}
}
if (this.cpuScrollbar != null) {
this.cpuScrollbar.draw(this);
}
super.drawFG(offsetX, offsetY, mouseX, mouseY);
if (tooltip.length() > 0) {
this.drawTooltip(mouseX - offsetX, mouseY - offsetY, tooltip.toString());
}
}
@Override
public List<Rectangle> getJEIExclusionArea() {
Rectangle craftingCPUArea = new Rectangle(this.guiLeft - CPU_TABLE_WIDTH, this.guiTop, CPU_TABLE_WIDTH, CPU_TABLE_HEIGHT);
List<Rectangle> area = new ArrayList<Rectangle>();
area.add(craftingCPUArea);
return area;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
super.drawBG(offsetX, offsetY, mouseX, mouseY);
this.bindTexture("guis/cpu_selector.png");
this.drawTexturedModalRect(offsetX - CPU_TABLE_WIDTH, offsetY, 0, 0, CPU_TABLE_WIDTH, CPU_TABLE_HEIGHT);
}
@Override
protected void mouseClicked( int xCoord, int yCoord, int btn ) throws IOException {
super.mouseClicked( xCoord, yCoord, btn );
@Override
public List<Rectangle> getJEIExclusionArea() {
Rectangle craftingCPUArea = new Rectangle(this.guiLeft - CPU_TABLE_WIDTH, this.guiTop, CPU_TABLE_WIDTH, CPU_TABLE_HEIGHT);
List<Rectangle> area = new ArrayList<Rectangle>();
area.add(craftingCPUArea);
return area;
}
if( cpuScrollbar != null )
{
cpuScrollbar.click( this, xCoord - this.guiLeft, yCoord - this.guiTop );
}
CraftingCPUStatus hit = hitCpu( xCoord, yCoord );
if (hit != null)
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu.Set", Integer.toString( hit.getSerial() ) ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) throws IOException {
super.mouseClicked(xCoord, yCoord, btn);
@Override
protected void mouseClickMove( int x, int y, int c, long d )
{
super.mouseClickMove( x, y, c, d );
if( cpuScrollbar != null )
{
cpuScrollbar.click( this, x - this.guiLeft, y - this.guiTop );
}
}
if (cpuScrollbar != null) {
cpuScrollbar.click(this, xCoord - this.guiLeft, yCoord - this.guiTop);
}
CraftingCPUStatus hit = hitCpu(xCoord, yCoord);
if (hit != null) {
try {
NetworkHandler.instance.sendToServer(new PacketValueConfig("Terminal.Cpu.Set", Integer.toString(hit.getSerial())));
} catch (final IOException e) {
AELog.debug(e);
}
}
}
@Override
public void handleMouseInput() throws IOException {
int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
x -= guiLeft - CPU_TABLE_WIDTH;
y -= guiTop;
int dwheel = Mouse.getEventDWheel();
if (x >= 9 && x < CPU_TABLE_SLOT_WIDTH + 9 && y >= 19 && y < 19 + 6 * CPU_TABLE_SLOT_HEIGHT)
{
if (this.cpuScrollbar != null && dwheel != 0)
{
this.cpuScrollbar.wheel( dwheel );
return;
}
}
super.handleMouseInput();
}
@Override
protected void mouseClickMove(int x, int y, int c, long d) {
super.mouseClickMove(x, y, c, d);
if (cpuScrollbar != null) {
cpuScrollbar.click(this, x - this.guiLeft, y - this.guiTop);
}
}
private CraftingCPUStatus hitCpu( int x, int y )
{
x -= guiLeft - CPU_TABLE_WIDTH;
y -= guiTop;
if (!(x >= 9 && x < CPU_TABLE_SLOT_WIDTH + 9 && y >= 19 && y < 19 + 6 * CPU_TABLE_SLOT_HEIGHT))
{
return null;
}
int scrollOffset = this.cpuScrollbar != null ? this.cpuScrollbar.getCurrentScroll() : 0;
int cpuId = scrollOffset + (y - 19) / CPU_TABLE_SLOT_HEIGHT;
List<CraftingCPUStatus> cpus = this.status.getCPUs();
return (cpuId >= 0 && cpuId < cpus.size()) ? cpus.get(cpuId) : null;
}
@Override
public void handleMouseInput() throws IOException {
int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
x -= guiLeft - CPU_TABLE_WIDTH;
y -= guiTop;
int dwheel = Mouse.getEventDWheel();
if (x >= 9 && x < CPU_TABLE_SLOT_WIDTH + 9 && y >= 19 && y < 19 + 6 * CPU_TABLE_SLOT_HEIGHT) {
if (this.cpuScrollbar != null && dwheel != 0) {
this.cpuScrollbar.wheel(dwheel);
return;
}
}
super.handleMouseInput();
}
private void updateCPUButtonText()
{
String btnTextText = GuiText.NoCraftingJobs.getLocal();
private CraftingCPUStatus hitCpu(int x, int y) {
x -= guiLeft - CPU_TABLE_WIDTH;
y -= guiTop;
if (!(x >= 9 && x < CPU_TABLE_SLOT_WIDTH + 9 && y >= 19 && y < 19 + 6 * CPU_TABLE_SLOT_HEIGHT)) {
return null;
}
int scrollOffset = this.cpuScrollbar != null ? this.cpuScrollbar.getCurrentScroll() : 0;
int cpuId = scrollOffset + (y - 19) / CPU_TABLE_SLOT_HEIGHT;
List<CraftingCPUStatus> cpus = this.status.getCPUs();
return (cpuId >= 0 && cpuId < cpus.size()) ? cpus.get(cpuId) : null;
}
if( this.status.selectedCpuSerial >= 0 )// && status.selectedCpu < status.cpus.size() )
{
if( this.selectedCPUName != null && this.selectedCPUName.length() > 0 )
{
final String name = this.selectedCPUName.substring( 0, Math.min( 20, this.selectedCPUName.length() ) );
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
}
else
{
btnTextText = GuiText.CPUs.getLocal() + ": #" + this.status.selectedCpuSerial;
}
}
private void updateCPUButtonText() {
String btnTextText = GuiText.NoCraftingJobs.getLocal();
if( this.status.getCPUs().isEmpty() )
{
btnTextText = GuiText.NoCraftingJobs.getLocal();
}
if (this.status.selectedCpuSerial >= 0)// && status.selectedCpu < status.cpus.size() )
{
if (this.selectedCPUName != null && this.selectedCPUName.length() > 0) {
final String name = this.selectedCPUName.substring(0, Math.min(20, this.selectedCPUName.length()));
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
} else {
btnTextText = GuiText.CPUs.getLocal() + ": #" + this.status.selectedCpuSerial;
}
}
this.selectCPU.displayString = btnTextText;
}
if (this.status.getCPUs().isEmpty()) {
btnTextText = GuiText.NoCraftingJobs.getLocal();
}
@Override
protected String getGuiDisplayName( final String in )
{
return in; // the cup name is on the button
}
this.selectCPU.displayString = btnTextText;
}
public void postCPUUpdate( CraftingCPUStatus[] cpus )
{
this.status.postCPUUpdate(cpus);
}
@Override
protected String getGuiDisplayName(final String in) {
return in; // the cup name is on the button
}
public void postCPUUpdate(CraftingCPUStatus[] cpus) {
this.status.postCPUUpdate(cpus);
}
}
@@ -19,11 +19,6 @@
package appeng.client.gui.implementations;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
@@ -34,62 +29,56 @@ import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.InventoryAction;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
public class GuiCraftingTerm extends GuiMEMonitorable
{
public class GuiCraftingTerm extends GuiMEMonitorable {
private GuiImgButton clearBtn;
private GuiImgButton clearBtn;
public GuiCraftingTerm( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( inventoryPlayer, te, new ContainerCraftingTerm( inventoryPlayer, te ) );
this.setReservedSpace( 73 );
}
public GuiCraftingTerm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(inventoryPlayer, te, new ContainerCraftingTerm(inventoryPlayer, te));
this.setReservedSpace(73);
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if( this.clearBtn == btn )
{
Slot s = null;
final Container c = this.inventorySlots;
for( final Object j : c.inventorySlots )
{
if( j instanceof SlotCraftingMatrix )
{
s = (Slot) j;
}
}
if (this.clearBtn == btn) {
Slot s = null;
final Container c = this.inventorySlots;
for (final Object j : c.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 initGui()
{
super.initGui();
this.buttonList.add( this.clearBtn = new GuiImgButton( this.guiLeft + 92, this.guiTop + this.ySize - 156, Settings.ACTIONS, ActionItems.STASH ) );
this.clearBtn.setHalfSize( true );
}
@Override
public void initGui() {
super.initGui();
this.buttonList.add(this.clearBtn = new GuiImgButton(this.guiLeft + 92, this.guiTop + this.ySize - 156, Settings.ACTIONS, ActionItems.STASH));
this.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.fontRenderer.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.fontRenderer.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";
}
}
@@ -19,11 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerDrive;
@@ -32,49 +27,46 @@ import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.tile.storage.TileDrive;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import java.io.IOException;
public class GuiDrive extends AEBaseGui
{
public class GuiDrive extends AEBaseGui {
private GuiTabButton priority;
private GuiTabButton priority;
public GuiDrive( final InventoryPlayer inventoryPlayer, final TileDrive te )
{
super( new ContainerDrive( inventoryPlayer, te ) );
this.ySize = 199;
}
public GuiDrive(final InventoryPlayer inventoryPlayer, final TileDrive te) {
super(new ContainerDrive(inventoryPlayer, te));
this.ySize = 199;
}
@Override
protected void actionPerformed( final GuiButton par1GuiButton ) throws IOException
{
super.actionPerformed( par1GuiButton );
@Override
protected void actionPerformed(final GuiButton par1GuiButton) throws IOException {
super.actionPerformed(par1GuiButton);
if( par1GuiButton == this.priority )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
}
if (par1GuiButton == this.priority) {
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PRIORITY));
}
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.buttonList.add( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
}
this.buttonList.add(this.priority = new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender));
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.Drive.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.Drive.getLocal()), 8, 6, 4210752);
this.fontRenderer.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 )
{
this.bindTexture( "guis/drive.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/drive.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}
@@ -24,13 +24,13 @@ import net.minecraft.init.Blocks;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import java.awt.Rectangle;
import java.awt.*;
import java.io.IOException;
import java.util.List;
import java.util.*;
public class GuiExpandedProcessingPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredients
{
public class GuiExpandedProcessingPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredients {
private static final String BACKGROUND_EXPANDED_PROCESSING_MODE = "guis/pattern_processing_expanded.png";
private static final String SUBSITUTION_DISABLE = "0";
@@ -54,146 +54,125 @@ public class GuiExpandedProcessingPatternTerm extends GuiMEMonitorable implement
private GuiImgButton maxCountBtn;
public Map<IGhostIngredientHandler.Target<?>, Object> mapTargetSlot = new HashMap<>();
public GuiExpandedProcessingPatternTerm( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( inventoryPlayer, te, new ContainerExpandedProcessingPatternTerm( inventoryPlayer, te ) );
this.setReservedSpace( 81 );
public GuiExpandedProcessingPatternTerm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(inventoryPlayer, te, new ContainerExpandedProcessingPatternTerm(inventoryPlayer, te));
this.setReservedSpace(81);
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
try
{
try {
if( this.tabCraftButton == btn || this.tabProcessButton == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING ) );
if (this.tabCraftButton == btn || this.tabProcessButton == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING));
}
if( this.encodeBtn == btn )
{
if( isShiftKeyDown() )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "2" ) );
}
else
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
if (this.encodeBtn == btn) {
if (isShiftKeyDown()) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Encode", "2"));
} else {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Encode", "1"));
}
}
if( this.clearBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) );
if (this.clearBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Clear", "1"));
}
if( this.x2Btn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MultiplyByTwo", "1" ) );
if (this.x2Btn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.MultiplyByTwo", "1"));
}
if( this.x3Btn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MultiplyByThree", "1" ) );
if (this.x3Btn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.MultiplyByThree", "1"));
}
if( this.divTwoBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DivideByTwo", "1" ) );
if (this.divTwoBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.DivideByTwo", "1"));
}
if( this.divThreeBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DivideByThree", "1" ) );
if (this.divThreeBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.DivideByThree", "1"));
}
if( this.plusOneBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.IncreaseByOne", "1" ) );
if (this.plusOneBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.IncreaseByOne", "1"));
}
if( this.minusOneBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DecreaseByOne", "1" ) );
if (this.minusOneBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.DecreaseByOne", "1"));
}
if( this.maxCountBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MaximizeCount", "1" ) );
if (this.maxCountBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.MaximizeCount", "1"));
}
if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE));
}
}
catch( final IOException e )
{
AELog.error( e );
} catch (final IOException e) {
AELog.error(e);
}
}
@Override
public void initGui()
{
public void initGui() {
super.initGui();
this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.CRAFTING_TABLE ), GuiText.CraftingPattern.getLocal(), this.itemRender );
this.buttonList.add( this.tabCraftButton );
this.tabCraftButton = new GuiTabButton(this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack(Blocks.CRAFTING_TABLE), GuiText.CraftingPattern.getLocal(), this.itemRender);
this.buttonList.add(this.tabCraftButton);
this.tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.FURNACE ), GuiText.ProcessingPattern.getLocal(), this.itemRender );
this.buttonList.add( this.tabProcessButton );
this.tabProcessButton = new GuiTabButton(this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack(Blocks.FURNACE), GuiText.ProcessingPattern.getLocal(), this.itemRender);
this.buttonList.add(this.tabProcessButton);
this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED );
this.substitutionsEnabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsEnabledBtn );
this.substitutionsEnabledBtn = new GuiImgButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED);
this.substitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsEnabledBtn);
this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED );
this.substitutionsDisabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsDisabledBtn );
this.substitutionsDisabledBtn = new GuiImgButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED);
this.substitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsDisabledBtn);
this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
this.clearBtn.setHalfSize( true );
this.buttonList.add( this.clearBtn );
this.clearBtn = new GuiImgButton(this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
this.buttonList.add(this.clearBtn);
this.x3Btn = new GuiImgButton( this.guiLeft + 131, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.MULTIPLY_BY_THREE );
this.x3Btn.setHalfSize( true );
this.buttonList.add( this.x3Btn );
this.x3Btn = new GuiImgButton(this.guiLeft + 131, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.MULTIPLY_BY_THREE);
this.x3Btn.setHalfSize(true);
this.buttonList.add(this.x3Btn);
this.x2Btn = new GuiImgButton( this.guiLeft + 131, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.MULTIPLY_BY_TWO );
this.x2Btn.setHalfSize( true );
this.buttonList.add( this.x2Btn );
this.x2Btn = new GuiImgButton(this.guiLeft + 131, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.MULTIPLY_BY_TWO);
this.x2Btn.setHalfSize(true);
this.buttonList.add(this.x2Btn);
this.plusOneBtn = new GuiImgButton( this.guiLeft + 131, this.guiTop + this.ySize - 110, Settings.ACTIONS, ActionItems.INCREASE_BY_ONE );
this.plusOneBtn.setHalfSize( true );
this.buttonList.add( this.plusOneBtn );
this.plusOneBtn = new GuiImgButton(this.guiLeft + 131, this.guiTop + this.ySize - 110, Settings.ACTIONS, ActionItems.INCREASE_BY_ONE);
this.plusOneBtn.setHalfSize(true);
this.buttonList.add(this.plusOneBtn);
this.divThreeBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.DIVIDE_BY_THREE );
this.divThreeBtn.setHalfSize( true );
this.buttonList.add( this.divThreeBtn );
this.divThreeBtn = new GuiImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.DIVIDE_BY_THREE);
this.divThreeBtn.setHalfSize(true);
this.buttonList.add(this.divThreeBtn);
this.divTwoBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.DIVIDE_BY_TWO );
this.divTwoBtn.setHalfSize( true );
this.buttonList.add( this.divTwoBtn );
this.divTwoBtn = new GuiImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.DIVIDE_BY_TWO);
this.divTwoBtn.setHalfSize(true);
this.buttonList.add(this.divTwoBtn);
this.minusOneBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 110, Settings.ACTIONS, ActionItems.DECREASE_BY_ONE );
this.minusOneBtn.setHalfSize( true );
this.buttonList.add( this.minusOneBtn );
this.minusOneBtn = new GuiImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 110, Settings.ACTIONS, ActionItems.DECREASE_BY_ONE);
this.minusOneBtn.setHalfSize(true);
this.buttonList.add(this.minusOneBtn);
//this.maxCountBtn = new GuiImgButton( this.guiLeft + 128, this.guiTop + this.ySize - 108, Settings.ACTIONS, ActionItems.MAX_COUNT );
//this.maxCountBtn.setHalfSize( true );
//this.buttonList.add( this.maxCountBtn );
this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE );
this.buttonList.add( this.encodeBtn );
this.encodeBtn = new GuiImgButton(this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE);
this.buttonList.add(this.encodeBtn);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.tabCraftButton.visible = false;
this.tabProcessButton.visible = true;
this.substitutionsEnabledBtn.visible = false;
@@ -206,71 +185,58 @@ public class GuiExpandedProcessingPatternTerm extends GuiMEMonitorable implement
this.minusOneBtn.visible = true;
//this.maxCountBtn.visible = true;
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRenderer.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - this.getReservedSpace(), 4210752 );
super.drawFG(offsetX, offsetY, mouseX, mouseY);
this.fontRenderer.drawString(GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - this.getReservedSpace(), 4210752);
}
@Override
protected String getBackground()
{
protected String getBackground() {
return BACKGROUND_EXPANDED_PROCESSING_MODE;
}
@Override
protected void repositionSlot( final AppEngSlot s )
{
protected void repositionSlot(final AppEngSlot s) {
final int offsetPlayerSide = s.isPlayerSide() ? 5 : 3;
s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide;
}
@Override
public List<IGhostIngredientHandler.Target<?>> getPhantomTargets( Object ingredient )
{
if( !( ingredient instanceof ItemStack ) )
{
public List<IGhostIngredientHandler.Target<?>> getPhantomTargets(Object ingredient) {
if (!(ingredient instanceof ItemStack)) {
return Collections.emptyList();
}
List<IGhostIngredientHandler.Target<?>> targets = new ArrayList<>();
for( Slot slot : this.inventorySlots.inventorySlots )
{
if( slot instanceof SlotFake )
{
for (Slot slot : this.inventorySlots.inventorySlots) {
if (slot instanceof SlotFake) {
ItemStack itemStack = (ItemStack) ingredient;
IGhostIngredientHandler.Target<Object> target = new IGhostIngredientHandler.Target<Object>()
{
IGhostIngredientHandler.Target<Object> target = new IGhostIngredientHandler.Target<Object>() {
@Override
public Rectangle getArea()
{
return new Rectangle( getGuiLeft() + slot.xPos, getGuiTop() + slot.yPos, 16, 16 );
public Rectangle getArea() {
return new Rectangle(getGuiLeft() + slot.xPos, getGuiTop() + slot.yPos, 16, 16);
}
@Override
public void accept( Object ingredient )
{
public void accept(Object ingredient) {
final PacketInventoryAction p;
try
{
p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (SlotFake) slot, AEItemStack.fromItemStack( itemStack ) );
NetworkHandler.instance().sendToServer( p );
try {
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (SlotFake) slot, AEItemStack.fromItemStack(itemStack));
NetworkHandler.instance().sendToServer(p);
}
catch( IOException e )
{
} catch (IOException e) {
e.printStackTrace();
}
}
};
targets.add( target );
mapTargetSlot.putIfAbsent( target, slot );
targets.add(target);
mapTargetSlot.putIfAbsent(target, slot);
}
}
return targets;
}
@Override
public Map<IGhostIngredientHandler.Target<?>, Object> getFakeSlotTargetMap()
{
public Map<IGhostIngredientHandler.Target<?>, Object> getFakeSlotTargetMap() {
return mapTargetSlot;
}
}
@@ -19,13 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
@@ -38,69 +31,63 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.parts.automation.PartFormationPlane;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import java.io.IOException;
public class GuiFormationPlane extends GuiUpgradeable
{
public class GuiFormationPlane extends GuiUpgradeable {
private GuiTabButton priority;
private GuiImgButton placeMode;
private GuiTabButton priority;
private GuiImgButton placeMode;
public GuiFormationPlane( final InventoryPlayer inventoryPlayer, final PartFormationPlane te )
{
super( new ContainerFormationPlane( inventoryPlayer, te ) );
this.ySize = 251;
}
public GuiFormationPlane(final InventoryPlayer inventoryPlayer, final PartFormationPlane te) {
super(new ContainerFormationPlane(inventoryPlayer, te));
this.ySize = 251;
}
@Override
protected void addButtons()
{
this.placeMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK, YesNo.YES );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
@Override
protected void addButtons() {
this.placeMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK, YesNo.YES);
this.fuzzyMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
this.buttonList.add( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
this.buttonList.add(this.priority = new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender));
this.buttonList.add( this.placeMode );
this.buttonList.add( this.fuzzyMode );
}
this.buttonList.add(this.placeMode);
this.buttonList.add(this.fuzzyMode);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.FormationPlane.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.FormationPlane.getLocal()), 8, 6, 4210752);
this.fontRenderer.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";
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
if( btn == this.priority )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
else if( btn == this.placeMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.placeMode.getSetting(), backwards ) );
}
}
if (btn == this.priority) {
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PRIORITY));
} else if (btn == this.placeMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.placeMode.getSetting(), backwards));
}
}
}
@@ -19,34 +19,29 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.container.implementations.ContainerGrinder;
import appeng.core.localization.GuiText;
import appeng.tile.grindstone.TileGrinder;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiGrinder extends AEBaseGui
{
public class GuiGrinder extends AEBaseGui {
public GuiGrinder( final InventoryPlayer inventoryPlayer, final TileGrinder te )
{
super( new ContainerGrinder( inventoryPlayer, te ) );
this.ySize = 176;
}
public GuiGrinder(final InventoryPlayer inventoryPlayer, final TileGrinder te) {
super(new ContainerGrinder(inventoryPlayer, te));
this.ySize = 176;
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.GrindStone.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.GrindStone.getLocal()), 8, 6, 4210752);
this.fontRenderer.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 )
{
this.bindTexture( "guis/grinder.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/grinder.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}
@@ -19,13 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.AEApi;
import appeng.api.config.FullnessMode;
import appeng.api.config.OperationMode;
@@ -38,87 +31,80 @@ import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.tile.storage.TileIOPort;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import java.io.IOException;
public class GuiIOPort extends GuiUpgradeable
{
public class GuiIOPort extends GuiUpgradeable {
private GuiImgButton fullMode;
private GuiImgButton operationMode;
private GuiImgButton fullMode;
private GuiImgButton operationMode;
public GuiIOPort( final InventoryPlayer inventoryPlayer, final TileIOPort te )
{
super( new ContainerIOPort( inventoryPlayer, te ) );
this.ySize = 166;
}
public GuiIOPort(final InventoryPlayer inventoryPlayer, final TileIOPort te) {
super(new ContainerIOPort(inventoryPlayer, te));
this.ySize = 166;
}
@Override
protected void addButtons()
{
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
this.fullMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY );
this.operationMode = new GuiImgButton( this.guiLeft + 80, this.guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY );
@Override
protected void addButtons() {
this.redstoneMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
this.fullMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY);
this.operationMode = new GuiImgButton(this.guiLeft + 80, this.guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY);
this.buttonList.add( this.operationMode );
this.buttonList.add( this.redstoneMode );
this.buttonList.add( this.fullMode );
}
this.buttonList.add(this.operationMode);
this.buttonList.add(this.redstoneMode);
this.buttonList.add(this.fullMode);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.IOPort.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.IOPort.getLocal()), 8, 6, 4210752);
this.fontRenderer.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 )
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawBG(offsetX, offsetY, mouseX, mouseY);
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";
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
if( btn == this.fullMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.fullMode.getSetting(), backwards ) );
}
if (btn == this.fullMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.fullMode.getSetting(), backwards));
}
if( btn == this.operationMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.operationMode.getSetting(), backwards ) );
}
}
if (btn == this.operationMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.operationMode.getSetting(), backwards));
}
}
}
@@ -19,8 +19,6 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiProgressBar;
import appeng.client.gui.widgets.GuiProgressBar.Direction;
@@ -28,66 +26,58 @@ import appeng.container.implementations.ContainerInscriber;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.core.localization.GuiText;
import appeng.tile.misc.TileInscriber;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiInscriber extends AEBaseGui
{
public class GuiInscriber extends AEBaseGui {
private final ContainerInscriber cvc;
private GuiProgressBar pb;
private final ContainerInscriber cvc;
private GuiProgressBar pb;
public GuiInscriber( final InventoryPlayer inventoryPlayer, final TileInscriber te )
{
super( new ContainerInscriber( inventoryPlayer, te ) );
this.cvc = (ContainerInscriber) this.inventorySlots;
this.ySize = 176;
this.xSize = this.hasToolbox() ? 246 : 211;
}
public GuiInscriber(final InventoryPlayer inventoryPlayer, final TileInscriber te) {
super(new ContainerInscriber(inventoryPlayer, te));
this.cvc = (ContainerInscriber) this.inventorySlots;
this.ySize = 176;
this.xSize = this.hasToolbox() ? 246 : 211;
}
private boolean hasToolbox()
{
return ( (ContainerUpgradeable) this.inventorySlots ).hasToolbox();
}
private boolean hasToolbox() {
return ((ContainerUpgradeable) this.inventorySlots).hasToolbox();
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.pb = new GuiProgressBar( this.cvc, "guis/inscriber.png", 135, 39, 135, 177, 6, 18, Direction.VERTICAL );
this.buttonList.add( this.pb );
}
this.pb = new GuiProgressBar(this.cvc, "guis/inscriber.png", 135, 39, 135, 177, 6, 18, Direction.VERTICAL);
this.buttonList.add(this.pb);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.pb.setFullMsg( this.cvc.getCurrentProgress() * 100 / this.cvc.getMaxProgress() + "%" );
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.pb.setFullMsg(this.cvc.getCurrentProgress() * 100 / this.cvc.getMaxProgress() + "%");
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.Inscriber.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.Inscriber.getLocal()), 8, 6, 4210752);
this.fontRenderer.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 )
{
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) {
this.bindTexture("guis/inscriber.png");
this.pb.x = 135 + this.guiLeft;
this.pb.y = 39 + this.guiTop;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize );
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, 211 - 34, this.ySize);
if( this.drawUpgrades() )
{
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvc.availableUpgrades() * 18 );
}
if( this.hasToolbox() )
{
this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68 );
}
}
if (this.drawUpgrades()) {
this.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvc.availableUpgrades() * 18);
}
if (this.hasToolbox()) {
this.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68);
}
}
private boolean drawUpgrades()
{
return true;
}
private boolean drawUpgrades() {
return true;
}
}
@@ -19,13 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.client.gui.widgets.GuiImgButton;
@@ -38,90 +31,81 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.helpers.IInterfaceHost;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import java.io.IOException;
public class GuiInterface extends GuiUpgradeable
{
public class GuiInterface extends GuiUpgradeable {
private GuiTabButton priority;
private GuiImgButton BlockMode;
private GuiToggleButton interfaceMode;
private GuiTabButton priority;
private GuiImgButton BlockMode;
private GuiToggleButton interfaceMode;
public GuiInterface( final InventoryPlayer inventoryPlayer, final IInterfaceHost te )
{
super( new ContainerInterface( inventoryPlayer, te ) );
this.ySize = 256;
}
public GuiInterface(final InventoryPlayer inventoryPlayer, final IInterfaceHost te) {
super(new ContainerInterface(inventoryPlayer, te));
this.ySize = 256;
}
@Override
protected void addButtons()
{
this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender );
this.buttonList.add( this.priority );
@Override
protected void addButtons() {
this.priority = new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender);
this.buttonList.add(this.priority);
this.BlockMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO );
this.buttonList.add( this.BlockMode );
this.BlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO);
this.buttonList.add(this.BlockMode);
this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal() );
this.buttonList.add( this.interfaceMode );
}
this.interfaceMode = new GuiToggleButton(this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal());
this.buttonList.add(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.fontRenderer.drawString( this.getGuiDisplayName( GuiText.Interface.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.Interface.getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString( GuiText.Config.getLocal(), 8, 6 + 11 + 7, 4210752 );
this.fontRenderer.drawString( GuiText.StoredItems.getLocal(), 8, 6 + 60 + 7, 4210752 );
this.fontRenderer.drawString( GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752 );
this.fontRenderer.drawString(GuiText.Config.getLocal(), 8, 6 + 11 + 7, 4210752);
this.fontRenderer.drawString(GuiText.StoredItems.getLocal(), 8, 6 + 60 + 7, 4210752);
this.fontRenderer.drawString(GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752);
}
}
@Override
protected String getBackground()
{
int upgrades = ( (ContainerInterface) this.cvb ).getPatternUpgrades();
if( upgrades == 0 )
{
return "guis/newinterface.png";
}
else
{
return "guis/newinterface" + upgrades + ".png";
}
}
@Override
protected String getBackground() {
int upgrades = ((ContainerInterface) this.cvb).getPatternUpgrades();
if (upgrades == 0) {
return "guis/newinterface.png";
} else {
return "guis/newinterface" + upgrades + ".png";
}
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
if( btn == this.priority )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
if (btn == this.priority) {
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PRIORITY));
}
if( btn == this.interfaceMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
}
if (btn == this.interfaceMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(Settings.INTERFACE_TERMINAL, backwards));
}
if( btn == this.BlockMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.BlockMode.getSetting(), backwards ) );
}
}
if (btn == this.BlockMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.BlockMode.getSetting(), backwards));
}
}
}
@@ -19,25 +19,28 @@
package appeng.client.gui.implementations;
import java.awt.*;
import java.io.IOException;
import java.util.*;
import java.util.List;
import appeng.api.AEApi;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected;
import appeng.container.implementations.ContainerInterfaceConfigurationTerminal;
import appeng.container.interfaces.IJEIGhostIngredients;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.DualityInterface;
import appeng.helpers.InventoryAction;
import appeng.parts.reporting.PartInterfaceConfigurationTerminal;
import appeng.util.BlockPosUtils;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import com.google.common.collect.HashMultimap;
import mezz.jei.api.gui.IGhostIngredientHandler;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
@@ -45,531 +48,436 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.common.DimensionManager;
import org.lwjgl.input.Mouse;
import java.awt.*;
import java.io.IOException;
import java.util.List;
import java.util.*;
import static appeng.client.render.BlockPosHighlighter.hilightBlock;
public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEIGhostIngredients
{
private static final int LINES_ON_PAGE = 6;
// TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded?
private final int offsetX = 21;
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
private final HashMap<ClientDCInternalInv, BlockPos> blockPosHashMap = new HashMap<>();
private final HashMap<GuiButton, ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
private final Map<ClientDCInternalInv, Integer> numUpgradesMap = new HashMap<>();
private final ArrayList<String> names = new ArrayList<>();
private final ArrayList<Object> lines = new ArrayList<>();
private final Set<Object> matchedStacks = new HashSet<>();
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
private boolean refreshList = false;
private MEGuiTextField searchFieldInputs;
private PartInterfaceConfigurationTerminal partInterfaceTerminal;
private HashMap<ClientDCInternalInv, Integer> dimHashMap = new HashMap<>();
public Map<IGhostIngredientHandler.Target<?>, Object> mapTargetSlot = new HashMap<>();
public GuiInterfaceConfigurationTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceConfigurationTerminal te )
{
super( new ContainerInterfaceConfigurationTerminal( inventoryPlayer, te ) );
this.partInterfaceTerminal = te;
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar );
this.xSize = 208;
this.ySize = 235;
}
@Override
public void initGui()
{
super.initGui();
this.getScrollBar().setLeft( 189 );
this.getScrollBar().setHeight( 106 );
this.getScrollBar().setTop( 31 );
this.searchFieldInputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 32, this.offsetX ), this.guiTop + 17, 65, 12 );
this.searchFieldInputs.setEnableBackgroundDrawing( false );
this.searchFieldInputs.setMaxStringLength( 25 );
this.searchFieldInputs.setTextColor( 0xFFFFFF );
this.searchFieldInputs.setVisible( true );
this.searchFieldInputs.setFocused( false );
this.searchFieldInputs.setText( partInterfaceTerminal.in );
}
@Override
public void onGuiClosed()
{
partInterfaceTerminal.saveSearchStrings( this.searchFieldInputs.getText().toLowerCase() );
super.onGuiClosed();
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.buttonList.clear();
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.InterfaceConfigurationTerminal.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.drawString( GuiText.inventory.getLocal(), this.offsetX + 2, this.ySize - 96 + 3, 4210752 );
final int currentScroll = this.getScrollBar().getCurrentScroll();
this.inventorySlots.inventorySlots.removeIf( slot -> slot instanceof SlotDisconnected );
int offset = 30;
int linesDraw = 0;
for( int x = 0; x < LINES_ON_PAGE && linesDraw < LINES_ON_PAGE && currentScroll + x < this.lines.size(); x++ )
{
final Object lineObj = this.lines.get( currentScroll + x );
if( lineObj instanceof ClientDCInternalInv )
{
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
GuiButton guiButton = new GuiImgButton( guiLeft + 4, guiTop + offset, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE );
guiButtonHashMap.put( guiButton, inv );
this.buttonList.add( guiButton );
int extraLines = numUpgradesMap.get( inv );
for( int row = 0; row < 1 + extraLines && linesDraw < LINES_ON_PAGE; ++row )
{
for( int z = 0; z < 9; z++ )
{
this.inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z + ( row * 9 ), ( z * 18 + 22 ), offset ) );
if( this.matchedStacks.contains( inv.getInventory().getStackInSlot( z + ( row * 9 ) ) ) )
{
drawRect( z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x2A00FF00 );
}
}
linesDraw++;
offset += 18;
}
}
else if( lineObj instanceof String )
{
String name = (String) lineObj;
final int rows = this.byName.get( name ).size();
if( rows > 1 )
{
name = name + " (" + rows + ')';
}
while ( name.length() > 2 && this.fontRenderer.getStringWidth( name ) > 155 )
{
name = name.substring( 0, name.length() - 1 );
}
this.fontRenderer.drawString( name, this.offsetX + 2, 5 + offset, 4210752 );
linesDraw++;
offset += 18;
}
}
if( searchFieldInputs.isMouseIn( mouseX, mouseY ) )
{
drawTooltip( Mouse.getEventX() * this.width / this.mc.displayWidth - offsetX, mouseY - guiTop, "Inputs OR names" );
}
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
{
this.searchFieldInputs.mouseClicked( xCoord, yCoord, btn );
if( btn == 1 && this.searchFieldInputs.isMouseIn( xCoord, yCoord ) )
{
this.searchFieldInputs.setText( "" );
this.refreshList();
}
super.mouseClicked( xCoord, yCoord, btn );
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
if( guiButtonHashMap.containsKey( btn ) )
{
BlockPos blockPos = blockPosHashMap.get( guiButtonHashMap.get( this.selectedButton ) );
BlockPos blockPos2 = mc.player.getPosition();
int playerDim = mc.world.provider.getDimension();
int interfaceDim = dimHashMap.get( guiButtonHashMap.get( this.selectedButton ) );
if( playerDim != interfaceDim )
{
try
{
mc.player.sendStatusMessage( new TextComponentString( "Interface located at dimension: " + interfaceDim + " [" + DimensionManager.getWorld( interfaceDim ).provider.getDimensionType().getName() + "] and cant be highlighted" ), false );
}
catch( Exception e )
{
mc.player.sendStatusMessage( new TextComponentString( "Interface is located in another dimension and cannot be highlighted" ), false );
}
}
else
{
hilightBlock( blockPos, System.currentTimeMillis() + 500 * BlockPosUtils.getDistance( blockPos, blockPos2 ), playerDim );
mc.player.sendStatusMessage( new TextComponentString( "The interface is now highlighted at " + "X: " + blockPos.getX() + " Y: " + blockPos.getY() + " Z: " + blockPos.getZ() ), false );
}
mc.player.closeScreen();
}
}
@Override
protected void mouseWheelEvent( final int x, final int y, final int wheel )
{
final Slot slot = this.getSlot( x, y );
if( slot instanceof SlotDisconnected )
{
final ItemStack stack = slot.getStack();
if( stack != ItemStack.EMPTY )
{
InventoryAction direction = wheel > 0 ? InventoryAction.PLACE_SINGLE : InventoryAction.PICKUP_SINGLE;
final PacketInventoryAction p = new PacketInventoryAction( direction, slot.getSlotIndex(), ( (SlotDisconnected) slot ).getSlot().getId() );
NetworkHandler.instance().sendToServer( p );
}
}
else
{
super.mouseWheelEvent( x, y, wheel );
}
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.bindTexture( "guis/interfaceconfigurationterminal.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
int offset = 29;
final int ex = this.getScrollBar().getCurrentScroll();
int linesDraw = 0;
for( int x = 0; x < LINES_ON_PAGE && linesDraw < LINES_ON_PAGE && ex + x < this.lines.size(); x++ )
{
final Object lineObj = this.lines.get( ex + x );
if( lineObj instanceof ClientDCInternalInv )
{
GlStateManager.color( 1, 1, 1, 1 );
final int width = 9 * 18;
int extraLines = numUpgradesMap.get( lineObj );
for( int row = 0; row < 1 + extraLines && linesDraw < LINES_ON_PAGE; ++row )
{
this.drawTexturedModalRect( offsetX + 20, offsetY + offset, 20, 170, width, 18 );
offset += 18;
linesDraw++;
}
}
else
{
offset += 18;
linesDraw++;
}
}
if( this.searchFieldInputs != null )
{
this.searchFieldInputs.drawTextBox();
}
}
@Override
protected void keyTyped( final char character, final int key ) throws IOException
{
if( !this.checkHotbarKeys( key ) )
{
if( character == ' ' && this.searchFieldInputs.getText().isEmpty() && this.searchFieldInputs.isFocused() )
{
return;
}
if( this.searchFieldInputs.textboxKeyTyped( character, key ) )
{
this.refreshList();
}
else
{
super.keyTyped( character, key );
}
}
}
public void postUpdate( final NBTTagCompound in )
{
if( in.getBoolean( "clear" ) )
{
this.byId.clear();
this.refreshList = true;
}
for( final Object oKey : in.getKeySet() )
{
final String key = (String) oKey;
if( key.startsWith( "=" ) )
{
try
{
final long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX );
final NBTTagCompound invData = in.getCompoundTag( key );
final ClientDCInternalInv current = this.getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
blockPosHashMap.put( current, NBTUtil.getPosFromTag( invData.getCompoundTag( "pos" ) ) );
dimHashMap.put( current, invData.getInteger( "dim" ) );
numUpgradesMap.put( current, invData.getInteger( "numUpgrades" ) );
for( int x = 0; x < current.getInventory().getSlots(); x++ )
{
final String which = Integer.toString( x );
if( invData.hasKey( which ) )
{
current.getInventory().setStackInSlot( x, new ItemStack( invData.getCompoundTag( which ) ) );
}
}
}
catch( final NumberFormatException ignored )
{
}
}
}
if( this.refreshList )
{
this.refreshList = false;
// invalid caches on refresh
this.cachedSearches.clear();
this.refreshList();
}
}
/**
* Rebuilds the list of interfaces.
* <p>
* Respects a search term if present (ignores case) and adding only matching patterns.
*/
private void refreshList()
{
this.byName.clear();
this.buttonList.clear();
this.matchedStacks.clear();
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
final Set<Object> cachedSearch = this.getCacheForSearchTerm( searchFieldInputs );
final boolean rebuild = cachedSearch.isEmpty();
for( final ClientDCInternalInv entry : this.byId.values() )
{
// ignore inventory if not doing a full rebuild and cache already marks it as miss.
if( !rebuild && !cachedSearch.contains( entry ) )
{
continue;
}
// Shortcut to skip any filter if search term is ""/empty
boolean found = searchFieldInputs.isEmpty();
// Search if the current inventory holds a pattern containing the search term.
if( !found )
{
int slot = 0;
for( final ItemStack itemStack : entry.getInventory() )
{
if( slot > 8 + numUpgradesMap.get( entry ) * 9 )
{
break;
}
if( this.itemStackMatchesSearchTerm( itemStack, searchFieldInputs ) )
{
found = true;
matchedStacks.add( itemStack );
}
slot++;
}
}
// if found, filter skipped or machine name matching the search term, add it
if( found || entry.getName().toLowerCase().contains( searchFieldInputs ) )
{
this.byName.put( entry.getName(), entry );
cachedSearch.add( entry );
}
else
{
cachedSearch.remove( entry );
}
}
this.names.clear();
this.names.addAll( this.byName.keySet() );
Collections.sort( this.names );
this.lines.clear();
this.lines.ensureCapacity( this.getMaxRows() );
for( final String n : this.names )
{
this.lines.add( n );
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>();
clientInventories.addAll( this.byName.get( n ) );
Collections.sort( clientInventories );
this.lines.addAll( clientInventories );
}
this.getScrollBar().setRange( 0, this.lines.size() - 1, 1 );
}
private boolean itemStackMatchesSearchTerm( final ItemStack itemStack, final String searchTerm )
{
if( itemStack.isEmpty() )
{
return false;
}
boolean foundMatchingItemStack = false;
final String displayName = Platform
.getItemDisplayName( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( itemStack ) )
.toLowerCase();
for( String term : searchTerm.split( " " ) )
{
if( term.length() > 1 && ( term.startsWith( "-" ) || term.startsWith( "!" ) ) )
{
term = term.substring( 1 );
if( displayName.contains( term ) )
{
return false;
}
}
else if( displayName.contains( term ) )
{
foundMatchingItemStack = true;
}
}
return foundMatchingItemStack;
}
/**
* Tries to retrieve a cache for a with search term as keyword.
* <p>
* 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 Set<Object> cache = this.cachedSearches.get( searchTerm );
if( cache.isEmpty() && searchTerm.length() > 1 )
{
cache.addAll( this.getCacheForSearchTerm( searchTerm.substring( 0, searchTerm.length() - 1 ) ) );
return cache;
}
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();
}
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( DualityInterface.NUMBER_OF_CONFIG_SLOTS, id, sortBy, string, 64 ) );
this.refreshList = true;
}
return o;
}
@Override
public List<IGhostIngredientHandler.Target<?>> getPhantomTargets( Object ingredient )
{
if( !( ingredient instanceof ItemStack ) )
{
return Collections.emptyList();
}
List<IGhostIngredientHandler.Target<?>> targets = new ArrayList<>();
for( Slot slot : this.inventorySlots.inventorySlots )
{
if( slot instanceof SlotDisconnected )
{
ItemStack itemStack = (ItemStack) ingredient;
IGhostIngredientHandler.Target<Object> target = new IGhostIngredientHandler.Target<Object>()
{
@Override
public Rectangle getArea()
{
return new Rectangle( getGuiLeft() + slot.xPos, getGuiTop() + slot.yPos, 16, 16 );
}
@Override
public void accept( Object ingredient )
{
final PacketInventoryAction p;
try
{
p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (SlotDisconnected) slot, AEItemStack.fromItemStack( itemStack ) );
NetworkHandler.instance().sendToServer( p );
}
catch( IOException e )
{
e.printStackTrace();
}
}
};
targets.add( target );
mapTargetSlot.putIfAbsent( target, slot );
}
}
return targets;
}
@Override
public Map<IGhostIngredientHandler.Target<?>, Object> getFakeSlotTargetMap()
{
return IJEIGhostIngredients.super.getFakeSlotTargetMap();
}
public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEIGhostIngredients {
private static final int LINES_ON_PAGE = 6;
// TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded?
private final int offsetX = 21;
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
private final HashMap<ClientDCInternalInv, BlockPos> blockPosHashMap = new HashMap<>();
private final HashMap<GuiButton, ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
private final Map<ClientDCInternalInv, Integer> numUpgradesMap = new HashMap<>();
private final ArrayList<String> names = new ArrayList<>();
private final ArrayList<Object> lines = new ArrayList<>();
private final Set<Object> matchedStacks = new HashSet<>();
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
private boolean refreshList = false;
private MEGuiTextField searchFieldInputs;
private final PartInterfaceConfigurationTerminal partInterfaceTerminal;
private final HashMap<ClientDCInternalInv, Integer> dimHashMap = new HashMap<>();
public Map<IGhostIngredientHandler.Target<?>, Object> mapTargetSlot = new HashMap<>();
public GuiInterfaceConfigurationTerminal(final InventoryPlayer inventoryPlayer, final PartInterfaceConfigurationTerminal te) {
super(new ContainerInterfaceConfigurationTerminal(inventoryPlayer, te));
this.partInterfaceTerminal = te;
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar(scrollbar);
this.xSize = 208;
this.ySize = 235;
}
@Override
public void initGui() {
super.initGui();
this.getScrollBar().setLeft(189);
this.getScrollBar().setHeight(106);
this.getScrollBar().setTop(31);
this.searchFieldInputs = new MEGuiTextField(this.fontRenderer, this.guiLeft + Math.max(32, this.offsetX), this.guiTop + 17, 65, 12);
this.searchFieldInputs.setEnableBackgroundDrawing(false);
this.searchFieldInputs.setMaxStringLength(25);
this.searchFieldInputs.setTextColor(0xFFFFFF);
this.searchFieldInputs.setVisible(true);
this.searchFieldInputs.setFocused(false);
this.searchFieldInputs.setText(partInterfaceTerminal.in);
}
@Override
public void onGuiClosed() {
partInterfaceTerminal.saveSearchStrings(this.searchFieldInputs.getText().toLowerCase());
super.onGuiClosed();
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.buttonList.clear();
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.InterfaceConfigurationTerminal.getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), this.offsetX + 2, this.ySize - 96 + 3, 4210752);
final int currentScroll = this.getScrollBar().getCurrentScroll();
this.inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected);
int offset = 30;
int linesDraw = 0;
for (int x = 0; x < LINES_ON_PAGE && linesDraw < LINES_ON_PAGE && currentScroll + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(currentScroll + x);
if (lineObj instanceof ClientDCInternalInv) {
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
GuiButton guiButton = new GuiImgButton(guiLeft + 4, guiTop + offset, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE);
guiButtonHashMap.put(guiButton, inv);
this.buttonList.add(guiButton);
int extraLines = numUpgradesMap.get(inv);
for (int row = 0; row < 1 + extraLines && linesDraw < LINES_ON_PAGE; ++row) {
for (int z = 0; z < 9; z++) {
this.inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z + (row * 9), (z * 18 + 22), offset));
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z + (row * 9)))) {
drawRect(z * 18 + 22, offset, z * 18 + 22 + 16, offset + 16, 0x2A00FF00);
}
}
linesDraw++;
offset += 18;
}
} else if (lineObj instanceof String) {
String name = (String) lineObj;
final int rows = this.byName.get(name).size();
if (rows > 1) {
name = name + " (" + rows + ')';
}
while (name.length() > 2 && this.fontRenderer.getStringWidth(name) > 155) {
name = name.substring(0, name.length() - 1);
}
this.fontRenderer.drawString(name, this.offsetX + 2, 5 + offset, 4210752);
linesDraw++;
offset += 18;
}
}
if (searchFieldInputs.isMouseIn(mouseX, mouseY)) {
drawTooltip(Mouse.getEventX() * this.width / this.mc.displayWidth - offsetX, mouseY - guiTop, "Inputs OR names");
}
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) throws IOException {
this.searchFieldInputs.mouseClicked(xCoord, yCoord, btn);
if (btn == 1 && this.searchFieldInputs.isMouseIn(xCoord, yCoord)) {
this.searchFieldInputs.setText("");
this.refreshList();
}
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
if (guiButtonHashMap.containsKey(btn)) {
BlockPos blockPos = blockPosHashMap.get(guiButtonHashMap.get(this.selectedButton));
BlockPos blockPos2 = mc.player.getPosition();
int playerDim = mc.world.provider.getDimension();
int interfaceDim = dimHashMap.get(guiButtonHashMap.get(this.selectedButton));
if (playerDim != interfaceDim) {
try {
mc.player.sendStatusMessage(new TextComponentString("Interface located at dimension: " + interfaceDim + " [" + DimensionManager.getWorld(interfaceDim).provider.getDimensionType().getName() + "] and cant be highlighted"), false);
} catch (Exception e) {
mc.player.sendStatusMessage(new TextComponentString("Interface is located in another dimension and cannot be highlighted"), false);
}
} else {
hilightBlock(blockPos, System.currentTimeMillis() + 500 * BlockPosUtils.getDistance(blockPos, blockPos2), playerDim);
mc.player.sendStatusMessage(new TextComponentString("The interface is now highlighted at " + "X: " + blockPos.getX() + " Y: " + blockPos.getY() + " Z: " + blockPos.getZ()), false);
}
mc.player.closeScreen();
}
}
@Override
protected void mouseWheelEvent(final int x, final int y, final int wheel) {
final Slot slot = this.getSlot(x, y);
if (slot instanceof SlotDisconnected) {
final ItemStack stack = slot.getStack();
if (stack != ItemStack.EMPTY) {
InventoryAction direction = wheel > 0 ? InventoryAction.PLACE_SINGLE : InventoryAction.PICKUP_SINGLE;
final PacketInventoryAction p = new PacketInventoryAction(direction, slot.getSlotIndex(), ((SlotDisconnected) slot).getSlot().getId());
NetworkHandler.instance().sendToServer(p);
}
} else {
super.mouseWheelEvent(x, y, wheel);
}
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/interfaceconfigurationterminal.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
int offset = 29;
final int ex = this.getScrollBar().getCurrentScroll();
int linesDraw = 0;
for (int x = 0; x < LINES_ON_PAGE && linesDraw < LINES_ON_PAGE && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof ClientDCInternalInv) {
GlStateManager.color(1, 1, 1, 1);
final int width = 9 * 18;
int extraLines = numUpgradesMap.get(lineObj);
for (int row = 0; row < 1 + extraLines && linesDraw < LINES_ON_PAGE; ++row) {
this.drawTexturedModalRect(offsetX + 20, offsetY + offset, 20, 170, width, 18);
offset += 18;
linesDraw++;
}
} else {
offset += 18;
linesDraw++;
}
}
if (this.searchFieldInputs != null) {
this.searchFieldInputs.drawTextBox();
}
}
@Override
protected void keyTyped(final char character, final int key) throws IOException {
if (!this.checkHotbarKeys(key)) {
if (character == ' ' && this.searchFieldInputs.getText().isEmpty() && this.searchFieldInputs.isFocused()) {
return;
}
if (this.searchFieldInputs.textboxKeyTyped(character, key)) {
this.refreshList();
} else {
super.keyTyped(character, key);
}
}
}
public void postUpdate(final NBTTagCompound in) {
if (in.getBoolean("clear")) {
this.byId.clear();
this.refreshList = true;
}
for (final Object oKey : in.getKeySet()) {
final String key = (String) oKey;
if (key.startsWith("=")) {
try {
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
final NBTTagCompound invData = in.getCompoundTag(key);
final ClientDCInternalInv current = this.getById(id, invData.getLong("sortBy"), invData.getString("un"));
blockPosHashMap.put(current, NBTUtil.getPosFromTag(invData.getCompoundTag("pos")));
dimHashMap.put(current, invData.getInteger("dim"));
numUpgradesMap.put(current, invData.getInteger("numUpgrades"));
for (int x = 0; x < current.getInventory().getSlots(); x++) {
final String which = Integer.toString(x);
if (invData.hasKey(which)) {
current.getInventory().setStackInSlot(x, new ItemStack(invData.getCompoundTag(which)));
}
}
} catch (final NumberFormatException ignored) {
}
}
}
if (this.refreshList) {
this.refreshList = false;
// invalid caches on refresh
this.cachedSearches.clear();
this.refreshList();
}
}
/**
* Rebuilds the list of interfaces.
* <p>
* Respects a search term if present (ignores case) and adding only matching patterns.
*/
private void refreshList() {
this.byName.clear();
this.buttonList.clear();
this.matchedStacks.clear();
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
final Set<Object> cachedSearch = this.getCacheForSearchTerm(searchFieldInputs);
final boolean rebuild = cachedSearch.isEmpty();
for (final ClientDCInternalInv entry : this.byId.values()) {
// ignore inventory if not doing a full rebuild and cache already marks it as miss.
if (!rebuild && !cachedSearch.contains(entry)) {
continue;
}
// Shortcut to skip any filter if search term is ""/empty
boolean found = searchFieldInputs.isEmpty();
// Search if the current inventory holds a pattern containing the search term.
if (!found) {
int slot = 0;
for (final ItemStack itemStack : entry.getInventory()) {
if (slot > 8 + numUpgradesMap.get(entry) * 9) {
break;
}
if (this.itemStackMatchesSearchTerm(itemStack, searchFieldInputs)) {
found = true;
matchedStacks.add(itemStack);
}
slot++;
}
}
// if found, filter skipped or machine name matching the search term, add it
if (found || entry.getName().toLowerCase().contains(searchFieldInputs)) {
this.byName.put(entry.getName(), entry);
cachedSearch.add(entry);
} else {
cachedSearch.remove(entry);
}
}
this.names.clear();
this.names.addAll(this.byName.keySet());
Collections.sort(this.names);
this.lines.clear();
this.lines.ensureCapacity(this.getMaxRows());
for (final String n : this.names) {
this.lines.add(n);
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>();
clientInventories.addAll(this.byName.get(n));
Collections.sort(clientInventories);
this.lines.addAll(clientInventories);
}
this.getScrollBar().setRange(0, this.lines.size() - 1, 1);
}
private boolean itemStackMatchesSearchTerm(final ItemStack itemStack, final String searchTerm) {
if (itemStack.isEmpty()) {
return false;
}
boolean foundMatchingItemStack = false;
final String displayName = Platform
.getItemDisplayName(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(itemStack))
.toLowerCase();
for (String term : searchTerm.split(" ")) {
if (term.length() > 1 && (term.startsWith("-") || term.startsWith("!"))) {
term = term.substring(1);
if (displayName.contains(term)) {
return false;
}
} else if (displayName.contains(term)) {
foundMatchingItemStack = true;
}
}
return foundMatchingItemStack;
}
/**
* Tries to retrieve a cache for a with search term as keyword.
* <p>
* 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 Set<Object> cache = this.cachedSearches.get(searchTerm);
if (cache.isEmpty() && searchTerm.length() > 1) {
cache.addAll(this.getCacheForSearchTerm(searchTerm.substring(0, searchTerm.length() - 1)));
return cache;
}
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();
}
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(DualityInterface.NUMBER_OF_CONFIG_SLOTS, id, sortBy, string, 64));
this.refreshList = true;
}
return o;
}
@Override
public List<IGhostIngredientHandler.Target<?>> getPhantomTargets(Object ingredient) {
if (!(ingredient instanceof ItemStack)) {
return Collections.emptyList();
}
List<IGhostIngredientHandler.Target<?>> targets = new ArrayList<>();
for (Slot slot : this.inventorySlots.inventorySlots) {
if (slot instanceof SlotDisconnected) {
ItemStack itemStack = (ItemStack) ingredient;
IGhostIngredientHandler.Target<Object> target = new IGhostIngredientHandler.Target<Object>() {
@Override
public Rectangle getArea() {
return new Rectangle(getGuiLeft() + slot.xPos, getGuiTop() + slot.yPos, 16, 16);
}
@Override
public void accept(Object ingredient) {
final PacketInventoryAction p;
try {
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (SlotDisconnected) slot, AEItemStack.fromItemStack(itemStack));
NetworkHandler.instance().sendToServer(p);
} catch (IOException e) {
e.printStackTrace();
}
}
};
targets.add(target);
mapTargetSlot.putIfAbsent(target, slot);
}
}
return targets;
}
@Override
public Map<IGhostIngredientHandler.Target<?>, Object> getFakeSlotTargetMap() {
return IJEIGhostIngredients.super.getFakeSlotTargetMap();
}
}
File diff suppressed because it is too large Load Diff
@@ -19,19 +19,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.FuzzyMode;
import appeng.api.config.LevelType;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.api.config.*;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.container.implementations.ContainerLevelEmitter;
@@ -42,240 +30,209 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.parts.automation.PartLevelEmitter;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import java.io.IOException;
public class GuiLevelEmitter extends GuiUpgradeable
{
public class GuiLevelEmitter extends GuiUpgradeable {
private GuiNumberBox level;
private GuiNumberBox level;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiImgButton levelMode;
private GuiImgButton craftingMode;
private GuiImgButton levelMode;
private GuiImgButton craftingMode;
public GuiLevelEmitter( final InventoryPlayer inventoryPlayer, final PartLevelEmitter te )
{
super( new ContainerLevelEmitter( inventoryPlayer, te ) );
}
public GuiLevelEmitter(final InventoryPlayer inventoryPlayer, final PartLevelEmitter te) {
super(new ContainerLevelEmitter(inventoryPlayer, te));
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.level = new GuiNumberBox( this.fontRenderer, this.guiLeft + 24, this.guiTop + 43, 79, this.fontRenderer.FONT_HEIGHT, Long.class );
this.level.setEnableBackgroundDrawing( false );
this.level.setMaxStringLength( 16 );
this.level.setTextColor( 0xFFFFFF );
this.level.setVisible( true );
this.level.setFocused( true );
( (ContainerLevelEmitter) this.inventorySlots ).setTextField( this.level );
}
this.level = new GuiNumberBox(this.fontRenderer, this.guiLeft + 24, this.guiTop + 43, 79, this.fontRenderer.FONT_HEIGHT, Long.class);
this.level.setEnableBackgroundDrawing(false);
this.level.setMaxStringLength(16);
this.level.setTextColor(0xFFFFFF);
this.level.setVisible(true);
this.level.setFocused(true);
((ContainerLevelEmitter) this.inventorySlots).setTextField(this.level);
}
@Override
protected void addButtons()
{
this.levelMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL );
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.craftingMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_VIA_REDSTONE, YesNo.NO );
@Override
protected void addButtons() {
this.levelMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL);
this.redstoneMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL);
this.fuzzyMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
this.craftingMode = new GuiImgButton(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.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a ) );
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b ) );
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c ) );
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d ) );
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d));
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a ) );
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b ) );
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c ) );
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d ) );
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d));
this.buttonList.add( this.levelMode );
this.buttonList.add( this.redstoneMode );
this.buttonList.add( this.fuzzyMode );
this.buttonList.add( this.craftingMode );
}
this.buttonList.add(this.levelMode);
this.buttonList.add(this.redstoneMode);
this.buttonList.add(this.fuzzyMode);
this.buttonList.add(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.enabled = notCraftingMode;
this.plus10.enabled = notCraftingMode;
this.plus100.enabled = notCraftingMode;
this.plus1000.enabled = notCraftingMode;
this.minus1.enabled = notCraftingMode;
this.minus10.enabled = notCraftingMode;
this.minus100.enabled = notCraftingMode;
this.minus1000.enabled = notCraftingMode;
this.levelMode.enabled = notCraftingMode;
this.redstoneMode.enabled = notCraftingMode;
// configure enabled status...
this.level.setEnabled(notCraftingMode);
this.plus1.enabled = notCraftingMode;
this.plus10.enabled = notCraftingMode;
this.plus100.enabled = notCraftingMode;
this.plus1000.enabled = notCraftingMode;
this.minus1.enabled = notCraftingMode;
this.minus10.enabled = notCraftingMode;
this.minus100.enabled = notCraftingMode;
this.minus1000.enabled = notCraftingMode;
this.levelMode.enabled = notCraftingMode;
this.redstoneMode.enabled = notCraftingMode;
super.drawFG( offsetX, offsetY, mouseX, mouseY );
super.drawFG(offsetX, offsetY, mouseX, mouseY);
if( this.craftingMode != null )
{
this.craftingMode.set( ( (ContainerLevelEmitter) 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 )
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
this.level.drawTextBox();
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawBG(offsetX, offsetY, mouseX, mouseY);
this.level.drawTextBox();
}
@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;
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
if( btn == this.craftingMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.craftingMode.getSetting(), backwards ) );
}
if (btn == this.craftingMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.craftingMode.getSetting(), backwards));
}
if( btn == this.levelMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.levelMode.getSetting(), backwards ) );
}
if (btn == this.levelMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.levelMode.getSetting(), backwards));
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if( isPlus || isMinus )
{
this.addQty( this.getQty( btn ) );
}
}
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
}
}
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" );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
NetworkHandler.instance().sendToServer(new PacketValueConfig("LevelEmitter.Value", Out));
} catch (final NumberFormatException e) {
// nope..
this.level.setText("0");
} catch (final IOException e) {
AELog.debug(e);
}
}
@Override
protected void keyTyped( final char character, final int key ) throws IOException
{
if( !this.checkHotbarKeys( key ) )
{
if( ( key == 211 || key == 205 || key == 203 || key == 14 || Character.isDigit( character ) ) && this.level.textboxKeyTyped( character, key ) )
{
try
{
String Out = this.level.getText();
@Override
protected void keyTyped(final char character, final int key) throws IOException {
if (!this.checkHotbarKeys(key)) {
if ((key == 211 || key == 205 || key == 203 || key == 14 || Character.isDigit(character)) && this.level.textboxKeyTyped(character, key)) {
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";
}
NetworkHandler.instance().sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
else
{
super.keyTyped( character, key );
}
}
}
NetworkHandler.instance().sendToServer(new PacketValueConfig("LevelEmitter.Value", Out));
} catch (final IOException e) {
AELog.debug(e);
}
} else {
super.keyTyped(character, key);
}
}
}
}
@@ -19,8 +19,6 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.client.gui.widgets.GuiImgButton;
@@ -29,61 +27,54 @@ import appeng.client.gui.widgets.GuiProgressBar.Direction;
import appeng.container.implementations.ContainerMAC;
import appeng.core.localization.GuiText;
import appeng.tile.crafting.TileMolecularAssembler;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiMAC extends GuiUpgradeable
{
public class GuiMAC extends GuiUpgradeable {
private final ContainerMAC container;
private GuiProgressBar pb;
private final ContainerMAC container;
private GuiProgressBar pb;
public GuiMAC( final InventoryPlayer inventoryPlayer, final TileMolecularAssembler te )
{
super( new ContainerMAC( inventoryPlayer, te ) );
this.ySize = 197;
this.container = (ContainerMAC) this.inventorySlots;
}
public GuiMAC(final InventoryPlayer inventoryPlayer, final TileMolecularAssembler te) {
super(new ContainerMAC(inventoryPlayer, te));
this.ySize = 197;
this.container = (ContainerMAC) this.inventorySlots;
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.pb = new GuiProgressBar( this.container, "guis/mac.png", 139, 36, 148, 201, 6, 18, Direction.VERTICAL );
this.buttonList.add( this.pb );
}
this.pb = new GuiProgressBar(this.container, "guis/mac.png", 139, 36, 148, 201, 6, 18, Direction.VERTICAL);
this.buttonList.add(this.pb);
}
@Override
protected void addButtons()
{
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
this.buttonList.add( this.redstoneMode );
}
@Override
protected void addButtons() {
this.redstoneMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
this.buttonList.add(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 )
{
this.pb.x = 148 + this.guiLeft;
this.pb.y = 48 + this.guiTop;
super.drawBG( offsetX, offsetY, mouseX, mouseY );
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.pb.x = 148 + this.guiLeft;
this.pb.y = 48 + this.guiTop;
super.drawBG(offsetX, offsetY, mouseX, mouseY);
}
@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
@@ -19,28 +19,23 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.container.implementations.ContainerMEPortableCell;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiMEPortableCell extends GuiMEMonitorable
{
public class GuiMEPortableCell extends GuiMEMonitorable {
public GuiMEPortableCell( final InventoryPlayer inventoryPlayer, final IPortableCell te )
{
super( inventoryPlayer, te, new ContainerMEPortableCell( inventoryPlayer, te ) );
}
public GuiMEPortableCell(final InventoryPlayer inventoryPlayer, final IPortableCell te) {
super(inventoryPlayer, te, new ContainerMEPortableCell(inventoryPlayer, te));
}
int defaultGetMaxRows()
{
return super.getMaxRows();
}
int defaultGetMaxRows() {
return super.getMaxRows();
}
@Override
int getMaxRows()
{
return 3;
}
@Override
int getMaxRows() {
return 3;
}
}
@@ -19,18 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import java.util.List;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
@@ -47,249 +35,227 @@ import appeng.container.implementations.ContainerNetworkStatus;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.util.List;
public class GuiNetworkStatus extends AEBaseGui implements ISortSource
{
public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
private final ItemRepo repo;
private final int rows = 4;
private GuiImgButton units;
private int tooltip = -1;
private final ItemRepo repo;
private final int rows = 4;
private GuiImgButton units;
private int tooltip = -1;
public GuiNetworkStatus( final InventoryPlayer inventoryPlayer, final INetworkTool te )
{
super( new ContainerNetworkStatus( inventoryPlayer, te ) );
final GuiScrollbar scrollbar = new GuiScrollbar();
public GuiNetworkStatus(final InventoryPlayer inventoryPlayer, final INetworkTool te) {
super(new ContainerNetworkStatus(inventoryPlayer, te));
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar );
this.repo = new ItemRepo( scrollbar, this );
this.ySize = 153;
this.xSize = 195;
this.repo.setRowSize( 5 );
}
this.setScrollBar(scrollbar);
this.repo = new ItemRepo(scrollbar, this);
this.ySize = 153;
this.xSize = 195;
this.repo.setRowSize(5);
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
if( btn == this.units )
{
AEConfig.instance().nextPowerUnit( backwards );
this.units.set( AEConfig.instance().selectedPowerUnit() );
}
}
if (btn == this.units) {
AEConfig.instance().nextPowerUnit(backwards);
this.units.set(AEConfig.instance().selectedPowerUnit());
}
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit() );
this.buttonList.add( this.units );
}
this.units = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit());
this.buttonList.add(this.units);
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn )
{
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
final int gx = ( this.width - this.xSize ) / 2;
final int gy = ( this.height - this.ySize ) / 2;
final int gx = (this.width - this.xSize) / 2;
final int gy = (this.height - this.ySize) / 2;
this.tooltip = -1;
this.tooltip = -1;
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;
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;
if( minX < mouseX && minX + 28 > mouseX )
{
if( minY < mouseY && minY + 20 > mouseY )
{
this.tooltip = z;
break;
}
}
if (minX < mouseX && minX + 28 > mouseX) {
if (minY < mouseY && minY + 20 > mouseY) {
this.tooltip = z;
break;
}
}
x++;
x++;
if( x > 4 )
{
y++;
x = 0;
}
}
if (x > 4) {
y++;
x = 0;
}
}
super.drawScreen( mouseX, mouseY, btn );
}
super.drawScreen(mouseX, mouseY, btn);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
final ContainerNetworkStatus ns = (ContainerNetworkStatus) this.inventorySlots;
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
final ContainerNetworkStatus ns = (ContainerNetworkStatus) this.inventorySlots;
this.fontRenderer.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 );
this.fontRenderer.drawString(GuiText.NetworkDetails.getLocal(), 8, 6, 4210752);
this.fontRenderer.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( ns.getCurrentPower(), false ), 13, 16, 4210752 );
this.fontRenderer.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( ns.getMaxPower(), false ), 13, 26, 4210752 );
this.fontRenderer.drawString(GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong(ns.getCurrentPower(), false), 13, 16, 4210752);
this.fontRenderer.drawString(GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong(ns.getMaxPower(), false), 13, 26, 4210752);
this.fontRenderer.drawString( GuiText.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong( ns.getAverageAddition(), true ), 13, 143 - 10,
4210752 );
this.fontRenderer.drawString( GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( ns.getPowerUsage(), true ), 13, 143 - 20, 4210752 );
this.fontRenderer.drawString(GuiText.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong(ns.getAverageAddition(), true), 13, 143 - 10,
4210752);
this.fontRenderer.drawString(GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong(ns.getPowerUsage(), true), 13, 143 - 20, 4210752);
final int sectionLength = 30;
final int sectionLength = 30;
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;
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;
String toolTip = "";
int toolPosX = 0;
int toolPosY = 0;
String toolTip = "";
int toolPosX = 0;
int toolPosY = 0;
for( int z = viewStart; z < Math.min( viewEnd, this.repo.size() ); z++ )
{
final IAEItemStack refStack = this.repo.getReferenceItem( z );
if( refStack != null )
{
GlStateManager.pushMatrix();
GlStateManager.scale( 0.5, 0.5, 0.5 );
for (int z = viewStart; z < Math.min(viewEnd, this.repo.size()); z++) {
final IAEItemStack refStack = this.repo.getReferenceItem(z);
if (refStack != null) {
GlStateManager.pushMatrix();
GlStateManager.scale(0.5, 0.5, 0.5);
String str = Long.toString( refStack.getStackSize() );
if( refStack.getStackSize() >= 10000 )
{
str = Long.toString( refStack.getStackSize() / 1000 ) + 'k';
}
String str = Long.toString(refStack.getStackSize());
if (refStack.getStackSize() >= 10000) {
str = Long.toString(refStack.getStackSize() / 1000) + 'k';
}
final int w = this.fontRenderer.getStringWidth( str );
this.fontRenderer.drawString( str, (int) ( ( x * sectionLength + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * 18 + yo + 6 ) * 2,
4210752 );
final int w = this.fontRenderer.getStringWidth(str);
this.fontRenderer.drawString(str, (int) ((x * sectionLength + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * 18 + yo + 6) * 2,
4210752);
GlStateManager.popMatrix();
final int posX = x * sectionLength + xo + sectionLength - 18;
final int posY = y * 18 + yo;
GlStateManager.popMatrix();
final int posX = x * sectionLength + xo + sectionLength - 18;
final int posY = y * 18 + yo;
if( this.tooltip == z - viewStart )
{
toolTip = Platform.getItemDisplayName( refStack );
if (this.tooltip == z - viewStart) {
toolTip = Platform.getItemDisplayName(refStack);
toolTip += ( '\n' + GuiText.Installed.getLocal() + ": " + ( refStack.getStackSize() ) );
if( refStack.getCountRequestable() > 0 )
{
toolTip += ( '\n' + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( refStack.getCountRequestable(), true ) );
}
toolTip += ('\n' + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
if (refStack.getCountRequestable() > 0) {
toolTip += ('\n' + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong(refStack.getCountRequestable(), true));
}
toolPosX = x * sectionLength + xo + sectionLength - 8;
toolPosY = y * 18 + yo;
}
toolPosX = x * sectionLength + xo + sectionLength - 8;
toolPosY = y * 18 + yo;
}
this.drawItem( posX, posY, refStack.asItemStackRepresentation() );
this.drawItem(posX, posY, refStack.asItemStackRepresentation());
x++;
x++;
if( x > 4 )
{
y++;
x = 0;
}
}
}
if (x > 4) {
y++;
x = 0;
}
}
}
if( this.tooltip >= 0 && toolTip.length() > 0 )
{
this.drawTooltip( toolPosX, toolPosY + 10, toolTip );
}
}
if (this.tooltip >= 0 && toolTip.length() > 0) {
this.drawTooltip(toolPosX, toolPosY + 10, toolTip);
}
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.bindTexture( "guis/networkstatus.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/networkstatus.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
public void postUpdate( final List<IAEItemStack> list )
{
this.repo.clear();
public void postUpdate(final List<IAEItemStack> list) {
this.repo.clear();
for( final IAEItemStack is : list )
{
this.repo.postUpdate( is );
}
for (final IAEItemStack is : list) {
this.repo.postUpdate(is);
}
this.repo.updateView();
this.setScrollBar();
}
this.repo.updateView();
this.setScrollBar();
}
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 );
}
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);
}
@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 != null )
{
IAEItemStack myStack = null;
if (s instanceof SlotME && stack != null) {
IAEItemStack myStack = null;
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 )
{
ITooltipFlag.TooltipFlags tooltipFlag = this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
List<String> currentToolTip = stack.getTooltip( this.mc.player, tooltipFlag );
if (myStack != null) {
ITooltipFlag.TooltipFlags tooltipFlag = this.mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
List<String> currentToolTip = stack.getTooltip(this.mc.player, tooltipFlag);
while( currentToolTip.size() > 1 )
{
currentToolTip.remove( 1 );
}
while (currentToolTip.size() > 1) {
currentToolTip.remove(1);
}
currentToolTip.add( GuiText.Installed.getLocal() + ": " + ( myStack.getStackSize() ) );
currentToolTip.add( GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( myStack.getCountRequestable(), true ) );
currentToolTip.add(GuiText.Installed.getLocal() + ": " + (myStack.getStackSize()));
currentToolTip.add(GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong(myStack.getCountRequestable(), true));
this.drawTooltip( x, y, currentToolTip );
}
}
this.drawTooltip(x, y, currentToolTip);
}
}
super.renderToolTip( stack, x, y );
}
super.renderToolTip(stack, x, y);
}
@Override
public Enum getSortBy()
{
return SortOrder.NAME;
}
@Override
public Enum getSortBy() {
return SortOrder.NAME;
}
@Override
public Enum getSortDir()
{
return SortDir.ASCENDING;
}
@Override
public Enum getSortDir() {
return SortDir.ASCENDING;
}
@Override
public Enum getSortDisplay()
{
return ViewItems.ALL;
}
@Override
public Enum getSortDisplay() {
return ViewItems.ALL;
}
}
@@ -19,11 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiToggleButton;
@@ -32,64 +27,57 @@ 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.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import java.io.IOException;
public class GuiNetworkTool extends AEBaseGui
{
public class GuiNetworkTool extends AEBaseGui {
private GuiToggleButton tFacades;
private GuiToggleButton tFacades;
public GuiNetworkTool( final InventoryPlayer inventoryPlayer, final INetworkTool te )
{
super( new ContainerNetworkTool( inventoryPlayer, te ) );
this.ySize = 166;
}
public GuiNetworkTool(final InventoryPlayer inventoryPlayer, final INetworkTool te) {
super(new ContainerNetworkTool(inventoryPlayer, te));
this.ySize = 166;
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
try
{
if( btn == this.tFacades )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "NetworkTool", "Toggle" ) );
}
}
catch( final IOException e )
{
AELog.debug( e );
}
}
try {
if (btn == this.tFacades) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("NetworkTool", "Toggle"));
}
} catch (final IOException e) {
AELog.debug(e);
}
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.tFacades = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 8, 23, 22, GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint
.getLocal() );
this.tFacades = new GuiToggleButton(this.guiLeft - 18, this.guiTop + 8, 23, 22, GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint
.getLocal());
this.buttonList.add( this.tFacades );
}
this.buttonList.add(this.tFacades);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
if( this.tFacades != null )
{
this.tFacades.setState( ( (ContainerNetworkTool) this.inventorySlots ).isFacadeMode() );
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
if (this.tFacades != null) {
this.tFacades.setState(((ContainerNetworkTool) this.inventorySlots).isFacadeMode());
}
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.NetworkTool.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.NetworkTool.getLocal()), 8, 6, 4210752);
this.fontRenderer.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 )
{
this.bindTexture( "guis/toolbox.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/toolbox.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}
@@ -26,152 +26,123 @@ import java.io.IOException;
import java.util.regex.Pattern;
public class GuiOreDictStorageBus extends AEBaseGui
{
public class GuiOreDictStorageBus extends AEBaseGui {
private final ContainerOreDictStorageBus container;
PartOreDicStorageBus part;
private GuiTabButton priority;
private GuiImgButton partition;
private GuiImgButton storageFilter;
private GuiImgButton rwMode;
private static final Pattern ORE_DICTIONARY_FILTER = Pattern.compile( "[(!]* *[0-9a-zA-Z*]* *\\)*( *[&|^]? *[(!]* *[0-9a-zA-Z*]* *\\)*)*" );
private static final Pattern ORE_DICTIONARY_FILTER = Pattern.compile("[(!]* *[0-9a-zA-Z*]* *\\)*( *[&|^]? *[(!]* *[0-9a-zA-Z*]* *\\)*)*");
private MEGuiTextField searchFieldInputs;
public GuiOreDictStorageBus( final InventoryPlayer inventoryPlayer, final PartOreDicStorageBus te )
{
super( new ContainerOreDictStorageBus( inventoryPlayer, te ) );
public GuiOreDictStorageBus(final InventoryPlayer inventoryPlayer, final PartOreDicStorageBus te) {
super(new ContainerOreDictStorageBus(inventoryPlayer, te));
this.container = (ContainerOreDictStorageBus) super.inventorySlots;
part = te;
this.ySize = 84;
}
@Override
public void initGui()
{
public void initGui() {
super.initGui();
this.searchFieldInputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + 3, this.guiTop + 22, 170, 12 );
this.searchFieldInputs.setEnableBackgroundDrawing( false );
this.searchFieldInputs.setMaxStringLength( 512 );
this.searchFieldInputs.setTextColor( 0xFFFFFF );
this.searchFieldInputs.setVisible( true );
this.searchFieldInputs.setFocused( false );
this.searchFieldInputs.setValidator( str -> ORE_DICTIONARY_FILTER.matcher( str ).matches() );
this.searchFieldInputs = new MEGuiTextField(this.fontRenderer, this.guiLeft + 3, this.guiTop + 22, 170, 12);
this.searchFieldInputs.setEnableBackgroundDrawing(false);
this.searchFieldInputs.setMaxStringLength(512);
this.searchFieldInputs.setTextColor(0xFFFFFF);
this.searchFieldInputs.setVisible(true);
this.searchFieldInputs.setFocused(false);
this.searchFieldInputs.setValidator(str -> ORE_DICTIONARY_FILTER.matcher(str).matches());
this.buttonList.add( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
this.buttonList.add( this.partition = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH ) );
this.buttonList.add( this.rwMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE ) );
this.buttonList.add( this.storageFilter = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY ) );
this.buttonList.add(this.priority = new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender));
this.buttonList.add(this.partition = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH));
this.buttonList.add(this.rwMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE));
this.buttonList.add(this.storageFilter = new GuiImgButton(this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY));
try
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "OreDictStorageBus.getRegex", "1" ) );
}
catch( IOException e )
{
try {
NetworkHandler.instance().sendToServer(new PacketValueConfig("OreDictStorageBus.getRegex", "1"));
} catch (IOException e) {
e.printStackTrace();
}
}
public void fillRegex( String regex )
{
this.searchFieldInputs.setText( regex );
public void fillRegex(String regex) {
this.searchFieldInputs.setText(regex);
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
try
{
if( btn == this.priority )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
try {
if (btn == this.priority) {
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PRIORITY));
} else if (btn == this.partition) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("StorageBus.Action", "Partition"));
} else if (btn == this.rwMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
} else if (btn == this.storageFilter) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.storageFilter.getSetting(), backwards));
}
else if( btn == this.partition )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
}
else if( btn == this.rwMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.rwMode.getSetting(), backwards ) );
}
else if( btn == this.storageFilter )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.storageFilter.getSetting(), backwards ) );
}
}
catch( final IOException e )
{
AELog.debug( e );
} catch (final IOException e) {
AELog.debug(e);
}
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
{
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) throws IOException {
boolean wasFocused = this.searchFieldInputs.isFocused();
this.searchFieldInputs.mouseClicked( xCoord, yCoord, btn );
this.searchFieldInputs.mouseClicked(xCoord, yCoord, btn);
if( btn == 1 && this.searchFieldInputs.isMouseIn( xCoord, yCoord ) )
{
this.searchFieldInputs.setText( "" );
if (btn == 1 && this.searchFieldInputs.isMouseIn(xCoord, yCoord)) {
this.searchFieldInputs.setText("");
}
if( !searchFieldInputs.isFocused() && wasFocused )
{
searchFieldInputs.setText( OreDictFilterMatcher.validateExp( searchFieldInputs.getText() ) );
NetworkHandler.instance().sendToServer( new PacketValueConfig( "OreDictStorageBus.save", searchFieldInputs.getText() ) );
if (!searchFieldInputs.isFocused() && wasFocused) {
searchFieldInputs.setText(OreDictFilterMatcher.validateExp(searchFieldInputs.getText()));
NetworkHandler.instance().sendToServer(new PacketValueConfig("OreDictStorageBus.save", searchFieldInputs.getText()));
}
super.mouseClicked( xCoord, yCoord, btn );
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void keyTyped( final char character, final int key ) throws IOException
{
if( !this.checkHotbarKeys( key ) )
{
if( !this.searchFieldInputs.textboxKeyTyped( character, key ) )
{
super.keyTyped( character, key );
protected void keyTyped(final char character, final int key) throws IOException {
if (!this.checkHotbarKeys(key)) {
if (!this.searchFieldInputs.textboxKeyTyped(character, key)) {
super.keyTyped(character, key);
}
}
}
@Override
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.OreDictStorageBus.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.drawString( this.searchFieldInputs.getText().length() + " / " + this.searchFieldInputs.getMaxStringLength(), 120, 36, 4210752 );
this.fontRenderer.drawString( "& = AND " + "| = OR", 8, 36, 4210752 );
this.fontRenderer.drawString( "^ = XOR " + "! = NOT", 8, 48, 4210752 );
this.fontRenderer.drawString( "() for priority " + "* for wildcard", 8, 60, 4210752 );
this.fontRenderer.drawString( "Ex.: *Redstone*&!dustRedstone", 8, 72, 4210752 );
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.OreDictStorageBus.getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString(this.searchFieldInputs.getText().length() + " / " + this.searchFieldInputs.getMaxStringLength(), 120, 36, 4210752);
this.fontRenderer.drawString("& = AND " + "| = OR", 8, 36, 4210752);
this.fontRenderer.drawString("^ = XOR " + "! = NOT", 8, 48, 4210752);
this.fontRenderer.drawString("() for priority " + "* for wildcard", 8, 60, 4210752);
this.fontRenderer.drawString("Ex.: *Redstone*&!dustRedstone", 8, 72, 4210752);
if( this.storageFilter != null )
{
this.storageFilter.set( container.getStorageFilter() );
if (this.storageFilter != null) {
this.storageFilter.set(container.getStorageFilter());
}
if( this.rwMode != null )
{
this.rwMode.set( container.getReadWriteMode() );
if (this.rwMode != null) {
this.rwMode.set(container.getReadWriteMode());
}
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/oredictstoragebus.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 175, 85 );
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/oredictstoragebus.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, 175, 85);
if( this.searchFieldInputs != null )
{
if (this.searchFieldInputs != null) {
this.searchFieldInputs.drawTextBox();
}
}
@@ -19,14 +19,21 @@
package appeng.client.gui.implementations;
import java.awt.*;
import java.io.IOException;
import java.util.*;
import java.util.List;
import appeng.api.config.ActionItems;
import appeng.api.config.ItemSubstitution;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerPatternTerm;
import appeng.container.interfaces.IJEIGhostIngredients;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotFake;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
import mezz.jei.api.gui.IGhostIngredientHandler.Target;
@@ -36,301 +43,254 @@ import net.minecraft.init.Blocks;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import appeng.api.config.ActionItems;
import appeng.api.config.ItemSubstitution;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerPatternTerm;
import appeng.container.slot.AppEngSlot;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import java.awt.*;
import java.io.IOException;
import java.util.List;
import java.util.*;
public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredients
{
public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredients {
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 final ContainerPatternTerm container;
private final ContainerPatternTerm container;
private GuiTabButton tabCraftButton;
private GuiTabButton tabProcessButton;
private GuiImgButton substitutionsEnabledBtn;
private GuiImgButton substitutionsDisabledBtn;
private GuiImgButton encodeBtn;
private GuiImgButton clearBtn;
private GuiImgButton x2Btn;
private GuiImgButton x3Btn;
private GuiImgButton plusOneBtn;
private GuiImgButton divTwoBtn;
private GuiImgButton divThreeBtn;
private GuiImgButton minusOneBtn;
private GuiImgButton maxCountBtn;
public Map<Target<?>,Object> mapTargetSlot = new HashMap<>();
private GuiTabButton tabCraftButton;
private GuiTabButton tabProcessButton;
private GuiImgButton substitutionsEnabledBtn;
private GuiImgButton substitutionsDisabledBtn;
private GuiImgButton encodeBtn;
private GuiImgButton clearBtn;
private GuiImgButton x2Btn;
private GuiImgButton x3Btn;
private GuiImgButton plusOneBtn;
private GuiImgButton divTwoBtn;
private GuiImgButton divThreeBtn;
private GuiImgButton minusOneBtn;
private GuiImgButton maxCountBtn;
public Map<Target<?>, Object> mapTargetSlot = new HashMap<>();
public GuiPatternTerm( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( inventoryPlayer, te, new ContainerPatternTerm( inventoryPlayer, te ) );
this.container = (ContainerPatternTerm) this.inventorySlots;
this.setReservedSpace( 81 );
}
public GuiPatternTerm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(inventoryPlayer, te, new ContainerPatternTerm(inventoryPlayer, te));
this.container = (ContainerPatternTerm) this.inventorySlots;
this.setReservedSpace(81);
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
try
{
try {
if( this.tabCraftButton == btn || this.tabProcessButton == btn )
{
NetworkHandler.instance()
.sendToServer(
new PacketValueConfig( "PatternTerminal.CraftMode", this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING ) );
}
if (this.tabCraftButton == btn || this.tabProcessButton == btn) {
NetworkHandler.instance()
.sendToServer(
new PacketValueConfig("PatternTerminal.CraftMode", this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING));
}
if( this.encodeBtn == btn )
{
if ( isShiftKeyDown() ){
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "2" ) );
}
else
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
}
}
if (this.encodeBtn == btn) {
if (isShiftKeyDown()) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Encode", "2"));
} else {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Encode", "1"));
}
}
if( this.clearBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) );
}
if (this.clearBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Clear", "1"));
}
if( this.x2Btn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MultiplyByTwo", "1" ) );
}
if (this.x2Btn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.MultiplyByTwo", "1"));
}
if( this.x3Btn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MultiplyByThree", "1" ) );
}
if (this.x3Btn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.MultiplyByThree", "1"));
}
if( this.divTwoBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DivideByTwo", "1" ) );
}
if (this.divTwoBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.DivideByTwo", "1"));
}
if( this.divThreeBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DivideByThree", "1" ) );
}
if (this.divThreeBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.DivideByThree", "1"));
}
if( this.plusOneBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.IncreaseByOne", "1" ) );
}
if (this.plusOneBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.IncreaseByOne", "1"));
}
if( this.minusOneBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DecreaseByOne", "1" ) );
}
if (this.minusOneBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.DecreaseByOne", "1"));
}
if( this.maxCountBtn == btn )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MaximizeCount", "1" ) );
}
if (this.maxCountBtn == btn) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.MaximizeCount", "1"));
}
if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn )
{
NetworkHandler.instance()
.sendToServer(
new PacketValueConfig( "PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
}
}
catch( final IOException e )
{
AELog.error( e );
}
}
if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) {
NetworkHandler.instance()
.sendToServer(
new PacketValueConfig("PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE));
}
} catch (final IOException e) {
AELog.error(e);
}
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.CRAFTING_TABLE ), GuiText.CraftingPattern
.getLocal(), this.itemRender );
this.buttonList.add( this.tabCraftButton );
this.tabCraftButton = new GuiTabButton(this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack(Blocks.CRAFTING_TABLE), GuiText.CraftingPattern
.getLocal(), this.itemRender);
this.buttonList.add(this.tabCraftButton);
this.tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.FURNACE ), GuiText.ProcessingPattern
.getLocal(), this.itemRender );
this.buttonList.add( this.tabProcessButton );
this.tabProcessButton = new GuiTabButton(this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack(Blocks.FURNACE), GuiText.ProcessingPattern
.getLocal(), this.itemRender);
this.buttonList.add(this.tabProcessButton);
this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED );
this.substitutionsEnabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsEnabledBtn );
this.substitutionsEnabledBtn = new GuiImgButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED);
this.substitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsEnabledBtn);
this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED );
this.substitutionsDisabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsDisabledBtn );
this.substitutionsDisabledBtn = new GuiImgButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED);
this.substitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsDisabledBtn);
this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
this.clearBtn.setHalfSize( true );
this.buttonList.add( this.clearBtn );
this.clearBtn = new GuiImgButton(this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
this.buttonList.add(this.clearBtn);
this.x3Btn = new GuiImgButton( this.guiLeft + 128, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.MULTIPLY_BY_THREE );
this.x3Btn.setHalfSize( true );
this.buttonList.add( this.x3Btn );
this.x3Btn = new GuiImgButton(this.guiLeft + 128, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.MULTIPLY_BY_THREE);
this.x3Btn.setHalfSize(true);
this.buttonList.add(this.x3Btn);
this.x2Btn = new GuiImgButton( this.guiLeft + 128, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.MULTIPLY_BY_TWO );
this.x2Btn.setHalfSize( true );
this.buttonList.add( this.x2Btn );
this.x2Btn = new GuiImgButton(this.guiLeft + 128, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.MULTIPLY_BY_TWO);
this.x2Btn.setHalfSize(true);
this.buttonList.add(this.x2Btn);
this.plusOneBtn = new GuiImgButton( this.guiLeft + 128, this.guiTop + this.ySize - 138, Settings.ACTIONS, ActionItems.INCREASE_BY_ONE );
this.plusOneBtn.setHalfSize( true );
this.buttonList.add( this.plusOneBtn );
this.plusOneBtn = new GuiImgButton(this.guiLeft + 128, this.guiTop + this.ySize - 138, Settings.ACTIONS, ActionItems.INCREASE_BY_ONE);
this.plusOneBtn.setHalfSize(true);
this.buttonList.add(this.plusOneBtn);
this.divThreeBtn = new GuiImgButton( this.guiLeft + 100, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.DIVIDE_BY_THREE );
this.divThreeBtn.setHalfSize( true );
this.buttonList.add( this.divThreeBtn );
this.divThreeBtn = new GuiImgButton(this.guiLeft + 100, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.DIVIDE_BY_THREE);
this.divThreeBtn.setHalfSize(true);
this.buttonList.add(this.divThreeBtn);
this.divTwoBtn = new GuiImgButton( this.guiLeft + 100, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.DIVIDE_BY_TWO );
this.divTwoBtn.setHalfSize( true );
this.buttonList.add( this.divTwoBtn );
this.divTwoBtn = new GuiImgButton(this.guiLeft + 100, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.DIVIDE_BY_TWO);
this.divTwoBtn.setHalfSize(true);
this.buttonList.add(this.divTwoBtn);
this.minusOneBtn = new GuiImgButton( this.guiLeft + 100, this.guiTop + this.ySize - 138, Settings.ACTIONS, ActionItems.DECREASE_BY_ONE );
this.minusOneBtn.setHalfSize( true );
this.buttonList.add( this.minusOneBtn );
this.minusOneBtn = new GuiImgButton(this.guiLeft + 100, this.guiTop + this.ySize - 138, Settings.ACTIONS, ActionItems.DECREASE_BY_ONE);
this.minusOneBtn.setHalfSize(true);
this.buttonList.add(this.minusOneBtn);
//this.maxCountBtn = new GuiImgButton( this.guiLeft + 128, this.guiTop + this.ySize - 108, Settings.ACTIONS, ActionItems.MAX_COUNT );
//this.maxCountBtn.setHalfSize( true );
//this.buttonList.add( this.maxCountBtn );
//this.maxCountBtn = new GuiImgButton( this.guiLeft + 128, this.guiTop + this.ySize - 108, Settings.ACTIONS, ActionItems.MAX_COUNT );
//this.maxCountBtn.setHalfSize( true );
//this.buttonList.add( this.maxCountBtn );
this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE );
this.buttonList.add( this.encodeBtn );
}
this.encodeBtn = new GuiImgButton(this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE);
this.buttonList.add(this.encodeBtn);
}
@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;
this.x2Btn.visible = false;
this.x3Btn.visible = false;
this.divTwoBtn.visible = false;
this.divThreeBtn.visible = false;
this.plusOneBtn.visible = false;
this.minusOneBtn.visible = false;
//this.maxCountBtn.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;
this.x2Btn.visible = false;
this.x3Btn.visible = false;
this.divTwoBtn.visible = false;
this.divThreeBtn.visible = false;
this.plusOneBtn.visible = false;
this.minusOneBtn.visible = false;
//this.maxCountBtn.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;
this.x2Btn.visible = true;
this.x3Btn.visible = true;
this.divTwoBtn.visible = true;
this.divThreeBtn.visible = true;
this.plusOneBtn.visible = true;
this.minusOneBtn.visible = true;
//this.maxCountBtn.visible = true;
}
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;
this.x2Btn.visible = true;
this.x3Btn.visible = true;
this.divTwoBtn.visible = true;
this.divThreeBtn.visible = true;
this.plusOneBtn.visible = true;
this.minusOneBtn.visible = true;
//this.maxCountBtn.visible = true;
}
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRenderer.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - this.getReservedSpace(), 4210752 );
}
super.drawFG(offsetX, offsetY, mouseX, mouseY);
this.fontRenderer.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;
}
@Override
public List<Target<?>> getPhantomTargets(Object ingredient) {
if (!(ingredient instanceof ItemStack )) {
return Collections.emptyList();
}
List<Target<?>> targets = new ArrayList<>();
for( Slot slot : this.inventorySlots.inventorySlots )
{
if( slot instanceof SlotFake )
{
ItemStack itemStack = (ItemStack) ingredient;
Target<Object> target = new Target<Object>()
{
@Override
public Rectangle getArea()
{
return new Rectangle( getGuiLeft() + slot.xPos, getGuiTop() + slot.yPos, 16, 16 );
}
@Override
public List<Target<?>> getPhantomTargets(Object ingredient) {
if (!(ingredient instanceof ItemStack)) {
return Collections.emptyList();
}
List<Target<?>> targets = new ArrayList<>();
for (Slot slot : this.inventorySlots.inventorySlots) {
if (slot instanceof SlotFake) {
ItemStack itemStack = (ItemStack) ingredient;
Target<Object> target = new Target<Object>() {
@Override
public Rectangle getArea() {
return new Rectangle(getGuiLeft() + slot.xPos, getGuiTop() + slot.yPos, 16, 16);
}
@Override
public void accept( Object ingredient )
{
final PacketInventoryAction p;
try
{
p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (SlotFake) slot, AEItemStack.fromItemStack( itemStack ) );
NetworkHandler.instance().sendToServer( p );
@Override
public void accept(Object ingredient) {
final PacketInventoryAction p;
try {
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (SlotFake) slot, AEItemStack.fromItemStack(itemStack));
NetworkHandler.instance().sendToServer(p);
}
catch( IOException e )
{
e.printStackTrace();
}
}
};
targets.add( target );
mapTargetSlot.putIfAbsent( target, slot );
}
}
return targets;
}
} catch (IOException e) {
e.printStackTrace();
}
}
};
targets.add(target);
mapTargetSlot.putIfAbsent(target, slot);
}
}
return targets;
}
@Override
public Map<Target<?>, Object> getFakeSlotTargetMap()
{
return mapTargetSlot;
}
@Override
public Map<Target<?>, Object> getFakeSlotTargetMap() {
return mapTargetSlot;
}
}
@@ -19,12 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.gui.widgets.GuiTabButton;
@@ -37,188 +31,163 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IPriorityHost;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import java.io.IOException;
public class GuiPriority extends AEBaseGui
{
public class GuiPriority extends AEBaseGui {
private GuiNumberBox priority;
private GuiTabButton originalGuiBtn;
private GuiNumberBox priority;
private GuiTabButton originalGuiBtn;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiBridge OriginalGui;
private GuiBridge OriginalGui;
public GuiPriority( final InventoryPlayer inventoryPlayer, final IPriorityHost te )
{
super( new ContainerPriority( inventoryPlayer, te ) );
}
public GuiPriority(final InventoryPlayer inventoryPlayer, final IPriorityHost te) {
super(new ContainerPriority(inventoryPlayer, te));
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
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.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a ) );
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b ) );
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c ) );
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d ) );
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d));
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a ) );
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b ) );
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c ) );
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) );
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d));
final ContainerPriority con = ( (ContainerPriority) this.inventorySlots );
final ItemStack myIcon = con.getPriorityHost().getItemStackRepresentation();
this.OriginalGui = con.getPriorityHost().getGuiBridge();
final ContainerPriority con = ((ContainerPriority) this.inventorySlots);
final ItemStack myIcon = con.getPriorityHost().getItemStackRepresentation();
this.OriginalGui = con.getPriorityHost().getGuiBridge();
if( this.OriginalGui != null && !myIcon.isEmpty() )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), this.itemRender ) );
}
if (this.OriginalGui != null && !myIcon.isEmpty()) {
this.buttonList.add(this.originalGuiBtn = new GuiTabButton(this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), this.itemRender));
}
this.priority = new GuiNumberBox( this.fontRenderer, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRenderer.FONT_HEIGHT, Long.class );
this.priority.setEnableBackgroundDrawing( false );
this.priority.setMaxStringLength( 16 );
this.priority.setTextColor( 0xFFFFFF );
this.priority.setVisible( true );
this.priority.setFocused( true );
( (ContainerPriority) this.inventorySlots ).setTextField( this.priority );
}
this.priority = new GuiNumberBox(this.fontRenderer, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRenderer.FONT_HEIGHT, Long.class);
this.priority.setEnableBackgroundDrawing(false);
this.priority.setMaxStringLength(16);
this.priority.setTextColor(0xFFFFFF);
this.priority.setVisible(true);
this.priority.setFocused(true);
((ContainerPriority) this.inventorySlots).setTextField(this.priority);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 );
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRenderer.drawString(GuiText.Priority.getLocal(), 8, 6, 4210752);
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.bindTexture( "guis/priority.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/priority.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
this.priority.drawTextBox();
}
this.priority.drawTextBox();
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
if( btn == this.originalGuiBtn )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( this.OriginalGui ) );
}
if (btn == this.originalGuiBtn) {
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(this.OriginalGui));
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if( isPlus || isMinus )
{
this.addQty( this.getQty( btn ) );
}
}
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
}
}
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" );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
NetworkHandler.instance().sendToServer(new PacketValueConfig("PriorityHost.Priority", out));
} catch (final NumberFormatException e) {
// nope..
this.priority.setText("0");
} catch (final IOException e) {
AELog.debug(e);
}
}
@Override
protected void keyTyped( final char character, final int key ) throws IOException
{
if( !this.checkHotbarKeys( key ) )
{
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.priority
.textboxKeyTyped( character, key ) )
{
try
{
String out = this.priority.getText();
@Override
protected void keyTyped(final char character, final int key) throws IOException {
if (!this.checkHotbarKeys(key)) {
if ((key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit(character)) && this.priority
.textboxKeyTyped(character, key)) {
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";
}
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
else
{
super.keyTyped( character, key );
}
}
}
NetworkHandler.instance().sendToServer(new PacketValueConfig("PriorityHost.Priority", out));
} catch (final IOException e) {
AELog.debug(e);
}
} else {
super.keyTyped(character, key);
}
}
}
protected String getBackground()
{
return "guis/priority.png";
}
protected String getBackground() {
return "guis/priority.png";
}
}
@@ -19,34 +19,29 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.container.implementations.ContainerQNB;
import appeng.core.localization.GuiText;
import appeng.tile.qnb.TileQuantumBridge;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiQNB extends AEBaseGui
{
public class GuiQNB extends AEBaseGui {
public GuiQNB( final InventoryPlayer inventoryPlayer, final TileQuantumBridge te )
{
super( new ContainerQNB( inventoryPlayer, te ) );
this.ySize = 166;
}
public GuiQNB(final InventoryPlayer inventoryPlayer, final TileQuantumBridge te) {
super(new ContainerQNB(inventoryPlayer, te));
this.ySize = 166;
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.QuantumLinkChamber.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.QuantumLinkChamber.getLocal()), 8, 6, 4210752);
this.fontRenderer.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 )
{
this.bindTexture( "guis/chest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/chest.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}
@@ -19,78 +19,65 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import appeng.items.contents.QuartzKnifeObj;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.container.implementations.ContainerQuartzKnife;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.items.contents.QuartzKnifeObj;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.InventoryPlayer;
import java.io.IOException;
public class GuiQuartzKnife extends AEBaseGui
{
public class GuiQuartzKnife extends AEBaseGui {
private GuiTextField name;
private GuiTextField name;
public GuiQuartzKnife( final InventoryPlayer inventoryPlayer, final QuartzKnifeObj te )
{
super( new ContainerQuartzKnife( inventoryPlayer, te ) );
this.ySize = 184;
}
public GuiQuartzKnife(final InventoryPlayer inventoryPlayer, final QuartzKnifeObj te) {
super(new ContainerQuartzKnife(inventoryPlayer, te));
this.ySize = 184;
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.name = new GuiTextField( 0, this.fontRenderer, this.guiLeft + 24, this.guiTop + 32, 79, this.fontRenderer.FONT_HEIGHT );
this.name.setEnableBackgroundDrawing( false );
this.name.setMaxStringLength( 32 );
this.name.setTextColor( 0xFFFFFF );
this.name.setVisible( true );
this.name.setFocused( true );
}
this.name = new GuiTextField(0, this.fontRenderer, this.guiLeft + 24, this.guiTop + 32, 79, this.fontRenderer.FONT_HEIGHT);
this.name.setEnableBackgroundDrawing(false);
this.name.setMaxStringLength(32);
this.name.setTextColor(0xFFFFFF);
this.name.setVisible(true);
this.name.setFocused(true);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.QuartzCuttingKnife.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.QuartzCuttingKnife.getLocal()), 8, 6, 4210752);
this.fontRenderer.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 )
{
this.bindTexture( "guis/quartzknife.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.name.drawTextBox();
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/quartzknife.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
this.name.drawTextBox();
}
@Override
protected void keyTyped( final char character, final int key ) throws IOException
{
if( this.name.textboxKeyTyped( character, key ) )
{
try
{
final String Out = this.name.getText();
( (ContainerQuartzKnife) this.inventorySlots ).setName( Out );
NetworkHandler.instance().sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
else
{
super.keyTyped( character, key );
}
}
@Override
protected void keyTyped(final char character, final int key) throws IOException {
if (this.name.textboxKeyTyped(character, key)) {
try {
final String Out = this.name.getText();
((ContainerQuartzKnife) this.inventorySlots).setName(Out);
NetworkHandler.instance().sendToServer(new PacketValueConfig("QuartzKnife.Name", Out));
} catch (final IOException e) {
AELog.debug(e);
}
} else {
super.keyTyped(character, key);
}
}
}
@@ -14,101 +14,81 @@ import org.lwjgl.input.Keyboard;
import java.io.IOException;
public class GuiRenamer extends AEBaseGui
{
private MEGuiTextField textField;
private GuiButton confirmButton;
public class GuiRenamer extends AEBaseGui {
private MEGuiTextField textField;
private GuiButton confirmButton;
public GuiRenamer( InventoryPlayer ip, ICustomNameObject obj )
{
super( new ContainerRenamer( ip, obj ) );
this.xSize = 256;
}
public GuiRenamer(InventoryPlayer ip, ICustomNameObject obj) {
super(new ContainerRenamer(ip, obj));
this.xSize = 256;
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.textField = new MEGuiTextField( this.fontRenderer, this.guiLeft + 9, this.guiTop + 33, 229, 12 );
this.textField = new MEGuiTextField(this.fontRenderer, this.guiLeft + 9, this.guiTop + 33, 229, 12);
this.textField.setEnableBackgroundDrawing( false );
this.textField.setMaxStringLength( 32 );
this.textField.setEnableBackgroundDrawing(false);
this.textField.setMaxStringLength(32);
this.textField.setFocused( true );
this.textField.setFocused(true);
this.buttonList.add( this.confirmButton = new GuiButton( 0, this.guiLeft + 238, this.guiTop + 33, 12, 12, "" ) );
this.buttonList.add(this.confirmButton = new GuiButton(0, this.guiLeft + 238, this.guiTop + 33, 12, 12, ""));
( (ContainerRenamer) this.inventorySlots ).setTextField( this.textField );
}
((ContainerRenamer) this.inventorySlots).setTextField(this.textField);
}
@Override
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.Renamer.getLocal() ), 12, 8, 4210752 );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.Renamer.getLocal()), 12, 8, 4210752);
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/renamer.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.textField.drawTextBox();
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/renamer.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
this.textField.drawTextBox();
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
{
if( this.textField.isMouseIn( xCoord, yCoord ) )
{
if( btn == 1 )
{
this.textField.setText( "" );
}
this.textField.mouseClicked( xCoord, yCoord, btn );
}
super.mouseClicked( xCoord, yCoord, btn );
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) throws IOException {
if (this.textField.isMouseIn(xCoord, yCoord)) {
if (btn == 1) {
this.textField.setText("");
}
this.textField.mouseClicked(xCoord, yCoord, btn);
}
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void keyTyped( final char character, final int key ) throws IOException
{
if( key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER )
{ // Enter
try
{
NetworkHandler.instance().sendToServer(
new PacketValueConfig( "QuartzKnife.ReName", this.textField.getText() ) );
}
catch( IOException e )
{
AELog.debug( e );
}
this.mc.player.closeScreen();
}
else if( !this.textField.textboxKeyTyped( character, key ) )
{
super.keyTyped( character, key );
}
}
@Override
protected void keyTyped(final char character, final int key) throws IOException {
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) { // Enter
try {
NetworkHandler.instance().sendToServer(
new PacketValueConfig("QuartzKnife.ReName", this.textField.getText()));
} catch (IOException e) {
AELog.debug(e);
}
this.mc.player.closeScreen();
} else if (!this.textField.textboxKeyTyped(character, key)) {
super.keyTyped(character, key);
}
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
if( btn == this.confirmButton )
{
try
{
NetworkHandler.instance().sendToServer(
new PacketValueConfig( "QuartzKnife.ReName", this.textField.getText() ) );
this.mc.player.closeScreen();
}
catch( IOException e )
{
AELog.debug( e );
}
}
}
if (btn == this.confirmButton) {
try {
NetworkHandler.instance().sendToServer(
new PacketValueConfig("QuartzKnife.ReName", this.textField.getText()));
this.mc.player.closeScreen();
} catch (IOException e) {
AELog.debug(e);
}
}
}
}
@@ -19,10 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.SortOrder;
import appeng.api.storage.ITerminalHost;
@@ -32,115 +28,102 @@ import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import net.minecraft.entity.player.InventoryPlayer;
import java.io.IOException;
public class GuiSecurityStation extends GuiMEMonitorable
{
public class GuiSecurityStation extends GuiMEMonitorable {
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( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( inventoryPlayer, te, new ContainerSecurityStation( inventoryPlayer, te ) );
this.setCustomSortOrder( false );
this.setReservedSpace( 33 );
public GuiSecurityStation(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(inventoryPlayer, te, new ContainerSecurityStation(inventoryPlayer, te));
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);
}
@Override
protected void actionPerformed( final net.minecraft.client.gui.GuiButton btn )
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final net.minecraft.client.gui.GuiButton btn) {
super.actionPerformed(btn);
SecurityPermissions toggleSetting = null;
SecurityPermissions toggleSetting = null;
if( btn == this.inject )
{
toggleSetting = SecurityPermissions.INJECT;
}
if( btn == this.extract )
{
toggleSetting = SecurityPermissions.EXTRACT;
}
if( btn == this.craft )
{
toggleSetting = SecurityPermissions.CRAFT;
}
if( btn == this.build )
{
toggleSetting = SecurityPermissions.BUILD;
}
if( btn == this.security )
{
toggleSetting = SecurityPermissions.SECURITY;
}
if (btn == this.inject) {
toggleSetting = SecurityPermissions.INJECT;
}
if (btn == this.extract) {
toggleSetting = SecurityPermissions.EXTRACT;
}
if (btn == this.craft) {
toggleSetting = SecurityPermissions.CRAFT;
}
if (btn == this.build) {
toggleSetting = SecurityPermissions.BUILD;
}
if (btn == this.security) {
toggleSetting = SecurityPermissions.SECURITY;
}
if( toggleSetting != null )
{
try
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "TileSecurityStation.ToggleOption", toggleSetting.name() ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
}
if (toggleSetting != null) {
try {
NetworkHandler.instance().sendToServer(new PacketValueConfig("TileSecurityStation.ToggleOption", toggleSetting.name()));
} catch (final IOException e) {
AELog.debug(e);
}
}
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
final int top = this.guiTop + this.ySize - 116;
this.buttonList.add( this.inject = new GuiToggleButton( this.guiLeft + 56, top, 11 * 16, 12 * 16, SecurityPermissions.INJECT
.getUnlocalizedName(), SecurityPermissions.INJECT.getUnlocalizedTip() ) );
final int top = this.guiTop + this.ySize - 116;
this.buttonList.add(this.inject = new GuiToggleButton(this.guiLeft + 56, top, 11 * 16, 12 * 16, SecurityPermissions.INJECT
.getUnlocalizedName(), SecurityPermissions.INJECT.getUnlocalizedTip()));
this.buttonList.add( this.extract = new GuiToggleButton( this.guiLeft + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
.getUnlocalizedName(), SecurityPermissions.EXTRACT.getUnlocalizedTip() ) );
this.buttonList.add(this.extract = new GuiToggleButton(this.guiLeft + 56 + 18, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
.getUnlocalizedName(), SecurityPermissions.EXTRACT.getUnlocalizedTip()));
this.buttonList.add( this.craft = new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT
.getUnlocalizedName(), SecurityPermissions.CRAFT.getUnlocalizedTip() ) );
this.buttonList.add(this.craft = new GuiToggleButton(this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT
.getUnlocalizedName(), SecurityPermissions.CRAFT.getUnlocalizedTip()));
this.buttonList.add( this.build = new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD
.getUnlocalizedName(), SecurityPermissions.BUILD.getUnlocalizedTip() ) );
this.buttonList.add(this.build = new GuiToggleButton(this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD
.getUnlocalizedName(), SecurityPermissions.BUILD.getUnlocalizedTip()));
this.buttonList.add( this.security = new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
.getUnlocalizedName(), SecurityPermissions.SECURITY.getUnlocalizedTip() ) );
}
this.buttonList.add(this.security = new GuiToggleButton(this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
.getUnlocalizedName(), SecurityPermissions.SECURITY.getUnlocalizedTip()));
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRenderer.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.fontRenderer.drawString(GuiText.SecurityCardEditor.getLocal(), 8, this.ySize - 96 + 1 - this.getReservedSpace(), 4210752);
}
@Override
protected String getBackground()
{
final ContainerSecurityStation cs = (ContainerSecurityStation) this.inventorySlots;
@Override
protected String getBackground() {
final ContainerSecurityStation cs = (ContainerSecurityStation) this.inventorySlots;
this.inject.setState( ( cs.getPermissionMode() & ( 1 << SecurityPermissions.INJECT.ordinal() ) ) > 0 );
this.extract.setState( ( cs.getPermissionMode() & ( 1 << SecurityPermissions.EXTRACT.ordinal() ) ) > 0 );
this.craft.setState( ( cs.getPermissionMode() & ( 1 << SecurityPermissions.CRAFT.ordinal() ) ) > 0 );
this.build.setState( ( cs.getPermissionMode() & ( 1 << SecurityPermissions.BUILD.ordinal() ) ) > 0 );
this.security.setState( ( cs.getPermissionMode() & ( 1 << SecurityPermissions.SECURITY.ordinal() ) ) > 0 );
this.inject.setState((cs.getPermissionMode() & (1 << SecurityPermissions.INJECT.ordinal())) > 0);
this.extract.setState((cs.getPermissionMode() & (1 << SecurityPermissions.EXTRACT.ordinal())) > 0);
this.craft.setState((cs.getPermissionMode() & (1 << SecurityPermissions.CRAFT.ordinal())) > 0);
this.build.setState((cs.getPermissionMode() & (1 << SecurityPermissions.BUILD.ordinal())) > 0);
this.security.setState((cs.getPermissionMode() & (1 << SecurityPermissions.SECURITY.ordinal())) > 0);
return "guis/security_station.png";
}
return "guis/security_station.png";
}
@Override
public Enum getSortBy()
{
return SortOrder.NAME;
}
@Override
public Enum getSortBy() {
return SortOrder.NAME;
}
}
@@ -19,41 +19,35 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.container.implementations.ContainerSkyChest;
import appeng.core.localization.GuiText;
import appeng.integration.Integrations;
import appeng.tile.storage.TileSkyChest;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiSkyChest extends AEBaseGui
{
public class GuiSkyChest extends AEBaseGui {
public GuiSkyChest( final InventoryPlayer inventoryPlayer, final TileSkyChest te )
{
super( new ContainerSkyChest( inventoryPlayer, te ) );
this.ySize = 195;
}
public GuiSkyChest(final InventoryPlayer inventoryPlayer, final TileSkyChest te) {
super(new ContainerSkyChest(inventoryPlayer, te));
this.ySize = 195;
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.SkyChest.getLocal() ), 8, 8, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.SkyChest.getLocal()), 8, 8, 4210752);
this.fontRenderer.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 )
{
this.bindTexture( "guis/skychest.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/skychest.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
@Override
protected boolean enableSpaceClicking()
{
return !Integrations.invTweaks().isEnabled();
}
@Override
protected boolean enableSpaceClicking() {
return !Integrations.invTweaks().isEnabled();
}
}
@@ -19,13 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.Settings;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
@@ -34,73 +27,68 @@ import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import java.io.IOException;
public class GuiSpatialIOPort extends AEBaseGui
{
public class GuiSpatialIOPort extends AEBaseGui {
private final ContainerSpatialIOPort container;
private GuiImgButton units;
private final ContainerSpatialIOPort container;
private GuiImgButton units;
public GuiSpatialIOPort( final InventoryPlayer inventoryPlayer, final TileSpatialIOPort te )
{
super( new ContainerSpatialIOPort( inventoryPlayer, te ) );
this.ySize = 199;
this.container = (ContainerSpatialIOPort) this.inventorySlots;
}
public GuiSpatialIOPort(final InventoryPlayer inventoryPlayer, final TileSpatialIOPort te) {
super(new ContainerSpatialIOPort(inventoryPlayer, te));
this.ySize = 199;
this.container = (ContainerSpatialIOPort) this.inventorySlots;
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
if( btn == this.units )
{
AEConfig.instance().nextPowerUnit( backwards );
this.units.set( AEConfig.instance().selectedPowerUnit() );
}
}
if (btn == this.units) {
AEConfig.instance().nextPowerUnit(backwards);
this.units.set(AEConfig.instance().selectedPowerUnit());
}
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit() );
this.buttonList.add( this.units );
}
this.units = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit());
this.buttonList.add(this.units);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getCurrentPower(), false ), 13, 21,
4210752 );
this.fontRenderer.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getMaxPower(), false ), 13, 31, 4210752 );
this.fontRenderer.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getRequiredPower(), false ), 13, 73,
4210752 );
this.fontRenderer.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.fontRenderer.drawString(GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong(this.container.getCurrentPower(), false), 13, 21,
4210752);
this.fontRenderer.drawString(GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong(this.container.getMaxPower(), false), 13, 31, 4210752);
this.fontRenderer.drawString(GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong(this.container.getRequiredPower(), false), 13, 73,
4210752);
this.fontRenderer.drawString(GuiText.Efficiency.getLocal() + ": " + (((float) this.container.getEfficency()) / 100) + '%', 13, 83, 4210752);
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96, 4210752 );
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.SpatialIOPort.getLocal()), 8, 6, 4210752);
this.fontRenderer.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.fontRenderer.drawString( text, 13, 93, 4210752 );
}
else
{
this.fontRenderer.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.fontRenderer.drawString(text, 13, 93, 4210752);
} else {
this.fontRenderer.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 )
{
this.bindTexture( "guis/spatialio.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/spatialio.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}
@@ -19,18 +19,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.AccessRestriction;
import appeng.api.config.ActionItems;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.api.config.*;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerStorageBus;
@@ -42,102 +31,86 @@ import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.parts.misc.PartStorageBus;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import java.io.IOException;
public class GuiStorageBus extends GuiUpgradeable
{
public class GuiStorageBus extends GuiUpgradeable {
private GuiImgButton rwMode;
private GuiImgButton storageFilter;
private GuiTabButton priority;
private GuiImgButton partition;
private GuiImgButton clear;
private GuiImgButton rwMode;
private GuiImgButton storageFilter;
private GuiTabButton priority;
private GuiImgButton partition;
private GuiImgButton clear;
public GuiStorageBus( final InventoryPlayer inventoryPlayer, final PartStorageBus te )
{
super( new ContainerStorageBus( inventoryPlayer, te ) );
this.ySize = 251;
}
public GuiStorageBus(final InventoryPlayer inventoryPlayer, final PartStorageBus te) {
super(new ContainerStorageBus(inventoryPlayer, te));
this.ySize = 251;
}
@Override
protected void addButtons()
{
this.clear = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
this.partition = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
this.rwMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE );
this.storageFilter = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
@Override
protected void addButtons() {
this.clear = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE);
this.partition = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH);
this.rwMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE);
this.storageFilter = new GuiImgButton(this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
this.fuzzyMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
this.buttonList.add( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
this.buttonList.add(this.priority = new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender));
this.buttonList.add( this.storageFilter );
this.buttonList.add( this.fuzzyMode );
this.buttonList.add( this.rwMode );
this.buttonList.add( this.partition );
this.buttonList.add( this.clear );
}
this.buttonList.add(this.storageFilter);
this.buttonList.add(this.fuzzyMode);
this.buttonList.add(this.rwMode);
this.buttonList.add(this.partition);
this.buttonList.add(this.clear);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.StorageBus.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.StorageBus.getLocal()), 8, 6, 4210752);
this.fontRenderer.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";
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
try
{
if( btn == this.partition )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
}
else if( btn == this.clear )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
}
else if( btn == this.priority )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
else if( btn == this.rwMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.rwMode.getSetting(), backwards ) );
}
else if( btn == this.storageFilter )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.storageFilter.getSetting(), backwards ) );
}
}
catch( final IOException e )
{
AELog.debug( e );
}
}
try {
if (btn == this.partition) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("StorageBus.Action", "Partition"));
} else if (btn == this.clear) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("StorageBus.Action", "Clear"));
} else if (btn == this.priority) {
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PRIORITY));
} else if (btn == this.rwMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
} else if (btn == this.storageFilter) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.storageFilter.getSetting(), backwards));
}
} catch (final IOException e) {
AELog.debug(e);
}
}
}
@@ -19,327 +19,264 @@
package appeng.client.gui.implementations;
import java.awt.*;
import java.io.IOException;
import java.util.*;
import java.util.List;
import appeng.api.config.*;
import appeng.api.implementations.IUpgradeableHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.interfaces.IJEIGhostIngredients;
import appeng.container.slot.IJEITargetSlot;
import appeng.container.slot.SlotFake;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
import appeng.fluids.util.AEFluidStack;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
import mezz.jei.api.gui.IGhostIngredientHandler.Target;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.*;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.FuzzyMode;
import appeng.api.config.RedstoneMode;
import appeng.api.config.SchedulingMode;
import appeng.api.config.Settings;
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.GuiImgButton;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.parts.automation.PartExportBus;
import appeng.parts.automation.PartImportBus;
import appeng.util.item.AEItemStack;
import mezz.jei.api.gui.IGhostIngredientHandler.Target;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import org.lwjgl.input.Mouse;
import java.awt.*;
import java.io.IOException;
import java.util.List;
import java.util.*;
public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients
{
private final Map<Target<?>, Object> mapTargetSlot = new HashMap<>();
protected final ContainerUpgradeable cvb;
protected final IUpgradeableHost bc;
public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients {
private final Map<Target<?>, Object> mapTargetSlot = new HashMap<>();
protected final ContainerUpgradeable cvb;
protected final IUpgradeableHost bc;
protected GuiImgButton redstoneMode;
protected GuiImgButton fuzzyMode;
protected GuiImgButton craftMode;
protected GuiImgButton schedulingMode;
protected GuiImgButton redstoneMode;
protected GuiImgButton fuzzyMode;
protected GuiImgButton craftMode;
protected GuiImgButton schedulingMode;
public GuiUpgradeable( final InventoryPlayer inventoryPlayer, final IUpgradeableHost te )
{
this( new ContainerUpgradeable( inventoryPlayer, te ) );
}
public GuiUpgradeable(final InventoryPlayer inventoryPlayer, final IUpgradeableHost te) {
this(new ContainerUpgradeable(inventoryPlayer, te));
}
public GuiUpgradeable( final ContainerUpgradeable te )
{
super( te );
this.cvb = te;
public GuiUpgradeable(final ContainerUpgradeable te) {
super(te);
this.cvb = te;
this.bc = (IUpgradeableHost) te.getTarget();
this.xSize = this.hasToolbox() ? 246 : 211;
this.ySize = 184;
}
this.bc = (IUpgradeableHost) te.getTarget();
this.xSize = this.hasToolbox() ? 246 : 211;
this.ySize = 184;
}
protected boolean hasToolbox()
{
return ( (ContainerUpgradeable) this.inventorySlots ).hasToolbox();
}
protected boolean hasToolbox() {
return ((ContainerUpgradeable) this.inventorySlots).hasToolbox();
}
@Override
public void initGui()
{
super.initGui();
this.addButtons();
}
@Override
public void initGui() {
super.initGui();
this.addButtons();
}
@Override
public List<Rectangle> getJEIExclusionArea()
{
List<Rectangle> exclusionArea = new ArrayList<>();
@Override
public List<Rectangle> getJEIExclusionArea() {
List<Rectangle> exclusionArea = new ArrayList<>();
int yOffset = guiTop + 8;
int yOffset = guiTop + 8;
int visibleButtons = (int) this.buttonList.stream().filter( v -> v.enabled && v.x < guiLeft ).count();
Rectangle sortDir = new Rectangle( guiLeft - 18, yOffset, 18, visibleButtons * 18 + visibleButtons - 2 );
exclusionArea.add( sortDir );
int visibleButtons = (int) this.buttonList.stream().filter(v -> v.enabled && v.x < guiLeft).count();
Rectangle sortDir = new Rectangle(guiLeft - 18, yOffset, 18, visibleButtons * 18 + visibleButtons - 2);
exclusionArea.add(sortDir);
return exclusionArea;
}
return exclusionArea;
}
protected void addButtons()
{
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.craftMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO );
this.schedulingMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
protected void addButtons() {
this.redstoneMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
this.fuzzyMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
this.craftMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO);
this.schedulingMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 68, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT);
this.buttonList.add( this.craftMode );
this.buttonList.add( this.redstoneMode );
this.buttonList.add( this.fuzzyMode );
this.buttonList.add( this.schedulingMode );
}
this.buttonList.add(this.craftMode);
this.buttonList.add(this.redstoneMode);
this.buttonList.add(this.fuzzyMode);
this.buttonList.add(this.schedulingMode);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( this.getName().getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(this.getName().getLocal()), 8, 6, 4210752);
this.fontRenderer.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 )
{
this.handleButtonVisibility();
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.handleButtonVisibility();
this.bindTexture( this.getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize );
if( this.drawUpgrades() )
{
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvb.availableUpgrades() * 18 );
}
if( this.hasToolbox() )
{
this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68 );
}
}
this.bindTexture(this.getBackground());
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, 211 - 34, this.ySize);
if (this.drawUpgrades()) {
this.drawTexturedModalRect(offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvb.availableUpgrades() * 18);
}
if (this.hasToolbox()) {
this.drawTexturedModalRect(offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68);
}
}
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;
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
if( btn == this.redstoneMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.redstoneMode.getSetting(), backwards ) );
}
if (btn == this.redstoneMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.redstoneMode.getSetting(), backwards));
}
if( btn == this.craftMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.craftMode.getSetting(), backwards ) );
}
if (btn == this.craftMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.craftMode.getSetting(), backwards));
}
if( btn == this.fuzzyMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.fuzzyMode.getSetting(), backwards ) );
}
if (btn == this.fuzzyMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.fuzzyMode.getSetting(), backwards));
}
if( btn == this.schedulingMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.schedulingMode.getSetting(), backwards ) );
}
}
if (btn == this.schedulingMode) {
NetworkHandler.instance().sendToServer(new PacketConfigButton(this.schedulingMode.getSetting(), backwards));
}
}
@Override
public List<Target<?>> getPhantomTargets( Object ingredient )
{
mapTargetSlot.clear();
@Override
public List<Target<?>> getPhantomTargets(Object ingredient) {
mapTargetSlot.clear();
FluidStack fluidStack = null;
ItemStack itemStack = ItemStack.EMPTY;
FluidStack fluidStack = null;
ItemStack itemStack = ItemStack.EMPTY;
if( ingredient instanceof ItemStack )
{
itemStack = (ItemStack) ingredient;
fluidStack = FluidUtil.getFluidContained( itemStack );
}
else if( ingredient instanceof FluidStack )
{
fluidStack = (FluidStack) ingredient;
}
if (ingredient instanceof ItemStack) {
itemStack = (ItemStack) ingredient;
fluidStack = FluidUtil.getFluidContained(itemStack);
} else if (ingredient instanceof FluidStack) {
fluidStack = (FluidStack) ingredient;
}
if( !( ingredient instanceof ItemStack ) && !( ingredient instanceof FluidStack ) )
{
return Collections.emptyList();
}
if (!(ingredient instanceof ItemStack) && !(ingredient instanceof FluidStack)) {
return Collections.emptyList();
}
List<Target<?>> targets = new ArrayList<>();
List<Target<?>> targets = new ArrayList<>();
List<IJEITargetSlot> slots = new ArrayList<>();
if( this.inventorySlots.inventorySlots.size() > 0 )
{
for( Slot slot : this.inventorySlots.inventorySlots )
{
if( slot instanceof SlotFake && ( !itemStack.isEmpty() || this instanceof GuiCellWorkbench && fluidStack != null ) )
{
slots.add( (IJEITargetSlot) slot );
}
}
}
if( this.getGuiSlots().size() > 0 )
{
for( GuiCustomSlot slot : this.getGuiSlots() )
{
if( slot instanceof GuiFluidSlot && fluidStack != null )
{
slots.add( (IJEITargetSlot) slot );
}
}
}
for( Object slot : slots )
{
ItemStack finalItemStack = itemStack;
FluidStack finalFluidStack = fluidStack;
Target<Object> targetItem = new Target<Object>()
{
@Override
public Rectangle getArea()
{
if( slot instanceof SlotFake && ( (SlotFake) slot ).isSlotEnabled() )
{
return new Rectangle( getGuiLeft() + ( (SlotFake) slot ).xPos, getGuiTop() + ( (SlotFake) slot ).yPos, 16, 16 );
}
else if( slot instanceof GuiFluidSlot && ( (GuiFluidSlot) slot ).isSlotEnabled() )
{
return new Rectangle( getGuiLeft() + ( (GuiFluidSlot) slot ).xPos(), getGuiTop() + ( (GuiFluidSlot) slot ).yPos(), 16, 16 );
}
return new Rectangle();
}
List<IJEITargetSlot> slots = new ArrayList<>();
if (this.inventorySlots.inventorySlots.size() > 0) {
for (Slot slot : this.inventorySlots.inventorySlots) {
if (slot instanceof SlotFake && (!itemStack.isEmpty() || this instanceof GuiCellWorkbench && fluidStack != null)) {
slots.add((IJEITargetSlot) slot);
}
}
}
if (this.getGuiSlots().size() > 0) {
for (GuiCustomSlot slot : this.getGuiSlots()) {
if (slot instanceof GuiFluidSlot && fluidStack != null) {
slots.add((IJEITargetSlot) slot);
}
}
}
for (Object slot : slots) {
ItemStack finalItemStack = itemStack;
FluidStack finalFluidStack = fluidStack;
Target<Object> targetItem = new Target<Object>() {
@Override
public Rectangle getArea() {
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
return new Rectangle(getGuiLeft() + ((SlotFake) slot).xPos, getGuiTop() + ((SlotFake) slot).yPos, 16, 16);
} else if (slot instanceof GuiFluidSlot && ((GuiFluidSlot) slot).isSlotEnabled()) {
return new Rectangle(getGuiLeft() + ((GuiFluidSlot) slot).xPos(), getGuiTop() + ((GuiFluidSlot) slot).yPos(), 16, 16);
}
return new Rectangle();
}
@Override
public void accept( Object ingredient )
{
PacketInventoryAction p = null;
try
{
if( slot instanceof SlotFake && ( (SlotFake) slot ).isSlotEnabled() )
{
if( finalItemStack.isEmpty() && finalFluidStack != null )
{
p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack( FluidUtil.getFilledBucket( finalFluidStack ) ) );
}
else if( !finalItemStack.isEmpty() )
{
p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack( finalItemStack ) );
}
}
else
{
if( finalFluidStack == null )
{
return;
}
p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack( AEFluidStack.fromFluidStack( finalFluidStack ).asItemStackRepresentation() ) );
}
NetworkHandler.instance().sendToServer( p );
@Override
public void accept(Object ingredient) {
PacketInventoryAction p = null;
try {
if (slot instanceof SlotFake && ((SlotFake) slot).isSlotEnabled()) {
if (finalItemStack.isEmpty() && finalFluidStack != null) {
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack(FluidUtil.getFilledBucket(finalFluidStack)));
} else if (!finalItemStack.isEmpty()) {
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack(finalItemStack));
}
} else {
if (finalFluidStack == null) {
return;
}
p = new PacketInventoryAction(InventoryAction.PLACE_JEI_GHOST_ITEM, (IJEITargetSlot) slot, AEItemStack.fromItemStack(AEFluidStack.fromFluidStack(finalFluidStack).asItemStackRepresentation()));
}
NetworkHandler.instance().sendToServer(p);
}
catch( IOException e )
{
e.printStackTrace();
}
}
};
targets.add( targetItem );
mapTargetSlot.putIfAbsent( targetItem, slot );
}
return targets;
}
} catch (IOException e) {
e.printStackTrace();
}
}
};
targets.add(targetItem);
mapTargetSlot.putIfAbsent(targetItem, slot);
}
return targets;
}
@Override
public Map<Target<?>, Object> getFakeSlotTargetMap()
{
return mapTargetSlot;
}
@Override
public Map<Target<?>, Object> getFakeSlotTargetMap() {
return mapTargetSlot;
}
}
@@ -19,64 +19,57 @@
package appeng.client.gui.implementations;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiProgressBar;
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.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiVibrationChamber extends AEBaseGui
{
public class GuiVibrationChamber extends AEBaseGui {
private final ContainerVibrationChamber cvc;
private GuiProgressBar pb;
private final ContainerVibrationChamber cvc;
private GuiProgressBar pb;
public GuiVibrationChamber( final InventoryPlayer inventoryPlayer, final TileVibrationChamber te )
{
super( new ContainerVibrationChamber( inventoryPlayer, te ) );
this.cvc = (ContainerVibrationChamber) this.inventorySlots;
this.ySize = 166;
}
public GuiVibrationChamber(final InventoryPlayer inventoryPlayer, final TileVibrationChamber te) {
super(new ContainerVibrationChamber(inventoryPlayer, te));
this.cvc = (ContainerVibrationChamber) this.inventorySlots;
this.ySize = 166;
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.pb = new GuiProgressBar( this.cvc, "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL );
this.buttonList.add( this.pb );
}
this.pb = new GuiProgressBar(this.cvc, "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL);
this.buttonList.add(this.pb);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.VibrationChamber.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.VibrationChamber.getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
this.pb.setFullMsg( TileVibrationChamber.POWER_PER_TICK * this.cvc.getCurrentProgress() / TileVibrationChamber.DILATION_SCALING + " AE/t" );
this.pb.setFullMsg(TileVibrationChamber.POWER_PER_TICK * this.cvc.getCurrentProgress() / TileVibrationChamber.DILATION_SCALING + " AE/t");
if( this.cvc.getRemainingBurnTime() > 0 )
{
final int i1 = this.cvc.getRemainingBurnTime() * 12 / 100;
this.bindTexture( "guis/vibchamber.png" );
GlStateManager.color( 1, 1, 1 );
final int l = -15;
final int k = 25;
this.drawTexturedModalRect( k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2 );
}
}
if (this.cvc.getRemainingBurnTime() > 0) {
final int i1 = this.cvc.getRemainingBurnTime() * 12 / 100;
this.bindTexture("guis/vibchamber.png");
GlStateManager.color(1, 1, 1);
final int l = -15;
final int k = 25;
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
}
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.bindTexture( "guis/vibchamber.png" );
this.pb.x = 99 + this.guiLeft;
this.pb.y = 36 + this.guiTop;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/vibchamber.png");
this.pb.x = 99 + this.guiLeft;
this.pb.y = 36 + this.guiTop;
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}
@@ -19,13 +19,6 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.Settings;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
@@ -34,66 +27,63 @@ import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import java.io.IOException;
public class GuiWireless extends AEBaseGui
{
public class GuiWireless extends AEBaseGui {
private GuiImgButton units;
private GuiImgButton units;
public GuiWireless( final InventoryPlayer inventoryPlayer, final TileWireless te )
{
super( new ContainerWireless( inventoryPlayer, te ) );
this.ySize = 166;
}
public GuiWireless(final InventoryPlayer inventoryPlayer, final TileWireless te) {
super(new ContainerWireless(inventoryPlayer, te));
this.ySize = 166;
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
if( btn == this.units )
{
AEConfig.instance().nextPowerUnit( backwards );
this.units.set( AEConfig.instance().selectedPowerUnit() );
}
}
if (btn == this.units) {
AEConfig.instance().nextPowerUnit(backwards);
this.units.set(AEConfig.instance().selectedPowerUnit());
}
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit() );
this.buttonList.add( this.units );
}
this.units = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit());
this.buttonList.add(this.units);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.Wireless.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.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.fontRenderer.drawString(this.getGuiDisplayName(GuiText.Wireless.getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
final ContainerWireless cw = (ContainerWireless) this.inventorySlots;
final ContainerWireless cw = (ContainerWireless) this.inventorySlots;
if( cw.getRange() > 0 )
{
final String firstMessage = GuiText.Range.getLocal() + ": " + ( cw.getRange() / 10.0 ) + " m";
final String secondMessage = GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( cw.getDrain(), true );
if (cw.getRange() > 0) {
final String firstMessage = GuiText.Range.getLocal() + ": " + (cw.getRange() / 10.0) + " m";
final String secondMessage = GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong(cw.getDrain(), true);
final int strWidth = Math.max( this.fontRenderer.getStringWidth( firstMessage ), this.fontRenderer.getStringWidth( secondMessage ) );
final int cOffset = ( this.xSize / 2 ) - ( strWidth / 2 );
this.fontRenderer.drawString( firstMessage, cOffset, 20, 4210752 );
this.fontRenderer.drawString( secondMessage, cOffset, 20 + 12, 4210752 );
}
}
final int strWidth = Math.max(this.fontRenderer.getStringWidth(firstMessage), this.fontRenderer.getStringWidth(secondMessage));
final int cOffset = (this.xSize / 2) - (strWidth / 2);
this.fontRenderer.drawString(firstMessage, cOffset, 20, 4210752);
this.fontRenderer.drawString(secondMessage, cOffset, 20 + 12, 4210752);
}
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.bindTexture( "guis/wireless.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/wireless.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
}
@@ -19,22 +19,18 @@
package appeng.client.gui.implementations;
import appeng.api.implementations.guiobjects.IPortableCell;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.implementations.guiobjects.IPortableCell;
public class GuiWirelessTerm extends GuiMEPortableCell {
public class GuiWirelessTerm extends GuiMEPortableCell
{
public GuiWirelessTerm(final InventoryPlayer inventoryPlayer, final IPortableCell te) {
super(inventoryPlayer, te);
}
public GuiWirelessTerm( final InventoryPlayer inventoryPlayer, final IPortableCell te )
{
super( inventoryPlayer, te );
}
@Override
int getMaxRows()
{
return this.defaultGetMaxRows();
}
@Override
int getMaxRows() {
return this.defaultGetMaxRows();
}
}
@@ -1,4 +1,3 @@
package appeng.client.gui.widgets;
@@ -8,78 +7,65 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public abstract class GuiCustomSlot extends Gui implements ITooltip
{
protected final int x;
protected final int y;
protected final int id;
public abstract class GuiCustomSlot extends Gui implements ITooltip {
protected final int x;
protected final int y;
protected 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 EntityPlayer player )
{
return true;
}
public boolean canClick(final EntityPlayer 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 )
{
}
public void drawBackground(int guileft, int guitop) {
}
@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;
}
}
@@ -19,422 +19,354 @@
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 net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import appeng.api.config.AccessRestriction;
import appeng.api.config.ActionItems;
import appeng.api.config.CondenserOutput;
import appeng.api.config.FullnessMode;
import appeng.api.config.FuzzyMode;
import appeng.api.config.ItemSubstitution;
import appeng.api.config.LevelType;
import appeng.api.config.OperationMode;
import appeng.api.config.PowerUnits;
import appeng.api.config.RedstoneMode;
import appeng.api.config.RelativeDirection;
import appeng.api.config.SchedulingMode;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.StorageFilter;
import appeng.api.config.TerminalStyle;
import appeng.api.config.ViewItems;
import appeng.api.config.YesNo;
import appeng.core.localization.ButtonToolTips;
public class GuiImgButton extends GuiButton implements ITooltip
{
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 Enum buttonSetting;
private boolean halfSize = false;
private String fillVar;
private Enum currentValue;
public GuiImgButton( final int x, final int y, final Enum idx, final Enum val )
{
super( 0, 0, 16, "" );
this.buttonSetting = idx;
this.currentValue = val;
this.x = x;
this.y = y;
this.width = 16;
this.height = 16;
if( appearances == null )
{
appearances = new HashMap<>();
this.registerApp( 16 * 7, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput, ButtonToolTips.Trash );
this.registerApp( 16 * 7 + 1, Settings.CONDENSER_OUTPUT, CondenserOutput.MATTER_BALLS, ButtonToolTips.CondenserOutput, ButtonToolTips.MatterBalls );
this.registerApp( 16 * 7 + 2, Settings.CONDENSER_OUTPUT, CondenserOutput.SINGULARITY, ButtonToolTips.CondenserOutput, ButtonToolTips.Singularity );
this.registerApp( 16 * 9 + 1, Settings.ACCESS, AccessRestriction.READ, ButtonToolTips.IOMode, ButtonToolTips.Read );
this.registerApp( 16 * 9, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write );
this.registerApp( 16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode, ButtonToolTips.ReadWrite );
this.registerApp( 16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.unlocalizedName );
this.registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName );
this.registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName );
this.registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.GTEU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName );
this.registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive );
this.registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal );
this.registerApp( 1, Settings.REDSTONE_CONTROLLED, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithSignal );
this.registerApp( 2, Settings.REDSTONE_CONTROLLED, RedstoneMode.SIGNAL_PULSE, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveOnPulse );
this.registerApp( 0, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelsBelow );
this.registerApp( 1, Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelAbove );
this.registerApp( 51, Settings.OPERATION_MODE, OperationMode.FILL, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
this.registerApp( 50, Settings.OPERATION_MODE, OperationMode.EMPTY, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
this.registerApp( 51, Settings.IO_DIRECTION, RelativeDirection.LEFT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
this.registerApp( 50, Settings.IO_DIRECTION, RelativeDirection.RIGHT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
this.registerApp( 48, Settings.SORT_DIRECTION, SortDir.ASCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
this.registerApp( 49, Settings.SORT_DIRECTION, SortDir.DESCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
this.registerApp( 16 * 2 + 3, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Auto );
this.registerApp( 16 * 2 + 4, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Standard );
this.registerApp( 16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIAuto );
this.registerApp( 16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIStandard );
this.registerApp( 16 * 2 + 7, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_AutoKeep );
this.registerApp( 16 * 2 + 8, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_StandardKeep );
this.registerApp( 16 * 2 + 9, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIAutoKeep );
this.registerApp( 16 * 2 + 10, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIStandardKeep );
this.registerApp( 16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Energy );
this.registerApp( 16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Item );
this.registerApp( 16 * 13, Settings.TERMINAL_STYLE, TerminalStyle.TALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Tall );
this.registerApp( 16 * 13 + 1, Settings.TERMINAL_STYLE, TerminalStyle.SMALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Small );
this.registerApp( 16 * 13 + 2, Settings.TERMINAL_STYLE, TerminalStyle.FULL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Full );
this.registerApp( 64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName );
this.registerApp( 65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems );
this.registerApp( 68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy, ButtonToolTips.InventoryTweaks );
this.registerApp( 69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod );
this.registerApp( 66, Settings.ACTIONS, ActionItems.WRENCH, ButtonToolTips.PartitionStorage, ButtonToolTips.PartitionStorageHint );
this.registerApp( 6, Settings.ACTIONS, ActionItems.CLOSE, ButtonToolTips.Clear, ButtonToolTips.ClearSettings );
this.registerApp( 6, Settings.ACTIONS, ActionItems.STASH, ButtonToolTips.Stash, ButtonToolTips.StashDesc );
this.registerApp( 6 + 4 * 16, Settings.ACTIONS, ActionItems.MULTIPLY_BY_TWO, ButtonToolTips.MultiplyByTwo, ButtonToolTips.MultiplyByTwoDesc );
this.registerApp( 7 + 4 * 16, Settings.ACTIONS, ActionItems.MULTIPLY_BY_THREE, ButtonToolTips.MultiplyByThree, ButtonToolTips.MultiplyByThreeDesc );
this.registerApp( 8 + 4 * 16, Settings.ACTIONS, ActionItems.INCREASE_BY_ONE, ButtonToolTips.IncreaseByOne, ButtonToolTips.IncreaseByOneDesc );
this.registerApp( 9 + 4 * 16, Settings.ACTIONS, ActionItems.DIVIDE_BY_TWO, ButtonToolTips.DivideByTwo, ButtonToolTips.DivideByTwoDesc );
this.registerApp( 10 + 4 * 16, Settings.ACTIONS, ActionItems.DIVIDE_BY_THREE, ButtonToolTips.DivideByThree, ButtonToolTips.DivideByThreeDesc );
this.registerApp( 11 + 4 * 16, Settings.ACTIONS, ActionItems.DECREASE_BY_ONE, ButtonToolTips.DecreaseByOne, ButtonToolTips.DecreaseByOneDesc );
this.registerApp( 12 + 4 * 16, Settings.ACTIONS, ActionItems.MAX_COUNT, ButtonToolTips.MaxCount, ButtonToolTips.MaxCountDesc );
this.registerApp( 6 + 5 * 16, Settings.ACTIONS, ActionItems.FREE_MOLECULAR_SLOT_SHORTCUT, ButtonToolTips.FreeMolecularSlotShortcut, ButtonToolTips.FreeMolecularSlotShortcutDesc );
this.registerApp( 7 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON, ButtonToolTips.ToggleShowFullInterfaces, ButtonToolTips.ToggleShowFullInterfacesOnDesc );
this.registerApp( 8 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF, ButtonToolTips.ToggleShowFullInterfaces, ButtonToolTips.ToggleShowFullInterfacesOffDesc );
this.registerApp( 6 + 6 * 16, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE, ButtonToolTips.HighlightInterface, "" );
this.registerApp( 8, Settings.ACTIONS, ActionItems.ENCODE, ButtonToolTips.Encode, ButtonToolTips.EncodeDescription );
this.registerApp( 4 + 3 * 16, Settings.ACTIONS, ItemSubstitution.ENABLED, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDescEnabled );
this.registerApp( 7 + 3 * 16, Settings.ACTIONS, ItemSubstitution.DISABLED, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDescDisabled );
this.registerApp( 16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems );
this.registerApp( 18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable );
this.registerApp( 19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable );
this.registerApp( 16 * 6, Settings.FUZZY_MODE, FuzzyMode.PERCENT_25, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_25 );
this.registerApp( 16 * 6 + 1, Settings.FUZZY_MODE, FuzzyMode.PERCENT_50, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_50 );
this.registerApp( 16 * 6 + 2, Settings.FUZZY_MODE, FuzzyMode.PERCENT_75, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_75 );
this.registerApp( 16 * 6 + 3, Settings.FUZZY_MODE, FuzzyMode.PERCENT_99, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_99 );
this.registerApp( 16 * 6 + 4, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, ButtonToolTips.FuzzyMode, ButtonToolTips.FZIgnoreAll );
this.registerApp( 80, Settings.FULLNESS_MODE, FullnessMode.EMPTY, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenEmpty );
this.registerApp( 81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenWorkIsDone );
this.registerApp( 82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenFull );
this.registerApp( 16 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.Blocking );
this.registerApp( 16 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.NonBlocking );
this.registerApp( 16 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly );
this.registerApp( 16 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither );
this.registerApp( 16 * 11 + 2, Settings.CRAFT_VIA_REDSTONE, YesNo.YES, ButtonToolTips.EmitterMode, ButtonToolTips.CraftViaRedstone );
this.registerApp( 16 * 11 + 1, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, ButtonToolTips.EmitterMode, ButtonToolTips.EmitWhenCrafting );
this.registerApp( 16 * 3 + 5, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, ButtonToolTips.ReportInaccessibleItems, ButtonToolTips.ReportInaccessibleItemsNo );
this.registerApp( 16 * 3 + 6, Settings.STORAGE_FILTER, StorageFilter.NONE, ButtonToolTips.ReportInaccessibleItems, ButtonToolTips.ReportInaccessibleItemsYes );
this.registerApp( 16 * 14, Settings.PLACE_BLOCK, YesNo.YES, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementYes );
this.registerApp( 16 * 14 + 1, Settings.PLACE_BLOCK, YesNo.NO, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementNo );
this.registerApp( 16 * 15, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeDefault );
this.registerApp( 16 * 15 + 1, Settings.SCHEDULING_MODE, SchedulingMode.ROUNDROBIN, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeRoundRobin );
this.registerApp( 16 * 15 + 2, Settings.SCHEDULING_MODE, SchedulingMode.RANDOM, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeRandom );
}
}
private void registerApp( final int iconIndex, final Settings setting, final Enum val, final ButtonToolTips title, final Object hint )
{
final ButtonAppearance a = new ButtonAppearance();
a.displayName = title.getUnlocalized();
a.displayValue = (String) ( hint instanceof String ? hint : ( (ButtonToolTips) hint ).getUnlocalized() );
a.index = iconIndex;
appearances.put( new EnumPair( setting, val ), a );
}
public void setVisibility( final boolean vis )
{
this.visible = vis;
this.enabled = vis;
}
@Override
public void drawButton( final Minecraft par1Minecraft, final int par2, final int par3, float partial )
{
if( this.visible )
{
final int iconIndex = this.getIconIndex();
if( this.halfSize )
{
this.width = 8;
this.height = 8;
GlStateManager.pushMatrix();
GlStateManager.translate( this.x, this.y, 0.0F );
GlStateManager.scale( 0.5f, 0.5f, 0.5f );
if( this.enabled )
{
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
}
else
{
GlStateManager.color( 0.5f, 0.5f, 0.5f, 1.0f );
}
par1Minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
final int uv_y = (int) Math.floor( iconIndex / 16 );
final int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16 );
this.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16 );
this.mouseDragged( par1Minecraft, par2, par3 );
GlStateManager.popMatrix();
}
else
{
if( this.enabled )
{
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
}
else
{
GlStateManager.color( 0.5f, 0.5f, 0.5f, 1.0f );
}
par1Minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
final int uv_y = (int) Math.floor( iconIndex / 16 );
final int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16 );
this.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16 );
this.mouseDragged( par1Minecraft, par2, par3 );
}
}
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
}
private 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 Settings getSetting()
{
return (Settings) this.buttonSetting;
}
public Enum getCurrentValue()
{
return this.currentValue;
}
@Override
public String getMessage()
{
String displayName = null;
String displayValue = null;
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";
}
displayName = buttonAppearance.displayName;
displayValue = buttonAppearance.displayValue;
}
if( displayName != null )
{
String name = I18n.translateToLocal( displayName );
String value = I18n.translateToLocal( displayValue );
if( name == null || name.isEmpty() )
{
name = displayName;
}
if( value == null || value.isEmpty() )
{
value = displayValue;
}
if( this.fillVar != null )
{
value = COMPILE.matcher( value ).replaceFirst( this.fillVar );
}
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" );
}
return name + '\n' + sb;
}
return null;
}
@Override
public int xPos()
{
return this.x;
}
@Override
public int yPos()
{
return this.y;
}
@Override
public int getWidth()
{
return this.halfSize ? 8 : 16;
}
@Override
public int getHeight()
{
return this.halfSize ? 8 : 16;
}
@Override
public boolean isVisible()
{
return this.visible;
}
public void set( final Enum e )
{
if( this.currentValue != e )
{
this.currentValue = e;
}
}
public boolean isHalfSize()
{
return this.halfSize;
}
public void setHalfSize( final boolean halfSize )
{
this.halfSize = halfSize;
}
public String getFillVar()
{
return this.fillVar;
}
public void setFillVar( final String fillVar )
{
this.fillVar = fillVar;
}
private static final class EnumPair
{
final Enum setting;
final Enum value;
EnumPair( final Enum a, final Enum b )
{
this.setting = a;
this.value = b;
}
@Override
public int hashCode()
{
return this.setting.hashCode() ^ this.value.hashCode();
}
@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 String displayName;
public String displayValue;
}
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
public class GuiImgButton extends GuiButton implements ITooltip {
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 Enum buttonSetting;
private boolean halfSize = false;
private String fillVar;
private Enum currentValue;
public GuiImgButton(final int x, final int y, final Enum idx, final Enum val) {
super(0, 0, 16, "");
this.buttonSetting = idx;
this.currentValue = val;
this.x = x;
this.y = y;
this.width = 16;
this.height = 16;
if (appearances == null) {
appearances = new HashMap<>();
this.registerApp(16 * 7, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput, ButtonToolTips.Trash);
this.registerApp(16 * 7 + 1, Settings.CONDENSER_OUTPUT, CondenserOutput.MATTER_BALLS, ButtonToolTips.CondenserOutput, ButtonToolTips.MatterBalls);
this.registerApp(16 * 7 + 2, Settings.CONDENSER_OUTPUT, CondenserOutput.SINGULARITY, ButtonToolTips.CondenserOutput, ButtonToolTips.Singularity);
this.registerApp(16 * 9 + 1, Settings.ACCESS, AccessRestriction.READ, ButtonToolTips.IOMode, ButtonToolTips.Read);
this.registerApp(16 * 9, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write);
this.registerApp(16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode, ButtonToolTips.ReadWrite);
this.registerApp(16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.unlocalizedName);
this.registerApp(16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName);
this.registerApp(16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName);
this.registerApp(16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.GTEU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName);
this.registerApp(3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive);
this.registerApp(0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal);
this.registerApp(1, Settings.REDSTONE_CONTROLLED, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithSignal);
this.registerApp(2, Settings.REDSTONE_CONTROLLED, RedstoneMode.SIGNAL_PULSE, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveOnPulse);
this.registerApp(0, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelsBelow);
this.registerApp(1, Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelAbove);
this.registerApp(51, Settings.OPERATION_MODE, OperationMode.FILL, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell);
this.registerApp(50, Settings.OPERATION_MODE, OperationMode.EMPTY, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork);
this.registerApp(51, Settings.IO_DIRECTION, RelativeDirection.LEFT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell);
this.registerApp(50, Settings.IO_DIRECTION, RelativeDirection.RIGHT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork);
this.registerApp(48, Settings.SORT_DIRECTION, SortDir.ASCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection);
this.registerApp(49, Settings.SORT_DIRECTION, SortDir.DESCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection);
this.registerApp(16 * 2 + 3, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Auto);
this.registerApp(16 * 2 + 4, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Standard);
this.registerApp(16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIAuto);
this.registerApp(16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIStandard);
this.registerApp(16 * 2 + 7, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_AutoKeep);
this.registerApp(16 * 2 + 8, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_StandardKeep);
this.registerApp(16 * 2 + 9, Settings.SEARCH_MODE, SearchBoxMode.JEI_AUTOSEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIAutoKeep);
this.registerApp(16 * 2 + 10, Settings.SEARCH_MODE, SearchBoxMode.JEI_MANUAL_SEARCH_KEEP, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_JEIStandardKeep);
this.registerApp(16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Energy);
this.registerApp(16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Item);
this.registerApp(16 * 13, Settings.TERMINAL_STYLE, TerminalStyle.TALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Tall);
this.registerApp(16 * 13 + 1, Settings.TERMINAL_STYLE, TerminalStyle.SMALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Small);
this.registerApp(16 * 13 + 2, Settings.TERMINAL_STYLE, TerminalStyle.FULL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Full);
this.registerApp(64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName);
this.registerApp(65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems);
this.registerApp(68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy, ButtonToolTips.InventoryTweaks);
this.registerApp(69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod);
this.registerApp(66, Settings.ACTIONS, ActionItems.WRENCH, ButtonToolTips.PartitionStorage, ButtonToolTips.PartitionStorageHint);
this.registerApp(6, Settings.ACTIONS, ActionItems.CLOSE, ButtonToolTips.Clear, ButtonToolTips.ClearSettings);
this.registerApp(6, Settings.ACTIONS, ActionItems.STASH, ButtonToolTips.Stash, ButtonToolTips.StashDesc);
this.registerApp(6 + 4 * 16, Settings.ACTIONS, ActionItems.MULTIPLY_BY_TWO, ButtonToolTips.MultiplyByTwo, ButtonToolTips.MultiplyByTwoDesc);
this.registerApp(7 + 4 * 16, Settings.ACTIONS, ActionItems.MULTIPLY_BY_THREE, ButtonToolTips.MultiplyByThree, ButtonToolTips.MultiplyByThreeDesc);
this.registerApp(8 + 4 * 16, Settings.ACTIONS, ActionItems.INCREASE_BY_ONE, ButtonToolTips.IncreaseByOne, ButtonToolTips.IncreaseByOneDesc);
this.registerApp(9 + 4 * 16, Settings.ACTIONS, ActionItems.DIVIDE_BY_TWO, ButtonToolTips.DivideByTwo, ButtonToolTips.DivideByTwoDesc);
this.registerApp(10 + 4 * 16, Settings.ACTIONS, ActionItems.DIVIDE_BY_THREE, ButtonToolTips.DivideByThree, ButtonToolTips.DivideByThreeDesc);
this.registerApp(11 + 4 * 16, Settings.ACTIONS, ActionItems.DECREASE_BY_ONE, ButtonToolTips.DecreaseByOne, ButtonToolTips.DecreaseByOneDesc);
this.registerApp(12 + 4 * 16, Settings.ACTIONS, ActionItems.MAX_COUNT, ButtonToolTips.MaxCount, ButtonToolTips.MaxCountDesc);
this.registerApp(6 + 5 * 16, Settings.ACTIONS, ActionItems.FREE_MOLECULAR_SLOT_SHORTCUT, ButtonToolTips.FreeMolecularSlotShortcut, ButtonToolTips.FreeMolecularSlotShortcutDesc);
this.registerApp(7 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON, ButtonToolTips.ToggleShowFullInterfaces, ButtonToolTips.ToggleShowFullInterfacesOnDesc);
this.registerApp(8 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF, ButtonToolTips.ToggleShowFullInterfaces, ButtonToolTips.ToggleShowFullInterfacesOffDesc);
this.registerApp(6 + 6 * 16, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE, ButtonToolTips.HighlightInterface, "");
this.registerApp(8, Settings.ACTIONS, ActionItems.ENCODE, ButtonToolTips.Encode, ButtonToolTips.EncodeDescription);
this.registerApp(4 + 3 * 16, Settings.ACTIONS, ItemSubstitution.ENABLED, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDescEnabled);
this.registerApp(7 + 3 * 16, Settings.ACTIONS, ItemSubstitution.DISABLED, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDescDisabled);
this.registerApp(16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems);
this.registerApp(18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable);
this.registerApp(19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable);
this.registerApp(16 * 6, Settings.FUZZY_MODE, FuzzyMode.PERCENT_25, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_25);
this.registerApp(16 * 6 + 1, Settings.FUZZY_MODE, FuzzyMode.PERCENT_50, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_50);
this.registerApp(16 * 6 + 2, Settings.FUZZY_MODE, FuzzyMode.PERCENT_75, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_75);
this.registerApp(16 * 6 + 3, Settings.FUZZY_MODE, FuzzyMode.PERCENT_99, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_99);
this.registerApp(16 * 6 + 4, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, ButtonToolTips.FuzzyMode, ButtonToolTips.FZIgnoreAll);
this.registerApp(80, Settings.FULLNESS_MODE, FullnessMode.EMPTY, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenEmpty);
this.registerApp(81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenWorkIsDone);
this.registerApp(82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenFull);
this.registerApp(16 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.Blocking);
this.registerApp(16 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.NonBlocking);
this.registerApp(16 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly);
this.registerApp(16 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither);
this.registerApp(16 * 11 + 2, Settings.CRAFT_VIA_REDSTONE, YesNo.YES, ButtonToolTips.EmitterMode, ButtonToolTips.CraftViaRedstone);
this.registerApp(16 * 11 + 1, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, ButtonToolTips.EmitterMode, ButtonToolTips.EmitWhenCrafting);
this.registerApp(16 * 3 + 5, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, ButtonToolTips.ReportInaccessibleItems, ButtonToolTips.ReportInaccessibleItemsNo);
this.registerApp(16 * 3 + 6, Settings.STORAGE_FILTER, StorageFilter.NONE, ButtonToolTips.ReportInaccessibleItems, ButtonToolTips.ReportInaccessibleItemsYes);
this.registerApp(16 * 14, Settings.PLACE_BLOCK, YesNo.YES, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementYes);
this.registerApp(16 * 14 + 1, Settings.PLACE_BLOCK, YesNo.NO, ButtonToolTips.BlockPlacement, ButtonToolTips.BlockPlacementNo);
this.registerApp(16 * 15, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeDefault);
this.registerApp(16 * 15 + 1, Settings.SCHEDULING_MODE, SchedulingMode.ROUNDROBIN, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeRoundRobin);
this.registerApp(16 * 15 + 2, Settings.SCHEDULING_MODE, SchedulingMode.RANDOM, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeRandom);
}
}
private void registerApp(final int iconIndex, final Settings setting, final Enum val, final ButtonToolTips title, final Object hint) {
final ButtonAppearance a = new ButtonAppearance();
a.displayName = title.getUnlocalized();
a.displayValue = (String) (hint instanceof String ? hint : ((ButtonToolTips) hint).getUnlocalized());
a.index = iconIndex;
appearances.put(new EnumPair(setting, val), a);
}
public void setVisibility(final boolean vis) {
this.visible = vis;
this.enabled = vis;
}
@Override
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3, float partial) {
if (this.visible) {
final int iconIndex = this.getIconIndex();
if (this.halfSize) {
this.width = 8;
this.height = 8;
GlStateManager.pushMatrix();
GlStateManager.translate(this.x, this.y, 0.0F);
GlStateManager.scale(0.5f, 0.5f, 0.5f);
if (this.enabled) {
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
} else {
GlStateManager.color(0.5f, 0.5f, 0.5f, 1.0f);
}
par1Minecraft.renderEngine.bindTexture(new ResourceLocation("appliedenergistics2", "textures/guis/states.png"));
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
final int uv_y = (int) Math.floor(iconIndex / 16);
final int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect(0, 0, 256 - 16, 256 - 16, 16, 16);
this.drawTexturedModalRect(0, 0, uv_x * 16, uv_y * 16, 16, 16);
this.mouseDragged(par1Minecraft, par2, par3);
GlStateManager.popMatrix();
} else {
if (this.enabled) {
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
} else {
GlStateManager.color(0.5f, 0.5f, 0.5f, 1.0f);
}
par1Minecraft.renderEngine.bindTexture(new ResourceLocation("appliedenergistics2", "textures/guis/states.png"));
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
final int uv_y = (int) Math.floor(iconIndex / 16);
final int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect(this.x, this.y, 256 - 16, 256 - 16, 16, 16);
this.drawTexturedModalRect(this.x, this.y, uv_x * 16, uv_y * 16, 16, 16);
this.mouseDragged(par1Minecraft, par2, par3);
}
}
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
}
private 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 Settings getSetting() {
return (Settings) this.buttonSetting;
}
public Enum getCurrentValue() {
return this.currentValue;
}
@Override
public String getMessage() {
String displayName = null;
String displayValue = null;
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";
}
displayName = buttonAppearance.displayName;
displayValue = buttonAppearance.displayValue;
}
if (displayName != null) {
String name = I18n.translateToLocal(displayName);
String value = I18n.translateToLocal(displayValue);
if (name == null || name.isEmpty()) {
name = displayName;
}
if (value == null || value.isEmpty()) {
value = displayValue;
}
if (this.fillVar != null) {
value = COMPILE.matcher(value).replaceFirst(this.fillVar);
}
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");
}
return name + '\n' + sb;
}
return null;
}
@Override
public int xPos() {
return this.x;
}
@Override
public int yPos() {
return this.y;
}
@Override
public int getWidth() {
return this.halfSize ? 8 : 16;
}
@Override
public int getHeight() {
return this.halfSize ? 8 : 16;
}
@Override
public boolean isVisible() {
return this.visible;
}
public void set(final Enum e) {
if (this.currentValue != e) {
this.currentValue = e;
}
}
public boolean isHalfSize() {
return this.halfSize;
}
public void setHalfSize(final boolean halfSize) {
this.halfSize = halfSize;
}
public String getFillVar() {
return this.fillVar;
}
public void setFillVar(final String fillVar) {
this.fillVar = fillVar;
}
private static final class EnumPair {
final Enum setting;
final Enum value;
EnumPair(final Enum a, final Enum b) {
this.setting = a;
this.value = b;
}
@Override
public int hashCode() {
return this.setting.hashCode() ^ this.value.hashCode();
}
@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 String displayName;
public String displayValue;
}
}
@@ -23,41 +23,30 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
public class GuiNumberBox extends GuiTextField
{
public class GuiNumberBox extends GuiTextField {
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( 0, fontRenderer, x, y, width, height );
this.type = type;
}
public GuiNumberBox(final FontRenderer fontRenderer, final int x, final int y, final int width, final int height, final Class type) {
super(0, fontRenderer, x, y, width, height);
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);
}
}
}
@@ -19,118 +19,100 @@
package appeng.client.gui.widgets;
import appeng.container.interfaces.IProgressProvider;
import appeng.core.localization.GuiText;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import appeng.container.interfaces.IProgressProvider;
import appeng.core.localization.GuiText;
public class GuiProgressBar extends GuiButton implements ITooltip {
public class GuiProgressBar extends GuiButton 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, "");
this.source = source;
this.x = posX;
this.y = posY;
this.texture = new ResourceLocation("appliedenergistics2", "textures/" + texture);
this.width = width;
this.height = height;
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, "" );
this.source = source;
this.x = posX;
this.y = posY;
this.texture = new ResourceLocation( "appliedenergistics2", "textures/" + texture );
this.width = width;
this.height = height;
this.fill_u = u;
this.fill_v = y;
this.layout = dir;
this.titleName = title;
}
@Override
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3, final float partial) {
if (this.visible) {
par1Minecraft.getTextureManager().bindTexture(this.texture);
final int max = this.source.getMaxProgress();
final int current = this.source.getCurrentProgress();
@Override
public void drawButton( final Minecraft par1Minecraft, final int par2, final int par3, final float partial )
{
if( this.visible )
{
par1Minecraft.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);
this.drawTexturedModalRect(this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width, this.height - diff);
} else {
final int diff = this.width - (max > 0 ? (this.width * current) / max : 0);
this.drawTexturedModalRect(this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff, this.height);
}
if( this.layout == Direction.VERTICAL )
{
final int diff = this.height - ( max > 0 ? ( this.height * current ) / max : 0 );
this.drawTexturedModalRect( this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width, this.height - diff );
}
else
{
final int diff = this.width - ( max > 0 ? ( this.width * current ) / max : 0 );
this.drawTexturedModalRect( this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff, this.height );
}
this.mouseDragged(par1Minecraft, par2, par3);
}
}
this.mouseDragged( par1Minecraft, par2, par3 );
}
}
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
}
}
@@ -19,137 +19,113 @@
package appeng.client.gui.widgets;
import appeng.client.gui.AEBaseGui;
import net.minecraft.client.renderer.GlStateManager;
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");
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
public void draw( final AEBaseGui g )
{
g.bindTexture( "minecraft", "gui/container/creative_inventory/tabs.png" );
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
if (this.getRange() == 0) {
g.drawTexturedModalRect(this.displayX, this.displayY, 232 + this.width, 0, this.width, 15);
} else {
final int offset = (this.currentScroll - this.minScroll) * (this.height - 15) / this.getRange();
g.drawTexturedModalRect(this.displayX, offset + this.displayY, 232, 0, this.width, 15);
}
}
if( this.getRange() == 0 )
{
g.drawTexturedModalRect( this.displayX, this.displayY, 232 + this.width, 0, this.width, 15 );
}
else
{
final int offset = ( this.currentScroll - this.minScroll ) * ( this.height - 15 ) / this.getRange();
g.drawTexturedModalRect( this.displayX, offset + this.displayY, 232, 0, this.width, 15 );
}
}
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 AEBaseGui aeBaseGui, final int x, final int y) {
if (this.getRange() == 0) {
return;
}
public void click( final AEBaseGui aeBaseGui, final int x, final int 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 = (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 = ( 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( int delta )
{
delta = Math.max( Math.min( -delta, 1 ), -1 );
this.currentScroll += delta * this.pageSize;
this.applyRange();
}
public void wheel(int delta) {
delta = Math.max(Math.min(-delta, 1), -1);
this.currentScroll += delta * this.pageSize;
this.applyRange();
}
}
@@ -28,132 +28,117 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public class GuiTabButton extends GuiButton implements ITooltip
{
private final RenderItem itemRenderer;
private final String message;
private int hideEdge = 0;
private int myIcon = -1;
private ItemStack myItem;
public class GuiTabButton extends GuiButton implements ITooltip {
private final RenderItem itemRenderer;
private final String message;
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 RenderItem ir )
{
super( 0, 0, 16, "" );
public GuiTabButton(final int x, final int y, final int ico, final String message, final RenderItem ir) {
super(0, 0, 16, "");
this.x = x;
this.y = y;
this.width = 22;
this.height = 22;
this.myIcon = ico;
this.message = message;
this.itemRenderer = ir;
}
this.x = x;
this.y = y;
this.width = 22;
this.height = 22;
this.myIcon = ico;
this.message = message;
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 RenderItem ir )
{
super( 0, 0, 16, "" );
this.x = x;
this.y = y;
this.width = 22;
this.height = 22;
this.myItem = ico;
this.message = message;
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 RenderItem ir) {
super(0, 0, 16, "");
this.x = x;
this.y = y;
this.width = 22;
this.height = 22;
this.myItem = ico;
this.message = message;
this.itemRenderer = ir;
}
@Override
public void drawButton( final Minecraft minecraft, final int x, final int y, float partial )
{
if( this.visible )
{
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height;
@Override
public void drawButton(final Minecraft minecraft, final int x, final int y, float partial) {
if (this.visible) {
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
minecraft.renderEngine.bindTexture(new ResourceLocation("appliedenergistics2", "textures/guis/states.png"));
this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height;
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;
this.drawTexturedModalRect( this.x, this.y, uv_x * 16, 0, 25, 22 );
this.drawTexturedModalRect(this.x, this.y, uv_x * 16, 0, 25, 22);
if( this.myIcon >= 0 )
{
final int uv_y = (int) Math.floor( this.myIcon / 16 );
uv_x = this.myIcon - uv_y * 16;
if (this.myIcon >= 0) {
final int uv_y = (int) Math.floor(this.myIcon / 16);
uv_x = this.myIcon - uv_y * 16;
this.drawTexturedModalRect( offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16 );
}
this.drawTexturedModalRect(offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16);
}
this.mouseDragged( minecraft, x, y );
this.mouseDragged(minecraft, x, y);
if( this.myItem != null )
{
this.zLevel = 100.0F;
this.itemRenderer.zLevel = 100.0F;
if (this.myItem != null) {
this.zLevel = 100.0F;
this.itemRenderer.zLevel = 100.0F;
GlStateManager.enableDepth();
RenderHelper.enableGUIStandardItemLighting();
this.itemRenderer.renderItemAndEffectIntoGUI( this.myItem, offsetX + this.x + 3, this.y + 3 );
GlStateManager.disableDepth();
GlStateManager.enableDepth();
RenderHelper.enableGUIStandardItemLighting();
this.itemRenderer.renderItemAndEffectIntoGUI(this.myItem, offsetX + this.x + 3, this.y + 3);
GlStateManager.disableDepth();
this.itemRenderer.zLevel = 0.0F;
this.zLevel = 0.0F;
}
}
}
this.itemRenderer.zLevel = 0.0F;
this.zLevel = 0.0F;
}
}
}
@Override
public String getMessage()
{
return this.message;
}
@Override
public String getMessage() {
return this.message;
}
@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;
}
}
@@ -19,131 +19,114 @@
package appeng.client.gui.widgets;
import java.util.regex.Pattern;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import java.util.regex.Pattern;
public class GuiToggleButton extends GuiButton implements ITooltip
{
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;
public class GuiToggleButton extends GuiButton implements ITooltip {
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
private final int iconIdxOn;
private final int iconIdxOff;
private boolean isActive;
private final String displayName;
private final String displayHint;
public GuiToggleButton( final int x, final int y, final int on, final int off, final String displayName, final String displayHint )
{
super( 0, 0, 16, "" );
this.iconIdxOn = on;
this.iconIdxOff = off;
this.displayName = displayName;
this.displayHint = displayHint;
this.x = x;
this.y = y;
this.width = 16;
this.height = 16;
}
private boolean isActive;
public void setState( final boolean isOn )
{
this.isActive = isOn;
}
public GuiToggleButton(final int x, final int y, final int on, final int off, final String displayName, final String displayHint) {
super(0, 0, 16, "");
this.iconIdxOn = on;
this.iconIdxOff = off;
this.displayName = displayName;
this.displayHint = displayHint;
this.x = x;
this.y = y;
this.width = 16;
this.height = 16;
}
@Override
public void drawButton( final Minecraft par1Minecraft, final int par2, final int par3, final float partial )
{
if( this.visible )
{
final int iconIndex = this.getIconIndex();
public void setState(final boolean isOn) {
this.isActive = isOn;
}
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
par1Minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
@Override
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3, final float partial) {
if (this.visible) {
final int iconIndex = this.getIconIndex();
final int uv_y = (int) Math.floor( iconIndex / 16 );
final int uv_x = iconIndex - uv_y * 16;
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
par1Minecraft.renderEngine.bindTexture(new ResourceLocation("appliedenergistics2", "textures/guis/states.png"));
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
this.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16 );
this.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16 );
this.mouseDragged( par1Minecraft, par2, par3 );
}
}
final int uv_y = (int) Math.floor(iconIndex / 16);
final int uv_x = iconIndex - uv_y * 16;
private int getIconIndex()
{
return this.isActive ? this.iconIdxOn : this.iconIdxOff;
}
this.drawTexturedModalRect(this.x, this.y, 256 - 16, 256 - 16, 16, 16);
this.drawTexturedModalRect(this.x, this.y, uv_x * 16, uv_y * 16, 16, 16);
this.mouseDragged(par1Minecraft, par2, par3);
}
}
@Override
public String getMessage()
{
if( this.displayName != null )
{
String name = I18n.translateToLocal( this.displayName );
String value = I18n.translateToLocal( this.displayHint );
private int getIconIndex() {
return this.isActive ? this.iconIdxOn : this.iconIdxOff;
}
if( name == null || name.isEmpty() )
{
name = this.displayName;
}
if( value == null || value.isEmpty() )
{
value = this.displayHint;
}
@Override
public String getMessage() {
if (this.displayName != null) {
String name = I18n.translateToLocal(this.displayName);
String value = I18n.translateToLocal(this.displayHint);
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
final StringBuilder sb = new StringBuilder( value );
if (name == null || name.isEmpty()) {
name = this.displayName;
}
if (value == null || value.isEmpty()) {
value = this.displayHint;
}
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");
}
@Override
public int xPos()
{
return this.x;
}
return name + '\n' + sb;
}
return null;
}
@Override
public int yPos()
{
return this.y;
}
@Override
public int xPos() {
return this.x;
}
@Override
public int getWidth()
{
return 16;
}
@Override
public int yPos() {
return this.y;
}
@Override
public int getHeight()
{
return 16;
}
@Override
public int getWidth() {
return 16;
}
@Override
public boolean isVisible()
{
return this.visible;
}
@Override
public int getHeight() {
return 16;
}
@Override
public boolean isVisible() {
return this.visible;
}
}
@@ -19,8 +19,7 @@
package appeng.client.gui.widgets;
public interface IScrollSource
{
public interface IScrollSource {
int getCurrentScroll();
int getCurrentScroll();
}
@@ -23,21 +23,20 @@ import appeng.api.config.SortDir;
import appeng.api.config.ViewItems;
public interface ISortSource
{
public interface ISortSource {
/**
* @return Sor
*/
Enum getSortBy();
/**
* @return Sor
*/
Enum getSortBy();
/**
* @return {@link SortDir}
*/
Enum getSortDir();
/**
* @return {@link SortDir}
*/
Enum getSortDir();
/**
* @return {@link ViewItems}
*/
Enum getSortDisplay();
/**
* @return {@link ViewItems}
*/
Enum getSortDisplay();
}
@@ -22,46 +22,45 @@ 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();
}
@@ -33,197 +33,179 @@ import org.lwjgl.input.Keyboard;
* You can initialize it over the full element span.
* The mouse click area is increased to the full element
* subtracted with the defined padding.
*
* <p>
* The rendering does pay attention to the size of the '_' caret.
*/
public class MEGuiTextField extends GuiTextField
{
private static final int PADDING = 2;
public class MEGuiTextField extends GuiTextField {
private static final int PADDING = 2;
private final int _xPos;
private final int _yPos;
private final int _width;
private final int _height;
private final int _fontPad;
private int selectionColor = 0xFF00FF00;
private final int _xPos;
private final int _yPos;
private final int _width;
private final int _height;
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( 0, fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - 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(0, fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth('_'), height - 2 * PADDING);
this._fontPad = fontRenderer.getCharWidth( '_' );
this._xPos = xPos;
this._yPos = yPos;
this._width = width;
this._height = height;
}
this._fontPad = fontRenderer.getCharWidth('_');
this._xPos = xPos;
this._yPos = yPos;
this._width = width;
this._height = height;
}
public void onTextChange(final String oldText) {}
public void onTextChange(final String oldText) {
}
@Override
public boolean mouseClicked( final int xPos, final int yPos, final int button )
{
super.mouseClicked( xPos, yPos, button );
@Override
public boolean mouseClicked(final int xPos, final int yPos, final int button) {
super.mouseClicked(xPos, yPos, button);
final boolean requiresFocus = this.isMouseIn( xPos, yPos );
if( !this.isFocused() )
{
this.setFocused( requiresFocus );
}
final boolean requiresFocus = this.isMouseIn(xPos, yPos);
if (!this.isFocused()) {
this.setFocused(requiresFocus);
}
return true;
}
return true;
}
/**
* Checks if the mouse is within the element
*
* @param xCoord current x coord of the mouse
* @param yCoord current y coord of the mouse
*
* @return true if mouse position is within the text field area
*/
public boolean isMouseIn( final int xCoord, final int yCoord )
{
final boolean withinXRange = this._xPos <= xCoord && xCoord < this._xPos + this._width;
final boolean withinYRange = this._yPos <= yCoord && yCoord < this._yPos + this._height;
/**
* Checks if the mouse is within the element
*
* @param xCoord current x coord of the mouse
* @param yCoord current y coord of the mouse
* @return true if mouse position is within the text field area
*/
public boolean isMouseIn(final int xCoord, final int yCoord) {
final boolean withinXRange = this._xPos <= xCoord && xCoord < this._xPos + this._width;
final boolean withinYRange = this._yPos <= yCoord && yCoord < this._yPos + this._height;
return withinXRange && withinYRange;
}
return withinXRange && withinYRange;
}
public boolean textboxKeyTyped(final char keyChar, final int keyID) {
if (!isFocused()) {
return false;
}
public boolean textboxKeyTyped(final char keyChar, final int keyID) {
if (!isFocused()) {
return false;
}
final String oldText = getText();
boolean handled = super.textboxKeyTyped(keyChar, keyID);
final String oldText = getText();
boolean handled = super.textboxKeyTyped(keyChar, keyID);
if (!handled
&& (keyID == Keyboard.KEY_RETURN
|| keyID == Keyboard.KEY_NUMPADENTER
|| keyID == Keyboard.KEY_ESCAPE)) {
setFocused(false);
}
if (!handled
&& (keyID == Keyboard.KEY_RETURN
|| keyID == Keyboard.KEY_NUMPADENTER
|| keyID == Keyboard.KEY_ESCAPE)) {
setFocused(false);
}
if (handled) {
onTextChange(oldText);
}
if (handled) {
onTextChange(oldText);
}
return handled;
}
return handled;
}
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 drawTextBox()
{
if( this.getVisible() )
{
if( this.isFocused() )
{
drawRect( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
0xFF606060 );
}
else
{
drawRect( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
0xFFA8A8A8 );
}
super.drawTextBox();
}
}
@Override
public void drawTextBox() {
if (this.getVisible()) {
if (this.isFocused()) {
drawRect(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
0xFF606060);
} else {
drawRect(this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
0xFFA8A8A8);
}
super.drawTextBox();
}
}
public void setText(String text, boolean ignoreTrigger) {
final String oldText = getText();
public void setText(String text, boolean ignoreTrigger) {
final String oldText = getText();
super.setText(text);
super.setCursorPositionEnd();
super.setText(text);
super.setCursorPositionEnd();
if (!ignoreTrigger) {
onTextChange(oldText);
}
}
if (!ignoreTrigger) {
onTextChange(oldText);
}
}
public void setText(String text) {
setText(text, false);
}
public void setText(String text) {
setText(text, false);
}
@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;
GlStateManager.color( red, green, blue, alpha );
GlStateManager.disableTexture2D();
GlStateManager.enableColorLogic();
GlStateManager.colorLogicOp( 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();
GlStateManager.disableColorLogic();
GlStateManager.enableTexture2D();
}
GlStateManager.color(red, green, blue, alpha);
GlStateManager.disableTexture2D();
GlStateManager.enableColorLogic();
GlStateManager.colorLogicOp(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();
GlStateManager.disableColorLogic();
GlStateManager.enableTexture2D();
}
}