v0.8.2: improved layout and UI elements on journal UI
This commit is contained in:
parent
4b81a9c138
commit
40da8d2395
|
@ -183,6 +183,7 @@ public class WndJournal extends WndTabbed {
|
|||
protected void layout() {
|
||||
|
||||
icon.y = y + 1 + (height() - 1 - icon.height()) / 2f;
|
||||
icon.x = x + (16 - icon.width())/2f;
|
||||
PixelScene.align(icon);
|
||||
|
||||
depth.x = icon.x + (icon.width - depth.width()) / 2f;
|
||||
|
@ -193,8 +194,8 @@ public class WndJournal extends WndTabbed {
|
|||
line.x = 0;
|
||||
line.y = y;
|
||||
|
||||
label.maxWidth((int)(width - icon.width() - 8 - 1));
|
||||
label.setPos(icon.x + icon.width() + 1, y + 1 + (height() - label.height()) / 2f);
|
||||
label.maxWidth((int)(width - 16 - 1));
|
||||
label.setPos(17, y + 1 + (height() - label.height()) / 2f);
|
||||
PixelScene.align(label);
|
||||
}
|
||||
}
|
||||
|
@ -264,8 +265,7 @@ public class WndJournal extends WndTabbed {
|
|||
private String page;
|
||||
|
||||
public GuideItem( String page ){
|
||||
super( new ItemSprite( ItemSpriteSheet.GUIDE_PAGE, null),
|
||||
Messages.titleCase(Document.ADVENTURERS_GUIDE.pageTitle(page)), -1);
|
||||
super( iconForPage(page), Messages.titleCase(Document.ADVENTURERS_GUIDE.pageTitle(page)));
|
||||
|
||||
this.page = page;
|
||||
found = Document.ADVENTURERS_GUIDE.hasPage(page);
|
||||
|
@ -280,13 +280,44 @@ public class WndJournal extends WndTabbed {
|
|||
|
||||
public boolean onClick( float x, float y ) {
|
||||
if (inside( x, y ) && found) {
|
||||
GameScene.show( new WndStory( Document.ADVENTURERS_GUIDE.pageBody(page) ));
|
||||
GameScene.show( new WndStory( iconForPage(page),
|
||||
Document.ADVENTURERS_GUIDE.pageTitle(page),
|
||||
Document.ADVENTURERS_GUIDE.pageBody(page) ));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO might just want this to be part of the Document class
|
||||
private static Image iconForPage( String page ){
|
||||
if (!Document.ADVENTURERS_GUIDE.hasPage(page)){
|
||||
return new ItemSprite( ItemSpriteSheet.GUIDE_PAGE );
|
||||
}
|
||||
switch (page){
|
||||
case Document.GUIDE_INTRO_PAGE: default:
|
||||
return new ItemSprite(ItemSpriteSheet.MASTERY);
|
||||
case "Identifying":
|
||||
return new ItemSprite( ItemSpriteSheet.SCROLL_ISAZ );
|
||||
case Document.GUIDE_SEARCH_PAGE:
|
||||
return new ItemSprite( ItemSpriteSheet.LOCKED_CHEST );
|
||||
case "Strength":
|
||||
return new ItemSprite( ItemSpriteSheet.ARMOR_SCALE );
|
||||
case "Food":
|
||||
return new ItemSprite( ItemSpriteSheet.PASTY );
|
||||
case "Levelling":
|
||||
return new ItemSprite( ItemSpriteSheet.POTION_MAGENTA );
|
||||
case "Surprise_Attacks":
|
||||
return new ItemSprite( ItemSpriteSheet.ASSASSINS_BLADE );
|
||||
case "Dieing":
|
||||
return new ItemSprite( ItemSpriteSheet.ANKH );
|
||||
case "Looting":
|
||||
return new ItemSprite( ItemSpriteSheet.CRYSTAL_KEY );
|
||||
case "Magic":
|
||||
return new ItemSprite( ItemSpriteSheet.WAND_LIGHTNING );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.utils.SparseArray;
|
||||
|
||||
|
@ -58,19 +59,33 @@ public class WndStory extends Window {
|
|||
CHAPTERS.put( ID_HALLS, "halls" );
|
||||
}
|
||||
|
||||
private IconTitle ttl;
|
||||
private RenderedTextBlock tf;
|
||||
|
||||
private float delay;
|
||||
|
||||
public WndStory( String text ) {
|
||||
this( null, null, text );
|
||||
}
|
||||
|
||||
public WndStory(Image icon, String title, String text ) {
|
||||
super( 0, 0, Chrome.get( Chrome.Type.SCROLL ) );
|
||||
|
||||
int width = PixelScene.landscape() ? WIDTH_L - MARGIN * 2: WIDTH_P - MARGIN *2;
|
||||
|
||||
float y = MARGIN;
|
||||
if (icon != null && title != null){
|
||||
ttl = new IconTitle(icon, title);
|
||||
ttl.setRect(MARGIN, y, width-2*MARGIN, 0);
|
||||
y = ttl.bottom()+MARGIN;
|
||||
add(ttl);
|
||||
ttl.tfLabel.invert();
|
||||
}
|
||||
|
||||
tf = PixelScene.renderTextBlock( text, 6 );
|
||||
tf.maxWidth(PixelScene.landscape() ?
|
||||
WIDTH_L - MARGIN * 2:
|
||||
WIDTH_P - MARGIN *2);
|
||||
tf.maxWidth(width);
|
||||
tf.invert();
|
||||
tf.setPos(MARGIN, 2);
|
||||
tf.setPos(MARGIN, y);
|
||||
add( tf );
|
||||
|
||||
add( new PointerArea( chrome ) {
|
||||
|
@ -80,7 +95,7 @@ public class WndStory extends Window {
|
|||
}
|
||||
} );
|
||||
|
||||
resize( (int)(tf.width() + MARGIN * 2), (int)Math.min( tf.height()+2, 180 ) );
|
||||
resize( (int)(tf.width() + MARGIN * 2), (int)Math.min( tf.bottom()+MARGIN, 180 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,6 +104,7 @@ public class WndStory extends Window {
|
|||
|
||||
if (delay > 0 && (delay -= Game.elapsed) <= 0) {
|
||||
shadow.visible = chrome.visible = tf.visible = true;
|
||||
if (ttl != null) ttl.visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,6 +119,7 @@ public class WndStory extends Window {
|
|||
WndStory wnd = new WndStory( text );
|
||||
if ((wnd.delay = 0.6f) > 0) {
|
||||
wnd.shadow.visible = wnd.chrome.visible = wnd.tf.visible = false;
|
||||
if (wnd.ttl != null) wnd.ttl.visible = false;
|
||||
}
|
||||
|
||||
Game.scene().add( wnd );
|
||||
|
|
Loading…
Reference in New Issue
Block a user