v0.7.5: improved itemsprite construction for heaps and various UI elements
This commit is contained in:
parent
868ace78b1
commit
92f198a9b0
|
@ -84,33 +84,6 @@ public class Heap implements Bundlable {
|
||||||
|
|
||||||
public LinkedList<Item> items = new LinkedList<Item>();
|
public LinkedList<Item> items = new LinkedList<Item>();
|
||||||
|
|
||||||
public int image() {
|
|
||||||
switch (type) {
|
|
||||||
case HEAP:
|
|
||||||
case FOR_SALE:
|
|
||||||
return size() > 0 ? items.peek().image() : 0;
|
|
||||||
case CHEST:
|
|
||||||
case MIMIC:
|
|
||||||
return ItemSpriteSheet.CHEST;
|
|
||||||
case LOCKED_CHEST:
|
|
||||||
return ItemSpriteSheet.LOCKED_CHEST;
|
|
||||||
case CRYSTAL_CHEST:
|
|
||||||
return ItemSpriteSheet.CRYSTAL_CHEST;
|
|
||||||
case TOMB:
|
|
||||||
return ItemSpriteSheet.TOMB;
|
|
||||||
case SKELETON:
|
|
||||||
return ItemSpriteSheet.BONES;
|
|
||||||
case REMAINS:
|
|
||||||
return ItemSpriteSheet.REMAINS;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemSprite.Glowing glowing() {
|
|
||||||
return (type == Type.HEAP || type == Type.FOR_SALE) && items.size() > 0 ? items.peek().glowing() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void open( Hero hero ) {
|
public void open( Hero hero ) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MIMIC:
|
case MIMIC:
|
||||||
|
@ -180,8 +153,7 @@ public class Heap implements Bundlable {
|
||||||
if (items.isEmpty()) {
|
if (items.isEmpty()) {
|
||||||
destroy();
|
destroy();
|
||||||
} else if (sprite != null) {
|
} else if (sprite != null) {
|
||||||
sprite.view( image(), glowing() );
|
sprite.view(this).place( pos );
|
||||||
sprite.place( pos );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
@ -212,11 +184,7 @@ public class Heap implements Bundlable {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sprite != null) {
|
if (sprite != null) {
|
||||||
if (type == Type.HEAP || type == Type.FOR_SALE)
|
sprite.view(this).place( pos );
|
||||||
sprite.view( items.peek() );
|
|
||||||
else
|
|
||||||
sprite.view( image(), glowing() );
|
|
||||||
sprite.place( pos );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,9 +200,8 @@ public class Heap implements Bundlable {
|
||||||
items.remove(a);
|
items.remove(a);
|
||||||
if (items.isEmpty()){
|
if (items.isEmpty()){
|
||||||
destroy();
|
destroy();
|
||||||
} else {
|
} else if (sprite != null) {
|
||||||
sprite.view( image(), glowing() );
|
sprite.view(this).place( pos );
|
||||||
sprite.place( pos );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,7 +259,7 @@ public class Heap implements Bundlable {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
destroy();
|
destroy();
|
||||||
} else if (sprite != null) {
|
} else if (sprite != null) {
|
||||||
sprite.view( items.peek() );
|
sprite.view(this).place( pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -339,7 +306,7 @@ public class Heap implements Bundlable {
|
||||||
if (isEmpty()){
|
if (isEmpty()){
|
||||||
destroy();
|
destroy();
|
||||||
} else if (sprite != null) {
|
} else if (sprite != null) {
|
||||||
sprite.view( items.peek() );
|
sprite.view(this).place( pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,7 +344,7 @@ public class Heap implements Bundlable {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
destroy();
|
destroy();
|
||||||
} else if (sprite != null) {
|
} else if (sprite != null) {
|
||||||
sprite.view( items.peek() );
|
sprite.view(this).place( pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,9 +74,13 @@ public class ItemSprite extends MovieClip {
|
||||||
this( ItemSpriteSheet.SOMETHING, null );
|
this( ItemSpriteSheet.SOMETHING, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemSprite( Heap heap ){
|
||||||
|
super(Assets.ITEMS);
|
||||||
|
view( heap );
|
||||||
|
}
|
||||||
|
|
||||||
public ItemSprite( Item item ) {
|
public ItemSprite( Item item ) {
|
||||||
super(Assets.ITEMS);
|
super(Assets.ITEMS);
|
||||||
|
|
||||||
view( item );
|
view( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +104,7 @@ public class ItemSprite extends MovieClip {
|
||||||
|
|
||||||
public void link( Heap heap ) {
|
public void link( Heap heap ) {
|
||||||
this.heap = heap;
|
this.heap = heap;
|
||||||
view( heap.image(), heap.glowing() );
|
view(heap);
|
||||||
renderShadow = true;
|
renderShadow = true;
|
||||||
place(heap.pos);
|
place(heap.pos);
|
||||||
}
|
}
|
||||||
|
@ -193,6 +197,32 @@ public class ItemSprite extends MovieClip {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemSprite view( Heap heap ){
|
||||||
|
if (heap.size() <= 0 || heap.items == null){
|
||||||
|
return view( 0, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (heap.type) {
|
||||||
|
case HEAP: case FOR_SALE:
|
||||||
|
return view( heap.peek() );
|
||||||
|
case CHEST:
|
||||||
|
case MIMIC:
|
||||||
|
return view( ItemSpriteSheet.CHEST, null );
|
||||||
|
case LOCKED_CHEST:
|
||||||
|
return view( ItemSpriteSheet.LOCKED_CHEST, null );
|
||||||
|
case CRYSTAL_CHEST:
|
||||||
|
return view( ItemSpriteSheet.CRYSTAL_CHEST, null );
|
||||||
|
case TOMB:
|
||||||
|
return view( ItemSpriteSheet.TOMB, null );
|
||||||
|
case SKELETON:
|
||||||
|
return view( ItemSpriteSheet.BONES, null );
|
||||||
|
case REMAINS:
|
||||||
|
return view( ItemSpriteSheet.REMAINS, null );
|
||||||
|
default:
|
||||||
|
return view( 0, null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ItemSprite view( int image, Glowing glowing ) {
|
public ItemSprite view( int image, Glowing glowing ) {
|
||||||
if (this.emitter != null) this.emitter.killAndErase();
|
if (this.emitter != null) this.emitter.killAndErase();
|
||||||
emitter = null;
|
emitter = null;
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class MissileSprite extends ItemSprite implements Tweener.Listener {
|
||||||
revive();
|
revive();
|
||||||
|
|
||||||
if (item == null) view(0, null);
|
if (item == null) view(0, null);
|
||||||
else view(item.image(), item.glowing());
|
else view( item );
|
||||||
|
|
||||||
setup( from,
|
setup( from,
|
||||||
to,
|
to,
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||||
|
@ -54,6 +55,13 @@ public class IconTitle extends Component {
|
||||||
icon.view( item );
|
icon.view( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IconTitle( Heap heap ){
|
||||||
|
ItemSprite icon = new ItemSprite();
|
||||||
|
icon( icon );
|
||||||
|
label( Messages.titleCase( heap.toString() ) );
|
||||||
|
icon.view( heap );
|
||||||
|
}
|
||||||
|
|
||||||
public IconTitle( Image icon, String label ) {
|
public IconTitle( Image icon, String label ) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
|
|
@ -43,28 +43,40 @@ public class WndInfoItem extends Window {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
if (heap.type == Heap.Type.HEAP || heap.type == Heap.Type.FOR_SALE) {
|
if (heap.type == Heap.Type.HEAP || heap.type == Heap.Type.FOR_SALE) {
|
||||||
|
fillFields( heap.peek() );
|
||||||
Item item = heap.peek();
|
|
||||||
|
|
||||||
int color = TITLE_COLOR;
|
|
||||||
if (item.levelKnown && item.level() > 0) {
|
|
||||||
color = ItemSlot.UPGRADED;
|
|
||||||
} else if (item.levelKnown && item.level() < 0) {
|
|
||||||
color = ItemSlot.DEGRADED;
|
|
||||||
}
|
|
||||||
fillFields( item.image(), item.glowing(), color, item.toString(), item.info() );
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
fillFields( heap );
|
||||||
fillFields( heap.image(), heap.glowing(), TITLE_COLOR, heap.toString(), heap.info() );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public WndInfoItem( Item item ) {
|
public WndInfoItem( Item item ) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
fillFields( item );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillFields( Heap heap ) {
|
||||||
|
|
||||||
|
int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P;
|
||||||
|
|
||||||
|
IconTitle titlebar = new IconTitle();
|
||||||
|
titlebar.icon( new ItemSprite(heap) );
|
||||||
|
titlebar.color( TITLE_COLOR );
|
||||||
|
titlebar.setRect( 0, 0, width, 0 );
|
||||||
|
add( titlebar );
|
||||||
|
|
||||||
|
RenderedTextMultiline txtInfo = PixelScene.renderMultiline( heap.info(), 6 );
|
||||||
|
txtInfo.maxWidth(width);
|
||||||
|
txtInfo.setPos(titlebar.left(), titlebar.bottom() + GAP);
|
||||||
|
add( txtInfo );
|
||||||
|
|
||||||
|
resize( width, (int)(txtInfo.top() + txtInfo.height()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillFields( Item item ) {
|
||||||
|
|
||||||
int color = TITLE_COLOR;
|
int color = TITLE_COLOR;
|
||||||
if (item.levelKnown && item.level() > 0) {
|
if (item.levelKnown && item.level() > 0) {
|
||||||
color = ItemSlot.UPGRADED;
|
color = ItemSlot.UPGRADED;
|
||||||
|
@ -72,20 +84,14 @@ public class WndInfoItem extends Window {
|
||||||
color = ItemSlot.DEGRADED;
|
color = ItemSlot.DEGRADED;
|
||||||
}
|
}
|
||||||
|
|
||||||
fillFields( item.image(), item.glowing(), color, item.toString(), item.info() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fillFields( int image, ItemSprite.Glowing glowing, int titleColor, String title, String info ) {
|
|
||||||
|
|
||||||
int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P;
|
int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P;
|
||||||
|
|
||||||
IconTitle titlebar = new IconTitle();
|
IconTitle titlebar = new IconTitle( item );
|
||||||
titlebar.icon( new ItemSprite( image, glowing ) );
|
titlebar.color( color );
|
||||||
titlebar.label( Messages.titleCase( title ), titleColor );
|
|
||||||
titlebar.setRect( 0, 0, width, 0 );
|
titlebar.setRect( 0, 0, width, 0 );
|
||||||
add( titlebar );
|
add( titlebar );
|
||||||
|
|
||||||
RenderedTextMultiline txtInfo = PixelScene.renderMultiline( info, 6 );
|
RenderedTextMultiline txtInfo = PixelScene.renderMultiline( item.info(), 6 );
|
||||||
txtInfo.maxWidth(width);
|
txtInfo.maxWidth(width);
|
||||||
txtInfo.setPos(titlebar.left(), titlebar.bottom() + GAP);
|
txtInfo.setPos(titlebar.left(), titlebar.bottom() + GAP);
|
||||||
add( txtInfo );
|
add( txtInfo );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user