From c5e3d1e7e402a206d930c5b8cc3583f6ad7c69ac Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Mon, 18 Oct 2021 18:28:33 +0200 Subject: [PATCH] Move modified properties to editor-settings and rename --- src/editor/nodes/AudioParamsNode.js | 2 +- src/editor/nodes/EditorNodeMixin.js | 30 ++-- src/editor/nodes/SceneNode.js | 5 +- src/ui/properties/useAudioParams.js | 4 +- test/integration/snapshots/Editor.test.js.md | 159 +++---------------- 5 files changed, 38 insertions(+), 162 deletions(-) diff --git a/src/editor/nodes/AudioParamsNode.js b/src/editor/nodes/AudioParamsNode.js index 78f6d167..acfdb29c 100644 --- a/src/editor/nodes/AudioParamsNode.js +++ b/src/editor/nodes/AudioParamsNode.js @@ -36,7 +36,7 @@ export default function AudioParamsNode(Type) { set overrideAudioSettings(overriden) { this._overrideAudioSettings = overriden; if (!overriden) { - this.enabledProperties = {}; + this.modifiedProperties = {}; } } diff --git a/src/editor/nodes/EditorNodeMixin.js b/src/editor/nodes/EditorNodeMixin.js index 96927b3f..762c5a6e 100644 --- a/src/editor/nodes/EditorNodeMixin.js +++ b/src/editor/nodes/EditorNodeMixin.js @@ -64,12 +64,7 @@ export default function EditorNodeMixin(Object3DClass) { if (editorSettingsComponent) { node.enabled = editorSettingsComponent.props.enabled; - } - - const enabledProperties = json.components.find(c => c.name === "enabled-properties"); - - if (enabledProperties) { - node.enabledProperties = enabledProperties.props.enabled; + node.modifiedProperties = editorSettingsComponent.props.modifiedProperties; } } @@ -95,7 +90,7 @@ export default function EditorNodeMixin(Object3DClass) { this.loadingCube = null; this.errorIcon = null; this.issues = []; - this._enabledProperties = {}; + this._modifiedProperties = {}; } clone(recursive) { @@ -127,7 +122,7 @@ export default function EditorNodeMixin(Object3DClass) { this.issues = source.issues.slice(); this._visible = source._visible; this.enabled = source.enabled; - this._enabledProperties = source.enabledProperties; + this._modifiedProperties = source.modifiedProperties; return this; } @@ -195,13 +190,8 @@ export default function EditorNodeMixin(Object3DClass) { { name: "editor-settings", props: { - enabled: this.enabled - } - }, - { - name: "enabled-properties", - props: { - enabled: this.enabledProperties + enabled: this.enabled, + modifiedProperties: this.modifiedProperties } } ] @@ -473,15 +463,15 @@ export default function EditorNodeMixin(Object3DClass) { } optionalPropertyExportValue(propName) { - return this.enabledProperties[propName] ? this[propName] : undefined; + return this.modifiedProperties[propName] ? this[propName] : undefined; } - set enabledProperties(object) { - this._enabledProperties = { ...this._enabledProperties, ...object }; + set modifiedProperties(object) { + this._modifiedProperties = { ...this._modifiedProperties, ...object }; } - get enabledProperties() { - return this._enabledProperties; + get modifiedProperties() { + return this._modifiedProperties; } }; } diff --git a/src/editor/nodes/SceneNode.js b/src/editor/nodes/SceneNode.js index 356045ea..063ff792 100644 --- a/src/editor/nodes/SceneNode.js +++ b/src/editor/nodes/SceneNode.js @@ -568,9 +568,10 @@ export default class SceneNode extends EditorNodeMixin(Scene) { } }, { - name: "enabled-properties", + name: "editor-settings", props: { - enabled: this.enabledProperties + enabled: true, + modifiedProperties: this.modifiedProperties } } ] diff --git a/src/ui/properties/useAudioParams.js b/src/ui/properties/useAudioParams.js index e6c18b33..12355e4b 100644 --- a/src/ui/properties/useAudioParams.js +++ b/src/ui/properties/useAudioParams.js @@ -5,11 +5,11 @@ export default function useAudioParams(node, editor, sourceType, propName, scene const targetPropName = (scenePropName && scenePropName) || propName; return { onChange: useCallback(value => editor.setPropertySelected(targetPropName, value), [editor, targetPropName]), - onEnable: useCallback(value => editor.setPropertySelected("enabledProperties", { [targetPropName]: value }), [ + onEnable: useCallback(value => editor.setPropertySelected("modifiedProperties", { [targetPropName]: value }), [ editor, targetPropName ]), - enabled: node.enabledProperties[targetPropName], + enabled: node.modifiedProperties[targetPropName], onReset: useCallback(() => editor.setPropertySelected(targetPropName, Defaults[sourceType][propName]), [ editor, targetPropName, diff --git a/test/integration/snapshots/Editor.test.js.md b/test/integration/snapshots/Editor.test.js.md index b43b4a7b..5f477d9e 100644 --- a/test/integration/snapshots/Editor.test.js.md +++ b/test/integration/snapshots/Editor.test.js.md @@ -42,13 +42,9 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, + modifiedProperties: {}, }, }, - { - name: 'enabled-properties', - props: { - enabled: {}, - }, }, { name: 'box-collider', @@ -91,12 +87,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -148,12 +139,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -200,12 +186,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -249,12 +230,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -319,12 +295,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -374,12 +345,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -445,12 +411,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -497,12 +458,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -546,12 +502,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -621,12 +572,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -681,12 +627,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -740,12 +681,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -802,12 +738,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -864,12 +795,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -919,12 +845,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -970,12 +891,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -1028,12 +944,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -1089,12 +1000,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -1159,12 +1065,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -1208,12 +1109,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -1261,12 +1157,7 @@ Generated by [AVA](https://avajs.dev). name: 'editor-settings', props: { enabled: true, - }, - }, - { - name: 'enabled-properties', - props: { - enabled: {}, + modifiedProperties: {}, }, }, { @@ -1314,12 +1205,6 @@ Generated by [AVA](https://avajs.dev). overrideAudioSettings: false, }, }, - { - name: 'enabled-properties', - props: { - enabled: {}, - }, - }, ], name: 'V1TestScene', },