private void SetCustomTagWrapper(string[] modOutputFiles, string nextModTag, ComboBox currentModLoadedFilesCenterViewComboBox)
        {
            foreach (string nextModFile in modOutputFiles)
            {
                string newOutputLocation      = Path.Combine(XmlFileManager.LoadedFilesPath, nextModTag);
                XmlObjectsListWrapper wrapper = LoadWrapperFromFile(nextModFile);
                if (wrapper != null)
                {
                    string wrapperDictionaryKey = nextModTag + "_" + wrapper.GenerateDictionaryKey();

                    UpdateWrapperInDictionary(wrapperDictionaryKey, wrapper);
                    if (nextModTag.Equals(Properties.Settings.Default.ModTagSetting))
                    {
                        currentModLoadedFilesCenterViewComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                    }
                    if (!Directory.Exists(newOutputLocation))
                    {
                        Directory.CreateDirectory(newOutputLocation);
                    }
                    string parentPath = wrapper.XmlFile.ParentPath ?? "";
                    if (!File.Exists(Path.Combine(newOutputLocation, parentPath, wrapper.XmlFile.FileName)))
                    {
                        Directory.CreateDirectory(Path.Combine(newOutputLocation, parentPath));
                        File.Copy(nextModFile, Path.Combine(newOutputLocation, parentPath, wrapper.XmlFile.FileName));
                    }
                }
            }
        }
        private void AddWrapperDataToUIAndCopyFiles(string nextFileName, List <string> unloadedFiles, ComboBox searchTreeLoadedFilesComboBox, ComboBox newObjectViewLoadedFilesComboBox, ComboBox currentGameFilesCenterViewComboBox)
        {
            XmlObjectsListWrapper wrapper = LoadWrapperFromFile(nextFileName);
            string parentPath             = wrapper.XmlFile.ParentPath ?? "";
            string loadedFilePathToFile   = Path.Combine(XmlFileManager.LoadedFilesPath, parentPath, wrapper.XmlFile.FileName);

            if (wrapper == null)
            {
                unloadedFiles.Add(nextFileName);
            }
            else if (File.Exists(loadedFilePathToFile))
            {
                OverwriteFilePrompt(loadedFilePathToFile, nextFileName);
            }
            else
            {
                File.Copy(nextFileName, Path.Combine(XmlFileManager.LoadedFilesPath, parentPath, wrapper.XmlFile.FileName));
            }

            if (wrapper != null)
            {
                string wrapperDictionaryKey = wrapper.GenerateDictionaryKey();
                UpdateWrapperInDictionary(wrapperDictionaryKey, wrapper);
                searchTreeLoadedFilesComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                newObjectViewLoadedFilesComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                currentGameFilesCenterViewComboBox.AddUniqueValueTo(wrapperDictionaryKey);
            }
        }
Пример #3
0
        public void AddSearchTree(MyStackPanel searchTreeFormsPanel, ComboBox searchTreeLoadedFilesComboBox, bool isGameFileTree = true, bool includeChildrenInOnHover = false, bool includeComments = false)
        {
            string selectedObject = searchTreeLoadedFilesComboBox.Text;

            if (String.IsNullOrEmpty(selectedObject))
            {
                return;
            }
            XmlObjectsListWrapper selectedWrapper = LoadedListWrappers.GetWrapperFromDictionary(selectedObject);

            if (selectedObject.Split("_").Length > 1)
            {
                selectedWrapper = LoadedListWrappers.GetValueOrDefault(selectedObject);
                if (selectedWrapper == null)
                {
                    MessageBox.Show(
                        "The was an error in the file for " + selectedObject + ".\n\n" +
                        "It is probably malformed xml, to check this, switch to the mod, open the \"File\" menu and click \"Validate Mod files\".",
                        "File Loading Error!",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                    return;
                }
            }
            XmlObjectsListWrapper leftObjectWrapper = searchTreeFormsPanel.StackPanelLoadedListWrappers.GetValueOrDefault(selectedObject);
            string gameWrapperKey = selectedWrapper.GenerateDictionaryKey();

            if (leftObjectWrapper == null || leftObjectWrapper.XmlFile.FileSize < this.FILE_SIZE_THRESHOLD)
            {
                TreeViewItem nextTreeView = TreeViewGenerator.GetSearchTreeViewRecursive(selectedWrapper, gameWrapperKey, isGameTree: isGameFileTree, includeChildrenInOnHover: includeChildrenInOnHover, includeComments: includeComments);
                nextTreeView.Header = selectedObject;
                searchTreeFormsPanel.Children.Add(nextTreeView);
            }
            else
            {
                MessageBoxResult result = MessageBox.Show(
                    "That is a large file and consumes a considerable amount of resources, you already have one of those objects in the view. Are you sure you want another? ",
                    "Add Another Large Search Tree",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Exclamation);
                switch (result)
                {
                case MessageBoxResult.Yes:
                    TreeViewItem nextTreeView = TreeViewGenerator.GetSearchTreeViewRecursive(selectedWrapper, gameWrapperKey, isGameTree: isGameFileTree, includeChildrenInOnHover: includeChildrenInOnHover, includeComments: includeComments);
                    nextTreeView.Header = selectedObject;
                    searchTreeFormsPanel.Children.Add(nextTreeView);
                    break;
                }
            }
        }
        private void LoadFilesPathWrappers(string[] files, ComboBox searchTreeLoadedFilesComboBox, ComboBox newObjectViewLoadedFilesComboBox, ComboBox currentGameFilesCenterViewComboBox)
        {
            foreach (string file in files)
            {
                XmlObjectsListWrapper wrapper = LoadWrapperFromFile(file);
                string parentPath             = wrapper.XmlFile.ParentPath ?? "";
                if (wrapper != null && !File.Exists(Path.Combine(XmlFileManager.LoadedFilesPath, parentPath, wrapper.XmlFile.FileName)))
                {
                    File.Copy(file, Path.Combine(XmlFileManager.LoadedFilesPath, parentPath, wrapper.XmlFile.FileName));
                }
                if (wrapper != null)
                {
                    string wrapperDictionaryKey = wrapper.GenerateDictionaryKey();

                    UpdateWrapperInDictionary(wrapperDictionaryKey, wrapper);
                    searchTreeLoadedFilesComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                    newObjectViewLoadedFilesComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                    currentGameFilesCenterViewComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                }
            }
        }