Exemple #1
0
        public void LoadFile(string fileName)
        {
            try
            {
                LoadMEPackage(fileName);

                /*if (pcc.Game == MEGame.ME1)
                 * {
                 *  pcc?.Release(wpfWindow: this);
                 *  pcc = null;
                 *  throw new FormatException("FaceFXEditor does not work on ME1 files.");
                 * }*/
                selectedLine = null;
                FaceFX       = null;
                treeView.Nodes.Clear();
                linesListBox.ItemsSource     = null;
                animationListBox.ItemsSource = null;
                graph.Clear();
                RefreshComboBox();
            }
            catch (Exception ex)
            {
                pcc?.Release(wpfWindow: this);
                pcc = null;
                MessageBox.Show("Error:\n" + ex.Message);
            }
        }
Exemple #2
0
        private void linesListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            animationListBox.ItemsSource = null;
            lineText.Text = null;

            if (e.AddedItems.Count != 1)
            {
                return;
            }
            selectedLine = (ME3FaceFXLine)e.AddedItems[0];
            updateAnimListBox();
            if (int.TryParse(selectedLine.ID, out int tlkID))
            {
                if (pcc.Game == MEGame.ME3)
                {
                    lineText.Text = ME3TalkFiles.findDataById(tlkID);
                }
                else
                {
                    lineText.Text = ME2Explorer.ME2TalkFiles.findDataById(tlkID);
                }
            }
            treeView.Nodes.Clear();
            System.Windows.Forms.TreeNode[] treeNodes = FaceFX.DataToTree2(selectedLine);
            treeView.Nodes.AddRange(treeNodes);
        }
 private void Open_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     OpenFileDialog d = new OpenFileDialog();
     d.Filter = "*.pcc|*.pcc";
     if (d.ShowDialog() == true)
     {
         try
         {
             LoadMEPackage(d.FileName);
             if (pcc.Game == MEGame.ME1)
             {
                 pcc?.Release(wpfWindow: this);
                 pcc = null;
                 throw new FormatException("FaceFXEditor does not work on ME1 files.");
             }
             selectedLine = null;
             FaceFX = null;
             treeView.Nodes.Clear();
             linesListBox.ItemsSource = null;
             animationListBox.ItemsSource = null;
             graph.Clear();
             RefreshComboBox();
         }
         catch (Exception ex)
         {
             pcc?.Release(wpfWindow: this);
             pcc = null;
             MessageBox.Show("Error:\n" + ex.Message);
         }
     }
 }
Exemple #4
0
        private void Open_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.pcc|*.pcc";
            if (d.ShowDialog() == true)
            {
                try
                {
                    LoadMEPackage(d.FileName);
                    if (pcc.Game == MEGame.ME1)
                    {
                        pcc?.Release(wpfWindow: this);
                        pcc = null;
                        throw new FormatException("FaceFXEditor does not work on ME1 files.");
                    }
                    selectedLine = null;
                    FaceFX       = null;
                    treeView.Nodes.Clear();
                    linesListBox.ItemsSource     = null;
                    animationListBox.ItemsSource = null;
                    graph.Clear();
                    RefreshComboBox();
                }
                catch (Exception ex)
                {
                    pcc?.Release(wpfWindow: this);
                    pcc = null;
                    MessageBox.Show("Error:\n" + ex.Message);
                }
            }
        }
Exemple #5
0
        public ME3FaceFXLine Clone()
        {
            ME3FaceFXLine line = (ME3FaceFXLine)MemberwiseClone();

            line.animations = line.animations.TypedClone();
            line.points     = line.points.TypedClone();
            line.numKeys    = line.numKeys.TypedClone();
            return(line);
        }
        public ME3FaceFXLine Clone()
        {
            ME3FaceFXLine line = this.MemberwiseClone() as ME3FaceFXLine;

            line.animations = line.animations.Clone() as ME3NameRef[];
            line.points     = line.points.Clone() as ControlPoint[];
            line.numKeys    = line.numKeys.Clone() as int[];
            return(line);
        }
Exemple #7
0
 public TreeNode[] DataToTree2(ME3FaceFXLine d)
 {
     TreeNode[] nodes = new TreeNode[7];
     nodes[0] = new TreeNode("Name : 0x" + d.Name.ToString("X8") + " \"" + header.Names[d.Name].Trim() + "\"");
     nodes[1] = new TreeNode("FadeInTime : " + d.FadeInTime);
     nodes[2] = new TreeNode("FadeOutTime : " + d.FadeOutTime);
     nodes[3] = new TreeNode("Unk2 : 0x" + d.unk2.ToString("X8"));
     nodes[4] = new TreeNode("Path : " + d.path);
     nodes[5] = new TreeNode("ID : " + d.ID);
     nodes[6] = new TreeNode("Index : 0x" + d.index.ToString("X8"));
     return(nodes);
 }
 public TreeNode[] DataToTree2(ME3FaceFXLine d)
 {
     TreeNode[] nodes = new TreeNode[7];
     nodes[0] = new TreeNode($"Name : 0x{d.Name:X8} \"{header.Names[d.Name].Trim()}\"");
     nodes[1] = new TreeNode($"FadeInTime : {d.FadeInTime}");
     nodes[2] = new TreeNode($"FadeOutTime : {d.FadeOutTime}");
     nodes[3] = new TreeNode($"Unk2 : 0x{d.unk2:X8}");
     nodes[4] = new TreeNode($"Path : {d.path}");
     nodes[5] = new TreeNode($"ID : {d.ID}");
     nodes[6] = new TreeNode($"Index : 0x{d.index:X8}");
     return(nodes);
 }
 private void linesListBox_Drop(object sender, DragEventArgs e)
 {
     this.RestoreAndBringToFront();
     if (e.Data.GetDataPresent("FaceFXLine"))
     {
         dynamic       d           = e.Data.GetData("FaceFXLine");
         string[]      sourceNames = d.sourceNames;
         List <string> names       = FaceFX.Header.Names.ToList();
         ME3FaceFXLine line        = d.line;
         line.Name = names.FindOrAdd(sourceNames[line.Name]);
         if (Pcc.Game == MEGame.ME3)
         {
             (FaceFX as ME3FaceFXAnimSet).FixNodeTable();
             line.animations = line.animations.Select(x => new ME3NameRef
             {
                 index = names.FindOrAdd(sourceNames[x.index]),
                 unk2  = x.unk2
             }).ToArray();
             FaceFX.Data.Data         = FaceFX.Data.Data.Append(line).ToArray();
             FaceFX.Header.Names      = names.ToArray();
             linesListBox.ItemsSource = FaceFX.Data.Data;
         }
         else
         {
             if (!(line is ME2FaceFXLine))
             {
                 var result = MessageBox.Show("Cannot add ME3 FaceFX lines to ME2 FaceFXAnimsets. " +
                                              "If you require this feature, please make an issue on the project's Github page. Would you like to go the Github page now?",
                                              "Feature Not Implemented", MessageBoxButton.YesNo, MessageBoxImage.Question);
                 if (result == MessageBoxResult.Yes)
                 {
                     System.Diagnostics.Process.Start(App.BugReportURL);
                 }
                 return;
             }
             line.animations = line.animations.Select(x => new ME2NameRef
             {
                 index = names.FindOrAdd(sourceNames[x.index]),
                 unk2  = x.unk2
             }).ToArray();
             ME2DataAnimSetStruct me2DataAnimSetStruct = (FaceFX.Data as ME2DataAnimSetStruct);
             me2DataAnimSetStruct.Data = me2DataAnimSetStruct.Data.Append(line as ME2FaceFXLine).ToArray();
             FaceFX.Header.Names       = names.ToArray();
             linesListBox.ItemsSource  = me2DataAnimSetStruct.Data;
         }
     }
     SaveChanges();
 }
 public void LoadFile(string fileName)
 {
     try
     {
         LoadMEPackage(fileName);
         selectedLine = null;
         FaceFX       = null;
         treeView.Nodes.Clear();
         linesListBox.ItemsSource     = null;
         animationListBox.ItemsSource = null;
         graph.Clear();
         RefreshComboBox();
     }
     catch (Exception ex)
     {
         UnLoadMEPackage();
         MessageBox.Show("Error:\n" + ex.Message);
     }
 }
Exemple #11
0
        public override void handleUpdate(List <PackageUpdate> updates)
        {
            IEnumerable <PackageUpdate> relevantUpdates = updates.Where(x => x.change != PackageChange.Import &&
                                                                        x.change != PackageChange.ImportAdd &&
                                                                        x.change != PackageChange.Names);
            List <int> updatedExports = relevantUpdates.Select(x => x.index).ToList();

            if (FaceFX != null && updatedExports.Contains(FaceFX.Export.Index))
            {
                int index = FaceFX.Export.Index;
                //loaded FaceFXAnimset is no longer a FaceFXAnimset
                if (FaceFX.Export.ClassName != "FaceFXAnimSet")
                {
                    selectedLine = null;
                    FaceFX       = null;
                    treeView.Nodes.Clear();
                    linesListBox.ItemsSource     = null;
                    animationListBox.ItemsSource = null;
                    graph.Clear();
                }
                else if (!this.IsForegroundWindow())
                {
                    loadFaceFXAnimset();
                }
                updatedExports.Remove(index);
            }
            if (updatedExports.Intersect(animSets.Select(x => x.Index)).Any())
            {
                RefreshComboBox();
            }
            else
            {
                foreach (var i in updatedExports)
                {
                    if (pcc.getExport(i).ClassName == "FaceFXAnimSet")
                    {
                        RefreshComboBox();
                        break;
                    }
                }
            }
        }
Exemple #12
0
 private void linesListBox_Drop(object sender, DragEventArgs e)
 {
     this.RestoreAndBringToFront();
     if (e.Data.GetDataPresent("FaceFXLine"))
     {
         dynamic       d           = e.Data.GetData("FaceFXLine");
         string[]      sourceNames = d.sourceNames;
         List <string> names       = FaceFX.Header.Names.ToList();
         ME3FaceFXLine line        = d.line;
         line.Name = names.FindOrAdd(sourceNames[line.Name]);
         if (pcc.Game == MEGame.ME3)
         {
             line.animations = line.animations.Select(x => new ME3NameRef
             {
                 index = names.FindOrAdd(sourceNames[x.index]),
                 unk2  = x.unk2
             }).ToArray();
             FaceFX.Data.Data         = FaceFX.Data.Data.Concat(line).ToArray();
             FaceFX.Header.Names      = names.ToArray();
             linesListBox.ItemsSource = FaceFX.Data.Data;
         }
         else
         {
             if (!(line is ME2FaceFXLine))
             {
                 MessageBox.Show("Cannot add ME3 FaceFX lines to ME2 FaceFXAnimsets. If you require this feature, please make an issue on the project's Github page");
                 return;
             }
             line.animations = line.animations.Select(x => new ME2NameRef
             {
                 index = names.FindOrAdd(sourceNames[x.index]),
                 unk2  = x.unk2
             }).ToArray();
             ME2DataAnimSetStruct me2DataAnimSetStruct = (FaceFX.Data as ME2DataAnimSetStruct);
             me2DataAnimSetStruct.Data = me2DataAnimSetStruct.Data.Concat(line as ME2FaceFXLine).ToArray();
             FaceFX.Header.Names       = names.ToArray();
             linesListBox.ItemsSource  = me2DataAnimSetStruct.Data;
         }
     }
     SaveChanges();
 }
Exemple #13
0
        private void DeleteLine_Click(object sender, RoutedEventArgs e)
        {
            ME3FaceFXLine line = (ME3FaceFXLine)linesListBox.SelectedItem;

            if (pcc.Game == MEGame.ME3)
            {
                List <ME3FaceFXLine> lines = FaceFX.Data.Data.ToList();
                lines.Remove(line);
                FaceFX.Data.Data         = lines.ToArray();
                linesListBox.ItemsSource = FaceFX.Data.Data;
            }
            else
            {
                ME2DataAnimSetStruct me2DataAnimSetStruct = (FaceFX.Data as ME2DataAnimSetStruct);
                List <ME2FaceFXLine> lines = me2DataAnimSetStruct.Data.ToList();
                lines.Remove(line as ME2FaceFXLine);
                me2DataAnimSetStruct.Data = lines.ToArray();
                linesListBox.ItemsSource  = me2DataAnimSetStruct.Data;
            }
            SaveChanges();
        }
Exemple #14
0
 private void linesListBox_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.LeftButton == MouseButtonState.Pressed && !dragStart.Equals(new Point(0, 0)) && dragEnabled)
     {
         System.Windows.Vector diff = dragStart - e.GetPosition(linesListBox);
         if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
         {
             try
             {
                 dragStart = new Point(0, 0);
                 if (!(e.OriginalSource is ScrollViewer) && linesListBox.SelectedItem != null)
                 {
                     ME3FaceFXLine d = (linesListBox.SelectedItem as ME3FaceFXLine).Clone();
                     DragDrop.DoDragDrop(linesListBox, new DataObject("FaceFXLine", new { line = d, sourceNames = FaceFX.Header.Names }), DragDropEffects.Copy);
                 }
             }
             catch (Exception)
             {
                 throw;
             }
         }
     }
 }
Exemple #15
0
        void SerializeData(SerializingContainer Container)
        {
            if (Container.isLoading)
            {
                data = new ME3DataAnimSetStruct();
            }
            data.unk1 = Container + data.unk1;
            data.unk2 = Container + data.unk2;
            data.unk3 = Container + data.unk3;
            data.unk4 = Container + data.unk4;
            int count = 0;

            if (!Container.isLoading)
            {
                count = data.Data.Length;
            }
            count = Container + count;
            if (Container.isLoading)
            {
                data.Data = new ME3FaceFXLine[count];
            }
            for (int i = 0; i < count; i++)
            {
                if (Container.isLoading)
                {
                    data.Data[i] = new ME3FaceFXLine();
                }
                ME3FaceFXLine d = data.Data[i];
                d.Name = Container + d.Name;
                if (Container.isLoading)
                {
                    d.NameAsString = header.Names[d.Name];
                }
                int count2 = 0;
                if (!Container.isLoading)
                {
                    count2 = d.animations.Length;
                }
                count2 = Container + count2;
                if (Container.isLoading)
                {
                    d.animations = new ME3NameRef[count2];
                }
                for (int j = 0; j < count2; j++)
                {
                    if (Container.isLoading)
                    {
                        d.animations[j] = new ME3NameRef();
                    }
                    ME3NameRef u = d.animations[j];
                    u.index         = Container + u.index;
                    u.unk2          = Container + u.unk2;
                    d.animations[j] = u;
                }
                count2 = 0;
                if (!Container.isLoading)
                {
                    count2 = d.points.Length;
                }
                count2 = Container + count2;
                if (Container.isLoading)
                {
                    d.points = new ControlPoint[count2];
                }
                for (int j = 0; j < count2; j++)
                {
                    if (Container.isLoading)
                    {
                        d.points[j] = new ControlPoint();
                    }
                    ControlPoint u = d.points[j];
                    u.time         = Container + u.time;
                    u.weight       = Container + u.weight;
                    u.inTangent    = Container + u.inTangent;
                    u.leaveTangent = Container + u.leaveTangent;
                    d.points[j]    = u;
                }
                if (d.animations.Length > 0)
                {
                    count2 = 0;
                    if (!Container.isLoading)
                    {
                        count2 = d.numKeys.Length;
                    }
                    count2 = Container + count2;
                    if (Container.isLoading)
                    {
                        d.numKeys = new int[count2];
                    }
                    for (int j = 0; j < count2; j++)
                    {
                        d.numKeys[j] = Container + d.numKeys[j];
                    }
                }
                else if (Container.isLoading)
                {
                    d.numKeys = new int[0];
                }
                d.FadeInTime  = Container + d.FadeInTime;
                d.FadeOutTime = Container + d.FadeOutTime;
                d.unk2        = Container + d.unk2;
                d.path        = SerializeString(Container, d.path);
                d.ID          = SerializeString(Container, d.ID);
                d.index       = Container + d.index;
                data.Data[i]  = d;
            }
        }
 public override void handleUpdate(List<PackageUpdate> updates)
 {
     IEnumerable<PackageUpdate> relevantUpdates = updates.Where(x => x.change != PackageChange.Import &&
                                                                     x.change != PackageChange.ImportAdd &&
                                                                     x.change != PackageChange.Names);
     List<int> updatedExports = relevantUpdates.Select(x => x.index).ToList();
     if (FaceFX != null && updatedExports.Contains(FaceFX.Export.Index))
     {
         int index = FaceFX.Export.Index;
         //loaded FaceFXAnimset is no longer a FaceFXAnimset
         if (FaceFX.Export.ClassName != "FaceFXAnimSet")
         {
             selectedLine = null;
             FaceFX = null;
             treeView.Nodes.Clear();
             linesListBox.ItemsSource = null;
             animationListBox.ItemsSource = null;
             graph.Clear();
         }
         else if (!this.IsForegroundWindow())
         {
             loadFaceFXAnimset();
         }
         updatedExports.Remove(index);
     }
     if (updatedExports.Intersect(animSets.Select(x => x.Index)).Count() > 0)
     {
         RefreshComboBox();
     }
     else
     {
         foreach (var i in updatedExports)
         {
             if (pcc.getExport(i).ClassName == "FaceFXAnimSet")
             {
                 RefreshComboBox();
                 break;
             }
         }
     }
 }
        private void linesListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            animationListBox.ItemsSource = null;
            lineText.Text = null;

            if (e.AddedItems.Count != 1)
            {
                return;
            }
            selectedLine = (ME3FaceFXLine)e.AddedItems[0];
            updateAnimListBox();
            int tlkID = 0;
            if (int.TryParse(selectedLine.ID, out tlkID))
            {
                if (pcc.Game == MEGame.ME3)
                {
                    lineText.Text = ME3TalkFiles.findDataById(tlkID); 
                }
                else
                {
                    lineText.Text = ME2Explorer.ME2TalkFiles.findDataById(tlkID);
                }
            }
            treeView.Nodes.Clear();
            System.Windows.Forms.TreeNode[] treeNodes = FaceFX.DataToTree2(selectedLine);
            treeView.Nodes.AddRange(treeNodes);
        }
 public TreeNode[] DataToTree2(ME3FaceFXLine d)
 {
     TreeNode[] nodes = new TreeNode[7];
     nodes[0] = new TreeNode("Name : 0x" + d.Name.ToString("X8") + " \"" + header.Names[d.Name].Trim() + "\"");
     nodes[1] = new TreeNode("FadeInTime : " + d.FadeInTime);
     nodes[2] = new TreeNode("FadeOutTime : " + d.FadeOutTime);
     nodes[3] = new TreeNode("Unk2 : 0x" + d.unk2.ToString("X8"));
     nodes[4] = new TreeNode("Path : " + d.path);
     nodes[5] = new TreeNode("ID : " + d.ID);
     nodes[6] = new TreeNode("Index : 0x" + d.index.ToString("X8"));
     return nodes;
 }
Exemple #19
0
        private void treeView2_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            TreeNode t = treeView2.SelectedNode;

            if (t == null || t.Parent == null)
            {
                return;
            }
            TreeNode t1 = t.Parent;

            if (t1 == null || t1.Parent == null)
            {
                return;
            }
            TreeNode t2 = t1.Parent;

            if (t2 == null || t2.Parent == null)
            {
                return;
            }
            string result; int i; float f = 0;

            if (t2.Text == "Entries")
            {
                int           entidx = t1.Index;
                int           subidx = t.Index;
                ME3FaceFXLine d      = FaceFX.Data.Data[entidx];
                switch (subidx)
                {
                case 0:    //unk1
                    result = Microsoft.VisualBasic.Interaction.InputBox("Please enter new value", "ME3Explorer", d.Name.ToString(), 0, 0);
                    i      = -1;
                    if (int.TryParse(result, out i) && i >= 0 && i < FaceFX.Header.Names.Length)
                    {
                        d.Name         = i;
                        d.NameAsString = FaceFX.Header.Names[d.Name];
                    }

                    break;

                case 4:    //FadeInTime
                    result = Microsoft.VisualBasic.Interaction.InputBox("Please enter new value", "ME3Explorer", d.FadeInTime.ToString(), 0, 0);
                    if (float.TryParse(result, out f))
                    {
                        d.FadeInTime = f;
                    }
                    break;

                case 5:    //FadeInTime
                    result = Microsoft.VisualBasic.Interaction.InputBox("Please enter new value", "ME3Explorer", d.FadeOutTime.ToString(), 0, 0);
                    if (float.TryParse(result, out f))
                    {
                        d.FadeOutTime = f;
                    }
                    break;

                case 6:    //unk2
                    result = Microsoft.VisualBasic.Interaction.InputBox("Please enter new value", "ME3Explorer", d.unk2.ToString(), 0, 0);
                    i      = -1;
                    if (int.TryParse(result, out i) && i >= 0 && i < FaceFX.Header.Names.Length)
                    {
                        d.unk2 = i;
                    }
                    break;

                case 7:    //Path
                    d.path = Microsoft.VisualBasic.Interaction.InputBox("Please enter new value", "ME3Explorer", d.path, 0, 0);
                    break;

                case 8:    //ID
                    d.ID = Microsoft.VisualBasic.Interaction.InputBox("Please enter new value", "ME3Explorer", d.ID, 0, 0);
                    break;

                case 9:    //unk3
                    result = Microsoft.VisualBasic.Interaction.InputBox("Please enter new value", "ME3Explorer", d.index.ToString(), 0, 0);
                    i      = -1;
                    if (int.TryParse(result, out i) && i >= 0 && i < FaceFX.Header.Names.Length)
                    {
                        d.index = i;
                    }
                    break;

                default:
                    return;
                }
                FaceFX.Data.Data[entidx] = d;
                FaceFX.Save();
            }
            else if (t2.Parent.Text == "Entries")
            {
                int           entidx    = t2.Index;
                int           subidx    = t1.Index;
                int           subsubidx = t.Index;
                ME3FaceFXLine d         = FaceFX.Data.Data[entidx];
                switch (subidx)
                {
                case 1:
                    ME3NameRef u = d.animations[subsubidx];
                    result = Microsoft.VisualBasic.Interaction.InputBox("Please enter new value", "ME3Explorer", u.index + " ; " + u.unk2, 0, 0);
                    string[] reslist = result.Split(';');
                    if (reslist.Length != 2)
                    {
                        return;
                    }
                    if (int.TryParse(reslist[0].Trim(), out i))
                    {
                        u.index = i;
                    }
                    else
                    {
                        return;
                    }
                    if (int.TryParse(reslist[1].Trim(), out i))
                    {
                        u.unk2 = i;
                    }
                    else
                    {
                        return;
                    }
                    d.animations[subsubidx] = u;
                    break;

                case 2:
                    ControlPoint u2 = d.points[subsubidx];
                    result  = Microsoft.VisualBasic.Interaction.InputBox("Please enter new value", "ME3Explorer", u2.time + " ; " + u2.weight + " ; " + u2.inTangent + " ; " + u2.leaveTangent, 0, 0);
                    reslist = result.Split(';');
                    if (reslist.Length != 4)
                    {
                        return;
                    }
                    if (float.TryParse(reslist[0].Trim(), out f))
                    {
                        u2.time = f;
                    }
                    else
                    {
                        return;
                    }
                    if (float.TryParse(reslist[1].Trim(), out f))
                    {
                        u2.weight = f;
                    }
                    else
                    {
                        return;
                    }
                    if (float.TryParse(reslist[2].Trim(), out f))
                    {
                        u2.inTangent = f;
                    }
                    else
                    {
                        return;
                    }
                    if (float.TryParse(reslist[3].Trim(), out f))
                    {
                        u2.leaveTangent = f;
                    }
                    else
                    {
                        return;
                    }
                    d.points[subsubidx] = u2;
                    break;

                case 3:
                    result = Microsoft.VisualBasic.Interaction.InputBox("Please enter new value", "ME3Explorer", d.numKeys[subsubidx].ToString(), 0, 0);
                    if (int.TryParse(result.Trim(), out i))
                    {
                        d.numKeys[subsubidx] = i;
                    }
                    else
                    {
                        return;
                    }
                    break;
                }
                FaceFX.Data.Data[entidx] = d;
                FaceFX.Save();
            }
        }