Skip to content

Commit

Permalink
Allow for the AllFilledNode to show again after it resets.
Browse files Browse the repository at this point in the history
  • Loading branch information
Denz1994 committed Jan 16, 2020
1 parent 6ede9ff commit 8bb7d22
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions js/common/model/KitCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ define( require => {
this.collectionBoxes.forEach( box => { box.reset(); } );
this.kits.forEach( kit => { kit.reset(); } );
this.hasBlinkedOnce = false;
this.allCollectionBoxesFilledProperty.reset();
}
}

Expand Down
4 changes: 2 additions & 2 deletions js/common/view/BAMScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ define( require => {
kitPanel.reset();
this.updateRefillButton();

// If the nextCollectionButton is present on screen dispose it.
// If the nextCollectionButton is present on screen hide it.
if ( this.children.includes( this.nextCollectionButton ) ) {
this.removeChild( this.nextCollectionButton );
this.nextCollectionButton.visible = false
}
},
right: this.layoutBounds.right - BAMConstants.VIEW_PADDING * 1.3,
Expand Down
14 changes: 11 additions & 3 deletions js/common/view/MoleculeCollectingScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ define( require => {
super( kitCollectionList );
this.kitCollectionList = kitCollectionList;

// @private
this.hasShownOnce = false;

// @private {TextPushButton} Create a next collection button
this.nextCollectionButton = new TextPushButton( nextCollectionString, {
centerX: this.layoutBounds.centerX - 100,
Expand Down Expand Up @@ -110,6 +113,11 @@ define( require => {
// notify attachment
collectionAttachmentCallbacks.forEach( callback => { callback(); } );

// Affects whether the AllFilledNode will show after resetting.
this.resetAllButton.addListener( () => {
this.hasShownOnce = false;
} );

// Adjust the center of the AllFilledNode
this.visibleBoundsProperty.link( () => {
this.allFilledNode.center = BAMConstants.STAGE_SIZE.center;
Expand All @@ -124,14 +132,14 @@ define( require => {
*/
addCollection( collection ) {
const kitCollectionNode = BAMScreenView.prototype.addCollection.call( this, collection, true );
let hasShownOnce = false;
this.hasShownOnce = false;

// show dialog the 1st time all collection boxes are filled
collection.allCollectionBoxesFilledProperty.link( filled => {
if ( filled ) {
if ( !hasShownOnce ) {
if ( !this.hasShownOnce ) {
this.allFilledNode.show();
hasShownOnce = true;
this.hasShownOnce = true;
}
}
} );
Expand Down

0 comments on commit 8bb7d22

Please sign in to comment.