mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Hot-reload events when an EBO is installed or updated.
This commit is contained in:
@@ -16,7 +16,8 @@ type SwitchToSceneEditionOptions = {|
|
||||
externalLayoutName: string | null,
|
||||
eventsBasedObjectType: string | null,
|
||||
eventsBasedObjectVariantName: string | null,
|
||||
forceFullDataReload?: boolean,
|
||||
hotReload: boolean,
|
||||
projectDataOnlyExport: boolean,
|
||||
|};
|
||||
|
||||
let onAttachToPreview: null | (AttachToPreviewOptions => void) = null;
|
||||
@@ -35,7 +36,8 @@ export const switchToSceneEdition = ({
|
||||
externalLayoutName,
|
||||
eventsBasedObjectType,
|
||||
eventsBasedObjectVariantName,
|
||||
forceFullDataReload,
|
||||
hotReload,
|
||||
projectDataOnlyExport,
|
||||
}: SwitchToSceneEditionOptions) => {
|
||||
if (!onSwitchToSceneEdition)
|
||||
throw new Error('No EmbeddedGameFrame registered.');
|
||||
@@ -45,7 +47,8 @@ export const switchToSceneEdition = ({
|
||||
externalLayoutName,
|
||||
eventsBasedObjectType,
|
||||
eventsBasedObjectVariantName,
|
||||
forceFullDataReload,
|
||||
hotReload,
|
||||
projectDataOnlyExport,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -92,10 +95,11 @@ export const EmbeddedGameFrame = ({
|
||||
externalLayoutName,
|
||||
eventsBasedObjectType,
|
||||
eventsBasedObjectVariantName,
|
||||
forceFullDataReload,
|
||||
hotReload,
|
||||
projectDataOnlyExport,
|
||||
} = options;
|
||||
|
||||
if (!previewIndexHtmlLocation || forceFullDataReload) {
|
||||
if (!previewIndexHtmlLocation || hotReload) {
|
||||
console.info(
|
||||
eventsBasedObjectType
|
||||
? `Launching in-game edition preview for variant "${eventsBasedObjectVariantName ||
|
||||
@@ -112,8 +116,8 @@ export const EmbeddedGameFrame = ({
|
||||
externalLayoutName,
|
||||
eventsBasedObjectType,
|
||||
eventsBasedObjectVariantName,
|
||||
hotReload: forceFullDataReload || false,
|
||||
projectDataOnlyExport: forceFullDataReload || false,
|
||||
hotReload,
|
||||
projectDataOnlyExport,
|
||||
});
|
||||
} else {
|
||||
console.info(
|
||||
|
@@ -60,7 +60,7 @@ export type AskAiEditorInterface = {|
|
||||
objectWithContext: ObjectWithContext
|
||||
) => void,
|
||||
onSceneObjectsDeleted: (scene: gdLayout) => void,
|
||||
forceInGameEditorFullDataReload: () => void,
|
||||
forceInGameEditorHotReload: ({| projectDataOnlyExport: boolean |}) => void,
|
||||
|};
|
||||
|
||||
const noop = () => {};
|
||||
@@ -112,7 +112,7 @@ export const AskAi = React.memo<Props>(
|
||||
onEventsBasedObjectChildrenEdited: noop,
|
||||
onSceneObjectEdited: noop,
|
||||
onSceneObjectsDeleted: noop,
|
||||
forceInGameEditorFullDataReload: noop,
|
||||
forceInGameEditorHotReload: noop,
|
||||
}));
|
||||
|
||||
const aiRequestChatRef = React.useRef<AiRequestChatInterface | null>(
|
||||
|
@@ -56,12 +56,9 @@ export class CustomObjectEditorContainer extends React.Component<RenderEditorCon
|
||||
});
|
||||
|
||||
if (gameEditorMode === 'embedded-game' && projectItemName) {
|
||||
switchToSceneEdition({
|
||||
editorId,
|
||||
sceneName: null,
|
||||
externalLayoutName: null,
|
||||
eventsBasedObjectType: this.getEventsBasedObjectType() || null,
|
||||
eventsBasedObjectVariantName: this.getVariantName(),
|
||||
this._switchToSceneEdition({
|
||||
hotReload: false,
|
||||
projectDataOnlyExport: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -78,18 +75,27 @@ export class CustomObjectEditorContainer extends React.Component<RenderEditorCon
|
||||
|
||||
componentDidUpdate(prevProps: RenderEditorContainerProps) {
|
||||
if (!prevProps.isActive && this.props.isActive) {
|
||||
this._switchToSceneEdition({ forceFullDataReload: false });
|
||||
this._switchToSceneEdition({
|
||||
hotReload: false,
|
||||
projectDataOnlyExport: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
forceInGameEditorFullDataReload() {
|
||||
this._switchToSceneEdition({ forceFullDataReload: true });
|
||||
forceInGameEditorHotReload({
|
||||
projectDataOnlyExport,
|
||||
}: {|
|
||||
projectDataOnlyExport: boolean,
|
||||
|}) {
|
||||
this._switchToSceneEdition({ hotReload: true, projectDataOnlyExport });
|
||||
}
|
||||
|
||||
_switchToSceneEdition({
|
||||
forceFullDataReload,
|
||||
hotReload,
|
||||
projectDataOnlyExport,
|
||||
}: {|
|
||||
forceFullDataReload: boolean,
|
||||
hotReload: boolean,
|
||||
projectDataOnlyExport: boolean,
|
||||
|}): void {
|
||||
const { projectItemName, editorId } = this.props;
|
||||
this.props.setPreviewedLayout({
|
||||
@@ -106,7 +112,8 @@ export class CustomObjectEditorContainer extends React.Component<RenderEditorCon
|
||||
externalLayoutName: null,
|
||||
eventsBasedObjectType: this.getEventsBasedObjectType() || null,
|
||||
eventsBasedObjectVariantName: this.getVariantName(),
|
||||
forceFullDataReload,
|
||||
hotReload,
|
||||
projectDataOnlyExport,
|
||||
});
|
||||
if (this.editor) {
|
||||
this.editor.onEditorReloaded();
|
||||
|
@@ -61,7 +61,11 @@ export class DebuggerEditorContainer extends React.Component<
|
||||
// No thing to be done.
|
||||
}
|
||||
|
||||
forceInGameEditorFullDataReload() {
|
||||
forceInGameEditorHotReload({
|
||||
projectDataOnlyExport,
|
||||
}: {|
|
||||
projectDataOnlyExport: boolean,
|
||||
|}) {
|
||||
// No thing to be done.
|
||||
}
|
||||
|
||||
|
@@ -67,7 +67,11 @@ export class EventsEditorContainer extends React.Component<RenderEditorContainer
|
||||
// No thing to be done.
|
||||
}
|
||||
|
||||
forceInGameEditorFullDataReload() {
|
||||
forceInGameEditorHotReload({
|
||||
projectDataOnlyExport,
|
||||
}: {|
|
||||
projectDataOnlyExport: boolean,
|
||||
|}) {
|
||||
// No thing to be done.
|
||||
}
|
||||
|
||||
|
@@ -50,7 +50,11 @@ export class EventsFunctionsExtensionEditorContainer extends React.Component<Ren
|
||||
// No thing to be done.
|
||||
}
|
||||
|
||||
forceInGameEditorFullDataReload() {
|
||||
forceInGameEditorHotReload({
|
||||
projectDataOnlyExport,
|
||||
}: {|
|
||||
projectDataOnlyExport: boolean,
|
||||
|}) {
|
||||
// No thing to be done.
|
||||
}
|
||||
|
||||
|
@@ -94,7 +94,11 @@ export class ExternalEventsEditorContainer extends React.Component<
|
||||
// No thing to be done.
|
||||
}
|
||||
|
||||
forceInGameEditorFullDataReload() {
|
||||
forceInGameEditorHotReload({
|
||||
projectDataOnlyExport,
|
||||
}: {|
|
||||
projectDataOnlyExport: boolean,
|
||||
|}) {
|
||||
// No thing to be done.
|
||||
}
|
||||
|
||||
|
@@ -76,12 +76,9 @@ export class ExternalLayoutEditorContainer extends React.Component<
|
||||
});
|
||||
|
||||
if (gameEditorMode === 'embedded-game' && layout && projectItemName) {
|
||||
switchToSceneEdition({
|
||||
editorId,
|
||||
sceneName: layout.getName(),
|
||||
externalLayoutName: projectItemName,
|
||||
eventsBasedObjectType: null,
|
||||
eventsBasedObjectVariantName: null,
|
||||
this._switchToSceneEdition({
|
||||
hotReload: false,
|
||||
projectDataOnlyExport: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -97,18 +94,27 @@ export class ExternalLayoutEditorContainer extends React.Component<
|
||||
|
||||
componentDidUpdate(prevProps: RenderEditorContainerProps) {
|
||||
if (!prevProps.isActive && this.props.isActive) {
|
||||
this._switchToSceneEdition({ forceFullDataReload: false });
|
||||
this._switchToSceneEdition({
|
||||
hotReload: false,
|
||||
projectDataOnlyExport: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
forceInGameEditorFullDataReload() {
|
||||
this._switchToSceneEdition({ forceFullDataReload: true });
|
||||
forceInGameEditorHotReload({
|
||||
projectDataOnlyExport,
|
||||
}: {|
|
||||
projectDataOnlyExport: boolean,
|
||||
|}) {
|
||||
this._switchToSceneEdition({ hotReload: true, projectDataOnlyExport });
|
||||
}
|
||||
|
||||
_switchToSceneEdition({
|
||||
forceFullDataReload,
|
||||
hotReload,
|
||||
projectDataOnlyExport,
|
||||
}: {|
|
||||
forceFullDataReload: boolean,
|
||||
hotReload: boolean,
|
||||
projectDataOnlyExport: boolean,
|
||||
|}): void {
|
||||
const { projectItemName, editorId } = this.props;
|
||||
const layout = this.getLayout();
|
||||
@@ -126,7 +132,8 @@ export class ExternalLayoutEditorContainer extends React.Component<
|
||||
externalLayoutName: projectItemName,
|
||||
eventsBasedObjectType: null,
|
||||
eventsBasedObjectVariantName: null,
|
||||
forceFullDataReload,
|
||||
hotReload,
|
||||
projectDataOnlyExport,
|
||||
});
|
||||
if (this.editor) {
|
||||
this.editor.onEditorReloaded();
|
||||
|
@@ -174,7 +174,7 @@ export type HomePageEditorInterface = {|
|
||||
objectWithContext: ObjectWithContext
|
||||
) => void,
|
||||
onSceneObjectsDeleted: (scene: gdLayout) => void,
|
||||
forceInGameEditorFullDataReload: () => void,
|
||||
forceInGameEditorHotReload: ({| projectDataOnlyExport: boolean |}) => void,
|
||||
|};
|
||||
|
||||
export const HomePage = React.memo<Props>(
|
||||
@@ -497,7 +497,7 @@ export const HomePage = React.memo<Props>(
|
||||
onEventsBasedObjectChildrenEdited,
|
||||
onSceneObjectEdited,
|
||||
onSceneObjectsDeleted,
|
||||
forceInGameEditorFullDataReload: noop,
|
||||
forceInGameEditorHotReload: noop,
|
||||
}));
|
||||
|
||||
const onUserSurveyStarted = React.useCallback(() => {
|
||||
|
@@ -45,7 +45,11 @@ export class ResourcesEditorContainer extends React.Component<RenderEditorContai
|
||||
// No thing to be done.
|
||||
}
|
||||
|
||||
forceInGameEditorFullDataReload() {
|
||||
forceInGameEditorHotReload({
|
||||
projectDataOnlyExport,
|
||||
}: {|
|
||||
projectDataOnlyExport: boolean,
|
||||
|}) {
|
||||
// No thing to be done.
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,7 @@ export class SceneEditorContainer extends React.Component<RenderEditorContainerP
|
||||
|
||||
componentDidMount() {
|
||||
if (this.props.isActive) {
|
||||
const { projectItemName, editorId } = this.props;
|
||||
const { projectItemName } = this.props;
|
||||
this.props.setPreviewedLayout({
|
||||
layoutName: projectItemName || null,
|
||||
externalLayoutName: null,
|
||||
@@ -42,12 +42,9 @@ export class SceneEditorContainer extends React.Component<RenderEditorContainerP
|
||||
});
|
||||
|
||||
if (gameEditorMode === 'embedded-game' && projectItemName) {
|
||||
switchToSceneEdition({
|
||||
editorId,
|
||||
sceneName: projectItemName,
|
||||
externalLayoutName: null,
|
||||
eventsBasedObjectType: null,
|
||||
eventsBasedObjectVariantName: null,
|
||||
this._switchToSceneEdition({
|
||||
hotReload: false,
|
||||
projectDataOnlyExport: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -55,18 +52,27 @@ export class SceneEditorContainer extends React.Component<RenderEditorContainerP
|
||||
|
||||
componentDidUpdate(prevProps: RenderEditorContainerProps) {
|
||||
if (!prevProps.isActive && this.props.isActive) {
|
||||
this._switchToSceneEdition({ forceFullDataReload: false });
|
||||
this._switchToSceneEdition({
|
||||
hotReload: false,
|
||||
projectDataOnlyExport: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
forceInGameEditorFullDataReload() {
|
||||
this._switchToSceneEdition({ forceFullDataReload: true });
|
||||
forceInGameEditorHotReload({
|
||||
projectDataOnlyExport,
|
||||
}: {|
|
||||
projectDataOnlyExport: boolean,
|
||||
|}) {
|
||||
this._switchToSceneEdition({ hotReload: true, projectDataOnlyExport });
|
||||
}
|
||||
|
||||
_switchToSceneEdition({
|
||||
forceFullDataReload,
|
||||
hotReload,
|
||||
projectDataOnlyExport,
|
||||
}: {|
|
||||
forceFullDataReload: boolean,
|
||||
hotReload: boolean,
|
||||
projectDataOnlyExport: boolean,
|
||||
|}): void {
|
||||
const { projectItemName, editorId } = this.props;
|
||||
this.props.setPreviewedLayout({
|
||||
@@ -82,7 +88,8 @@ export class SceneEditorContainer extends React.Component<RenderEditorContainerP
|
||||
externalLayoutName: null,
|
||||
eventsBasedObjectType: null,
|
||||
eventsBasedObjectVariantName: null,
|
||||
forceFullDataReload,
|
||||
hotReload,
|
||||
projectDataOnlyExport,
|
||||
});
|
||||
if (this.editor) {
|
||||
this.editor.onEditorReloaded();
|
||||
|
@@ -1417,6 +1417,7 @@ const MainFrame = (props: Props) => {
|
||||
if (!currentProject) {
|
||||
return;
|
||||
}
|
||||
let hasEventsBasedObject = false;
|
||||
for (const extensionName of extensionNames) {
|
||||
const eventsBasedObjects = currentProject
|
||||
.getEventsFunctionsExtension(extensionName)
|
||||
@@ -1442,6 +1443,18 @@ const MainFrame = (props: Props) => {
|
||||
extensionName
|
||||
),
|
||||
}));
|
||||
|
||||
hasEventsBasedObject =
|
||||
hasEventsBasedObject || eventsBasedObjects.getCount() > 0;
|
||||
}
|
||||
if (hasEventsBasedObject) {
|
||||
// TODO This won't do anything if the current tab is not a scene tab.
|
||||
const { editorRef } = getCurrentTab(state.editorTabs);
|
||||
if (editorRef) {
|
||||
editorRef.forceInGameEditorHotReload({
|
||||
projectDataOnlyExport: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2464,7 +2477,7 @@ const MainFrame = (props: Props) => {
|
||||
() => {
|
||||
const { editorRef } = getCurrentTab(state.editorTabs);
|
||||
if (editorRef) {
|
||||
editorRef.forceInGameEditorFullDataReload();
|
||||
editorRef.forceInGameEditorHotReload({ projectDataOnlyExport: true });
|
||||
}
|
||||
},
|
||||
[state.editorTabs]
|
||||
|
Reference in New Issue
Block a user