Skip to content

Commit 9cbb13a

Browse files
TOFIX
1 parent f527b30 commit 9cbb13a

File tree

3 files changed

+51
-30
lines changed

3 files changed

+51
-30
lines changed

Extensions/3D/JsExtension.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -818,17 +818,28 @@ module.exports = {
818818
object
819819
.addScopedAction(
820820
'SyncAll',
821-
_('Set crossfade duration'),
822-
_('Set the crossfade duration when switching to a new animation.'),
821+
_('Save the whole game'),
822+
_('Save the wole game.'),
823823
_('Syncall'),
824824
_('Animations and images'),
825825
'res/conditions/animation24.png',
826826
'res/conditions/animation.png'
827827
)
828828
.addCodeOnlyParameter('currentScene', '')
829-
830829
.setFunctionName('saveWholeGame');
831830

831+
object
832+
.addScopedAction(
833+
'LoadAll',
834+
_('loadAll'),
835+
_('Set the crossfade duration when switching to a new animation.'),
836+
_('loadALl'),
837+
_('Animations and images'),
838+
'res/conditions/animation24.png',
839+
'res/conditions/animation.png'
840+
)
841+
.setFunctionName('loadWholeGame');
842+
832843
}
833844

834845
const Cube3DObject = new gd.ObjectJsImplementation();

Extensions/3D/Model3DRuntimeObject.ts

+36-26
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace gdjs {
9595
* @see gdjs.Model3DRuntimeObject3DRenderer.getCenterPoint
9696
*/
9797
_centerPoint: FloatPoint3D | null;
98-
98+
_allSyncData: string;
9999
_animations: Model3DAnimation[];
100100
_currentAnimationIndex: integer = 0;
101101
_animationSpeedScale: float = 1;
@@ -126,6 +126,7 @@ namespace gdjs {
126126
this.onModelChanged(objectData);
127127

128128
this._crossfadeDuration = objectData.content.crossfadeDuration || 0;
129+
this._allSyncData = "";
129130

130131
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
131132
this.onCreated();
@@ -251,34 +252,43 @@ namespace gdjs {
251252
this.onModelChanged(objectData);
252253
}
253254

255+
a(currentScene : RuntimeScene) : void
256+
{
257+
console.log("pomme");
258+
}
259+
254260
saveWholeGame(currentScene : RuntimeScene ): void {
255-
const sceneStack = currentScene.getGame()._sceneStack._stack;
261+
console.log("là on est bons");
256262

257-
const allSyncData: any[] = [];
258-
allSyncData.push(currentScene.getGame().getNetworkSyncData({syncEverythingForWholeGameSaveState: true}));
259-
260-
sceneStack.forEach(scene => {
261-
allSyncData.push(scene.getNetworkSyncData({syncEverythingForWholeGameSaveState:true}))
262-
}
263-
);
264-
sceneStack.forEach(scene => {
265-
const sceneObjects = scene.getAdhocListOfAllInstances();
266-
for (const key in sceneObjects) {
267-
if (sceneObjects.hasOwnProperty(key)) {
268-
const object = sceneObjects[key];
269-
if (object.getNetworkSyncData) {
270-
const syncData = object.getNetworkSyncData(true);
271-
allSyncData.push(syncData);
272-
}
273-
}
274-
}
275-
});
276-
const syncDataJson = JSON.stringify(allSyncData);
277-
this.LoadWholeGame(syncDataJson);
278-
}
279-
LoadWholeGame(syncDataJson: string): void {
263+
// let allSyncData: { gameNetworkSyncData: GameNetworkSyncData } = { gameNetworkSyncData: {} as GameNetworkSyncData };
264+
// const gameData = currentScene.getGame().getNetworkSyncData({syncEverythingForWholeGameSaveState: true});
265+
// if(gameData)
266+
// {
267+
// allSyncData.gameNetworkSyncData = gameData;
268+
// }
269+
// this._allSyncData = JSON.stringify(allSyncData);
270+
// sceneStack.forEach(scene => {
271+
// allSyncData.push(scene.getNetworkSyncData({syncEverythingForWholeGameSaveState:true}))
272+
// }
273+
// );
274+
// sceneStack.forEach(scene => {
275+
// const sceneObjects = scene.getAdhocListOfAllInstances();
276+
// for (const key in sceneObjects) {
277+
// if (sceneObjects.hasOwnProperty(key)) {
278+
// const object = sceneObjects[key];
279+
// if (object.getNetworkSyncData) {
280+
// const syncData = object.getNetworkSyncData(true);
281+
// allSyncData.push(syncData);
282+
// }
283+
// }
284+
// }
285+
// });
286+
// const syncDataJson = JSON.stringify(allSyncData);
287+
// this.LoadWholeGame(syncDataJson);
288+
}
289+
loadWholeGame(): void {
280290
this._runtimeScene._destroy();
281-
const allSyncData = JSON.parse(syncDataJson);
291+
const allSyncData = JSON.parse(this._allSyncData);
282292
const sceneStack = allSyncData[0].ss;
283293
console.log(sceneStack);
284294
let sceneIndex = 1;

GDJS/Runtime/runtimegame.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ namespace gdjs {
13671367
});
13681368
syncData.extVar = extensionsVariablesSyncData;
13691369

1370-
if (
1370+
if (!syncOptions.syncEverythingForWholeGameSaveState &&
13711371
(!syncData.var || syncData.var.length === 0) &&
13721372
!syncData.ss &&
13731373
(!syncData.extVar || Object.keys(syncData.extVar).length === 0)

0 commit comments

Comments
 (0)