Skip to content

Commit

Permalink
Update sceneDefaults.js
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniGrief authored Jul 25, 2023
1 parent 9ccf5fc commit 6609b57
Showing 1 changed file with 9 additions and 27 deletions.
36 changes: 9 additions & 27 deletions src/sceneDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,14 @@ Hooks.on("ready", function() {
});

Hooks.on("preCreateScene", function(scene, data, options) {
// With 0.8.0's document change, we need to update the scene's data differently
// Include backwards compatibility for now
// Note: This hook's parameters changed from {data, options} to {scene, data, options}
if(isNewerVersion("0.8.0", game.data.version)) {
preCreateSceneLegacy(scene, data);
return;
}

if(!options.sdUseOriginal && !isCopy(data)) {
console.log("Scene Defaults | Replacing Defaults");
const preset = Settings.getActivePresetData();
const newData = mergeObject(data, preset, {
insertKeys: true,
insertValues: true,
overwrite: true,
inplace: false
});
console.log("Scene Defaults | Replacing Defaults");
const preset = Settings.getActivePresetData();
const newData = mergeObject(data, preset, {
insertKeys: true,
insertValues: true,
overwrite: true,
inplace: false
});

scene.data.update(newData);
}
scene.updateSource(newData);
});

function preCreateSceneLegacy(data, options) {
if(!options.sdUseOriginal && !isCopy(data)) {
console.log("Scene Defaults | Replacing Defaults");
const newData = Settings.getActivePresetData();
mergeObject(data, newData, true, true, true);
}
};

0 comments on commit 6609b57

Please sign in to comment.