2014-07-27 13:39:07 +00:00
|
|
|
/*
|
|
|
|
* Pixel Dungeon
|
|
|
|
* Copyright (C) 2012-2014 Oleg Dolya
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
2014-08-03 18:46:22 +00:00
|
|
|
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
import com.watabou.noosa.BitmapText;
|
|
|
|
import com.watabou.noosa.ui.Component;
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
2015-02-06 06:07:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ui.HealthBar;
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
public class WndInfoMob extends WndTitledMessage {
|
|
|
|
|
|
|
|
public WndInfoMob( Mob mob ) {
|
|
|
|
|
|
|
|
super( new MobTitle( mob ), desc( mob ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private static String desc( Mob mob ) {
|
|
|
|
|
|
|
|
StringBuilder builder = new StringBuilder( mob.description() );
|
2014-10-20 07:24:59 +00:00
|
|
|
|
2015-06-12 20:22:26 +00:00
|
|
|
builder.append( "\n\n" + mob.state.status() + "." );
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
return builder.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
private static class MobTitle extends Component {
|
2015-02-06 06:07:22 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
private static final int GAP = 2;
|
|
|
|
|
|
|
|
private CharSprite image;
|
|
|
|
private BitmapText name;
|
2015-02-06 06:07:22 +00:00
|
|
|
private HealthBar health;
|
2014-07-27 13:39:07 +00:00
|
|
|
private BuffIndicator buffs;
|
|
|
|
|
|
|
|
public MobTitle( Mob mob ) {
|
|
|
|
|
|
|
|
name = PixelScene.createText( Utils.capitalize( mob.name ), 9 );
|
|
|
|
name.hardlight( TITLE_COLOR );
|
2015-06-12 20:22:26 +00:00
|
|
|
name.measure();
|
2014-07-27 13:39:07 +00:00
|
|
|
add( name );
|
|
|
|
|
|
|
|
image = mob.sprite();
|
|
|
|
add( image );
|
2015-02-06 06:07:22 +00:00
|
|
|
|
|
|
|
health = new HealthBar();
|
|
|
|
health.level((float) mob.HP / mob.HT);
|
|
|
|
add( health );
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
buffs = new BuffIndicator( mob );
|
|
|
|
add( buffs );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void layout() {
|
|
|
|
|
|
|
|
image.x = 0;
|
2015-02-06 06:07:22 +00:00
|
|
|
image.y = Math.max( 0, name.height() + GAP + health.height() - image.height );
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
name.x = image.width + GAP;
|
2015-02-06 06:07:22 +00:00
|
|
|
name.y = image.height - health.height() - GAP - name.baseLine();
|
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
float w = width - image.width - GAP;
|
2015-02-06 06:07:22 +00:00
|
|
|
|
|
|
|
health.setRect(image.width + GAP, image.height - health.height(), w, health.height());
|
|
|
|
|
2015-06-12 20:22:26 +00:00
|
|
|
buffs.setPos(
|
2015-04-08 04:23:12 +00:00
|
|
|
name.x + name.width() + GAP-1,
|
|
|
|
name.y + name.baseLine() - BuffIndicator.SIZE-2 );
|
2015-02-06 06:07:22 +00:00
|
|
|
|
|
|
|
height = health.bottom();
|
2014-07-27 13:39:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|