2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* 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>.
|
|
|
|
*/
|
|
|
|
|
2014-09-20 23:22:45 +02:00
|
|
|
package appeng.client.texture;
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-09-20 23:22:45 +02:00
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
public class FlippableIcon implements IAESprite
|
2014-09-20 23:22:45 +02:00
|
|
|
{
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
private IAESprite original;
|
|
|
|
private boolean flip_u;
|
|
|
|
private boolean flip_v;
|
2014-09-20 23:22:45 +02:00
|
|
|
|
2015-09-30 14:24:40 +02:00
|
|
|
public FlippableIcon( final IAESprite o )
|
2015-06-16 02:44:59 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.original = o;
|
|
|
|
this.flip_u = false;
|
|
|
|
this.flip_v = false;
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
@Override
|
|
|
|
public TextureAtlasSprite getAtlas()
|
|
|
|
{
|
|
|
|
return this.original.getAtlas();
|
|
|
|
}
|
|
|
|
|
2014-09-20 23:22:45 +02:00
|
|
|
@Override
|
|
|
|
public int getIconWidth()
|
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getIconWidth();
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getIconHeight()
|
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getIconHeight();
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getMinU()
|
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
if( this.isFlipU() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getMaxU();
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getMinU();
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getMaxU()
|
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
if( this.isFlipU() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getMinU();
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getMaxU();
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public float getInterpolatedU( final double px )
|
2014-09-20 23:22:45 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
if( this.isFlipU() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getInterpolatedU( 16 - px );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getInterpolatedU( px );
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getMinV()
|
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
if( this.isFlipV() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getMaxV();
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getMinV();
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getMaxV()
|
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
if( this.isFlipV() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getMinV();
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getMaxV();
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public float getInterpolatedV( final double px )
|
2014-09-20 23:22:45 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
if( this.isFlipV() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getInterpolatedV( 16 - px );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getInterpolatedV( px );
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getIconName()
|
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
return this.getOriginal().getIconName();
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
2015-06-16 02:44:59 +02:00
|
|
|
public IAESprite getOriginal()
|
2014-09-20 23:22:45 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.original;
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
2015-09-30 14:24:40 +02:00
|
|
|
public void setFlip( final boolean u, final boolean v )
|
2014-09-20 23:22:45 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setFlipU( u );
|
|
|
|
this.setFlipV( v );
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
2015-09-30 14:24:40 +02:00
|
|
|
public int setFlip( final int orientation )
|
2014-09-20 23:22:45 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setFlipU( ( orientation & 8 ) == 8 );
|
|
|
|
this.setFlipV( ( orientation & 16 ) == 16 );
|
2014-09-20 23:22:45 +02:00
|
|
|
return orientation & 7;
|
|
|
|
}
|
2015-10-08 15:42:42 +02:00
|
|
|
|
|
|
|
boolean isFlipU()
|
|
|
|
{
|
|
|
|
return this.flip_u;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setFlipU( final boolean flipU )
|
|
|
|
{
|
|
|
|
this.flip_u = flipU;
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean isFlipV()
|
|
|
|
{
|
|
|
|
return this.flip_v;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setFlipV( final boolean flipV )
|
|
|
|
{
|
|
|
|
this.flip_v = flipV;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOriginal( @Nonnull final IAESprite original )
|
|
|
|
{
|
|
|
|
this.original = original;
|
|
|
|
}
|
2014-09-20 23:22:45 +02:00
|
|
|
}
|