-
Notifications
You must be signed in to change notification settings - Fork 901
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove game.resumed/paused in favor of status
- Loading branch information
Showing
7 changed files
with
75 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,62 @@ | ||
// @flow | ||
import { t } from '@lingui/macro'; | ||
import * as React from 'react'; | ||
import { I18n } from '@lingui/react'; | ||
import SelectField from '../UI/SelectField'; | ||
import SelectOption from '../UI/SelectOption'; | ||
import { type DebuggerId } from '../ExportAndShare/PreviewLauncher.flow'; | ||
import { | ||
type DebuggerId, | ||
type DebuggerStatus, | ||
} from '../ExportAndShare/PreviewLauncher.flow'; | ||
|
||
type Props = {| | ||
selectedId: DebuggerId, | ||
debuggerIds: Array<DebuggerId>, | ||
debuggerStatus: { [DebuggerId]: DebuggerStatus }, | ||
onChooseDebugger: DebuggerId => void, | ||
|}; | ||
|
||
export default class DebuggerSelector extends React.Component<Props, void> { | ||
render() { | ||
const hasDebuggers = !!this.props.debuggerIds.length; | ||
const debuggerIds = Object.keys(this.props.debuggerStatus); | ||
const hasDebuggers = !!debuggerIds.length; | ||
return ( | ||
<SelectField | ||
fullWidth | ||
value={hasDebuggers ? this.props.selectedId : 0} | ||
onChange={(e, i, value) => | ||
this.props.onChooseDebugger(parseInt(value, 10) || 0) | ||
} | ||
disabled={!hasDebuggers} | ||
> | ||
{this.props.debuggerIds.map(id => ( | ||
<SelectOption value={id} key={id} label={t`Game preview #${id}`} /> | ||
))} | ||
{!hasDebuggers && ( | ||
<SelectOption | ||
value={0} | ||
label={t`No preview running. Run a preview and you will be able to inspect it with the debugger`} | ||
/> | ||
<I18n> | ||
{({ i18n }) => ( | ||
<SelectField | ||
fullWidth | ||
value={hasDebuggers ? this.props.selectedId : 0} | ||
onChange={(e, i, value) => | ||
this.props.onChooseDebugger(parseInt(value, 10) || 0) | ||
} | ||
disabled={!hasDebuggers} | ||
> | ||
{debuggerIds.map(id => { | ||
const status = this.props.debuggerStatus[+id]; | ||
const statusText = status.isPaused | ||
? status.isInGameEdition | ||
? t`Editing` | ||
: t`Paused` | ||
: status.isInGameEdition | ||
? t`Playing (in-game edition)` | ||
: t`Playing`; | ||
|
||
return ( | ||
<SelectOption | ||
value={+id} | ||
key={id} | ||
label={t`Game preview #${id} (${i18n._(statusText)})`} | ||
/> | ||
); | ||
})} | ||
{!hasDebuggers && ( | ||
<SelectOption | ||
value={0} | ||
label={t`No preview running. Run a preview and you will be able to inspect it with the debugger`} | ||
/> | ||
)} | ||
</SelectField> | ||
)} | ||
</SelectField> | ||
</I18n> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters