-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathenumdump.ts
48 lines (45 loc) · 1.61 KB
/
enumdump.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
47
48
function repeat(pattern, count) {
if (count < 1) return '';
var result = '';
while (count > 1) {
if (count & 1) result += pattern;
count >>= 1, pattern += pattern;
}
return result + pattern;
}
function altDump(name: string, object: Object) {
$.Msg(`/*
Typescript definition file of the DotA 2 Panorama API.
This file contains information on the enums. This file can be used
just as reference, or when writing Typescript to compile into Panorama JS.
To use this file with typescript for Panorama, install typescript and put this file at the project root.
Any javascript compiled from this typescript should be Panorama-compatible and run in Panorama.
Issues or bugs in the definitions can be reported by making an issue on GitHub:
https://github.com/ModDota/DotaUI.
*/`);
$.Msg("");
for (var v in object) {
if(typeof object[v] == "object") {
let i = 0;
for (let w in object[v]) {
if (typeof(object[v][w]) != "function") {
i++;
}
}
if (i > 0) {
$.Msg("declare enum " + v + " {");
for (let w in object[v]) {
/*if (i-- == 1) {
$.Msg("Last entry test");
}*/
if (typeof(object[v][w]) != "function") {
$.Msg(" " + w + " = " + (""+object[v][w]) + ((i-- == 1) ? "" : ","));
}
}
$.Msg("}");
$.Msg("");
}
}
}
}
altDump("Globals", this);