merging 1.7.5 source: windows changes
This commit is contained in:
@@ -23,18 +23,22 @@ import com.watabou.noosa.ui.Component;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.HealthBar;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
|
||||
public class IconTitle extends Component {
|
||||
|
||||
private static final float FONT_SIZE = 9;
|
||||
|
||||
|
||||
private static final float GAP = 2;
|
||||
|
||||
|
||||
protected Image imIcon;
|
||||
protected BitmapTextMultiline tfLabel;
|
||||
|
||||
protected HealthBar health;
|
||||
|
||||
private float healthLvl = Float.NaN;
|
||||
|
||||
public IconTitle() {
|
||||
super();
|
||||
}
|
||||
@@ -45,55 +49,71 @@ public class IconTitle extends Component {
|
||||
Utils.capitalize( item.toString() ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
public IconTitle( Image icon, String label ) {
|
||||
super();
|
||||
|
||||
|
||||
icon( icon );
|
||||
label( label );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
imIcon = new Image();
|
||||
add( imIcon );
|
||||
|
||||
|
||||
tfLabel = PixelScene.createMultiline( FONT_SIZE );
|
||||
tfLabel.hardlight( Window.TITLE_COLOR );
|
||||
add( tfLabel );
|
||||
|
||||
health = new HealthBar();
|
||||
add( health );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
imIcon.x = this.x;
|
||||
imIcon.y = this.y;
|
||||
|
||||
|
||||
health.visible = !Float.isNaN( healthLvl );
|
||||
|
||||
imIcon.x = x;
|
||||
imIcon.y = y;
|
||||
|
||||
tfLabel.x = PixelScene.align( PixelScene.uiCamera, imIcon.x + imIcon.width() + GAP );
|
||||
tfLabel.maxWidth = (int)(width - tfLabel.x);
|
||||
tfLabel.measure();
|
||||
tfLabel.y = PixelScene.align( PixelScene.uiCamera,
|
||||
imIcon.height > tfLabel.height() ?
|
||||
imIcon.y + 1 + (imIcon.height() - tfLabel.height()) / 2 :
|
||||
imIcon.y + (imIcon.height() - tfLabel.baseLine()) / 2 :
|
||||
imIcon.y );
|
||||
|
||||
height = Math.max( imIcon.height(), tfLabel.height() );
|
||||
|
||||
if (health.visible) {
|
||||
health.setRect( tfLabel.x, Math.max( tfLabel.y + tfLabel.height(), imIcon.y + imIcon.height() - health.height() ), tfLabel.maxWidth, 0 );
|
||||
height = health.bottom();
|
||||
} else {
|
||||
height = Math.max( imIcon.y + imIcon.height(), tfLabel.y + tfLabel.height() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void icon( Image icon ) {
|
||||
remove( imIcon );
|
||||
add( imIcon = icon );
|
||||
}
|
||||
|
||||
|
||||
public void label( String label ) {
|
||||
tfLabel.text( label );
|
||||
}
|
||||
|
||||
|
||||
public void label( String label, int color ) {
|
||||
tfLabel.text( label );
|
||||
tfLabel.hardlight( color );
|
||||
}
|
||||
|
||||
|
||||
public void color( int color ) {
|
||||
tfLabel.hardlight( color );
|
||||
}
|
||||
|
||||
public void health( float value ) {
|
||||
health.level( healthLvl = value );
|
||||
layout();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user