Пример #1
0
 def get_parent_class(cls, classname):
     ret = godot_string_alloc()
     lib.godot_string_new(ret)
     gd_classname = godot_string_from_pyobj(classname)
     args = ffi.new("godot_string**", gd_classname)
     lib.godot_method_bind_ptrcall(cls._meth_get_parent_class,
                                   cls._instance, ffi.cast("void**",
                                                           args), ret)
     raw_str = lib.godot_string_wide_str(ret)
     return ffi.string(raw_str)
Пример #2
0
 def get_class_consts(cls, classname):
     consts = []
     ret = godot_pool_string_array_alloc()
     lib.godot_pool_string_array_new(ret)
     gd_classname = godot_string_from_pyobj(classname)
     gd_true = godot_bool_alloc(True)
     args = ffi.new("void*[2]", [gd_classname, gd_true])
     # 2nd arg should be false, which what we get by not initializing it
     lib.godot_method_bind_ptrcall(cls._meth_get_integer_constant_list,
                                   cls._instance, args, ret)
     for i in range(lib.godot_pool_string_array_size(ret)):
         godot_str = lib.godot_pool_string_array_get(ret, i)
         raw_str = lib.godot_string_wide_str(ffi.addressof(godot_str))
         consts.append(ffi.string(raw_str))
     return consts
Пример #3
0
    def get_class_list(cls):
        ret = godot_pool_string_array_alloc()
        lib.godot_method_bind_ptrcall(cls._meth_get_class_list, cls._instance,
                                      ffi.NULL, ret)

        # Convert Godot return into Python civilized stuff
        unordered = []
        for i in range(lib.godot_pool_string_array_size(ret)):
            godot_str = lib.godot_pool_string_array_get(ret, i)
            raw_str = lib.godot_string_wide_str(ffi.addressof(godot_str))
            unordered.append(ffi.string(raw_str))

        # Order class to have a parent defined before their children
        classes = []
        while len(unordered) != len(classes):
            for classname in unordered:
                parentname = cls.get_parent_class(classname)
                if not parentname or parentname in classes:
                    if classname not in classes:
                        classes.append(classname)

        return classes
Пример #4
0
 def path(self):
     gd_repr = lib.godot_node_path_as_string(self._gd_ptr)
     return ffi.string(lib.godot_string_wide_str(ffi.addressof(gd_repr)))
Пример #5
0
 def __repr__(self):
     gd_repr = lib.godot_transform2d_as_string(self._gd_ptr)
     raw_str = lib.godot_string_wide_str(ffi.addressof(gd_repr))
     return "<%s(%s)>" % (type(self).__name__, ffi.string(raw_str))
Пример #6
0
def godot_string_to_pyobj(p_gdstring):
    raw_str = lib.godot_string_wide_str(p_gdstring)
    return ffi.string(raw_str)
Пример #7
0
 def to_html(self, with_alpha=True):
     gdstr = lib.godot_color_to_html(self._gd_ptr, with_alpha)
     return ffi.string(lib.godot_string_wide_str(ffi.addressof(gdstr)))