Ejemplo n.º 1
0
        public void ExportAll()
        {
            string path = Program.ChooseFolder();

            if (path == null)
            {
                return;
            }

            bool hasTextures = false;

            foreach (BRESGroupNode e in _resource.Children)
            {
                if (e.Type == BRESGroupNode.BRESGroupType.Textures)
                {
                    hasTextures = true;
                    break;
                }
            }

            if (hasTextures)
            {
                ExportAllFormatDialog dialog = new ExportAllFormatDialog();

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    ((BRRESNode)_resource).ExportToFolder(path, dialog.SelectedExtension);
                }
            }
            else
            {
                ((BRRESNode)_resource).ExportToFolder(path);
            }
        }
Ejemplo n.º 2
0
        public void ExportSelected()
        {
            string folder = Program.ChooseFolder();

            if (string.IsNullOrEmpty(folder))
            {
                return;
            }

            Dictionary <Type, string> extensions = new Dictionary <Type, string>();
            List <GenericWrapper>     nodes      = new List <GenericWrapper>();

            foreach (TreeNode tNode in MainForm.Instance.resourceTree.SelectedNodes)
            {
                if (tNode is GenericWrapper g)
                {
                    nodes.Add(g);
                    if (!extensions.ContainsKey(g._resource.GetType()))
                    {
                        extensions.Add(g._resource.GetType(), g.ExportFilter);
                    }
                }
            }

            Dictionary <Type, string> chosenExtensions = new Dictionary <Type, string>();

            foreach (KeyValuePair <Type, string> ext in extensions)
            {
                ExportAllFormatDialog dialog = new ExportAllFormatDialog("Export Selected", ext.Key, ext.Value);

                DialogResult?d = null;
                if (dialog.AutoSelect || dialog.Valid && (d = dialog.ShowDialog()) == DialogResult.OK)
                {
                    chosenExtensions.Add(ext.Key, dialog.SelectedExtension);
                }
                else if (d != null)
                {
                    return;
                }
            }

            string invalidChars  = Regex.Escape(new string(Path.GetInvalidFileNameChars()));
            string invalidRegStr = string.Format(@"([{0}]*\.+$)|([{0}]+)", invalidChars);

            foreach (GenericWrapper n in nodes)
            {
                chosenExtensions.TryGetValue(n._resource.GetType(), out string ext);
                if (!string.IsNullOrEmpty(ext) && !ext.StartsWith("."))
                {
                    ext = ext.Insert(0, ".");
                }

                n.OnExport($"{folder}\\{Regex.Replace($"{n.DefaultName}{ext ?? ""}", invalidRegStr, "")}");
            }

            MessageBox.Show($"{nodes.Count} nodes successfully exported to {folder}", "Export Selected");
        }
Ejemplo n.º 3
0
 private void imageFormatToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //Just use an existing dialog with the same basic function
     using (ExportAllFormatDialog d = new ExportAllFormatDialog())
     {
         d.Text = "Choose texture format";
         d.comboBox1.Items.RemoveAt(6); //TEX0
         if (d.ShowDialog(this) == DialogResult.OK)
         {
             _imgExtIndex = d.comboBox1.SelectedIndex;
             _imgExt      = d.SelectedExtension;
             imageFormatToolStripMenuItem.Text = "Image Format: " + _imgExt.Substring(1).ToUpper();
         }
     }
 }
Ejemplo n.º 4
0
        public void ExportAll()
        {
            string path = Program.ChooseFolder();

            if (path == null)
            {
                return;
            }

            ExportAllFormatDialog dialog = new ExportAllFormatDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                ((BRRESNode)_resource).ExportToFolder(path, dialog.SelectedExtension);
            }
        }
Ejemplo n.º 5
0
        public void ReplaceAll()
        {
            string path = Program.ChooseFolder();

            if (path == null)
            {
                return;
            }

            ExportAllFormatDialog dialog = new ExportAllFormatDialog();

            dialog.label1.Text = "Input format for textures:";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                ((BRRESNode)_resource).ReplaceFromFolder(path, dialog.SelectedExtension);
            }
        }
Ejemplo n.º 6
0
        public void ExportAll()
        {
            string path = Program.ChooseFolder();

            if (path == null)
            {
                return;
            }

            bool hasModels   = false;
            bool hasTextures = false;

            foreach (ResourceNode r in _resource.Children)
            {
                if (hasModels && hasTextures)
                {
                    break;
                }

                if (r is BRRESNode)
                {
                    foreach (BRESGroupNode e in r.Children)
                    {
                        if (e.Type == BRESGroupNode.BRESGroupType.Textures)
                        {
                            hasTextures = true;
                        }
                        else if (e.Type == BRESGroupNode.BRESGroupType.Models)
                        {
                            hasModels = true;
                        }

                        if (hasModels && hasTextures)
                        {
                            break;
                        }
                    }
                }
                else if (r is U8FolderNode)
                {
                    searchU8Folder((U8FolderNode)r, out bool hasModelsTemp, out bool hasTexturesTemp);
                    hasModels   = hasModels || hasModelsTemp;
                    hasTextures = hasTextures || hasTexturesTemp;
                }
            }

            string extensionTEX0 = ".tex0";
            string extensionMDL0 = ".mdl0";

            if (hasTextures)
            {
                ExportAllFormatDialog dialog = new ExportAllFormatDialog();

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    extensionTEX0 = dialog.SelectedExtension;
                }
                else
                {
                    return;
                }
            }

            if (hasModels)
            {
                ExportAllFormatDialog dialog = new ExportAllFormatDialog(true);

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    extensionMDL0 = dialog.SelectedExtension;
                }
                else
                {
                    return;
                }
            }

            ((U8Node)_resource).ExtractToFolder(path, extensionTEX0, extensionMDL0);
        }