//  // Called every frame. 'delta' is the elapsed time since the previous frame.
//  public override void _Process(float delta)
//  {
//
//  }

    void FillAudioDict(string path, Dictionary <string, AudioStream> dict)
    {
        Directory audioDirectory = new Directory();

        audioDirectory.ChangeDir(path);
        audioDirectory.ListDirBegin(true, true);
        string file = audioDirectory.GetNext();

        while (file != "")
        {
            if (!file.Contains(".import"))
            {
                audioList.Add(file, (AudioStream)ResourceLoader.Load(path + file));
            }

            file = audioDirectory.GetNext();
        }
    }
示例#2
0
    /// <summary>
    /// Makes sure the plugin directory exists and is accessible
    /// </summary>
    private void ValidatePluginDirectory()
    {
        String PluginFolderPath = UserDataDirectory + "/plugins/";
        bool   PluginPathExists = System.IO.Directory.Exists(PluginFolderPath);

        PluginDir = new Directory();

        if (!PluginPathExists)
        {
            GD.PushWarning("ERROR: Plugin directory does not exist, creating...");
            var err = PluginDir.MakeDirRecursive(PluginFolderPath);
            if (err != Error.Ok)
            {
                GD.PushError("ERROR: Cannot create directory, " + err);
            }
        }

        var err2   = PluginDir.ChangeDir(PluginFolderPath);
        var curDir = PluginDir.GetCurrentDir();

        GD.Print("PLUGIN DIR SET TO : " + curDir);
    }
示例#3
0
        public static bool TryGetSqlFilesInDirectory(string dirPath, out Array <string> filePaths, bool recursive = true)
        {
            Array <string> resultFilePaths = new Array <string>();

            using (Directory dir = new Directory())
            {
                if (dir.ChangeDir(dirPath) != Error.Ok)
                {
                    Log.Error("The directory (" + dirPath + ") didn't exist", true);
                    // error switch here
                    filePaths = null;
                    return(false);
                }

                dir.ListDirBegin(true, true);

                using (File file = new File())
                {
                    string currentItemName = dir.GetNext();

                    while (currentItemName != String.Empty)
                    {
                        string currentItemPath = Paths.Combine(dirPath, currentItemName);

                        if (dir.CurrentIsDir())
                        {
                            if (recursive)
                            {
                                Array <string> recursiveResult = new Array <string>();
                                string         currFolder      = Paths.Combine(dirPath, currentItemName);

                                if (Log.LoggingLevel > LoggingLevel.Default)
                                {
                                    Log.Print("Directory (" + dirPath + ") contained a child directory (" + currFolder + "), loading it too (recursive=true)", true);
                                }

                                if (TryGetSqlFilesInDirectory(currFolder, out recursiveResult, true))
                                {
                                    foreach (string path in recursiveResult)
                                    {
                                        resultFilePaths.Add(path);
                                    }
                                }
                                else
                                {
                                    Log.Error("Tried to do a recursive search on sql files but there were no sql files", true);
                                }
                            }
                        }
                        else if (file.FileExists(currentItemPath))
                        {
                            if (currentItemPath.EndsWith(".sql") || currentItemPath.EndsWith(".sql.tres")) // .sql.tres is legacy but it's there just in case we change our mind about using them as gd resources
                            {
                                resultFilePaths.Add(currentItemPath);
                            }
                            else if (Log.LoggingLevel > LoggingLevel.Default)
                            {
                                Log.Print("Found a file (" + currentItemPath + "), but it wasn't an .sql file, not including it", true);
                            }
                        }
                        else
                        {
                            //Debug.Log.Database("Files.GetFilesInDirectory()", "Tried to read a file (" + currentItemPath + ") but it didn't exist (this can cause unexpected crashes)", true);
                            Log.Database("Tried to read a file (" + currentItemPath + ") but it didn't exist (this can cause unexpected crashes)", true);
                        }
                        currentItemName = dir.GetNext();
                    }
                }
            }

            if (resultFilePaths.Count > 0)
            {
                filePaths = resultFilePaths;

                if (Log.LoggingLevel > LoggingLevel.Default)
                {
                    Log.Print("Total amount of .sql files found&processed: " + filePaths.Count + "(" + dirPath + ")", true);
                }

                return(true);
            }
            else
            {
                filePaths = null;
                return(false);
            }
        }