Skip to content

Commit 23422df

Browse files
authored
Stop sending the existing events as text to the events generation (#9056)
Don't show in changelog
1 parent fcc3241 commit 23422df

7 files changed

Lines changed: 39 additions & 16 deletions

File tree

newIDE/app/src/AiGeneration/UseGenerateEvents.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ type UseGenerateEventsReturnType = {
2222
generateEvents: ({
2323
eventsDescription: string | null,
2424
eventBatches: Array<EventBatch> | null,
25-
existingEventsAsText: string,
2625
existingEventsJson: string | null,
2726
extensionNamesList: string,
2827
objectsList: string,
@@ -48,7 +47,6 @@ export const useGenerateEvents = ({
4847
eventBatches,
4948
extensionNamesList,
5049
objectsList,
51-
existingEventsAsText,
5250
existingEventsJson,
5351
placementHint,
5452
relatedAiRequestId,
@@ -59,7 +57,6 @@ export const useGenerateEvents = ({
5957
eventBatches: Array<EventBatch> | null,
6058
extensionNamesList: string,
6159
objectsList: string,
62-
existingEventsAsText: string,
6360
existingEventsJson: string | null,
6461
placementHint: string | null,
6562
relatedAiRequestId: string,
@@ -105,7 +102,6 @@ export const useGenerateEvents = ({
105102
eventBatches,
106103
extensionNamesList,
107104
objectsList,
108-
existingEventsAsText,
109105
placementHint,
110106
relatedAiRequestId,
111107
estimatedComplexity,

newIDE/app/src/EditorFunctions/AddSceneEvents.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ describe('add_scene_events', () => {
138138
eventsDescription: 'Some events',
139139
extensionNamesList: '',
140140
objectsList: 'Player',
141-
existingEventsAsText: '',
142141
existingEventsJson: null,
143142
existingEventsJsonUserRelativeKey: null,
144143
resultMessage: 'Successfully added events.',

newIDE/app/src/EditorFunctions/EditorFunctions.spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,6 @@ describe('editorFunctions', () => {
17991799
'When the player presses space, play an explosion sound and show an explosion effect',
18001800
extensionNamesList: '',
18011801
objectsList: 'Player',
1802-
existingEventsAsText: '',
18031802
existingEventsJson: null,
18041803
existingEventsJsonUserRelativeKey: null,
18051804
resultMessage: 'Successfully added explosion events.',
@@ -1904,7 +1903,6 @@ describe('editorFunctions', () => {
19041903
'When the player presses space, play an explosion sound and the boss music',
19051904
extensionNamesList: '',
19061905
objectsList: 'Player',
1907-
existingEventsAsText: '',
19081906
existingEventsJson: null,
19091907
existingEventsJsonUserRelativeKey: null,
19101908
resultMessage: 'Successfully added sound events.',

newIDE/app/src/EditorFunctions/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ export type EventsGenerationOptions = {|
280280
eventBatches: Array<EventBatch> | null,
281281
extensionNamesList: string,
282282
objectsList: string,
283-
existingEventsAsText: string,
284283
existingEventsJson: string | null,
285284
placementHint: string | null,
286285
relatedAiRequestId: string,
@@ -5734,9 +5733,8 @@ const addSceneEvents: EditorFunction = {
57345733
const scene = project.getLayout(sceneName);
57355734
const currentSceneEvents = scene.getEvents();
57365735

5737-
const existingEventsAsText = renderNonTranslatedEventsAsText({
5738-
eventsList: currentSceneEvents,
5739-
});
5736+
// The existing events are sent as JSON only: the generation backend
5737+
// renders them itself (as a bounded EventScript view) for its model.
57405738
const existingEventsJson =
57415739
toolOptions && toolOptions.includeEventsJson
57425740
? serializeToJSON(currentSceneEvents)
@@ -5841,7 +5839,6 @@ const addSceneEvents: EditorFunction = {
58415839
eventBatches: parsedEventBatches,
58425840
extensionNamesList,
58435841
objectsList,
5844-
existingEventsAsText,
58455842
existingEventsJson,
58465843
placementHint,
58475844
relatedAiRequestId,

newIDE/app/src/EventsSheet/EventsTree/TextRenderer/EventScriptRenderer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,12 @@ export const renderEventAsEventScriptLines = ({
600600
lines.push(
601601
`${bodyIndent}# ... ${eventsCount} sub-event(s) (${instructionsCount} action(s)) not shown: read event_ids: ["event-${eventPath}"] to see them.`
602602
);
603+
// A group must contain at least one event for the parser: the marker
604+
// is a comment, so make the (collapsed) body explicit with `pass` to
605+
// keep the rendering valid EventScript.
606+
if (event.getType() === 'BuiltinCommonInstructions::Group') {
607+
lines.push(`${bodyIndent}pass`);
608+
}
603609
}
604610
}
605611

newIDE/app/src/EventsSheet/EventsTree/TextRenderer/EventScriptRenderer.spec.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,35 @@ describe('EventScriptRenderer', () => {
224224
project.delete();
225225
}
226226
});
227+
228+
it('keeps a collapsed group valid EventScript with an explicit `pass`', () => {
229+
const { project } = makeTestProject(gd);
230+
try {
231+
const eventsList = makeEventsList(project, [
232+
{
233+
type: 'BuiltinCommonInstructions::Group',
234+
name: 'My group',
235+
events: sceneStartSerializedEvents,
236+
},
237+
]);
238+
239+
const { text, renderingErrors } = renderEventsAsEventScript({
240+
eventsList,
241+
subEventsDepth: 0,
242+
});
243+
244+
expect(renderingErrors).toEqual([]);
245+
// A group must contain at least one event for the parser: the marker
246+
// alone (a comment) would not do.
247+
expect(text).toBe(
248+
[
249+
'group "My group": # event-0',
250+
' # ... 2 sub-event(s) (3 action(s)) not shown: read event_ids: ["event-0"] to see them.',
251+
' pass',
252+
].join('\n')
253+
);
254+
} finally {
255+
project.delete();
256+
}
257+
});
227258
});

newIDE/app/src/Utils/GDevelopServices/Generation.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ export type AiGeneratedEvent = {
237237
eventBatches: Array<AiGeneratedEventBatch> | null,
238238
extensionNamesList: string,
239239
objectsList: string,
240-
existingEventsAsText: string,
241240
existingEventsJson: string | null,
242241
existingEventsJsonUserRelativeKey: string | null,
243242

@@ -735,7 +734,6 @@ export const createAiGeneratedEvent = async (
735734
eventBatches,
736735
extensionNamesList,
737736
objectsList,
738-
existingEventsAsText,
739737
existingEventsJson,
740738
existingEventsJsonUserRelativeKey,
741739
placementHint,
@@ -752,7 +750,6 @@ export const createAiGeneratedEvent = async (
752750
eventBatches: Array<AiGeneratedEventBatch> | null,
753751
extensionNamesList: string,
754752
objectsList: string,
755-
existingEventsAsText: string,
756753
existingEventsJson: string | null,
757754
existingEventsJsonUserRelativeKey: string | null,
758755
placementHint: string | null,
@@ -774,7 +771,6 @@ export const createAiGeneratedEvent = async (
774771
eventBatches,
775772
extensionNamesList,
776773
objectsList,
777-
existingEventsAsText,
778774
existingEventsJson,
779775
existingEventsJsonUserRelativeKey,
780776
placementHint,

0 commit comments

Comments
 (0)