From c5cb7506259f2bf6e96fe8a30ff642ba336427c0 Mon Sep 17 00:00:00 2001 From: alestiago Date: Sun, 1 May 2022 23:50:45 +0100 Subject: [PATCH] refactor: renamed RenderPriority to ZIndexes --- lib/game/components/bottom_group.dart | 2 +- lib/game/components/controlled_ball.dart | 6 +++--- .../flutter_forest/flutter_forest.dart | 2 +- lib/game/components/google_word/google_word.dart | 2 +- lib/game/components/multipliers/multipliers.dart | 2 +- lib/game/pinball_game.dart | 2 +- .../android_bumper/android_bumper.dart | 2 +- .../lib/src/components/android_spaceship.dart | 12 ++++++------ .../lib/src/components/ball.dart | 2 +- .../board_background_sprite_component.dart | 2 +- .../lib/src/components/boundaries.dart | 6 +++--- .../lib/src/components/chrome_dino.dart | 2 +- .../lib/src/components/components.dart | 2 +- .../lib/src/components/dino_walls.dart | 4 ++-- .../lib/src/components/launch_ramp.dart | 8 ++++---- .../lib/src/components/layer_sensor.dart | 4 ++-- .../lib/src/components/plunger.dart | 2 +- .../lib/src/components/rocket.dart | 2 +- .../lib/src/components/score_text.dart | 2 +- .../lib/src/components/slingshot.dart | 2 +- .../lib/src/components/spaceship_rail.dart | 6 +++--- .../lib/src/components/spaceship_ramp.dart | 16 ++++++++-------- .../lib/src/components/sparky_animatronic.dart | 2 +- .../components/sparky_bumper/sparky_bumper.dart | 2 +- .../lib/src/components/sparky_computer.dart | 6 +++--- .../{render_priority.dart => z_indexes.dart} | 13 ++----------- .../android_acres/android_spaceship_game.dart | 2 +- .../android_acres/spaceship_rail_game.dart | 2 +- .../android_acres/spaceship_ramp_game.dart | 2 +- .../stories/launch_ramp/launch_ramp_game.dart | 2 +- .../test/src/components/layer_sensor_test.dart | 4 ++-- 31 files changed, 58 insertions(+), 67 deletions(-) rename packages/pinball_components/lib/src/components/{render_priority.dart => z_indexes.dart} (83%) diff --git a/lib/game/components/bottom_group.dart b/lib/game/components/bottom_group.dart index 2a5c0ec3..bc5f473c 100644 --- a/lib/game/components/bottom_group.dart +++ b/lib/game/components/bottom_group.dart @@ -18,7 +18,7 @@ class BottomGroup extends Component with ZIndex { _BottomGroupSide(side: BoardSide.left), ], ) { - zIndex = RenderPriority.bottomGroup; + zIndex = ZIndexes.bottomGroup; } } diff --git a/lib/game/components/controlled_ball.dart b/lib/game/components/controlled_ball.dart index 9a9b3b5e..4103bb81 100644 --- a/lib/game/components/controlled_ball.dart +++ b/lib/game/components/controlled_ball.dart @@ -20,7 +20,7 @@ class ControlledBall extends Ball with Controls { }) : 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 { 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; } } diff --git a/lib/game/components/flutter_forest/flutter_forest.dart b/lib/game/components/flutter_forest/flutter_forest.dart index bca645ea..92c69048 100644 --- a/lib/game/components/flutter_forest/flutter_forest.dart +++ b/lib/game/components/flutter_forest/flutter_forest.dart @@ -40,7 +40,7 @@ class FlutterForest extends Component with ZIndex { FlutterForestBonusBehavior(), ], ) { - zIndex = RenderPriority.flutterForest; + zIndex = ZIndexes.flutterForest; } /// Creates a [FlutterForest] without any children. diff --git a/lib/game/components/google_word/google_word.dart b/lib/game/components/google_word/google_word.dart index b75117e7..79e1e6e5 100644 --- a/lib/game/components/google_word/google_word.dart +++ b/lib/game/components/google_word/google_word.dart @@ -41,7 +41,7 @@ class GoogleWord extends Component with ZIndex { GoogleWordBonusBehavior(), ], ) { - zIndex = RenderPriority.decal; + zIndex = ZIndexes.decal; } /// Creates a [GoogleWord] without any children. diff --git a/lib/game/components/multipliers/multipliers.dart b/lib/game/components/multipliers/multipliers.dart index a45a9271..8e9df1ff 100644 --- a/lib/game/components/multipliers/multipliers.dart +++ b/lib/game/components/multipliers/multipliers.dart @@ -36,7 +36,7 @@ class Multipliers extends Component with ZIndex { MultipliersBehavior(), ], ) { - zIndex = RenderPriority.decal; + zIndex = ZIndexes.decal; } /// Creates [Multipliers] without any children. diff --git a/lib/game/pinball_game.dart b/lib/game/pinball_game.dart index 613ede3f..872bcd7e 100644 --- a/lib/game/pinball_game.dart +++ b/lib/game/pinball_game.dart @@ -209,7 +209,7 @@ class _DebugGameBallsController extends _GameBallsController { // TODO(wolfenrain): investigate this CI failure. // coverage:ignore-start class _DebugInformation extends Component with HasGameRef { - _DebugInformation() : super(priority: RenderPriority.debugInfo); + _DebugInformation() : super(priority: ZIndexes.debugInfo); @override PositionType get positionType => PositionType.widget; diff --git a/packages/pinball_components/lib/src/components/android_bumper/android_bumper.dart b/packages/pinball_components/lib/src/components/android_bumper/android_bumper.dart index fa1762d8..b1fb642d 100644 --- a/packages/pinball_components/lib/src/components/android_bumper/android_bumper.dart +++ b/packages/pinball_components/lib/src/components/android_bumper/android_bumper.dart @@ -38,7 +38,7 @@ class AndroidBumper extends BodyComponent with InitialPosition, ZIndex { ...?children, ], ) { - zIndex = RenderPriority.androidBumper; + zIndex = ZIndexes.androidBumper; } /// {@macro android_bumper} diff --git a/packages/pinball_components/lib/src/components/android_spaceship.dart b/packages/pinball_components/lib/src/components/android_spaceship.dart index 292a955d..81a564e1 100644 --- a/packages/pinball_components/lib/src/components/android_spaceship.dart +++ b/packages/pinball_components/lib/src/components/android_spaceship.dart @@ -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; diff --git a/packages/pinball_components/lib/src/components/ball.dart b/packages/pinball_components/lib/src/components/ball.dart index e33841c6..81a57e7c 100644 --- a/packages/pinball_components/lib/src/components/ball.dart +++ b/packages/pinball_components/lib/src/components/ball.dart @@ -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; diff --git a/packages/pinball_components/lib/src/components/board_background_sprite_component.dart b/packages/pinball_components/lib/src/components/board_background_sprite_component.dart index 1fb0a96c..ba5b430e 100644 --- a/packages/pinball_components/lib/src/components/board_background_sprite_component.dart +++ b/packages/pinball_components/lib/src/components/board_background_sprite_component.dart @@ -11,7 +11,7 @@ class BoardBackgroundSpriteComponent extends SpriteComponent anchor: Anchor.center, position: Vector2(0, -1), ) { - zIndex = RenderPriority.boardBackground; + zIndex = ZIndexes.boardBackground; } @override diff --git a/packages/pinball_components/lib/src/components/boundaries.dart b/packages/pinball_components/lib/src/components/boundaries.dart index 15baecd3..cc66bed2 100644 --- a/packages/pinball_components/lib/src/components/boundaries.dart +++ b/packages/pinball_components/lib/src/components/boundaries.dart @@ -29,7 +29,7 @@ class _BottomBoundary extends BodyComponent with InitialPosition, ZIndex { renderBody: false, children: [_BottomBoundarySpriteComponent()], ) { - zIndex = RenderPriority.bottomBoundary; + zIndex = ZIndexes.bottomBoundary; } List _createFixtureDefs() { @@ -97,7 +97,7 @@ class _OuterBoundary extends BodyComponent with InitialPosition, ZIndex { renderBody: false, children: [_OuterBoundarySpriteComponent()], ) { - zIndex = RenderPriority.outerBoundary; + zIndex = ZIndexes.outerBoundary; } List _createFixtureDefs() { @@ -199,7 +199,7 @@ class _OuterBottomBoundarySpriteComponent extends SpriteComponent anchor: Anchor.center, position: Vector2(0, 71), ) { - zIndex = RenderPriority.outerBottomBoundary; + zIndex = ZIndexes.outerBottomBoundary; } @override diff --git a/packages/pinball_components/lib/src/components/chrome_dino.dart b/packages/pinball_components/lib/src/components/chrome_dino.dart index 3d79645a..8619874e 100644 --- a/packages/pinball_components/lib/src/components/chrome_dino.dart +++ b/packages/pinball_components/lib/src/components/chrome_dino.dart @@ -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. diff --git a/packages/pinball_components/lib/src/components/components.dart b/packages/pinball_components/lib/src/components/components.dart index 2781030e..fc037fbd 100644 --- a/packages/pinball_components/lib/src/components/components.dart +++ b/packages/pinball_components/lib/src/components/components.dart @@ -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'; diff --git a/packages/pinball_components/lib/src/components/dino_walls.dart b/packages/pinball_components/lib/src/components/dino_walls.dart index a73ae000..73f3d5a5 100644 --- a/packages/pinball_components/lib/src/components/dino_walls.dart +++ b/packages/pinball_components/lib/src/components/dino_walls.dart @@ -30,7 +30,7 @@ class _DinoTopWall extends BodyComponent with InitialPosition, ZIndex { children: [_DinoTopWallSpriteComponent()], renderBody: false, ) { - zIndex = RenderPriority.dinoTopWall; + zIndex = ZIndexes.dinoTopWall; } List _createFixtureDefs() { @@ -124,7 +124,7 @@ class _DinoBottomWall extends BodyComponent with InitialPosition, ZIndex { children: [_DinoBottomWallSpriteComponent()], renderBody: false, ) { - zIndex = RenderPriority.dinoBottomWall; + zIndex = ZIndexes.dinoBottomWall; } List _createFixtureDefs() { diff --git a/packages/pinball_components/lib/src/components/launch_ramp.dart b/packages/pinball_components/lib/src/components/launch_ramp.dart index acfc92e1..4713c3a2 100644 --- a/packages/pinball_components/lib/src/components/launch_ramp.dart +++ b/packages/pinball_components/lib/src/components/launch_ramp.dart @@ -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 _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; } diff --git a/packages/pinball_components/lib/src/components/layer_sensor.dart b/packages/pinball_components/lib/src/components/layer_sensor.dart index 62a3848f..6b5f3832 100644 --- a/packages/pinball_components/lib/src/components/layer_sensor.dart +++ b/packages/pinball_components/lib/src/components/layer_sensor.dart @@ -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; } diff --git a/packages/pinball_components/lib/src/components/plunger.dart b/packages/pinball_components/lib/src/components/plunger.dart index fa97d451..143e1049 100644 --- a/packages/pinball_components/lib/src/components/plunger.dart +++ b/packages/pinball_components/lib/src/components/plunger.dart @@ -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; } diff --git a/packages/pinball_components/lib/src/components/rocket.dart b/packages/pinball_components/lib/src/components/rocket.dart index 3d8f3dcb..07133fc5 100644 --- a/packages/pinball_components/lib/src/components/rocket.dart +++ b/packages/pinball_components/lib/src/components/rocket.dart @@ -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 diff --git a/packages/pinball_components/lib/src/components/score_text.dart b/packages/pinball_components/lib/src/components/score_text.dart index b5568e0b..6dcba4b1 100644 --- a/packages/pinball_components/lib/src/components/score_text.dart +++ b/packages/pinball_components/lib/src/components/score_text.dart @@ -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; diff --git a/packages/pinball_components/lib/src/components/slingshot.dart b/packages/pinball_components/lib/src/components/slingshot.dart index 07a3aa43..8acf0f9a 100644 --- a/packages/pinball_components/lib/src/components/slingshot.dart +++ b/packages/pinball_components/lib/src/components/slingshot.dart @@ -23,7 +23,7 @@ class Slingshots extends Component with ZIndex { )..initialPosition = Vector2(24.7, 6.2), ], ) { - zIndex = RenderPriority.slingshots; + zIndex = ZIndexes.slingshots; } } diff --git a/packages/pinball_components/lib/src/components/spaceship_rail.dart b/packages/pinball_components/lib/src/components/spaceship_rail.dart index 058c769c..7dbabc93 100644 --- a/packages/pinball_components/lib/src/components/spaceship_rail.dart +++ b/packages/pinball_components/lib/src/components/spaceship_rail.dart @@ -27,7 +27,7 @@ class _SpaceshipRail extends BodyComponent with Layered, ZIndex { renderBody: false, ) { layer = Layer.spaceshipExitRail; - zIndex = RenderPriority.spaceshipRail; + zIndex = ZIndexes.spaceshipRail; } List _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; } diff --git a/packages/pinball_components/lib/src/components/spaceship_ramp.dart b/packages/pinball_components/lib/src/components/spaceship_ramp.dart index bdab52a2..511d4273 100644 --- a/packages/pinball_components/lib/src/components/spaceship_ramp.dart +++ b/packages/pinball_components/lib/src/components/spaceship_ramp.dart @@ -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 _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, ); diff --git a/packages/pinball_components/lib/src/components/sparky_animatronic.dart b/packages/pinball_components/lib/src/components/sparky_animatronic.dart index f5ffde58..2ee2803c 100644 --- a/packages/pinball_components/lib/src/components/sparky_animatronic.dart +++ b/packages/pinball_components/lib/src/components/sparky_animatronic.dart @@ -13,7 +13,7 @@ class SparkyAnimatronic extends SpriteAnimationComponent anchor: Anchor.center, playing: false, ) { - zIndex = RenderPriority.sparkyAnimatronic; + zIndex = ZIndexes.sparkyAnimatronic; } @override diff --git a/packages/pinball_components/lib/src/components/sparky_bumper/sparky_bumper.dart b/packages/pinball_components/lib/src/components/sparky_bumper/sparky_bumper.dart index a07368da..205dab62 100644 --- a/packages/pinball_components/lib/src/components/sparky_bumper/sparky_bumper.dart +++ b/packages/pinball_components/lib/src/components/sparky_bumper/sparky_bumper.dart @@ -38,7 +38,7 @@ class SparkyBumper extends BodyComponent with InitialPosition, ZIndex { ...?children, ], ) { - zIndex = RenderPriority.sparkyBumper; + zIndex = ZIndexes.sparkyBumper; } /// {@macro sparky_bumper} diff --git a/packages/pinball_components/lib/src/components/sparky_computer.dart b/packages/pinball_components/lib/src/components/sparky_computer.dart index 774ac683..512c9d48 100644 --- a/packages/pinball_components/lib/src/components/sparky_computer.dart +++ b/packages/pinball_components/lib/src/components/sparky_computer.dart @@ -26,7 +26,7 @@ class _ComputerBase extends BodyComponent with InitialPosition, ZIndex { renderBody: false, children: [_ComputerBaseSpriteComponent()], ) { - zIndex = RenderPriority.computerBase; + zIndex = ZIndexes.computerBase; } List _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 diff --git a/packages/pinball_components/lib/src/components/render_priority.dart b/packages/pinball_components/lib/src/components/z_indexes.dart similarity index 83% rename from packages/pinball_components/lib/src/components/render_priority.dart rename to packages/pinball_components/lib/src/components/z_indexes.dart index 382118b3..21a59cca 100644 --- a/packages/pinball_components/lib/src/components/render_priority.dart +++ b/packages/pinball_components/lib/src/components/z_indexes.dart @@ -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 diff --git a/packages/pinball_components/sandbox/lib/stories/android_acres/android_spaceship_game.dart b/packages/pinball_components/sandbox/lib/stories/android_acres/android_spaceship_game.dart index bcb127ed..6799ef29 100644 --- a/packages/pinball_components/sandbox/lib/stories/android_acres/android_spaceship_game.dart +++ b/packages/pinball_components/sandbox/lib/stories/android_acres/android_spaceship_game.dart @@ -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, diff --git a/packages/pinball_components/sandbox/lib/stories/android_acres/spaceship_rail_game.dart b/packages/pinball_components/sandbox/lib/stories/android_acres/spaceship_rail_game.dart index 37a4283e..dee83e26 100644 --- a/packages/pinball_components/sandbox/lib/stories/android_acres/spaceship_rail_game.dart +++ b/packages/pinball_components/sandbox/lib/stories/android_acres/spaceship_rail_game.dart @@ -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, diff --git a/packages/pinball_components/sandbox/lib/stories/android_acres/spaceship_ramp_game.dart b/packages/pinball_components/sandbox/lib/stories/android_acres/spaceship_ramp_game.dart index 373ffc5a..cabe4d54 100644 --- a/packages/pinball_components/sandbox/lib/stories/android_acres/spaceship_ramp_game.dart +++ b/packages/pinball_components/sandbox/lib/stories/android_acres/spaceship_ramp_game.dart @@ -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, diff --git a/packages/pinball_components/sandbox/lib/stories/launch_ramp/launch_ramp_game.dart b/packages/pinball_components/sandbox/lib/stories/launch_ramp/launch_ramp_game.dart index a936371d..ea3bd4db 100644 --- a/packages/pinball_components/sandbox/lib/stories/launch_ramp/launch_ramp_game.dart +++ b/packages/pinball_components/sandbox/lib/stories/launch_ramp/launch_ramp_game.dart @@ -9,7 +9,7 @@ class LaunchRampGame extends BallGame { LaunchRampGame() : super( color: Colors.blue, - ballPriority: RenderPriority.ballOnLaunchRamp, + ballPriority: ZIndexes.ballOnLaunchRamp, ballLayer: Layer.launcher, ); diff --git a/packages/pinball_components/test/src/components/layer_sensor_test.dart b/packages/pinball_components/test/src/components/layer_sensor_test.dart index 44c68d53..20ba8472 100644 --- a/packages/pinball_components/test/src/components/layer_sensor_test.dart +++ b/packages/pinball_components/test/src/components/layer_sensor_test.dart @@ -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); }); }); }