v0.3.0: some refactoring to item sprites to better use an item as a parameter

This commit is contained in:
Evan Debenham
2015-05-11 20:14:13 -04:00
parent 097852207d
commit 0a78b2dc28
6 changed files with 23 additions and 13 deletions
@@ -59,7 +59,13 @@ public class ItemSprite extends MovieClip {
} }
public ItemSprite( Item item ) { public ItemSprite( Item item ) {
this( item.image(), item.glowing() ); super(Assets.ITEMS);
if (film == null) {
film = new TextureFilm( texture, SIZE, SIZE );
}
view (item);
} }
public ItemSprite( int image, Glowing glowing ) { public ItemSprite( int image, Glowing glowing ) {
@@ -143,6 +149,10 @@ public class ItemSprite extends MovieClip {
} }
} }
public ItemSprite view(Item item){
return view(item.image(), item.glowing());
}
public ItemSprite view( int image, Glowing glowing ) { public ItemSprite view( int image, Glowing glowing ) {
frame( film.get( image ) ); frame( film.get( image ) );
if ((this.glowing = glowing) == null) { if ((this.glowing = glowing) == null) {
@@ -140,7 +140,7 @@ public class ItemSlot extends Button {
active = true; active = true;
icon.visible = topLeft.visible = topRight.visible = bottomRight.visible = true; icon.visible = topLeft.visible = topRight.visible = bottomRight.visible = true;
icon.view( item.image(), item.glowing() ); icon.view( item );
topLeft.text( item.status() ); topLeft.text( item.status() );
@@ -341,7 +341,7 @@ public class Toolbar extends Component {
} }
public void reset( Item item, float dstX, float dstY ) { public void reset( Item item, float dstX, float dstY ) {
view( item.image(), item.glowing() ); view( item );
active = active =
visible = visible =
@@ -45,7 +45,7 @@ public class IconTitle extends Component {
public IconTitle( Item item ) { public IconTitle( Item item ) {
this( this(
new ItemSprite( item.image(), item.glowing() ), new ItemSprite( item ),
Utils.capitalize( item.toString() ) ); Utils.capitalize( item.toString() ) );
} }
@@ -41,7 +41,7 @@ public class WndItem extends Window {
super(); super();
IconTitle titlebar = new IconTitle(); IconTitle titlebar = new IconTitle();
titlebar.icon( new ItemSprite( item.image(), item.glowing() ) ); titlebar.icon( new ItemSprite( item ) );
titlebar.label( Utils.capitalize( item.toString() ) ); titlebar.label( Utils.capitalize( item.toString() ) );
titlebar.setRect( 0, 0, WIDTH, 0 ); titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar ); add( titlebar );
@@ -205,7 +205,7 @@ public class WndTradeItem extends Window {
// Title // Title
IconTitle titlebar = new IconTitle(); IconTitle titlebar = new IconTitle();
titlebar.icon( new ItemSprite( item.image(), item.glowing() ) ); titlebar.icon( new ItemSprite( item ) );
titlebar.label( forSale ? titlebar.label( forSale ?
Utils.format( TXT_SALE, item.toString(), price( item ) ) : Utils.format( TXT_SALE, item.toString(), price( item ) ) :
Utils.capitalize( item.toString() ) ); Utils.capitalize( item.toString() ) );