Ejemplo n.º 1
0
        private string createToolTip(string mod, GameData.Header h)
        {
            if (h == null)
            {
                return(mod);
            }
            string str = string.Concat(mod, "\n版本: ", h.Version.ToString());

            if (h.Author != "")
            {
                str = string.Concat(str, "\n作者: ", h.Author);
            }
            if (h.Description != "")
            {
                str = string.Concat(str, "\n", h.Description);
            }
            if (h.Dependencies.Count > 0)
            {
                str = string.Concat(str, "\n依赖:");
                foreach (string dependency in h.Dependencies)
                {
                    str = string.Concat(str, "\n\t", dependency);
                }
            }
            if (h.Referenced.Count > 0)
            {
                str = string.Concat(str, "\n引用:");
                foreach (string referenced in h.Referenced)
                {
                    str = string.Concat(str, "\n\t", referenced);
                }
            }
            return(str);
        }
Ejemplo n.º 2
0
 private void enforceDependencies(TreeNode n, bool check, bool reorder, List <TreeNode> cycle = null)
 {
     if (n.Tag != null)
     {
         if (cycle == null)
         {
             cycle = new List <TreeNode>();
         }
         if (cycle.Contains(n))
         {
             return;
         }
         cycle.Add(n);
         GameData.Header tag = n.Tag as GameData.Header;
         foreach (string dependency in tag.Dependencies)
         {
             TreeNode treeNode = this.findNode(dependency);
             if (check && treeNode != null && !treeNode.Checked)
             {
                 treeNode.Checked = true;
                 this.enforceDependencies(treeNode, check, reorder, cycle);
             }
             if (!reorder || treeNode == null || !this.moveAbove(treeNode, n))
             {
                 continue;
             }
             this.enforceDependencies(treeNode, check, reorder, cycle);
         }
         foreach (string referenced in tag.Referenced)
         {
             TreeNode treeNode1 = this.findNode(referenced);
             if (!check || treeNode1 == null || treeNode1.Checked)
             {
                 continue;
             }
             treeNode1.Checked = true;
             this.enforceDependencies(treeNode1, check, reorder, cycle);
         }
     }
     if (reorder)
     {
         foreach (TreeNode node in this.modList.Nodes)
         {
             if (node.TreeView != n.TreeView || node.Index <= n.Index)
             {
                 if (node.Tag == null || !(node.Tag as GameData.Header).Dependencies.Contains(n.Text) || !this.moveBelow(node, n))
                 {
                     continue;
                 }
                 this.enforceDependencies(node, check, reorder, cycle);
             }
             else
             {
                 return;
             }
         }
     }
 }
Ejemplo n.º 3
0
 public ModData(GameData.Header header, string rootDir, string modName)
 {
     this.id         = (ulong)0;
     this.visibility = 0;
     this.tags       = new List <string>();
     this.mod        = modName;
     this.dir        = rootDir;
     this.header     = header;
 }
Ejemplo n.º 4
0
 private InheritFiles.DependencyState checkDependencies(TreeNode n)
 {
     InheritFiles.DependencyState dependencyState;
     if (n.Tag != null)
     {
         GameData.Header tag = n.Tag as GameData.Header;
         foreach (string dependency in tag.Dependencies)
         {
             TreeNode treeNode = this.findNode(dependency);
             if (treeNode != null && treeNode.Checked)
             {
                 continue;
             }
             dependencyState = InheritFiles.DependencyState.MISSING_DEPENDENCIES;
             return(dependencyState);
         }
         List <string> .Enumerator enumerator = tag.Referenced.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 TreeNode treeNode1 = this.findNode(enumerator.Current);
                 if (treeNode1 != null && treeNode1.Checked)
                 {
                     continue;
                 }
                 dependencyState = InheritFiles.DependencyState.MISSING_REFERENCES;
                 return(dependencyState);
             }
             return(InheritFiles.DependencyState.OK);
         }
         finally
         {
             ((IDisposable)enumerator).Dispose();
         }
         return(dependencyState);
     }
     return(InheritFiles.DependencyState.OK);
 }
Ejemplo n.º 5
0
        public InheritFiles(baseForm _nav, string baseDir, string modDir)
        {
            int i;

            this.parentForm = _nav;
            this.InitializeComponent();
            this.baseDir = baseDir;
            this.modDir  = modDir;
            string[] strArrays = new string[0];
            try
            {
                strArrays = File.ReadAllLines(string.Concat(baseDir, "mods.cfg"));
            }
            catch (Exception exception)
            {
            }
            string[] strArrays1 = new string[(int)InheritFiles.FixedModsList.Length + (int)strArrays.Length];
            InheritFiles.FixedMods.CopyTo(strArrays1, 0);
            strArrays.CopyTo(strArrays1, (int)InheritFiles.FixedModsList.Length);
            List <string> strs          = new List <string>();
            DirectoryInfo directoryInfo = new DirectoryInfo(baseDir);

            FileInfo[] files = directoryInfo.GetFiles("*.base");
            for (i = 0; i < (int)files.Length; i++)
            {
                strs.Add(files[i].Name);
            }
            files = directoryInfo.GetFiles("*.mod");
            for (i = 0; i < (int)files.Length; i++)
            {
                strs.Add(files[i].Name);
            }
            List <string> strs1 = new List <string>();

            directoryInfo = new DirectoryInfo(modDir);
            if (directoryInfo.Exists)
            {
                DirectoryInfo[] directories        = directoryInfo.GetDirectories();
                List <string>   strs2              = new List <string>((int)directories.Length);
                DirectoryInfo[] directoryInfoArray = directories;
                for (i = 0; i < (int)directoryInfoArray.Length; i++)
                {
                    DirectoryInfo directoryInfo1 = directoryInfoArray[i];
                    FileInfo[]    fileInfoArray  = directoryInfo1.GetFiles(string.Concat(directoryInfo1.Name, ".mod"));
                    if (fileInfoArray.Length != 0)
                    {
                        strs1.Add(fileInfoArray[0].Name);
                    }
                }
            }
            string[] strArrays2 = strArrays1;
            for (i = 0; i < (int)strArrays2.Length; i++)
            {
                string str = strArrays2[i];
                if (strs.Contains(str))
                {
                    this.baseList.Nodes.Add(str).Checked = true;
                    strs.Remove(str);
                }
                else if (strs1.Contains(str))
                {
                    this.modList.Nodes.Add(str).Checked = true;
                    strs1.Remove(str);
                    this.defaultChecked.Add(str);
                }
            }
            foreach (string str1 in strs)
            {
                this.baseList.Nodes.Add(str1);
            }
            foreach (string str2 in strs1)
            {
                this.modList.Nodes.Add(str2);
            }
            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
            foreach (TreeNode node in this.baseList.Nodes)
            {
                GameData.Header header = GameData.loadHeader(string.Concat(baseDir, node.Text));
                node.ToolTipText = this.createToolTip(node.Text, header);
                node.Tag         = header;
            }
            foreach (TreeNode treeNode in this.modList.Nodes)
            {
                string          str3    = treeNode.Text.Substring(0, treeNode.Text.Length - 4);
                GameData.Header header1 = GameData.loadHeader(string.Concat(modDir, str3, "/", treeNode.Text));
                treeNode.ToolTipText = this.createToolTip(treeNode.Text, header1);
                treeNode.Tag         = header1;
            }
            System.Windows.Forms.Cursor.Current = Cursors.Default;
            this.updateActiveMod();
            this.baseList.DrawMode           = TreeViewDrawMode.OwnerDrawText;
            this.baseList.DrawNode          += new DrawTreeNodeEventHandler(this.modList_DrawNode);
            this.baseList.MouseDown         += new MouseEventHandler(this.modList_MouseDown);
            this.baseList.MouseClick        += new MouseEventHandler(this.modList_MouseClick);
            this.baseList.MouseDoubleClick  += new MouseEventHandler(this.modList_MouseClick);
            this.baseList.ItemDrag          += new ItemDragEventHandler(this.modList_ItemDrag);
            this.baseList.DragDrop          += new DragEventHandler(this.modList_DragDrop);
            this.baseList.DragOver          += new DragEventHandler(this.modList_DragOver);
            this.modList.DrawMode            = TreeViewDrawMode.OwnerDrawText;
            this.modList.DrawNode           += new DrawTreeNodeEventHandler(this.modList_DrawNode);
            this.modList.MouseDown          += new MouseEventHandler(this.modList_MouseDown);
            this.modList.MouseClick         += new MouseEventHandler(this.modList_MouseClick);
            this.modList.MouseDoubleClick   += new MouseEventHandler(this.modList_MouseClick);
            this.modList.ItemDrag           += new ItemDragEventHandler(this.modList_ItemDrag);
            this.modList.DragDrop           += new DragEventHandler(this.modList_DragDrop);
            this.modList.DragOver           += new DragEventHandler(this.modList_DragOver);
            this.btnNewTranslation.Enabled   = false;
            this.cbActiveTranslation.Enabled = false;
        }