From 460b8f7c5c0c70e979be46a5a400a1935b1e71fa Mon Sep 17 00:00:00 2001 From: Jesse Date: Wed, 18 Mar 2020 12:36:17 -0400 Subject: [PATCH] Prototype for verbose interaction mode of the self voicing feature, see #196 --- js/view/GravityForceLabAlertManager.js | 40 ++++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/js/view/GravityForceLabAlertManager.js b/js/view/GravityForceLabAlertManager.js index a99d106e..a2408b59 100644 --- a/js/view/GravityForceLabAlertManager.js +++ b/js/view/GravityForceLabAlertManager.js @@ -52,16 +52,9 @@ class GravityForceLabAlertManager extends ISLCAlertManager { this.scientificNotationUtterance = new ActivationUtterance(); const constantRadiusUtterance = new ActivationUtterance(); - const constantRadiusAlert = StringUtils.fillIn( constantRadiusThinkDensityPatternString, { - - // use forceDescriber just for the sim specific object labels, could be any ISLCDescriber - mass1: forceDescriber.object1Label, - mass2: forceDescriber.object2Label - } ); model.constantRadiusProperty.lazyLink( constantRadius => { - constantRadiusUtterance.alert = constantRadius ? constantRadiusAlert : - massDescriber.getM1RelativeSize(); + constantRadiusUtterance.alert = this.getConstantRadiusAlert( constantRadius ); phet.joist.sim.utteranceQueue.addToBack( constantRadiusUtterance ); } ); @@ -121,7 +114,18 @@ class GravityForceLabAlertManager extends ISLCAlertManager { * @private */ alertMassValueChanged( objectEnum, forceBiggerOverride ) { + phet.joist.sim.utteranceQueue.addToBack( this.getMassValueChangedAlert( objectEnum, forceBiggerOverride ) ); + } + /** + * Get the alert content for when the mass value changes. + * @public + * + * @param {ISLCObjectEnum} objectEnum + * @param {boolean} [forceBiggerOverride] + * @returns {Utterance} + */ + getMassValueChangedAlert( objectEnum, forceBiggerOverride ) { let massClause = this.massDescriber.getMassOrDensityChangeClause( objectEnum ); // if changing the mass of an object caused one of the masses to move position @@ -136,7 +140,25 @@ class GravityForceLabAlertManager extends ISLCAlertManager { massClause: massClause, forceClause: this.forceDescriber.getVectorChangeClause( forceBiggerOverride, false ) } ); - phet.joist.sim.utteranceQueue.addToBack( this.massChangedUtterance ); + return this.massChangedUtterance; + } + + /** + * Get an alert for when masses radius becomes constant or dynamic. + * @public + * + * @param {boolean} constantRadius + * @return {string} + */ + getConstantRadiusAlert( constantRadius ) { + const constantRadiusAlert = StringUtils.fillIn( constantRadiusThinkDensityPatternString, { + + // use forceDescriber just for the sim specific object labels, could be any ISLCDescriber + mass1: this.forceDescriber.object1Label, + mass2: this.forceDescriber.object2Label + } ); + + return constantRadius ? constantRadiusAlert : this.massDescriber.getM1RelativeSize(); } /**