Skip to content

Commit

Permalink
Moving options to the options dialog. fixes #31
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Oct 8, 2014
1 parent 416334d commit e442faf
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 62 deletions.
1 change: 0 additions & 1 deletion js/model/MoleculeShapesModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ define( function( require ) {
molecule: null, // {Molecule}
showBondAngles: false,
showLonePairs: !isBasicsVersion,
showOuterLonePairs: false,
showMolecularShapeName: false,
showElectronShapeName: false
}, options ) );
Expand Down
31 changes: 23 additions & 8 deletions js/molecule-shapes-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ define( function( require ) {
var ModelMoleculesScreen = require( 'MOLECULE_SHAPES/screens/model/ModelMoleculesScreen' );
var RealMoleculesScreen = require( 'MOLECULE_SHAPES/screens/real/RealMoleculesScreen' );
var MoleculeShapesColors = require( 'MOLECULE_SHAPES/view/MoleculeShapesColors' );
var MoleculeShapesGlobals = require( 'MOLECULE_SHAPES/view/MoleculeShapesGlobals' );
var Sim = require( 'JOIST/Sim' );
var SimLauncher = require( 'JOIST/SimLauncher' );

// strings
var simTitle = require( 'string!MOLECULE_SHAPES/molecule-shapes.name' );
var showOuterLonePairsString = require( 'string!MOLECULE_SHAPES/options.showOuterLonePairs' );
var projectorColorsString = require( 'string!MOLECULE_SHAPES/options.projectorColors' );

var simOptions = {
credits: {
Expand All @@ -25,7 +28,19 @@ define( function( require ) {
softwareDevelopment: '',
team: '',
thanks: ''
}
},
globalOptions: [
{
label: showOuterLonePairsString,
type: 'boolean',
property: MoleculeShapesGlobals.showOuterLonePairsProperty
},
{
label: projectorColorsString,
type: 'boolean',
property: MoleculeShapesGlobals.projectorColorsProperty
}
]
};

// Appending '?dev' to the URL will enable developer-only features.
Expand All @@ -38,14 +53,14 @@ define( function( require ) {
// NOTE: ?canvasOnly will trigger Canvas rendering with a reduced poly-count

var isBasicsVersion = false;
if ( window.phetcommon.getQueryParameter( 'basics' ) ) {
isBasicsVersion = true;
MoleculeShapesColors.applyProfile( 'basics' );
}

if ( window.phetcommon.getQueryParameter( 'projector' ) ) {
MoleculeShapesColors.applyProfile( 'projector' );
}
MoleculeShapesGlobals.projectorColorsProperty.link( function( useProjectorColors ) {
if ( useProjectorColors ) {
MoleculeShapesColors.applyProfile( 'projector' );
} else {
MoleculeShapesColors.applyProfile( 'default' );
}
} );

SimLauncher.launch( function() {
var sim = new Sim( simTitle, [
Expand Down
3 changes: 2 additions & 1 deletion js/view/3d/MoleculeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ define( function( require ) {
var BondView = require( 'MOLECULE_SHAPES/view/3d/BondView' );
var LonePairView = require( 'MOLECULE_SHAPES/view/3d/LonePairView' );
var MoleculeShapesScreenView = require( 'MOLECULE_SHAPES/view/MoleculeShapesScreenView' );
var MoleculeShapesGlobals = require( 'MOLECULE_SHAPES/view/MoleculeShapesGlobals' );
var BondAngleView = require( 'MOLECULE_SHAPES/view/3d/BondAngleView' );

var angleDegreesString = require( 'string!MOLECULE_SHAPES/angle.degrees' );
Expand Down Expand Up @@ -177,7 +178,7 @@ define( function( require ) {

var visibilityProperty = parentAtom === centralAtom ?
this.model.showLonePairsProperty :
this.model.showOuterLonePairsProperty;
MoleculeShapesGlobals.showOuterLonePairsProperty;
visibilityProperty.linkAttribute( lonePairView, 'visible' );

group.link( 'position', function( position ) {
Expand Down
11 changes: 9 additions & 2 deletions js/view/MoleculeShapesGlobals.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ define( function( require ) {
'use strict';

var Property = require( 'AXON/Property' );
var PropertySet = require( 'AXON/PropertySet' );
var Color = require( 'SCENERY/util/Color' );
var Util = require( 'SCENERY/util/Util' );

return {
// TODO: MOVE me out of view
var MoleculeShapesGlobals = new PropertySet( {
showOuterLonePairs: !!window.phetcommon.getQueryParameter( 'showOuterLonePairs' ) || false,
projectorColors: !!window.phetcommon.getQueryParameter( 'projector' ) || false
} );

return _.extend( MoleculeShapesGlobals, {
useWebGL: !window.phetcommon.getQueryParameter( 'canvasOnly' ) && Util.isWebGLSupported(),

/*
Expand Down Expand Up @@ -65,6 +72,6 @@ define( function( require ) {
}
return colorProperty;
}
};
} );
} );

49 changes: 0 additions & 49 deletions js/view/MoleculeShapesScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ define( function( require ) {
var SimpleDragHandler = require( 'SCENERY/input/SimpleDragHandler' );
var ScreenView = require( 'JOIST/ScreenView' );
var ResetAllButton = require( 'SCENERY_PHET/buttons/ResetAllButton' );
var TextPushButton = require( 'SUN/buttons/TextPushButton' );
var MoleculeShapesColors = require( 'MOLECULE_SHAPES/view/MoleculeShapesColors' );
var GeometryNamePanel = require( 'MOLECULE_SHAPES/view/GeometryNamePanel' );
var PhetFont = require( 'SCENERY_PHET/PhetFont' );
Expand Down Expand Up @@ -98,54 +97,6 @@ define( function( require ) {
bottom: this.layoutBounds.maxY - 10
} ) );

/*---------------------------------------------------------------------------*
* Temporary
*----------------------------------------------------------------------------*/
this.addChild( new TextPushButton( 'Regular Colors', {
font: new PhetFont( 20 ),
baseColor: '#888',
left: this.layoutBounds.left + 10,
top: this.layoutBounds.top + 10,
scale: 0.5,
listener: function() {
MoleculeShapesColors.applyProfile( 'default' );
}
} ) );
this.addChild( new TextPushButton( 'Basics Colors', {
font: new PhetFont( 20 ),
baseColor: '#888',
left: this.layoutBounds.left + 10,
top: this.layoutBounds.top + 30,
scale: 0.5,
listener: function() {
MoleculeShapesColors.applyProfile( 'default' );
MoleculeShapesColors.applyProfile( 'basics' );
}
} ) );
this.addChild( new TextPushButton( 'Projector Colors', {
font: new PhetFont( 20 ),
baseColor: '#888',
left: this.layoutBounds.left + 10,
top: this.layoutBounds.top + 50,
scale: 0.5,
listener: function() {
MoleculeShapesColors.applyProfile( 'default' );
MoleculeShapesColors.applyProfile( 'projector' );
}
} ) );
if ( !model.isBasicsVersion ) {
this.addChild( new TextPushButton( 'Toggle "Show Outer Lone Pairs"', {
font: new PhetFont( 20 ),
baseColor: '#888',
left: this.layoutBounds.left + 10,
top: this.layoutBounds.top + 70,
scale: 0.5,
listener: function() {
model.showOuterLonePairs = !model.showOuterLonePairs;
}
} ) );
}

// for computing rays
this.projector = new THREE.Projector();

Expand Down
5 changes: 4 additions & 1 deletion strings/molecule-shapes-strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@

"angle.degrees": "{0}\u00B0",
"angle.greaterThanDegrees": "greater than {0}\u00B0",
"angle.lessThanDegrees": "less than {0}\u00B0"
"angle.lessThanDegrees": "less than {0}\u00B0",

"options.showOuterLonePairs": "Show Outer Lone Pairs",
"options.projectorColors": "Projector Mode"
}

0 comments on commit e442faf

Please sign in to comment.