Пример #1
0
        private void InitGGPK()
        {
            if (content != null)
            {
                return;
            }

            string ggpkPath = textBoxContentGGPK.Text;

            if (!File.Exists(ggpkPath))
            {
                OutputLine(string.Format("GGPK {0} not exists.", ggpkPath));
                return;
            }
            OutputLine(string.Format("Parsing {0}", ggpkPath));

            content = new GGPK();
            content.Read(ggpkPath, Output);

            RecordsByPath = new Dictionary <string, FileRecord>(content.RecordOffsets.Count);
            DirectoryTreeNode.TraverseTreePostorder(content.DirectoryRoot, null, n => RecordsByPath.Add(n.GetDirectoryPath() + n.Name, n as FileRecord));

            textBoxContentGGPK.Enabled = false;
            buttonSelectPOE.Enabled    = false;

            CreateExampleRegistryFile(ggpkPath);
        }
Пример #2
0
        /// <summary>
        /// Reloads the entire content.ggpk, rebuilds the tree
        /// </summary>
        private void ReloadGGPK()
        {
            treeView1.Items.Clear();
            ResetViewer();
            textBoxOutput.Visibility = System.Windows.Visibility.Visible;
            textBoxOutput.Text       = string.Empty;
            content = null;

            workerThread = new Thread(new ThreadStart(() =>
            {
                content = new GGPK();
                try
                {
                    content.Read(ggpkPath, Output);
                }
                catch (Exception ex)
                {
                    Output(string.Format(Settings.Strings["ReloadGGPK_Failed"], ex.Message));
                    return;
                }

                if (content.IsReadOnly)
                {
                    Output(Settings.Strings["ReloadGGPK_ReadOnly"] + Environment.NewLine);
                    UpdateTitle(Settings.Strings["MainWindow_Title_Readonly"]);
                }

                OutputLine(Settings.Strings["ReloadGGPK_Traversing_Tree"]);

                // Collect all FileRecordPath -> FileRecord pairs for easier replacing
                RecordsByPath = new Dictionary <string, FileRecord>(content.RecordOffsets.Count);
                DirectoryTreeNode.TraverseTreePostorder(content.DirectoryRoot, null, n => RecordsByPath.Add(n.GetDirectoryPath() + n.Name, n as FileRecord));

                treeView1.Dispatcher.BeginInvoke(new Action(() =>
                {
                    try
                    {
                        AddDirectoryTreeToControl(content.DirectoryRoot, null);
                    }
                    catch (Exception ex)
                    {
                        Output(string.Format(Settings.Strings["Error_Read_Directory_Tree"], ex.Message));
                        return;
                    }

                    workerThread = null;
                }), null);


                OutputLine(Settings.Strings["ReloadGGPK_Successful"]);
            }));

            workerThread.Start();
        }
Пример #3
0
        private static void InitGGPK()
        {
            if (content != null)
            {
                return;
            }

            searchContentGGPK();

            if (ggpkPaths.Count == 1)
            {
                ggpkPath = ggpkPaths[0];
            }
            else if (ggpkPaths.Count > 1)
            {
                int pos = 0;
                foreach (string ggpkPath2 in ggpkPaths)
                {
                    OutputLine(string.Format("[{0}] {1}", pos++, ggpkPath2));
                }
                OutputLine(string.Format("Choose [0-{0}]: ", pos - 1));
                ConsoleKeyInfo cki = Console.ReadKey();
                OutputLine("");
                Int32 number;
                if (Int32.TryParse(cki.KeyChar.ToString(), out number))
                {
                    if (number >= 0 && number <= pos - 1)
                    {
                        ggpkPath = ggpkPaths[number];
                    }
                }
            }
            if (!File.Exists(ggpkPath))
            {
                OutputLine(string.Format("GGPK {0} not exists.", ggpkPath));
                return;
            }

            OutputLine(string.Format("Parsing {0}", ggpkPath));

            content = new GrindingGearsPackageContainer();
            content.Read(ggpkPath, Output);

            RecordsByPath = new Dictionary <string, FileRecord>(content.RecordOffsets.Count);
            DirectoryTreeNode.TraverseTreePostorder(content.DirectoryRoot, null, n => RecordsByPath.Add(n.GetDirectoryPath() + n.Name, n as FileRecord));
        }
Пример #4
0
        private static void InitGGPK()
        {
            if (content != null)
            {
                return;
            }

            ggpkPath = searchContentGGPK();
            if (!File.Exists(ggpkPath))
            {
                OutputLine(string.Format("GGPK {0} not exists.", ggpkPath));
                return;
            }
            OutputLine(string.Format("Parsing {0}", ggpkPath));

            content = new GGPK();
            content.Read(ggpkPath, Output);

            RecordsByPath = new Dictionary <string, FileRecord>(content.RecordOffsets.Count);
            DirectoryTreeNode.TraverseTreePostorder(content.DirectoryRoot, null, n => RecordsByPath.Add(n.GetDirectoryPath() + n.Name, n as FileRecord));
        }
Пример #5
0
        /// <summary>
        /// Reloads the entire content.ggpk, rebuilds the tree
        /// </summary>
        private void ReloadGgpkFile()
        {
            TreeView1.Items.Clear();
            ResetViewer();
            TextBoxOutput.Visibility = Visibility.Visible;
            TextBoxOutput.Text       = string.Empty;
            _content = null;

            _workerThread = new Thread(() =>
            {
                _content = new GrindingGearsPackageContainer();
                try
                {
                    _content.Read(_ggpkPath, Output);
                }
                catch (Exception ex)
                {
                    Output(string.Format(Settings.Strings["ReloadGGPK_Failed"], ex.Message));
                    return;
                }

                if (_content.IsReadOnly)
                {
                    Output(Settings.Strings["ReloadGGPK_ReadOnly"] + Environment.NewLine);
                    UpdateTitle(Settings.Strings["MainWindow_Title_Readonly"]);
                }

                OutputLine(Settings.Strings["ReloadGGPK_Traversing_Tree"]);

                // Collect all FileRecordPath -> FileRecord pairs for easier replacing
                _recordsByPath = new Dictionary <string, FileRecord>(_content.RecordOffsets.Count);
                DirectoryTreeNode.TraverseTreePostorder(
                    _content.DirectoryRoot,
                    null,
                    n => _recordsByPath.Add(n.GetDirectoryPath() + n.Name, n));

                TreeView1.Dispatcher.BeginInvoke(new Action(() =>
                {
                    try
                    {
                        var rootItem = CreateLazyTreeViewItem(_content.DirectoryRoot);
                        TreeView1.Items.Add(rootItem);
                        rootItem.IsExpanded = true;
                        rootItem.RaiseEvent(new RoutedEventArgs(TreeViewItem.ExpandedEvent, rootItem));
                    }
                    catch (Exception ex)
                    {
                        Output(string.Format(Settings.Strings["Error_Read_Directory_Tree"], ex.Message));
                        Output(ex.StackTrace);
                        return;
                    }

                    _workerThread = null;
                }), null);


                OutputLine(Settings.Strings["ReloadGGPK_Successful"]);
            });

            _workerThread.Start();
        }