v0.7.0: added generic icontab class, added icons to journal tabs
This commit is contained in:
parent
6e8fe2089d
commit
0f4dadc229
|
@ -62,7 +62,6 @@ import com.watabou.noosa.Game;
|
||||||
import com.watabou.noosa.Image;
|
import com.watabou.noosa.Image;
|
||||||
import com.watabou.noosa.RenderedText;
|
import com.watabou.noosa.RenderedText;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
import com.watabou.utils.RectF;
|
|
||||||
|
|
||||||
public class WndBag extends WndTabbed {
|
public class WndBag extends WndTabbed {
|
||||||
|
|
||||||
|
@ -280,55 +279,30 @@ public class WndBag extends WndTabbed {
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BagTab extends Tab {
|
private Image icon( Bag bag ) {
|
||||||
|
if (bag instanceof VelvetPouch) {
|
||||||
private Image icon;
|
return Icons.get( Icons.SEED_POUCH );
|
||||||
|
} else if (bag instanceof ScrollHolder) {
|
||||||
|
return Icons.get( Icons.SCROLL_HOLDER );
|
||||||
|
} else if (bag instanceof MagicalHolster) {
|
||||||
|
return Icons.get( Icons.WAND_HOLSTER );
|
||||||
|
} else if (bag instanceof PotionBandolier) {
|
||||||
|
return Icons.get( Icons.POTION_BANDOLIER );
|
||||||
|
} else {
|
||||||
|
return Icons.get( Icons.BACKPACK );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class BagTab extends IconTab {
|
||||||
|
|
||||||
private Bag bag;
|
private Bag bag;
|
||||||
|
|
||||||
public BagTab( Bag bag ) {
|
public BagTab( Bag bag ) {
|
||||||
super();
|
super( icon(bag) );
|
||||||
|
|
||||||
this.bag = bag;
|
this.bag = bag;
|
||||||
|
|
||||||
icon = icon();
|
|
||||||
add( icon );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void select( boolean value ) {
|
|
||||||
super.select( value );
|
|
||||||
icon.am = selected ? 1.0f : 0.6f;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void layout() {
|
|
||||||
super.layout();
|
|
||||||
|
|
||||||
icon.copy( icon() );
|
|
||||||
icon.x = x + (width - icon.width) / 2;
|
|
||||||
icon.y = y + (height - icon.height) / 2 - 2 - (selected ? 0 : 1);
|
|
||||||
if (!selected && icon.y < y + CUT) {
|
|
||||||
RectF frame = icon.frame();
|
|
||||||
frame.top += (y + CUT - icon.y) / icon.texture.height;
|
|
||||||
icon.frame( frame );
|
|
||||||
icon.y = y + CUT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Image icon() {
|
|
||||||
if (bag instanceof VelvetPouch) {
|
|
||||||
return Icons.get( Icons.SEED_POUCH );
|
|
||||||
} else if (bag instanceof ScrollHolder) {
|
|
||||||
return Icons.get( Icons.SCROLL_HOLDER );
|
|
||||||
} else if (bag instanceof MagicalHolster) {
|
|
||||||
return Icons.get( Icons.WAND_HOLSTER );
|
|
||||||
} else if (bag instanceof PotionBandolier) {
|
|
||||||
return Icons.get( Icons.POTION_BANDOLIER );
|
|
||||||
} else {
|
|
||||||
return Icons.get( Icons.BACKPACK );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Placeholder extends Item {
|
public static class Placeholder extends Item {
|
||||||
|
|
|
@ -90,21 +90,21 @@ public class WndJournal extends WndTabbed {
|
||||||
catalogTab.updateList();
|
catalogTab.updateList();
|
||||||
|
|
||||||
Tab[] tabs = {
|
Tab[] tabs = {
|
||||||
new LabeledTab( Messages.get(this, "guide") ) {
|
new IconTab( new ItemSprite(ItemSpriteSheet.GUIDE_PAGE, null) ) {
|
||||||
protected void select( boolean value ) {
|
protected void select( boolean value ) {
|
||||||
super.select( value );
|
super.select( value );
|
||||||
guideTab.active = guideTab.visible = value;
|
guideTab.active = guideTab.visible = value;
|
||||||
if (value) last_index = 0;
|
if (value) last_index = 0;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new LabeledTab( Messages.get(this, "notes") ) {
|
new IconTab( Icons.get(Icons.DEPTH) ) {
|
||||||
protected void select( boolean value ) {
|
protected void select( boolean value ) {
|
||||||
super.select( value );
|
super.select( value );
|
||||||
notesTab.active = notesTab.visible = value;
|
notesTab.active = notesTab.visible = value;
|
||||||
if (value) last_index = 1;
|
if (value) last_index = 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new LabeledTab( Messages.get(this, "items") ) {
|
new IconTab( new ItemSprite(ItemSpriteSheet.WEAPON_HOLDER, null) ) {
|
||||||
protected void select( boolean value ) {
|
protected void select( boolean value ) {
|
||||||
super.select( value );
|
super.select( value );
|
||||||
catalogTab.active = catalogTab.visible = value;
|
catalogTab.active = catalogTab.visible = value;
|
||||||
|
|
|
@ -26,10 +26,12 @@ import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
|
import com.watabou.noosa.Image;
|
||||||
import com.watabou.noosa.NinePatch;
|
import com.watabou.noosa.NinePatch;
|
||||||
import com.watabou.noosa.RenderedText;
|
import com.watabou.noosa.RenderedText;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
import com.watabou.noosa.ui.Button;
|
import com.watabou.noosa.ui.Button;
|
||||||
|
import com.watabou.utils.RectF;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -229,5 +231,51 @@ public class WndTabbed extends Window {
|
||||||
btLabel.am = selected ? 1.0f : 0.6f;
|
btLabel.am = selected ? 1.0f : 0.6f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected class IconTab extends Tab {
|
||||||
|
|
||||||
|
private Image icon;
|
||||||
|
private RectF defaultFrame;
|
||||||
|
|
||||||
|
public IconTab( Image icon ){
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.icon.copy(icon);
|
||||||
|
this.defaultFrame = icon.frame();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createChildren() {
|
||||||
|
super.createChildren();
|
||||||
|
|
||||||
|
icon = new Image();
|
||||||
|
add( icon );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void layout() {
|
||||||
|
super.layout();
|
||||||
|
|
||||||
|
icon.frame(defaultFrame);
|
||||||
|
icon.x = x + (width - icon.width) / 2;
|
||||||
|
icon.y = y + (height - icon.height) / 2 - 1;
|
||||||
|
if (!selected) {
|
||||||
|
icon.y -= 2;
|
||||||
|
//if some of the icon is going into the window, cut it off
|
||||||
|
if (icon.y < y + CUT) {
|
||||||
|
RectF frame = icon.frame();
|
||||||
|
frame.top += (y + CUT - icon.y) / icon.texture.height;
|
||||||
|
icon.frame( frame );
|
||||||
|
icon.y = y + CUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void select( boolean value ) {
|
||||||
|
super.select( value );
|
||||||
|
icon.am = selected ? 1.0f : 0.6f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user