dazscript-framework 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +14 -1
- package/src/Install.dsa.ts +19 -0
- package/src/Uninstall.dsa.ts +19 -0
- package/src/dialog/builders/line-edit-builder.ts +1 -1
- package/src/dialog/builders/node-selection-builder.ts +13 -1
- package/src/dialog/input-dialog.ts +1 -1
- package/src/samples/config.ts +3 -0
- package/src/samples/hello-world.dsa.ts +13 -0
- package/src/samples/sample-dialog.dsa.ts +52 -0
- package/src/samples/sample-dialog.ts +49 -0
- package/src/shared/set-keyboard-shortcut.ts +2 -2
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dazscript-framework",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"author": "Freddy Diaz",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"description": "",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"prebuild": "npm run installer",
|
|
9
|
+
"build": "webpack --env outputPath=./out",
|
|
10
|
+
"postbuild": "npm run icons",
|
|
11
|
+
"watch": "webpack --env outputPath=./out --watch",
|
|
12
|
+
"icons": "copyfiles -u 1 src/**/*.png out/",
|
|
13
|
+
"installer": "node ./dist/scripts/install-generator.js -p ./src/samples -m /DazScriptFramework"
|
|
14
|
+
},
|
|
7
15
|
"keywords": [
|
|
8
16
|
"daz3d",
|
|
9
17
|
"daz studio",
|
|
@@ -53,5 +61,10 @@
|
|
|
53
61
|
"typescript": "^5.2.2",
|
|
54
62
|
"webpack": "^5.88.2",
|
|
55
63
|
"webpack-cli": "^5.1.4"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/node": "^22.10.5",
|
|
67
|
+
"eslint": "^9.17.0",
|
|
68
|
+
"typescript": "^5.7.3"
|
|
56
69
|
}
|
|
57
70
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { installCustomActions as install } from '@dsf/helpers/custom-action-helper';
|
|
3
|
+
|
|
4
|
+
install([
|
|
5
|
+
{
|
|
6
|
+
"name": null,
|
|
7
|
+
"text": "Hello World",
|
|
8
|
+
"filePath": "samples/hello-world.dsa",
|
|
9
|
+
"menuPath": "/DazScriptFramework/samples",
|
|
10
|
+
"description": "hello-world"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": null,
|
|
14
|
+
"text": "Sample Dialog",
|
|
15
|
+
"filePath": "samples/sample-dialog.dsa",
|
|
16
|
+
"menuPath": "/DazScriptFramework/samples",
|
|
17
|
+
"description": "sample-dialog"
|
|
18
|
+
}
|
|
19
|
+
]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { uninstallCustomActions as uninstall } from '@dsf/helpers/custom-action-helper';
|
|
3
|
+
|
|
4
|
+
uninstall([
|
|
5
|
+
{
|
|
6
|
+
"name": null,
|
|
7
|
+
"text": "Hello World",
|
|
8
|
+
"filePath": "samples/hello-world.dsa",
|
|
9
|
+
"menuPath": "/DazScriptFramework/samples",
|
|
10
|
+
"description": "hello-world"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": null,
|
|
14
|
+
"text": "Sample Dialog",
|
|
15
|
+
"filePath": "samples/sample-dialog.dsa",
|
|
16
|
+
"menuPath": "/DazScriptFramework/samples",
|
|
17
|
+
"description": "sample-dialog"
|
|
18
|
+
}
|
|
19
|
+
]);
|
|
@@ -74,7 +74,7 @@ export default class LineEditBuilder extends WidgetBuilderBase<DzLineEdit> {
|
|
|
74
74
|
return this
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
value(text_: string | Observable<string>): this {
|
|
78
78
|
if (typeof text_ === 'string') {
|
|
79
79
|
this.widget.text = text_
|
|
80
80
|
}
|
|
@@ -31,13 +31,25 @@ export class NodeSelectionComboBoxBuilder extends WidgetBuilderBase<DzNodeSelect
|
|
|
31
31
|
return this
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
value(node: Observable<DzNode>): this {
|
|
35
35
|
this.widget.nodeSelectionChanged.scriptConnect(() => {
|
|
36
36
|
node.value = this.widget.getSelectedNode()
|
|
37
37
|
})
|
|
38
|
+
this.selected(node)
|
|
38
39
|
return this
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
changed(then: (node: DzNode) => void): this {
|
|
43
|
+
this.widget.nodeSelectionChanged.scriptConnect(() => {
|
|
44
|
+
then(this.widget.getSelectedNode())
|
|
45
|
+
})
|
|
46
|
+
return this
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
refresh(): void {
|
|
50
|
+
this.widget.update()
|
|
51
|
+
}
|
|
52
|
+
|
|
41
53
|
build(then?: (comboBox: DzNodeSelectionComboBox) => void): DzNodeSelectionComboBox {
|
|
42
54
|
return super.build()
|
|
43
55
|
}
|
|
@@ -23,6 +23,6 @@ export class InputDialog extends BasicDialog {
|
|
|
23
23
|
protected build(): void {
|
|
24
24
|
let add = this.add
|
|
25
25
|
|
|
26
|
-
add.edit().
|
|
26
|
+
add.edit().value(this.model.value$).validator(this.model.validator).focus()
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { debug } from '@dsf/common/log';
|
|
2
|
+
import { action } from '@dsf/core/action-decorator';
|
|
3
|
+
import { BaseScript } from '@dsf/core/base-script';
|
|
4
|
+
import { info } from '@dsf/helpers/message-box-helper';
|
|
5
|
+
|
|
6
|
+
@action({ text: 'Hello World' })
|
|
7
|
+
class HelloWorldScript extends BaseScript {
|
|
8
|
+
protected run(): void {
|
|
9
|
+
debug('Hello World!');
|
|
10
|
+
info('Hello World!');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
new HelloWorldScript().exec();
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { debug, dump } from '@dsf/common/log';
|
|
2
|
+
import { action } from '@dsf/core/action-decorator';
|
|
3
|
+
import { BaseScript } from '@dsf/core/base-script';
|
|
4
|
+
import { error } from '@dsf/helpers/message-box-helper';
|
|
5
|
+
import { getNodes, getSelectedNode } from '@dsf/helpers/scene-helper';
|
|
6
|
+
import { SampleDialog, SampleDialogModel } from './sample-dialog';
|
|
7
|
+
|
|
8
|
+
@action({ text: 'Sample Dialog' })
|
|
9
|
+
class SampleDialogScript extends BaseScript {
|
|
10
|
+
protected run(): void {
|
|
11
|
+
let sceneNodes = getNodes()
|
|
12
|
+
let selectedNode = getSelectedNode()
|
|
13
|
+
if (!selectedNode) {
|
|
14
|
+
error('Please select a node.')
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let model = new SampleDialogModel()
|
|
19
|
+
model.nodes$.value = sceneNodes
|
|
20
|
+
|
|
21
|
+
model.nodeLabel$.connect((label) => {
|
|
22
|
+
if (label === model.selectedNode$.value.getLabel()) return
|
|
23
|
+
model.selectedNode$.value.setLabel(label)
|
|
24
|
+
model.nodes$.value = getNodes()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
let dialog = new SampleDialog(model)
|
|
28
|
+
|
|
29
|
+
model.selectedNode$.connect((node) => {
|
|
30
|
+
if (!node) return
|
|
31
|
+
debug(`Selected Node: ${node.getLabel()}`)
|
|
32
|
+
node.select(true)
|
|
33
|
+
model.nodeLabel$.value = node.getLabel()
|
|
34
|
+
model.showNode$.value = node.isVisible()
|
|
35
|
+
model.hideNode$.value = !node.isVisible()
|
|
36
|
+
})
|
|
37
|
+
dialog.onNodeVisibilityChanged = (node, visible) => {
|
|
38
|
+
node.setVisible(visible)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
model.selectedNode$.value = selectedNode
|
|
42
|
+
|
|
43
|
+
if (!dialog.run()) {
|
|
44
|
+
debug(`Dialog Cancelled`)
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
debug(`Dialog Closed`)
|
|
49
|
+
dump(model)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
new SampleDialogScript().exec();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BasicDialog } from '@dsf/dialog/basic-dialog';
|
|
2
|
+
import { Observable } from '@dsf/lib/observable';
|
|
3
|
+
import { AppSettings } from '@dsf/lib/settings';
|
|
4
|
+
import { config } from './config';
|
|
5
|
+
|
|
6
|
+
export class SampleDialogModel extends AppSettings {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(`${config.author}/SampleDialog`);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
selectedNode$ = new Observable<DzNode>()
|
|
12
|
+
nodes$ = new Observable<DzNode[]>()
|
|
13
|
+
nodeLabel$ = new Observable<string>()
|
|
14
|
+
showNode$ = new Observable<boolean>()
|
|
15
|
+
hideNode$ = new Observable<boolean>()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class SampleDialog extends BasicDialog {
|
|
19
|
+
constructor(private readonly model: SampleDialogModel) {
|
|
20
|
+
super(`Sample Dialog`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public onNodeChanged?: (node: DzNode) => void
|
|
24
|
+
|
|
25
|
+
public onNodeVisibilityChanged?: (node: DzNode, visible: boolean) => void
|
|
26
|
+
|
|
27
|
+
protected build(): void {
|
|
28
|
+
let add = this.add
|
|
29
|
+
let model = this.model
|
|
30
|
+
this.dialog.showAcceptButton(false)
|
|
31
|
+
this.dialog.setCancelButtonText(`Close`)
|
|
32
|
+
|
|
33
|
+
add.tab('General').build(() => {
|
|
34
|
+
add.group(`Selected Node`).build(() => {
|
|
35
|
+
add.nodeSelection().nodes(model.nodes$).value(model.selectedNode$)
|
|
36
|
+
add.horizontal((layout) => {
|
|
37
|
+
add.label(`Label:`)
|
|
38
|
+
layout.addSpacing(10)
|
|
39
|
+
add.edit().value(model.nodeLabel$)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
add.group(`Visibility`).horizontal().build(() => {
|
|
43
|
+
add.radio(`Show`).value(model.showNode$).toolTip(`Show the selected node.`).toggled((checked) => { this.onNodeVisibilityChanged(model.selectedNode$.value, checked) })
|
|
44
|
+
add.radio(`Hide`).value(model.hideNode$).toolTip(`Hide the selected node.`)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -63,14 +63,14 @@ class KeyboardShortcutDialog extends BasicDialog {
|
|
|
63
63
|
|
|
64
64
|
add.group('Assign Keyboard Shortcut').build((layout) => {
|
|
65
65
|
layout.spacing = 5
|
|
66
|
-
add.edit().
|
|
66
|
+
add.edit().value(model.actionLabel).readOnly(true)
|
|
67
67
|
add.comboEdit().focus().items([...letters, ...keys]).changed(this.key).edited(this.key)
|
|
68
68
|
add.checkbox('Control').value(model.control)
|
|
69
69
|
add.checkbox('Option / Alt').value(model.alt)
|
|
70
70
|
add.checkbox('Shift').value(model.shift)
|
|
71
71
|
add.checkbox('Command / Windows').value(model.windows)
|
|
72
72
|
add.group('Shortcut:').style({ flat: true }).build(() => {
|
|
73
|
-
add.edit().
|
|
73
|
+
add.edit().value(model.shortcut).readOnly(true)
|
|
74
74
|
})
|
|
75
75
|
})
|
|
76
76
|
}
|