From 689d3b1df53e2551574a29677495e19d0207e322 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 19 Jan 2022 16:47:23 -0500 Subject: [PATCH] v1.2.0: separated the menu buttons from the status pane --- core/src/main/assets/interfaces/menu_pane.png | Bin 0 -> 265 bytes .../main/assets/interfaces/status_pane.png | Bin 663 -> 585 bytes .../shatteredpixeldungeon/Assets.java | 3 +- .../scenes/GameScene.java | 33 +- .../shatteredpixeldungeon/ui/KeyDisplay.java | 2 +- .../shatteredpixeldungeon/ui/MenuPane.java | 283 ++++++++++++++++++ .../shatteredpixeldungeon/ui/StatusPane.java | 220 +------------- .../ui/changelist/v0_3_X_Changes.java | 2 +- 8 files changed, 308 insertions(+), 235 deletions(-) create mode 100644 core/src/main/assets/interfaces/menu_pane.png create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/MenuPane.java diff --git a/core/src/main/assets/interfaces/menu_pane.png b/core/src/main/assets/interfaces/menu_pane.png new file mode 100644 index 0000000000000000000000000000000000000000..c0a1ec4083a707a8721b08916f5879f339a41fa3 GIT binary patch literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^4nQox!3HFkJ+IURQWrd3978G?lT!}xFEJ_-n$OkE zVaSvA;oDj3Hp$>;#*-FLZ=JxDtu5Tq##701qB7nO-vJw0E+(o9T$_AmKm(?e?eD% z4FCTB=Rfr0iMs?6;WlaD8 literal 0 HcmV?d00001 diff --git a/core/src/main/assets/interfaces/status_pane.png b/core/src/main/assets/interfaces/status_pane.png index 971d117d110feb71c61b3be26876a7c53ea5125a..522d804ac11339db45d5cafa4b3b84341031157c 100644 GIT binary patch delta 373 zcmbQvdXi;=3gfYfs`8u`RwmZA=8Kn2ofxpFUYxfykb!}Lvn0qb_&)?lF%-Df?`B|N z)bw<545?szd!f;d)luZw$NxW{y~*udCBE`|eX9e@)#xcv+i%_EUB_*GF{Zry!Jh*> zXTF2%+E_VT(oH5=m4Q>jK9`ek;S{$MQb>nZ)(YuW4Sz~X|24(N;WnBFT{`oR?#mJFV* KelF{r5}E+`^q{K% delta 452 zcmV;#0XzQ51eXPnBmv2hB_9lB1T@IEC`_1A?dt;`+cU!Ffr5M2&t=m80D67Y@5 z03>e^@a0hyHsZ$zpbr#ZBQyv=alV8`0lEWt(jfsC7D|;42(ZuZsRj5!0e-!FV##Cx zvfTqlk1Py$5`cX7fD={nD}Wzx1uP}7fnx+}PU$1Xqu7<5sYq95!5e%5ugrTnHx_8D u2lOa_9?%1NKo95vJ)j5lfF95TdcYr>Cs@c5*YV!~0000 + */ + +package com.shatteredpixel.shatteredpixeldungeon.ui; + +import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDAction; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.journal.Document; +import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndGame; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory; +import com.watabou.input.GameAction; +import com.watabou.noosa.BitmapText; +import com.watabou.noosa.Game; +import com.watabou.noosa.Image; +import com.watabou.noosa.audio.Sample; +import com.watabou.noosa.ui.Button; +import com.watabou.noosa.ui.Component; + +public class MenuPane extends Component { + + private Image bg; + + private BitmapText depth; + private JournalButton btnJournal; + private MenuButton btnMenu; + + private Toolbar.PickedUpItem pickedUp; + + private BitmapText version; + + private DangerIndicator danger; + + public static final int WIDTH = 50; + + @Override + protected void createChildren() { + super.createChildren(); + + bg = new Image(Assets.Interfaces.MENU); + add(bg); + + depth = new BitmapText( Integer.toString( Dungeon.depth ), PixelScene.pixelFont); + depth.hardlight( 0xCACFC2 ); + depth.measure(); + add( depth ); + + btnJournal = new JournalButton(); + add( btnJournal ); + + btnMenu = new MenuButton(); + add( btnMenu ); + + version = new BitmapText( "v" + Game.version, PixelScene.pixelFont); + version.alpha( 0.5f ); + add(version); + + danger = new DangerIndicator(); + add( danger ); + + add( pickedUp = new Toolbar.PickedUpItem()); + } + + @Override + protected void layout() { + super.layout(); + + bg.x = x; + bg.y = y; + + depth.x = x + 14.5f - depth.width() / 2f; + depth.y = y + 7f - depth.baseLine() / 2f; + PixelScene.align(depth); + + btnJournal.setPos( x + WIDTH - 42, 1 ); + + btnMenu.setPos( x + WIDTH - btnMenu.width(), 1 ); + + version.scale.set(PixelScene.align(0.5f)); + version.measure(); + version.x = x + WIDTH - version.width(); + version.y = y + bg.height() + (3 - version.baseLine()); + PixelScene.align(version); + + danger.setPos( x + WIDTH - danger.width(), y + bg.height + 3 ); + } + + public void pickup(Item item, int cell) { + pickedUp.reset( item, + cell, + btnJournal.centerX(), + btnJournal.centerY()); + } + + public void flashForPage( String page ){ + btnJournal.flashingPage = page; + } + + public void updateKeys(){ + btnJournal.updateKeyDisplay(); + } + + private static class JournalButton extends Button { + + private Image bg; + private Image journalIcon; + private KeyDisplay keyIcon; + + private String flashingPage = null; + + public JournalButton() { + super(); + + width = bg.width + 13; //includes the depth display to the left + height = bg.height + 4; + } + + @Override + public GameAction keyAction() { + return SPDAction.JOURNAL; + } + + @Override + protected void createChildren() { + super.createChildren(); + + bg = new Image( Assets.Interfaces.MENU, 2, 2, 13, 11 ); + add( bg ); + + journalIcon = new Image( Assets.Interfaces.MENU_BTN, 31, 0, 11, 7); + add( journalIcon ); + + keyIcon = new KeyDisplay(); + add(keyIcon); + updateKeyDisplay(); + } + + @Override + protected void layout() { + super.layout(); + + bg.x = x + 13; + bg.y = y + 2; + + journalIcon.x = bg.x + (bg.width() - journalIcon.width())/2f; + journalIcon.y = bg.y + (bg.height() - journalIcon.height())/2f; + PixelScene.align(journalIcon); + + keyIcon.x = bg.x + 1; + keyIcon.y = bg.y + 1; + keyIcon.width = bg.width - 2; + keyIcon.height = bg.height - 2; + PixelScene.align(keyIcon); + } + + private float time; + + @Override + public void update() { + super.update(); + + if (flashingPage != null){ + journalIcon.am = (float)Math.abs(Math.cos( StatusPane.FLASH_RATE * (time += Game.elapsed) )); + keyIcon.am = journalIcon.am; + if (time >= Math.PI/StatusPane.FLASH_RATE) { + time = 0; + } + } + } + + public void updateKeyDisplay() { + keyIcon.updateKeys(); + keyIcon.visible = keyIcon.keyCount() > 0; + journalIcon.visible = !keyIcon.visible; + if (keyIcon.keyCount() > 0) { + bg.brightness(.8f - (Math.min(6, keyIcon.keyCount()) / 20f)); + } else { + bg.resetColor(); + } + } + + @Override + protected void onPointerDown() { + bg.brightness( 1.5f ); + Sample.INSTANCE.play( Assets.Sounds.CLICK ); + } + + @Override + protected void onPointerUp() { + if (keyIcon.keyCount() > 0) { + bg.brightness(.8f - (Math.min(6, keyIcon.keyCount()) / 20f)); + } else { + bg.resetColor(); + } + } + + @Override + protected void onClick() { + time = 0; + keyIcon.am = journalIcon.am = 1; + if (flashingPage != null){ + if (Document.ADVENTURERS_GUIDE.pageNames().contains(flashingPage)){ + GameScene.show( new WndStory( WndJournal.GuideTab.iconForPage(flashingPage), + Document.ADVENTURERS_GUIDE.pageTitle(flashingPage), + Document.ADVENTURERS_GUIDE.pageBody(flashingPage) )); + Document.ADVENTURERS_GUIDE.readPage(flashingPage); + } else { + GameScene.show( new WndJournal() ); + } + flashingPage = null; + } else { + GameScene.show( new WndJournal() ); + } + } + + } + + private static class MenuButton extends Button { + + private Image image; + + public MenuButton() { + super(); + + width = image.width + 4; + height = image.height + 4; + } + + @Override + protected void createChildren() { + super.createChildren(); + + image = new Image( Assets.Interfaces.MENU_BTN, 17, 2, 12, 11 ); + add( image ); + } + + @Override + protected void layout() { + super.layout(); + + image.x = x + 2; + image.y = y + 2; + } + + @Override + protected void onPointerDown() { + image.brightness( 1.5f ); + Sample.INSTANCE.play( Assets.Sounds.CLICK ); + } + + @Override + protected void onPointerUp() { + image.resetColor(); + } + + @Override + protected void onClick() { + GameScene.show( new WndGame() ); + } + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java index ff3827a8c..4720fabdd 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java @@ -54,7 +54,7 @@ public class StatusPane extends Component { public static float talentBlink; private float warning; - private static final float FLASH_RATE = (float)(Math.PI*1.5f); //1.5 blinks per second + public static final float FLASH_RATE = (float)(Math.PI*1.5f); //1.5 blinks per second private int lastTier = 0; @@ -70,19 +70,10 @@ public class StatusPane extends Component { private int lastLvl = -1; private BitmapText level; - private BitmapText depth; - private DangerIndicator danger; private BuffIndicator buffs; private Compass compass; - private JournalButton btnJournal; - private MenuButton btnMenu; - - private Toolbar.PickedUpItem pickedUp; - - private BitmapText version; - @Override protected void createChildren() { @@ -102,12 +93,6 @@ public class StatusPane extends Component { } }.setRect( 0, 1, 30, 30 )); - btnJournal = new JournalButton(); - add( btnJournal ); - - btnMenu = new MenuButton(); - add( btnMenu ); - avatar = HeroSprite.avatar( Dungeon.hero.heroClass, lastTier ); add( avatar ); @@ -140,22 +125,8 @@ public class StatusPane extends Component { level.hardlight( 0xFFFFAA ); add( level ); - depth = new BitmapText( Integer.toString( Dungeon.depth ), PixelScene.pixelFont); - depth.hardlight( 0xCACFC2 ); - depth.measure(); - add( depth ); - - danger = new DangerIndicator(); - add( danger ); - buffs = new BuffIndicator( Dungeon.hero ); add( buffs ); - - add( pickedUp = new Toolbar.PickedUpItem()); - - version = new BitmapText( "v" + Game.version, PixelScene.pixelFont); - version.alpha( 0.5f ); - add(version); } @Override @@ -184,23 +155,7 @@ public class StatusPane extends Component { bossHP.setPos( 6 + (width - bossHP.width())/2, 20); - depth.x = width - 35.5f - depth.width() / 2f; - depth.y = 8f - depth.baseLine() / 2f; - PixelScene.align(depth); - - danger.setPos( width - danger.width(), 20 ); - buffs.setPos( 31, 9 ); - - btnJournal.setPos( width - 42, 1 ); - - btnMenu.setPos( width - btnMenu.width(), 1 ); - - version.scale.set(PixelScene.align(0.5f)); - version.measure(); - version.x = width - version.width(); - version.y = btnMenu.bottom() + (4 - version.baseLine()); - PixelScene.align(version); } private static final int[] warningColors = new int[]{0x660000, 0xCC0000, 0x660000}; @@ -266,177 +221,4 @@ public class StatusPane extends Component { emitter.burst( Speck.factory( Speck.STAR ), 12 ); } - public void pickup( Item item, int cell) { - pickedUp.reset( item, - cell, - btnJournal.journalIcon.x + btnJournal.journalIcon.width()/2f, - btnJournal.journalIcon.y + btnJournal.journalIcon.height()/2f); - } - - public void flashForPage( String page ){ - btnJournal.flashingPage = page; - } - - public void updateKeys(){ - btnJournal.updateKeyDisplay(); - } - - private static class JournalButton extends Button { - - private Image bg; - private Image journalIcon; - private KeyDisplay keyIcon; - - private String flashingPage = null; - - public JournalButton() { - super(); - - width = bg.width + 13; //includes the depth display to the left - height = bg.height + 4; - } - - @Override - public GameAction keyAction() { - return SPDAction.JOURNAL; - } - - @Override - protected void createChildren() { - super.createChildren(); - - bg = new Image( Assets.Interfaces.MENU, 2, 2, 13, 11 ); - add( bg ); - - journalIcon = new Image( Assets.Interfaces.MENU, 31, 0, 11, 7); - add( journalIcon ); - - keyIcon = new KeyDisplay(); - add(keyIcon); - updateKeyDisplay(); - } - - @Override - protected void layout() { - super.layout(); - - bg.x = x + 13; - bg.y = y + 2; - - journalIcon.x = bg.x + (bg.width() - journalIcon.width())/2f; - journalIcon.y = bg.y + (bg.height() - journalIcon.height())/2f; - PixelScene.align(journalIcon); - - keyIcon.x = bg.x + 1; - keyIcon.y = bg.y + 1; - keyIcon.width = bg.width - 2; - keyIcon.height = bg.height - 2; - PixelScene.align(keyIcon); - } - - private float time; - - @Override - public void update() { - super.update(); - - if (flashingPage != null){ - journalIcon.am = (float)Math.abs(Math.cos( FLASH_RATE * (time += Game.elapsed) )); - keyIcon.am = journalIcon.am; - if (time >= Math.PI/FLASH_RATE) { - time = 0; - } - } - } - - public void updateKeyDisplay() { - keyIcon.updateKeys(); - keyIcon.visible = keyIcon.keyCount() > 0; - journalIcon.visible = !keyIcon.visible; - if (keyIcon.keyCount() > 0) { - bg.brightness(.8f - (Math.min(6, keyIcon.keyCount()) / 20f)); - } else { - bg.resetColor(); - } - } - - @Override - protected void onPointerDown() { - bg.brightness( 1.5f ); - Sample.INSTANCE.play( Assets.Sounds.CLICK ); - } - - @Override - protected void onPointerUp() { - if (keyIcon.keyCount() > 0) { - bg.brightness(.8f - (Math.min(6, keyIcon.keyCount()) / 20f)); - } else { - bg.resetColor(); - } - } - - @Override - protected void onClick() { - time = 0; - keyIcon.am = journalIcon.am = 1; - if (flashingPage != null){ - if (Document.ADVENTURERS_GUIDE.pageNames().contains(flashingPage)){ - GameScene.show( new WndStory( WndJournal.GuideTab.iconForPage(flashingPage), - Document.ADVENTURERS_GUIDE.pageTitle(flashingPage), - Document.ADVENTURERS_GUIDE.pageBody(flashingPage) )); - Document.ADVENTURERS_GUIDE.readPage(flashingPage); - } else { - GameScene.show( new WndJournal() ); - } - flashingPage = null; - } else { - GameScene.show( new WndJournal() ); - } - } - - } - - private static class MenuButton extends Button { - - private Image image; - - public MenuButton() { - super(); - - width = image.width + 4; - height = image.height + 4; - } - - @Override - protected void createChildren() { - super.createChildren(); - - image = new Image( Assets.Interfaces.MENU, 17, 2, 12, 11 ); - add( image ); - } - - @Override - protected void layout() { - super.layout(); - - image.x = x + 2; - image.y = y + 2; - } - - @Override - protected void onPointerDown() { - image.brightness( 1.5f ); - Sample.INSTANCE.play( Assets.Sounds.CLICK ); - } - - @Override - protected void onPointerUp() { - image.resetColor(); - } - - @Override - protected void onClick() { - GameScene.show( new WndGame() ); - } - } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/changelist/v0_3_X_Changes.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/changelist/v0_3_X_Changes.java index 92a2f27b3..cfaec1714 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/changelist/v0_3_X_Changes.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/changelist/v0_3_X_Changes.java @@ -245,7 +245,7 @@ public class v0_3_X_Changes { "_-_ Traps now get trickier deeper in the dungeon\n" + "_-_ Trap room reworked to make use of new traps")); - changes.addButton( new ChangeButton(new Image(Assets.Interfaces.MENU, 15, 0, 16, 15), "Interface Improvements", + changes.addButton( new ChangeButton(new Image(Assets.Interfaces.MENU_BTN, 15, 0, 16, 15), "Interface Improvements", "_-_ Adjusted display scaling\n" + "_-_ Search and Examine merged into one button (double tap to search)\n" + "_-_ New max of 4 Quickslots!\n" +