11import bindAll from 'lodash.bindall' ;
22import React from 'react' ;
33import PropTypes from 'prop-types' ;
4+ import classNames from 'classnames' ;
45
56import { connect } from 'react-redux' ;
67import VM from 'scratch-vm' ;
78import Box from '../components/box/box.jsx' ;
89import greenFlag from '../components/green-flag/icon--green-flag.svg' ;
910import { setStartedState } from '../reducers/vm-status.js' ;
11+ import { FormattedMessage } from 'react-intl' ;
12+
13+ import styles from '../components/stage/stage.css' ;
1014
1115class GreenFlagOverlay extends React . Component {
1216 constructor ( props ) {
@@ -27,11 +31,36 @@ class GreenFlagOverlay extends React.Component {
2731 }
2832
2933 render ( ) {
34+ // Check if project has cloud vars and user is generic 'player' or empty string (not logged in)
35+ const isGuest = ! this . props . username || this . props . username === 'player' ;
36+ const showCloudWarning = this . props . hasCloudVariables && isGuest ;
37+
3038 return (
3139 < Box
32- className = { this . props . wrapperClass }
40+ className = { classNames (
41+ this . props . wrapperClass ,
42+ { [ styles . greenFlagOverlayWithWarning ] : showCloudWarning }
43+ ) }
3344 onClick = { this . handleClick }
3445 >
46+ { showCloudWarning && (
47+ < div className = { styles . cloudWarningContent } >
48+ < div className = { styles . cloudWarningText } >
49+ < span className = { styles . cloudWarningTextRed } >
50+ < FormattedMessage
51+ defaultMessage = "Multiplayer Features: "
52+ id = "gui.greenFlagOverlay.cloudTitle"
53+ />
54+ </ span >
55+ < span >
56+ < FormattedMessage
57+ defaultMessage = "This project uses cloud variables. To play online or interact with others, you must log in."
58+ id = "gui.greenFlagOverlay.cloudWarning"
59+ />
60+ </ span >
61+ </ div >
62+ </ div >
63+ ) }
3564 < div className = { this . props . className } >
3665 < img
3766 draggable = { false }
@@ -48,11 +77,15 @@ GreenFlagOverlay.propTypes = {
4877 className : PropTypes . string ,
4978 vm : PropTypes . instanceOf ( VM ) ,
5079 wrapperClass : PropTypes . string ,
51- onStarted : PropTypes . func
80+ onStarted : PropTypes . func ,
81+ hasCloudVariables : PropTypes . bool ,
82+ username : PropTypes . string
5283} ;
5384
5485const mapStateToProps = state => ( {
55- vm : state . scratchGui . vm
86+ vm : state . scratchGui . vm ,
87+ hasCloudVariables : state . scratchGui . tw . hasCloudVariables ,
88+ username : state . scratchGui . tw . username
5689} ) ;
5790
5891const mapDispatchToProps = dispatch => ( {
0 commit comments