示例#1
0
        /// <summary>
        /// Loads all of the *.ai files located in the SubDir name, into
        /// the ObjectManager
        /// </summary>
        /// <param name="templateType">The folder name of .ai files to load</param>
        protected async Task LoadTemplates(string templateType)
        {
            string path = Path.Combine(Program.RootPath, "Temp", "Server Objects", SelectedMod.Name, templateType);
            TreeNode topNode = new TreeNode(templateType);

            // Make sure our tempalte directory exists
            if (!Directory.Exists(path))
                return;

            // Now loop through each object type
            foreach (string dir in Directory.EnumerateDirectories(path))
            {
                string dirName = dir.Remove(0, path.Length + 1);

                // Skip common folder
                if (dirName.ToLowerInvariant() == "common")
                    continue;

                TreeNode dirNode = new TreeNode(dirName);
                foreach (string subdir in Directory.EnumerateDirectories(dir))
                {
                    string subdirName = subdir.Remove(0, dir.Length + 1);

                    // Skip common folder
                    if (subdirName.ToLowerInvariant() == "common")
                        continue;

                    // Create namespace, and load files
                    try
                    {
                        // Create namespace and load the base object
                        NameSpace nspace = new NameSpace(subdirName, subdir);
                        await nspace.LoadFile($"{subdirName}.con");

                        // Load tweak (if it exists)
                        await nspace.LoadFile($"{subdirName}.tweak");

                        // Load Ai Files
                        await nspace.LoadFile("ai/Objects.ai");
                        await nspace.LoadFile("ai/Weapons.ai");

                        // Add TreeNode to our object view
                        if (nspace.Files.Count > 0)
                        {
                            TreeNode subNode = new TreeNode(subdirName);
                            subNode.Tag = nspace;
                            dirNode.Nodes.Add(subNode);
                        }
                    }
                    catch
                    {

                    }
                }

                if (dirNode.Nodes.Count > 0)
                    topNode.Nodes.Add(dirNode);

            }

            // Cross-Thread
            Invoke((MethodInvoker)delegate
            {
                if (topNode.Nodes.Count > 0)
                    treeView1.Nodes.Add(topNode);
            });
        }
示例#2
0
        /// <summary>
        /// Loads all of the *.ai files located in the SubDir name, into
        /// the ObjectManager
        /// </summary>
        /// <param name="templateType">The folder name of .ai files to load</param>
        protected async Task LoadTemplates(string templateType)
        {
            string   path    = Path.Combine(Program.RootPath, "Temp", "Server Objects", SelectedMod.Name, templateType);
            TreeNode topNode = new TreeNode(templateType);

            // Make sure our tempalte directory exists
            if (!Directory.Exists(path))
            {
                return;
            }

            // Now loop through each object type
            foreach (string dir in Directory.EnumerateDirectories(path))
            {
                string dirName = dir.Remove(0, path.Length + 1);

                // Skip common folder
                if (dirName.ToLowerInvariant() == "common")
                {
                    continue;
                }

                TreeNode dirNode = new TreeNode(dirName);
                foreach (string subdir in Directory.EnumerateDirectories(dir))
                {
                    string subdirName = subdir.Remove(0, dir.Length + 1);

                    // Skip common folder
                    if (subdirName.ToLowerInvariant() == "common")
                    {
                        continue;
                    }

                    // Create namespace, and load files
                    try
                    {
                        // Create namespace and load the base object
                        NameSpace nspace = new NameSpace(subdirName, subdir);
                        await nspace.LoadFile($"{subdirName}.con");

                        // Load tweak (if it exists)
                        await nspace.LoadFile($"{subdirName}.tweak");

                        // Load Ai Files
                        await nspace.LoadFile("ai/Objects.ai");

                        await nspace.LoadFile("ai/Weapons.ai");

                        // Add TreeNode to our object view
                        if (nspace.Files.Count > 0)
                        {
                            TreeNode subNode = new TreeNode(subdirName);
                            subNode.Tag = nspace;
                            dirNode.Nodes.Add(subNode);
                        }
                    }
                    catch
                    {
                    }
                }

                if (dirNode.Nodes.Count > 0)
                {
                    topNode.Nodes.Add(dirNode);
                }
            }

            // Cross-Thread
            Invoke((MethodInvoker) delegate
            {
                if (topNode.Nodes.Count > 0)
                {
                    treeView1.Nodes.Add(topNode);
                }
            });
        }