mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Fix the event height after adding local variables (#6590)
- Also fix local variable dialog cancel. - Don't show in changelog
This commit is contained in:
@@ -114,7 +114,7 @@ import {
|
||||
} from '../MainFrame/ResourcesWatcher';
|
||||
import { insertInVariablesContainer } from '../Utils/VariablesUtils';
|
||||
import { ProjectScopedContainersAccessor } from '../InstructionOrExpression/EventsScope.flow';
|
||||
import VariablesEditorDialog from '../VariablesList/VariablesEditorDialog';
|
||||
import LocalVariablesDialog from '../VariablesList/LocalVariablesDialog';
|
||||
|
||||
const gd: libGDevelop = global.gd;
|
||||
|
||||
@@ -2102,9 +2102,8 @@ export class EventsSheetComponentWithoutHandle extends React.Component<
|
||||
/>
|
||||
)}
|
||||
{this.state.editedVariable && (
|
||||
<VariablesEditorDialog
|
||||
<LocalVariablesDialog
|
||||
project={project}
|
||||
title={<Trans>Local variables</Trans>}
|
||||
open
|
||||
onCancel={() =>
|
||||
this.setState({
|
||||
@@ -2112,23 +2111,27 @@ export class EventsSheetComponentWithoutHandle extends React.Component<
|
||||
})
|
||||
}
|
||||
onApply={() => {
|
||||
const eventContext = this.state.editedVariable
|
||||
? this.state.editedVariable.eventContext
|
||||
: null;
|
||||
this.setState({
|
||||
editedVariable: null,
|
||||
});
|
||||
if (this._eventsTree)
|
||||
this._eventsTree.forceEventsUpdate();
|
||||
if (this._eventsTree && eventContext) {
|
||||
this._eventsTree.forceEventsUpdate(() => {
|
||||
const positions = this._getChangedEventRows([
|
||||
eventContext.event,
|
||||
]);
|
||||
this._saveChangesToHistory('ADD', {
|
||||
positionsBeforeAction: positions,
|
||||
positionAfterAction: positions,
|
||||
});
|
||||
});
|
||||
}
|
||||
}}
|
||||
tabs={[
|
||||
{
|
||||
id: 'local-variables',
|
||||
label: '',
|
||||
variablesContainer: this.state.editedVariable
|
||||
.variablesContainer,
|
||||
onComputeAllVariableNames: () => [],
|
||||
},
|
||||
]}
|
||||
helpPagePath={'/all-features/variables/local-variables'}
|
||||
preventRefactoringToDeleteInstructions
|
||||
variablesContainer={
|
||||
this.state.editedVariable.variablesContainer
|
||||
}
|
||||
initiallySelectedVariableName={
|
||||
this.state.editedVariable.variableName
|
||||
}
|
||||
|
51
newIDE/app/src/VariablesList/LocalVariablesDialog.js
Normal file
51
newIDE/app/src/VariablesList/LocalVariablesDialog.js
Normal file
@@ -0,0 +1,51 @@
|
||||
// @flow
|
||||
import * as React from 'react';
|
||||
import { Trans } from '@lingui/macro';
|
||||
import VariablesEditorDialog from './VariablesEditorDialog';
|
||||
|
||||
type Props = {|
|
||||
open: boolean,
|
||||
project: gdProject,
|
||||
variablesContainer: gdVariablesContainer,
|
||||
onApply: (selectedVariableName: string | null) => void,
|
||||
onCancel: () => void,
|
||||
initiallySelectedVariableName: string,
|
||||
|};
|
||||
|
||||
const LocalVariablesDialog = ({
|
||||
project,
|
||||
variablesContainer,
|
||||
open,
|
||||
onCancel,
|
||||
onApply,
|
||||
initiallySelectedVariableName,
|
||||
}: Props) => {
|
||||
const tabs = React.useMemo(
|
||||
() => [
|
||||
{
|
||||
id: 'local-variables',
|
||||
label: '',
|
||||
variablesContainer,
|
||||
onComputeAllVariableNames: () => [],
|
||||
},
|
||||
],
|
||||
[variablesContainer]
|
||||
);
|
||||
|
||||
return (
|
||||
<VariablesEditorDialog
|
||||
project={project}
|
||||
open={open}
|
||||
onCancel={onCancel}
|
||||
onApply={onApply}
|
||||
title={<Trans>Local variables</Trans>}
|
||||
tabs={tabs}
|
||||
helpPagePath={'/all-features/variables/local-variables'}
|
||||
preventRefactoringToDeleteInstructions
|
||||
id="local-variables-dialog"
|
||||
initiallySelectedVariableName={initiallySelectedVariableName}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default LocalVariablesDialog;
|
Reference in New Issue
Block a user