Nameable CPUs.
This commit is contained in:
@@ -110,7 +110,16 @@ public class GuiCraftConfirm extends AEBaseGui
|
|||||||
{
|
{
|
||||||
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic;
|
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic;
|
||||||
if ( ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() )
|
if ( ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() )
|
||||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + ccc.selectedCpu;
|
{
|
||||||
|
if ( ccc.myName.length() > 0 )
|
||||||
|
{
|
||||||
|
String name = ccc.myName.substring( 0, Math.min( 20, ccc.myName.length() ) );
|
||||||
|
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + ccc.selectedCpu;
|
||||||
|
}
|
||||||
|
|
||||||
if ( ccc.noCPU )
|
if ( ccc.noCPU )
|
||||||
btnTextText = GuiText.NoCraftingCPUs.getLocal();
|
btnTextText = GuiText.NoCraftingCPUs.getLocal();
|
||||||
|
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
|||||||
@Override
|
@Override
|
||||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||||
{
|
{
|
||||||
fontRendererObj.drawString( GuiText.CraftingStatus.getLocal(), 8, 7, 4210752 );
|
fontRendererObj.drawString( getGuiDisplayName( GuiText.CraftingStatus.getLocal() ), 8, 7, 4210752 );
|
||||||
|
|
||||||
int sectionLength = 67;
|
int sectionLength = 67;
|
||||||
|
|
||||||
|
|||||||
@@ -578,7 +578,7 @@ public abstract class AEBaseContainer extends Container
|
|||||||
{
|
{
|
||||||
if ( syncData.containsKey( idx ) )
|
if ( syncData.containsKey( idx ) )
|
||||||
{
|
{
|
||||||
syncData.get( idx ).update( value );
|
syncData.get( idx ).update( (long) value );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,13 +588,22 @@ public abstract class AEBaseContainer extends Container
|
|||||||
{
|
{
|
||||||
if ( syncData.containsKey( idx ) )
|
if ( syncData.containsKey( idx ) )
|
||||||
{
|
{
|
||||||
syncData.get( idx ).update( value );
|
syncData.get( idx ).update( (long) value );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProgressBar( idx, (int) value );
|
updateProgressBar( idx, (int) value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stringSync(int idx, String value)
|
||||||
|
{
|
||||||
|
if ( syncData.containsKey( idx ) )
|
||||||
|
{
|
||||||
|
syncData.get( idx ).update( value );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void prepareSync()
|
private void prepareSync()
|
||||||
{
|
{
|
||||||
for (Field f : getClass().getFields())
|
for (Field f : getClass().getFields())
|
||||||
@@ -625,6 +634,12 @@ public abstract class AEBaseContainer extends Container
|
|||||||
if ( tileEntity instanceof ICustomNameObject )
|
if ( tileEntity instanceof ICustomNameObject )
|
||||||
name = (ICustomNameObject) tileEntity;
|
name = (ICustomNameObject) tileEntity;
|
||||||
|
|
||||||
|
if ( obj instanceof ICustomNameObject )
|
||||||
|
name = (ICustomNameObject) obj;
|
||||||
|
|
||||||
|
if ( this instanceof ICustomNameObject )
|
||||||
|
name = (ICustomNameObject) this;
|
||||||
|
|
||||||
if ( name != null )
|
if ( name != null )
|
||||||
{
|
{
|
||||||
if ( name.hasCustomName() )
|
if ( name.hasCustomName() )
|
||||||
@@ -1055,4 +1070,5 @@ public abstract class AEBaseContainer extends Container
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import appeng.container.AEBaseContainer;
|
|||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
import appeng.core.sync.network.NetworkHandler;
|
||||||
import appeng.core.sync.packets.PacketProgressBar;
|
import appeng.core.sync.packets.PacketProgressBar;
|
||||||
|
import appeng.core.sync.packets.PacketValueConfig;
|
||||||
|
|
||||||
public class SyncDat
|
public class SyncDat
|
||||||
{
|
{
|
||||||
@@ -59,12 +60,15 @@ public class SyncDat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(long val)
|
public void update(Object val)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Object oldValue = field.get( source );
|
Object oldValue = field.get( source );
|
||||||
updateValue( oldValue, val );
|
if ( val instanceof String )
|
||||||
|
updateString( oldValue, (String) val );
|
||||||
|
else
|
||||||
|
updateValue( oldValue, (Long) val );
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e)
|
catch (IllegalArgumentException e)
|
||||||
{
|
{
|
||||||
@@ -77,6 +81,22 @@ public class SyncDat
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateString(Object oldValue, String val)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
field.set( source, val );
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException e)
|
||||||
|
{
|
||||||
|
AELog.error( e );
|
||||||
|
}
|
||||||
|
catch (IllegalAccessException e)
|
||||||
|
{
|
||||||
|
AELog.error( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateValue(Object oldValue, long val)
|
private void updateValue(Object oldValue, long val)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -123,7 +143,12 @@ public class SyncDat
|
|||||||
|
|
||||||
private void send(ICrafting o, Object val) throws IOException
|
private void send(ICrafting o, Object val) throws IOException
|
||||||
{
|
{
|
||||||
if ( field.getType().isEnum() )
|
if ( val instanceof String )
|
||||||
|
{
|
||||||
|
if ( o instanceof EntityPlayerMP )
|
||||||
|
NetworkHandler.instance.sendTo( new PacketValueConfig( "SyncDat." + channel, (String) val ), (EntityPlayerMP) o );
|
||||||
|
}
|
||||||
|
else if ( field.getType().isEnum() )
|
||||||
{
|
{
|
||||||
o.sendProgressBarUpdate( source, channel, ((Enum) val).ordinal() );
|
o.sendProgressBarUpdate( source, channel, ((Enum) val).ordinal() );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ public class ContainerCraftConfirm extends AEBaseContainer
|
|||||||
@GuiSync(6)
|
@GuiSync(6)
|
||||||
public boolean noCPU = true;
|
public boolean noCPU = true;
|
||||||
|
|
||||||
|
@GuiSync(7)
|
||||||
|
public String myName = "";
|
||||||
|
|
||||||
protected long cpuIdx = Long.MIN_VALUE;
|
protected long cpuIdx = Long.MIN_VALUE;
|
||||||
|
|
||||||
public class CraftingCPURecord implements Comparable<CraftingCPURecord>
|
public class CraftingCPURecord implements Comparable<CraftingCPURecord>
|
||||||
@@ -82,10 +85,13 @@ public class ContainerCraftConfirm extends AEBaseContainer
|
|||||||
long size;
|
long size;
|
||||||
int processors;
|
int processors;
|
||||||
|
|
||||||
|
public String myName;
|
||||||
|
|
||||||
CraftingCPURecord(long size, int proc, ICraftingCPU server) {
|
CraftingCPURecord(long size, int proc, ICraftingCPU server) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.processors = proc;
|
this.processors = proc;
|
||||||
this.cpu = server;
|
this.cpu = server;
|
||||||
|
myName = server.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -115,9 +121,11 @@ public class ContainerCraftConfirm extends AEBaseContainer
|
|||||||
selectedCpu = -1;
|
selectedCpu = -1;
|
||||||
cpuBytesAvail = 0;
|
cpuBytesAvail = 0;
|
||||||
cpuCoProcessors = 0;
|
cpuCoProcessors = 0;
|
||||||
|
myName = "";
|
||||||
}
|
}
|
||||||
else if ( selectedCpu != -1 )
|
else if ( selectedCpu != -1 )
|
||||||
{
|
{
|
||||||
|
myName = cpus.get( selectedCpu ).myName;
|
||||||
cpuBytesAvail = cpus.get( selectedCpu ).size;
|
cpuBytesAvail = cpus.get( selectedCpu ).size;
|
||||||
cpuCoProcessors = cpus.get( selectedCpu ).processors;
|
cpuCoProcessors = cpus.get( selectedCpu ).processors;
|
||||||
}
|
}
|
||||||
@@ -139,9 +147,11 @@ public class ContainerCraftConfirm extends AEBaseContainer
|
|||||||
{
|
{
|
||||||
cpuBytesAvail = 0;
|
cpuBytesAvail = 0;
|
||||||
cpuCoProcessors = 0;
|
cpuCoProcessors = 0;
|
||||||
|
myName = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
myName = cpus.get( selectedCpu ).myName;
|
||||||
cpuBytesAvail = cpus.get( selectedCpu ).size;
|
cpuBytesAvail = cpus.get( selectedCpu ).size;
|
||||||
cpuCoProcessors = cpus.get( selectedCpu ).processors;
|
cpuCoProcessors = cpus.get( selectedCpu ).processors;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,15 +20,17 @@ import appeng.api.storage.data.IItemList;
|
|||||||
import appeng.container.AEBaseContainer;
|
import appeng.container.AEBaseContainer;
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
import appeng.core.sync.network.NetworkHandler;
|
||||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||||
|
import appeng.helpers.ICustomNameObject;
|
||||||
import appeng.me.cluster.IAECluster;
|
import appeng.me.cluster.IAECluster;
|
||||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||||
import appeng.tile.crafting.TileCraftingTile;
|
import appeng.tile.crafting.TileCraftingTile;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorHandlerReceiver<IAEItemStack>
|
public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorHandlerReceiver<IAEItemStack>, ICustomNameObject
|
||||||
{
|
{
|
||||||
|
|
||||||
CraftingCPUCluster monitor = null;
|
CraftingCPUCluster monitor = null;
|
||||||
|
String cpuName = null;
|
||||||
IGrid network;
|
IGrid network;
|
||||||
|
|
||||||
IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||||
@@ -49,6 +51,8 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
|||||||
IAECluster c = ((TileCraftingTile) te).getCluster();
|
IAECluster c = ((TileCraftingTile) te).getCluster();
|
||||||
if ( c instanceof CraftingCPUCluster )
|
if ( c instanceof CraftingCPUCluster )
|
||||||
{
|
{
|
||||||
|
cpuName = ((CraftingCPUCluster) c).getName();
|
||||||
|
|
||||||
monitor = (CraftingCPUCluster) c;
|
monitor = (CraftingCPUCluster) c;
|
||||||
if ( monitor != null )
|
if ( monitor != null )
|
||||||
{
|
{
|
||||||
@@ -162,4 +166,16 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCustomName()
|
||||||
|
{
|
||||||
|
return cpuName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCustomName()
|
||||||
|
{
|
||||||
|
return cpuName != null && cpuName.length() > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,6 +186,10 @@ public class PacketValueConfig extends AppEngPacket
|
|||||||
{
|
{
|
||||||
((AEBaseContainer) c).customName = Value;
|
((AEBaseContainer) c).customName = Value;
|
||||||
}
|
}
|
||||||
|
else if ( Name.startsWith( "SyncDat." ) )
|
||||||
|
{
|
||||||
|
((AEBaseContainer) c).stringSync( Integer.parseInt( Name.substring( 8 ) ), Value );
|
||||||
|
}
|
||||||
else if ( c instanceof IConfigureableObject )
|
else if ( c instanceof IConfigureableObject )
|
||||||
{
|
{
|
||||||
IConfigManager cm = ((IConfigureableObject) c).getConfigManager();
|
IConfigManager cm = ((IConfigureableObject) c).getConfigManager();
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
public ICraftingLink myLastLink;
|
public ICraftingLink myLastLink;
|
||||||
|
|
||||||
MachineSource machineSrc = null;
|
MachineSource machineSrc = null;
|
||||||
|
public String myName = "";
|
||||||
|
|
||||||
int accelerator = 0;
|
int accelerator = 0;
|
||||||
public WorldCoord min;
|
public WorldCoord min;
|
||||||
@@ -244,7 +245,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
|
|
||||||
te.isCoreBlock = false;
|
te.isCoreBlock = false;
|
||||||
te.markDirty();
|
te.markDirty();
|
||||||
tiles.add( te );
|
tiles.push( te );
|
||||||
|
|
||||||
if ( te.isStorage() )
|
if ( te.isStorage() )
|
||||||
{
|
{
|
||||||
@@ -995,6 +996,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateCPU();
|
updateCPU();
|
||||||
|
updateName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1003,4 +1005,27 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
|||||||
return machineSrc;
|
return machineSrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return myName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateName()
|
||||||
|
{
|
||||||
|
myName = "";
|
||||||
|
for (TileCraftingTile te : tiles)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( te.hasCustomName() )
|
||||||
|
{
|
||||||
|
if ( myName.length() > 0 )
|
||||||
|
myName += " " + te.getCustomName();
|
||||||
|
else
|
||||||
|
myName = te.getCustomName();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,13 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
|||||||
calc.calculateMultiblock( worldObj, getLocation() );
|
calc.calculateMultiblock( worldObj, getLocation() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
super.setName( name );
|
||||||
|
if ( clust != null )
|
||||||
|
clust.updateName();
|
||||||
|
}
|
||||||
|
|
||||||
private class CraftingHandler extends AETileEventHandler
|
private class CraftingHandler extends AETileEventHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user