Guided lessons opening fixes (#6745)

Do not show in changelog
This commit is contained in:
Clément Pasteau
2024-07-02 17:40:46 +02:00
committed by GitHub
parent 0792e59b24
commit 40674fd3b9
2 changed files with 182 additions and 184 deletions

View File

@@ -258,199 +258,195 @@ const InstructionParametersEditor = React.forwardRef<
let parameterFieldIndex = 0;
return (
<div id={id}>
<I18n>
{({ i18n }) => (
<ScrollView autoHideScrollbar>
<Column expand>
<Line alignItems="flex-start">
<img
src={iconFilename}
alt=""
style={{
...styles.icon,
filter: shouldInvertGrayScale
? 'grayscale(1) invert(1)'
: undefined,
<I18n>
{({ i18n }) => (
<ScrollView autoHideScrollbar id={id}>
<Column expand>
<Line alignItems="flex-start">
<img
src={iconFilename}
alt=""
style={{
...styles.icon,
filter: shouldInvertGrayScale
? 'grayscale(1) invert(1)'
: undefined,
}}
/>
<Column expand>
<Text style={styles.description}>
{instructionMetadata.getDescription()}
</Text>
</Column>
</Line>
{instructionExtraInformation && (
<Line>
{instructionExtraInformation.identifier === undefined ? (
<AlertMessage kind={instructionExtraInformation.kind}>
{i18n._(instructionExtraInformation.message)}
</AlertMessage>
) : (
<DismissableAlertMessage
kind={instructionExtraInformation.kind}
identifier={instructionExtraInformation.identifier}
>
{i18n._(instructionExtraInformation.message)}
</DismissableAlertMessage>
)}
</Line>
)}
{tutorialIds.length ? (
<Line>
<ColumnStackLayout expand>
{tutorialIds.map(tutorialId => (
<DismissableTutorialMessage
key={tutorialId}
tutorialId={tutorialId}
/>
))}
</ColumnStackLayout>
</Line>
) : null}
<Spacer />
<div
key={instructionType}
style={styles.parametersContainer}
id="instruction-parameters-container"
>
<ColumnStackLayout noMargin>
{mapFor(0, instructionMetadata.getParametersCount(), i => {
const parameterMetadata = instructionMetadata.getParameter(
i
);
if (
!isParameterVisible(
parameterMetadata,
i,
objectParameterIndex
)
)
return null;
const parameterMetadataType = parameterMetadata.getType();
const ParameterComponent = ParameterRenderingService.getParameterComponent(
parameterMetadataType
);
// Track the field count on screen, to affect the ref to the
// first visible field.
const isFirstVisibleParameterField =
parameterFieldIndex === 0;
parameterFieldIndex++;
return (
<ParameterComponent
instructionMetadata={instructionMetadata}
instruction={instruction}
parameterMetadata={parameterMetadata}
parameterIndex={i}
value={instruction.getParameter(i).getPlainString()}
onChange={value => {
if (
instruction.getParameter(i).getPlainString() !==
value
) {
instruction.setParameter(i, value);
setIsDirty(true);
forceUpdate();
}
}}
onInstructionTypeChanged={forceUpdate}
project={project}
scope={scope}
globalObjectsContainer={globalObjectsContainer}
objectsContainer={objectsContainer}
projectScopedContainersAccessor={
projectScopedContainersAccessor
}
key={i}
parameterRenderingService={ParameterRenderingService}
resourceManagementProps={resourceManagementProps}
ref={field => {
if (isFirstVisibleParameterField) {
firstVisibleField.current = field;
}
}}
/>
);
})}
</ColumnStackLayout>
{getVisibleParametersCount(instructionMetadata, objectName) ===
0 && (
<EmptyMessage>
<Trans>There is nothing to configure.</Trans>
</EmptyMessage>
)}
{isCondition && (
<Toggle
label={<Trans>Invert condition</Trans>}
labelPosition="right"
toggled={instruction.isInverted()}
style={styles.invertToggle}
onToggle={(e, enabled) => {
instruction.setInverted(enabled);
forceUpdate();
}}
/>
<Column expand>
<Text style={styles.description}>
{instructionMetadata.getDescription()}
</Text>
</Column>
</Line>
{instructionExtraInformation && (
<Line>
{instructionExtraInformation.identifier === undefined ? (
<AlertMessage kind={instructionExtraInformation.kind}>
{i18n._(instructionExtraInformation.message)}
</AlertMessage>
) : (
<DismissableAlertMessage
kind={instructionExtraInformation.kind}
identifier={instructionExtraInformation.identifier}
>
{i18n._(instructionExtraInformation.message)}
</DismissableAlertMessage>
)}
</Line>
)}
{tutorialIds.length ? (
{instructionMetadata.isOptionallyAsync() && (
<Toggle
label={
<Trans>
Wait for the action to end before executing the actions
(and subevents) following it
</Trans>
}
labelPosition="right"
toggled={instruction.isAwaited()}
style={styles.invertToggle}
onToggle={(e, enabled) => {
instruction.setAwaited(enabled);
forceUpdate();
}}
/>
)}
{isAnEventFunctionMetadata(instructionMetadata) && (
<Line>
<ColumnStackLayout expand>
{tutorialIds.map(tutorialId => (
<DismissableTutorialMessage
key={tutorialId}
tutorialId={tutorialId}
/>
))}
</ColumnStackLayout>
</Line>
) : null}
<Spacer />
<div
key={instructionType}
style={styles.parametersContainer}
id="instruction-parameters-container"
>
<ColumnStackLayout noMargin>
{mapFor(0, instructionMetadata.getParametersCount(), i => {
const parameterMetadata = instructionMetadata.getParameter(
i
);
if (
!isParameterVisible(
parameterMetadata,
i,
objectParameterIndex
)
)
return null;
const parameterMetadataType = parameterMetadata.getType();
const ParameterComponent = ParameterRenderingService.getParameterComponent(
parameterMetadataType
);
// Track the field count on screen, to affect the ref to the
// first visible field.
const isFirstVisibleParameterField =
parameterFieldIndex === 0;
parameterFieldIndex++;
return (
<ParameterComponent
instructionMetadata={instructionMetadata}
instruction={instruction}
parameterMetadata={parameterMetadata}
parameterIndex={i}
value={instruction.getParameter(i).getPlainString()}
onChange={value => {
if (
instruction.getParameter(i).getPlainString() !==
value
) {
instruction.setParameter(i, value);
setIsDirty(true);
forceUpdate();
}
}}
onInstructionTypeChanged={forceUpdate}
project={project}
scope={scope}
globalObjectsContainer={globalObjectsContainer}
objectsContainer={objectsContainer}
projectScopedContainersAccessor={
projectScopedContainersAccessor
}
key={i}
parameterRenderingService={ParameterRenderingService}
resourceManagementProps={resourceManagementProps}
ref={field => {
if (isFirstVisibleParameterField) {
firstVisibleField.current = field;
}
}}
/>
);
})}
</ColumnStackLayout>
{getVisibleParametersCount(
instructionMetadata,
objectName
) === 0 && (
<EmptyMessage>
<Trans>There is nothing to configure.</Trans>
</EmptyMessage>
)}
{isCondition && (
<Toggle
label={<Trans>Invert condition</Trans>}
labelPosition="right"
toggled={instruction.isInverted()}
style={styles.invertToggle}
onToggle={(e, enabled) => {
instruction.setInverted(enabled);
forceUpdate();
}}
/>
)}
{instructionMetadata.isOptionallyAsync() && (
<Toggle
label={
<Trans>
Wait for the action to end before executing the
actions (and subevents) following it
</Trans>
}
labelPosition="right"
toggled={instruction.isAwaited()}
style={styles.invertToggle}
onToggle={(e, enabled) => {
instruction.setAwaited(enabled);
forceUpdate();
}}
/>
)}
{isAnEventFunctionMetadata(instructionMetadata) && (
<Line>
<FlatButton
key={'open-extension'}
label={
isCondition ? (
<Trans>Edit this condition events</Trans>
) : (
<Trans>Edit this action events</Trans>
)
}
onClick={() => {
openExtension(i18n);
}}
leftIcon={<Edit />}
/>
</Line>
)}
</div>
<Line>
{!noHelpButton && helpPage && (
<HelpButton
helpPagePath={instructionMetadata.getHelpPath()}
<FlatButton
key={'open-extension'}
label={
isCondition ? (
<Trans>Help for this condition</Trans>
<Trans>Edit this condition events</Trans>
) : (
<Trans>Help for this action</Trans>
<Trans>Edit this action events</Trans>
)
}
onClick={() => {
openExtension(i18n);
}}
leftIcon={<Edit />}
/>
)}
</Line>
</Column>
</ScrollView>
)}
</I18n>
</div>
</Line>
)}
</div>
<Line>
{!noHelpButton && helpPage && (
<HelpButton
helpPagePath={instructionMetadata.getHelpPath()}
label={
isCondition ? (
<Trans>Help for this condition</Trans>
) : (
<Trans>Help for this action</Trans>
)
}
/>
)}
</Line>
</Column>
</ScrollView>
)}
</I18n>
);
}
);

View File

@@ -2063,7 +2063,9 @@ const MainFrame = (props: Props) => {
}));
// Re-open first layout as this is usually the entry point for a game.
const firstLayout = currentProject.getFirstLayout();
const firstLayout =
currentProject.getFirstLayout() || // First layout can be empty
currentProject.getLayoutAt(0).getName();
openLayout(firstLayout, {
openSceneEditor: true,
openEventsEditor: true,