From 68406db6fe528dd672b1ec4a139750b6bd0800e4 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 6 Feb 2015 01:07:22 -0500 Subject: [PATCH] merging 1.7.5 source: windows changes --- .../windows/IconTitle.java | 56 +++++++++++++------ .../shatteredpixeldungeon/windows/WndBag.java | 43 +++++++++----- .../windows/WndCatalogus.java | 39 ++++++++----- .../windows/WndChallenges.java | 8 ++- .../windows/WndGame.java | 53 ++++++++++-------- .../shatteredpixeldungeon/windows/WndImp.java | 8 +-- .../windows/WndInfoItem.java | 2 +- .../windows/WndInfoMob.java | 49 ++++++---------- .../windows/WndItem.java | 6 +- .../windows/WndJournal.java | 18 +++--- .../windows/WndMessage.java | 8 ++- .../windows/WndResurrect.java | 2 +- .../windows/WndSadGhost.java | 2 +- .../windows/WndStory.java | 4 +- .../windows/WndTabbed.java | 5 ++ .../windows/WndTitledMessage.java | 14 +++-- .../windows/WndTradeItem.java | 3 +- .../windows/WndWandmaker.java | 2 +- 18 files changed, 188 insertions(+), 134 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java index c7a38180f..4695806c4 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java @@ -23,18 +23,22 @@ import com.watabou.noosa.ui.Component; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; +import com.shatteredpixel.shatteredpixeldungeon.ui.HealthBar; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; public class IconTitle extends Component { private static final float FONT_SIZE = 9; - + private static final float GAP = 2; - + protected Image imIcon; protected BitmapTextMultiline tfLabel; - + protected HealthBar health; + + private float healthLvl = Float.NaN; + public IconTitle() { super(); } @@ -45,55 +49,71 @@ public class IconTitle extends Component { Utils.capitalize( item.toString() ) ); } - + public IconTitle( Image icon, String label ) { super(); - + icon( icon ); label( label ); } - + @Override protected void createChildren() { imIcon = new Image(); add( imIcon ); - + tfLabel = PixelScene.createMultiline( FONT_SIZE ); tfLabel.hardlight( Window.TITLE_COLOR ); add( tfLabel ); + + health = new HealthBar(); + add( health ); } - + @Override protected void layout() { - imIcon.x = this.x; - imIcon.y = this.y; - + + health.visible = !Float.isNaN( healthLvl ); + + imIcon.x = x; + imIcon.y = y; + tfLabel.x = PixelScene.align( PixelScene.uiCamera, imIcon.x + imIcon.width() + GAP ); tfLabel.maxWidth = (int)(width - tfLabel.x); tfLabel.measure(); tfLabel.y = PixelScene.align( PixelScene.uiCamera, imIcon.height > tfLabel.height() ? - imIcon.y + 1 + (imIcon.height() - tfLabel.height()) / 2 : + imIcon.y + (imIcon.height() - tfLabel.baseLine()) / 2 : imIcon.y ); - - height = Math.max( imIcon.height(), tfLabel.height() ); + + if (health.visible) { + health.setRect( tfLabel.x, Math.max( tfLabel.y + tfLabel.height(), imIcon.y + imIcon.height() - health.height() ), tfLabel.maxWidth, 0 ); + height = health.bottom(); + } else { + height = Math.max( imIcon.y + imIcon.height(), tfLabel.y + tfLabel.height() ); + } } - + public void icon( Image icon ) { remove( imIcon ); add( imIcon = icon ); } - + public void label( String label ) { tfLabel.text( label ); } - + public void label( String label, int color ) { tfLabel.text( label ); tfLabel.hardlight( color ); } - + public void color( int color ) { tfLabel.hardlight( color ); } + + public void health( float value ) { + health.level( healthLvl = value ); + layout(); + } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index 0ca880ffc..71d59d323 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -62,6 +62,7 @@ public class WndBag extends WndTabbed { FOR_SALE, WEAPON, ARMOR, + ENCHANTABLE, WAND, SEED, FOOD, @@ -70,7 +71,8 @@ public class WndBag extends WndTabbed { EQUIPMENT } - protected static final int COLS = 4; + protected static final int COLS_P = 4; + protected static final int COLS_L = 6; protected static final int SLOT_SIZE = 28; protected static final int SLOT_MARGIN = 1; @@ -79,14 +81,13 @@ public class WndBag extends WndTabbed { protected static final int TITLE_HEIGHT = 12; - @SuppressWarnings("unused") - protected static final int ROWS = - (Belongings.BACKPACK_SIZE + 4 + 1) / COLS + ((Belongings.BACKPACK_SIZE + 4 + 1) % COLS > 0 ? 1 : 0); - private Listener listener; private WndBag.Mode mode; private String title; + private int nCols; + private int nRows; + protected int count; protected int col; protected int row; @@ -105,18 +106,22 @@ public class WndBag extends WndTabbed { lastMode = mode; lastBag = bag; + nCols = ShatteredPixelDungeon.landscape() ? COLS_L : COLS_P; + nRows = (Belongings.BACKPACK_SIZE + 4 + 1) / nCols + ((Belongings.BACKPACK_SIZE + 4 + 1) % nCols > 0 ? 1 : 0); + + int slotsWidth = SLOT_SIZE * nCols + SLOT_MARGIN * (nCols - 1); + int slotsHeight = SLOT_SIZE * nRows + SLOT_MARGIN * (nRows - 1); + BitmapText txtTitle = PixelScene.createText( title != null ? title : Utils.capitalize( bag.name() ), 9 ); txtTitle.hardlight( TITLE_COLOR ); txtTitle.measure(); - txtTitle.x = (int)(SLOT_SIZE * COLS + SLOT_MARGIN * (COLS - 1) - txtTitle.width()) / 2; + txtTitle.x = (int)(slotsWidth - txtTitle.width()) / 2; txtTitle.y = (int)(TITLE_HEIGHT - txtTitle.height()) / 2; add( txtTitle ); placeItems( bag ); - resize( - SLOT_SIZE * COLS + SLOT_MARGIN * (COLS - 1), - SLOT_SIZE * ROWS + SLOT_MARGIN * (ROWS - 1) + TITLE_HEIGHT ); + resize( slotsWidth, slotsHeight + TITLE_HEIGHT ); Belongings stuff = Dungeon.hero.belongings; Bag[] bags = { @@ -167,20 +172,27 @@ public class WndBag extends WndTabbed { placeItem( stuff.misc1 != null ? stuff.misc1 : new Placeholder( ItemSpriteSheet.RING ) ); placeItem( stuff.misc2 != null ? stuff.misc2 : new Placeholder( ItemSpriteSheet.RING ) ); - // Unequipped items + boolean backpack = (container == Dungeon.hero.belongings.backpack); + if (!backpack) { + count = nCols; + col = 0; + row = 1; + } + + // Items in the bag for (Item item : container.items) { placeItem( item ); } - // Empty slots - while (count-4 < container.size) { + // Free Space + while (count-(backpack ? 4 : nCols) < container.size) { placeItem( null ); } // Gold if (container == Dungeon.hero.belongings.backpack) { - row = ROWS - 1; - col = COLS - 1; + row = nRows - 1; + col = nCols - 1; placeItem( new Gold( Dungeon.gold ) ); } } @@ -192,7 +204,7 @@ public class WndBag extends WndTabbed { add( new ItemButton( item ).setPos( x, y ) ); - if (++col >= COLS) { + if (++col >= nCols) { col = 0; row++; } @@ -358,6 +370,7 @@ public class WndBag extends WndTabbed { mode == Mode.QUICKSLOT && (item.defaultAction != null) || mode == Mode.WEAPON && (item instanceof MeleeWeapon || item instanceof Boomerang) || mode == Mode.ARMOR && (item instanceof Armor) || + mode == Mode.ENCHANTABLE && (item instanceof MeleeWeapon || item instanceof Boomerang || item instanceof Armor) || mode == Mode.WAND && (item instanceof Wand) || mode == Mode.SEED && (item instanceof Seed) || mode == Mode.FOOD && (item instanceof Food) || diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogus.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogus.java index 2190fa66d..f274e172b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogus.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogus.java @@ -19,6 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import java.util.ArrayList; +import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.watabou.noosa.BitmapText; import com.watabou.noosa.ui.Component; import com.shatteredpixel.shatteredpixeldungeon.items.Item; @@ -32,10 +33,13 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; public class WndCatalogus extends WndTabbed { - - private static final int WIDTH = 112; - private static final int HEIGHT = 160; - + + private static final int WIDTH_P = 112; + private static final int HEIGHT_P = 160; + + private static final int WIDTH_L = 128; + private static final int HEIGHT_L = 128; + private static final int ITEM_HEIGHT = 18; private static final int TAB_WIDTH = 50; @@ -54,8 +58,13 @@ public class WndCatalogus extends WndTabbed { public WndCatalogus() { super(); - resize( WIDTH, HEIGHT ); - + + if (ShatteredPixelDungeon.landscape()) { + resize( WIDTH_L, HEIGHT_L ); + } else { + resize( WIDTH_P, HEIGHT_P ); + } + txtTitle = PixelScene.createText( TXT_TITLE, 9 ); txtTitle.hardlight( Window.TITLE_COLOR ); txtTitle.measure(); @@ -73,8 +82,8 @@ public class WndCatalogus extends WndTabbed { } }; add( list ); - list.setRect( 0, txtTitle.height(), WIDTH, HEIGHT - txtTitle.height() ); - + list.setRect( 0, txtTitle.height(), width, height - txtTitle.height() ); + boolean showPotions = WndCatalogus.showPotions; Tab[] tabs = { new LabeledTab( TXT_POTIONS ) { @@ -104,8 +113,8 @@ public class WndCatalogus extends WndTabbed { txtTitle.text( Utils.format( TXT_TITLE, showPotions ? TXT_POTIONS : TXT_SCROLLS ) ); txtTitle.measure(); - txtTitle.x = PixelScene.align( PixelScene.uiCamera, (WIDTH - txtTitle.width()) / 2 ); - + txtTitle.x = PixelScene.align( PixelScene.uiCamera, (width - txtTitle.width()) / 2 ); + items.clear(); Component content = list.content(); @@ -115,7 +124,7 @@ public class WndCatalogus extends WndTabbed { float pos = 0; for (Class itemClass : showPotions ? Potion.getKnown() : Scroll.getKnown()) { ListItem item = new ListItem( itemClass ); - item.setRect( 0, pos, WIDTH, ITEM_HEIGHT ); + item.setRect( 0, pos, width, ITEM_HEIGHT ); content.add( item ); items.add( item ); @@ -124,14 +133,14 @@ public class WndCatalogus extends WndTabbed { for (Class itemClass : showPotions ? Potion.getUnknown() : Scroll.getUnknown()) { ListItem item = new ListItem( itemClass ); - item.setRect( 0, pos, WIDTH, ITEM_HEIGHT ); + item.setRect( 0, pos, width, ITEM_HEIGHT ); content.add( item ); items.add( item ); pos += item.height(); } - - content.setSize( WIDTH, pos ); + + content.setSize( width, pos ); } private static class ListItem extends Component { @@ -156,7 +165,7 @@ public class WndCatalogus extends WndTabbed { label.hardlight( 0xCCCCCC ); } } catch (Exception e) { - // + // Do nothing } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChallenges.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChallenges.java index 47ee7b2d0..129146933 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChallenges.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChallenges.java @@ -29,8 +29,9 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window; public class WndChallenges extends Window { private static final int WIDTH = 108; - private static final int BTN_HEIGHT = 20; - private static final int GAP = 2; + private static final int TTL_HEIGHT = 12; + private static final int BTN_HEIGHT = 18; + private static final int GAP = 1; private static final String TITLE = "Challenges"; @@ -47,11 +48,12 @@ public class WndChallenges extends Window { title.hardlight( TITLE_COLOR ); title.measure(); title.x = PixelScene.align( camera, (WIDTH - title.width()) / 2 ); + title.y = PixelScene.align( camera, (TTL_HEIGHT - title.height()) / 2 ); add( title ); boxes = new ArrayList(); - float pos = title.height() + GAP; + float pos = TTL_HEIGHT; for (int i=0; i < Challenges.NAMES.length; i++) { CheckBox cb = new CheckBox( Challenges.NAMES[i] ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java index dbd8fce0c..5fe2bd9e0 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java @@ -37,7 +37,7 @@ public class WndGame extends Window { private static final String TXT_RANKINGS = "Rankings"; private static final String TXT_START = "Start New Game"; private static final String TXT_MENU = "Main Menu"; - private static final String TXT_EXIT = "Exit Pixel Dungeon"; + private static final String TXT_EXIT = "Exit Game"; private static final String TXT_RETURN = "Return to Game"; private static final int WIDTH = 120; @@ -93,28 +93,29 @@ public class WndGame extends Window { } } ); } - - // Main menu - addButton( new RedButton( TXT_MENU ) { - @Override - protected void onClick() { - try { - Dungeon.saveAll(); - } catch (IOException e) { - // + + addButtons( + // Main menu + new RedButton(TXT_MENU) { + @Override + protected void onClick() { + try { + Dungeon.saveAll(); + } catch (IOException e) { + // Do nothing + } + Game.switchScene(TitleScene.class); + } + }, + // Quit + new RedButton( TXT_EXIT ) { + @Override + protected void onClick() { + Game.instance.finish(); + } } - Game.switchScene( TitleScene.class ); - } - } ); - - // Exit - addButton( new RedButton( TXT_EXIT ) { - @Override - protected void onClick() { - Game.instance.finish(); - } - } ); - + ); + // Cancel addButton( new RedButton( TXT_RETURN ) { @Override @@ -131,4 +132,12 @@ public class WndGame extends Window { btn.setRect( 0, pos > 0 ? pos += GAP : 0, WIDTH, BTN_HEIGHT ); pos += BTN_HEIGHT; } + + private void addButtons( RedButton btn1, RedButton btn2 ) { + add( btn1 ); + btn1.setRect( 0, pos > 0 ? pos += GAP : 0, (WIDTH - GAP) / 2, BTN_HEIGHT ); + add( btn2 ); + btn2.setRect( btn1.right() + GAP, btn1.top(), WIDTH - btn1.right() - GAP, BTN_HEIGHT ); + pos += BTN_HEIGHT; + } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java index a7084fccc..a1a0c5af3 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java @@ -38,10 +38,10 @@ public class WndImp extends Window { "This is my family heirloom ring: my granddad took it off a dead paladin's finger."; private static final String TXT_REWARD = "Take the ring"; - private static final int WIDTH = 120; - private static final int BTN_HEIGHT = 18; - private static final float GAP = 2; - + private static final int WIDTH = 120; + private static final int BTN_HEIGHT = 20; + private static final int GAP = 2; + public WndImp( final Imp imp, final DwarfToken tokens ) { super(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java index 3016ad9d0..572139090 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java @@ -74,7 +74,7 @@ public class WndInfoItem extends Window { String title; String info; - if (heap.type == Type.CHEST) { + if (heap.type == Type.CHEST || heap.type == Type.MIMIC) { title = TTL_CHEST; info = TXT_WONT_KNOW; } else if (heap.type == Type.TOMB) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java index edc07db91..91ccec53f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java @@ -18,12 +18,12 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.watabou.noosa.BitmapText; -import com.watabou.noosa.ColorBlock; import com.watabou.noosa.ui.Component; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; +import com.shatteredpixel.shatteredpixeldungeon.ui.HealthBar; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; public class WndInfoMob extends WndTitledMessage { @@ -44,25 +44,16 @@ public class WndInfoMob extends WndTitledMessage { } private static class MobTitle extends Component { - - private static final int COLOR_BG = 0xFFCC0000; - private static final int COLOR_LVL = 0xFF00EE00; - - private static final int BAR_HEIGHT = 2; + private static final int GAP = 2; private CharSprite image; private BitmapText name; - private ColorBlock hpBg; - private ColorBlock hpLvl; + private HealthBar health; private BuffIndicator buffs; - private float hp; - public MobTitle( Mob mob ) { - hp = (float)mob.HP / mob.HT; - name = PixelScene.createText( Utils.capitalize( mob.name ), 9 ); name.hardlight( TITLE_COLOR ); name.measure(); @@ -70,13 +61,11 @@ public class WndInfoMob extends WndTitledMessage { image = mob.sprite(); add( image ); - - hpBg = new ColorBlock( 1, 1, COLOR_BG ); - add( hpBg ); - - hpLvl = new ColorBlock( 1, 1, COLOR_LVL ); - add( hpLvl ); - + + health = new HealthBar(); + health.level((float) mob.HP / mob.HT); + add( health ); + buffs = new BuffIndicator( mob ); add( buffs ); } @@ -85,24 +74,20 @@ public class WndInfoMob extends WndTitledMessage { protected void layout() { image.x = 0; - image.y = Math.max( 0, name.height() + GAP + BAR_HEIGHT - image.height ); - + image.y = Math.max( 0, name.height() + GAP + health.height() - image.height ); + name.x = image.width + GAP; - name.y = image.height - BAR_HEIGHT - GAP - name.baseLine(); - + name.y = image.height - health.height() - GAP - name.baseLine(); + float w = width - image.width - GAP; - - hpBg.size( w, BAR_HEIGHT ); - hpLvl.size( w * hp, BAR_HEIGHT ); - - hpBg.x = hpLvl.x = image.width + GAP; - hpBg.y = hpLvl.y = image.height - BAR_HEIGHT; - + + health.setRect(image.width + GAP, image.height - health.height(), w, health.height()); + buffs.setPos( name.x + name.width() + GAP, name.y + name.baseLine() - BuffIndicator.SIZE ); - - height = hpBg.y + hpBg.height(); + + height = health.bottom(); } } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndItem.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndItem.java index 160b4b7e4..cd37dd59b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndItem.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndItem.java @@ -80,7 +80,11 @@ public class WndItem extends Window { } btn.setPos( x, y ); add( btn ); - + + if (action == item.defaultAction) { + btn.textColor( TITLE_COLOR ); + } + x += btn.width() + GAP; } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java index 68c33fa70..8372e12ef 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java @@ -19,6 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import java.util.Collections; +import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.watabou.noosa.BitmapText; import com.watabou.noosa.Image; import com.watabou.noosa.ui.Component; @@ -30,10 +31,11 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; public class WndJournal extends Window { - - private static final int WIDTH = 112; - private static final int HEIGHT = 160; - + + private static final int WIDTH = 112; + private static final int HEIGHT_P = 160; + private static final int HEIGHT_L = 144; + private static final int ITEM_HEIGHT = 18; private static final String TXT_TITLE = "Journal"; @@ -44,8 +46,8 @@ public class WndJournal extends Window { public WndJournal() { super(); - resize( WIDTH, HEIGHT ); - + resize( WIDTH, ShatteredPixelDungeon.landscape() ? HEIGHT_L : HEIGHT_P ); + txtTitle = PixelScene.createText( TXT_TITLE, 9 ); txtTitle.hardlight( Window.TITLE_COLOR ); txtTitle.measure(); @@ -69,8 +71,8 @@ public class WndJournal extends Window { list = new ScrollPane( content ); add( list ); - - list.setRect( 0, txtTitle.height(), WIDTH, HEIGHT - txtTitle.height() ); + + list.setRect( 0, txtTitle.height(), WIDTH, height - txtTitle.height() ); } private static class ListItem extends Component { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java index 97923f201..15a5b97dd 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java @@ -17,13 +17,15 @@ */ package com.shatteredpixel.shatteredpixeldungeon.windows; +import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.watabou.noosa.BitmapTextMultiline; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; public class WndMessage extends Window { - - private static final int WIDTH = 120; + + private static final int WIDTH_P = 120; + private static final int WIDTH_L = 144; private static final int MARGIN = 4; public WndMessage( String text ) { @@ -31,7 +33,7 @@ public class WndMessage extends Window { super(); BitmapTextMultiline info = PixelScene.createMultiline( text, 6 ); - info.maxWidth = WIDTH - MARGIN * 2; + info.maxWidth = (ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P) - MARGIN * 2; info.measure(); info.x = info.y = MARGIN; add( info ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndResurrect.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndResurrect.java index 537a23680..d02df2459 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndResurrect.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndResurrect.java @@ -36,7 +36,7 @@ public class WndResurrect extends Window { private static final String TXT_NO = "No, I give up"; private static final int WIDTH = 120; - private static final int BTN_HEIGHT = 18; + private static final int BTN_HEIGHT = 20; private static final float GAP = 2; public static WndResurrect instance; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndSadGhost.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndSadGhost.java index e3e91f89e..88e247b13 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndSadGhost.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndSadGhost.java @@ -51,7 +51,7 @@ public class WndSadGhost extends Window { private static final String TXT_ARMOR = "Ghost's armor"; private static final int WIDTH = 120; - private static final int BTN_HEIGHT = 18; + private static final int BTN_HEIGHT = 20; private static final float GAP = 2; public WndSadGhost( final Ghost ghost, final int type ) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndStory.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndStory.java index 29408c314..67b2d4f25 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndStory.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndStory.java @@ -109,7 +109,7 @@ public class WndStory extends Window { super.update(); if (delay > 0 && (delay -= Game.elapsed) <= 0) { - chrome.visible = tf.visible = true; + shadow.visible = chrome.visible = tf.visible = true; } } @@ -123,7 +123,7 @@ public class WndStory extends Window { if (text != null) { WndStory wnd = new WndStory( text ); if ((wnd.delay = 0.6f) > 0) { - wnd.chrome.visible = wnd.tf.visible = false; + wnd.shadow.visible = wnd.chrome.visible = wnd.tf.visible = false; } Game.scene().add( wnd ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTabbed.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTabbed.java index 38d50309c..9c8ec9050 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTabbed.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTabbed.java @@ -82,6 +82,11 @@ public class WndTabbed extends Window { camera.resize( (int)chrome.width, (int)(chrome.marginTop() + height + tabHeight()) ); camera.x = (int)(Game.width - camera.screenWidth()) / 2; camera.y = (int)(Game.height - camera.screenHeight()) / 2; + + shadow.boxRect( + camera.x / camera.zoom, + camera.y / camera.zoom, + chrome.width(), chrome.height ); // <- super.resize(...) for (Tab tab : tabs) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTitledMessage.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTitledMessage.java index fd62109b9..9e7cfbef0 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTitledMessage.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTitledMessage.java @@ -17,6 +17,7 @@ */ package com.shatteredpixel.shatteredpixeldungeon.windows; +import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.Image; import com.watabou.noosa.ui.Component; @@ -25,7 +26,8 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window; public class WndTitledMessage extends Window { - private static final int WIDTH = 120; + private static final int WIDTH_P = 120; + private static final int WIDTH_L = 144; private static final int GAP = 2; private BitmapTextMultiline normal; @@ -40,14 +42,16 @@ public class WndTitledMessage extends Window { public WndTitledMessage( Component titlebar, String message ) { super(); - - titlebar.setRect( 0, 0, WIDTH, 0 ); + + int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P; + + titlebar.setRect( 0, 0, width, 0 ); add( titlebar ); Highlighter hl = new Highlighter( message ); normal = PixelScene.createMultiline( hl.text, 6 ); - normal.maxWidth = WIDTH; + normal.maxWidth = width; normal.measure(); normal.x = titlebar.left(); normal.y = titlebar.bottom() + GAP; @@ -67,6 +71,6 @@ public class WndTitledMessage extends Window { highlighted.hardlight( TITLE_COLOR ); } - resize( WIDTH, (int)(normal.y + normal.height()) ); + resize( width, (int)(normal.y + normal.height()) ); } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java index ad29f7df6..e0386efd3 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java @@ -39,7 +39,7 @@ public class WndTradeItem extends Window { private static final float GAP = 2; private static final int WIDTH = 120; - private static final int BTN_HEIGHT = 18; + private static final int BTN_HEIGHT = 16; private static final String TXT_SALE = "FOR SALE: %s - %dg"; private static final String TXT_BUY = "Buy for %dg"; @@ -262,7 +262,6 @@ public class WndTradeItem extends Window { } private int price( Item item ) { - // This formula is not completely correct... int price = item.price() * 5 * (Dungeon.depth / 5 + 1); return price; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java index 660d0548c..34d7cea89 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java @@ -41,7 +41,7 @@ public class WndWandmaker extends Window { private static final String TXT_FARAWELL = "Good luck in your quest, %s!"; private static final int WIDTH = 120; - private static final int BTN_HEIGHT = 18; + private static final int BTN_HEIGHT = 20; private static final float GAP = 2; public WndWandmaker( final Wandmaker wandmaker, final Item item ) {