refactor: renamed RenderPriority to ZIndexes

pull/282/head
alestiago 3 years ago
parent 7555bfe1a2
commit c5cb750625

@ -18,7 +18,7 @@ class BottomGroup extends Component with ZIndex {
_BottomGroupSide(side: BoardSide.left),
],
) {
zIndex = RenderPriority.bottomGroup;
zIndex = ZIndexes.bottomGroup;
}
}

@ -20,7 +20,7 @@ class ControlledBall extends Ball with Controls<BallController> {
}) : super(baseColor: characterTheme.ballColor) {
controller = BallController(this);
layer = Layer.launcher;
zIndex = RenderPriority.ballOnLaunchRamp;
zIndex = ZIndexes.ballOnLaunchRamp;
}
/// {@template bonus_ball}
@ -30,13 +30,13 @@ class ControlledBall extends Ball with Controls<BallController> {
required CharacterTheme characterTheme,
}) : super(baseColor: characterTheme.ballColor) {
controller = BallController(this);
zIndex = RenderPriority.ballOnBoard;
zIndex = ZIndexes.ballOnBoard;
}
/// [Ball] used in [DebugPinballGame].
ControlledBall.debug() : super(baseColor: const Color(0xFFFF0000)) {
controller = BallController(this);
zIndex = RenderPriority.ballOnBoard;
zIndex = ZIndexes.ballOnBoard;
}
}

@ -40,7 +40,7 @@ class FlutterForest extends Component with ZIndex {
FlutterForestBonusBehavior(),
],
) {
zIndex = RenderPriority.flutterForest;
zIndex = ZIndexes.flutterForest;
}
/// Creates a [FlutterForest] without any children.

@ -41,7 +41,7 @@ class GoogleWord extends Component with ZIndex {
GoogleWordBonusBehavior(),
],
) {
zIndex = RenderPriority.decal;
zIndex = ZIndexes.decal;
}
/// Creates a [GoogleWord] without any children.

@ -36,7 +36,7 @@ class Multipliers extends Component with ZIndex {
MultipliersBehavior(),
],
) {
zIndex = RenderPriority.decal;
zIndex = ZIndexes.decal;
}
/// Creates [Multipliers] without any children.

@ -209,7 +209,7 @@ class _DebugGameBallsController extends _GameBallsController {
// TODO(wolfenrain): investigate this CI failure.
// coverage:ignore-start
class _DebugInformation extends Component with HasGameRef<DebugPinballGame> {
_DebugInformation() : super(priority: RenderPriority.debugInfo);
_DebugInformation() : super(priority: ZIndexes.debugInfo);
@override
PositionType get positionType => PositionType.widget;

@ -38,7 +38,7 @@ class AndroidBumper extends BodyComponent with InitialPosition, ZIndex {
...?children,
],
) {
zIndex = RenderPriority.androidBumper;
zIndex = ZIndexes.androidBumper;
}
/// {@macro android_bumper}

@ -19,11 +19,11 @@ class AndroidSpaceship extends Component {
_AndroidHead()..initialPosition = position + Vector2(0.5, 0.25),
_SpaceshipHole(
outsideLayer: Layer.spaceshipExitRail,
outsidePriority: RenderPriority.ballOnSpaceshipRail,
outsidePriority: ZIndexes.ballOnSpaceshipRail,
)..initialPosition = position - Vector2(5.3, -5.4),
_SpaceshipHole(
outsideLayer: Layer.board,
outsidePriority: RenderPriority.ballOnBoard,
outsidePriority: ZIndexes.ballOnBoard,
)..initialPosition = position - Vector2(-7.5, -1.1),
],
);
@ -70,7 +70,7 @@ class _SpaceshipSaucerSpriteAnimationComponent extends SpriteAnimationComponent
: super(
anchor: Anchor.center,
) {
zIndex = RenderPriority.spaceshipSaucer;
zIndex = ZIndexes.spaceshipSaucer;
}
@override
@ -108,7 +108,7 @@ class _LightBeamSpriteComponent extends SpriteComponent
: super(
anchor: Anchor.center,
) {
zIndex = RenderPriority.spaceshipLightBeam;
zIndex = ZIndexes.spaceshipLightBeam;
}
@override
@ -131,7 +131,7 @@ class _AndroidHead extends BodyComponent with InitialPosition, Layered, ZIndex {
renderBody: false,
) {
layer = Layer.spaceship;
zIndex = RenderPriority.androidHead;
zIndex = ZIndexes.androidHead;
}
@override
@ -194,7 +194,7 @@ class _SpaceshipHole extends LayerSensor {
insideLayer: Layer.spaceship,
outsideLayer: outsideLayer,
orientation: LayerEntranceOrientation.down,
insideZIndex: RenderPriority.ballOnSpaceship,
insideZIndex: ZIndexes.ballOnSpaceship,
outsideZIndex: outsidePriority,
) {
layer = Layer.spaceship;

@ -140,7 +140,7 @@ class _TurboChargeSpriteAnimationComponent extends SpriteAnimationComponent
anchor: const Anchor(0.53, 0.72),
removeOnFinish: true,
) {
zIndex = RenderPriority.turboChargeFlame;
zIndex = ZIndexes.turboChargeFlame;
}
late final Vector2 _textureSize;

@ -11,7 +11,7 @@ class BoardBackgroundSpriteComponent extends SpriteComponent
anchor: Anchor.center,
position: Vector2(0, -1),
) {
zIndex = RenderPriority.boardBackground;
zIndex = ZIndexes.boardBackground;
}
@override

@ -29,7 +29,7 @@ class _BottomBoundary extends BodyComponent with InitialPosition, ZIndex {
renderBody: false,
children: [_BottomBoundarySpriteComponent()],
) {
zIndex = RenderPriority.bottomBoundary;
zIndex = ZIndexes.bottomBoundary;
}
List<FixtureDef> _createFixtureDefs() {
@ -97,7 +97,7 @@ class _OuterBoundary extends BodyComponent with InitialPosition, ZIndex {
renderBody: false,
children: [_OuterBoundarySpriteComponent()],
) {
zIndex = RenderPriority.outerBoundary;
zIndex = ZIndexes.outerBoundary;
}
List<FixtureDef> _createFixtureDefs() {
@ -199,7 +199,7 @@ class _OuterBottomBoundarySpriteComponent extends SpriteComponent
anchor: Anchor.center,
position: Vector2(0, 71),
) {
zIndex = RenderPriority.outerBottomBoundary;
zIndex = ZIndexes.outerBottomBoundary;
}
@override

@ -17,7 +17,7 @@ class ChromeDino extends BodyComponent with InitialPosition, ZIndex {
: super(
renderBody: false,
) {
zIndex = RenderPriority.dino;
zIndex = ZIndexes.dino;
}
/// The size of the dinosaur mouth.

@ -23,7 +23,6 @@ export 'layer.dart';
export 'layer_sensor.dart';
export 'multiplier/multiplier.dart';
export 'plunger.dart';
export 'render_priority.dart';
export 'rocket.dart';
export 'score_text.dart';
export 'shapes/shapes.dart';
@ -34,3 +33,4 @@ export 'spaceship_ramp.dart';
export 'sparky_animatronic.dart';
export 'sparky_bumper/sparky_bumper.dart';
export 'sparky_computer.dart';
export 'z_indexes.dart';

@ -30,7 +30,7 @@ class _DinoTopWall extends BodyComponent with InitialPosition, ZIndex {
children: [_DinoTopWallSpriteComponent()],
renderBody: false,
) {
zIndex = RenderPriority.dinoTopWall;
zIndex = ZIndexes.dinoTopWall;
}
List<FixtureDef> _createFixtureDefs() {
@ -124,7 +124,7 @@ class _DinoBottomWall extends BodyComponent with InitialPosition, ZIndex {
children: [_DinoBottomWallSpriteComponent()],
renderBody: false,
) {
zIndex = RenderPriority.dinoBottomWall;
zIndex = ZIndexes.dinoBottomWall;
}
List<FixtureDef> _createFixtureDefs() {

@ -32,7 +32,7 @@ class _LaunchRampBase extends BodyComponent with Layered, ZIndex {
_LaunchRampBaseSpriteComponent(),
],
) {
zIndex = RenderPriority.launchRamp;
zIndex = ZIndexes.launchRamp;
layer = Layer.launcher;
}
@ -141,7 +141,7 @@ class _LaunchRampForegroundRailing extends BodyComponent with ZIndex {
children: [_LaunchRampForegroundRailingSpriteComponent()],
renderBody: false,
) {
zIndex = RenderPriority.launchRampForegroundRailing;
zIndex = ZIndexes.launchRampForegroundRailing;
}
List<FixtureDef> _createFixtureDefs() {
@ -230,8 +230,8 @@ class _LaunchRampExit extends LayerSensor {
insideLayer: Layer.launcher,
outsideLayer: Layer.board,
orientation: LayerEntranceOrientation.down,
insideZIndex: RenderPriority.ballOnLaunchRamp,
outsideZIndex: RenderPriority.ballOnBoard,
insideZIndex: ZIndexes.ballOnLaunchRamp,
outsideZIndex: ZIndexes.ballOnBoard,
) {
layer = Layer.launcher;
}

@ -18,7 +18,7 @@ enum LayerEntranceOrientation {
/// [BodyComponent] located at the entrance and exit of a [Layer].
///
/// By default the base [layer] is set to [Layer.board] and the
/// [_outsideZIndex] is set to [RenderPriority.ballOnBoard].
/// [_outsideZIndex] is set to [ZIndexes.ballOnBoard].
/// {@endtemplate}
abstract class LayerSensor extends BodyComponent
with InitialPosition, Layered, ContactCallbacks {
@ -32,7 +32,7 @@ abstract class LayerSensor extends BodyComponent
}) : _insideLayer = insideLayer,
_outsideLayer = outsideLayer ?? Layer.board,
_insideZIndex = insideZIndex,
_outsideZIndex = outsideZIndex ?? RenderPriority.ballOnBoard,
_outsideZIndex = outsideZIndex ?? ZIndexes.ballOnBoard,
super(renderBody: false) {
layer = Layer.opening;
}

@ -14,7 +14,7 @@ class Plunger extends BodyComponent with InitialPosition, Layered, ZIndex {
Plunger({
required this.compressionDistance,
}) : super(renderBody: false) {
zIndex = RenderPriority.plunger;
zIndex = ZIndexes.plunger;
layer = Layer.launcher;
}

@ -9,7 +9,7 @@ import 'package:pinball_flame/pinball_flame.dart';
class RocketSpriteComponent extends SpriteComponent with HasGameRef, ZIndex {
/// {@macro rocket_sprite_component}
RocketSpriteComponent() : super(anchor: Anchor.center) {
zIndex = RenderPriority.rocket;
zIndex = ZIndexes.rocket;
}
@override

@ -20,7 +20,7 @@ class ScoreText extends TextComponent with ZIndex {
position: position,
anchor: Anchor.center,
) {
zIndex = RenderPriority.scoreText;
zIndex = ZIndexes.scoreText;
}
late final Effect _effect;

@ -23,7 +23,7 @@ class Slingshots extends Component with ZIndex {
)..initialPosition = Vector2(24.7, 6.2),
],
) {
zIndex = RenderPriority.slingshots;
zIndex = ZIndexes.slingshots;
}
}

@ -27,7 +27,7 @@ class _SpaceshipRail extends BodyComponent with Layered, ZIndex {
renderBody: false,
) {
layer = Layer.spaceshipExitRail;
zIndex = RenderPriority.spaceshipRail;
zIndex = ZIndexes.spaceshipRail;
}
List<FixtureDef> _createFixtureDefs() {
@ -131,7 +131,7 @@ class _SpaceshipRailExitSpriteComponent extends SpriteComponent
anchor: Anchor.center,
position: Vector2(-28, 19.4),
) {
zIndex = RenderPriority.spaceshipRailExit;
zIndex = ZIndexes.spaceshipRailExit;
}
@override
@ -153,7 +153,7 @@ class _SpaceshipRailExit extends LayerSensor {
: super(
orientation: LayerEntranceOrientation.down,
insideLayer: Layer.spaceshipExitRail,
insideZIndex: RenderPriority.ballOnSpaceshipRail,
insideZIndex: ZIndexes.ballOnSpaceshipRail,
) {
layer = Layer.spaceshipExitRail;
}

@ -16,14 +16,14 @@ class SpaceshipRamp extends Component {
: super(
children: [
_SpaceshipRampOpening(
outsidePriority: RenderPriority.ballOnBoard,
outsidePriority: ZIndexes.ballOnBoard,
rotation: math.pi,
)
..initialPosition = Vector2(1.7, -19.8)
..layer = Layer.opening,
_SpaceshipRampOpening(
outsideLayer: Layer.spaceship,
outsidePriority: RenderPriority.ballOnSpaceship,
outsidePriority: ZIndexes.ballOnSpaceship,
rotation: math.pi,
)
..initialPosition = Vector2(-13.7, -18.6)
@ -101,7 +101,7 @@ class _SpaceshipRampBackground extends BodyComponent
],
) {
layer = Layer.spaceshipEntranceRamp;
zIndex = RenderPriority.spaceshipRamp;
zIndex = ZIndexes.spaceshipRamp;
}
/// Width between walls of the ramp.
@ -152,7 +152,7 @@ class _SpaceshipRampBackgroundRailingSpriteComponent extends SpriteComponent
anchor: Anchor.center,
position: Vector2(-11.7, -54.3),
) {
zIndex = RenderPriority.spaceshipRampBackgroundRailing;
zIndex = ZIndexes.spaceshipRampBackgroundRailing;
}
@override
@ -203,7 +203,7 @@ class _SpaceshipRampArrowSpriteComponent
anchor: Anchor.center,
position: Vector2(-3.9, -56.5),
) {
zIndex = RenderPriority.spaceshipRampArrow;
zIndex = ZIndexes.spaceshipRampArrow;
}
/// Changes arrow image to the next [Sprite].
@ -228,7 +228,7 @@ class _SpaceshipRampArrowSpriteComponent
class _SpaceshipRampBoardOpeningSpriteComponent extends SpriteComponent
with HasGameRef, ZIndex {
_SpaceshipRampBoardOpeningSpriteComponent() : super(anchor: Anchor.center) {
zIndex = RenderPriority.spaceshipRampBoardOpening;
zIndex = ZIndexes.spaceshipRampBoardOpening;
}
@override
@ -252,7 +252,7 @@ class _SpaceshipRampForegroundRailing extends BodyComponent
children: [_SpaceshipRampForegroundRailingSpriteComponent()],
) {
layer = Layer.spaceshipEntranceRamp;
zIndex = RenderPriority.spaceshipRampForegroundRailing;
zIndex = ZIndexes.spaceshipRampForegroundRailing;
}
List<FixtureDef> _createFixtureDefs() {
@ -354,7 +354,7 @@ class _SpaceshipRampOpening extends LayerSensor {
insideLayer: Layer.spaceshipEntranceRamp,
outsideLayer: outsideLayer,
orientation: LayerEntranceOrientation.down,
insideZIndex: RenderPriority.ballOnSpaceshipRamp,
insideZIndex: ZIndexes.ballOnSpaceshipRamp,
outsideZIndex: outsidePriority,
);

@ -13,7 +13,7 @@ class SparkyAnimatronic extends SpriteAnimationComponent
anchor: Anchor.center,
playing: false,
) {
zIndex = RenderPriority.sparkyAnimatronic;
zIndex = ZIndexes.sparkyAnimatronic;
}
@override

@ -38,7 +38,7 @@ class SparkyBumper extends BodyComponent with InitialPosition, ZIndex {
...?children,
],
) {
zIndex = RenderPriority.sparkyBumper;
zIndex = ZIndexes.sparkyBumper;
}
/// {@macro sparky_bumper}

@ -26,7 +26,7 @@ class _ComputerBase extends BodyComponent with InitialPosition, ZIndex {
renderBody: false,
children: [_ComputerBaseSpriteComponent()],
) {
zIndex = RenderPriority.computerBase;
zIndex = ZIndexes.computerBase;
}
List<FixtureDef> _createFixtureDefs() {
@ -91,7 +91,7 @@ class _ComputerTopSpriteComponent extends SpriteComponent
anchor: Anchor.center,
position: Vector2(-12.52, -49.37),
) {
zIndex = RenderPriority.computerTop;
zIndex = ZIndexes.computerTop;
}
@override
@ -115,7 +115,7 @@ class _ComputerGlowSpriteComponent extends SpriteComponent
anchor: Anchor.center,
position: Vector2(7.4, 10),
) {
zIndex = RenderPriority.computerGlow;
zIndex = ZIndexes.computerGlow;
}
@override

@ -1,31 +1,22 @@
// ignore_for_file: public_member_api_docs
import 'package:pinball_components/pinball_components.dart';
/// {@template render_priority}
/// Priorities for the component rendering order in the pinball game.
/// {@endtemplate}
/// Z-Indexes for the component rendering order in the pinball game.
// TODO(allisonryan0002): find alternative to section comments.
abstract class RenderPriority {
abstract class ZIndexes {
static const _base = 0;
static const _above = 1;
static const _below = -1;
// Ball
/// Render priority for the [Ball] while it's on the board.
static const ballOnBoard = _base;
/// Render priority for the [Ball] while it's on the [SpaceshipRamp].
static const ballOnSpaceshipRamp = _above + spaceshipRampBackgroundRailing;
/// Render priority for the [Ball] while it's on the [AndroidSpaceship].
static const ballOnSpaceship = _above + spaceshipSaucer;
/// Render priority for the [Ball] while it's on the [SpaceshipRail].
static const ballOnSpaceshipRail = _above + spaceshipRail;
/// Render priority for the [Ball] while it's on the [LaunchRamp].
static const ballOnLaunchRamp = _above + launchRamp;
// Background

@ -7,7 +7,7 @@ import 'package:sandbox/stories/ball/basic_ball_game.dart';
class AndroidSpaceshipGame extends BallGame {
AndroidSpaceshipGame()
: super(
ballPriority: RenderPriority.ballOnSpaceship,
ballPriority: ZIndexes.ballOnSpaceship,
ballLayer: Layer.spaceship,
imagesFileNames: [
Assets.images.android.spaceship.saucer.keyName,

@ -9,7 +9,7 @@ class SpaceshipRailGame extends BallGame {
SpaceshipRailGame()
: super(
color: Colors.blue,
ballPriority: RenderPriority.ballOnSpaceshipRail,
ballPriority: ZIndexes.ballOnSpaceshipRail,
ballLayer: Layer.spaceshipExitRail,
imagesFileNames: [
Assets.images.android.rail.main.keyName,

@ -10,7 +10,7 @@ class SpaceshipRampGame extends BallGame with KeyboardEvents {
SpaceshipRampGame()
: super(
color: Colors.blue,
ballPriority: RenderPriority.ballOnSpaceshipRamp,
ballPriority: ZIndexes.ballOnSpaceshipRamp,
ballLayer: Layer.spaceshipEntranceRamp,
imagesFileNames: [
Assets.images.android.ramp.railingBackground.keyName,

@ -9,7 +9,7 @@ class LaunchRampGame extends BallGame {
LaunchRampGame()
: super(
color: Colors.blue,
ballPriority: RenderPriority.ballOnLaunchRamp,
ballPriority: ZIndexes.ballOnLaunchRamp,
ballLayer: Layer.launcher,
);

@ -145,7 +145,7 @@ void main() {
sensor.beginContact(ball, MockContact());
verify(() => ball.layer = Layer.board);
verify(() => ball.zIndex = RenderPriority.ballOnBoard).called(1);
verify(() => ball.zIndex = ZIndexes.ballOnBoard).called(1);
});
flameTester.test(
@ -168,7 +168,7 @@ void main() {
sensor.beginContact(ball, MockContact());
verify(() => ball.layer = Layer.board);
verify(() => ball.zIndex = RenderPriority.ballOnBoard).called(1);
verify(() => ball.zIndex = ZIndexes.ballOnBoard).called(1);
});
});
}

Loading…
Cancel
Save