v0.3.0: added functionality for full buff descriptions (need to write them still)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user