From e8ed5949f1734d798f3a29f3513afb134e6425ce Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 18 Jul 2016 21:55:03 -0400 Subject: [PATCH] v0.4.1: significantly improved the UI of the journal and catalog --- .../messages/windows/windows.properties | 6 +- .../shatteredpixeldungeon/ui/Icons.java | 2 +- .../shatteredpixeldungeon/ui/Toolbar.java | 4 +- .../{WndCatalogus.java => WndCatalogs.java} | 82 +++++++++++-------- .../windows/WndHero.java | 25 +----- .../windows/WndJournal.java | 69 +++++++++------- 6 files changed, 96 insertions(+), 92 deletions(-) rename src/com/shatteredpixel/shatteredpixeldungeon/windows/{WndCatalogus.java => WndCatalogs.java} (69%) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties b/src/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties index e8e62ed38..56b6bfe23 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties +++ b/src/com/shatteredpixel/shatteredpixeldungeon/messages/windows/windows.properties @@ -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.reforge=Reforge them -windows.wndcatalogus.potions=Potions -windows.wndcatalogus.scrolls=Scrolls -windows.wndcatalogus.title=Catalogs +windows.wndcatalogs.potions=Potions +windows.wndcatalogs.scrolls=Scrolls +windows.wndcatalogs.title=Catalogs windows.wndchallenges.title=Challenges diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java index af9b0b196..8e4eabf00 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java @@ -112,7 +112,7 @@ public enum Icons { icon.frame( icon.texture.uvRect( 0, 45, 13, 58 ) ); break; case DEPTH: - icon.frame( icon.texture.uvRect( 45, 12, 54, 20 ) ); + icon.frame( icon.texture.uvRect( 46, 12, 54, 20 ) ); break; case DEPTH_LG: icon.frame( icon.texture.uvRect( 34, 46, 50, 62 ) ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java index 445404e78..9b0da96b2 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java @@ -30,7 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; 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.Gizmo; import com.watabou.noosa.Image; @@ -122,7 +122,7 @@ public class Toolbar extends Component { } protected boolean onLongClick() { - GameScene.show(new WndCatalogus()); + GameScene.show(new WndCatalogs()); return true; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogus.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogs.java similarity index 69% rename from src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogus.java rename to src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogs.java index 4b81467ab..7cf3e20ad 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogus.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogs.java @@ -20,7 +20,6 @@ */ package com.shatteredpixel.shatteredpixeldungeon.windows; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; 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.PixelScene; 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.ScrollPane; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; -import com.watabou.noosa.RenderedText; +import com.watabou.noosa.ColorBlock; import com.watabou.noosa.ui.Component; 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 HEIGHT_P = 160; + private static final int WIDTH = 112; + private static final int HEIGHT = 141; - private static final int WIDTH_L = 128; - private static final int HEIGHT_L = 128; + private static final int ITEM_HEIGHT = 17; - private static final int ITEM_HEIGHT = 18; - - private RenderedText txtTitle; + private RedButton btnJournal; + private RedButton btnTitle; private ScrollPane list; private ArrayList items = new ArrayList<>(); private static boolean showPotions = true; - public WndCatalogus() { + public WndCatalogs() { super(); - if (ShatteredPixelDungeon.landscape()) { - resize( WIDTH_L, HEIGHT_L ); - } else { - resize( WIDTH_P, HEIGHT_P ); - } + resize( WIDTH, HEIGHT ); - txtTitle = PixelScene.renderText( Messages.get(this, "title"), 9 ); - txtTitle.hardlight( Window.TITLE_COLOR ); - add( txtTitle ); + btnJournal = new RedButton( Messages.get(WndJournal.class, "title"), 9 ){ + @Override + 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() ) { @Override @@ -79,21 +88,21 @@ public class WndCatalogus extends WndTabbed { } }; 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 = { new LabeledTab( Messages.get(this, "potions") ) { protected void select( boolean value ) { super.select( value ); - WndCatalogus.showPotions = value; + WndCatalogs.showPotions = value; updateList(); }; }, new LabeledTab( Messages.get(this, "scrolls") ) { protected void select( boolean value ) { super.select( value ); - WndCatalogus.showPotions = !value; + WndCatalogs.showPotions = !value; updateList(); }; } @@ -108,10 +117,6 @@ public class WndCatalogus extends WndTabbed { } 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(); @@ -149,6 +154,7 @@ public class WndCatalogus extends WndTabbed { private ItemSprite sprite; private RenderedTextMultiline label; + private ColorBlock line; public ListItem( Class cl ) { super(); @@ -157,10 +163,10 @@ public class WndCatalogus extends WndTabbed { item = cl.newInstance(); if (identified = item.isIdentified()) { sprite.view( item.image(), null ); - label.text( item.name() ); + label.text( Messages.titleCase(item.name()) ); } else { - sprite.view( 127, null ); - label.text( item.trueName() ); + sprite.view( ItemSpriteSheet.SOMETHING, null ); + label.text( Messages.titleCase(item.trueName()) ); label.hardlight( 0xCCCCCC ); } } catch (Exception e) { @@ -173,16 +179,24 @@ public class WndCatalogus extends WndTabbed { sprite = new ItemSprite(); add( sprite ); - label = PixelScene.renderMultiline( 8 ); + label = PixelScene.renderMultiline( 7 ); add( label ); + + line = new ColorBlock( 1, 1, 0xFF222222); + add(line); } @Override 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)); - label.setPos(sprite.x + sprite.width, y + (height - label.height()) / 2); + line.size(width, 1); + 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); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java index bf4aca857..ae48f1506 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java @@ -30,7 +30,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; -import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.watabou.gltextures.SmartTexture; import com.watabou.gltextures.TextureCache; @@ -105,29 +104,7 @@ public class WndHero extends WndTabbed { title.setRect( 0, 0, WIDTH, 0 ); add(title); - RedButton btnCatalogs = new RedButton( Messages.get(this, "catalogs") ) { - @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; + pos = title.bottom() + 2*GAP; statSlot( Messages.get(this, "str"), hero.STR() ); if (hero.SHLD > 0) statSlot( Messages.get(this, "health"), hero.HP + "+" + hero.SHLD + "/" + hero.HT ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java index 6c512262b..b9abfee67 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java @@ -22,44 +22,57 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Journal; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey; import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey; import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; 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.Window; import com.watabou.noosa.BitmapText; import com.watabou.noosa.ColorBlock; import com.watabou.noosa.Image; -import com.watabou.noosa.RenderedText; import com.watabou.noosa.ui.Component; import java.util.Collections; public class WndJournal extends Window { - private static final int WIDTH = 112; - private static final int HEIGHT_P = 160; - private static final int HEIGHT_L = 144; + private static final int WIDTH = 112; + private static final int HEIGHT = 160; - 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; public WndJournal() { super(); - resize( WIDTH, ShatteredPixelDungeon.landscape() ? HEIGHT_L : HEIGHT_P ); + resize( WIDTH, HEIGHT ); - txtTitle = PixelScene.renderText( Messages.get(this, "title"), 9 ); - txtTitle.hardlight( Window.TITLE_COLOR ); - txtTitle.x = (WIDTH - txtTitle.width()) / 2; - PixelScene.align(txtTitle); - add( txtTitle ); + //does nothing, we're already in the journal + btnTitle = new RedButton( Messages.get(this, "title"), 9 ); + btnTitle.textColor( Window.TITLE_COLOR ); + btnTitle.setRect(0, 0, WIDTH/2f - 1, btnTitle.reqHeight()); + 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(); @@ -79,14 +92,14 @@ public class WndJournal extends Window { if (Dungeon.hero.belongings.specialKeys[i] > 1){ 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 ); content.add( item ); pos += item.height(); } 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){ text += " x" + Dungeon.hero.belongings.ironKeys[i]; @@ -115,12 +128,12 @@ public class WndJournal extends Window { list = new ScrollPane( content ); 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 RenderedText feature; + private RenderedTextMultiline feature; private BitmapText depth; private ColorBlock line; private Image icon; @@ -141,9 +154,9 @@ public class WndJournal extends Window { @Override protected void createChildren() { - feature = PixelScene.renderText( 7 ); + feature = PixelScene.renderMultiline( 7 ); add( feature ); - + depth = new BitmapText( PixelScene.pixelFont); add( depth ); @@ -156,21 +169,21 @@ public class WndJournal extends Window { @Override protected void layout() { - - icon.x = width - icon.width; - - depth.x = icon.x - 1 - depth.width(); - depth.y = y + (height() - depth.height() + 1) / 2f; + + depth.x = (8 - depth.width())/2f; + depth.y = y + 1.5f + (height() - 1 - depth.height()) / 2f; 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); line.size(width, 1); line.x = 0; 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); } }