Esempio n. 1
0
        public TreeDB Clone()
        {
            TreeDB newtree = new TreeDB(pccs, ref TexplorerTreeView, GameVersion, pathBIOGame);

            newtree.AdvancedFeatures = AdvancedFeatures;
            newtree.Texes            = new List <TreeTexInfo>(Texes);
            newtree.nodeList         = new List <myTreeNode>(nodeList);
            newtree.TreePath         = TreePath;
            return(newtree);
        }
Esempio n. 2
0
 public TreeDB Clone()
 {
     TreeDB newtree = new TreeDB(pccs, ref TexplorerTreeView, GameVersion, pathBIOGame);
     newtree.AdvancedFeatures = AdvancedFeatures;
     newtree.Texes = new List<TreeTexInfo>(Texes);
     newtree.nodeList = new List<myTreeNode>(nodeList);
     newtree.TreePath = TreePath;
     return newtree;
 }
Esempio n. 3
0
        public static bool SetupTree(ref TreeDB Tree, string pathCooked, int WhichGame, TreeView MainTreeView, string pathBIOGame)
        {
            DebugOutput.PrintLn("Setting up tree: " + WhichGame + " using PathBIOGame: " + pathBIOGame);
            if (Tree == null)
            {
                DebugOutput.PrintLn("Tree: " + WhichGame + " is not null.");
                List<string> allPccFiles = new List<string>();
                string path = pathCooked;

                if (!Directory.Exists(path))
                {
                    DebugOutput.PrintLn("Couldn't find main game files for ME" + WhichGame + ".");
                    return false;
                }
                else
                {
                    DebugOutput.PrintLn("Found main gamefiles for ME" + WhichGame + " at  " + pathBIOGame);
                }

                allPccFiles.AddRange(Directory.GetFiles(path, "*", SearchOption.AllDirectories).Where(s =>
                {
                    if (WhichGame == 1)
                    {
                        return s.EndsWith(".upk", true, null) || s.EndsWith(".u", true, null) || s.EndsWith(".sfm", true, null);
                    }
                    else
                        return s.EndsWith(".pcc");
                }));

                DebugOutput.PrintLn("Creating tree: " + WhichGame + ". Found: " + allPccFiles.Count + " scannable gamefiles.");

                Tree = new TreeDB(allPccFiles, ref MainTreeView, WhichGame, pathBIOGame);
            }
            return true;
        }
Esempio n. 4
0
        /// <summary>
        /// Loads Tree.
        /// </summary>
        /// <returns>True if tree loaded properly.</returns>
        private bool LoadTrees()
        {
            // KFreon: Try to setup tree
            Task<TreeDB> current = null;
            for (int i = 1; i < 4; i++)
            {
                // KFreon: Start task for tree we want
                var y = i;
                Task<TreeDB> temptask = Task.Run(() =>
                {
                    TreeDB temptree = null;
                    string tempcooked = MEExDirecs.GetDifferentPathCooked(y);
                    string tempbio = MEExDirecs.GetDifferentPathBIOGame(y);
                    bool res = Texplorer2.SetupTree(ref temptree, tempcooked, y, null, tempbio);
                    bool temp = false;
                    if (res)
                    {
                        int status2;
                        temp = temptree.ReadFromFile(ExecFolder + "me" + y + "tree.bin", Path.GetDirectoryName(tempbio), ExecFolder + "ThumbnailCaches\\ME" + y + "ThumbnailCache\\", out status2);
                    }

                    ChangeIndicatorColours(y, temp, true);
                    DebugOutput.PrintLn(temp ? "ME" + y + " tree found." : "ME" + y + " tree not found.");
                    return temp ? temptree : null;
                });


                if (i == WhichGame)
                    current = temptask;
            }

            //KFreon: Wait for tree we want to finish loading.
            while (!current.IsCompleted)
            {
                System.Threading.Thread.Sleep(50);
                Application.DoEvents();
            }

            Tree = current.Result;
            return Tree != null;
        }
Esempio n. 5
0
        private async void ChangeButton_Click(object sender, EventArgs e)
        {
            OutputBoxPrintLn(Environment.NewLine);
            switch (WhichGame)
            {
                case 1:
                    WhichGame = 2;
                    ChangeButton.Text = "Modding ME2";
                    break;
                case 2:
                    WhichGame = 3;
                    ChangeButton.Text = "Modding ME3";
                    break;
                case 3:
                    WhichGame = 1;
                    ChangeButton.Text = "Modding ME1";
                    break;
            }

            MEExDirecs.WhichGame = WhichGame;
            DebugOutput.PrintLn();
            DebugOutput.PrintLn("Changing Trees...");
            WindowTitle = "Texplorer 2.0:  " + "ME" + WhichGame;
            this.Text = WindowTitle;
            Properties.Settings.Default.TexplorerGameVersion = WhichGame;
            SaveProperties();
            ClearDisplays();
            Tree = null;

            if (!noWindow)
            {
                NoRenderButton.Visible = (WhichGame == 1);
                LowResButton.Visible = (WhichGame == 1);
            }

            // KFreon: Setup pathing
            await Task.Run(() => MEExDirecs.SetupPathing(true));
            BeginLoadingTree();
        }
Esempio n. 6
0
        private void rebuildDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("This will delete your current tree and re-scan your gamefiles. Are you sure?", "Reconstruct facial profile?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
            {
                // KFreon: Check game state first in case of update
                CheckGameStates();

                // KFreon: Remove tree
                if (File.Exists(ExecFolder + "me" + WhichGame + "tree.bin"))
                    File.Delete(ExecFolder + "me" + WhichGame + "tree.bin");
                OutputBoxPrintLn(Environment.NewLine + "Rebuilding ME" + WhichGame + " tree...");

                // MrFob: probably unnecessary but if the game is ME3, run extract DLCs just to be sure
                if (WhichGame == 3)
                {
                    DLCEditor2.DLCEditor2 dlcedit2 = new DLCEditor2.DLCEditor2();
                    dlcedit2.ExtractAllDLC();
                }

                // KFreon: Clear everything and rebuild tree
                ClearDisplays();
                Tree = null;
                BeginLoadingTree(true, true);
            }
        }
Esempio n. 7
0
        private void ImportTree()
        {
            if (Tree == null)
            {
                MessageBox.Show("Game files not found. Unfortunately we seem to need them to use trees...");
                return;
            }
            else if (Tree.TexCount != 0)
                if (MessageBox.Show("This will replace your currently loaded tree but NOT on disk. Do you wish to proceed? Make REALLY sure you're loading the right game tree in...", "Sure you wanna do that Commander?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                    return;

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "ME Trees|*.bin";
                ofd.Title = "Select tree to import.";
                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    TreeDB temptree = Tree.Clone();
                    int status;
                    if (!LoadTreeFromFile(ofd.FileName, out status, false))
                    {
                        Tree = temptree;
                        MessageBox.Show("Error occured while loading tree. Likely a corrupted or invalid tree.");
                        return;
                    }
                }
            }
        }
Esempio n. 8
0
        private async void ImportTree()
        {
            if (Tree == null)
            {
                MessageBox.Show("Game files not found. Unfortunately we seem to need them to use trees...");
                return;
            }
            else if (Tree.TexCount != 0)
                if (MessageBox.Show("This will import the tree and thumbnails (if present) from the specified location. Be sure the game currently selected in Texplorer matches the tree you're importing. Do you want to continue?", "Sure you wanna do that Commander?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                    return;
            
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "ME Trees|*.bin";
                ofd.Title = "Select tree to import.";

                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    StatusUpdater.UpdateText("Importing tree...");
                    ProgBarUpdater.ChangeProgressBar(0, 1);

                    TreeDB temptree = Tree.Clone();  // KFreon: Copy settings so can back track if tree load fails

                    string destTreePath = ExecFolder + "me" + WhichGame + "tree.bin";
                    File.Copy(ofd.FileName, destTreePath);

                    int status;
                    if (!LoadTreeFromFile(destTreePath, out status, false))  // KFreon: Load actual tree.bin
                    {
                        Tree = temptree;
                        MessageBox.Show("Error occured while loading tree. Likely a corrupted or invalid tree.");
                        return;
                    }

                    StatusUpdater.UpdateText("Importing thumbs...");

                    await Task.Run(() =>
                    {
                        // KFreon: Copy thumbnails
                        string basePath = Path.GetDirectoryName(ofd.FileName);
                        string mainCachePath = Path.Combine(basePath, $"ThumbnailCaches\\ME{WhichGame}ThumbnailCache");

                        bool inMainCachePath = Directory.Exists(mainCachePath);
                        string sourceThumbCachePath = mainCachePath;

                        if (!inMainCachePath)
                        {
                            string nakedPath = Path.Combine(basePath, $"ME{WhichGame}ThumbnailCache");
                            bool isNakedPath = Directory.Exists(nakedPath);  // KFreon: Huehuehue

                            if (isNakedPath)
                                sourceThumbCachePath = nakedPath;
                            else
                            {
                                DebugOutput.PrintLn("Thumbnails not found. Skipping...");
                                return;
                            }
                        }

                        string destThumbCachePath = ThumbnailPath;
                        Directory.CreateDirectory(destThumbCachePath);

                        var files = Directory.GetFiles(sourceThumbCachePath);
                        ProgBarUpdater.ChangeProgressBar(0, files.Length);

                        int count = 0;
                        foreach (var file in files)
                        {
                            string filename = Path.GetFileName(file);
                            string destPath = Path.Combine(destThumbCachePath, filename);  // KFreon: No overwriting. 
                            if (!File.Exists(destPath))
                                File.Copy(file, destPath);

                            if (count++ % 10 == 0)
                                ProgBarUpdater.IncrementBar();
                        }
                    });

                    ChangeTreeIndicators(MEExDirecs.WhichGame, true);
                    ProgBarUpdater.ChangeProgressBar(1, 1);
                    StatusUpdater.UpdateText("Tree imported!");
                }
            }
        }
Esempio n. 9
0
        private void AddDLCToTree(List<string> pccs)
        {
            Tree.AddPCCs(pccs);
            ConcurrentBag<string> errors = ScanPCCList(false, pccs);
            Tree.WriteToFile(Tree.TreePath, Path.GetDirectoryName(pathBIOGame));

            if (errors != null && errors.Count != 0)
            {
                MessageBox.Show("Errors occured!" + Environment.NewLine + string.Join(Environment.NewLine, errors), "Your technology is based on that of the Mass Relays...", MessageBoxButtons.OK);
                StatusUpdater.UpdateText("Errors occured. See DebugWindow");
            }
            else
            {
                StatusUpdater.UpdateText("Refreshing Tree...");

                ClearDisplays();
                Tree = null;
                BeginLoadingTree();
                StatusUpdater.UpdateText("DLC added to tree!");
            }

            ProgBarUpdater.ChangeProgressBar(1, 1);
        }