-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add preferences model and structure for portrayals. Remove unused cod…
…e in re-centering trash can image that was previously offset. See #304.
- Loading branch information
Showing
14 changed files
with
293 additions
and
45 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
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
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,20 @@ | ||
// Copyright 2024, University of Colorado Boulder | ||
|
||
/** | ||
* Preferences model as a singleton, so it can be accessed by the HumanTypeEnum. | ||
* | ||
* @author Luisa Vargas | ||
*/ | ||
|
||
import PreferencesModel from '../../../joist/js/preferences/PreferencesModel.js'; | ||
import forcesAndMotionBasics from '../forcesAndMotionBasics.js'; | ||
import MassPlayerImages from './view/MassPlayerImages.js'; | ||
|
||
const PreferencesModelSingleton = new PreferencesModel( { | ||
localizationOptions: { | ||
portrayals: MassPlayerImages.MASS_PLAYER_PORTRAYALS | ||
} | ||
} ); | ||
|
||
forcesAndMotionBasics.register( 'PreferencesModelSingleton', PreferencesModelSingleton ); | ||
export default PreferencesModelSingleton; |
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,67 @@ | ||
// Copyright 2024, University of Colorado Boulder | ||
|
||
/** | ||
* HumanTypeEnum identifies the human object type and sets the holding, standing, or sitting image for the human. | ||
* | ||
* @author Luisa Vargas | ||
*/ | ||
|
||
import MappedProperty from '../../../../axon/js/MappedProperty.js'; | ||
import EnumerationValue from '../../../../phet-core/js/EnumerationValue.js'; | ||
import Enumeration from '../../../../phet-core/js/Enumeration.js'; | ||
import forcesAndMotionBasics from '../../forcesAndMotionBasics.js'; | ||
import PreferencesModelSingleton from '../PreferencesModelSingleton.js'; | ||
|
||
class HumanTypeEnum extends EnumerationValue { | ||
|
||
static GIRL = new HumanTypeEnum( 'girl' ); | ||
static MAN = new HumanTypeEnum( 'man' ); | ||
|
||
static enumeration = new Enumeration( HumanTypeEnum ); | ||
|
||
/** | ||
* @param {string} humanType | ||
*/ | ||
constructor( humanType ) { | ||
super(); | ||
|
||
this.holdingImageProperty = new MappedProperty( PreferencesModelSingleton.localizationModel.regionAndCulturePortrayalProperty, { | ||
map: portrayal => { | ||
if ( humanType === 'girl' ) { | ||
return portrayal.girlHolding; | ||
} | ||
else { | ||
assert && assert( humanType === 'man', 'Human type must be girl, or man, but it is ', humanType ); | ||
return portrayal.manHolding; | ||
} | ||
} | ||
} ); | ||
|
||
this.standingImageProperty = new MappedProperty( PreferencesModelSingleton.localizationModel.regionAndCulturePortrayalProperty, { | ||
map: portrayal => { | ||
if ( humanType === 'girl' ) { | ||
return portrayal.girlStanding; | ||
} | ||
else { | ||
assert && assert( humanType === 'man', 'Human type must be girl, or man, but it is ', humanType ); | ||
return portrayal.manStanding; | ||
} | ||
} | ||
} ); | ||
|
||
this.sittingImageProperty = new MappedProperty( PreferencesModelSingleton.localizationModel.regionAndCulturePortrayalProperty, { | ||
map: portrayal => { | ||
if ( humanType === 'girl' ) { | ||
return portrayal.girlSitting; | ||
} | ||
else { | ||
assert && assert( humanType === 'man', 'Human type must be girl, or man, but it is ', humanType ); | ||
return portrayal.manSitting; | ||
} | ||
} | ||
} ); | ||
} | ||
} | ||
|
||
forcesAndMotionBasics.register( 'HumanTypeEnum', HumanTypeEnum ); | ||
export default HumanTypeEnum; |
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
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
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
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,19 @@ | ||
// Copyright 2024, University of Colorado Boulder | ||
|
||
/** | ||
* MassPlayerImages contains an array of character sets, each representing a different region/culture. | ||
* | ||
* @author Luisa Vargas | ||
*/ | ||
|
||
import forcesAndMotionBasics from '../../forcesAndMotionBasics.js'; | ||
import MassPlayerPortrayalUSA from './MassPlayerPortrayalUSA.js'; | ||
|
||
const MassPlayerImages = { | ||
MASS_PLAYER_PORTRAYALS: [ | ||
MassPlayerPortrayalUSA | ||
] | ||
}; | ||
|
||
forcesAndMotionBasics.register( 'MassPlayerImages', MassPlayerImages ); | ||
export default MassPlayerImages; |
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,43 @@ | ||
// Copyright 2024, University of Colorado Boulder | ||
|
||
/** | ||
* The MassPlayerPortrayal defines what is needed for each portrayal in Forces and Motion: Basics. | ||
* | ||
* @author Luisa Vargas | ||
* | ||
*/ | ||
|
||
import RegionAndCulturePortrayal from '../../../../joist/js/preferences/RegionAndCulturePortrayal.js'; | ||
import forcesAndMotionBasics from '../../forcesAndMotionBasics.js'; | ||
|
||
export default class MassPlayerPortrayal extends RegionAndCulturePortrayal { | ||
|
||
/** | ||
* @param label { LocalizedStringProperty } | ||
* @param girlHolding { HTMLImageElement } | ||
* @param girlSitting { HTMLImageElement } | ||
* @param girlStanding { HTMLImageElement } | ||
* @param manHolding { HTMLImageElement } | ||
* @param manSitting { HTMLImageElement } | ||
* @param manStanding { HTMLImageElement } | ||
* @param screenIcon { HTMLImageElement } | ||
* @param queryParameterValue { string } | ||
*/ | ||
constructor( label, | ||
girlHolding, girlSitting, girlStanding, | ||
manHolding, manSitting, manStanding, | ||
screenIcon, queryParameterValue ) { | ||
|
||
super( label, queryParameterValue, {} ); | ||
|
||
this.girlHolding = girlHolding; | ||
this.girlSitting = girlSitting; | ||
this.girlStanding = girlStanding; | ||
this.manHolding = manHolding; | ||
this.manStanding = manStanding; | ||
this.manSitting = manSitting; | ||
this.screenIcon = screenIcon; | ||
} | ||
} | ||
|
||
forcesAndMotionBasics.register( 'MassPlayerPortrayal', MassPlayerPortrayal ); |
Oops, something went wrong.