dazscript-framework 0.1.15 → 0.1.16

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.
Files changed (82) hide show
  1. package/README.md +365 -93
  2. package/babel.config.js +33 -33
  3. package/dist/babel/trace-babel-plugin.js +243 -243
  4. package/dist/babel/trace-log-babel-plugin.js +164 -164
  5. package/dist/scripts/install-generator.js +185 -185
  6. package/package.json +72 -70
  7. package/src/common/dz-dump.ts +120 -120
  8. package/src/common/log.ts +56 -56
  9. package/src/common/trace.ts +26 -26
  10. package/src/core/action-decorator.ts +15 -15
  11. package/src/core/base-script.ts +30 -30
  12. package/src/core/custom-action.ts +11 -11
  13. package/src/core/global.ts +4 -4
  14. package/src/dialog/basic-dialog.ts +40 -32
  15. package/src/dialog/builders/button-builder.ts +52 -52
  16. package/src/dialog/builders/checkbox-builder.ts +29 -29
  17. package/src/dialog/builders/color-picker-builder.ts +35 -35
  18. package/src/dialog/builders/combo-box-builder.ts +38 -35
  19. package/src/dialog/builders/combo-edit-builder.ts +35 -35
  20. package/src/dialog/builders/dialog-builder.ts +49 -49
  21. package/src/dialog/builders/groupbox-builder.ts +121 -82
  22. package/src/dialog/builders/label-builder.ts +33 -28
  23. package/src/dialog/builders/layout-builder.ts +59 -59
  24. package/src/dialog/builders/line-edit-builder.ts +124 -119
  25. package/src/dialog/builders/list-box-builder.ts +103 -0
  26. package/src/dialog/builders/list-view-builder.ts +396 -328
  27. package/src/dialog/builders/node-selection-builder.ts +55 -55
  28. package/src/dialog/builders/path-combo-box-builder.ts +24 -24
  29. package/src/dialog/builders/popup-menu-builder.ts +46 -46
  30. package/src/dialog/builders/radio-builder.ts +42 -42
  31. package/src/dialog/builders/slider-builder.ts +39 -22
  32. package/src/dialog/builders/splitter-builder.ts +88 -88
  33. package/src/dialog/builders/tab-builder.ts +120 -106
  34. package/src/dialog/builders/widget-builder.ts +136 -124
  35. package/src/dialog/builders/widgets-builder.ts +140 -135
  36. package/src/dialog/input-dialog.ts +30 -27
  37. package/src/dialog/input-validator.ts +8 -8
  38. package/src/dialog/selection-dialog.ts +47 -0
  39. package/src/dialog/shared.ts +8 -8
  40. package/src/helpers/action-helper.ts +214 -81
  41. package/src/helpers/array-helper.ts +170 -145
  42. package/src/helpers/camera-helper.ts +12 -12
  43. package/src/helpers/custom-action-helper.ts +176 -176
  44. package/src/helpers/directory-helper.ts +14 -0
  45. package/src/helpers/file-helper.ts +90 -90
  46. package/src/helpers/http-helper.ts +186 -0
  47. package/src/helpers/input-helper.ts +18 -18
  48. package/src/helpers/list-view-helper.ts +105 -89
  49. package/src/helpers/menu-helper.ts +28 -28
  50. package/src/helpers/message-box-helper.ts +25 -15
  51. package/src/helpers/node-helper.ts +461 -236
  52. package/src/helpers/number-helper.ts +10 -10
  53. package/src/helpers/numeric-property-helper.ts +91 -91
  54. package/src/helpers/object-helper.ts +2 -2
  55. package/src/helpers/pane-helper.ts +28 -20
  56. package/src/helpers/progress-helper.ts +51 -33
  57. package/src/helpers/property-helper.ts +61 -52
  58. package/src/helpers/record-helper.ts +16 -16
  59. package/src/helpers/scene-helper.ts +144 -94
  60. package/src/helpers/script-helper.ts +15 -15
  61. package/src/helpers/skeleton-helper.ts +26 -26
  62. package/src/helpers/splitter-helper.ts +8 -8
  63. package/src/helpers/string-helper.ts +39 -31
  64. package/src/helpers/surface-helper.ts +5 -5
  65. package/src/helpers/undo-helper.ts +8 -8
  66. package/src/helpers/viewport-helper.ts +21 -8
  67. package/src/lib/delayed.ts +38 -38
  68. package/src/lib/dictionary.ts +3 -0
  69. package/src/lib/frame-keys.ts +67 -67
  70. package/src/lib/guid.ts +2 -2
  71. package/src/lib/menu-item.ts +10 -9
  72. package/src/lib/observable.ts +147 -94
  73. package/src/lib/set.ts +50 -25
  74. package/src/lib/settings.ts +112 -104
  75. package/src/lib/tree-node.ts +149 -145
  76. package/src/samples/config.ts +2 -2
  77. package/src/samples/hello-world.dsa.ts +12 -12
  78. package/src/samples/sample-dialog.dsa.ts +51 -51
  79. package/src/samples/sample-dialog.ts +48 -48
  80. package/src/shared/set-keyboard-shortcut.ts +146 -102
  81. package/tsconfig.json +116 -116
  82. package/webpack.config.js +70 -70
@@ -1,104 +1,112 @@
1
- import { Observable } from './observable';
2
-
3
- export class AppSettings {
4
- private appSettings: DzAppSettings
5
- private _settingsPath: string
6
- private _appDataPath: string
7
- get appDataPath(): string {
8
- return this._appDataPath
9
- }
10
-
11
- constructor(settingsPath: string, appDataPath?: string) {
12
- this._settingsPath = settingsPath
13
- this.setPaths({ settingsPath: settingsPath, appDataPath: appDataPath ?? settingsPath })
14
- }
15
-
16
- setPaths(paths: { settingsPath?: string, appDataPath?: string }) {
17
- if (!paths.settingsPath && !paths.appDataPath) return
18
- if (paths.settingsPath) {
19
- this._settingsPath = paths.settingsPath
20
- this.appSettings = new DzAppSettings(paths.settingsPath)
21
- }
22
- if (paths.appDataPath) {
23
- this._appDataPath = `${App.getAppDataPath()}/${paths.appDataPath}`
24
- }
25
- }
26
-
27
- forPath(path: string, ...paths: string[]): DzAppSettings {
28
- let target = [this._settingsPath, path, ...paths].join('/')
29
- return new DzAppSettings(target)
30
- }
31
-
32
- protected getInt(name: keyof this, value: number): number {
33
- return this.appSettings.getIntValue(String(name), value);
34
- }
35
-
36
- protected setInt(name: keyof this, value: number) {
37
- this.appSettings.setIntValue(String(name), value)
38
- }
39
-
40
- protected getFloat(name: keyof this, value: number): number {
41
- return this.appSettings.getFloatValue(String(name), value);
42
- }
43
-
44
- protected setFloat(name: keyof this, value: number) {
45
- this.appSettings.setFloatValue(String(name), value)
46
- }
47
-
48
- protected getBool(name: keyof this, defaultValue: boolean): boolean {
49
- return this.appSettings.getBoolValue(String(name), defaultValue);
50
- }
51
-
52
- protected setBool(name: keyof this, value: boolean): void {
53
- this.appSettings.setBoolValue(String(name), value)
54
- }
55
-
56
- protected getString(name: keyof this, defaultValue: string): string {
57
- return this.appSettings.getStringValue(String(name), defaultValue)
58
- }
59
-
60
- protected setString(name: keyof this, value: string): void {
61
- this.appSettings.setStringValue(String(name), value)
62
- }
63
-
64
- protected getArray(name: keyof this, defaultValue: string[]): string[] {
65
- return this.appSettings.getStringValue(String(name), defaultValue.join(',')).split(',')
66
- }
67
-
68
- // protected setArray(name: keyof this, value: string[]): void {
69
- // this.appSettings.setStringValue(String(name), value.join(','))
70
- // }
71
-
72
- // protected getJson<T>(name: keyof this, defaultValue: T): T {
73
- // return JSON.parse(this.getString(name, JSON.stringify(defaultValue)))
74
- // }
75
-
76
- // protected setJson<T>(name: keyof this, value: T): void {
77
- // this.setString(name, JSON.stringify(value))
78
- // }
79
-
80
-
81
- bindBoolean(name: keyof this, defaultValue: boolean = false): Observable<boolean> {
82
- return new Observable(this.getBool(name, defaultValue), (value) => this.setBool(name, value))
83
- }
84
-
85
- bindString(name: keyof this, defaultValue: string = ''): Observable<string> {
86
- return new Observable(this.getString(name, defaultValue), (value) => this.setString(name, value))
87
- }
88
-
89
- bindInt(name: keyof this, defaultValue: number): Observable<number> {
90
- return new Observable(this.getInt(name, defaultValue), (value) => this.setInt(name, value))
91
- }
92
-
93
- bindFloat(name: keyof this, defaultValue: number): Observable<number> {
94
- return new Observable(this.getFloat(name, defaultValue), (value) => this.setFloat(name, value))
95
- }
96
-
97
- // bindArray(name: keyof this, defaultValue: string[] = []): Observable<string[]> {
98
- // return new Observable(this.getArray(name, defaultValue), (value) => this.setArray(name, value))
99
- // }
100
-
101
- // bindJson<T>(name: keyof this, defaultValue: T): Observable<T> {
102
- // return new Observable(this.getJson(name, defaultValue), (value) => this.setJson(name, value))
103
- // }
104
- }
1
+ import { Observable } from './observable';
2
+
3
+ export class AppSettings {
4
+ private appSettings: DzAppSettings
5
+ private _settingsPath: string
6
+ private _appDataPath: string
7
+ get appDataPath(): string {
8
+ return this._appDataPath
9
+ }
10
+
11
+ constructor(settingsPath: string, appDataPath?: string) {
12
+ this._settingsPath = settingsPath
13
+ this.setPaths({ settingsPath: settingsPath, appDataPath: appDataPath ?? settingsPath })
14
+ }
15
+
16
+ setPaths(paths: { settingsPath?: string, appDataPath?: string }) {
17
+ if (!paths.settingsPath && !paths.appDataPath) return
18
+ if (paths.settingsPath) {
19
+ this._settingsPath = paths.settingsPath
20
+ this.appSettings = new DzAppSettings(paths.settingsPath)
21
+ }
22
+ if (paths.appDataPath) {
23
+ this._appDataPath = `${App.getAppDataPath()}/${paths.appDataPath}`
24
+ }
25
+ }
26
+
27
+ forPath(path: string, ...paths: string[]): DzAppSettings {
28
+ let target = [this._settingsPath, path, ...paths].join('/')
29
+ return new DzAppSettings(target)
30
+ }
31
+
32
+ protected getInt(name: keyof this, value: number): number {
33
+ return this.appSettings.getIntValue(String(name), value);
34
+ }
35
+
36
+ protected setInt(name: keyof this, value: number) {
37
+ this.appSettings.setIntValue(String(name), value)
38
+ }
39
+
40
+ protected getFloat(name: keyof this, value: number): number {
41
+ return this.appSettings.getFloatValue(String(name), value);
42
+ }
43
+
44
+ protected setFloat(name: keyof this, value: number) {
45
+ this.appSettings.setFloatValue(String(name), value)
46
+ }
47
+
48
+ protected getBool(name: keyof this, defaultValue: boolean): boolean {
49
+ return this.appSettings.getBoolValue(String(name), defaultValue);
50
+ }
51
+
52
+ protected setBool(name: keyof this, value: boolean): void {
53
+ this.appSettings.setBoolValue(String(name), value)
54
+ }
55
+
56
+ protected getString(name: keyof this, defaultValue: string): string {
57
+ return this.appSettings.getStringValue(String(name), defaultValue)
58
+ }
59
+
60
+ protected setString(name: keyof this, value: string): void {
61
+ this.appSettings.setStringValue(String(name), value)
62
+ }
63
+
64
+ protected getArray(name: keyof this, defaultValue: string[]): string[] {
65
+ const value = this.appSettings.getStringValue(String(name), defaultValue.join(','))
66
+ if (!value) return []
67
+ return value.split(',').filter(Boolean)
68
+ }
69
+
70
+ protected setArray(name: keyof this, value: string[]): void {
71
+ this.appSettings.setStringValue(String(name), value.join(','))
72
+ }
73
+
74
+ protected getJson<T>(name: keyof this, defaultValue: T): T {
75
+ const raw = this.getString(name, JSON.stringify(defaultValue))
76
+ if (!raw) return defaultValue
77
+ try {
78
+ return JSON.parse(raw) as T
79
+ } catch (_error) {
80
+ return defaultValue
81
+ }
82
+ }
83
+
84
+ protected setJson<T>(name: keyof this, value: T): void {
85
+ this.setString(name, JSON.stringify(value))
86
+ }
87
+
88
+
89
+ bindBoolean(name: keyof this, defaultValue: boolean = false): Observable<boolean> {
90
+ return new Observable(this.getBool(name, defaultValue), (value) => this.setBool(name, value))
91
+ }
92
+
93
+ bindString(name: keyof this, defaultValue: string = ''): Observable<string> {
94
+ return new Observable(this.getString(name, defaultValue), (value) => this.setString(name, value))
95
+ }
96
+
97
+ bindInt(name: keyof this, defaultValue: number): Observable<number> {
98
+ return new Observable(this.getInt(name, defaultValue), (value) => this.setInt(name, value))
99
+ }
100
+
101
+ bindFloat(name: keyof this, defaultValue: number): Observable<number> {
102
+ return new Observable(this.getFloat(name, defaultValue), (value) => this.setFloat(name, value))
103
+ }
104
+
105
+ bindArray(name: keyof this, defaultValue: string[] = []): Observable<string[]> {
106
+ return new Observable(this.getArray(name, defaultValue), (value) => this.setArray(name, value))
107
+ }
108
+
109
+ bindJson<T>(name: keyof this, defaultValue: T): Observable<T> {
110
+ return new Observable(this.getJson(name, defaultValue), (value) => this.setJson(name, value))
111
+ }
112
+ }
@@ -1,145 +1,149 @@
1
- export class TreeNode<T = null> {
2
- name: string;
3
- value: T | null;
4
- path: string = '';
5
- parent: TreeNode<T> | null = null;
6
- private _children: TreeNode<T>[] = [];
7
-
8
- constructor(name: string, path: string, value: T | null = null, children: TreeNode<T>[] = []) {
9
- this.name = name;
10
- this.path = path;
11
- this.value = value;
12
- this.addChild(...children)
13
- }
14
-
15
- addChild(...children: TreeNode<T>[]) {
16
- children.forEach(child => child.parent = this)
17
- this._children.push(...children)
18
- }
19
-
20
- get children(): TreeNode<T>[] {
21
- return this._children
22
- }
23
-
24
- get isRoot(): boolean {
25
- return !this.parent;
26
- }
27
-
28
- get isLeaf(): boolean {
29
- return this._children.length === 0;
30
- }
31
-
32
- first(fn: (node: TreeNode<T>) => boolean): TreeNode<T> | null {
33
- if (fn(this)) {
34
- return this;
35
- }
36
-
37
- for (const child of this._children) {
38
- const result = child.first(fn);
39
- if (result !== null) {
40
- return result;
41
- }
42
- }
43
-
44
- return null;
45
- }
46
-
47
- forEach(fn: (node: TreeNode<T>) => void) {
48
- fn(this)
49
- for (const child of this._children) {
50
- child.forEach(fn)
51
- }
52
- }
53
-
54
- values(): (T | null)[] {
55
- let result: (T | null)[] = [];
56
-
57
- // Add the current node's value to the result
58
- result.push(this.value);
59
-
60
- // Recursively add values from children
61
- for (const child of this.children) {
62
- result = result.concat(child.values());
63
- }
64
-
65
- return result.filter(value => value !== null) as (T | null)[];
66
- }
67
-
68
- toJSON(): object {
69
- return {
70
- name: this.name,
71
- path: this.path,
72
- value: this.value,
73
- isLeaf: this.isLeaf,
74
- children: this._children
75
- };
76
- }
77
-
78
- static fromJSON<T>(data: TreeNode<T>): TreeNode<T> {
79
- const { name, path, value, children } = data;
80
- const node = new TreeNode<T>(name, path, value);
81
- if (children && children.length > 0) {
82
- const parsedChildren = children.map((childData) => TreeNode.fromJSON<T>(childData));
83
- node.addChild(...parsedChildren);
84
- }
85
- return node;
86
- }
87
- }
88
-
89
- // getPaths(): string[] {
90
- // let paths: string[] = [];
91
-
92
- // const traverse = (node: TreeNode<T>) => {
93
- // if (node.isLeaf) {
94
- // paths.push(node.path);
95
- // } else {
96
- // for (let child of node.children) {
97
- // traverse(child);
98
- // }
99
- // }
100
- // };
101
-
102
- // traverse(this);
103
- // return paths;
104
- // }
105
-
106
- // getPartialPaths(keyProperty?: keyof TreeNode<T>): string[] {
107
- // let key = String(keyProperty ?? "name");
108
- // let paths: string[] = [];
109
-
110
- // const traverse = (node: TreeNode<T>, path: string) => {
111
- // path += "/" + node[key];
112
- // if (node.isLeaf) {
113
- // paths.push(path);
114
- // } else {
115
- // for (let child of node.children) {
116
- // traverse(child, path);
117
- // }
118
- // }
119
- // };
120
-
121
- // traverse(this, '');
122
- // return paths;
123
- // }
124
-
125
- // find(path: string): TreeNode<T> | null {
126
- // // Start with this node
127
- // let stack: TreeNode<T>[] = [this];
128
-
129
- // // While there are nodes left to check
130
- // while (stack.length > 0) {
131
- // let node = stack.pop();
132
-
133
- // // If this node's path matches the path, return it
134
- // if (node.path === path) {
135
- // return node;
136
- // }
137
-
138
- // // Add this node's children to the stack to be checked
139
- // stack.push(...node.children);
140
- // }
141
-
142
- // // If no node was found with a matching path, return null
143
- // return null;
144
- // }
145
-
1
+ export class TreeNode<T = null> {
2
+ name: string;
3
+ value: T | null;
4
+ path: string = '';
5
+ parent: TreeNode<T> | null = null;
6
+ private _children: TreeNode<T>[] = [];
7
+
8
+ constructor(name: string, path: string, value: T | null = null, children: TreeNode<T>[] = []) {
9
+ this.name = name;
10
+ this.path = path;
11
+ this.value = value;
12
+ this.addChild(...children)
13
+ }
14
+
15
+ addChild(...children: TreeNode<T>[]) {
16
+ children.forEach(child => child.parent = this)
17
+ this._children.push(...children)
18
+ }
19
+
20
+ get children(): TreeNode<T>[] {
21
+ return this._children
22
+ }
23
+
24
+ get isRoot(): boolean {
25
+ return !this.parent;
26
+ }
27
+
28
+ get isLeaf(): boolean {
29
+ return this._children.length === 0;
30
+ }
31
+
32
+ first(fn: (node: TreeNode<T>) => boolean): TreeNode<T> | null {
33
+ if (fn(this)) {
34
+ return this;
35
+ }
36
+
37
+ for (const child of this._children) {
38
+ const result = child.first(fn);
39
+ if (result !== null) {
40
+ return result;
41
+ }
42
+ }
43
+
44
+ return null;
45
+ }
46
+
47
+ forEach(fn: (node: TreeNode<T>) => void) {
48
+ fn(this)
49
+ for (const child of this._children) {
50
+ child.forEach(fn)
51
+ }
52
+ }
53
+
54
+ values(): T[] {
55
+ let result: T[] = [];
56
+
57
+ const collect = (node: TreeNode<T>) => {
58
+ if (node.value !== null) {
59
+ result.push(node.value);
60
+ }
61
+
62
+ for (const child of node.children) {
63
+ collect(child);
64
+ }
65
+ }
66
+
67
+ collect(this)
68
+
69
+ return result;
70
+ }
71
+
72
+ toJSON(): object {
73
+ return {
74
+ name: this.name,
75
+ path: this.path,
76
+ value: this.value,
77
+ isLeaf: this.isLeaf,
78
+ children: this._children
79
+ };
80
+ }
81
+
82
+ static fromJSON<T>(data: TreeNode<T>): TreeNode<T> {
83
+ const { name, path, value, children } = data;
84
+ const node = new TreeNode<T>(name, path, value);
85
+ if (children && children.length > 0) {
86
+ const parsedChildren = children.map((childData) => TreeNode.fromJSON<T>(childData));
87
+ node.addChild(...parsedChildren);
88
+ }
89
+ return node;
90
+ }
91
+ }
92
+
93
+ // getPaths(): string[] {
94
+ // let paths: string[] = [];
95
+
96
+ // const traverse = (node: TreeNode<T>) => {
97
+ // if (node.isLeaf) {
98
+ // paths.push(node.path);
99
+ // } else {
100
+ // for (let child of node.children) {
101
+ // traverse(child);
102
+ // }
103
+ // }
104
+ // };
105
+
106
+ // traverse(this);
107
+ // return paths;
108
+ // }
109
+
110
+ // getPartialPaths(keyProperty?: keyof TreeNode<T>): string[] {
111
+ // let key = String(keyProperty ?? "name");
112
+ // let paths: string[] = [];
113
+
114
+ // const traverse = (node: TreeNode<T>, path: string) => {
115
+ // path += "/" + node[key];
116
+ // if (node.isLeaf) {
117
+ // paths.push(path);
118
+ // } else {
119
+ // for (let child of node.children) {
120
+ // traverse(child, path);
121
+ // }
122
+ // }
123
+ // };
124
+
125
+ // traverse(this, '');
126
+ // return paths;
127
+ // }
128
+
129
+ // find(path: string): TreeNode<T> | null {
130
+ // // Start with this node
131
+ // let stack: TreeNode<T>[] = [this];
132
+
133
+ // // While there are nodes left to check
134
+ // while (stack.length > 0) {
135
+ // let node = stack.pop();
136
+
137
+ // // If this node's path matches the path, return it
138
+ // if (node.path === path) {
139
+ // return node;
140
+ // }
141
+
142
+ // // Add this node's children to the stack to be checked
143
+ // stack.push(...node.children);
144
+ // }
145
+
146
+ // // If no node was found with a matching path, return null
147
+ // return null;
148
+ // }
149
+
@@ -1,3 +1,3 @@
1
- export const config = {
2
- author: 'DazScriptFramework'
1
+ export const config = {
2
+ author: 'DazScriptFramework'
3
3
  }
@@ -1,13 +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
- }
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
13
  new HelloWorldScript().exec();
@@ -1,52 +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
- }
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
52
  new SampleDialogScript().exec();