Skip to content

Commit 4c8792c

Browse files
committed
🐛 Fix outliner elements inheriting the same property list
1 parent ea233a6 commit 4c8792c

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

src/outliner/resizableOutlinerElement.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { fixClassPropertyInheritance } from 'src/util/property'
12
import { makeNotZero } from '../util/misc'
23

4+
@fixClassPropertyInheritance
35
export class ResizableOutlinerElement extends OutlinerElement {
46
type = 'resizable'
57
// Properties
@@ -58,13 +60,10 @@ export class ResizableOutlinerElement extends OutlinerElement {
5860
}
5961

6062
extend(data: any) {
61-
for (const key in ResizableOutlinerElement.properties) {
62-
ResizableOutlinerElement.properties[key].merge(this, data)
63+
const properties = this.constructor.properties
64+
for (const key in properties) {
65+
properties[key]!.merge(this, data)
6366
}
64-
if (data.visibility !== undefined) {
65-
this.visibility = data.visibility
66-
}
67-
6867
return this
6968
}
7069

src/util/moddingTools.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ export function registerProjectMod<ID extends string, RevertContext extends any
200200
apply: () => {
201201
return [
202202
EVENTS.PRE_SELECT_PROJECT.subscribe(project => {
203-
console.log('Checking project mod condition for', options.id, project)
204203
if (!options.condition(project)) return
205204
console.log(`Applying project mod '${options.id}'`)
206205
revertContext = options.apply()
@@ -620,8 +619,3 @@ export class ObjectProperty extends Property<'object'> {
620619
}
621620
}
622621
}
623-
624-
export const fixClassPropertyInheritance: ClassDecorator = target => {
625-
target.properties = { ...target.properties }
626-
return target
627-
}

src/util/property.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export class DeepClonedObjectProperty extends Property<'object'> {
2+
constructor(targetClass: any, name: string, options?: PropertyOptions) {
3+
super(targetClass, 'object', name, options)
4+
}
5+
6+
merge(instance: any, data: any) {
7+
if (typeof data[this.name] === 'object') {
8+
instance[this.name] = JSON.parse(JSON.stringify(data[this.name]))
9+
}
10+
}
11+
12+
copy(instance: any, target: any) {
13+
if (typeof instance[this.name] === 'object') {
14+
target[this.name] = JSON.parse(JSON.stringify(instance[this.name]))
15+
}
16+
}
17+
}
18+
19+
export const fixClassPropertyInheritance: ClassDecorator = target => {
20+
target.properties = { ...target.properties }
21+
return target
22+
}

0 commit comments

Comments
 (0)