v1.2.0: separated the menu buttons from the status pane

This commit is contained in:
Evan Debenham 2022-01-19 16:47:23 -05:00
parent f64d56252f
commit 689d3b1df5
8 changed files with 308 additions and 235 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 663 B

After

Width:  |  Height:  |  Size: 585 B

View File

@ -73,7 +73,8 @@ public class Assets {
public static final String CHROME = "interfaces/chrome.png";
public static final String ICONS = "interfaces/icons.png";
public static final String STATUS = "interfaces/status_pane.png";
public static final String MENU = "interfaces/menu_button.png";
public static final String MENU = "interfaces/menu_pane.png";
public static final String MENU_BTN = "interfaces/menu_button.png";
public static final String HP_BAR = "interfaces/hp_bar.png";
public static final String SHLD_BAR = "interfaces/shield_bar.png";
public static final String XP_BAR = "interfaces/exp_bar.png";

View File

@ -84,6 +84,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.CharHealthIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.shatteredpixel.shatteredpixeldungeon.ui.LootIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.MenuPane;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.ResumeIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane;
@ -140,7 +141,8 @@ public class GameScene extends PixelScene {
private FogOfWar fog;
private HeroSprite hero;
private StatusPane pane;
private MenuPane menu;
private StatusPane status;
private GameLog log;
@ -348,10 +350,15 @@ public class GameScene extends PixelScene {
add( cellSelector = new CellSelector( tiles ) );
pane = new StatusPane();
pane.camera = uiCamera;
pane.setSize( uiCamera.width, 0 );
add( pane );
menu = new MenuPane();
menu.camera = uiCamera;
menu.setPos( uiCamera.width-50, 1);
add(menu);
status = new StatusPane();
status.camera = uiCamera;
status.setSize( uiCamera.width, 0 );
add(status);
toolbar = new Toolbar();
toolbar.camera = uiCamera;
@ -384,7 +391,7 @@ public class GameScene extends PixelScene {
busy = new BusyIndicator();
busy.camera = uiCamera;
busy.x = 1;
busy.y = pane.bottom() + 1;
busy.y = status.bottom() + 1;
add( busy );
counter = new CircleArc(18, 4.25f);
@ -964,20 +971,20 @@ public class GameScene extends PixelScene {
}
public static void pickUpJournal( Item item, int pos ) {
if (scene != null) scene.pane.pickup( item, pos );
if (scene != null) scene.menu.pickup( item, pos );
}
//TODO currently only works with guidebooks
public static void flashForDocument( String page ){
if (scene != null) scene.pane.flashForPage( page );
}
public static void showlevelUpStars(){
if (scene != null) scene.pane.showStarParticles();
if (scene != null) scene.menu.flashForPage( page );
}
public static void updateKeyDisplay(){
if (scene != null) scene.pane.updateKeys();
if (scene != null) scene.menu.updateKeys();
}
public static void showlevelUpStars(){
if (scene != null) scene.status.showStarParticles();
}
public static void resetMap() {

View File

@ -47,7 +47,7 @@ public class KeyDisplay extends Visual {
private FloatBuffer quads;
private Vertexbuffer buffer;
private SmartTexture tx = TextureCache.get(Assets.Interfaces.MENU);
private SmartTexture tx = TextureCache.get(Assets.Interfaces.MENU_BTN);
private boolean dirty = true;
private int[] keys;

View File

@ -0,0 +1,283 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2022 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
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() );
}
}
}

View File

@ -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() );
}
}
}

View File

@ -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" +