mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Make warnings about instruction/behaviors translatable
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// @flow
|
||||
import { Trans } from '@lingui/macro';
|
||||
import { I18n } from '@lingui/react';
|
||||
import { type I18n as I18nType } from '@lingui/core';
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import Dialog from '../UI/Dialog';
|
||||
@@ -139,66 +141,72 @@ export default class NewBehaviorDialog extends Component<Props, State> {
|
||||
({ type }) => !!deprecatedBehaviorsInformation[type]
|
||||
);
|
||||
|
||||
const chooseBehavior = ({
|
||||
type,
|
||||
defaultName,
|
||||
}: EnumeratedBehaviorMetadata) => {
|
||||
const chooseBehavior = (
|
||||
i18n: I18nType,
|
||||
{ type, defaultName }: EnumeratedBehaviorMetadata
|
||||
) => {
|
||||
if (deprecatedBehaviorsInformation[type]) {
|
||||
showMessageBox(deprecatedBehaviorsInformation[type].warning);
|
||||
showMessageBox(i18n._(deprecatedBehaviorsInformation[type].warning));
|
||||
}
|
||||
|
||||
return this.props.onChoose(type, defaultName);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
title={<Trans>Add a new behavior to the object</Trans>}
|
||||
actions={actions}
|
||||
secondaryActions={<HelpButton helpPagePath="/behaviors" />}
|
||||
open={open}
|
||||
noMargin
|
||||
autoScrollBodyContent
|
||||
>
|
||||
<List>
|
||||
{behaviors.map((behaviorMetadata, index) => (
|
||||
<BehaviorListItem
|
||||
key={index}
|
||||
behaviorMetadata={behaviorMetadata}
|
||||
onClick={() => chooseBehavior(behaviorMetadata)}
|
||||
/>
|
||||
))}
|
||||
{showDeprecated && (
|
||||
<Subheader>Deprecated (old, prefer not to use anymore)</Subheader>
|
||||
)}
|
||||
{showDeprecated &&
|
||||
deprecatedBehaviors.map((behaviorMetadata, index) => (
|
||||
<BehaviorListItem
|
||||
key={index}
|
||||
behaviorMetadata={behaviorMetadata}
|
||||
onClick={() => chooseBehavior(behaviorMetadata)}
|
||||
/>
|
||||
))}
|
||||
</List>
|
||||
<Line justifyContent="center" alignItems="center">
|
||||
{!showDeprecated ? (
|
||||
<FlatButton
|
||||
key="toggle-experimental"
|
||||
icon={<Visibility />}
|
||||
primary={false}
|
||||
onClick={() => this._showDeprecated(true)}
|
||||
label={<Trans>Show deprecated (old) behaviors</Trans>}
|
||||
/>
|
||||
) : (
|
||||
<FlatButton
|
||||
key="toggle-experimental"
|
||||
icon={<VisibilityOff />}
|
||||
primary={false}
|
||||
onClick={() => this._showDeprecated(false)}
|
||||
label={<Trans>Show deprecated (old) behaviors</Trans>}
|
||||
/>
|
||||
)}
|
||||
</Line>
|
||||
</Dialog>
|
||||
<I18n>
|
||||
{({ i18n }) => (
|
||||
<Dialog
|
||||
title={<Trans>Add a new behavior to the object</Trans>}
|
||||
actions={actions}
|
||||
secondaryActions={<HelpButton helpPagePath="/behaviors" />}
|
||||
open={open}
|
||||
noMargin
|
||||
autoScrollBodyContent
|
||||
>
|
||||
<List>
|
||||
{behaviors.map((behaviorMetadata, index) => (
|
||||
<BehaviorListItem
|
||||
key={index}
|
||||
behaviorMetadata={behaviorMetadata}
|
||||
onClick={() => chooseBehavior(i18n, behaviorMetadata)}
|
||||
/>
|
||||
))}
|
||||
{showDeprecated && (
|
||||
<Subheader>
|
||||
Deprecated (old, prefer not to use anymore)
|
||||
</Subheader>
|
||||
)}
|
||||
{showDeprecated &&
|
||||
deprecatedBehaviors.map((behaviorMetadata, index) => (
|
||||
<BehaviorListItem
|
||||
key={index}
|
||||
behaviorMetadata={behaviorMetadata}
|
||||
onClick={() => chooseBehavior(i18n, behaviorMetadata)}
|
||||
/>
|
||||
))}
|
||||
</List>
|
||||
<Line justifyContent="center" alignItems="center">
|
||||
{!showDeprecated ? (
|
||||
<FlatButton
|
||||
key="toggle-experimental"
|
||||
icon={<Visibility />}
|
||||
primary={false}
|
||||
onClick={() => this._showDeprecated(true)}
|
||||
label={<Trans>Show deprecated (old) behaviors</Trans>}
|
||||
/>
|
||||
) : (
|
||||
<FlatButton
|
||||
key="toggle-experimental"
|
||||
icon={<VisibilityOff />}
|
||||
primary={false}
|
||||
onClick={() => this._showDeprecated(false)}
|
||||
label={<Trans>Show deprecated (old) behaviors</Trans>}
|
||||
/>
|
||||
)}
|
||||
</Line>
|
||||
</Dialog>
|
||||
)}
|
||||
</I18n>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ import {
|
||||
import { type ResourceExternalEditor } from '../../ResourcesList/ResourceExternalEditor.flow';
|
||||
import { Line } from '../../UI/Grid';
|
||||
import AlertMessage from '../../UI/AlertMessage';
|
||||
import { getDeprecatedInstructionInformation } from '../../Hints';
|
||||
import { getExtraInstructionInformation } from '../../Hints';
|
||||
import { isAnEventFunctionMetadata } from '../../EventsFunctionsExtensionsLoader';
|
||||
import OpenInNew from 'material-ui/svg-icons/action/open-in-new';
|
||||
import IconButton from 'material-ui/IconButton';
|
||||
@@ -181,10 +181,7 @@ export default class InstructionParametersEditor extends React.Component<
|
||||
|
||||
const helpPage = instructionMetadata.getHelpPath();
|
||||
|
||||
const deprecatedInstructionInformation = getDeprecatedInstructionInformation(
|
||||
_ => _,
|
||||
type
|
||||
);
|
||||
const instructionExtraInformation = getExtraInstructionInformation(type);
|
||||
|
||||
//TODO?
|
||||
instruction.setParametersCount(instructionMetadata.getParametersCount());
|
||||
@@ -207,10 +204,10 @@ export default class InstructionParametersEditor extends React.Component<
|
||||
</IconButton>
|
||||
)}
|
||||
</Line>
|
||||
{deprecatedInstructionInformation && (
|
||||
{instructionExtraInformation && (
|
||||
<Line>
|
||||
<AlertMessage kind="warning">
|
||||
{deprecatedInstructionInformation.warning}
|
||||
{i18n._(instructionExtraInformation.warning)}
|
||||
</AlertMessage>
|
||||
</Line>
|
||||
)}
|
||||
|
@@ -1,27 +1,23 @@
|
||||
// @flow
|
||||
import { t } from '@lingui/macro';
|
||||
|
||||
export const getDeprecatedBehaviorsInformation = (
|
||||
t: string => string
|
||||
): { [string]: {| warning: string |} } => ({
|
||||
export const getDeprecatedBehaviorsInformation = (): {
|
||||
[string]: {| warning: string |},
|
||||
} => ({
|
||||
'PhysicsBehavior::PhysicsBehavior': {
|
||||
warning: t(
|
||||
'A new physics engine (Physics Engine 2.0) is now available. You should prefer using it for new game. For existing games, note that the two behaviors are not compatible, so you should only use one of them with your objects.'
|
||||
),
|
||||
warning: t`A new physics engine (Physics Engine 2.0) is now available. You should prefer using it for new game. For existing games, note that the two behaviors are not compatible, so you should only use one of them with your objects.`,
|
||||
},
|
||||
});
|
||||
|
||||
export const getDeprecatedInstructionInformation = (
|
||||
t: string => string,
|
||||
export const getExtraInstructionInformation = (
|
||||
type: string
|
||||
): ?{| warning: string |} => {
|
||||
if (type.indexOf('PhysicsBehavior::') === 0) {
|
||||
return {
|
||||
warning: t(
|
||||
`This action is deprecated and should not be used anymore. Instead,
|
||||
warning: t`This action is deprecated and should not be used anymore. Instead,
|
||||
use for all your objects the behavior called "Physics2" and the
|
||||
associated actions (in this case, all objects must be set up to use
|
||||
Physics2, you can't mix the behaviors).`
|
||||
),
|
||||
Physics2, you can't mix the behaviors).`,
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user