mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Pass a projectScopedContainers to the EventSheet.
This commit is contained in:
@@ -12,6 +12,12 @@
|
||||
|
||||
namespace gd {
|
||||
|
||||
ObjectsContainersList
|
||||
ObjectsContainersList::MakeNewEmptyObjectsContainersList() {
|
||||
ObjectsContainersList objectsContainersList;
|
||||
return objectsContainersList;
|
||||
}
|
||||
|
||||
ObjectsContainersList
|
||||
ObjectsContainersList::MakeNewObjectsContainersListForProjectAndLayout(
|
||||
const gd::Project& project, const gd::Layout& layout) {
|
||||
|
@@ -30,6 +30,8 @@ class GD_CORE_API ObjectsContainersList {
|
||||
public:
|
||||
virtual ~ObjectsContainersList(){};
|
||||
|
||||
static ObjectsContainersList MakeNewEmptyObjectsContainersList();
|
||||
|
||||
static ObjectsContainersList MakeNewObjectsContainersListForProjectAndLayout(
|
||||
const gd::Project& project, const gd::Layout& layout);
|
||||
|
||||
|
@@ -38,6 +38,16 @@ class ProjectScopedContainers {
|
||||
propertiesContainersList(propertiesContainersList_){};
|
||||
virtual ~ProjectScopedContainers(){};
|
||||
|
||||
static ProjectScopedContainers
|
||||
MakeNewEmptyProjectScopedContainers() {
|
||||
ProjectScopedContainers projectScopedContainers(
|
||||
ObjectsContainersList::MakeNewEmptyObjectsContainersList(),
|
||||
VariablesContainersList::MakeNewEmptyVariablesContainersList(),
|
||||
PropertiesContainersList::MakeNewEmptyPropertiesContainersList());
|
||||
|
||||
return projectScopedContainers;
|
||||
}
|
||||
|
||||
static ProjectScopedContainers
|
||||
MakeNewProjectScopedContainersForProjectAndLayout(const gd::Project &project,
|
||||
const gd::Layout &layout) {
|
||||
|
@@ -636,6 +636,7 @@ interface ObjectsContainersList {
|
||||
};
|
||||
|
||||
interface ProjectScopedContainers {
|
||||
[Value] ProjectScopedContainers STATIC_MakeNewEmptyProjectScopedContainers();
|
||||
[Value] ProjectScopedContainers STATIC_MakeNewProjectScopedContainersForProjectAndLayout(
|
||||
[Const, Ref] Project project,
|
||||
[Const, Ref] Layout layout);
|
||||
|
@@ -567,6 +567,8 @@ typedef ExtensionAndMetadata<ExpressionMetadata> ExtensionAndExpressionMetadata;
|
||||
MakeNewObjectsContainersListForProjectAndLayout
|
||||
#define STATIC_MakeNewObjectsContainersListForContainers \
|
||||
MakeNewObjectsContainersListForContainers
|
||||
#define STATIC_MakeNewEmptyProjectScopedContainers \
|
||||
MakeNewEmptyProjectScopedContainers
|
||||
#define STATIC_MakeNewProjectScopedContainersForProjectAndLayout \
|
||||
MakeNewProjectScopedContainersForProjectAndLayout
|
||||
#define STATIC_MakeNewProjectScopedContainersFor \
|
||||
|
1
GDevelop.js/types.d.ts
vendored
1
GDevelop.js/types.d.ts
vendored
@@ -582,6 +582,7 @@ export class ObjectsContainersList extends EmscriptenObject {
|
||||
}
|
||||
|
||||
export class ProjectScopedContainers extends EmscriptenObject {
|
||||
static makeNewEmptyProjectScopedContainers(): ProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForProjectAndLayout(project: Project, layout: Layout): ProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersFor(globalObjectsContainer: ObjectsContainer, objectsContainer: ObjectsContainer): ProjectScopedContainers;
|
||||
addPropertiesContainer(propertiesContainer: PropertiesContainer): ProjectScopedContainers;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
// Automatically generated by GDevelop.js/scripts/generate-types.js
|
||||
declare class gdProjectScopedContainers {
|
||||
static makeNewEmptyProjectScopedContainers(): gdProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersForProjectAndLayout(project: gdProject, layout: gdLayout): gdProjectScopedContainers;
|
||||
static makeNewProjectScopedContainersFor(globalObjectsContainer: gdObjectsContainer, objectsContainer: gdObjectsContainer): gdProjectScopedContainers;
|
||||
addPropertiesContainer(propertiesContainer: gdPropertiesContainer): gdProjectScopedContainers;
|
||||
|
@@ -38,6 +38,8 @@ import ExtensionEditIcon from '../UI/CustomSvgIcons/ExtensionEdit';
|
||||
import Tune from '../UI/CustomSvgIcons/Tune';
|
||||
import Mark from '../UI/CustomSvgIcons/Mark';
|
||||
import newNameGenerator from '../Utils/NewNameGenerator';
|
||||
import { getProjectScopedContainersFromScope } from '../InstructionOrExpression/EventsScope.flow';
|
||||
|
||||
const gd: libGDevelop = global.gd;
|
||||
|
||||
export type ExtensionItemConfigurationAttribute =
|
||||
@@ -1109,6 +1111,7 @@ export default class EventsFunctionsExtensionEditor extends React.Component<
|
||||
|
||||
render() {
|
||||
const { project, eventsFunctionsExtension } = this.props;
|
||||
|
||||
const {
|
||||
selectedEventsFunction,
|
||||
selectedEventsBasedBehavior,
|
||||
@@ -1119,6 +1122,21 @@ export default class EventsFunctionsExtensionEditor extends React.Component<
|
||||
extensionFunctionSelectorDialogOpen,
|
||||
} = this.state;
|
||||
|
||||
const scope = {
|
||||
project,
|
||||
layout: null,
|
||||
externalEvents: null,
|
||||
eventsFunctionsExtension,
|
||||
eventsBasedBehavior: selectedEventsBasedBehavior,
|
||||
eventsBasedObject: selectedEventsBasedObject,
|
||||
eventsFunction: selectedEventsFunction,
|
||||
};
|
||||
const projectScopedContainers = getProjectScopedContainersFromScope(
|
||||
scope,
|
||||
this._globalObjectsContainer,
|
||||
this._objectsContainer
|
||||
);
|
||||
|
||||
const selectedEventsBasedEntity =
|
||||
selectedEventsBasedBehavior || selectedEventsBasedObject;
|
||||
|
||||
@@ -1210,17 +1228,10 @@ export default class EventsFunctionsExtensionEditor extends React.Component<
|
||||
key={selectedEventsFunction.ptr}
|
||||
ref={editor => (this.editor = editor)}
|
||||
project={project}
|
||||
scope={{
|
||||
project,
|
||||
layout: null,
|
||||
externalEvents: null,
|
||||
eventsFunctionsExtension,
|
||||
eventsBasedBehavior: selectedEventsBasedBehavior,
|
||||
eventsBasedObject: selectedEventsBasedObject,
|
||||
eventsFunction: selectedEventsFunction,
|
||||
}}
|
||||
scope={scope}
|
||||
globalObjectsContainer={this._globalObjectsContainer}
|
||||
objectsContainer={this._objectsContainer}
|
||||
projectScopedContainers={projectScopedContainers}
|
||||
events={selectedEventsFunction.getEvents()}
|
||||
onOpenExternalEvents={() => {}}
|
||||
onOpenLayout={() => {}}
|
||||
|
@@ -79,10 +79,7 @@ import PreferencesContext, {
|
||||
} from '../MainFrame/Preferences/PreferencesContext';
|
||||
import EventsFunctionExtractorDialog from './EventsFunctionExtractor/EventsFunctionExtractorDialog';
|
||||
import { createNewInstructionForEventsFunction } from './EventsFunctionExtractor';
|
||||
import {
|
||||
getProjectScopedContainersFromScope,
|
||||
type EventsScope,
|
||||
} from '../InstructionOrExpression/EventsScope.flow';
|
||||
import { type EventsScope } from '../InstructionOrExpression/EventsScope.flow';
|
||||
import {
|
||||
pasteEventsFromClipboardInSelection,
|
||||
copySelectionToClipboard,
|
||||
@@ -132,6 +129,7 @@ type Props = {|
|
||||
scope: EventsScope,
|
||||
globalObjectsContainer: gdObjectsContainer,
|
||||
objectsContainer: gdObjectsContainer,
|
||||
projectScopedContainers: gdProjectScopedContainers,
|
||||
events: gdEventsList,
|
||||
setToolbar: (?React.Node) => void,
|
||||
onOpenSettings?: ?() => void,
|
||||
@@ -1519,13 +1517,8 @@ export class EventsSheetComponentWithoutHandle extends React.Component<
|
||||
};
|
||||
|
||||
_openEventsContextAnalyzer = () => {
|
||||
const { scope, globalObjectsContainer, objectsContainer } = this.props;
|
||||
const { projectScopedContainers } = this.props;
|
||||
|
||||
const projectScopedContainers = getProjectScopedContainersFromScope(
|
||||
scope,
|
||||
globalObjectsContainer,
|
||||
objectsContainer
|
||||
);
|
||||
const eventsContextAnalyzer = new gd.EventsContextAnalyzer(
|
||||
gd.JsPlatform.get()
|
||||
);
|
||||
@@ -2000,19 +1993,14 @@ export class EventsSheetComponentWithoutHandle extends React.Component<
|
||||
}
|
||||
instruction.setParameter(parameterIndex, value);
|
||||
|
||||
const projectScopedContainers = getProjectScopedContainersFromScope(
|
||||
scope,
|
||||
globalObjectsContainer,
|
||||
objectsContainer
|
||||
);
|
||||
switchBetweenUnifiedInstructionIfNeeded(
|
||||
project.getCurrentPlatform(),
|
||||
projectScopedContainers,
|
||||
this.props.projectScopedContainers,
|
||||
instruction
|
||||
);
|
||||
switchBetweenUnifiedObjectInstructionIfNeeded(
|
||||
project.getCurrentPlatform(),
|
||||
projectScopedContainers,
|
||||
this.props.projectScopedContainers,
|
||||
instruction
|
||||
);
|
||||
|
||||
|
@@ -12,7 +12,7 @@ export type EventsScope = {|
|
||||
eventsFunctionsExtension?: gdEventsFunctionsExtension,
|
||||
eventsBasedBehavior?: ?gdEventsBasedBehavior,
|
||||
eventsBasedObject?: ?gdEventsBasedObject,
|
||||
eventsFunction?: gdEventsFunction,
|
||||
eventsFunction?: ?gdEventsFunction,
|
||||
|};
|
||||
|
||||
export const getProjectScopedContainersFromScope = (
|
||||
|
@@ -6,6 +6,7 @@ import {
|
||||
type RenderEditorContainerProps,
|
||||
type RenderEditorContainerPropsWithRef,
|
||||
} from './BaseEditor';
|
||||
import { getProjectScopedContainersFromScope } from '../../InstructionOrExpression/EventsScope.flow';
|
||||
|
||||
export class EventsEditorContainer extends React.Component<RenderEditorContainerProps> {
|
||||
editor: ?EventsSheetInterface;
|
||||
@@ -78,6 +79,16 @@ export class EventsEditorContainer extends React.Component<RenderEditorContainer
|
||||
return <div>No layout called {projectItemName} found!</div>;
|
||||
}
|
||||
|
||||
const scope = {
|
||||
project,
|
||||
layout,
|
||||
};
|
||||
const projectScopedContainers = getProjectScopedContainersFromScope(
|
||||
scope,
|
||||
project,
|
||||
layout
|
||||
);
|
||||
|
||||
return (
|
||||
<EventsSheet
|
||||
ref={editor => (this.editor = editor)}
|
||||
@@ -89,12 +100,10 @@ export class EventsEditorContainer extends React.Component<RenderEditorContainer
|
||||
onBeginCreateEventsFunction={this.onBeginCreateEventsFunction}
|
||||
unsavedChanges={this.props.unsavedChanges}
|
||||
project={project}
|
||||
scope={{
|
||||
project,
|
||||
layout,
|
||||
}}
|
||||
scope={scope}
|
||||
globalObjectsContainer={project}
|
||||
objectsContainer={layout}
|
||||
projectScopedContainers={projectScopedContainers}
|
||||
events={layout.getEvents()}
|
||||
onOpenExternalEvents={this.props.onOpenExternalEvents}
|
||||
isActive={this.props.isActive}
|
||||
|
@@ -21,6 +21,7 @@ import {
|
||||
registerOnResourceExternallyChangedCallback,
|
||||
unregisterOnResourceExternallyChangedCallback,
|
||||
} from '../ResourcesWatcher';
|
||||
import { getProjectScopedContainersFromScope } from '../../InstructionOrExpression/EventsScope.flow';
|
||||
|
||||
const styles = {
|
||||
container: {
|
||||
@@ -159,6 +160,12 @@ export class ExternalEventsEditorContainer extends React.Component<
|
||||
return <div>No external events called {projectItemName} found!</div>;
|
||||
}
|
||||
|
||||
const scope = {
|
||||
project,
|
||||
layout,
|
||||
externalEvents,
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={styles.container}>
|
||||
{layout && (
|
||||
@@ -172,13 +179,14 @@ export class ExternalEventsEditorContainer extends React.Component<
|
||||
onBeginCreateEventsFunction={this.onBeginCreateEventsFunction}
|
||||
unsavedChanges={this.props.unsavedChanges}
|
||||
project={project}
|
||||
scope={{
|
||||
project,
|
||||
layout,
|
||||
externalEvents,
|
||||
}}
|
||||
scope={scope}
|
||||
globalObjectsContainer={project}
|
||||
objectsContainer={layout}
|
||||
projectScopedContainers={getProjectScopedContainersFromScope(
|
||||
scope,
|
||||
project,
|
||||
layout
|
||||
)}
|
||||
events={externalEvents.getEvents()}
|
||||
onOpenSettings={this.openExternalPropertiesDialog}
|
||||
settingsIcon={editSceneIconReactNode}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
// @flow
|
||||
import { getProjectScopedContainersFromScope } from '../InstructionOrExpression/EventsScope.flow';
|
||||
|
||||
/*::
|
||||
export type TestProject = {|
|
||||
@@ -19,6 +20,7 @@ export type TestProject = {|
|
||||
spriteObjectWithoutBehaviors: gdObject,
|
||||
testSpriteObjectInstance: gdInitialInstance,
|
||||
testLayout: gdLayout,
|
||||
testSceneProjectScopedContainers: gdProjectScopedContainers,
|
||||
group1: gdObjectGroup,
|
||||
group2: gdObjectGroup,
|
||||
group4WithLongsNames: gdObjectGroup,
|
||||
@@ -29,6 +31,7 @@ export type TestProject = {|
|
||||
testExternalEvents1: gdExternalEvents,
|
||||
testExternalEvents2: gdExternalEvents,
|
||||
emptyLayout: gdLayout,
|
||||
emptySceneProjectScopedContainers: gdProjectScopedContainers,
|
||||
emptyEventsList: gdEventsList,
|
||||
testEventsFunction: gdEventsFunction,
|
||||
testEventsFunctionsExtension: gdEventsFunctionsExtension,
|
||||
@@ -904,6 +907,24 @@ export const makeTestProject = (gd /*: libGDevelop */) /*: TestProject */ => {
|
||||
'whatever-this-is-not-recognised'
|
||||
);
|
||||
|
||||
const testSceneProjectScopedContainers = getProjectScopedContainersFromScope(
|
||||
{
|
||||
project,
|
||||
layout: testLayout,
|
||||
},
|
||||
project,
|
||||
testLayout
|
||||
);
|
||||
|
||||
const emptySceneProjectScopedContainers = getProjectScopedContainersFromScope(
|
||||
{
|
||||
project,
|
||||
layout: emptyLayout,
|
||||
},
|
||||
project,
|
||||
emptyLayout
|
||||
);
|
||||
|
||||
return {
|
||||
project,
|
||||
shapePainterObjectConfiguration: shapePainterObject.getConfiguration(),
|
||||
@@ -922,6 +943,7 @@ export const makeTestProject = (gd /*: libGDevelop */) /*: TestProject */ => {
|
||||
spriteObjectWithBehaviors,
|
||||
spriteObjectWithoutBehaviors,
|
||||
testLayout,
|
||||
testSceneProjectScopedContainers,
|
||||
group1,
|
||||
group2,
|
||||
group4WithLongsNames,
|
||||
@@ -932,6 +954,7 @@ export const makeTestProject = (gd /*: libGDevelop */) /*: TestProject */ => {
|
||||
testExternalEvents1,
|
||||
testExternalEvents2,
|
||||
emptyLayout,
|
||||
emptySceneProjectScopedContainers,
|
||||
emptyEventsList,
|
||||
testEventsFunction,
|
||||
testEventsFunctionsExtension,
|
||||
|
@@ -22,6 +22,7 @@ export const DefaultNoScope = () => (
|
||||
scope={{ project: testProject.project, layout: testProject.testLayout }}
|
||||
globalObjectsContainer={testProject.project}
|
||||
objectsContainer={testProject.testLayout}
|
||||
projectScopedContainers={testProject.testSceneProjectScopedContainers}
|
||||
events={testProject.testLayout.getEvents()}
|
||||
onOpenExternalEvents={action('Open external events')}
|
||||
resourceManagementProps={fakeResourceManagementProps}
|
||||
@@ -48,6 +49,7 @@ export const EmptyNoScope = () => (
|
||||
}}
|
||||
globalObjectsContainer={testProject.project}
|
||||
objectsContainer={testProject.emptyLayout}
|
||||
projectScopedContainers={testProject.emptySceneProjectScopedContainers}
|
||||
events={testProject.emptyLayout.getEvents()}
|
||||
onOpenExternalEvents={action('Open external events')}
|
||||
resourceManagementProps={fakeResourceManagementProps}
|
||||
|
Reference in New Issue
Block a user