-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving description from ph-scale => ph-scale-basics, removing package…
….json flags to rely on query parameters, see phetsims/ph-scale#249, phetsims/joist#941
- Loading branch information
1 parent
7e58e06
commit c189e84
Showing
5 changed files
with
935 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// Copyright 2024, University of Colorado Boulder | ||
|
||
// @author Jonathan Olson <[email protected]> | ||
|
||
/* eslint-disable */ | ||
|
||
export default () => { | ||
let context; | ||
let strings; | ||
|
||
const totalVolumeToEnum = totalVolume => { | ||
if ( totalVolume === 0 ) { | ||
return 'empty'; | ||
} | ||
else if ( totalVolume < 1.2 ) { | ||
return 'partiallyFilled'; | ||
} | ||
else { | ||
return 'full'; | ||
} | ||
}; | ||
|
||
return phet.joist.DescriptionContext.registerLogic( { | ||
launch( descriptionContext, descriptionStrings ) { | ||
context = descriptionContext; | ||
strings = descriptionStrings; | ||
|
||
const macroScreen = context.get( 'phScaleBasics.macroScreen' ); | ||
if ( macroScreen ) { | ||
const macroScreenView = context.get( 'phScaleBasics.macroScreen.view' ); | ||
|
||
// solution | ||
//const soluteProperty = context.get( 'phScaleBasics.macroScreen.model.solution.soluteProperty' ); | ||
const soluteProperty = context.get( 'phScaleBasics.macroScreen.model.dropper.soluteProperty' ); // TODO: why was this not defined? | ||
const solutionPHProperty = context.get( 'phScaleBasics.macroScreen.model.solution.pHProperty' ); | ||
const solutionTotalVolumeProperty = context.get( 'phScaleBasics.macroScreen.model.solution.totalVolumeProperty' ); | ||
const soluteVolumeProperty = context.get( 'phScaleBasics.macroScreen.model.solution.soluteVolumeProperty' ); | ||
const waterVolumeProperty = context.get( 'phScaleBasics.macroScreen.model.solution.waterVolumeProperty' ); | ||
|
||
// pH Meter | ||
const pHMeterPHProperty = context.get( 'phScaleBasics.macroScreen.model.pHMeter.pHProperty' ); | ||
const pHMeterPositionProperty = context.get( 'phScaleBasics.macroScreen.model.pHMeter.probe.positionProperty' ); | ||
|
||
// Dropper | ||
const dropperEnabledProperty = context.get( 'phScaleBasics.macroScreen.model.dropper.enabledProperty' ); | ||
const isDispensingProperty = context.get( 'phScaleBasics.macroScreen.model.dropper.isDispensingProperty' ); | ||
const isAutofillingProperty = context.get( 'phScaleBasics.macroScreen.model.isAutofillingProperty' ); | ||
|
||
// Water faucet | ||
const waterFaucetEnabledProperty = context.get( 'phScaleBasics.macroScreen.model.waterFaucet.enabledProperty' ); | ||
const waterFaucetFlowRateProperty = context.get( 'phScaleBasics.macroScreen.model.waterFaucet.flowRateProperty' ); | ||
|
||
// Drain faucet | ||
const drainFaucetEnabledProperty = context.get( 'phScaleBasics.macroScreen.model.drainFaucet.enabledProperty' ); | ||
const drainFaucetFlowRateProperty = context.get( 'phScaleBasics.macroScreen.model.drainFaucet.flowRateProperty' ); | ||
|
||
|
||
const simStateDescriptionNode = new phet.scenery.Node( { | ||
tagName: 'p' | ||
} ); | ||
|
||
context.nodeSet( macroScreenView, 'screenSummaryContent', new phet.scenery.Node( { | ||
children: [ | ||
new phet.scenery.Node( { | ||
tagName: 'p', | ||
innerContent: strings.screenSummary() | ||
} ), | ||
simStateDescriptionNode | ||
] | ||
} ) ); | ||
|
||
context.multilink( [ | ||
soluteProperty, | ||
solutionTotalVolumeProperty | ||
], ( | ||
solute, | ||
solutionTotalVolume | ||
) => { | ||
simStateDescriptionNode.innerContent = strings.screenSummarySimStateDescription( | ||
solute.tandemName, | ||
totalVolumeToEnum( solutionTotalVolume ) | ||
); | ||
} ); | ||
|
||
const solutes = [ | ||
phet.phScale.Solute.BATTERY_ACID, | ||
phet.phScale.Solute.BLOOD, | ||
phet.phScale.Solute.CHICKEN_SOUP, | ||
phet.phScale.Solute.COFFEE, | ||
phet.phScale.Solute.DRAIN_CLEANER, | ||
phet.phScale.Solute.HAND_SOAP, | ||
phet.phScale.Solute.MILK, | ||
phet.phScale.Solute.ORANGE_JUICE, | ||
phet.phScale.Solute.SODA, | ||
phet.phScale.Solute.SPIT, | ||
phet.phScale.Solute.VOMIT, | ||
phet.phScale.Solute.WATER | ||
]; | ||
|
||
const soluteComboBox = context.get( 'phScaleBasics.macroScreen.view.soluteComboBox' ); | ||
context.nodeSet( soluteComboBox, 'accessibleName', strings.soluteComboBoxAccessibleName() ); | ||
for ( const solute of solutes ) { | ||
context.propertySet( soluteComboBox.a11yNamePropertyMap.get( solute ), strings.soluteName( solute.tandemName ) ); | ||
} | ||
|
||
// pdomOrder | ||
// context.nodeSet( macroScreenView.pdomPlayAreaNode, 'pdomOrder', [ | ||
// context.get( 'phScaleBasics.macroScreen.view.dropperNode.button' ), | ||
// context.get( 'phScaleBasics.macroScreen.view.soluteComboBox' ), | ||
// context.get( 'phScaleBasics.macroScreen.view.waterFaucetNode.faucetNode' ), | ||
// context.get( 'phScaleBasics.macroScreen.view.drainFaucetNode' ), | ||
// context.get( 'phScaleBasics.macroScreen.view.pHMeterNode.probeNode' ), | ||
// context.get( 'phScaleBasics.macroScreen.view.resetAllButton' ) | ||
// ] ); | ||
|
||
const alerter = new phet.sceneryPhet.Alerter( { | ||
alertToVoicing: false, | ||
descriptionAlertNode: macroScreenView | ||
} ); | ||
|
||
context.lazyLink( isDispensingProperty, isDispensing => { | ||
alerter.alert( strings.dropperDispensingAlert( isDispensing ) ); | ||
} ); | ||
} | ||
}, | ||
added( tandemID, obj ) { | ||
// Will be called when an object is dynamically added after sim start-up | ||
}, | ||
removed( tandemID, obj ) { | ||
// Will be called when an object is dynamically removed after sim start-up | ||
} | ||
} ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2024, University of Colorado Boulder | ||
|
||
// @author Jonathan Olson <[email protected]> | ||
|
||
// eslint-disable | ||
|
||
export default () => { | ||
const soluteMap = { | ||
batteryAcid: 'battery acid', | ||
blood: 'blood', | ||
chickenSoup: 'chicken soup', | ||
coffee: 'coffee', | ||
drainCleaner: 'drain cleaner', | ||
handSoap: 'hand soap', | ||
milk: 'milk', | ||
orangeJuice: 'orange juice', | ||
soda: 'soda', | ||
spit: 'spit', | ||
vomit: 'vomit', | ||
water: 'water' | ||
}; | ||
|
||
const totalVolumeMap = { | ||
empty: 'empty', | ||
partiallyFilled: 'partially filled', | ||
full: 'full' | ||
}; | ||
|
||
return phet.joist.DescriptionContext.registerStrings( { | ||
locale: 'en', | ||
screenSummary() { | ||
return 'Place description of the screen here, or break into multiple paragraphs'; | ||
}, | ||
screenSummarySimStateDescription( | ||
solute, | ||
totalVolume | ||
) { | ||
return `The solute is ${soluteMap[ solute ]}, and the total volume is ${totalVolumeMap[ totalVolume ]}.`; | ||
}, | ||
soluteComboBoxAccessibleName() { | ||
return 'Solute'; | ||
}, | ||
soluteName( solute ) { | ||
return soluteMap[ solute ]; | ||
}, | ||
dropperDispensingAlert( | ||
isDispensing | ||
) { | ||
return isDispensing ? 'Dispensing' : 'Not dispensing'; | ||
} | ||
} ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2024, University of Colorado Boulder | ||
|
||
// @author Jonathan Olson <[email protected]> | ||
|
||
// eslint-disable | ||
|
||
export default () => { | ||
const soluteMap = { | ||
batteryAcid: 'ácido de batería', | ||
blood: 'sangre', | ||
chickenSoup: 'sopa de pollo', | ||
coffee: 'café', | ||
drainCleaner: 'limpiador de desagües', | ||
handSoap: 'jabón de manos', | ||
milk: 'leche', | ||
orangeJuice: 'jugo de naranja', | ||
soda: 'gaseosa', | ||
spit: 'saliva', | ||
vomit: 'vómito', | ||
water: 'agua' | ||
}; | ||
|
||
const totalVolumeMap = { | ||
empty: 'vacía', | ||
partiallyFilled: 'parcialmente lleno', | ||
full: 'lleno' | ||
}; | ||
|
||
return phet.joist.DescriptionContext.registerStrings( { | ||
locale: 'es', | ||
screenSummary() { | ||
return 'Coloque la descripción de la pantalla aquí o divídala en varios párrafos'; | ||
}, | ||
screenSummarySimStateDescription( | ||
solute, | ||
totalVolume | ||
) { | ||
return `El soluto es ${soluteMap[ solute ]}, y el volumen total es ${totalVolumeMap[ totalVolume ]}.`; | ||
}, | ||
soluteComboBoxAccessibleName() { | ||
return 'Soluto'; | ||
}, | ||
soluteName( solute ) { | ||
return soluteMap[ solute ]; | ||
}, | ||
dropperDispensingAlert( | ||
isDispensing | ||
) { | ||
return isDispensing ? 'dispensando' : 'no dispensando'; | ||
} | ||
} ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.