private void _HelperGetScripts(String path, List <string> unprocessed_dirs)
    {
        Godot.Directory dir = new Godot.Directory();
        dir.Open(path);
        dir.ListDirBegin();
        String filename = dir.GetNext();

        while (filename.Length != 0)
        {
            if (dir.CurrentIsDir())
            {
                if (filename[0] != '.')
                {
                    unprocessed_dirs.Add(path + "/" + filename);
                }
            }
            else
            {
                if (filename.Substring(filename.Length - 3).Equals(".cs"))
                {
                    paths_to_scripts.Add(path + "/" + filename);
                }
            }
            filename = dir.GetNext();
        }
    }
Esempio n. 2
0
    public override void _Ready()
    {
        var path = "res://art";

        dir.Open(path);
        dir.ListDirBegin();
        var fileName = dir.GetNext();

        while (fileName != "")
        {
            if ((fileName.Contains("board")) && (!fileName.Contains(".import")))
            {
                tabuleiro.Add((Texture)ResourceLoader.Load("res://art/" + fileName));
                GD.Print("lol = " + fileName);
            }
            if ((fileName.Contains("circulo")) && (!fileName.Contains(".import")))
            {
                circulo.Add((Texture)ResourceLoader.Load("res://art/" + fileName));
                GD.Print("bol = " + fileName);
            }
            if ((fileName.Contains("xis")) && (!fileName.Contains(".import")))
            {
                xis.Add((Texture)ResourceLoader.Load("res://art/" + fileName));
                GD.Print("gez = " + fileName);
            }
            fileName = dir.GetNext();
        }
        dir.ListDirEnd();
    }
Esempio n. 3
0
        /// <summary>
        /// Enumerate through all objects in a directory.
        /// </summary>
        public static IEnumerable <string> EnumerateDirectory(string rootpath)
        {
            List <string> ret = new List <string>();
            var           dir = new Godot.Directory();

            dir.Open(rootpath);
            dir.ListDirBegin();
            for (string path = dir.GetNext(); !string.IsNullOrEmpty(path); path = dir.GetNext())
            {
                if (path[0] != '.')
                {
                    ret.Add(dir.GetCurrentDir() + "/" + path);
                }
            }
            dir.ListDirEnd();
            return(ret);
        }
Esempio n. 4
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        _items = new Godot.Collections.Array <ItemResource>();
        Godot.Directory directory = new Godot.Directory();
        directory.Open("res://items");
        directory.ListDirBegin();

        String fileName = directory.GetNext();

        while (fileName != null && fileName.Length != 0)
        {
            if (!directory.CurrentIsDir() && fileName.Contains(".tres") && !fileName.Contains("ItemResource.tres") && !fileName.Contains("Pickup"))
            {
                ItemResource itemResource = ((ItemResource)GD.Load("res://items/" + fileName));

                _items.Add(itemResource);
            }
            fileName = directory.GetNext();
        }
        directory.ListDirEnd();
    }
        public static void scanDir <T>(string path, string filter, ref Godot.Collections.Dictionary <string, T> dic, object defaultObject)
        {
            if (defaultObject == null)
            {
                defaultObject = (bool)false;
            }

            List <string> names = new List <string>();

            if (!String.IsNullOrEmpty(path))
            {
                var dir = new Godot.Directory();
                dir.Open(path);
                dir.ListDirBegin();
                while (true)
                {
                    var file = dir.GetNext();

                    if (String.IsNullOrEmpty(file))
                    {
                        break;
                    }

                    else if (!file.BeginsWith(".") && file.Contains("." + filter))
                    {
                        var fileName = file.Replace("." + filter, "");
                        if (!names.Contains(fileName))
                        {
                            names.Add(fileName);
                        }
                    }
                }

                foreach (var x in names)
                {
                    if (!dic.ContainsKey(x))
                    {
                        if (defaultObject is Resource)
                        {
                            var df = (defaultObject as Resource);
                            df.ResourceLocalToScene = true;
                            var dup = (object)(df.Duplicate());
                            dic.Add(x, (T)dup);
                        }
                        else
                        {
                            dic.Add(x, (T)defaultObject);
                        }
                    }
                }

                foreach (var t in dic)
                {
                    if (!names.Contains(t.Key))
                    {
                        dic.Remove(t.Key);
                    }
                    else
                    {
                        if (t.Value is Resource)
                        {
                            (t.Value as Resource).ResourceLocalToScene = true;
                        }
                    }
                }
            }
            else
            {
                dic.Clear();
            }
        }