Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d237d30
commit 4560212
Showing
3 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
core/editor/src/Sections/Options/Particles/Roll/RollOptionsEditor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import type { Container } from "tsparticles"; | ||
import { EditorGroup, EditorType } from "object-gui"; | ||
import { EditorBase } from "../../../../EditorBase"; | ||
import type { IRoll } from "tsparticles/Options/Interfaces/Particles/Roll/IRoll"; | ||
|
||
export class RollOptionsEditor extends EditorBase { | ||
group!: EditorGroup; | ||
private options!: IRoll; | ||
|
||
constructor(particles: Container) { | ||
super(particles); | ||
} | ||
|
||
addToGroup(parent: EditorGroup): void { | ||
this.group = parent.addGroup("roll", "Roll"); | ||
this.options = this.group.data as IRoll; | ||
|
||
this.addDarken(); | ||
this.addEnlighten(); | ||
this.addProperties(); | ||
} | ||
|
||
private addDarken() { | ||
const particles = this.particles; | ||
const group = this.group.addGroup("darken", "Darken"); | ||
|
||
group.addProperty("enable", "Enable", EditorType.boolean).change(async () => { | ||
await particles.refresh(); | ||
}); | ||
|
||
group.addProperty("value", "Value", EditorType.number).change(async () => { | ||
await particles.refresh(); | ||
}); | ||
} | ||
|
||
private addEnlighten() { | ||
const particles = this.particles; | ||
const group = this.group.addGroup("enlighten", "Enlighten"); | ||
|
||
group.addProperty("enable", "Enable", EditorType.boolean).change(async () => { | ||
await particles.refresh(); | ||
}); | ||
|
||
group.addProperty("value", "Value", EditorType.number).change(async () => { | ||
await particles.refresh(); | ||
}); | ||
} | ||
|
||
private addProperties(): void { | ||
const particles = this.particles; | ||
const color = | ||
typeof this.options.backColor === "string" | ||
? this.options.backColor | ||
: this.options.backColor instanceof Array | ||
? this.options.backColor[0] | ||
: this.options.backColor?.value; | ||
|
||
this.group | ||
.addProperty("backColor", "Back Color", EditorType.color, color, false) | ||
.change(async (value: unknown) => { | ||
if (typeof value === "string") { | ||
if (typeof this.options.backColor === "string") { | ||
this.options.backColor = value; | ||
} else { | ||
if (this.options.backColor === undefined) { | ||
this.options.backColor = { | ||
value: value, | ||
}; | ||
} else { | ||
if (this.options.backColor instanceof Array) { | ||
this.options.backColor = { | ||
value: value, | ||
}; | ||
} else { | ||
this.options.backColor.value = value; | ||
} | ||
} | ||
} | ||
} | ||
|
||
await particles.refresh(); | ||
}); | ||
|
||
this.group.addProperty("enable", "Enable", EditorType.boolean).change(async () => { | ||
await particles.refresh(); | ||
}); | ||
|
||
this.group.addProperty("speed", "Speed", EditorType.number).change(async () => { | ||
await particles.refresh(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters