From 7bc94cb08f86d5eeb89309ef2827e156147fe1eb Mon Sep 17 00:00:00 2001 From: Jonathan Olson Date: Wed, 26 Dec 2018 16:10:23 -0700 Subject: [PATCH] Adding screen icons and converting to ES6, see https://github.com/phetsims/fractions-common/issues/40 and https://github.com/phetsims/fractions-common/issues/30 --- js/build-a-fraction-main.js | 18 ++++++------ js/buildAFraction.js | 4 +-- js/view/BuildAFractionScreen.js | 52 +++++++++++++++------------------ js/view/LabScreen.js | 49 +++++++++++++------------------ js/view/MixedNumbersScreen.js | 50 ++++++++++++++----------------- 5 files changed, 77 insertions(+), 96 deletions(-) diff --git a/js/build-a-fraction-main.js b/js/build-a-fraction-main.js index 0ccac48..bb2d19d 100644 --- a/js/build-a-fraction-main.js +++ b/js/build-a-fraction-main.js @@ -5,20 +5,20 @@ * * @author Jonathan Olson */ -define( function( require ) { +define( require => { 'use strict'; // modules - var BuildAFractionScreen = require( 'BUILD_A_FRACTION/view/BuildAFractionScreen' ); - var LabScreen = require( 'BUILD_A_FRACTION/view/LabScreen' ); - var MixedNumbersScreen = require( 'BUILD_A_FRACTION/view/MixedNumbersScreen' ); - var Sim = require( 'JOIST/Sim' ); - var SimLauncher = require( 'JOIST/SimLauncher' ); + const BuildAFractionScreen = require( 'BUILD_A_FRACTION/view/BuildAFractionScreen' ); + const LabScreen = require( 'BUILD_A_FRACTION/view/LabScreen' ); + const MixedNumbersScreen = require( 'BUILD_A_FRACTION/view/MixedNumbersScreen' ); + const Sim = require( 'JOIST/Sim' ); + const SimLauncher = require( 'JOIST/SimLauncher' ); // strings - var buildAFractionTitleString = require( 'string!BUILD_A_FRACTION/build-a-fraction.title' ); + const buildAFractionTitleString = require( 'string!BUILD_A_FRACTION/build-a-fraction.title' ); - var simOptions = { + const simOptions = { credits: { //TODO fill in proper credits, all of these fields are optional, see joist.AboutDialog leadDesign: '', @@ -31,7 +31,7 @@ define( function( require ) { }; SimLauncher.launch( function() { - var sim = new Sim( buildAFractionTitleString, [ + const sim = new Sim( buildAFractionTitleString, [ new BuildAFractionScreen(), new MixedNumbersScreen(), new LabScreen() diff --git a/js/buildAFraction.js b/js/buildAFraction.js index 9f41ba0..1915c0c 100644 --- a/js/buildAFraction.js +++ b/js/buildAFraction.js @@ -5,11 +5,11 @@ * * @author Jonathan Olson */ -define( function( require ) { +define( require => { 'use strict'; // modules - var Namespace = require( 'PHET_CORE/Namespace' ); + const Namespace = require( 'PHET_CORE/Namespace' ); return new Namespace( 'buildAFraction' ); } ); \ No newline at end of file diff --git a/js/view/BuildAFractionScreen.js b/js/view/BuildAFractionScreen.js index 09b08cf..c7df174 100644 --- a/js/view/BuildAFractionScreen.js +++ b/js/view/BuildAFractionScreen.js @@ -1,42 +1,36 @@ // Copyright 2018, University of Colorado Boulder /** - * TODO: doc + * The non-mixed-numbers game screen for Build a Fraction * * @author Jonathan Olson */ -define( function( require ) { +define( require => { 'use strict'; // modules - var buildAFraction = require( 'BUILD_A_FRACTION/buildAFraction' ); - var BuildingGameModel = require( 'FRACTIONS_COMMON/game/model/BuildingGameModel' ); - var BuildingGameScreenView = require( 'FRACTIONS_COMMON/game/view/BuildingGameScreenView' ); - var FractionsCommonColorProfile = require( 'FRACTIONS_COMMON/common/view/FractionsCommonColorProfile' ); - var inherit = require( 'PHET_CORE/inherit' ); - var Screen = require( 'JOIST/Screen' ); + const buildAFraction = require( 'BUILD_A_FRACTION/buildAFraction' ); + const BuildingGameModel = require( 'FRACTIONS_COMMON/game/model/BuildingGameModel' ); + const BuildingGameScreenView = require( 'FRACTIONS_COMMON/game/view/BuildingGameScreenView' ); + const FractionsCommonColorProfile = require( 'FRACTIONS_COMMON/common/view/FractionsCommonColorProfile' ); + const Screen = require( 'JOIST/Screen' ); // strings - var screenBuildAFractionString = require( 'string!BUILD_A_FRACTION/screen.buildAFraction' ); - - /** - * @constructor - */ - function BuildAFractionScreen() { - - var options = { - name: screenBuildAFractionString, - backgroundColorProperty: FractionsCommonColorProfile.otherScreenBackgroundProperty - }; - - Screen.call( this, - function() { return new BuildingGameModel( false ); }, - function( model ) { return new BuildingGameScreenView( model ); }, - options - ); + const screenBuildAFractionString = require( 'string!BUILD_A_FRACTION/screen.buildAFraction' ); + + class BuildAFractionScreen extends Screen { + constructor() { + super( + () => new BuildingGameModel( false ), + model => new BuildingGameScreenView( model ), + { + name: screenBuildAFractionString, + backgroundColorProperty: FractionsCommonColorProfile.otherScreenBackgroundProperty, + homeScreenIcon: BuildingGameScreenView.createUnmixedScreenIcon() + } + ); + } } - - buildAFraction.register( 'BuildAFractionScreen', BuildAFractionScreen ); - - return inherit( Screen, BuildAFractionScreen ); + + return buildAFraction.register( 'BuildAFractionScreen', BuildAFractionScreen ); } ); diff --git a/js/view/LabScreen.js b/js/view/LabScreen.js index 6abe683..c9ac819 100644 --- a/js/view/LabScreen.js +++ b/js/view/LabScreen.js @@ -1,42 +1,35 @@ // Copyright 2018, University of Colorado Boulder /** - * TODO: doc + * The "Lab" screen for Build a Fraction * * @author Jonathan Olson */ -define( function( require ) { +define( require => { 'use strict'; // modules - var buildAFraction = require( 'BUILD_A_FRACTION/buildAFraction' ); - var BuildingLabModel = require( 'FRACTIONS_COMMON/lab/model/BuildingLabModel' ); - var BuildingLabScreenView = require( 'FRACTIONS_COMMON/lab/view/BuildingLabScreenView' ); - var FractionsCommonColorProfile = require( 'FRACTIONS_COMMON/common/view/FractionsCommonColorProfile' ); - var inherit = require( 'PHET_CORE/inherit' ); - var Screen = require( 'JOIST/Screen' ); + const buildAFraction = require( 'BUILD_A_FRACTION/buildAFraction' ); + const BuildingLabModel = require( 'FRACTIONS_COMMON/lab/model/BuildingLabModel' ); + const BuildingLabScreenView = require( 'FRACTIONS_COMMON/lab/view/BuildingLabScreenView' ); + const FractionsCommonColorProfile = require( 'FRACTIONS_COMMON/common/view/FractionsCommonColorProfile' ); + const Screen = require( 'JOIST/Screen' ); // strings - var screenLabString = require( 'string!BUILD_A_FRACTION/screen.lab' ); - - /** - * @constructor - */ - function LabScreen() { - - var options = { - name: screenLabString, - backgroundColorProperty: FractionsCommonColorProfile.otherScreenBackgroundProperty - }; - - Screen.call( this, - function() { return new BuildingLabModel( true ); }, - function( model ) { return new BuildingLabScreenView( model ); }, - options - ); + const screenLabString = require( 'string!BUILD_A_FRACTION/screen.lab' ); + + class LabScreen extends Screen { + constructor() { + super( + () => new BuildingLabModel( true ), + model => new BuildingLabScreenView( model ), + { + name: screenLabString, + backgroundColorProperty: FractionsCommonColorProfile.otherScreenBackgroundProperty + } + ); + } } - buildAFraction.register( 'LabScreen', LabScreen ); - - return inherit( Screen, LabScreen ); + return buildAFraction.register( 'LabScreen', LabScreen ); } ); diff --git a/js/view/MixedNumbersScreen.js b/js/view/MixedNumbersScreen.js index b43af9e..37ea315 100644 --- a/js/view/MixedNumbersScreen.js +++ b/js/view/MixedNumbersScreen.js @@ -1,42 +1,36 @@ // Copyright 2018, University of Colorado Boulder /** - * TODO: doc + * The mixed-numbers game screen for Build a Fraction * * @author Jonathan Olson */ -define( function( require ) { +define( require => { 'use strict'; // modules - var buildAFraction = require( 'BUILD_A_FRACTION/buildAFraction' ); - var BuildingGameModel = require( 'FRACTIONS_COMMON/game/model/BuildingGameModel' ); - var BuildingGameScreenView = require( 'FRACTIONS_COMMON/game/view/BuildingGameScreenView' ); - var FractionsCommonColorProfile = require( 'FRACTIONS_COMMON/common/view/FractionsCommonColorProfile' ); - var inherit = require( 'PHET_CORE/inherit' ); - var Screen = require( 'JOIST/Screen' ); + const buildAFraction = require( 'BUILD_A_FRACTION/buildAFraction' ); + const BuildingGameModel = require( 'FRACTIONS_COMMON/game/model/BuildingGameModel' ); + const BuildingGameScreenView = require( 'FRACTIONS_COMMON/game/view/BuildingGameScreenView' ); + const FractionsCommonColorProfile = require( 'FRACTIONS_COMMON/common/view/FractionsCommonColorProfile' ); + const Screen = require( 'JOIST/Screen' ); // strings - var screenMixedNumbersString = require( 'string!BUILD_A_FRACTION/screen.mixedNumbers' ); - - /** - * @constructor - */ - function MixedNumbersScreen() { - - var options = { - name: screenMixedNumbersString, - backgroundColorProperty: FractionsCommonColorProfile.otherScreenBackgroundProperty - }; - - Screen.call( this, - function() { return new BuildingGameModel( true ); }, - function( model ) { return new BuildingGameScreenView( model ); }, - options - ); + const screenMixedNumbersString = require( 'string!BUILD_A_FRACTION/screen.mixedNumbers' ); + + class MixedNumbersScreen extends Screen { + constructor() { + super( + () => new BuildingGameModel( true ), + model => new BuildingGameScreenView( model ), + { + name: screenMixedNumbersString, + backgroundColorProperty: FractionsCommonColorProfile.otherScreenBackgroundProperty, + homeScreenIcon: BuildingGameScreenView.createMixedScreenIcon() + } + ); + } } - buildAFraction.register( 'MixedNumbersScreen', MixedNumbersScreen ); - - return inherit( Screen, MixedNumbersScreen ); + return buildAFraction.register( 'MixedNumbersScreen', MixedNumbersScreen ); } );