2014-07-27 13:39:07 +00:00
|
|
|
/*
|
|
|
|
* Pixel Dungeon
|
2015-06-12 20:44:04 +00:00
|
|
|
* Copyright (C) 2012-2015 Oleg Dolya
|
|
|
|
*
|
|
|
|
* Shattered Pixel Dungeon
|
|
|
|
* Copyright (C) 2014-2015 Evan Debenham
|
2014-07-27 13:39:07 +00:00
|
|
|
*
|
|
|
|
* 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 java.util.Locale;
|
|
|
|
|
2014-10-12 04:03:23 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
2014-07-27 13:39:07 +00:00
|
|
|
import com.watabou.gltextures.SmartTexture;
|
|
|
|
import com.watabou.gltextures.TextureCache;
|
|
|
|
import com.watabou.noosa.BitmapText;
|
|
|
|
import com.watabou.noosa.Group;
|
|
|
|
import com.watabou.noosa.Image;
|
|
|
|
import com.watabou.noosa.TextureFilm;
|
2014-08-03 18:46:22 +00:00
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
2015-04-07 05:52:17 +00:00
|
|
|
import com.watabou.noosa.ui.Button;
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
public class WndHero extends WndTabbed {
|
|
|
|
|
|
|
|
private static final String TXT_STATS = "Stats";
|
|
|
|
private static final String TXT_BUFFS = "Buffs";
|
|
|
|
|
|
|
|
private static final String TXT_EXP = "Experience";
|
|
|
|
private static final String TXT_STR = "Strength";
|
|
|
|
private static final String TXT_HEALTH = "Health";
|
|
|
|
private static final String TXT_GOLD = "Gold Collected";
|
|
|
|
private static final String TXT_DEPTH = "Maximum Depth";
|
|
|
|
|
|
|
|
private static final int WIDTH = 100;
|
|
|
|
private static final int TAB_WIDTH = 40;
|
|
|
|
|
|
|
|
private StatsTab stats;
|
|
|
|
private BuffsTab buffs;
|
|
|
|
|
|
|
|
private SmartTexture icons;
|
|
|
|
private TextureFilm film;
|
|
|
|
|
|
|
|
public WndHero() {
|
|
|
|
|
|
|
|
super();
|
|
|
|
|
|
|
|
icons = TextureCache.get( Assets.BUFFS_LARGE );
|
|
|
|
film = new TextureFilm( icons, 16, 16 );
|
|
|
|
|
|
|
|
stats = new StatsTab();
|
|
|
|
add( stats );
|
|
|
|
|
|
|
|
buffs = new BuffsTab();
|
|
|
|
add( buffs );
|
|
|
|
|
|
|
|
add( new LabeledTab( TXT_STATS ) {
|
|
|
|
protected void select( boolean value ) {
|
|
|
|
super.select( value );
|
|
|
|
stats.visible = stats.active = selected;
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
add( new LabeledTab( TXT_BUFFS ) {
|
|
|
|
protected void select( boolean value ) {
|
|
|
|
super.select( value );
|
|
|
|
buffs.visible = buffs.active = selected;
|
|
|
|
};
|
|
|
|
} );
|
2015-02-08 01:19:11 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
resize( WIDTH, (int)Math.max( stats.height(), buffs.height() ) );
|
2015-02-08 01:19:11 +00:00
|
|
|
|
|
|
|
layoutTabs();
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
select( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
private class StatsTab extends Group {
|
|
|
|
|
|
|
|
private static final String TXT_TITLE = "Level %d %s";
|
|
|
|
private static final String TXT_CATALOGUS = "Catalogus";
|
|
|
|
private static final String TXT_JOURNAL = "Journal";
|
|
|
|
|
|
|
|
private static final int GAP = 5;
|
|
|
|
|
|
|
|
private float pos;
|
|
|
|
|
|
|
|
public StatsTab() {
|
|
|
|
|
2014-10-12 04:03:23 +00:00
|
|
|
Hero hero = Dungeon.hero;
|
|
|
|
|
2015-06-12 20:22:26 +00:00
|
|
|
IconTitle title = new IconTitle();
|
|
|
|
title.icon( HeroSprite.avatar(hero.heroClass, hero.tier()) );
|
|
|
|
title.label(Utils.format( TXT_TITLE, hero.lvl, hero.className() ).toUpperCase( Locale.ENGLISH ), 9);
|
|
|
|
title.color(Window.SHPX_COLOR);
|
|
|
|
title.setRect( 0, 0, WIDTH, 0 );
|
2014-10-12 04:03:23 +00:00
|
|
|
add(title);
|
2014-07-27 13:39:07 +00:00
|
|
|
|
|
|
|
RedButton btnCatalogus = new RedButton( TXT_CATALOGUS ) {
|
|
|
|
@Override
|
|
|
|
protected void onClick() {
|
|
|
|
hide();
|
|
|
|
GameScene.show( new WndCatalogus() );
|
|
|
|
}
|
|
|
|
};
|
2014-10-12 04:03:23 +00:00
|
|
|
btnCatalogus.setRect( 0, title.height(), btnCatalogus.reqWidth() + 2, btnCatalogus.reqHeight() + 2 );
|
2014-07-27 13:39:07 +00:00
|
|
|
add( btnCatalogus );
|
2014-10-12 04:03:23 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
RedButton btnJournal = new RedButton( TXT_JOURNAL ) {
|
|
|
|
@Override
|
|
|
|
protected void onClick() {
|
|
|
|
hide();
|
|
|
|
GameScene.show( new WndJournal() );
|
|
|
|
}
|
|
|
|
};
|
2014-10-12 04:03:23 +00:00
|
|
|
btnJournal.setRect(
|
|
|
|
btnCatalogus.right() + 1, btnCatalogus.top(),
|
2014-07-27 13:39:07 +00:00
|
|
|
btnJournal.reqWidth() + 2, btnJournal.reqHeight() + 2 );
|
|
|
|
add( btnJournal );
|
2014-10-12 04:03:23 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
pos = btnCatalogus.bottom() + GAP;
|
2014-10-12 04:03:23 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
statSlot( TXT_STR, hero.STR() );
|
|
|
|
statSlot( TXT_HEALTH, hero.HP + "/" + hero.HT );
|
|
|
|
statSlot( TXT_EXP, hero.exp + "/" + hero.maxExp() );
|
|
|
|
|
|
|
|
pos += GAP;
|
2014-10-12 04:03:23 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
statSlot( TXT_GOLD, Statistics.goldCollected );
|
|
|
|
statSlot( TXT_DEPTH, Statistics.deepestFloor );
|
2014-10-12 04:03:23 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
pos += GAP;
|
|
|
|
}
|
2014-10-12 04:03:23 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
private void statSlot( String label, String value ) {
|
2014-10-12 04:03:23 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
BitmapText txt = PixelScene.createText( label, 8 );
|
|
|
|
txt.y = pos;
|
|
|
|
add( txt );
|
2014-10-12 04:03:23 +00:00
|
|
|
|
2014-07-27 13:39:07 +00:00
|
|
|
txt = PixelScene.createText( value, 8 );
|
|
|
|
txt.measure();
|
2015-09-11 00:06:14 +00:00
|
|
|
txt.x = 65;
|
2014-07-27 13:39:07 +00:00
|
|
|
txt.y = pos;
|
|
|
|
add( txt );
|
|
|
|
|
|
|
|
pos += GAP + txt.baseLine();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void statSlot( String label, int value ) {
|
|
|
|
statSlot( label, Integer.toString( value ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
public float height() {
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class BuffsTab extends Group {
|
|
|
|
|
|
|
|
private static final int GAP = 2;
|
|
|
|
|
|
|
|
private float pos;
|
|
|
|
|
|
|
|
public BuffsTab() {
|
|
|
|
for (Buff buff : Dungeon.hero.buffs()) {
|
2015-04-07 05:52:17 +00:00
|
|
|
if (buff.icon() != BuffIndicator.NONE) {
|
|
|
|
BuffSlot slot = new BuffSlot(buff);
|
|
|
|
slot.setRect(0, pos, WIDTH, slot.icon.height());
|
|
|
|
add(slot);
|
|
|
|
pos += GAP + slot.height();
|
|
|
|
}
|
2014-07-27 13:39:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-07 05:52:17 +00:00
|
|
|
public float height() {
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
private class BuffSlot extends Button{
|
|
|
|
|
|
|
|
private Buff buff;
|
|
|
|
|
|
|
|
Image icon;
|
|
|
|
BitmapText txt;
|
|
|
|
|
|
|
|
public BuffSlot( Buff buff ){
|
|
|
|
super();
|
|
|
|
this.buff = buff;
|
|
|
|
int index = buff.icon();
|
|
|
|
|
|
|
|
icon = new Image( icons );
|
2014-07-27 13:39:07 +00:00
|
|
|
icon.frame( film.get( index ) );
|
2015-04-07 05:52:17 +00:00
|
|
|
icon.y = this.y;
|
2014-07-27 13:39:07 +00:00
|
|
|
add( icon );
|
2015-04-07 05:52:17 +00:00
|
|
|
|
|
|
|
txt = PixelScene.createText( buff.toString(), 8 );
|
2014-07-27 13:39:07 +00:00
|
|
|
txt.x = icon.width + GAP;
|
2015-04-07 05:52:17 +00:00
|
|
|
txt.y = this.y + (int)(icon.height - txt.baseLine()) / 2;
|
2014-07-27 13:39:07 +00:00
|
|
|
add( txt );
|
2015-04-07 05:52:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void layout() {
|
|
|
|
super.layout();
|
|
|
|
icon.y = this.y;
|
|
|
|
txt.x = icon.width + GAP;
|
|
|
|
txt.y = pos + (int)(icon.height - txt.baseLine()) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onClick() {
|
|
|
|
GameScene.show( new WndInfoBuff( buff ));
|
2014-07-27 13:39:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|