Skip to content

Commit

Permalink
Add level 3 and 4 icons to portrayals since they have characters too.…
Browse files Browse the repository at this point in the history
… See #140.
  • Loading branch information
Luisav1 committed Dec 13, 2023
1 parent b8df0e6 commit 74212fa
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
8 changes: 6 additions & 2 deletions js/common/view/BalancerCharacterSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ export default class BalancerCharacterSet extends RegionAndCulturePortrayal {
* @param manSitting { HTMLImageElement }
* @param womanStanding { HTMLImageElement }
* @param womanSitting { HTMLImageElement }
* @param levelThree { HTMLImageElement }
* @param levelFour { HTMLImageElement }
* @param screenHomeIcon { HTMLImageElement }
* @param screenNavIcon { HTMLImageElement }
* @param queryParameterValue { string }
*/
constructor( label,
boyStanding, boySitting, girlStanding,
girlSitting, manStanding, manSitting,
womanStanding, womanSitting, screenHomeIcon,
screenNavIcon,
womanStanding, womanSitting, levelThree,
levelFour, screenHomeIcon, screenNavIcon,
queryParameterValue ) {

super( label, queryParameterValue, {} );
Expand All @@ -43,6 +45,8 @@ export default class BalancerCharacterSet extends RegionAndCulturePortrayal {
this.manSitting = manSitting;
this.womanStanding = womanStanding;
this.womanSitting = womanSitting;
this.levelThree = levelThree;
this.levelFour = levelFour;
this.screenHomeIcon = screenHomeIcon;
this.screenNavIcon = screenNavIcon;
}
Expand Down
4 changes: 4 additions & 0 deletions js/common/view/BalancerCharacterSetUSA.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import labIcon_png from '../../../images/labIcon_png.js';
import labIconSmall_png from '../../../images/labIconSmall_png.js';
import boySitting_png from '../../../mipmaps/usa/boySitting_png.js';
import boyStanding_png from '../../../mipmaps/usa/boyStanding_png.js';
import gameLevel3Icon_png from '../../../mipmaps/usa/gameLevel3Icon_png.js';
import gameLevel4Icon_png from '../../../mipmaps/usa/gameLevel4Icon_png.js';
import girlSitting_png from '../../../mipmaps/usa/girlSitting_png.js';
import girlStanding_png from '../../../mipmaps/usa/girlStanding_png.js';
import manSitting_png from '../../../mipmaps/usa/manSitting_png.js';
Expand All @@ -32,6 +34,8 @@ const BalancerCharacterSetUSA = new BalancerCharacterSet(
manSitting_png,
womanStanding_png,
womanSitting_png,
gameLevel3Icon_png,
gameLevel4Icon_png,
labIcon_png,
labIconSmall_png,
USA_REGION_AND_CULTURE_ID
Expand Down
12 changes: 4 additions & 8 deletions js/game/view/BalanceGameView.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import FiniteStatusBar from '../../../../vegas/js/FiniteStatusBar.js';
import GameAudioPlayer from '../../../../vegas/js/GameAudioPlayer.js';
import LevelCompletedNode from '../../../../vegas/js/LevelCompletedNode.js';
import VegasStrings from '../../../../vegas/js/VegasStrings.js';
import gameLevel1Icon_png from '../../../mipmaps/gameLevel1Icon_png.js';
import gameLevel2Icon_png from '../../../mipmaps/gameLevel2Icon_png.js';
import gameLevel3Icon_png from '../../../mipmaps/usa/gameLevel3Icon_png.js';
import gameLevel4Icon_png from '../../../mipmaps/usa/gameLevel4Icon_png.js';
import balancingAct from '../../balancingAct.js';
import BalancingActStrings from '../../BalancingActStrings.js';
import BASharedConstants from '../../common/BASharedConstants.js';
Expand Down Expand Up @@ -159,10 +155,10 @@ class BalanceGameView extends ScreenView {
() => { gameModel.reset(); },
gameModel.timerEnabledProperty,
[
new GameIconNode( gameLevel1Icon_png, 1 ),
new GameIconNode( gameLevel2Icon_png, 2 ),
new GameIconNode( gameLevel3Icon_png, 3 ),
new GameIconNode( gameLevel4Icon_png, 4 )
new GameIconNode( 1 ),
new GameIconNode( 2 ),
new GameIconNode( 3 ),
new GameIconNode( 4 )
],
gameModel.mostRecentScores,
modelViewTransform,
Expand Down
27 changes: 24 additions & 3 deletions js/game/view/GameIconNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import Vector2 from '../../../../dot/js/Vector2.js';
import StringUtils from '../../../../phetcommon/js/util/StringUtils.js';
import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
import { Image, Node, Text } from '../../../../scenery/js/imports.js';
import gameLevel1Icon_png from '../../../mipmaps/gameLevel1Icon_png.js';
import gameLevel2Icon_png from '../../../mipmaps/gameLevel2Icon_png.js';
import balancingAct from '../../balancingAct.js';
import BalancingActStrings from '../../BalancingActStrings.js';
import PreferencesModelSingleton from '../../common/PreferencesModelSingleton.js';

const levelString = BalancingActStrings.level;
const pattern0Label1ValueString = BalancingActStrings.pattern0Label1Value;
Expand All @@ -22,16 +25,34 @@ const IMAGE_SIZE = new Dimension2( 100, 65 );
class GameIconNode extends Node {

/**
* @param image
* @param levelNumber
* @param { number } levelNumber
*/
constructor( image, levelNumber ) {
constructor( levelNumber ) {
super();
const title = new Text( StringUtils.format( pattern0Label1ValueString, levelString, levelNumber ), {
font: FONT,
maxWidth: 100
} );
this.addChild( title );

let image;
switch( levelNumber ) {
case 1:
image = gameLevel1Icon_png;
break;
case 2:
image = gameLevel2Icon_png;
break;
case 3:
image = PreferencesModelSingleton.localizationModel.regionAndCulturePortrayalProperty.value.levelThree;
break;
case 4:
image = PreferencesModelSingleton.localizationModel.regionAndCulturePortrayalProperty.value.levelFour;
break;
default:
throw new Error( `Can't retrieve level icon image for requested level: ${levelNumber}` );
}

const imageNode = new Image( image );
imageNode.scale( new Vector2( IMAGE_SIZE.width / imageNode.width, IMAGE_SIZE.height / imageNode.height ) );
imageNode.top = title.bottom + 4;
Expand Down

0 comments on commit 74212fa

Please sign in to comment.