|
1 | 1 | import type * as Godot from "godot";
|
2 | 2 | import type * as GodotJsb from "godot-jsb";
|
3 | 3 |
|
4 |
| -const { jsb, FloatType, IntegerType, Node, PropertyHint, PropertyUsageFlags, Resource, Variant } = require("godot.lib.api"); |
| 4 | +const { jsb, FloatType, IntegerType, Node, PropertyHint, PropertyUsageFlags, ProxyTarget, Resource, Variant } = require("godot.lib.api"); |
5 | 5 |
|
6 | 6 | function guess_type_name(type: any) {
|
7 | 7 | if (typeof type === "function") {
|
@@ -146,12 +146,14 @@ function get_hint_string(clazz: any): string {
|
146 | 146 | }
|
147 | 147 | }
|
148 | 148 |
|
149 |
| - if (typeof clazz === "function" && typeof clazz.prototype !== "undefined") { |
150 |
| - if (clazz.prototype instanceof Resource) { |
| 149 | + if (typeof clazz === "function") { |
| 150 | + const prototype = clazz.prototype; |
| 151 | + |
| 152 | + if (prototype instanceof Resource) { |
151 | 153 | return `${Variant.Type.TYPE_OBJECT}/${PropertyHint.PROPERTY_HINT_RESOURCE_TYPE}:${clazz.name}`;
|
152 |
| - } else if (clazz.prototype instanceof Node) { |
| 154 | + } else if (prototype instanceof Node || ((clazz as any)[ProxyTarget] ?? clazz) === (Node[ProxyTarget] ?? Node)) { |
153 | 155 | return `${Variant.Type.TYPE_OBJECT}/${PropertyHint.PROPERTY_HINT_NODE_TYPE}:${clazz.name}`;
|
154 |
| - } else { |
| 156 | + } else if (typeof prototype !== "undefined") { |
155 | 157 | // other than Resource and Node, only primitive types and enum types are supported in gdscript
|
156 | 158 | //TODO but we barely know anything about the enum types and int/float/StringName/... in JS
|
157 | 159 |
|
@@ -216,12 +218,14 @@ export function export_(type: Godot.Variant.Type, details?: { class_?: ClassDesc
|
216 | 218 |
|
217 | 219 | if (type === Variant.Type.TYPE_OBJECT) {
|
218 | 220 | const clazz = details.class_;
|
219 |
| - if (typeof clazz === "function" && typeof clazz.prototype !== "undefined") { |
220 |
| - if (clazz.prototype instanceof Resource) { |
| 221 | + if (typeof clazz === "function") { |
| 222 | + const prototype = clazz.prototype; |
| 223 | + |
| 224 | + if (prototype instanceof Resource) { |
221 | 225 | ebd.hint = PropertyHint.PROPERTY_HINT_RESOURCE_TYPE;
|
222 | 226 | ebd.hint_string = clazz.name;
|
223 | 227 | ebd.usage |= PropertyUsageFlags.PROPERTY_USAGE_SCRIPT_VARIABLE;
|
224 |
| - } else if (clazz.prototype instanceof Node) { |
| 228 | + } else if (prototype instanceof Node || ((clazz as any)[ProxyTarget] ?? clazz) === (Node[ProxyTarget] ?? Node)) { |
225 | 229 | ebd.hint = PropertyHint.PROPERTY_HINT_NODE_TYPE;
|
226 | 230 | ebd.hint_string = clazz.name;
|
227 | 231 | ebd.usage |= PropertyUsageFlags.PROPERTY_USAGE_SCRIPT_VARIABLE;
|
|
0 commit comments