Skip to content

Commit

Permalink
minor code cleanup, see #258
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jul 1, 2024
1 parent b6d5434 commit e989593
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
18 changes: 10 additions & 8 deletions js/balance-point/view/BalancePointScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ export default class BalancePointScreenView extends SoccerScreenView<BalancePoin

super( model, options );

// There is only one scene in the balance point screen.
// By design, there is only one scene model used on this screen, and the code throughout this file assumes that this
// is the case.
const sceneModel = model.selectedSceneModelProperty.value;

const sceneView = new BalancePointSceneView(
model,
sceneModel,
Expand Down Expand Up @@ -113,13 +115,13 @@ export default class BalancePointScreenView extends SoccerScreenView<BalancePoin
} );

const kickButton = new KickButton( {
visibleProperty: model.selectedSceneModelProperty.value.hasKickableSoccerBallsProperty,
visibleProperty: sceneModel.hasKickableSoccerBallsProperty,
content: new Text( MeanShareAndBalanceStrings.kickStringProperty, {
font: KICK_BUTTON_FONT,
maxWidth: 60
} ),
multiKick: false,
listener: () => model.selectedSceneModelProperty.value.targetNumberOfBallsProperty.value++,
listener: () => sceneModel.targetNumberOfBallsProperty.value++,
leftTop: this.modelViewTransform.modelToViewXY( -2, 0 ).plusXY( 0, 8 ),
accessibleName: MeanShareAndBalanceStrings.kickStringProperty,
tandem: options.tandem.createTandem( 'kickButton' )
Expand All @@ -143,15 +145,15 @@ export default class BalancePointScreenView extends SoccerScreenView<BalancePoin
const notepadNodeBounds = notepadNode.bounds;
const calculationDependencies = [
model.selectedSceneModelProperty,
...model.selectedSceneModelProperty.value.soccerBalls.map( ball => ball.valueProperty ),
...model.selectedSceneModelProperty.value.soccerBalls.map( ball => ball.soccerBallPhaseProperty )
...sceneModel.soccerBalls.map( ball => ball.valueProperty ),
...sceneModel.soccerBalls.map( ball => ball.soccerBallPhaseProperty )
];

const meanInfoPanel = new MeanInfoPanel(
calculationDependencies,
model.selectedSceneModelProperty.value.meanValueProperty,
() => model.selectedSceneModelProperty.value.getStackedObjects().map( ball => ball.valueProperty.value! ),
() => model.selectedSceneModelProperty.value.getStackedObjects().length,
sceneModel.meanValueProperty,
() => sceneModel.getStackedObjects().map( ball => ball.valueProperty.value! ),
() => sceneModel.getStackedObjects().length,
model.meanInfoPanelVisibleProperty, notepadNodeBounds,
() => controls.infoButton!.focus(),
{
Expand Down
7 changes: 5 additions & 2 deletions js/level-out/view/LevelOutScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ export default class LevelOutScreenView extends MeanShareAndBalanceScreenView {
centerX: this.playAreaCenterX
} );

const meanPredictSliderModelViewTransform = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ),
new Vector2( this.playAreaCenterX, MeanShareAndBalanceConstants.NOTEPAD_CUPS_BOTTOM_Y ), MeanShareAndBalanceConstants.CUP_HEIGHT );
const meanPredictSliderModelViewTransform = ModelViewTransform2.createSinglePointScaleInvertedYMapping(
new Vector2( 0, 0 ),
new Vector2( this.playAreaCenterX, MeanShareAndBalanceConstants.NOTEPAD_CUPS_BOTTOM_Y ),
MeanShareAndBalanceConstants.CUP_HEIGHT
);
const meanPredictionLine = new MeanPredictionLine(
model.meanPredictionProperty,
model.dragRange,
Expand Down

0 comments on commit e989593

Please sign in to comment.