Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
@@ -72,7 +72,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
this.width = 16;
this.height = 16;
if ( appearances == null )
if( appearances == null )
{
appearances = new HashMap<EnumPair, ButtonAppearance>();
this.registerApp( 16 * 7, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput, ButtonToolTips.Trash );
@@ -165,7 +165,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
{
ButtonAppearance a = new ButtonAppearance();
a.displayName = title.getUnlocalized();
a.displayValue = ( String ) ( hint instanceof String ? hint : ( ( ButtonToolTips ) hint ).getUnlocalized() );
a.displayValue = (String) ( hint instanceof String ? hint : ( (ButtonToolTips) hint ).getUnlocalized() );
a.index = iconIndex;
appearances.put( new EnumPair( setting, val ), a );
}
@@ -179,11 +179,11 @@ public class GuiImgButton extends GuiButton implements ITooltip
@Override
public void drawButton( Minecraft par1Minecraft, int par2, int par3 )
{
if ( this.visible )
if( this.visible )
{
int iconIndex = this.getIconIndex();
if ( this.halfSize )
if( this.halfSize )
{
this.width = 8;
this.height = 8;
@@ -192,7 +192,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
GL11.glTranslatef( this.xPosition, this.yPosition, 0.0F );
GL11.glScalef( 0.5f, 0.5f, 0.5f );
if ( this.enabled )
if( this.enabled )
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
else
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
@@ -200,7 +200,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
int uv_y = ( int ) Math.floor( iconIndex / 16 );
int uv_y = (int) Math.floor( iconIndex / 16 );
int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16 );
@@ -211,7 +211,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
}
else
{
if ( this.enabled )
if( this.enabled )
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
else
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
@@ -219,7 +219,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
int uv_y = ( int ) Math.floor( iconIndex / 16 );
int uv_y = (int) Math.floor( iconIndex / 16 );
int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect( this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16 );
@@ -232,10 +232,10 @@ public class GuiImgButton extends GuiButton implements ITooltip
private int getIconIndex()
{
if ( this.buttonSetting != null && this.currentValue != null )
if( this.buttonSetting != null && this.currentValue != null )
{
ButtonAppearance app = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) );
if ( app == null )
if( app == null )
return 256 - 1;
return app.index;
}
@@ -244,7 +244,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
public Settings getSetting()
{
return ( Settings ) this.buttonSetting;
return (Settings) this.buttonSetting;
}
public Enum getCurrentValue()
@@ -258,36 +258,36 @@ public class GuiImgButton extends GuiButton implements ITooltip
String displayName = null;
String displayValue = null;
if ( this.buttonSetting != null && this.currentValue != null )
if( this.buttonSetting != null && this.currentValue != null )
{
ButtonAppearance buttonAppearance = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) );
if ( buttonAppearance == null )
if( buttonAppearance == null )
return "No Such Message";
displayName = buttonAppearance.displayName;
displayValue = buttonAppearance.displayValue;
}
if ( displayName != null )
if( displayName != null )
{
String name = StatCollector.translateToLocal( displayName );
String value = StatCollector.translateToLocal( displayValue );
if ( name == null || name.isEmpty() )
if( name == null || name.isEmpty() )
name = displayName;
if ( value == null || value.isEmpty() )
if( value == null || value.isEmpty() )
value = displayValue;
if ( this.fillVar != null )
if( this.fillVar != null )
value = COMPILE.matcher( value ).replaceFirst( this.fillVar );
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
StringBuilder sb = new StringBuilder( value );
int i = sb.lastIndexOf( "\n" );
if ( i <= 0 )
if( i <= 0 )
i = 0;
while ( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
{
sb.replace( i, i + 1, "\n" );
}
@@ -329,7 +329,7 @@ public class GuiImgButton extends GuiButton implements ITooltip
public void set( Enum e )
{
if ( this.currentValue != e )
if( this.currentValue != e )
{
this.currentValue = e;
}
@@ -356,15 +356,16 @@ public class GuiImgButton extends GuiButton implements ITooltip
@Override
public boolean equals( Object obj )
{
if ( obj == null )
if( obj == null )
return false;
if ( this.getClass() != obj.getClass() )
if( this.getClass() != obj.getClass() )
return false;
EnumPair other = ( EnumPair ) obj;
EnumPair other = (EnumPair) obj;
return other.setting == this.setting && other.value == this.value;
}
}
private static class ButtonAppearance
{
public int index;
@@ -18,6 +18,7 @@
package appeng.client.gui.widgets;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
@@ -27,31 +28,30 @@ public class GuiNumberBox extends GuiTextField
final Class type;
public GuiNumberBox(FontRenderer p_i1032_1_, int p_i1032_2_, int p_i1032_3_, int p_i1032_4_, int p_i1032_5_,Class type) {
public GuiNumberBox( FontRenderer p_i1032_1_, int p_i1032_2_, int p_i1032_3_, int p_i1032_4_, int p_i1032_5_, Class type )
{
super( p_i1032_1_, p_i1032_2_, p_i1032_3_, p_i1032_4_, p_i1032_5_ );
this.type = type;
}
@Override
public void writeText(String p_146191_1_)
public void writeText( String p_146191_1_ )
{
String original = this.getText();
super.writeText( p_146191_1_ );
try
{
if ( this.type == int.class || this.type == Integer.class )
if( this.type == int.class || this.type == Integer.class )
Integer.parseInt( this.getText() );
else if ( this.type == long.class || this.type == Long.class )
else if( this.type == long.class || this.type == Long.class )
Long.parseLong( this.getText() );
else if ( this.type == double.class || this.type == Double.class )
else if( this.type == double.class || this.type == Double.class )
Double.parseDouble( this.getText() );
}
catch(NumberFormatException e )
catch( NumberFormatException e )
{
this.setText( original );
}
}
}
@@ -26,29 +26,24 @@ import net.minecraft.util.ResourceLocation;
import appeng.container.interfaces.IProgressProvider;
import appeng.core.localization.GuiText;
public class GuiProgressBar extends GuiButton implements ITooltip
{
public enum Direction
{
HORIZONTAL, VERTICAL
}
private final IProgressProvider source;
private final ResourceLocation texture;
private final int fill_u;
private final int fill_v;
private final Direction layout;
private String fullMsg;
private final String titleName;
private String fullMsg;
public GuiProgressBar(IProgressProvider source, String texture, int posX, int posY, int u, int y, int _width, int _height, Direction dir)
public GuiProgressBar( IProgressProvider source, String texture, int posX, int posY, int u, int y, int _width, int _height, Direction dir )
{
this( source, texture, posX, posY, u, y, _width, _height, dir, null );
}
public GuiProgressBar(IProgressProvider source, String texture, int posX, int posY, int u, int y, int _width, int _height, Direction dir, String title)
public GuiProgressBar( IProgressProvider source, String texture, int posX, int posY, int u, int y, int _width, int _height, Direction dir, String title )
{
super( posX, posY, _width, "" );
this.source = source;
@@ -64,22 +59,22 @@ public class GuiProgressBar extends GuiButton implements ITooltip
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
public void drawButton( Minecraft par1Minecraft, int par2, int par3 )
{
if ( this.visible )
if( this.visible )
{
par1Minecraft.getTextureManager().bindTexture( this.texture );
int max = this.source.getMaxProgress();
int current = this.source.getCurrentProgress();
if ( this.layout == Direction.VERTICAL )
if( this.layout == Direction.VERTICAL )
{
int diff = this.height - (max > 0 ? (this.height * current) / max : 0);
int diff = this.height - ( max > 0 ? ( this.height * current ) / max : 0 );
this.drawTexturedModalRect( this.xPosition, this.yPosition + diff, this.fill_u, this.fill_v + diff, this.width, this.height - diff );
}
else
{
int diff = this.width - (max > 0 ? (this.width * current) / max : 0);
int diff = this.width - ( max > 0 ? ( this.width * current ) / max : 0 );
this.drawTexturedModalRect( this.xPosition, this.yPosition, this.fill_u + diff, this.fill_v, this.width - diff, this.height );
}
@@ -87,7 +82,7 @@ public class GuiProgressBar extends GuiButton implements ITooltip
}
}
public void setFullMsg(String msg)
public void setFullMsg( String msg )
{
this.fullMsg = msg;
}
@@ -95,10 +90,10 @@ public class GuiProgressBar extends GuiButton implements ITooltip
@Override
public String getMessage()
{
if ( this.fullMsg != null )
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
@@ -131,4 +126,8 @@ public class GuiProgressBar extends GuiButton implements ITooltip
return true;
}
public enum Direction
{
HORIZONTAL, VERTICAL
}
}
@@ -18,10 +18,12 @@
package appeng.client.gui.widgets;
import org.lwjgl.opengl.GL11;
import appeng.client.gui.AEBaseGui;
public class GuiScrollbar implements IScrollSource
{
@@ -35,23 +37,18 @@ public class GuiScrollbar implements IScrollSource
private int minScroll = 0;
private int currentScroll = 0;
private void applyRange()
{
this.currentScroll = Math.max( Math.min( this.currentScroll, this.maxScroll ), this.minScroll );
}
public void draw(AEBaseGui g)
public void draw( AEBaseGui g )
{
g.bindTexture( "minecraft", "gui/container/creative_inventory/tabs.png" );
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
if ( this.getRange() == 0 )
if( this.getRange() == 0 )
{
g.drawTexturedModalRect( this.displayX, this.displayY, 232 + this.width, 0, this.width, 15 );
}
else
{
int offset = (this.currentScroll - this.minScroll) * (this.height - 15) / this.getRange();
int offset = ( this.currentScroll - this.minScroll ) * ( this.height - 15 ) / this.getRange();
g.drawTexturedModalRect( this.displayX, offset + this.displayY, 232, 0, this.width, 15 );
}
}
@@ -66,85 +63,89 @@ public class GuiScrollbar implements IScrollSource
return this.displayX;
}
public GuiScrollbar setLeft( int v )
{
this.displayX = v;
return this;
}
public int getTop()
{
return this.displayY;
}
public GuiScrollbar setTop( int v )
{
this.displayY = v;
return this;
}
public int getWidth()
{
return this.width;
}
public int getHeight()
{
return this.height;
}
public GuiScrollbar setLeft(int v)
{
this.displayX = v;
return this;
}
public GuiScrollbar setTop(int v)
{
this.displayY = v;
return this;
}
public GuiScrollbar setWidth(int v)
public GuiScrollbar setWidth( int v )
{
this.width = v;
return this;
}
public GuiScrollbar setHeight(int v)
public int getHeight()
{
return this.height;
}
public GuiScrollbar setHeight( int v )
{
this.height = v;
return this;
}
public void setRange(int min, int max, int pageSize)
public void setRange( int min, int max, int pageSize )
{
this.minScroll = min;
this.maxScroll = max;
this.pageSize = pageSize;
if ( this.minScroll > this.maxScroll )
if( this.minScroll > this.maxScroll )
this.maxScroll = this.minScroll;
this.applyRange();
}
private void applyRange()
{
this.currentScroll = Math.max( Math.min( this.currentScroll, this.maxScroll ), this.minScroll );
}
@Override
public int getCurrentScroll()
{
return this.currentScroll;
}
public void click(AEBaseGui aeBaseGui, int x, int y)
public void click( AEBaseGui aeBaseGui, int x, int y )
{
if ( this.getRange() == 0 )
if( this.getRange() == 0 )
return;
if ( x > this.displayX && x <= this.displayX + this.width )
if( x > this.displayX && x <= this.displayX + this.width )
{
if ( y > this.displayY && y <= this.displayY + this.height )
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.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)
public void wheel( int delta )
{
delta = Math.max( Math.min( -delta, 1 ), -1 );
this.currentScroll += delta * this.pageSize;
this.applyRange();
}
}
@@ -56,11 +56,11 @@ public class GuiTabButton extends GuiButton implements ITooltip
/**
* Using itemstack as an icon
*
* @param x x pos of button
* @param y y pos of button
* @param ico used 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
* @param ir renderer
*/
public GuiTabButton( int x, int y, ItemStack ico, String message, RenderItem ir )
{
@@ -77,7 +77,7 @@ public class GuiTabButton extends GuiButton implements ITooltip
@Override
public void drawButton( Minecraft minecraft, int x, int y )
{
if ( this.visible )
if( this.visible )
{
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
@@ -89,9 +89,9 @@ public class GuiTabButton extends GuiButton implements ITooltip
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, 0, 25, 22 );
if ( this.myIcon >= 0 )
if( this.myIcon >= 0 )
{
int uv_y = ( int ) Math.floor( this.myIcon / 16 );
int uv_y = (int) Math.floor( this.myIcon / 16 );
uv_x = this.myIcon - uv_y * 16;
this.drawTexturedModalRect( offsetX + this.xPosition + 3, this.yPosition + 3, uv_x * 16, uv_y * 16, 16, 16 );
@@ -99,7 +99,7 @@ public class GuiTabButton extends GuiButton implements ITooltip
this.mouseDragged( minecraft, x, y );
if ( this.myItem != null )
if( this.myItem != null )
{
this.zLevel = 100.0F;
this.itemRenderer.zLevel = 100.0F;
@@ -62,7 +62,7 @@ public class GuiToggleButton extends GuiButton implements ITooltip
@Override
public void drawButton( Minecraft par1Minecraft, int par2, int par3 )
{
if ( this.visible )
if( this.visible )
{
int iconIndex = this.getIconIndex();
@@ -70,7 +70,7 @@ public class GuiToggleButton extends GuiButton implements ITooltip
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
int uv_y = ( int ) Math.floor( iconIndex / 16 );
int uv_y = (int) Math.floor( iconIndex / 16 );
int uv_x = iconIndex - uv_y * 16;
this.drawTexturedModalRect( this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16 );
@@ -87,23 +87,23 @@ public class GuiToggleButton extends GuiButton implements ITooltip
@Override
public String getMessage()
{
if ( this.displayName != null )
if( this.displayName != null )
{
String name = StatCollector.translateToLocal( this.displayName );
String value = StatCollector.translateToLocal( this.displayHint );
if ( name == null || name.isEmpty() )
if( name == null || name.isEmpty() )
name = this.displayName;
if ( value == null || value.isEmpty() )
if( value == null || value.isEmpty() )
value = this.displayHint;
value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" );
StringBuilder sb = new StringBuilder( value );
int i = sb.lastIndexOf( "\n" );
if ( i <= 0 )
if( i <= 0 )
i = 0;
while ( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 )
{
sb.replace( i, i + 1, "\n" );
}
@@ -18,9 +18,9 @@
package appeng.client.gui.widgets;
public interface IScrollSource
{
int getCurrentScroll();
}
@@ -18,9 +18,11 @@
package appeng.client.gui.widgets;
import appeng.api.config.SortDir;
import appeng.api.config.ViewItems;
public interface ISortSource
{
@@ -38,5 +40,4 @@ public interface ISortSource
* @return {@link ViewItems}
*/
Enum getSortDisplay();
}
@@ -18,9 +18,9 @@
package appeng.client.gui.widgets;
/**
* AEBaseGui controlled Tooltip Interface.
*
*/
public interface ITooltip
{
@@ -64,5 +64,4 @@ public interface ITooltip
* @return true if button being drawn
*/
boolean isVisible();
}
@@ -22,6 +22,7 @@ package appeng.client.gui.widgets;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
/**
* A modified version of the Minecraft text field.
* You can initialize it over the full element span.
@@ -44,10 +45,10 @@ public class MEGuiTextField extends GuiTextField
* 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
* @param xPos absolute left position
* @param yPos absolute top position
* @param width absolute width
* @param height absolute height
*/
public MEGuiTextField( FontRenderer fontRenderer, int xPos, int yPos, int width, int height )
{