ME3Explorer.KFreonTPFTools3.LoadExternal C# (CSharp) 메소드

LoadExternal() 공개 메소드

public LoadExternal ( string file, bool isDef ) : int
file string
isDef bool
리턴 int
        public int LoadExternal(string file, bool isDef)
        {
            EnableSecondProgressBar(false);
            TPFTexInfo tmpTex = new TPFTexInfo(Path.GetFileName(file), -1, Path.GetDirectoryName(file), null, WhichGame);
            // KFreon: Get hash
            if (!isDef)
            {
                string hash = "";

                // KFreon: Check if hash in filename
                // Heff: fix weird uppercase X
                file = Path.GetFileName(file).Replace("0X", "0x");
                if (file.Contains("0x"))
                    hash = file.Substring(file.IndexOf("0x"), 10);
                else  // KFreon: If not in filename, look in all non TPF .defs
                    foreach (TPFTexInfo tex in LoadedTexes)
                    {
                        if (tex.isDef && tex.isExternal)
                        {
                            using (StreamReader sr = new StreamReader(Path.Combine(tex.FilePath, tex.FileName)))
                                while (!sr.EndOfStream)
                                {
                                    string line = sr.ReadLine();
                                    if (line.Contains(file + '|'))
                                    {
                                        int start = line.IndexOf('|');
                                        hash = line.Substring(start + 1, line.Length - (start + 1));
                                        break;
                                    }
                                }
                            if (hash != "")
                                break;
                        }
                    }


                // KFreon: Convert hash to uint
                if (hash != "")
                    tmpTex.Hash = KFreonLib.Textures.Methods.FormatTexmodHashAsUint(hash);

                tmpTex.OriginalHash = tmpTex.Hash;
            }


            // KFreon: Get details
            if (!tmpTex.isDef)
                tmpTex.EnumerateDetails();

            // KFreon: Add node and its index to current node
            myTreeNode temp = new myTreeNode(Path.GetFileName(file));
            temp.TexInd = LoadedTexes.Count;
            // Heff: cancellation check
            if (!cts.IsCancellationRequested)
            {
                this.Invoke(new Action(() =>
                {
                    MainTreeView.Nodes.Add(temp);
                    OverallProg.IncrementBar();
                }));
            }

            LoadedTexes.Add(tmpTex);

            return temp.TexInd;
        }
KFreonTPFTools3