v0.4.1: significantly improved the UI of the journal and catalog

This commit is contained in:
Evan Debenham 2016-07-18 21:55:03 -04:00 committed by Evan Debenham
parent 40df7155f4
commit e8ed5949f1
6 changed files with 96 additions and 92 deletions

View File

@ -2,9 +2,9 @@ windows.wndblacksmith.prompt=Ok, a deal is a deal, here's what I can do for you:
windows.wndblacksmith.select=Select an item to reforge windows.wndblacksmith.select=Select an item to reforge
windows.wndblacksmith.reforge=Reforge them windows.wndblacksmith.reforge=Reforge them
windows.wndcatalogus.potions=Potions windows.wndcatalogs.potions=Potions
windows.wndcatalogus.scrolls=Scrolls windows.wndcatalogs.scrolls=Scrolls
windows.wndcatalogus.title=Catalogs windows.wndcatalogs.title=Catalogs
windows.wndchallenges.title=Challenges windows.wndchallenges.title=Challenges

View File

@ -112,7 +112,7 @@ public enum Icons {
icon.frame( icon.texture.uvRect( 0, 45, 13, 58 ) ); icon.frame( icon.texture.uvRect( 0, 45, 13, 58 ) );
break; break;
case DEPTH: case DEPTH:
icon.frame( icon.texture.uvRect( 45, 12, 54, 20 ) ); icon.frame( icon.texture.uvRect( 46, 12, 54, 20 ) );
break; break;
case DEPTH_LG: case DEPTH_LG:
icon.frame( icon.texture.uvRect( 34, 46, 50, 62 ) ); icon.frame( icon.texture.uvRect( 34, 46, 50, 62 ) );

View File

@ -30,7 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndCatalogus; import com.shatteredpixel.shatteredpixeldungeon.windows.WndCatalogs;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
import com.watabou.noosa.Gizmo; import com.watabou.noosa.Gizmo;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
@ -122,7 +122,7 @@ public class Toolbar extends Component {
} }
protected boolean onLongClick() { protected boolean onLongClick() {
GameScene.show(new WndCatalogus()); GameScene.show(new WndCatalogs());
return true; return true;
} }

View File

@ -20,7 +20,6 @@
*/ */
package com.shatteredpixel.shatteredpixeldungeon.windows; package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
@ -28,44 +27,54 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline;
import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane; import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.noosa.RenderedText; import com.watabou.noosa.ColorBlock;
import com.watabou.noosa.ui.Component; import com.watabou.noosa.ui.Component;
import java.util.ArrayList; import java.util.ArrayList;
public class WndCatalogus extends WndTabbed { public class WndCatalogs extends WndTabbed {
private static final int WIDTH_P = 112; private static final int WIDTH = 112;
private static final int HEIGHT_P = 160; private static final int HEIGHT = 141;
private static final int WIDTH_L = 128; private static final int ITEM_HEIGHT = 17;
private static final int HEIGHT_L = 128;
private static final int ITEM_HEIGHT = 18; private RedButton btnJournal;
private RedButton btnTitle;
private RenderedText txtTitle;
private ScrollPane list; private ScrollPane list;
private ArrayList<ListItem> items = new ArrayList<>(); private ArrayList<ListItem> items = new ArrayList<>();
private static boolean showPotions = true; private static boolean showPotions = true;
public WndCatalogus() { public WndCatalogs() {
super(); super();
if (ShatteredPixelDungeon.landscape()) { resize( WIDTH, HEIGHT );
resize( WIDTH_L, HEIGHT_L );
} else {
resize( WIDTH_P, HEIGHT_P );
}
txtTitle = PixelScene.renderText( Messages.get(this, "title"), 9 ); btnJournal = new RedButton( Messages.get(WndJournal.class, "title"), 9 ){
txtTitle.hardlight( Window.TITLE_COLOR ); @Override
add( txtTitle ); protected void onClick() {
hide();
GameScene.show(new WndJournal());
}
};
btnJournal.setRect(0, 0, WIDTH/2f - 1, btnJournal.reqHeight());
PixelScene.align( btnJournal );
add( btnJournal );
//does nothing, we're already in the catalog
btnTitle = new RedButton( Messages.get(this, "title"), 9 );
btnTitle.textColor( Window.TITLE_COLOR );
btnTitle.setRect(WIDTH/2f+1, 0, WIDTH/2f - 1, btnTitle.reqHeight());
PixelScene.align(btnTitle);
add( btnTitle );
list = new ScrollPane( new Component() ) { list = new ScrollPane( new Component() ) {
@Override @Override
@ -79,21 +88,21 @@ public class WndCatalogus extends WndTabbed {
} }
}; };
add( list ); add( list );
list.setRect( 0, txtTitle.height(), width, height - txtTitle.height() ); list.setRect( 0, btnTitle.height() + 1, width, height - btnTitle.height() - 1 );
boolean showPotions = WndCatalogus.showPotions; boolean showPotions = WndCatalogs.showPotions;
Tab[] tabs = { Tab[] tabs = {
new LabeledTab( Messages.get(this, "potions") ) { new LabeledTab( Messages.get(this, "potions") ) {
protected void select( boolean value ) { protected void select( boolean value ) {
super.select( value ); super.select( value );
WndCatalogus.showPotions = value; WndCatalogs.showPotions = value;
updateList(); updateList();
}; };
}, },
new LabeledTab( Messages.get(this, "scrolls") ) { new LabeledTab( Messages.get(this, "scrolls") ) {
protected void select( boolean value ) { protected void select( boolean value ) {
super.select( value ); super.select( value );
WndCatalogus.showPotions = !value; WndCatalogs.showPotions = !value;
updateList(); updateList();
}; };
} }
@ -109,10 +118,6 @@ public class WndCatalogus extends WndTabbed {
private void updateList() { private void updateList() {
txtTitle.text( Messages.get(this, "title", showPotions ? Messages.get(this, "potions") : Messages.get(this, "scrolls") ) );
txtTitle.x = (width - txtTitle.width()) / 2;
PixelScene.align(txtTitle);
items.clear(); items.clear();
Component content = list.content(); Component content = list.content();
@ -149,6 +154,7 @@ public class WndCatalogus extends WndTabbed {
private ItemSprite sprite; private ItemSprite sprite;
private RenderedTextMultiline label; private RenderedTextMultiline label;
private ColorBlock line;
public ListItem( Class<? extends Item> cl ) { public ListItem( Class<? extends Item> cl ) {
super(); super();
@ -157,10 +163,10 @@ public class WndCatalogus extends WndTabbed {
item = cl.newInstance(); item = cl.newInstance();
if (identified = item.isIdentified()) { if (identified = item.isIdentified()) {
sprite.view( item.image(), null ); sprite.view( item.image(), null );
label.text( item.name() ); label.text( Messages.titleCase(item.name()) );
} else { } else {
sprite.view( 127, null ); sprite.view( ItemSpriteSheet.SOMETHING, null );
label.text( item.trueName() ); label.text( Messages.titleCase(item.trueName()) );
label.hardlight( 0xCCCCCC ); label.hardlight( 0xCCCCCC );
} }
} catch (Exception e) { } catch (Exception e) {
@ -173,16 +179,24 @@ public class WndCatalogus extends WndTabbed {
sprite = new ItemSprite(); sprite = new ItemSprite();
add( sprite ); add( sprite );
label = PixelScene.renderMultiline( 8 ); label = PixelScene.renderMultiline( 7 );
add( label ); add( label );
line = new ColorBlock( 1, 1, 0xFF222222);
add(line);
} }
@Override @Override
protected void layout() { protected void layout() {
sprite.y = y + (height - sprite.height) / 2; sprite.y = y + 1 + (height - 1 - sprite.height) / 2f;
PixelScene.align(sprite);
label.maxWidth((int)(width - sprite.width)); line.size(width, 1);
label.setPos(sprite.x + sprite.width, y + (height - label.height()) / 2); line.x = 0;
line.y = y;
label.maxWidth((int)(width - sprite.width - 1));
label.setPos(sprite.x + sprite.width + 1, y + 1 + (height - 1 - label.height()) / 2f);
PixelScene.align(label); PixelScene.align(label);
} }

View File

@ -30,7 +30,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.gltextures.SmartTexture; import com.watabou.gltextures.SmartTexture;
import com.watabou.gltextures.TextureCache; import com.watabou.gltextures.TextureCache;
@ -105,29 +104,7 @@ public class WndHero extends WndTabbed {
title.setRect( 0, 0, WIDTH, 0 ); title.setRect( 0, 0, WIDTH, 0 );
add(title); add(title);
RedButton btnCatalogs = new RedButton( Messages.get(this, "catalogs") ) { pos = title.bottom() + 2*GAP;
@Override
protected void onClick() {
hide();
GameScene.show( new WndCatalogus() );
}
};
btnCatalogs.setRect( 0, title.height()+1, 57, btnCatalogs.reqHeight() + 2 );
add( btnCatalogs );
RedButton btnJournal = new RedButton( Messages.get(this, "journal") ) {
@Override
protected void onClick() {
hide();
GameScene.show( new WndJournal() );
}
};
btnJournal.setRect(
btnCatalogs.right() + 1, btnCatalogs.top(),
57, btnJournal.reqHeight() + 2 );
add( btnJournal );
pos = btnCatalogs.bottom() + GAP;
statSlot( Messages.get(this, "str"), hero.STR() ); statSlot( Messages.get(this, "str"), hero.STR() );
if (hero.SHLD > 0) statSlot( Messages.get(this, "health"), hero.HP + "+" + hero.SHLD + "/" + hero.HT ); if (hero.SHLD > 0) statSlot( Messages.get(this, "health"), hero.HP + "+" + hero.SHLD + "/" + hero.HT );

View File

@ -22,19 +22,20 @@ package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal; import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey; import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey; import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey; import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline;
import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane; import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText;
import com.watabou.noosa.ColorBlock; import com.watabou.noosa.ColorBlock;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
import com.watabou.noosa.RenderedText;
import com.watabou.noosa.ui.Component; import com.watabou.noosa.ui.Component;
import java.util.Collections; import java.util.Collections;
@ -42,24 +43,36 @@ import java.util.Collections;
public class WndJournal extends Window { public class WndJournal extends Window {
private static final int WIDTH = 112; private static final int WIDTH = 112;
private static final int HEIGHT_P = 160; private static final int HEIGHT = 160;
private static final int HEIGHT_L = 144;
private static final int ITEM_HEIGHT = 14; private static final int ITEM_HEIGHT = 17;
private RenderedText txtTitle; private RedButton btnTitle;
private RedButton btnCatalogues;
private ScrollPane list; private ScrollPane list;
public WndJournal() { public WndJournal() {
super(); super();
resize( WIDTH, ShatteredPixelDungeon.landscape() ? HEIGHT_L : HEIGHT_P ); resize( WIDTH, HEIGHT );
txtTitle = PixelScene.renderText( Messages.get(this, "title"), 9 ); //does nothing, we're already in the journal
txtTitle.hardlight( Window.TITLE_COLOR ); btnTitle = new RedButton( Messages.get(this, "title"), 9 );
txtTitle.x = (WIDTH - txtTitle.width()) / 2; btnTitle.textColor( Window.TITLE_COLOR );
PixelScene.align(txtTitle); btnTitle.setRect(0, 0, WIDTH/2f - 1, btnTitle.reqHeight());
add( txtTitle ); PixelScene.align(btnTitle);
add( btnTitle );
btnCatalogues = new RedButton( Messages.get(WndCatalogs.class, "title"), 9 ){
@Override
protected void onClick() {
hide();
GameScene.show(new WndCatalogs());
}
};
btnCatalogues.setRect(WIDTH/2f + 1, 0, WIDTH/2f - 1, btnCatalogues.reqHeight());
PixelScene.align( btnCatalogues );
add( btnCatalogues );
Component content = new Component(); Component content = new Component();
@ -79,14 +92,14 @@ public class WndJournal extends Window {
if (Dungeon.hero.belongings.specialKeys[i] > 1){ if (Dungeon.hero.belongings.specialKeys[i] > 1){
text += " x" + Dungeon.hero.belongings.specialKeys[i]; text += " x" + Dungeon.hero.belongings.specialKeys[i];
} }
ListItem item = new ListItem( text, i ); ListItem item = new ListItem( Messages.titleCase(text), i );
item.setRect( 0, pos, WIDTH, ITEM_HEIGHT ); item.setRect( 0, pos, WIDTH, ITEM_HEIGHT );
content.add( item ); content.add( item );
pos += item.height(); pos += item.height();
} }
if (Dungeon.hero.belongings.ironKeys[i] > 0){ if (Dungeon.hero.belongings.ironKeys[i] > 0){
String text = Messages.capitalize(Messages.get(IronKey.class, "name")); String text = Messages.titleCase(Messages.get(IronKey.class, "name"));
if (Dungeon.hero.belongings.ironKeys[i] > 1){ if (Dungeon.hero.belongings.ironKeys[i] > 1){
text += " x" + Dungeon.hero.belongings.ironKeys[i]; text += " x" + Dungeon.hero.belongings.ironKeys[i];
@ -115,12 +128,12 @@ public class WndJournal extends Window {
list = new ScrollPane( content ); list = new ScrollPane( content );
add( list ); add( list );
list.setRect( 0, txtTitle.height(), WIDTH, height - txtTitle.height() ); list.setRect( 0, btnTitle.height() + 1, WIDTH, height - btnTitle.height() - 1 );
} }
private static class ListItem extends Component { private static class ListItem extends Component {
private RenderedText feature; private RenderedTextMultiline feature;
private BitmapText depth; private BitmapText depth;
private ColorBlock line; private ColorBlock line;
private Image icon; private Image icon;
@ -141,7 +154,7 @@ public class WndJournal extends Window {
@Override @Override
protected void createChildren() { protected void createChildren() {
feature = PixelScene.renderText( 7 ); feature = PixelScene.renderMultiline( 7 );
add( feature ); add( feature );
depth = new BitmapText( PixelScene.pixelFont); depth = new BitmapText( PixelScene.pixelFont);
@ -157,20 +170,20 @@ public class WndJournal extends Window {
@Override @Override
protected void layout() { protected void layout() {
icon.x = width - icon.width; depth.x = (8 - depth.width())/2f;
depth.y = y + 1.5f + (height() - 1 - depth.height()) / 2f;
depth.x = icon.x - 1 - depth.width();
depth.y = y + (height() - depth.height() + 1) / 2f;
PixelScene.align(depth); PixelScene.align(depth);
icon.y = y + (height() - icon.height()) / 2f; icon.x = 8;
icon.y = y + 1 + (height() - 1 - icon.height()) / 2f;
PixelScene.align(icon); PixelScene.align(icon);
line.size(width, 1); line.size(width, 1);
line.x = 0; line.x = 0;
line.y = y; line.y = y;
feature.y = y + (height() - feature.baseLine()) / 2f; feature.maxWidth((int)(width - icon.width() - 8 - 1));
feature.setPos(icon.x + icon.width() + 1, y + 1 + (height() - 1 - feature.height()) / 2f);
PixelScene.align(feature); PixelScene.align(feature);
} }
} }