-
Notifications
You must be signed in to change notification settings - Fork 6
/
NodejsDemo.ts
46 lines (35 loc) · 1.26 KB
/
NodejsDemo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {ImGui, ImVec2} from 'cpp'
import {$ref, $unref, toCString} from 'puerts';
import * as fs from 'fs'
import * as UE from 'ue'
class NodeDemoWindow {
simple_window_titil : ArrayBuffer
button_text: ArrayBuffer
content_dir:string;
all_files_in_content_dir:string[] = [];
isOpened = $ref(true);
constructor() {
this.simple_window_titil = toCString("Nodejs Demo"); // faster than passing a string
this.button_text = toCString("refresh");
this.content_dir = UE.KismetSystemLibrary.GetProjectContentDirectory();
}
Render() : boolean {
ImGui.SetNextWindowSize(new ImVec2(200, 100), 1 << 2)
ImGui.Begin(this.simple_window_titil, this.isOpened);
if(ImGui.Button(this.button_text))
{
this.all_files_in_content_dir = fs.readdirSync(this.content_dir);
}
if (ImGui.TreeNode('content_dir', this.content_dir)) {
this.all_files_in_content_dir.forEach(file => {
if (ImGui.TreeNode(file, file)) {
ImGui.TreePop();
}
});
ImGui.TreePop();
}
ImGui.End();
return $unref(this.isOpened);
}
}
export {NodeDemoWindow};