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.
- package/README.md +365 -93
- package/babel.config.js +33 -33
- package/dist/babel/trace-babel-plugin.js +243 -243
- package/dist/babel/trace-log-babel-plugin.js +164 -164
- package/dist/scripts/install-generator.js +185 -185
- package/package.json +72 -70
- package/src/common/dz-dump.ts +120 -120
- package/src/common/log.ts +56 -56
- package/src/common/trace.ts +26 -26
- package/src/core/action-decorator.ts +15 -15
- package/src/core/base-script.ts +30 -30
- package/src/core/custom-action.ts +11 -11
- package/src/core/global.ts +4 -4
- package/src/dialog/basic-dialog.ts +40 -32
- package/src/dialog/builders/button-builder.ts +52 -52
- package/src/dialog/builders/checkbox-builder.ts +29 -29
- package/src/dialog/builders/color-picker-builder.ts +35 -35
- package/src/dialog/builders/combo-box-builder.ts +38 -35
- package/src/dialog/builders/combo-edit-builder.ts +35 -35
- package/src/dialog/builders/dialog-builder.ts +49 -49
- package/src/dialog/builders/groupbox-builder.ts +121 -82
- package/src/dialog/builders/label-builder.ts +33 -28
- package/src/dialog/builders/layout-builder.ts +59 -59
- package/src/dialog/builders/line-edit-builder.ts +124 -119
- package/src/dialog/builders/list-box-builder.ts +103 -0
- package/src/dialog/builders/list-view-builder.ts +396 -328
- package/src/dialog/builders/node-selection-builder.ts +55 -55
- package/src/dialog/builders/path-combo-box-builder.ts +24 -24
- package/src/dialog/builders/popup-menu-builder.ts +46 -46
- package/src/dialog/builders/radio-builder.ts +42 -42
- package/src/dialog/builders/slider-builder.ts +39 -22
- package/src/dialog/builders/splitter-builder.ts +88 -88
- package/src/dialog/builders/tab-builder.ts +120 -106
- package/src/dialog/builders/widget-builder.ts +136 -124
- package/src/dialog/builders/widgets-builder.ts +140 -135
- package/src/dialog/input-dialog.ts +30 -27
- package/src/dialog/input-validator.ts +8 -8
- package/src/dialog/selection-dialog.ts +47 -0
- package/src/dialog/shared.ts +8 -8
- package/src/helpers/action-helper.ts +214 -81
- package/src/helpers/array-helper.ts +170 -145
- package/src/helpers/camera-helper.ts +12 -12
- package/src/helpers/custom-action-helper.ts +176 -176
- package/src/helpers/directory-helper.ts +14 -0
- package/src/helpers/file-helper.ts +90 -90
- package/src/helpers/http-helper.ts +186 -0
- package/src/helpers/input-helper.ts +18 -18
- package/src/helpers/list-view-helper.ts +105 -89
- package/src/helpers/menu-helper.ts +28 -28
- package/src/helpers/message-box-helper.ts +25 -15
- package/src/helpers/node-helper.ts +461 -236
- package/src/helpers/number-helper.ts +10 -10
- package/src/helpers/numeric-property-helper.ts +91 -91
- package/src/helpers/object-helper.ts +2 -2
- package/src/helpers/pane-helper.ts +28 -20
- package/src/helpers/progress-helper.ts +51 -33
- package/src/helpers/property-helper.ts +61 -52
- package/src/helpers/record-helper.ts +16 -16
- package/src/helpers/scene-helper.ts +144 -94
- package/src/helpers/script-helper.ts +15 -15
- package/src/helpers/skeleton-helper.ts +26 -26
- package/src/helpers/splitter-helper.ts +8 -8
- package/src/helpers/string-helper.ts +39 -31
- package/src/helpers/surface-helper.ts +5 -5
- package/src/helpers/undo-helper.ts +8 -8
- package/src/helpers/viewport-helper.ts +21 -8
- package/src/lib/delayed.ts +38 -38
- package/src/lib/dictionary.ts +3 -0
- package/src/lib/frame-keys.ts +67 -67
- package/src/lib/guid.ts +2 -2
- package/src/lib/menu-item.ts +10 -9
- package/src/lib/observable.ts +147 -94
- package/src/lib/set.ts +50 -25
- package/src/lib/settings.ts +112 -104
- package/src/lib/tree-node.ts +149 -145
- package/src/samples/config.ts +2 -2
- package/src/samples/hello-world.dsa.ts +12 -12
- package/src/samples/sample-dialog.dsa.ts +51 -51
- package/src/samples/sample-dialog.ts +48 -48
- package/src/shared/set-keyboard-shortcut.ts +146 -102
- package/tsconfig.json +116 -116
- package/webpack.config.js +70 -70
package/src/lib/settings.ts
CHANGED
|
@@ -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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return new Observable(this.
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return new Observable(this.
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
+
}
|
package/src/lib/tree-node.ts
CHANGED
|
@@ -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():
|
|
55
|
-
let result:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
// }
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
118
|
-
// }
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
//
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
//
|
|
143
|
-
//
|
|
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
|
+
|
package/src/samples/config.ts
CHANGED
|
@@ -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();
|