1 /*************************************************************************/
2 /*  godot_nativescript.h                                                 */
3 /*************************************************************************/
4 /*                       This file is part of:                           */
5 /*                           GODOT ENGINE                                */
6 /*                    http://www.godotengine.org                         */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur.                 */
9 /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md)    */
10 /*                                                                       */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the       */
13 /* "Software"), to deal in the Software without restriction, including   */
14 /* without limitation the rights to use, copy, modify, merge, publish,   */
15 /* distribute, sublicense, and/or sell copies of the Software, and to    */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions:                                             */
18 /*                                                                       */
19 /* The above copyright notice and this permission notice shall be        */
20 /* included in all copies or substantial portions of the Software.       */
21 /*                                                                       */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
29 /*************************************************************************/
30 module godot.c.nativescript;
31 
32 @nogc nothrow:
33 extern(C):
34 
35 import godot.c.core;
36 
37 enum godot_method_rpc_mode {
38 	GODOT_METHOD_RPC_MODE_DISABLED,
39 	GODOT_METHOD_RPC_MODE_REMOTE,
40 	GODOT_METHOD_RPC_MODE_SYNC,
41 	GODOT_METHOD_RPC_MODE_MASTER,
42 	GODOT_METHOD_RPC_MODE_SLAVE,
43 }
44 
45 struct godot_method_attributes {
46 	godot_method_rpc_mode rpc_type;
47 }
48 
49 enum godot_property_hint {
50 	GODOT_PROPERTY_HINT_NONE, ///< no hint provided.
51 	GODOT_PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional"
52 	GODOT_PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit
53 	GODOT_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
54 	GODOT_PROPERTY_HINT_EXP_EASING, /// exponential easing funciton (Math::ease)
55 	GODOT_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
56 	GODOT_PROPERTY_HINT_SPRITE_FRAME,
57 	GODOT_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
58 	GODOT_PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
59 	GODOT_PROPERTY_HINT_LAYERS_2D_RENDER,
60 	GODOT_PROPERTY_HINT_LAYERS_2D_PHYSICS,
61 	GODOT_PROPERTY_HINT_LAYERS_3D_RENDER,
62 	GODOT_PROPERTY_HINT_LAYERS_3D_PHYSICS,
63 	GODOT_PROPERTY_HINT_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"
64 	GODOT_PROPERTY_HINT_DIR, ///< a directort path must be passed
65 	GODOT_PROPERTY_HINT_GLOBAL_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"
66 	GODOT_PROPERTY_HINT_GLOBAL_DIR, ///< a directort path must be passed
67 	GODOT_PROPERTY_HINT_RESOURCE_TYPE, ///< a resource object type
68 	GODOT_PROPERTY_HINT_MULTILINE_TEXT, ///< used for string properties that can contain multiple lines
69 	GODOT_PROPERTY_HINT_COLOR_NO_ALPHA, ///< used for ignoring alpha component when editing a color
70 	GODOT_PROPERTY_HINT_IMAGE_COMPRESS_LOSSY,
71 	GODOT_PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS,
72 	GODOT_PROPERTY_HINT_OBJECT_ID,
73 	GODOT_PROPERTY_HINT_TYPE_STRING, ///< a type string, the hint is the base type to choose
74 	GODOT_PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE, ///< so something else can provide this (used in scripts)
75 	GODOT_PROPERTY_HINT_METHOD_OF_VARIANT_TYPE, ///< a method of a type
76 	GODOT_PROPERTY_HINT_METHOD_OF_BASE_TYPE, ///< a method of a base type
77 	GODOT_PROPERTY_HINT_METHOD_OF_INSTANCE, ///< a method of an instance
78 	GODOT_PROPERTY_HINT_METHOD_OF_SCRIPT, ///< a method of a script & base
79 	GODOT_PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type
80 	GODOT_PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type
81 	GODOT_PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance
82 	GODOT_PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base
83 	GODOT_PROPERTY_HINT_MAX,
84 }
85 
86 enum godot_property_usage_flags {
87 
88 	GODOT_PROPERTY_USAGE_STORAGE = 1,
89 	GODOT_PROPERTY_USAGE_EDITOR = 2,
90 	GODOT_PROPERTY_USAGE_NETWORK = 4,
91 	GODOT_PROPERTY_USAGE_EDITOR_HELPER = 8,
92 	GODOT_PROPERTY_USAGE_CHECKABLE = 16, //used for editing global variables
93 	GODOT_PROPERTY_USAGE_CHECKED = 32, //used for editing global variables
94 	GODOT_PROPERTY_USAGE_INTERNATIONALIZED = 64, //hint for internationalized strings
95 	GODOT_PROPERTY_USAGE_GROUP = 128, //used for grouping props in the editor
96 	GODOT_PROPERTY_USAGE_CATEGORY = 256,
97 	GODOT_PROPERTY_USAGE_STORE_IF_NONZERO = 512, //only store if nonzero
98 	GODOT_PROPERTY_USAGE_STORE_IF_NONONE = 1024, //only store if false
99 	GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE = 2048,
100 	GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED = 4096,
101 	GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE = 8192,
102 	GODOT_PROPERTY_USAGE_STORE_IF_NULL = 16384,
103 	GODOT_PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768,
104 	GODOT_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536,
105 
106 	GODOT_PROPERTY_USAGE_DEFAULT = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK,
107 	GODOT_PROPERTY_USAGE_DEFAULT_INTL = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK | GODOT_PROPERTY_USAGE_INTERNATIONALIZED,
108 	GODOT_PROPERTY_USAGE_NOEDITOR = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_NETWORK,
109 }
110 
111 struct godot_property_attributes {
112 align(1):
113 	godot_method_rpc_mode rset_type;
114 
115 	godot_int type;
116 	godot_property_hint hint = godot_property_hint.GODOT_PROPERTY_HINT_NONE;
117 	godot_string hint_string;
118 	godot_property_usage_flags usage = godot_property_usage_flags.GODOT_PROPERTY_USAGE_DEFAULT;
119 	godot_variant default_value;
120 }
121 
122 struct godot_instance_create_func {
123 	// instance pointer, method_data - return user data
124 	void* function(godot_object , void* ) create_func;
125 	void* method_data;
126 	void function(void* ) free_func;
127 }
128 
129 struct godot_instance_destroy_func {
130 	// instance pointer, method data, user data
131 	void function(godot_object , void* , void* ) destroy_func;
132 	void* method_data;
133 	void function(void* ) free_func;
134 }
135 
136 struct godot_instance_method {
137 	// instance pointer, method data, user data, num args, args - return result as varaint
138 	godot_variant function(godot_object , void* , void* , int, godot_variant**) method;
139 	void* method_data;
140 	void function(void* ) free_func;
141 }
142 
143 struct godot_property_set_func {
144 	// instance pointer, method data, user data, value
145 	void function(godot_object , void* , void* , godot_variant *) set_func;
146 	void* method_data;
147 	void function(void* ) free_func;
148 }
149 
150 struct godot_property_get_func {
151 	// instance pointer, method data, user data, value
152 	godot_variant function(godot_object , void* , void* ) get_func;
153 	void* method_data;
154 	void function(void* ) free_func;
155 }
156 
157 struct godot_signal_argument {
158 align(1):
159 	godot_string name;
160 	godot_int type;
161 	godot_property_hint hint;
162 	godot_string hint_string;
163 	godot_property_usage_flags usage;
164 	godot_variant default_value;
165 }
166 
167 struct godot_signal {
168 	godot_string name;
169 	int num_args;
170 	godot_signal_argument* args;
171 	int num_default_args;
172 	godot_variant* default_args;
173 }
174 
175 // NativeScript 1.1
176 
177 struct godot_method_arg
178 {
179 	godot_string name;
180 	godot_variant_type type;
181 	godot_property_hint hint;
182 	godot_string hint_string;
183 }
184 
185 struct godot_instance_binding_functions
186 {
187 	void* function(void *, godot_object) alloc_instance_binding_data;
188 	void function(void *, void *) free_instance_binding_data;
189 	void* data;
190 	void function(void *) free_func;
191 }
192 
193