Example #1
0
 public static string TTR(this string text)
 {
     using godot_string textIn = Marshaling.ConvertStringToNative(text);
     Internal.godot_icall_Globals_TTR(textIn, out godot_string dest);
     using (dest)
         return(Marshaling.ConvertStringToManaged(dest));
 }
Example #2
0
 /// <summary>
 /// Converts one or more arguments of any type to string in the best way possible.
 /// </summary>
 /// <param name="what">Arguments that will converted to string.</param>
 /// <returns>The string formed by the given arguments.</returns>
 public static string Str(params Variant[] what)
 {
     using var whatGodot = new Godot.Collections.Array(what);
     NativeFuncs.godotsharp_str((godot_array)whatGodot.NativeValue, out godot_string ret);
     using (ret)
         return(Marshaling.ConvertStringToManaged(ret));
 }
Example #3
0
        /// <summary>
        /// Converts this <see cref="Array"/> to a string.
        /// </summary>
        /// <returns>A string representation of this array.</returns>
        public override string ToString()
        {
            var self = (godot_array)NativeValue;

            NativeFuncs.godotsharp_array_to_string(ref self, out godot_string str);
            using (str)
                return(Marshaling.ConvertStringToManaged(str));
        }
Example #4
0
        /// <summary>
        /// Gets the resource or property name indicated by <paramref name="idx"/> (0 to <see cref="GetSubNameCount"/>).
        /// </summary>
        /// <param name="idx">The subname index.</param>
        /// <returns>The subname at the given index <paramref name="idx"/>.</returns>
        public string GetSubName(int idx)
        {
            var self = (godot_node_path)NativeValue;

            NativeFuncs.godotsharp_node_path_get_subname(self, idx, out godot_string subName);
            using (subName)
                return(Marshaling.ConvertStringToManaged(subName));
        }
Example #5
0
        /// <summary>
        /// Returns all subnames concatenated with a colon character (<c>:</c>)
        /// as separator, i.e. the right side of the first colon in a node path.
        /// </summary>
        /// <example>
        /// <code>
        /// var nodepath = new NodePath("Path2D/PathFollow2D/Sprite2D:texture:load_path");
        /// GD.Print(nodepath.GetConcatenatedSubnames()); // texture:load_path
        /// </code>
        /// </example>
        /// <returns>The subnames concatenated with <c>:</c>.</returns>
        public string GetConcatenatedSubNames()
        {
            var self = (godot_node_path)NativeValue;

            NativeFuncs.godotsharp_node_path_get_concatenated_subnames(self, out godot_string subNames);
            using (subNames)
                return(Marshaling.ConvertStringToManaged(subNames));
        }
Example #6
0
 private static bool IsAnyOS(IEnumerable <string> names)
 {
     Internal.godot_icall_Utils_OS_GetPlatformName(out godot_string dest);
     using (dest)
     {
         string platformName = Marshaling.ConvertStringToManaged(dest);
         return(names.Any(p => p.Equals(platformName, StringComparison.OrdinalIgnoreCase)));
     }
 }
Example #7
0
 private static bool IsOS(string name)
 {
     Internal.godot_icall_Utils_OS_GetPlatformName(out godot_string dest);
     using (dest)
     {
         string platformName = Marshaling.ConvertStringToManaged(dest);
         return(name.Equals(platformName, StringComparison.OrdinalIgnoreCase));
     }
 }
Example #8
0
        /// <summary>
        /// Converts this <see cref="NodePath"/> to a string.
        /// </summary>
        /// <returns>A string representation of this <see cref="NodePath"/>.</returns>
        public override string ToString()
        {
            if (IsEmpty)
            {
                return(string.Empty);
            }

            var src = (godot_node_path)NativeValue;

            NativeFuncs.godotsharp_node_path_as_string(out godot_string dest, src);
            using (dest)
                return(Marshaling.ConvertStringToManaged(dest));
        }
Example #9
0
 /// <summary>
 /// Converts a <c>Variant</c> <paramref name="var"/> to a formatted string that
 /// can later be parsed using <see cref="StrToVar(string)"/>.
 /// </summary>
 /// <example>
 /// <code>
 /// var a = new Godot.Collections.Dictionary { ["a"] = 1, ["b"] = 2 };
 /// GD.Print(GD.VarToStr(a));
 /// // Prints
 /// // {
 /// //    "a": 1,
 /// //    "b": 2
 /// // }
 /// </code>
 /// </example>
 /// <param name="var">Variant that will be converted to string.</param>
 /// <returns>The <c>Variant</c> encoded as a string.</returns>
 public static string VarToStr(Variant var)
 {
     NativeFuncs.godotsharp_var_to_str((godot_variant)var.NativeVar, out godot_string ret);
     using (ret)
         return(Marshaling.ConvertStringToManaged(ret));
 }