-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert sims to new Region and Culture approach #958
Comments
@Luisav1 and I will be pairing at 10AM MT today. arithmetic looks like a good place to start. For the above steps:
|
@Luisav1 and I completed arithmetic, see phetsims/arithmetic@970fe8b. I'll work on center-and-variability + mean-share-and-balance (soccer-common) to expedite a fix for phetsims/center-and-variability#615 (CAV migration rules). @Luisav1 let me know if you have any questions, encounter problems, want review, etc. |
I was able to make progress on CAV migration processors by uninstrumenting the elements that have been deprecated, see phetsims/center-and-variability#615 (comment). Since I need to get back to other higher-priority work, I'm going to pause working on CAV for now. I created phetsims/center-and-variability#617, to capture some work and thoughts. |
…nd culture approach. See phetsims/joist#958.
…nd culture approach. See phetsims/joist#958.
…nd culture approach. See phetsims/joist#958.
…nd culture approach. See phetsims/joist#958.
@pixelzoom In the above commits I converted the code in Regarding image naming conventions, I noticed slight variations in the names of Navbar and Home icon images across all simulations.
In both sims as well, the icons in the Explore screen are slightly offset now.
Lastly, in NLI, there's an |
I could use HomeScreenIcon and NavigationBarIcon (or NavbarIcon would be fine) because the ScreenOptions are
The easist solution is probably to continue to use AlignGroup + AlignBox. The other (more complicated) alternatives are (1) add a boundsProperty listener to the Image that will reposition when the bounds changes, or (2) rewrite the layout using scenery GridBox.
Probably also solvable with AlignGroup + AlignBox. If that doesn't work, fill me in on more specifics.
I agree, that looks brittle. But that also looks like code that you probably don't want to touch. If it's working, I would leave it alone. Consider creating a separate GitHub issue, noting the dependency and brittleness, and assign to @jbphet -- it looks like he created |
…r HomeIcon -> HomeScreenIcon. See phetsims/joist#958.
…r HomeIcon -> HomeScreenIcon. See phetsims/joist#958.
In the above commits I've renamed the image suffixes. and tried aligning NLD images with the AlignGroup + AlignBox method but it doesn't exactly seem to be working. NLD NLI const legendAlignGroup = new AlignGroup();
const legendAlignBox = legendAlignGroup.createBox(
new Image( NumberLineIntegersImages.personInWaterImageProperty, { maxHeight: 40, center: new Vector2( 3, 5 ) } ),
{ xAlign: 'center' } );
const personInWaterRepresentation = new Node();
personInWaterRepresentation.addChild( legendAlignBox ); But the offset is much more noticeable than before: const swimmingImages = explorerSets.map( set => new Image( set.swimming,
{
visibleProperty: DerivedProperty.valueEqualsConstant( regionAdnCulturePortrayalProperty, set ),
maxHeight: 40,
center: new Vector2( 3, 5 )
} ) );
const flyingNode = new Node( { children: flyingImages } );
const hikingNode = new Node( { children: hikingImages } );
const swimmingNode = new Node( { children: swimmingImages } );
/**
* @public
* @type {Node[]}
*/
this.explorerNodes = [ flyingNode, hikingNode, swimmingNode ]; @pixelzoom might you know why the AlignGroup + AlignBox approach is not working? Should we try the other boundsProperty listener or rewriting the layout with a scenery GridBox approach? |
NLDBaseView was such a tangled mess that it was difficult to see what was related to the NDL layout problem. So the first major thing that I've done is to factor out PointControllerLegendNode in phetsims/number-line-distance@69a7ddc, which is this this UI component: It is now in TypeScript, and a number of other problems/oddities have been corrected. Now I'll work on identifying and fixing the layout problem. |
phetsims/number-line-distance@499b578 fixes the problem with PointControllerLegendNode. There was an unnecessary invisible Rectangle that was being added behind each icon, and that was preventing the HBox from vertically centering the icons. |
phetsims/number-line-distance@67a8757 fixes the layout of items in the toolbox. |
…cleanup in DistanceSceneView, phetsims/joist#958
Re this item for NLD:
I'm stuck here. The first problem is that the toolbox is not using using the PhET creator pattern. It's just a rectangle, and something else entirely (DistancePointControllerNode) renders the images on top of the rectange. The next problem is in DistancePointControllerNode. Both the house and person require their origin to be at their center, so that they appear to be centered in the toolbox: image.localBoundsProperty.link( () => {
image.centerX = 0;
image.centerY = 0;
image.touchArea = image.localBounds.dilated( IMAGE_DILATION / image.getScaleVector().x );
} ); Having the origin at the center make it impossible to keep the feet at a constant position on the sidewalk. PointController model element handles the position, and knows nothing about the changing height of the person image. And in DistanceSceneModel, there is this awful specification of where the person's origin is relative to the sidewalk (the 3rd arg here): new DistancePointController(
numberLine,
lockingBounds,
SIDEWALK_OFFSET_FROM_NUMBERLINE + SIDEWALK_HEIGHT / 2 - 25,
0.5
), Since I can't get the feet to be at constant y position on the sidewalk... I changed I'm going to stop here, and toss this back to the responsible developer. @jbphet is this good enough? |
I have two options for addressing the "feet on the sidewalk" problem in NLD. I'd like to discuss with @Luisav1 @marlitas and @jbphet after today's standup meeting. Option 1: Person is vertically centered in the toolbox. Feet are always on the sidewalk, but not always in the same vertical position. Options 2: Person is not vertically centered in the toolbox. Feet are always on the sidewalk, and always in the same vertical position. This is the same behavior as published 1.1.3. This version is not checked in; I'll demonstrate. |
Mini design meeting with @amanda-phet @Luisav1 @marlitas and @jbphet, to discuss the 2 options for NLD in #958 (comment). The consensus was that Option 1 is preferred; it's more important (and noticeable) for the person to be vertically centered in the toolbox, the person is still on the sidewalk, and no one is likely to notice that their feet move up/down on the sidewalk when R&C is changed. If anyone changes their mind and wants Option 2, here's a patch that does that: patchSubject: [PATCH] rename point controllers, https://github.com/phetsims/joist/issues/958
---
Index: js/explore/view/DistanceSceneView.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/explore/view/DistanceSceneView.js b/js/explore/view/DistanceSceneView.js
--- a/js/explore/view/DistanceSceneView.js (revision 1fc4a77ff697b986df5d72f462f097437b7b315f)
+++ b/js/explore/view/DistanceSceneView.js (date 1711467227122)
@@ -15,7 +15,7 @@
import numberLineDistance from '../../numberLineDistance.js';
import NumberLineDistanceImages from '../../NumberLineDistanceImages.js';
import NumberLineDistanceStrings from '../../NumberLineDistanceStrings.js';
-import DistancePointControllerNode from './DistancePointControllerNode.js';
+import { HousePointControllerNode, PersonPointControllerNode } from './DistancePointControllerNode.js';
import NLDSceneView from './NLDSceneView.js';
const eastStringProperty = NumberLineDistanceStrings.symbol.eastStringProperty;
@@ -90,8 +90,8 @@
personPointControllerImage.mouseArea = localBounds.dilated( 5 / personPointControllerImage.getScaleVector().x );
} );
- const housePointControllerNode = new DistancePointControllerNode( model.pointControllerOne, housePointControllerImage );
- const personPointControllerNode = new DistancePointControllerNode( model.pointControllerTwo, personPointControllerImage );
+ const housePointControllerNode = new HousePointControllerNode( model.pointControllerOne, housePointControllerImage );
+ const personPointControllerNode = new PersonPointControllerNode( model.pointControllerTwo, personPointControllerImage );
// Point controllers have different parent Nodes so that the person is always in front of the house.
const pointControllersLayer = new Node( {
Index: js/explore/model/DistanceSceneModel.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/explore/model/DistanceSceneModel.js b/js/explore/model/DistanceSceneModel.js
--- a/js/explore/model/DistanceSceneModel.js (revision 1fc4a77ff697b986df5d72f462f097437b7b315f)
+++ b/js/explore/model/DistanceSceneModel.js (date 1711466344006)
@@ -59,7 +59,7 @@
new DistancePointController(
numberLine,
lockingBounds,
- SIDEWALK_OFFSET_FROM_NUMBERLINE + SIDEWALK_HEIGHT / 2 - 25,
+ SIDEWALK_OFFSET_FROM_NUMBERLINE + SIDEWALK_HEIGHT / 2 - 28,
0.5
),
tandem
Index: js/explore/view/DistancePointControllerNode.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/explore/view/DistancePointControllerNode.js b/js/explore/view/DistancePointControllerNode.ts
rename from js/explore/view/DistancePointControllerNode.js
rename to js/explore/view/DistancePointControllerNode.ts
--- a/js/explore/view/DistancePointControllerNode.js (revision 1fc4a77ff697b986df5d72f462f097437b7b315f)
+++ b/js/explore/view/DistancePointControllerNode.ts (date 1711468148159)
@@ -1,40 +1,62 @@
// Copyright 2021-2024, University of Colorado Boulder
/**
- * A point controller node that is meant for use in the distance scene.
+ * DistancePointControllerNode is the base class for point controllers the Distance scene of the Explore screen.
+ * HousePointControllerNode is the subclass used for the house representation.
+ * PersonPointControllerNode is the subclass used for the person representation.
*
* @author Saurabh Totey
*/
import PointControllerNode from '../../../../number-line-common/js/common/view/PointControllerNode.js';
-import { Node } from '../../../../scenery/js/imports.js';
+import { Image, Node } from '../../../../scenery/js/imports.js';
import numberLineDistance from '../../numberLineDistance.js';
+import PointController from '../../../../number-line-common/js/common/model/PointController.js';
// constants
const IMAGE_DILATION = 20;
-class DistancePointControllerNode extends PointControllerNode {
+export default class DistancePointControllerNode extends PointControllerNode {
+
+ protected constructor( pointController: PointController, image: Image ) {
+ super( pointController, {
+ connectorLine: false,
+ node: new Node( { children: [ image ] } )
+ } );
+ }
- /**
- * @param {PointController} pointController
- * @param {Image} image - is mutated
- * @public
- */
- constructor( pointController, image ) {
+}
- image.localBoundsProperty.link( () => {
- image.centerX = 0;
- image.centerY = 0;
- image.touchArea = image.localBounds.dilated( IMAGE_DILATION / image.getScaleVector().x );
- } );
+export class HousePointControllerNode extends DistancePointControllerNode {
+
+ public constructor( pointController: PointController, image: Image ) {
+
+ // The house is a static image, with origin at its center.
+ image.centerX = 0;
+ image.centerY = 0;
+ image.touchArea = image.localBounds.dilated( IMAGE_DILATION / image.getScaleVector().x );
+
+ super( pointController, image );
+ }
+}
+
+export class PersonPointControllerNode extends DistancePointControllerNode {
+
+ public constructor( pointController: PointController, image: Image ) {
- super( pointController, {
- connectorLine: false,
- node: new Node( { children: [ image ] } )
+ // The person is a localized image. Its origin is at a fixed distance from the person's feet (the bottom of
+ // the image) so that feet will remain in the same position on the sidewalk when changing Region and Culture.
+ // The compromise for this is that the feet will also remain in the same position in the toolbox, and the person
+ // will therefore not be vertically centered in the toolbox.
+ image.localBoundsProperty.link( () => {
+ image.x = -image.width / 2;
+ image.y = -image.height + 44;
+ image.touchArea = image.localBounds.dilated( IMAGE_DILATION / image.getScaleVector().x );
} );
- }
+ super( pointController, image );
+ }
}
-numberLineDistance.register( 'DistancePointControllerNode', DistancePointControllerNode );
-export default DistancePointControllerNode;
\ No newline at end of file
+
+numberLineDistance.register( 'DistancePointControllerNode', DistancePointControllerNode );
\ No newline at end of file I also inspected NLI, and it still looks fine, unaffected by changes to NLD. So we're done with conversion of NLD and NLI. |
As @pixelzoom mentioned above, we reviewed this in a Zoom meeting with @amanda-phet and decided which tradeoff to go with. Unassigning myself. |
Looks like we're done here, so closing. Any remaining loose ends are being tracked in sim-specific issues. |
…nd culture approach. See phetsims/joist#958.
This is a sub-task of #953.
graphing-lines and graphing-slope-intercept can serve as examples.
Steps to convert:
Create {repo}-images.json.
Run
grunt update
to create {Repo}Images.js, a set ofLocalizedImageProperty
.For each
LocalizedImageProperty
, use it as the argument a sceneryImage
(or sim-specific subclass of sceneryImage
).Delete
localizationOptions.portrayals
option to PreferencesModel, typically in {repo}-main.ts.Delete all sim-specific subclasses of RegionAndCulturePortrayal.
Delete or modify other sim-specific classes related to the Region and Culture feature. E.g. KickerImage.ts, KickerNode.ts, BoxPlayerImages.js, BoxPlayerCharacters.js, ...
Sims to convert:
I'll set up a time with @Luisav1 to do one of these conversions together. We should consider doing center-and-variablility first, because it's blocking phetsims/center-and-variability#615.
The text was updated successfully, but these errors were encountered: