v0.3.0: added functionality for full buff descriptions (need to write them still)
This commit is contained in:
parent
f3c6296dd8
commit
00c19d55bd
|
@ -103,4 +103,8 @@ public class Buff extends Actor {
|
|||
public static void detach( Char target, Class<? extends Buff> cl ) {
|
||||
detach( target.buff( cl ) );
|
||||
}
|
||||
|
||||
public String desc(){
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,14 @@
|
|||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoBuff;
|
||||
import com.watabou.gltextures.SmartTexture;
|
||||
import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.TextureFilm;
|
||||
import com.watabou.noosa.tweeners.AlphaTweener;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
|
@ -77,7 +80,7 @@ public class BuffIndicator extends Component {
|
|||
private SmartTexture texture;
|
||||
private TextureFilm film;
|
||||
|
||||
private SparseArray<Image> icons = new SparseArray<Image>();
|
||||
private SparseArray<BuffIcon> icons = new SparseArray<BuffIcon>();
|
||||
|
||||
private Char ch;
|
||||
|
||||
|
@ -109,24 +112,20 @@ public class BuffIndicator extends Component {
|
|||
protected void layout() {
|
||||
clear();
|
||||
|
||||
SparseArray<Image> newIcons = new SparseArray<Image>();
|
||||
SparseArray<BuffIcon> newIcons = new SparseArray<BuffIcon>();
|
||||
|
||||
for (Buff buff : ch.buffs()) {
|
||||
int icon = buff.icon();
|
||||
if (icon != NONE) {
|
||||
Image img = new Image( texture );
|
||||
img.frame( film.get( icon ) );
|
||||
img.x = x + members.size() * (SIZE + 2);
|
||||
img.y = y;
|
||||
add( img );
|
||||
|
||||
newIcons.put( icon, img );
|
||||
if (buff.icon() != NONE) {
|
||||
BuffIcon icon = new BuffIcon( buff );
|
||||
icon.setRect(x + members.size() * (SIZE + 2), y, 7, 7);
|
||||
add(icon);
|
||||
newIcons.put( buff.icon(), icon );
|
||||
}
|
||||
}
|
||||
|
||||
for (Integer key : icons.keyArray()) {
|
||||
if (newIcons.get( key ) == null) {
|
||||
Image icon = icons.get( key );
|
||||
Image icon = icons.get( key ).icon;
|
||||
icon.origin.set( SIZE / 2 );
|
||||
add( icon );
|
||||
add( new AlphaTweener( icon, 0, 0.6f ) {
|
||||
|
@ -141,6 +140,34 @@ public class BuffIndicator extends Component {
|
|||
|
||||
icons = newIcons;
|
||||
}
|
||||
|
||||
private class BuffIcon extends Button {
|
||||
|
||||
private Buff buff;
|
||||
|
||||
public Image icon;
|
||||
|
||||
public BuffIcon( Buff buff ){
|
||||
super();
|
||||
this.buff = buff;
|
||||
|
||||
icon = new Image( texture );
|
||||
icon.frame( film.get( buff.icon() ) );
|
||||
add( icon );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
super.layout();
|
||||
icon.x = this.x;
|
||||
icon.y = this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
GameScene.show(new WndInfoBuff(buff));
|
||||
}
|
||||
}
|
||||
|
||||
public static void refreshHero() {
|
||||
if (heroInstance != null) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
|
||||
public class WndHero extends WndTabbed {
|
||||
|
||||
|
@ -180,32 +181,55 @@ public class WndHero extends WndTabbed {
|
|||
|
||||
public BuffsTab() {
|
||||
for (Buff buff : Dungeon.hero.buffs()) {
|
||||
buffSlot( buff );
|
||||
}
|
||||
}
|
||||
|
||||
private void buffSlot( Buff buff ) {
|
||||
|
||||
int index = buff.icon();
|
||||
|
||||
if (index != BuffIndicator.NONE) {
|
||||
|
||||
Image icon = new Image( icons );
|
||||
icon.frame( film.get( index ) );
|
||||
icon.y = pos;
|
||||
add( icon );
|
||||
|
||||
BitmapText txt = PixelScene.createText( buff.toString(), 8 );
|
||||
txt.x = icon.width + GAP;
|
||||
txt.y = pos + (int)(icon.height - txt.baseLine()) / 2;
|
||||
add( txt );
|
||||
|
||||
pos += GAP + icon.height;
|
||||
if (buff.icon() != BuffIndicator.NONE) {
|
||||
BuffSlot slot = new BuffSlot(buff);
|
||||
slot.setRect(0, pos, WIDTH, slot.icon.height());
|
||||
add(slot);
|
||||
pos += GAP + slot.height();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 );
|
||||
icon.frame( film.get( index ) );
|
||||
icon.y = this.y;
|
||||
add( icon );
|
||||
|
||||
txt = PixelScene.createText( buff.toString(), 8 );
|
||||
txt.x = icon.width + GAP;
|
||||
txt.y = this.y + (int)(icon.height - txt.baseLine()) / 2;
|
||||
add( txt );
|
||||
|
||||
}
|
||||
|
||||
@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 ));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.watabou.gltextures.SmartTexture;
|
||||
import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.noosa.BitmapTextMultiline;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.TextureFilm;
|
||||
|
||||
/**
|
||||
* Created by debenhame on 06/04/2015.
|
||||
*/
|
||||
public class WndInfoBuff extends Window {
|
||||
|
||||
private static final float GAP = 2;
|
||||
|
||||
private static final int WIDTH = 120;
|
||||
|
||||
private SmartTexture icons;
|
||||
private TextureFilm film;
|
||||
|
||||
public WndInfoBuff(Buff buff){
|
||||
super();
|
||||
|
||||
IconTitle titlebar = new IconTitle();
|
||||
|
||||
icons = TextureCache.get( Assets.BUFFS_LARGE );
|
||||
film = new TextureFilm( icons, 16, 16 );
|
||||
|
||||
Image buffIcon = new Image( icons );
|
||||
buffIcon.frame( film.get(buff.icon()) );
|
||||
|
||||
titlebar.icon( buffIcon );
|
||||
titlebar.label( Utils.capitalize(buff.toString()), Window.TITLE_COLOR );
|
||||
titlebar.setRect( 0, 0, WIDTH, 0 );
|
||||
add( titlebar );
|
||||
|
||||
BitmapTextMultiline txtInfo = PixelScene.createMultiline(buff.desc(), 6);
|
||||
txtInfo.maxWidth = WIDTH;
|
||||
txtInfo.measure();
|
||||
txtInfo.x = titlebar.left();
|
||||
txtInfo.y = titlebar.bottom() + GAP;
|
||||
add( txtInfo );
|
||||
|
||||
resize( WIDTH, (int)(txtInfo.y + txtInfo.height()) );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user