v1.2.0: refactored various code around status pane

This commit is contained in:
Evan Debenham 2022-01-19 20:42:04 -05:00
parent 632ae6cca0
commit 3f0a2ad1a3
3 changed files with 36 additions and 31 deletions

View File

@ -79,7 +79,7 @@ import com.shatteredpixel.shatteredpixeldungeon.tiles.WallBlockingTilemap;
import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.Banner; import com.shatteredpixel.shatteredpixeldungeon.ui.Banner;
import com.shatteredpixel.shatteredpixeldungeon.ui.BusyIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BossHealthBar;
import com.shatteredpixel.shatteredpixeldungeon.ui.CharHealthIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.CharHealthIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog; import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
@ -144,10 +144,9 @@ public class GameScene extends PixelScene {
private MenuPane menu; private MenuPane menu;
private StatusPane status; private StatusPane status;
private GameLog log; private BossHealthBar boss;
private BusyIndicator busy; private GameLog log;
private CircleArc counter;
private static CellSelector cellSelector; private static CellSelector cellSelector;
@ -357,9 +356,14 @@ public class GameScene extends PixelScene {
status = new StatusPane(); status = new StatusPane();
status.camera = uiCamera; status.camera = uiCamera;
status.setSize( uiCamera.width, 0 ); status.setRect(0, 0, uiCamera.width, 0 );
add(status); add(status);
boss = new BossHealthBar();
boss.camera = uiCamera;
boss.setPos( 6 + (uiCamera.width - boss.width())/2, 20);
add(boss);
toolbar = new Toolbar(); toolbar = new Toolbar();
toolbar.camera = uiCamera; toolbar.camera = uiCamera;
toolbar.setRect( 0,uiCamera.height - toolbar.height(), uiCamera.width, toolbar.height() ); toolbar.setRect( 0,uiCamera.height - toolbar.height(), uiCamera.width, toolbar.height() );
@ -388,17 +392,6 @@ public class GameScene extends PixelScene {
layoutTags(); layoutTags();
busy = new BusyIndicator();
busy.camera = uiCamera;
busy.x = 1;
busy.y = status.bottom() + 1;
add( busy );
counter = new CircleArc(18, 4.25f);
counter.color( 0x808080, true );
counter.camera = uiCamera;
counter.show(this, busy.center(), 0f);
switch (InterlevelScene.mode) { switch (InterlevelScene.mode) {
case RESURRECT: case RESURRECT:
Sample.INSTANCE.play(Assets.Sounds.TELEPORT); Sample.INSTANCE.play(Assets.Sounds.TELEPORT);
@ -693,8 +686,6 @@ public class GameScene extends PixelScene {
} }
} }
counter.setSweep((1f - Actor.now()%1f)%1f);
if (Dungeon.hero.ready && Dungeon.hero.paralysed == 0) { if (Dungeon.hero.ready && Dungeon.hero.paralysed == 0) {
log.newLine(); log.newLine();
} }

View File

@ -47,7 +47,7 @@ public class BossHealthBar extends Component {
private static BossHealthBar instance; private static BossHealthBar instance;
private static boolean bleeding; private static boolean bleeding;
BossHealthBar() { public BossHealthBar() {
super(); super();
visible = active = (boss != null); visible = active = (boss != null);
instance = this; instance = this;

View File

@ -25,6 +25,8 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.SPDAction; import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.effects.CircleArc;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.journal.Document; import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
@ -65,8 +67,6 @@ public class StatusPane extends Component {
private Image exp; private Image exp;
private BossHealthBar bossHP;
private int lastLvl = -1; private int lastLvl = -1;
private BitmapText level; private BitmapText level;
@ -74,6 +74,9 @@ public class StatusPane extends Component {
private BuffIndicator buffs; private BuffIndicator buffs;
private Compass compass; private Compass compass;
private BusyIndicator busy;
private CircleArc counter;
@Override @Override
protected void createChildren() { protected void createChildren() {
@ -118,15 +121,19 @@ public class StatusPane extends Component {
exp = new Image( Assets.Interfaces.XP_BAR ); exp = new Image( Assets.Interfaces.XP_BAR );
add( exp ); add( exp );
bossHP = new BossHealthBar();
add( bossHP );
level = new BitmapText( PixelScene.pixelFont); level = new BitmapText( PixelScene.pixelFont);
level.hardlight( 0xFFFFAA ); level.hardlight( 0xFFFFAA );
add( level ); add( level );
buffs = new BuffIndicator( Dungeon.hero, false ); buffs = new BuffIndicator( Dungeon.hero, false );
add( buffs ); add( buffs );
busy = new BusyIndicator();
add( busy );
counter = new CircleArc(18, 4.25f);
counter.color( 0x808080, true );
counter.show(this, busy.center(), 0f);
} }
@Override @Override
@ -134,6 +141,8 @@ public class StatusPane extends Component {
height = 32; height = 32;
bg.x = x;
bg.y = y;
bg.size( width, bg.height ); bg.size( width, bg.height );
avatar.x = bg.x + 15 - avatar.width / 2f; avatar.x = bg.x + 15 - avatar.width / 2f;
@ -144,8 +153,8 @@ public class StatusPane extends Component {
compass.y = avatar.y + avatar.height / 2f - compass.origin.y; compass.y = avatar.y + avatar.height / 2f - compass.origin.y;
PixelScene.align(compass); PixelScene.align(compass);
hp.x = shieldedHP.x = rawShielding.x = 30; hp.x = shieldedHP.x = rawShielding.x = x + 30;
hp.y = shieldedHP.y = rawShielding.y = 3; hp.y = shieldedHP.y = rawShielding.y = y + 3;
hpText.scale.set(PixelScene.align(0.5f)); hpText.scale.set(PixelScene.align(0.5f));
hpText.x = hp.x + 1; hpText.x = hp.x + 1;
@ -153,9 +162,12 @@ public class StatusPane extends Component {
hpText.y -= 0.001f; //prefer to be slightly higher hpText.y -= 0.001f; //prefer to be slightly higher
PixelScene.align(hpText); PixelScene.align(hpText);
bossHP.setPos( 6 + (width - bossHP.width())/2, 20); buffs.setPos( x + 31, y + 9 );
buffs.setPos( 31, 9 ); busy.x = x + 1;
busy.y = y + 33;
counter.point(busy.center());
} }
private static final int[] warningColors = new int[]{0x660000, 0xCC0000, 0x660000}; private static final int[] warningColors = new int[]{0x660000, 0xCC0000, 0x660000};
@ -202,8 +214,8 @@ public class StatusPane extends Component {
lastLvl = Dungeon.hero.lvl; lastLvl = Dungeon.hero.lvl;
level.text( Integer.toString( lastLvl ) ); level.text( Integer.toString( lastLvl ) );
level.measure(); level.measure();
level.x = 27.5f - level.width() / 2f; level.x = x + 27.5f - level.width() / 2f;
level.y = 28.0f - level.baseLine() / 2f; level.y = y + 28.0f - level.baseLine() / 2f;
PixelScene.align(level); PixelScene.align(level);
} }
@ -212,6 +224,8 @@ public class StatusPane extends Component {
lastTier = tier; lastTier = tier;
avatar.copy( HeroSprite.avatar( Dungeon.hero.heroClass, tier ) ); avatar.copy( HeroSprite.avatar( Dungeon.hero.heroClass, tier ) );
} }
counter.setSweep((1f - Actor.now()%1f)%1f);
} }
public void showStarParticles(){ public void showStarParticles(){