Skip to content

Commit

Permalink
added support for setting enhanced sound mode from the PhET menu, see p…
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jul 19, 2018
1 parent 9a47a3d commit 9b40f9f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
3 changes: 3 additions & 0 deletions joist-strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"menuItem.getUpdate": {
"value": "Check for Updates\u2026"
},
"menuItem.enhancedSound": {
"value": "Enhanced Sound"
},
"title.settings": {
"value": "Settings"
},
Expand Down
16 changes: 16 additions & 0 deletions js/PhetMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ define( function( require ) {

// strings
var menuItemAboutString = require( 'string!JOIST/menuItem.about' );
var menuItemEnhancedSoundString = require( 'string!JOIST/menuItem.enhancedSound' );
var menuItemFullscreenString = require( 'string!JOIST/menuItem.fullscreen' );
var menuItemGetUpdateString = require( 'string!JOIST/menuItem.getUpdate' );
var menuItemMailInputEventsLogString = require( 'string!JOIST/menuItem.mailInputEventsLog' );
Expand Down Expand Up @@ -270,6 +271,8 @@ define( function( require ) {
phetioInstanceDocumentation: 'This menu item captures a screenshot from the simulation and saves it to the file system.',
tagName: 'button'
},

// "Full Screen" menu item
{
text: menuItemFullscreenString,
present: FullScreen.isFullScreenEnabled() && !isPhetApp && !fuzzes,
Expand All @@ -282,6 +285,19 @@ define( function( require ) {
tagName: 'button'
},

// "Enhanced Sound" menu item
{
text: menuItemEnhancedSoundString,
present: phet.chipper.supportsEnhancedSound,
checkedProperty: sim.enhancedSoundEnabledProperty,
callback: function() {
sim.soundManager.enhancedSoundEnabledProperty.set( !sim.soundManager.enhancedSoundEnabledProperty.get() );
},
tandem: tandem.createTandem( 'enhancedSoundMenuItem' ),
phetioInstanceDocumentation: 'This menu item toggles between basic and enhanced sound modes.',
tagName: 'button'
},

// About dialog button
{
text: menuItemAboutString,
Expand Down
13 changes: 11 additions & 2 deletions js/Sim.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ define( function( require ) {

// Used in conjunction with the 'sonification' flag, indicates whether sounds that are beyond the 'basic' level
// are present in the sound design.
hasEnhancedSounds: false,
supportsEnhancedSound: false,

// the default renderer for the rootNode, see #221, #184 and https://github.com/phetsims/molarity/issues/24
rootRenderer: platform.edge ? 'canvas' : 'svg'
Expand Down Expand Up @@ -277,13 +277,16 @@ define( function( require ) {

// Set/update global flag values for sonification. Sonification can be turned on by sim flags or a query param.
phet.chipper.sonification = phet.chipper.tambo || options.tambo;
phet.chipper.hasEnhancedSounds = phet.chipper.hasEnhancedSounds || options.hasEnhancedSounds;
phet.chipper.supportsEnhancedSound = phet.chipper.supportsEnhancedSound || options.supportsEnhancedSound;

// Initialize the sound library if enabled.
if ( phet.chipper.tambo ) {
assert( options.soundManager, 'must supply sound manager if sonificaiton is enabled' );
options.soundManager.initialize( this.browserTabVisibleProperty );
this.soundEnabledProperty = options.soundManager.enabledProperty;

// @public (read-only) {soundManager}
this.soundManager = options.soundManager;
}
else if ( options.soundManager ) {

Expand All @@ -293,6 +296,12 @@ define( function( require ) {
options.soundManager.initialize( new BooleanProperty( false ) );
}

// @public {BooleanProperty} - a property that controls whether enhanced sound is enabled, must exist even if
// the sound library isn't present because it is needed in the menu (PhetMenu)
this.enhancedSoundEnabledProperty = options.soundManager ?
options.soundManager.enhancedSoundEnabledProperty :
new BooleanProperty( false );

assert && assert( !window.phet.joist.sim, 'Only supports one sim at a time' );
window.phet.joist.sim = this;

Expand Down

0 comments on commit 9b40f9f

Please sign in to comment.