diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/etc/image_etc.cpp | 3 | ||||
-rw-r--r-- | modules/gdnative/SCsub | 12 | ||||
-rw-r--r-- | modules/gdnative/gdnative.cpp | 6 | ||||
-rw-r--r-- | modules/gdnative/gdnative.h | 7 | ||||
-rw-r--r-- | modules/gdnative/gdnative/array.cpp (renamed from modules/gdnative/godot/array.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/basis.cpp (renamed from modules/gdnative/godot/basis.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/color.cpp (renamed from modules/gdnative/godot/color.cpp) | 10 | ||||
-rw-r--r-- | modules/gdnative/gdnative/dictionary.cpp (renamed from modules/gdnative/godot/dictionary.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/gdnative.cpp (renamed from modules/gdnative/godot/gdnative.cpp) | 3 | ||||
-rw-r--r-- | modules/gdnative/gdnative/node_path.cpp (renamed from modules/gdnative/godot/node_path.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/plane.cpp (renamed from modules/gdnative/godot/plane.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/pool_arrays.cpp (renamed from modules/gdnative/godot/pool_arrays.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/quat.cpp (renamed from modules/gdnative/godot/quat.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/rect2.cpp (renamed from modules/gdnative/godot/rect2.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/rect3.cpp (renamed from modules/gdnative/godot/rect3.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/rid.cpp (renamed from modules/gdnative/godot/rid.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/string.cpp (renamed from modules/gdnative/godot/string.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/transform.cpp (renamed from modules/gdnative/godot/transform.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/transform2d.cpp (renamed from modules/gdnative/godot/transform2d.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/variant.cpp (renamed from modules/gdnative/godot/variant.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/vector2.cpp (renamed from modules/gdnative/godot/vector2.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/gdnative/vector3.cpp (renamed from modules/gdnative/godot/vector3.cpp) | 2 | ||||
-rw-r--r-- | modules/gdnative/godot/icon.png.import | 23 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/array.h (renamed from modules/gdnative/godot/array.h) | 6 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/basis.h (renamed from modules/gdnative/godot/basis.h) | 6 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/color.h (renamed from modules/gdnative/godot/color.h) | 8 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/dictionary.h (renamed from modules/gdnative/godot/dictionary.h) | 6 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/gdnative.h (renamed from modules/gdnative/godot/gdnative.h) | 60 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/node_path.h (renamed from modules/gdnative/godot/node_path.h) | 4 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/plane.h (renamed from modules/gdnative/godot/plane.h) | 4 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/pool_arrays.h (renamed from modules/gdnative/godot/pool_arrays.h) | 10 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/quat.h (renamed from modules/gdnative/godot/quat.h) | 4 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/rect2.h (renamed from modules/gdnative/godot/rect2.h) | 4 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/rect3.h (renamed from modules/gdnative/godot/rect3.h) | 6 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/rid.h (renamed from modules/gdnative/godot/rid.h) | 2 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/string.h (renamed from modules/gdnative/godot/string.h) | 4 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/transform.h (renamed from modules/gdnative/godot/transform.h) | 8 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/transform2d.h (renamed from modules/gdnative/godot/transform2d.h) | 6 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/variant.h (renamed from modules/gdnative/godot/variant.h) | 38 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/vector2.h (renamed from modules/gdnative/godot/vector2.h) | 2 | ||||
-rw-r--r-- | modules/gdnative/include/gdnative/vector3.h (renamed from modules/gdnative/godot/vector3.h) | 4 | ||||
-rw-r--r-- | modules/gdnative/include/nativescript/godot_nativescript.h (renamed from modules/nativescript/godot_nativescript.h) | 2 | ||||
-rw-r--r-- | modules/gdnative/nativescript/SCsub (renamed from modules/nativescript/SCsub) | 0 | ||||
-rw-r--r-- | modules/gdnative/nativescript/api_generator.cpp (renamed from modules/nativescript/api_generator.cpp) | 0 | ||||
-rw-r--r-- | modules/gdnative/nativescript/api_generator.h (renamed from modules/nativescript/api_generator.h) | 0 | ||||
-rw-r--r-- | modules/gdnative/nativescript/godot_nativescript.cpp (renamed from modules/nativescript/godot_nativescript.cpp) | 8 | ||||
-rw-r--r-- | modules/gdnative/nativescript/nativescript.cpp (renamed from modules/nativescript/nativescript.cpp) | 59 | ||||
-rw-r--r-- | modules/gdnative/nativescript/nativescript.h (renamed from modules/nativescript/nativescript.h) | 5 | ||||
-rw-r--r-- | modules/gdnative/nativescript/register_types.cpp (renamed from modules/nativescript/register_types.cpp) | 0 | ||||
-rw-r--r-- | modules/gdnative/nativescript/register_types.h (renamed from modules/nativescript/register_types.h) | 0 | ||||
-rw-r--r-- | modules/gdnative/register_types.cpp | 176 | ||||
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 6 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.cpp | 18 | ||||
-rw-r--r-- | modules/gdscript/gd_script.h | 1 | ||||
-rw-r--r-- | modules/gridmap/grid_map.cpp | 22 | ||||
-rw-r--r-- | modules/gridmap/grid_map.h | 1 | ||||
-rw-r--r-- | modules/nativescript/config.py | 8 | ||||
-rw-r--r-- | modules/pvr/texture_loader_pvr.cpp | 8 | ||||
-rw-r--r-- | modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 6 | ||||
-rw-r--r-- | modules/svg/image_loader_svg.cpp | 4 | ||||
-rw-r--r-- | modules/theora/video_stream_theora.cpp | 3 | ||||
-rw-r--r-- | modules/visual_script/visual_script.h | 1 | ||||
-rw-r--r-- | modules/visual_script/visual_script_editor.cpp | 179 | ||||
-rw-r--r-- | modules/visual_script/visual_script_editor.h | 7 | ||||
-rw-r--r-- | modules/visual_script/visual_script_expression.cpp | 1 | ||||
-rw-r--r-- | modules/visual_script/visual_script_nodes.cpp | 20 |
66 files changed, 463 insertions, 350 deletions
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index e86fd06d81..dc7d23bbd7 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -37,7 +37,6 @@ static Image::Format _get_etc2_mode(Image::DetectChannels format) { switch (format) { - case Image::DETECTED_L: case Image::DETECTED_R: return Image::FORMAT_ETC2_R11; @@ -47,7 +46,7 @@ static Image::Format _get_etc2_mode(Image::DetectChannels format) { case Image::DETECTED_RGB: return Image::FORMAT_ETC2_RGB8; - case Image::DETECTED_RGBA: + default: return Image::FORMAT_ETC2_RGBA8; // TODO: would be nice if we could use FORMAT_ETC2_RGB8A1 for FORMAT_RGBA5551 diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub index 65970d48c1..f386f2b542 100644 --- a/modules/gdnative/SCsub +++ b/modules/gdnative/SCsub @@ -2,12 +2,16 @@ Import('env') -env.add_source_files(env.modules_sources, "*.cpp") -env.add_source_files(env.modules_sources, "godot/*.cpp") +gdn_env = env.Clone() -env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN']) -env.Append(CPPPATH=['#modules/gdnative/']) +gdn_env.add_source_files(env.modules_sources, "*.cpp") +gdn_env.add_source_files(env.modules_sources, "gdnative/*.cpp") +gdn_env.add_source_files(env.modules_sources, "nativescript/*.cpp") + +gdn_env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN']) +gdn_env.Append(CPPPATH=['#modules/gdnative/include/']) if "platform" in env and env["platform"] == "x11": # there has to be a better solution? env.Append(LINKFLAGS=["-rdynamic"]) + env.use_ptrcall = True diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index ded987557c..6da538844a 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -100,6 +100,11 @@ GDNativeLibrary::~GDNativeLibrary() { void GDNativeLibrary::_bind_methods() { ClassDB::bind_method(D_METHOD("set_library_path", "platform", "path"), &GDNativeLibrary::set_library_path); ClassDB::bind_method(D_METHOD("get_library_path", "platform"), &GDNativeLibrary::get_library_path); + + ClassDB::bind_method(D_METHOD("is_singleton_gdnative"), &GDNativeLibrary::is_singleton_gdnative); + ClassDB::bind_method(D_METHOD("set_singleton_gdnative", "singleton"), &GDNativeLibrary::set_singleton_gdnative); + + ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "singleton_gdnative"), "set_singleton_gdnative", "is_singleton_gdnative"); } bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_value) { @@ -175,7 +180,6 @@ GDNative::GDNative() { } GDNative::~GDNative() { - // TODO(karroffel): implement ALL the things! } extern "C" void _api_anchor(); diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h index dc1c3507ec..4753c7efe5 100644 --- a/modules/gdnative/gdnative.h +++ b/modules/gdnative/gdnative.h @@ -35,7 +35,7 @@ #include "os/thread_safe.h" #include "resource.h" -#include <godot/gdnative.h> +#include "gdnative/gdnative.h" class GDNativeLibrary : public Resource { GDCLASS(GDNativeLibrary, Resource) @@ -77,6 +77,8 @@ class GDNativeLibrary : public Resource { String library_paths[NUM_PLATFORMS]; + bool singleton_gdnative = false; + protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; @@ -92,6 +94,9 @@ public: String get_library_path(StringName p_platform) const; String get_active_library_path() const; + + _FORCE_INLINE_ bool is_singleton_gdnative() const { return singleton_gdnative; } + _FORCE_INLINE_ void set_singleton_gdnative(bool p_singleton) { singleton_gdnative = p_singleton; } }; typedef godot_variant (*native_call_cb)(void *, godot_string *, godot_array *); diff --git a/modules/gdnative/godot/array.cpp b/modules/gdnative/gdnative/array.cpp index c3fde0e954..51c023981f 100644 --- a/modules/gdnative/godot/array.cpp +++ b/modules/gdnative/gdnative/array.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/array.h> +#include "gdnative/array.h" #include "core/array.h" #include "core/os/memory.h" diff --git a/modules/gdnative/godot/basis.cpp b/modules/gdnative/gdnative/basis.cpp index 1d7aa18a70..b1327cdaef 100644 --- a/modules/gdnative/godot/basis.cpp +++ b/modules/gdnative/gdnative/basis.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/basis.h> +#include "gdnative/basis.h" #include "core/math/matrix3.h" #include "core/variant.h" diff --git a/modules/gdnative/godot/color.cpp b/modules/gdnative/gdnative/color.cpp index 3677fdc265..2a5c0887a1 100644 --- a/modules/gdnative/godot/color.cpp +++ b/modules/gdnative/gdnative/color.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/color.h> +#include "gdnative/color.h" #include "core/color.h" #include "core/variant.h" @@ -112,14 +112,14 @@ godot_string GDAPI godot_color_as_string(const godot_color *p_self) { return ret; } -godot_int GDAPI godot_color_to_32(const godot_color *p_self) { +godot_int GDAPI godot_color_to_rgba32(const godot_color *p_self) { const Color *self = (const Color *)p_self; - return self->to_32(); + return self->to_rgba32(); } -godot_int GDAPI godot_color_to_ARGB32(const godot_color *p_self) { +godot_int GDAPI godot_color_to_argb32(const godot_color *p_self) { const Color *self = (const Color *)p_self; - return self->to_ARGB32(); + return self->to_argb32(); } godot_real GDAPI godot_color_gray(const godot_color *p_self) { diff --git a/modules/gdnative/godot/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp index 2996cc78a3..ed98cdbb00 100644 --- a/modules/gdnative/godot/dictionary.cpp +++ b/modules/gdnative/gdnative/dictionary.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/dictionary.h> +#include "gdnative/dictionary.h" #include "core/variant.h" // core/variant.h before to avoid compile errors with MSVC diff --git a/modules/gdnative/godot/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp index 7cd52da34d..cf1f6a4f16 100644 --- a/modules/gdnative/godot/gdnative.cpp +++ b/modules/gdnative/gdnative/gdnative.cpp @@ -27,11 +27,10 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/gdnative.h> +#include "gdnative/gdnative.h" #include "class_db.h" #include "error_macros.h" -#include "gdnative.h" #include "global_constants.h" #include "os/os.h" #include "project_settings.h" diff --git a/modules/gdnative/godot/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp index 2309588a81..50fade5b94 100644 --- a/modules/gdnative/godot/node_path.cpp +++ b/modules/gdnative/gdnative/node_path.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/node_path.h> +#include "gdnative/node_path.h" #include "core/node_path.h" #include "core/variant.h" diff --git a/modules/gdnative/godot/plane.cpp b/modules/gdnative/gdnative/plane.cpp index f3d4b6971e..a5e05ffa6b 100644 --- a/modules/gdnative/godot/plane.cpp +++ b/modules/gdnative/gdnative/plane.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/plane.h> +#include "gdnative/plane.h" #include "core/math/plane.h" #include "core/variant.h" diff --git a/modules/gdnative/godot/pool_arrays.cpp b/modules/gdnative/gdnative/pool_arrays.cpp index 49bf851051..1393374da2 100644 --- a/modules/gdnative/godot/pool_arrays.cpp +++ b/modules/gdnative/gdnative/pool_arrays.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/pool_arrays.h> +#include "gdnative/pool_arrays.h" #include "array.h" #include "core/variant.h" diff --git a/modules/gdnative/godot/quat.cpp b/modules/gdnative/gdnative/quat.cpp index e6bea78b60..7db7847da1 100644 --- a/modules/gdnative/godot/quat.cpp +++ b/modules/gdnative/gdnative/quat.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/quat.h> +#include "gdnative/quat.h" #include "core/math/quat.h" #include "core/variant.h" diff --git a/modules/gdnative/godot/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp index 98e7855dc9..ecd8cce9ca 100644 --- a/modules/gdnative/godot/rect2.cpp +++ b/modules/gdnative/gdnative/rect2.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/rect2.h> +#include "gdnative/rect2.h" #include "core/math/math_2d.h" #include "core/variant.h" diff --git a/modules/gdnative/godot/rect3.cpp b/modules/gdnative/gdnative/rect3.cpp index 88952ab49c..d34d964db9 100644 --- a/modules/gdnative/godot/rect3.cpp +++ b/modules/gdnative/gdnative/rect3.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/rect3.h> +#include "gdnative/rect3.h" #include "core/math/rect3.h" #include "core/variant.h" diff --git a/modules/gdnative/godot/rid.cpp b/modules/gdnative/gdnative/rid.cpp index 51c8aaa1b3..f05c39906c 100644 --- a/modules/gdnative/godot/rid.cpp +++ b/modules/gdnative/gdnative/rid.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/rid.h> +#include "gdnative/rid.h" #include "core/resource.h" #include "core/rid.h" diff --git a/modules/gdnative/godot/string.cpp b/modules/gdnative/gdnative/string.cpp index 1282cf95e5..9b715ce36a 100644 --- a/modules/gdnative/godot/string.cpp +++ b/modules/gdnative/gdnative/string.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/string.h> +#include "gdnative/string.h" #include "core/variant.h" #include "string_db.h" diff --git a/modules/gdnative/godot/transform.cpp b/modules/gdnative/gdnative/transform.cpp index a965067b77..d7a3e78d3f 100644 --- a/modules/gdnative/godot/transform.cpp +++ b/modules/gdnative/gdnative/transform.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/transform.h> +#include "gdnative/transform.h" #include "core/math/transform.h" #include "core/variant.h" diff --git a/modules/gdnative/godot/transform2d.cpp b/modules/gdnative/gdnative/transform2d.cpp index 9fc44ecdfa..dcb54f7a53 100644 --- a/modules/gdnative/godot/transform2d.cpp +++ b/modules/gdnative/gdnative/transform2d.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/transform2d.h> +#include "gdnative/transform2d.h" #include "core/math/math_2d.h" #include "core/variant.h" diff --git a/modules/gdnative/godot/variant.cpp b/modules/gdnative/gdnative/variant.cpp index 582544b3a0..b61f80b1f9 100644 --- a/modules/gdnative/godot/variant.cpp +++ b/modules/gdnative/gdnative/variant.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/variant.h> +#include "gdnative/variant.h" #include "core/variant.h" diff --git a/modules/gdnative/godot/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp index 78ed5f06a9..67f858997f 100644 --- a/modules/gdnative/godot/vector2.cpp +++ b/modules/gdnative/gdnative/vector2.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/vector2.h> +#include "gdnative/vector2.h" #include "core/math/math_2d.h" #include "core/variant.h" diff --git a/modules/gdnative/godot/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp index 5faeac2864..c85a3f1c08 100644 --- a/modules/gdnative/godot/vector3.cpp +++ b/modules/gdnative/gdnative/vector3.cpp @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <godot/vector3.h> +#include "gdnative/vector3.h" #include "core/variant.h" #include "core/vector.h" diff --git a/modules/gdnative/godot/icon.png.import b/modules/gdnative/godot/icon.png.import deleted file mode 100644 index 27920124f9..0000000000 --- a/modules/gdnative/godot/icon.png.import +++ /dev/null @@ -1,23 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/icon.png-aa47d037a37fb38b3b7e7828e4eec407.stex" - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -stream=false -size_limit=0 -detect_3d=true diff --git a/modules/gdnative/godot/array.h b/modules/gdnative/include/gdnative/array.h index 08f73c8785..edab028cba 100644 --- a/modules/gdnative/godot/array.h +++ b/modules/gdnative/include/gdnative/array.h @@ -46,10 +46,10 @@ typedef struct { } godot_array; #endif -#include <godot/pool_arrays.h> -#include <godot/variant.h> +#include <gdnative/pool_arrays.h> +#include <gdnative/variant.h> -#include <godot/gdnative.h> +#include <gdnative/gdnative.h> void GDAPI godot_array_new(godot_array *r_dest); void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src); diff --git a/modules/gdnative/godot/basis.h b/modules/gdnative/include/gdnative/basis.h index f36d2199de..8ff6a6f541 100644 --- a/modules/gdnative/godot/basis.h +++ b/modules/gdnative/include/gdnative/basis.h @@ -45,9 +45,9 @@ typedef struct { } godot_basis; #endif -#include <godot/gdnative.h> -#include <godot/quat.h> -#include <godot/vector3.h> +#include <gdnative/gdnative.h> +#include <gdnative/quat.h> +#include <gdnative/vector3.h> void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis); void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi); diff --git a/modules/gdnative/godot/color.h b/modules/gdnative/include/gdnative/color.h index 5d550e40b3..14265466b9 100644 --- a/modules/gdnative/godot/color.h +++ b/modules/gdnative/include/gdnative/color.h @@ -45,8 +45,8 @@ typedef struct { } godot_color; #endif -#include <godot/gdnative.h> -#include <godot/string.h> +#include <gdnative/gdnative.h> +#include <gdnative/string.h> void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a); void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b); @@ -69,9 +69,9 @@ godot_real godot_color_get_v(const godot_color *p_self); godot_string GDAPI godot_color_as_string(const godot_color *p_self); -godot_int GDAPI godot_color_to_32(const godot_color *p_self); +godot_int GDAPI godot_color_to_rgba32(const godot_color *p_self); -godot_int GDAPI godot_color_to_ARGB32(const godot_color *p_self); +godot_int GDAPI godot_color_to_argb32(const godot_color *p_self); godot_real GDAPI godot_color_gray(const godot_color *p_self); diff --git a/modules/gdnative/godot/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h index 10d580af08..c85c3f3830 100644 --- a/modules/gdnative/godot/dictionary.h +++ b/modules/gdnative/include/gdnative/dictionary.h @@ -45,9 +45,9 @@ typedef struct { } godot_dictionary; #endif -#include <godot/array.h> -#include <godot/gdnative.h> -#include <godot/variant.h> +#include <gdnative/array.h> +#include <gdnative/gdnative.h> +#include <gdnative/variant.h> void GDAPI godot_dictionary_new(godot_dictionary *r_dest); void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src); diff --git a/modules/gdnative/godot/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h index c71a7ae1ef..c574c56d5a 100644 --- a/modules/gdnative/godot/gdnative.h +++ b/modules/gdnative/include/gdnative/gdnative.h @@ -146,100 +146,74 @@ typedef float godot_real; /////// Object (forward declared) typedef void godot_object; -/////// Brute force forward declarations for the rest -/* -typedef struct godot_variant godot_variant; -typedef struct godot_string godot_string; -typedef struct godot_vector2 godot_vector2; -typedef struct godot_rect2 godot_rect2; -typedef struct godot_vector3 godot_vector3; -typedef struct godot_transform2d godot_transform2d; -typedef struct godot_plane godot_plane; -typedef struct godot_quat godot_quat; -typedef struct godot_rect3 godot_rect3; -typedef struct godot_basis godot_basis; -typedef struct godot_transform godot_transform; -typedef struct godot_color godot_color; -typedef struct godot_node_path godot_node_path; -typedef struct godot_rid godot_rid; -typedef struct godot_dictionary godot_dictionary; -typedef struct godot_array godot_array; -typedef struct godot_pool_byte_array godot_pool_byte_array; -typedef struct godot_pool_int_array godot_pool_int_array; -typedef struct godot_pool_real_array godot_pool_real_array; -typedef struct godot_pool_string_array godot_pool_string_array; -typedef struct godot_pool_vector2_array godot_pool_vector2_array; -typedef struct godot_pool_vector3_array godot_pool_vector3_array; -typedef struct godot_pool_color_array godot_pool_color_array; -*/ /////// String -#include <godot/string.h> +#include <gdnative/string.h> ////// Vector2 -#include <godot/vector2.h> +#include <gdnative/vector2.h> ////// Rect2 -#include <godot/rect2.h> +#include <gdnative/rect2.h> ////// Vector3 -#include <godot/vector3.h> +#include <gdnative/vector3.h> ////// Transform2D -#include <godot/transform2d.h> +#include <gdnative/transform2d.h> /////// Plane -#include <godot/plane.h> +#include <gdnative/plane.h> /////// Quat -#include <godot/quat.h> +#include <gdnative/quat.h> /////// Rect3 -#include <godot/rect3.h> +#include <gdnative/rect3.h> /////// Basis -#include <godot/basis.h> +#include <gdnative/basis.h> /////// Transform -#include <godot/transform.h> +#include <gdnative/transform.h> /////// Color -#include <godot/color.h> +#include <gdnative/color.h> /////// NodePath -#include <godot/node_path.h> +#include <gdnative/node_path.h> /////// RID -#include <godot/rid.h> +#include <gdnative/rid.h> /////// Dictionary -#include <godot/dictionary.h> +#include <gdnative/dictionary.h> /////// Array -#include <godot/array.h> +#include <gdnative/array.h> // single API file for Pool*Array -#include <godot/pool_arrays.h> +#include <gdnative/pool_arrays.h> void GDAPI godot_object_destroy(godot_object *p_o); ////// Variant -#include <godot/variant.h> +#include <gdnative/variant.h> ////// Singleton API diff --git a/modules/gdnative/godot/node_path.h b/modules/gdnative/include/gdnative/node_path.h index 2f71ddd59d..0cfdbc1127 100644 --- a/modules/gdnative/godot/node_path.h +++ b/modules/gdnative/include/gdnative/node_path.h @@ -45,8 +45,8 @@ typedef struct { } godot_node_path; #endif -#include <godot/gdnative.h> -#include <godot/string.h> +#include <gdnative/gdnative.h> +#include <gdnative/string.h> void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from); void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src); diff --git a/modules/gdnative/godot/plane.h b/modules/gdnative/include/gdnative/plane.h index 27548c8b0c..6a8915e08b 100644 --- a/modules/gdnative/godot/plane.h +++ b/modules/gdnative/include/gdnative/plane.h @@ -45,8 +45,8 @@ typedef struct { } godot_plane; #endif -#include <godot/gdnative.h> -#include <godot/vector3.h> +#include <gdnative/gdnative.h> +#include <gdnative/vector3.h> void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d); void GDAPI godot_plane_new_with_vectors(godot_plane *r_dest, const godot_vector3 *p_v1, const godot_vector3 *p_v2, const godot_vector3 *p_v3); diff --git a/modules/gdnative/godot/pool_arrays.h b/modules/gdnative/include/gdnative/pool_arrays.h index 1b51dca38c..cb1095ee8c 100644 --- a/modules/gdnative/godot/pool_arrays.h +++ b/modules/gdnative/include/gdnative/pool_arrays.h @@ -113,12 +113,12 @@ typedef struct { } godot_pool_color_array; #endif -#include <godot/array.h> -#include <godot/color.h> -#include <godot/vector2.h> -#include <godot/vector3.h> +#include <gdnative/array.h> +#include <gdnative/color.h> +#include <gdnative/vector2.h> +#include <gdnative/vector3.h> -#include <godot/gdnative.h> +#include <gdnative/gdnative.h> // byte diff --git a/modules/gdnative/godot/quat.h b/modules/gdnative/include/gdnative/quat.h index 9a3238a337..4ffb96eb26 100644 --- a/modules/gdnative/godot/quat.h +++ b/modules/gdnative/include/gdnative/quat.h @@ -45,8 +45,8 @@ typedef struct { } godot_quat; #endif -#include <godot/gdnative.h> -#include <godot/vector3.h> +#include <gdnative/gdnative.h> +#include <gdnative/vector3.h> void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w); void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle); diff --git a/modules/gdnative/godot/rect2.h b/modules/gdnative/include/gdnative/rect2.h index 8ceeddf1b4..9e6cf60342 100644 --- a/modules/gdnative/godot/rect2.h +++ b/modules/gdnative/include/gdnative/rect2.h @@ -43,8 +43,8 @@ typedef struct godot_rect2 { } godot_rect2; #endif -#include <godot/gdnative.h> -#include <godot/vector2.h> +#include <gdnative/gdnative.h> +#include <gdnative/vector2.h> void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size); void GDAPI godot_rect2_new(godot_rect2 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_width, const godot_real p_height); diff --git a/modules/gdnative/godot/rect3.h b/modules/gdnative/include/gdnative/rect3.h index ca96aadd5c..f94b6fea25 100644 --- a/modules/gdnative/godot/rect3.h +++ b/modules/gdnative/include/gdnative/rect3.h @@ -45,9 +45,9 @@ typedef struct { } godot_rect3; #endif -#include <godot/gdnative.h> -#include <godot/plane.h> -#include <godot/vector3.h> +#include <gdnative/gdnative.h> +#include <gdnative/plane.h> +#include <gdnative/vector3.h> void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size); diff --git a/modules/gdnative/godot/rid.h b/modules/gdnative/include/gdnative/rid.h index c56ff38735..d9b5336fc9 100644 --- a/modules/gdnative/godot/rid.h +++ b/modules/gdnative/include/gdnative/rid.h @@ -45,7 +45,7 @@ typedef struct { } godot_rid; #endif -#include <godot/gdnative.h> +#include <gdnative/gdnative.h> void GDAPI godot_rid_new(godot_rid *r_dest); diff --git a/modules/gdnative/godot/string.h b/modules/gdnative/include/gdnative/string.h index 128448e64e..aca23a81d8 100644 --- a/modules/gdnative/godot/string.h +++ b/modules/gdnative/include/gdnative/string.h @@ -46,8 +46,8 @@ typedef struct { } godot_string; #endif -#include <godot/gdnative.h> -#include <godot/variant.h> +#include <gdnative/gdnative.h> +#include <gdnative/variant.h> void GDAPI godot_string_new(godot_string *r_dest); void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src); diff --git a/modules/gdnative/godot/transform.h b/modules/gdnative/include/gdnative/transform.h index 60788e3d57..656afae129 100644 --- a/modules/gdnative/godot/transform.h +++ b/modules/gdnative/include/gdnative/transform.h @@ -45,10 +45,10 @@ typedef struct { } godot_transform; #endif -#include <godot/basis.h> -#include <godot/gdnative.h> -#include <godot/variant.h> -#include <godot/vector3.h> +#include <gdnative/basis.h> +#include <gdnative/gdnative.h> +#include <gdnative/variant.h> +#include <gdnative/vector3.h> void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin); void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin); diff --git a/modules/gdnative/godot/transform2d.h b/modules/gdnative/include/gdnative/transform2d.h index c0f5725eed..a945868b17 100644 --- a/modules/gdnative/godot/transform2d.h +++ b/modules/gdnative/include/gdnative/transform2d.h @@ -45,9 +45,9 @@ typedef struct { } godot_transform2d; #endif -#include <godot/gdnative.h> -#include <godot/variant.h> -#include <godot/vector2.h> +#include <gdnative/gdnative.h> +#include <gdnative/variant.h> +#include <gdnative/vector2.h> void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos); void GDAPI godot_transform2d_new_axis_origin(godot_transform2d *r_dest, const godot_vector2 *p_x_axis, const godot_vector2 *p_y_axis, const godot_vector2 *p_origin); diff --git a/modules/gdnative/godot/variant.h b/modules/gdnative/include/gdnative/variant.h index 849ba8bda6..969506585d 100644 --- a/modules/gdnative/godot/variant.h +++ b/modules/gdnative/include/gdnative/variant.h @@ -99,25 +99,25 @@ typedef struct godot_variant_call_error { godot_variant_type expected; } godot_variant_call_error; -#include <godot/array.h> -#include <godot/basis.h> -#include <godot/color.h> -#include <godot/dictionary.h> -#include <godot/node_path.h> -#include <godot/plane.h> -#include <godot/pool_arrays.h> -#include <godot/quat.h> -#include <godot/rect2.h> -#include <godot/rect3.h> -#include <godot/rid.h> -#include <godot/string.h> -#include <godot/transform.h> -#include <godot/transform2d.h> -#include <godot/variant.h> -#include <godot/vector2.h> -#include <godot/vector3.h> - -#include <godot/gdnative.h> +#include <gdnative/array.h> +#include <gdnative/basis.h> +#include <gdnative/color.h> +#include <gdnative/dictionary.h> +#include <gdnative/node_path.h> +#include <gdnative/plane.h> +#include <gdnative/pool_arrays.h> +#include <gdnative/quat.h> +#include <gdnative/rect2.h> +#include <gdnative/rect3.h> +#include <gdnative/rid.h> +#include <gdnative/string.h> +#include <gdnative/transform.h> +#include <gdnative/transform2d.h> +#include <gdnative/variant.h> +#include <gdnative/vector2.h> +#include <gdnative/vector3.h> + +#include <gdnative/gdnative.h> godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_v); diff --git a/modules/gdnative/godot/vector2.h b/modules/gdnative/include/gdnative/vector2.h index 98e9700e32..0af4abae27 100644 --- a/modules/gdnative/godot/vector2.h +++ b/modules/gdnative/include/gdnative/vector2.h @@ -45,7 +45,7 @@ typedef struct { } godot_vector2; #endif -#include <godot/gdnative.h> +#include <gdnative/gdnative.h> void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y); diff --git a/modules/gdnative/godot/vector3.h b/modules/gdnative/include/gdnative/vector3.h index b76ca11a9c..a27d516ec5 100644 --- a/modules/gdnative/godot/vector3.h +++ b/modules/gdnative/include/gdnative/vector3.h @@ -45,8 +45,8 @@ typedef struct { } godot_vector3; #endif -#include <godot/basis.h> -#include <godot/gdnative.h> +#include <gdnative/basis.h> +#include <gdnative/gdnative.h> typedef enum { GODOT_VECTOR3_AXIS_X, diff --git a/modules/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h index d1cbf221ec..96f213ead7 100644 --- a/modules/nativescript/godot_nativescript.h +++ b/modules/gdnative/include/nativescript/godot_nativescript.h @@ -30,7 +30,7 @@ #ifndef GODOT_NATIVESCRIPT_H #define GODOT_NATIVESCRIPT_H -#include <godot/gdnative.h> +#include <gdnative/gdnative.h> #ifdef __cplusplus extern "C" { diff --git a/modules/nativescript/SCsub b/modules/gdnative/nativescript/SCsub index e980e40e8e..e980e40e8e 100644 --- a/modules/nativescript/SCsub +++ b/modules/gdnative/nativescript/SCsub diff --git a/modules/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index fdd5a2ea19..fdd5a2ea19 100644 --- a/modules/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp diff --git a/modules/nativescript/api_generator.h b/modules/gdnative/nativescript/api_generator.h index 56c2d786e6..56c2d786e6 100644 --- a/modules/nativescript/api_generator.h +++ b/modules/gdnative/nativescript/api_generator.h diff --git a/modules/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp index 926b3261b2..61ac13b796 100644 --- a/modules/nativescript/godot_nativescript.cpp +++ b/modules/gdnative/nativescript/godot_nativescript.cpp @@ -27,17 +27,17 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "godot_nativescript.h" - -#include "nativescript.h" +#include "nativescript/godot_nativescript.h" #include "class_db.h" #include "error_macros.h" -#include "gdnative.h" +#include "gdnative/gdnative.h" #include "global_constants.h" #include "project_settings.h" #include "variant.h" +#include "nativescript.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/modules/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index e141080687..b9bd65af53 100644 --- a/modules/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "nativescript.h" -#include "modules/gdnative/godot/gdnative.h" +#include "gdnative/gdnative.h" #include "global_constants.h" #include "io/file_access_encrypted.h" @@ -315,7 +315,7 @@ void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const { bool NativeScript::get_property_default_value(const StringName &p_property, Variant &r_value) const { NativeScriptDesc *script_data = get_script_desc(); - Map<StringName, NativeScriptDesc::Property>::Element *P = NULL; + OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P; while (!P && script_data) { P = script_data->properties.find(p_property); script_data = script_data->base_data; @@ -323,7 +323,7 @@ bool NativeScript::get_property_default_value(const StringName &p_property, Vari if (!P) return false; - r_value = P->get().default_value; + r_value = P.get().default_value; return true; } @@ -355,23 +355,20 @@ void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const { void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const { NativeScriptDesc *script_data = get_script_desc(); - if (!script_data) - return; - - Set<PropertyInfo> properties; - + Set<StringName> existing_properties; while (script_data) { - - for (Map<StringName, NativeScriptDesc::Property>::Element *E = script_data->properties.front(); E; E = E->next()) { - properties.insert(E->get().info); + List<PropertyInfo>::Element *insert_position = p_list->front(); + bool insert_before = true; + + for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) { + if (!existing_properties.has(E.key())) { + insert_position = insert_before ? p_list->insert_before(insert_position, E.get().info) : p_list->insert_after(insert_position, E.get().info); + insert_before = false; + existing_properties.insert(E.key()); + } } - script_data = script_data->base_data; } - - for (Set<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - p_list->push_back(E->get()); - } } Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::CallError &r_error) { @@ -461,10 +458,10 @@ bool NativeScriptInstance::set(const StringName &p_name, const Variant &p_value) NativeScriptDesc *script_data = GET_SCRIPT_DESC(); while (script_data) { - Map<StringName, NativeScriptDesc::Property>::Element *P = script_data->properties.find(p_name); + OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = script_data->properties.find(p_name); if (P) { - P->get().setter.set_func((godot_object *)owner, - P->get().setter.method_data, + P.get().setter.set_func((godot_object *)owner, + P.get().setter.method_data, userdata, (godot_variant *)&p_value); return true; @@ -491,11 +488,11 @@ bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const { NativeScriptDesc *script_data = GET_SCRIPT_DESC(); while (script_data) { - Map<StringName, NativeScriptDesc::Property>::Element *P = script_data->properties.find(p_name); + OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = script_data->properties.find(p_name); if (P) { godot_variant value; - value = P->get().getter.get_func((godot_object *)owner, - P->get().getter.method_data, + value = P.get().getter.get_func((godot_object *)owner, + P.get().getter.method_data, userdata); r_ret = *(Variant *)&value; godot_variant_destroy(&value); @@ -592,10 +589,10 @@ Variant::Type NativeScriptInstance::get_property_type(const StringName &p_name, while (script_data) { - Map<StringName, NativeScriptDesc::Property>::Element *P = script_data->properties.find(p_name); + OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = script_data->properties.find(p_name); if (P) { *r_is_valid = true; - return P->get().info.type; + return P.get().info.type; } script_data = script_data->base_data; @@ -706,9 +703,9 @@ NativeScriptInstance::RPCMode NativeScriptInstance::get_rset_mode(const StringNa while (script_data) { - Map<StringName, NativeScriptDesc::Property>::Element *E = script_data->properties.find(p_variable); + OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.find(p_variable); if (E) { - switch (E->get().rset_mode) { + switch (E.get().rset_mode) { case GODOT_METHOD_RPC_MODE_DISABLED: return RPC_MODE_DISABLED; case GODOT_METHOD_RPC_MODE_REMOTE: @@ -796,12 +793,12 @@ void NativeScriptLanguage::_unload_stuff() { for (Map<StringName, NativeScriptDesc>::Element *C = L->get().front(); C; C = C->next()) { // free property stuff first - for (Map<StringName, NativeScriptDesc::Property>::Element *P = C->get().properties.front(); P; P = P->next()) { - if (P->get().getter.free_func) - P->get().getter.free_func(P->get().getter.method_data); + for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { + if (P.get().getter.free_func) + P.get().getter.free_func(P.get().getter.method_data); - if (P->get().setter.free_func) - P->get().setter.free_func(P->get().setter.method_data); + if (P.get().setter.free_func) + P.get().setter.free_func(P.get().setter.method_data); } // free method stuff diff --git a/modules/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index 571a3c9cc7..bc7e850d3e 100644 --- a/modules/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -32,14 +32,15 @@ #include "io/resource_loader.h" #include "io/resource_saver.h" +#include "ordered_hash_map.h" #include "os/thread_safe.h" #include "resource.h" #include "scene/main/node.h" #include "script_language.h" #include "self_list.h" -#include "godot_nativescript.h" #include "modules/gdnative/gdnative.h" +#include <nativescript/godot_nativescript.h> #ifndef NO_THREADS #include "os/mutex.h" @@ -65,7 +66,7 @@ struct NativeScriptDesc { }; Map<StringName, Method> methods; - Map<StringName, Property> properties; + OrderedHashMap<StringName, Property> properties; Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals StringName base; StringName base_native_type; diff --git a/modules/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp index b846710ab8..b846710ab8 100644 --- a/modules/nativescript/register_types.cpp +++ b/modules/gdnative/nativescript/register_types.cpp diff --git a/modules/nativescript/register_types.h b/modules/gdnative/nativescript/register_types.h index 7ac558f68f..7ac558f68f 100644 --- a/modules/nativescript/register_types.h +++ b/modules/gdnative/nativescript/register_types.h diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index 9ad05b7194..559e9fa455 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -28,12 +28,99 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "register_types.h" +#include "gdnative/gdnative.h" + #include "gdnative.h" #include "io/resource_loader.h" #include "io/resource_saver.h" +#include "nativescript/register_types.h" + +#include "core/engine.h" #include "core/os/os.h" +#include "core/project_settings.h" + +#ifdef TOOLS_ENABLED +#include "editor/editor_node.h" + +// Class used to discover singleton gdnative files + +void actual_discoverer_handler(); + +class GDNativeSingletonDiscover : public Object { + // GDCLASS(GDNativeSingletonDiscover, Object) + + virtual String get_class() const { + // okay, this is a really dirty hack. + // We're overriding get_class so we can connect it to a signal + // This works because get_class is a virtual method, so we don't + // need to register a new class to ClassDB just for this one + // little signal. + + actual_discoverer_handler(); + + return "Object"; + } +}; + +Set<String> get_gdnative_singletons(EditorFileSystemDirectory *p_dir) { + + Set<String> file_paths; + + // check children + + for (int i = 0; i < p_dir->get_file_count(); i++) { + String file_name = p_dir->get_file(i); + String file_type = p_dir->get_file_type(i); + + if (file_type != "GDNativeLibrary") { + continue; + } + + Ref<GDNativeLibrary> lib = ResourceLoader::load(p_dir->get_file_path(i)); + if (lib.is_valid() && lib->is_singleton_gdnative()) { + file_paths.insert(p_dir->get_file_path(i)); + } + } + + // check subdirectories + for (int i = 0; i < p_dir->get_subdir_count(); i++) { + Set<String> paths = get_gdnative_singletons(p_dir->get_subdir(i)); + + for (Set<String>::Element *E = paths.front(); E; E = E->next()) { + file_paths.insert(E->get()); + } + } + + return file_paths; +} + +void actual_discoverer_handler() { + EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem(); + + Set<String> file_paths = get_gdnative_singletons(dir); + + Array files; + files.resize(file_paths.size()); + int i = 0; + for (Set<String>::Element *E = file_paths.front(); E; i++, E = E->next()) { + files.set(i, E->get()); + } + + ProjectSettings::get_singleton()->set("gdnative/singletons", files); + + ProjectSettings::get_singleton()->save(); +} + +GDNativeSingletonDiscover *discoverer = NULL; + +void discoverer_callback() { + discoverer = memnew(GDNativeSingletonDiscover); + EditorFileSystem::get_singleton()->connect("filesystem_changed", discoverer, "get_class"); +} + +#endif godot_variant cb_standard_varcall(void *handle, godot_string *p_procedure, godot_array *p_args) { if (handle == NULL) { @@ -62,21 +149,110 @@ godot_variant cb_standard_varcall(void *handle, godot_string *p_procedure, godot return proc(NULL, p_args); } +void cb_singleton_call( + void *p_handle, + godot_string *p_proc_name, + void *p_data, + int p_num_args, + void **p_args, + void *r_return) { + if (p_handle == NULL) { + ERR_PRINT("No valid library handle, can't call singleton procedure"); + return; + } + + void *singleton_proc; + Error err = OS::get_singleton()->get_dynamic_library_symbol_handle( + p_handle, + *(String *)p_proc_name, + singleton_proc); + + if (err != OK) { + return; + } + + void (*singleton_procedure_ptr)() = (void (*)())singleton_proc; + singleton_procedure_ptr(); +} + GDNativeCallRegistry *GDNativeCallRegistry::singleton; +Vector<Ref<GDNative> > singleton_gdnatives; + void register_gdnative_types() { +#ifdef TOOLS_ENABLED + + if (Engine::get_singleton()->is_editor_hint()) { + EditorNode::add_init_callback(discoverer_callback); + } +#endif + ClassDB::register_class<GDNativeLibrary>(); ClassDB::register_class<GDNative>(); GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry); GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall); + + GDNativeCallRegistry::singleton->register_native_raw_call_type("gdnative_singleton_call", cb_singleton_call); + + register_nativescript_types(); + + // run singletons + + Array singletons = ProjectSettings::get_singleton()->get("gdnative/singletons"); + + singleton_gdnatives.resize(singletons.size()); + + for (int i = 0; i < singletons.size(); i++) { + String path = singletons[i]; + + Ref<GDNativeLibrary> lib = ResourceLoader::load(path); + + singleton_gdnatives[i].instance(); + singleton_gdnatives[i]->set_library(lib); + + if (!singleton_gdnatives[i]->initialize()) { + // Can't initialize. Don't make a native_call then + continue; + } + + singleton_gdnatives[i]->call_native_raw( + "gdnative_singleton_call", + "godot_gdnative_singleton", + NULL, + 0, + NULL, + NULL); + } } void unregister_gdnative_types() { + + for (int i = 0; i < singleton_gdnatives.size(); i++) { + + if (singleton_gdnatives[i].is_null()) { + continue; + } + + if (!singleton_gdnatives[i]->is_initialized()) { + continue; + } + + singleton_gdnatives[i]->terminate(); + } + + unregister_nativescript_types(); + memdelete(GDNativeCallRegistry::singleton); +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint() && discoverer != NULL) { + memdelete(discoverer); + } +#endif + // This is for printing out the sizes of the core types /* diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 70e7da5748..bc51b84047 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -866,7 +866,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: MethodBind *mb = ClassDB::get_method(base_type, getter); if (mb) { PropertyInfo rt = mb->get_return_info(); - if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM && t == Variant::INT) { + if ((rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM) && t == Variant::INT) { r_type.enumeration = rt.class_name; } else if (t == Variant::OBJECT) { @@ -1903,11 +1903,11 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N arghint += ", "; else arghint += " "; - if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) { + if (i == p_argidx || ((mi.flags & METHOD_FLAG_VARARG) && i > p_argidx)) { arghint += String::chr(0xFFFF); } arghint += _get_visual_datatype(mi.arguments[i]) + " " + mi.arguments[i].name; - if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) { + if (i == p_argidx || ((mi.flags & METHOD_FLAG_VARARG) && i > p_argidx)) { arghint += String::chr(0xFFFF); } } diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index f0cfdd6258..34d01c6beb 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -1177,20 +1177,28 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, VALIDATE_ARG_COUNT(1); switch (p_args[0]->get_type()) { + case Variant::STRING: { + + String d = *p_args[0]; + r_ret = d.length(); + } break; case Variant::DICTIONARY: { + Dictionary d = *p_args[0]; r_ret = d.size(); } break; case Variant::ARRAY: { + Array d = *p_args[0]; r_ret = d.size(); } break; case Variant::POOL_BYTE_ARRAY: { + PoolVector<uint8_t> d = *p_args[0]; r_ret = d.size(); - } break; case Variant::POOL_INT_ARRAY: { + PoolVector<int> d = *p_args[0]; r_ret = d.size(); } break; @@ -1200,14 +1208,14 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, r_ret = d.size(); } break; case Variant::POOL_STRING_ARRAY: { + PoolVector<String> d = *p_args[0]; r_ret = d.size(); - } break; case Variant::POOL_VECTOR2_ARRAY: { + PoolVector<Vector2> d = *p_args[0]; r_ret = d.size(); - } break; case Variant::POOL_VECTOR3_ARRAY: { @@ -1412,12 +1420,12 @@ MethodInfo GDFunctions::get_info(Function p_func) { } break; case MATH_ISNAN: { MethodInfo mi("is_nan", PropertyInfo(Variant::REAL, "s")); - mi.return_val.type = Variant::REAL; + mi.return_val.type = Variant::BOOL; return mi; } break; case MATH_ISINF: { MethodInfo mi("is_inf", PropertyInfo(Variant::REAL, "s")); - mi.return_val.type = Variant::REAL; + mi.return_val.type = Variant::BOOL; return mi; } break; case MATH_EASE: { diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 6f05a4770b..5e1a8b19ac 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -389,7 +389,6 @@ public: virtual bool can_inherit_from_file() { return true; } virtual int find_function(const String &p_function, const String &p_code) const; virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const; - virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return OK; } virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint); #ifdef TOOLS_ENABLED virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_base_path, Object *p_owner, LookupResult &r_result); diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 1b932f040e..4f7545a11d 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -396,8 +396,6 @@ bool GridMap::_octant_update(const OctantKey &p_key) { Map<int, List<Pair<Transform, IndexKey> > > multimesh_items; - print_line("updating octant " + itos(p_key.x) + ", " + itos(p_key.y) + ", " + itos(p_key.z) + " cells: " + itos(g.cells.size())); - for (Set<IndexKey>::Element *E = g.cells.front(); E; E = E->next()) { ERR_CONTINUE(!cell_map.has(E->get())); @@ -464,7 +462,6 @@ bool GridMap::_octant_update(const OctantKey &p_key) { //update multimeshes for (Map<int, List<Pair<Transform, IndexKey> > >::Element *E = multimesh_items.front(); E; E = E->next()) { - print_line("multimesh item " + itos(E->key()) + " transforms " + itos(E->get().size())); Octant::MultimeshInstance mmi; RID mm = VS::get_singleton()->multimesh_create(); @@ -655,6 +652,24 @@ void GridMap::_notification(int p_what) { //_update_area_instances(); } break; + case NOTIFICATION_VISIBILITY_CHANGED: { + _update_visibility(); + } break; + } +} + +void GridMap::_update_visibility() { + if (!is_inside_tree()) + return; + + _change_notify("visible"); + + for (Map<OctantKey, Octant *>::Element *e = octant_map.front(); e; e = e->next()) { + Octant *octant = e->value(); + for (int i = 0; i < octant->multimesh_instances.size(); i++) { + Octant::MultimeshInstance &mi = octant->multimesh_instances[i]; + VS::get_singleton()->instance_set_visible(mi.instance, is_visible()); + } } } @@ -720,6 +735,7 @@ void GridMap::_update_octants_callback() { to_delete.pop_back(); } + _update_visibility(); awaiting_update = false; } diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 9e1d250680..eb1b215696 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -190,6 +190,7 @@ protected: void _get_property_list(List<PropertyInfo> *p_list) const; void _notification(int p_what); + void _update_visibility(); static void _bind_methods(); public: diff --git a/modules/nativescript/config.py b/modules/nativescript/config.py deleted file mode 100644 index 9f57b9bb74..0000000000 --- a/modules/nativescript/config.py +++ /dev/null @@ -1,8 +0,0 @@ - - -def can_build(platform): - return True - - -def configure(env): - env.use_ptrcall = True diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 9989785c70..90ee164b6f 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -74,15 +74,11 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, uint32_t mipmaps = f->get_32(); uint32_t flags = f->get_32(); uint32_t surfsize = f->get_32(); - uint32_t bpp = f->get_32(); - uint32_t rmask = f->get_32(); - uint32_t gmask = f->get_32(); - uint32_t bmask = f->get_32(); - uint32_t amask = f->get_32(); + f->seek(f->get_pos() + 20); // bpp, rmask, gmask, bmask, amask uint8_t pvrid[5] = { 0, 0, 0, 0, 0 }; f->get_buffer(pvrid, 4); ERR_FAIL_COND_V(String((char *)pvrid) != "PVR!", RES()); - uint32_t surfcount = f->get_32(); + f->get_32(); // surfcount /* print_line("height: "+itos(height)); diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index df427907f8..9457fbfaf6 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -45,6 +45,12 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra while (todo && active) { int mixed = stb_vorbis_get_samples_float_interleaved(ogg_stream, 2, (float *)p_buffer, todo * 2); + if (vorbis_stream->channels == 1 && mixed > 0) { + //mix mono to stereo + for (int i = 0; i < mixed; i++) { + p_buffer[i].r = p_buffer[i].l; + } + } todo -= mixed; frames_mixed += mixed; diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index f5c379d32e..935a412ed1 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -75,8 +75,8 @@ void ImageLoaderSVG::_convert_colors(NSVGimage *p_svg_image, const Dictionary p_ if (r_c.get_type() == Variant::COLOR && n_c.get_type() == Variant::COLOR) { Color replace_color = r_c; Color new_color = n_c; - replace_colors_i.push_back(replace_color.to_ABGR32()); - new_colors_i.push_back(new_color.to_ABGR32()); + replace_colors_i.push_back(replace_color.to_abgr32()); + new_colors_i.push_back(new_color.to_abgr32()); } } diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 2a24f8d4d1..02b994f8db 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -414,7 +414,8 @@ void VideoStreamPlaybackTheora::update(float p_delta) { bool buffer_full = false; /* if there's pending, decoded audio, grab it */ - if ((ret = vorbis_synthesis_pcmout(&vd, &pcm)) > 0) { + ret = vorbis_synthesis_pcmout(&vd, &pcm); + if (ret > 0) { const int AUXBUF_LEN = 4096; int to_read = ret; diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index b2e7a6aa27..297e9e510f 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -571,7 +571,6 @@ public: virtual bool has_named_classes() const; virtual int find_function(const String &p_function, const String &p_code) const; virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const; - virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; } virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const; virtual void add_global_constant(const StringName &p_variable, const Variant &p_value); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 8386687c9f..dfec1eea60 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -506,7 +506,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->set_show_close_button(true); } - if (Object::cast_to<VisualScriptExpression>(*node)) { + if (Object::cast_to<VisualScriptExpression>(node.ptr())) { LineEdit *line_edit = memnew(LineEdit); line_edit->set_text(node->get_text()); @@ -520,10 +520,10 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->add_child(text); } - if (Object::cast_to<VisualScriptExpression>(*node)) { + if (Object::cast_to<VisualScriptComment>(node.ptr())) { Ref<VisualScriptComment> vsc = node; gnode->set_comment(true); - gnode->set_resizeable(true); + gnode->set_resizable(true); gnode->set_custom_minimum_size(vsc->get_size() * EDSCALE); gnode->connect("resize_request", this, "_comment_node_resized", varray(E->get())); } @@ -926,48 +926,6 @@ void VisualScriptEditor::_member_edited() { } } -void VisualScriptEditor::_override_pressed(int p_id) { - - //override a virtual function or method from base type - - ERR_FAIL_COND(!virtuals_in_menu.has(p_id)); - - VirtualInMenu vim = virtuals_in_menu[p_id]; - - String name = _validate_name(vim.name); - selected = name; - edited_func = selected; - Ref<VisualScriptFunction> func_node; - func_node.instance(); - func_node->set_name(vim.name); - - undo_redo->create_action(TTR("Add Function")); - undo_redo->add_do_method(script.ptr(), "add_function", name); - for (int i = 0; i < vim.args.size(); i++) { - func_node->add_argument(vim.args[i].first, vim.args[i].second); - } - - undo_redo->add_do_method(script.ptr(), "add_node", name, script->get_available_id(), func_node); - if (vim.ret != Variant::NIL || vim.ret_variant) { - Ref<VisualScriptReturn> ret_node; - ret_node.instance(); - ret_node->set_return_type(vim.ret); - ret_node->set_enable_return_value(true); - ret_node->set_name(vim.name); - undo_redo->add_do_method(script.ptr(), "add_node", name, script->get_available_id() + 1, ret_node, Vector2(500, 0)); - } - - undo_redo->add_undo_method(script.ptr(), "remove_function", name); - undo_redo->add_do_method(this, "_update_members"); - undo_redo->add_undo_method(this, "_update_members"); - undo_redo->add_do_method(this, "_update_graph"); - undo_redo->add_undo_method(this, "_update_graph"); - - undo_redo->commit_action(); - - _update_graph(); -} - void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_button) { TreeItem *ti = Object::cast_to<TreeItem>(p_item); @@ -980,64 +938,9 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt //add function, this one uses menu if (p_button == 1) { - new_function_menu->clear(); - new_function_menu->set_size(Size2(0, 0)); - int idx = 0; - - virtuals_in_menu.clear(); - - List<MethodInfo> mi; - ClassDB::get_method_list(script->get_instance_base_type(), &mi); - for (List<MethodInfo>::Element *E = mi.front(); E; E = E->next()) { - MethodInfo mi = E->get(); - if (mi.flags & METHOD_FLAG_VIRTUAL) { - - VirtualInMenu vim; - vim.name = mi.name; - vim.ret = mi.return_val.type; - if (mi.return_val.name != String()) - vim.ret_variant = true; - else - vim.ret_variant = false; - - String desc; - - if (mi.return_val.type == Variant::NIL) - desc = "var"; - else - desc = Variant::get_type_name(mi.return_val.type); - desc += " " + mi.name + " ( "; - - for (int i = 0; i < mi.arguments.size(); i++) { - - if (i > 0) - desc += ", "; - - if (mi.arguments[i].type == Variant::NIL) - desc += "var "; - else - desc += Variant::get_type_name(mi.arguments[i].type) + " "; - - desc += mi.arguments[i].name; - - Pair<Variant::Type, String> p; - p.first = mi.arguments[i].type; - p.second = mi.arguments[i].name; - vim.args.push_back(p); - } - desc += " )"; + new_virtual_method_select->select_method_from_base_type(script->get_instance_base_type(), String(), true); - virtuals_in_menu[idx] = vim; - - new_function_menu->add_item(desc, idx); - idx++; - } - } - - Rect2 pos = members->get_item_rect(ti); - new_function_menu->set_position(members->get_global_position() + pos.position + Vector2(0, pos.size.y)); - new_function_menu->popup(); return; } else if (p_button == 0) { @@ -2686,21 +2589,21 @@ void VisualScriptEditor::_selected_connect_node_method_or_setget(const String &p Ref<VisualScriptNode> vsn = script->get_node(edited_func, port_action_new_node); - if (Object::cast_to<VisualScriptFunctionCall>(*vsn)) { + if (Object::cast_to<VisualScriptFunctionCall>(vsn.ptr())) { Ref<VisualScriptFunctionCall> vsfc = vsn; vsfc->set_function(p_text); script->data_connect(edited_func, port_action_node, port_action_output, port_action_new_node, 0); } - if (Object::cast_to<VisualScriptPropertySet>(*vsn)) { + if (Object::cast_to<VisualScriptPropertySet>(vsn.ptr())) { Ref<VisualScriptPropertySet> vsp = vsn; vsp->set_property(p_text); script->data_connect(edited_func, port_action_node, port_action_output, port_action_new_node, 0); } - if (Object::cast_to<VisualScriptPropertyGet>(*vsn)) { + if (Object::cast_to<VisualScriptPropertyGet>(vsn.ptr())) { Ref<VisualScriptPropertyGet> vsp = vsn; vsp->set_property(p_text); @@ -2711,6 +2614,63 @@ void VisualScriptEditor::_selected_connect_node_method_or_setget(const String &p _update_graph_connections(); } +void VisualScriptEditor::_selected_new_virtual_method(const String &p_text) { + + String name = p_text; + if (script->has_function(name)) { + EditorNode::get_singleton()->show_warning(vformat(TTR("Script already has function '%s'"), name)); + return; + } + + MethodInfo minfo; + { + List<MethodInfo> methods; + bool found = false; + ClassDB::get_virtual_methods(script->get_instance_base_type(), &methods); + for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { + if (E->get().name == name) { + minfo = E->get(); + found = true; + } + } + + ERR_FAIL_COND(!found); + } + + selected = name; + edited_func = selected; + Ref<VisualScriptFunction> func_node; + func_node.instance(); + func_node->set_name(name); + + undo_redo->create_action(TTR("Add Function")); + undo_redo->add_do_method(script.ptr(), "add_function", name); + + for (int i = 0; i < minfo.arguments.size(); i++) { + func_node->add_argument(minfo.arguments[i].type, minfo.arguments[i].name); + } + + undo_redo->add_do_method(script.ptr(), "add_node", name, script->get_available_id(), func_node); + if (minfo.return_val.type != Variant::NIL || minfo.return_val.usage & PROPERTY_USAGE_NIL_IS_VARIANT) { + Ref<VisualScriptReturn> ret_node; + ret_node.instance(); + ret_node->set_return_type(minfo.return_val.type); + ret_node->set_enable_return_value(true); + ret_node->set_name(name); + undo_redo->add_do_method(script.ptr(), "add_node", name, script->get_available_id() + 1, ret_node, Vector2(500, 0)); + } + + undo_redo->add_undo_method(script.ptr(), "remove_function", name); + undo_redo->add_do_method(this, "_update_members"); + undo_redo->add_undo_method(this, "_update_members"); + undo_redo->add_do_method(this, "_update_graph"); + undo_redo->add_undo_method(this, "_update_graph"); + + undo_redo->commit_action(); + + _update_graph(); +} + void VisualScriptEditor::_cancel_connect_node_method_or_setget() { script->remove_node(edited_func, port_action_new_node); @@ -3147,7 +3107,6 @@ void VisualScriptEditor::_bind_methods() { ClassDB::bind_method("_update_members", &VisualScriptEditor::_update_members); ClassDB::bind_method("_change_base_type", &VisualScriptEditor::_change_base_type); ClassDB::bind_method("_change_base_type_callback", &VisualScriptEditor::_change_base_type_callback); - ClassDB::bind_method("_override_pressed", &VisualScriptEditor::_override_pressed); ClassDB::bind_method("_node_selected", &VisualScriptEditor::_node_selected); ClassDB::bind_method("_node_moved", &VisualScriptEditor::_node_moved); ClassDB::bind_method("_move_node", &VisualScriptEditor::_move_node); @@ -3166,6 +3125,8 @@ void VisualScriptEditor::_bind_methods() { ClassDB::bind_method("_button_resource_previewed", &VisualScriptEditor::_button_resource_previewed); ClassDB::bind_method("_port_action_menu", &VisualScriptEditor::_port_action_menu); ClassDB::bind_method("_selected_connect_node_method_or_setget", &VisualScriptEditor::_selected_connect_node_method_or_setget); + ClassDB::bind_method("_selected_new_virtual_method", &VisualScriptEditor::_selected_new_virtual_method); + ClassDB::bind_method("_cancel_connect_node_method_or_setget", &VisualScriptEditor::_cancel_connect_node_method_or_setget); ClassDB::bind_method("_expression_text_changed", &VisualScriptEditor::_expression_text_changed); @@ -3344,9 +3305,6 @@ VisualScriptEditor::VisualScriptEditor() { undo_redo = EditorNode::get_singleton()->get_undo_redo(); - new_function_menu = memnew(PopupMenu); - new_function_menu->connect("id_pressed", this, "_override_pressed"); - add_child(new_function_menu); updating_members = false; set_process_input(true); //for revert on drag @@ -3366,6 +3324,11 @@ VisualScriptEditor::VisualScriptEditor() { new_connect_node_select->connect("selected", this, "_selected_connect_node_method_or_setget"); new_connect_node_select->get_cancel()->connect("pressed", this, "_cancel_connect_node_method_or_setget"); + new_virtual_method_select = memnew(PropertySelector); + add_child(new_virtual_method_select); + new_virtual_method_select->connect("selected", this, "_selected_new_virtual_method"); + new_virtual_method_select->get_cancel()->connect("pressed", this, "_selected_new_virtual_method"); + port_action_popup = memnew(PopupMenu); add_child(port_action_popup); port_action_popup->connect("id_pressed", this, "_port_action_menu"); diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index dd051ef8e4..5b8c3ea74e 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -103,6 +103,7 @@ class VisualScriptEditor : public ScriptEditorBase { PropertySelector *method_select; PropertySelector *new_connect_node_select; + PropertySelector *new_virtual_method_select; VisualScriptEditorVariableEdit *variable_editor; @@ -135,10 +136,6 @@ class VisualScriptEditor : public ScriptEditorBase { Vector<Pair<Variant::Type, String> > args; }; - Map<int, VirtualInMenu> virtuals_in_menu; - - PopupMenu *new_function_menu; - StringName edited_func; void _update_graph_connections(); @@ -177,6 +174,7 @@ class VisualScriptEditor : public ScriptEditorBase { void _port_action_menu(int p_option); void _selected_connect_node_method_or_setget(const String &p_text); void _cancel_connect_node_method_or_setget(); + void _selected_new_virtual_method(const String &p_text); int error_line; @@ -188,7 +186,6 @@ class VisualScriptEditor : public ScriptEditorBase { void _change_base_type(); void _member_selected(); void _member_edited(); - void _override_pressed(int p_id); void _begin_node_move(); void _end_node_move(); diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index d0e9b5bb86..eae866d167 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -831,7 +831,6 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { case TK_BUILTIN_FUNC: { //builtin function - Variant::Type bt = Variant::Type(int(tk.value)); _get_token(tk); if (tk.type != TK_PARENTHESIS_OPEN) { _set_error("Expected '('"); diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 1decc004ab..093f01c49f 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1493,7 +1493,7 @@ void VisualScriptGlobalConstant::_bind_methods() { cc += ","; cc += GlobalConstants::get_global_constant_name(i); } - ADD_PROPERTY(PropertyInfo(Variant::INT, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_global_constant", "get_global_constant"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "constant", PROPERTY_HINT_ENUM, cc), "set_global_constant", "get_global_constant"); } VisualScriptGlobalConstant::VisualScriptGlobalConstant() { @@ -1622,7 +1622,7 @@ void VisualScriptClassConstant::_bind_methods() { ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptClassConstant::get_base_type); ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, ""), "set_class_constant", "get_class_constant"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, ""), "set_class_constant", "get_class_constant"); } VisualScriptClassConstant::VisualScriptClassConstant() { @@ -1760,7 +1760,7 @@ void VisualScriptBasicTypeConstant::_bind_methods() { } ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, argt), "set_basic_type", "get_basic_type"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, ""), "set_basic_type_constant", "get_basic_type_constant"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, ""), "set_basic_type_constant", "get_basic_type_constant"); } VisualScriptBasicTypeConstant::VisualScriptBasicTypeConstant() { @@ -1881,7 +1881,7 @@ void VisualScriptMathConstant::_bind_methods() { cc += ","; cc += const_name[i]; } - ADD_PROPERTY(PropertyInfo(Variant::INT, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_math_constant", "get_math_constant"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "constant", PROPERTY_HINT_ENUM, cc), "set_math_constant", "get_math_constant"); } VisualScriptMathConstant::VisualScriptMathConstant() { @@ -2002,7 +2002,7 @@ void VisualScriptEngineSingleton::_bind_methods() { cc += E->get().name; } - ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_singleton", "get_singleton"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "/constant", PROPERTY_HINT_ENUM, cc), "set_singleton", "get_singleton"); } VisualScriptEngineSingleton::VisualScriptEngineSingleton() { @@ -3727,11 +3727,11 @@ void register_visual_script_nodes() { VisualScriptLanguage::singleton->add_register_func("data/preload", create_node_generic<VisualScriptPreload>); VisualScriptLanguage::singleton->add_register_func("data/action", create_node_generic<VisualScriptInputAction>); - VisualScriptLanguage::singleton->add_register_func("constant/constants/constant", create_node_generic<VisualScriptConstant>); - VisualScriptLanguage::singleton->add_register_func("constant/constants/math_constant", create_node_generic<VisualScriptMathConstant>); - VisualScriptLanguage::singleton->add_register_func("constant/constants/class_constant", create_node_generic<VisualScriptClassConstant>); - VisualScriptLanguage::singleton->add_register_func("constant/constants/global_constant", create_node_generic<VisualScriptGlobalConstant>); - VisualScriptLanguage::singleton->add_register_func("constant/constants/basic_type_constant", create_node_generic<VisualScriptBasicTypeConstant>); + VisualScriptLanguage::singleton->add_register_func("constants/constant", create_node_generic<VisualScriptConstant>); + VisualScriptLanguage::singleton->add_register_func("constants/math_constant", create_node_generic<VisualScriptMathConstant>); + VisualScriptLanguage::singleton->add_register_func("constants/class_constant", create_node_generic<VisualScriptClassConstant>); + VisualScriptLanguage::singleton->add_register_func("constants/global_constant", create_node_generic<VisualScriptGlobalConstant>); + VisualScriptLanguage::singleton->add_register_func("constants/basic_type_constant", create_node_generic<VisualScriptBasicTypeConstant>); VisualScriptLanguage::singleton->add_register_func("custom/custom_node", create_node_generic<VisualScriptCustomNode>); VisualScriptLanguage::singleton->add_register_func("custom/sub_call", create_node_generic<VisualScriptSubCall>); |