Basic reformat, hit once, hope never again
This commit is contained in:
@@ -51,6 +51,7 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
||||
{
|
||||
|
||||
@@ -61,6 +62,21 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
||||
IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
|
||||
|
||||
List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
|
||||
GuiButton cancel;
|
||||
int tooltip = -1;
|
||||
|
||||
public GuiCraftingCPU( InventoryPlayer inventoryPlayer, Object te )
|
||||
{
|
||||
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
protected GuiCraftingCPU( ContainerCraftingCPU container )
|
||||
{
|
||||
super( container );
|
||||
this.ySize = 184;
|
||||
this.xSize = 238;
|
||||
this.myScrollBar = new GuiScrollbar();
|
||||
}
|
||||
|
||||
public void clearItems()
|
||||
{
|
||||
@@ -70,31 +86,18 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
||||
this.visual = new ArrayList<IAEItemStack>();
|
||||
}
|
||||
|
||||
protected GuiCraftingCPU(ContainerCraftingCPU container) {
|
||||
super( container );
|
||||
this.ySize = 184;
|
||||
this.xSize = 238;
|
||||
this.myScrollBar = new GuiScrollbar();
|
||||
}
|
||||
|
||||
public GuiCraftingCPU(InventoryPlayer inventoryPlayer, Object te) {
|
||||
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
GuiButton cancel;
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
protected void actionPerformed( GuiButton btn )
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if ( this.cancel == btn )
|
||||
if( this.cancel == btn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
catch( IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
@@ -110,162 +113,45 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
||||
this.buttonList.add( this.cancel );
|
||||
}
|
||||
|
||||
private long getTotal(IAEItemStack is)
|
||||
{
|
||||
IAEItemStack a = this.storage.findPrecise( is );
|
||||
IAEItemStack b = this.active.findPrecise( is );
|
||||
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;
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list, byte ref)
|
||||
{
|
||||
switch (ref)
|
||||
{
|
||||
case 0:
|
||||
for (IAEItemStack l : list)
|
||||
this.handleInput( this.storage, l );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (IAEItemStack l : list)
|
||||
this.handleInput( this.active, l );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (IAEItemStack l : list)
|
||||
this.handleInput( this.pending, l );
|
||||
break;
|
||||
}
|
||||
|
||||
for (IAEItemStack l : list)
|
||||
{
|
||||
long amt = this.getTotal( l );
|
||||
|
||||
if ( amt <= 0 )
|
||||
this.deleteVisualStack( l );
|
||||
else
|
||||
{
|
||||
IAEItemStack is = this.findVisualStack( l );
|
||||
is.setStackSize( amt );
|
||||
}
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput(IItemList<IAEItemStack> s, 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 IAEItemStack findVisualStack(IAEItemStack l)
|
||||
{
|
||||
for (IAEItemStack o : this.visual)
|
||||
{
|
||||
if ( o.equals( l ) )
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
IAEItemStack stack = l.copy();
|
||||
this.visual.add( stack );
|
||||
return stack;
|
||||
}
|
||||
|
||||
private void deleteVisualStack(IAEItemStack l)
|
||||
{
|
||||
Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
IAEItemStack o = i.next();
|
||||
if ( o.equals( l ) )
|
||||
{
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
int size = this.visual.size();
|
||||
|
||||
this.myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 137 );
|
||||
this.myScrollBar.setRange( 0, (size + 2) / 3 - this.rows, 1 );
|
||||
this.myScrollBar.setRange( 0, ( size + 2 ) / 3 - this.rows, 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
this.bindTexture( "guis/craftingcpu.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
|
||||
}
|
||||
|
||||
int tooltip = -1;
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
public void drawScreen( int mouse_x, int mouse_y, float btn )
|
||||
{
|
||||
this.cancel.enabled = !this.visual.isEmpty();
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
int gx = (this.width - this.xSize) / 2;
|
||||
int gy = (this.height - this.ySize) / 2;
|
||||
int gx = ( this.width - this.xSize ) / 2;
|
||||
int gy = ( this.height - this.ySize ) / 2;
|
||||
int offY = 23;
|
||||
|
||||
this.tooltip = -1;
|
||||
|
||||
for (int z = 0; z <= 4 * 5; z++)
|
||||
for( int z = 0; z <= 4 * 5; z++ )
|
||||
{
|
||||
int minX = gx + 9 + x * 67;
|
||||
int minY = gy + 22 + y * offY;
|
||||
|
||||
if ( minX < mouse_x && minX + 67 > mouse_x )
|
||||
if( minX < mouse_x && minX + 67 > mouse_x )
|
||||
{
|
||||
if ( minY < mouse_y && minY + offY - 2 > mouse_y )
|
||||
if( minY < mouse_y && minY + offY - 2 > mouse_y )
|
||||
{
|
||||
this.tooltip = z;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 2 )
|
||||
if( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
@@ -276,7 +162,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
|
||||
{
|
||||
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.CraftingStatus.getLocal() ), 8, 7, 4210752 );
|
||||
|
||||
@@ -296,10 +182,10 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
||||
|
||||
int offY = 23;
|
||||
|
||||
for (int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++)
|
||||
for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ )
|
||||
{
|
||||
IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
|
||||
if ( refStack != null )
|
||||
if( refStack != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( 0.5, 0.5, 0.5 );
|
||||
@@ -312,102 +198,98 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
||||
boolean active = false;
|
||||
boolean scheduled = false;
|
||||
|
||||
if ( stored != null && stored.getStackSize() > 0 )
|
||||
if( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
}
|
||||
if ( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
if( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
active = true;
|
||||
}
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
if( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
lines++;
|
||||
scheduled = true;
|
||||
}
|
||||
|
||||
if ( AEConfig.instance.useColoredCraftingStatus && ( active || scheduled ) )
|
||||
if( AEConfig.instance.useColoredCraftingStatus && ( active || scheduled ) )
|
||||
{
|
||||
int bgColor = ( active ? AEColor.Green.blackVariant : AEColor.Yellow.blackVariant ) | 0x5A000000;
|
||||
int startX = (x * (1 + sectionLength) + xo) * 2;
|
||||
int startY = ((y * offY + yo) - 3) * 2;
|
||||
drawRect( startX, startY, startX + (sectionLength * 2), startY + (offY * 2) - 2, bgColor);
|
||||
int startX = ( x * ( 1 + sectionLength ) + xo ) * 2;
|
||||
int startY = ( ( y * offY + yo ) - 3 ) * 2;
|
||||
drawRect( startX, startY, startX + ( sectionLength * 2 ), startY + ( offY * 2 ) - 2, bgColor );
|
||||
}
|
||||
|
||||
int negY = ((lines - 1) * 5) / 2;
|
||||
int negY = ( ( lines - 1 ) * 5 ) / 2;
|
||||
int downY = 0;
|
||||
|
||||
if ( stored != null && stored.getStackSize() > 0 )
|
||||
if( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( stored.getStackSize() );
|
||||
if ( stored.getStackSize() >= 10000 )
|
||||
if( stored.getStackSize() >= 10000 )
|
||||
str = Long.toString( stored.getStackSize() / 1000 ) + 'k';
|
||||
if ( stored.getStackSize() >= 10000000 )
|
||||
if( stored.getStackSize() >= 10000000 )
|
||||
str = Long.toString( stored.getStackSize() / 1000000 ) + 'm';
|
||||
|
||||
str = GuiText.Stored.getLocal() + ": " + str;
|
||||
int w = 4 + this.fontRendererObj.getStringWidth( str );
|
||||
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
|
||||
+ 6 - negY + downY) * 2, 4210752 );
|
||||
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
|
||||
|
||||
if ( this.tooltip == z - viewStart )
|
||||
if( this.tooltip == z - viewStart )
|
||||
lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if ( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
if( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( activeStack.getStackSize() );
|
||||
if ( activeStack.getStackSize() >= 10000 )
|
||||
if( activeStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( activeStack.getStackSize() / 1000 ) + 'k';
|
||||
if ( activeStack.getStackSize() >= 10000000 )
|
||||
if( activeStack.getStackSize() >= 10000000 )
|
||||
str = Long.toString( activeStack.getStackSize() / 1000000 ) + 'm';
|
||||
|
||||
str = GuiText.Crafting.getLocal() + ": " + str;
|
||||
int w = 4 + this.fontRendererObj.getStringWidth( str );
|
||||
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
|
||||
+ 6 - negY + downY) * 2, 4210752 );
|
||||
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
|
||||
|
||||
if ( this.tooltip == z - viewStart )
|
||||
if( this.tooltip == z - viewStart )
|
||||
lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) );
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
if( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( pendingStack.getStackSize() );
|
||||
if ( pendingStack.getStackSize() >= 10000 )
|
||||
if( pendingStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000 ) + 'k';
|
||||
if ( pendingStack.getStackSize() >= 10000000 )
|
||||
if( pendingStack.getStackSize() >= 10000000 )
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + 'm';
|
||||
|
||||
str = GuiText.Scheduled.getLocal() + ": " + str;
|
||||
int w = 4 + this.fontRendererObj.getStringWidth( str );
|
||||
this.fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo
|
||||
+ 6 - negY + downY) * 2, 4210752 );
|
||||
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
|
||||
|
||||
if ( this.tooltip == z - viewStart )
|
||||
if( this.tooltip == z - viewStart )
|
||||
lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
|
||||
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
|
||||
int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
|
||||
int posY = y * offY + yo;
|
||||
|
||||
ItemStack is = refStack.copy().getItemStack();
|
||||
|
||||
if ( this.tooltip == z - viewStart )
|
||||
if( this.tooltip == z - viewStart )
|
||||
{
|
||||
dspToolTip = Platform.getItemDisplayName( is );
|
||||
|
||||
if ( lineList.size() > 0 )
|
||||
if( lineList.size() > 0 )
|
||||
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
|
||||
|
||||
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
|
||||
toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8;
|
||||
toolPosY = y * offY + yo;
|
||||
}
|
||||
|
||||
@@ -415,22 +297,134 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 2 )
|
||||
if( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( this.tooltip >= 0 && dspToolTip.length() > 0 )
|
||||
if( this.tooltip >= 0 && dspToolTip.length() > 0 )
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
this.drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
|
||||
{
|
||||
this.bindTexture( "guis/craftingcpu.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
|
||||
}
|
||||
|
||||
public void postUpdate( List<IAEItemStack> list, byte ref )
|
||||
{
|
||||
switch( ref )
|
||||
{
|
||||
case 0:
|
||||
for( IAEItemStack l : list )
|
||||
this.handleInput( this.storage, l );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for( IAEItemStack l : list )
|
||||
this.handleInput( this.active, l );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for( IAEItemStack l : list )
|
||||
this.handleInput( this.pending, l );
|
||||
break;
|
||||
}
|
||||
|
||||
for( IAEItemStack l : list )
|
||||
{
|
||||
long amt = this.getTotal( l );
|
||||
|
||||
if( amt <= 0 )
|
||||
this.deleteVisualStack( l );
|
||||
else
|
||||
{
|
||||
IAEItemStack is = this.findVisualStack( l );
|
||||
is.setStackSize( amt );
|
||||
}
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput( IItemList<IAEItemStack> s, 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( IAEItemStack is )
|
||||
{
|
||||
IAEItemStack a = this.storage.findPrecise( is );
|
||||
IAEItemStack b = this.active.findPrecise( is );
|
||||
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( IAEItemStack l )
|
||||
{
|
||||
Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
IAEItemStack o = i.next();
|
||||
if( o.equals( l ) )
|
||||
{
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack( IAEItemStack l )
|
||||
{
|
||||
for( IAEItemStack o : this.visual )
|
||||
{
|
||||
if( o.equals( l ) )
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
IAEItemStack stack = l.copy();
|
||||
this.visual.add( stack );
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -450,5 +444,4 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
||||
{
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user