Skip to content

Commit

Permalink
Merge pull request #1522 from yueh/feature-12
Browse files Browse the repository at this point in the history
Closes #12 Added visual lock state to monitors
  • Loading branch information
yueh committed Jun 13, 2015
2 parents 73ffbb2 + 5aaaeb6 commit 256c025
Show file tree
Hide file tree
Showing 26 changed files with 1,523 additions and 1,123 deletions.
Expand Up @@ -45,7 +45,7 @@
import appeng.client.me.SlotDisconnected;
import appeng.container.implementations.ContainerInterfaceTerminal;
import appeng.core.localization.GuiText;
import appeng.parts.reporting.PartMonitor;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.util.Platform;


Expand All @@ -67,7 +67,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
private boolean refreshList = false;
private MEGuiTextField searchField;

public GuiInterfaceTerminal( InventoryPlayer inventoryPlayer, PartMonitor te )
public GuiInterfaceTerminal( InventoryPlayer inventoryPlayer, PartInterfaceTerminal te )
{
super( new ContainerInterfaceTerminal( inventoryPlayer, te ) );
this.myScrollBar = new GuiScrollbar();
Expand Down
Expand Up @@ -62,6 +62,7 @@
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.parts.reporting.AbstractPartTerminal;
import appeng.parts.reporting.PartTerminal;
import appeng.tile.misc.TileSecurity;
import appeng.util.IConfigManagerHost;
Expand Down Expand Up @@ -139,7 +140,7 @@ else if( te instanceof IMEChest )
{
this.myName = GuiText.Chest;
}
else if( te instanceof PartTerminal )
else if( te instanceof AbstractPartTerminal )
{
this.myName = GuiText.Terminal;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/appeng/client/texture/CableBusTextures.java
Expand Up @@ -47,13 +47,13 @@ public enum CableBusTextures

PartPatternTerm_Bright( "PartPatternTerm_Bright" ), PartPatternTerm_Colored( "PartPatternTerm_Colored" ), PartPatternTerm_Dark( "PartPatternTerm_Dark" ),

PartConversionMonitor_Bright( "PartConversionMonitor_Bright" ), PartConversionMonitor_Colored( "PartConversionMonitor_Colored" ), PartConversionMonitor_Dark( "PartConversionMonitor_Dark" ),
PartConversionMonitor_Bright( "PartConversionMonitor_Bright" ), PartConversionMonitor_Colored( "PartConversionMonitor_Colored" ), PartConversionMonitor_Dark( "PartConversionMonitor_Dark" ), PartConversionMonitor_Dark_Locked( "PartConversionMonitor_Dark_Locked" ),

PartInterfaceTerm_Bright( "PartInterfaceTerm_Bright" ), PartInterfaceTerm_Colored( "PartInterfaceTerm_Colored" ), PartInterfaceTerm_Dark( "PartInterfaceTerm_Dark" ),

PartCraftingTerm_Bright( "PartCraftingTerm_Bright" ), PartCraftingTerm_Colored( "PartCraftingTerm_Colored" ), PartCraftingTerm_Dark( "PartCraftingTerm_Dark" ), //

PartStorageMonitor_Bright( "PartStorageMonitor_Bright" ), PartStorageMonitor_Colored( "PartStorageMonitor_Colored" ), PartStorageMonitor_Dark( "PartStorageMonitor_Dark" ),
PartStorageMonitor_Bright( "PartStorageMonitor_Bright" ), PartStorageMonitor_Colored( "PartStorageMonitor_Colored" ), PartStorageMonitor_Dark( "PartStorageMonitor_Dark" ), PartStorageMonitor_Colored_Locked( "PartStorageMonitor_Colored_Locked" ),

PartTerminal_Bright( "PartTerminal_Bright" ), PartTerminal_Colored( "PartTerminal_Colored" ), PartTerminal_Dark( "PartTerminal_Dark" ),

Expand Down
Expand Up @@ -44,7 +44,7 @@
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.parts.misc.PartInterface;
import appeng.parts.reporting.PartMonitor;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.misc.TileInterface;
import appeng.util.InventoryAdaptor;
Expand All @@ -67,7 +67,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
IGrid grid;
NBTTagCompound data = new NBTTagCompound();

public ContainerInterfaceTerminal( InventoryPlayer ip, PartMonitor anchor )
public ContainerInterfaceTerminal( InventoryPlayer ip, PartInterfaceTerminal anchor )
{
super( ip, anchor );

Expand Down Expand Up @@ -419,7 +419,6 @@ public InvTracker( DualityInterface dual, IInventory patterns, String unlocalize
}
}


static class PatternInvSlot extends WrapperInvSlot
{

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/appeng/core/sync/GuiBridge.java
Expand Up @@ -100,7 +100,8 @@
import appeng.parts.automation.PartLevelEmitter;
import appeng.parts.misc.PartStorageBus;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartMonitor;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.parts.reporting.PartPanel;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.tile.crafting.TileCraftingTile;
import appeng.tile.crafting.TileMolecularAssembler;
Expand Down Expand Up @@ -187,7 +188,7 @@ public enum GuiBridge implements IGuiHandler

GUI_CRAFTING_CONFIRM( ContainerCraftConfirm.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT ),

GUI_INTERFACE_TERMINAL( ContainerInterfaceTerminal.class, PartMonitor.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
GUI_INTERFACE_TERMINAL( ContainerInterfaceTerminal.class, PartInterfaceTerminal.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),

GUI_CRAFTING_STATUS( ContainerCraftingStatus.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT );

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/appeng/items/parts/PartType.java
Expand Up @@ -54,11 +54,11 @@
import appeng.parts.p2p.PartP2PTunnelME;
import appeng.parts.reporting.PartConversionMonitor;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartDarkMonitor;
import appeng.parts.reporting.PartDarkPanel;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.parts.reporting.PartMonitor;
import appeng.parts.reporting.PartPanel;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartSemiDarkMonitor;
import appeng.parts.reporting.PartSemiDarkPanel;
import appeng.parts.reporting.PartStorageMonitor;
import appeng.parts.reporting.PartTerminal;

Expand Down Expand Up @@ -111,11 +111,11 @@ public boolean isCable()

QuartzFiber( 140, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartQuartzFiber.class ),

Monitor( 160, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartMonitor.class ),
Monitor( 160, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartPanel.class ),

SemiDarkMonitor( 180, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartSemiDarkMonitor.class ),
SemiDarkMonitor( 180, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartSemiDarkPanel.class ),

DarkMonitor( 200, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartDarkMonitor.class ),
DarkMonitor( 200, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartDarkPanel.class ),

StorageBus( 220, EnumSet.of( AEFeature.StorageBus ), EnumSet.noneOf( IntegrationType.class ), PartStorageBus.class ),

Expand Down
18 changes: 11 additions & 7 deletions src/main/java/appeng/parts/AEBasePart.java
Expand Up @@ -25,6 +25,8 @@
import java.util.List;
import java.util.Random;

import com.google.common.base.Preconditions;

import io.netty.buffer.ByteBuf;

import net.minecraft.client.renderer.RenderBlocks;
Expand Down Expand Up @@ -85,6 +87,8 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,

public AEBasePart( ItemStack is )
{
Preconditions.checkNotNull( is );

this.is = is;
this.proxy = new AENetworkProxy( this, "part", is, this instanceof PartCable );
this.proxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
Expand Down Expand Up @@ -139,7 +143,9 @@ public void getBoxes( IPartCollisionHelper bch )
public int getInstalledUpgrades( Upgrades u )
{
return 0;
} @Override
}

@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
Expand Down Expand Up @@ -189,7 +195,9 @@ public void saveChanges()
public String getCustomName()
{
return this.is.getDisplayName();
} @Override
}

@Override
@SideOnly( Side.CLIENT )
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
Expand All @@ -208,10 +216,6 @@ public void addEntityCrashInfo( CrashReportCategory crashreportcategory )
crashreportcategory.addCrashSection( "Part Side", this.side );
}





@Override
@SideOnly( Side.CLIENT )
public void renderDynamic( double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer )
Expand Down Expand Up @@ -369,7 +373,7 @@ public IInventory getInventoryByName( String name )
/**
* depending on the from, different settings will be accepted, don't call this with null
*
* @param from source of settings
* @param from source of settings
* @param compound compound of source
*/
public void uploadSettings( SettingsFrom from, NBTTagCompound compound )
Expand Down
154 changes: 154 additions & 0 deletions src/main/java/appeng/parts/reporting/AbstractPartDisplay.java
@@ -0,0 +1,154 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/

package appeng.parts.reporting;


import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import appeng.api.parts.IPartRenderHelper;
import appeng.client.texture.CableBusTextures;


/**
* A more sophisticated part overlapping all 3 textures.
*
* Subclass this if you need want a new part and need all 3 textures.
* For more concrete implementations, the direct abstract subclasses might be a better alternative.
*
* @author AlgorithmX2
* @author yueh
* @version rv3
* @since rv3
*/
public abstract class AbstractPartDisplay extends AbstractPartReporting
{

public AbstractPartDisplay( ItemStack is )
{
super( is, true );
}

@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
{
rh.setBounds( 2, 2, 14, 14, 14, 16 );

final IIcon sideTexture = CableBusTextures.PartMonitorSides.getIcon();
final IIcon backTexture = CableBusTextures.PartMonitorBack.getIcon();

rh.setTexture( sideTexture, sideTexture, backTexture, this.is.getIconIndex(), sideTexture, sideTexture );
rh.renderInventoryBox( renderer );

rh.setInvColor( this.getColor().whiteVariant );
rh.renderInventoryFace( this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer );

rh.setInvColor( this.getColor().mediumVariant );
rh.renderInventoryFace( this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer );

rh.setInvColor( this.getColor().blackVariant );
rh.renderInventoryFace( this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer );

rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderInventoryBox( renderer );
}

@Override
@SideOnly( Side.CLIENT )
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
{
this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache );

final IIcon sideTexture = CableBusTextures.PartMonitorSides.getIcon();
final IIcon backTexture = CableBusTextures.PartMonitorBack.getIcon();

rh.setTexture( sideTexture, sideTexture, backTexture, this.is.getIconIndex(), sideTexture, sideTexture );

rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );

if( this.getLightLevel() > 0 )
{
final int l = 13;
Tessellator.instance.setBrightness( l << 20 | l << 4 );
}

renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this.getSpin();

Tessellator.instance.setColorOpaque_I( this.getColor().whiteVariant );
rh.renderFace( x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer );

Tessellator.instance.setColorOpaque_I( this.getColor().mediumVariant );
rh.renderFace( x, y, z, this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer );

Tessellator.instance.setColorOpaque_I( this.getColor().blackVariant );
rh.renderFace( x, y, z, this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer );

renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;

final IIcon sideStatusTexture = CableBusTextures.PartMonitorSidesStatus.getIcon();

rh.setTexture( sideStatusTexture, sideStatusTexture, backTexture, this.is.getIconIndex(), sideStatusTexture, sideStatusTexture );

rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderBlock( x, y, z, renderer );

final boolean hasChan = ( this.getClientFlags() & ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG ) ) == ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG );
final boolean hasPower = ( this.getClientFlags() & PartPanel.POWERED_FLAG ) == PartPanel.POWERED_FLAG;

if( hasChan )
{
final int l = 14;
Tessellator.instance.setBrightness( l << 20 | l << 4 );
Tessellator.instance.setColorOpaque_I( this.getColor().blackVariant );
}
else if( hasPower )
{
final int l = 9;
Tessellator.instance.setBrightness( l << 20 | l << 4 );
Tessellator.instance.setColorOpaque_I( this.getColor().whiteVariant );
}
else
{
Tessellator.instance.setBrightness( 0 );
Tessellator.instance.setColorOpaque_I( 0x000000 );
}

final IIcon sideStatusLightTexture = CableBusTextures.PartMonitorSidesStatusLights.getIcon();

rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.EAST, renderer );
rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.WEST, renderer );
rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.UP, renderer );
rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.DOWN, renderer );
}

@Override
public boolean isLightSource()
{
return false;
}

}

0 comments on commit 256c025

Please sign in to comment.