Beispiel #1
0
        private void Export_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(OpenFile.xmlPath))
            {
                return;
            }
            if (string.IsNullOrEmpty(OpenFile.bndPath))
            {
                return;
            }

            Data.UpdateRootmotionData(AnimXml.FrameDataToString(TempFrameData.Absolute));
            Data.Save(OpenFile.xmlPath);

            string  hkxpacksoulsPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "hkxpackds3.exe");
            HKXPack packer           = new HKXPack(hkxpacksoulsPath);

            OpenFile.hkxPath = packer.Pack(OpenFile.xmlPath);

            OpenFile.extractedFile.File.Bytes = File.ReadAllBytes(OpenFile.hkxPath);

            if (!anibnd.Files.Any(f => f.ID == OpenFile.extractedFile.File.ID))
            {
                return;
            }
            int listID = anibnd.Files.FindIndex(f => f.ID == OpenFile.extractedFile.File.ID);

            anibnd.Files[listID] = OpenFile.extractedFile.File;

            FileInfo bakFileInfo = new FileInfo(OpenFile.bndPath + ".bak");
            FileInfo bndFileInfo = new FileInfo(OpenFile.bndPath);

            bakFileInfo.IsReadOnly = false;
            bndFileInfo.IsReadOnly = false;

            if (File.Exists(OpenFile.bndPath + ".bak"))
            {
                File.SetAttributes(OpenFile.bndPath + ".bak", FileAttributes.Normal);
            }

            File.Delete(OpenFile.bndPath + ".bak");
            File.Move(OpenFile.bndPath, OpenFile.bndPath + ".bak");
            anibnd.Write(OpenFile.bndPath);
        }
Beispiel #2
0
        public void OpenFrameData(string xmlFile)
        {
            Data = new AnimXml(xmlFile);
            var(rootmotionData, rootmotionNotFound) = Data.GetRootmotionData();

            if (rootmotionNotFound)
            {
                TextBlock textBlock = new TextBlock
                {
                    Text       = "No Rootmotion Found to Edit",
                    Foreground = Brushes.Red,
                    FontSize   = 60,
                };

                Canvas.Children.Add(textBlock);
                OpenFile.xmlPath = string.Empty;
                OpenFile.hkxPath = string.Empty;
                return;
            }

            var(frameData, parsingError) = Data.processRootmotionData(rootmotionData);
            if (!parsingError)
            {
                FrameData     = new FrameDataModel(frameData);
                TempFrameData = new FrameDataModel(frameData);

                StackPanel.Children.Clear();
                foreach (var frame in FrameData.Relative.Select((motion, index) => (motion, index)))
                {
                    StackPanel newPanel = new StackPanel
                    {
                        Height      = 40,
                        Orientation = Orientation.Horizontal
                    };

                    Label Frame = new Label {
                        Content = frame.index, Background = Brushes.LightGray, Width = 60, VerticalContentAlignment = VerticalAlignment.Center
                    };
                    FrameInputBox X = new FrameInputBox {
                        Text = frame.motion["X"].ToString(), Background = Brushes.IndianRed, Width = 150, VerticalContentAlignment = VerticalAlignment.Center, BorderThickness = new Thickness(0)
                    };
                    FrameInputBox Y = new FrameInputBox {
                        Text = frame.motion["Y"].ToString(), Background = Brushes.LightYellow, Width = 150, VerticalContentAlignment = VerticalAlignment.Center, BorderThickness = new Thickness(0)
                    };
                    FrameInputBox Z = new FrameInputBox {
                        Text = frame.motion["Z"].ToString(), Background = Brushes.DodgerBlue, Width = 150, VerticalContentAlignment = VerticalAlignment.Center, BorderThickness = new Thickness(0)
                    };

                    X.Frame = frame.index;
                    Y.Frame = frame.index;
                    Z.Frame = frame.index;

                    X.axis = "X";
                    Y.axis = "Y";
                    Z.axis = "Z";

                    X.value = frame.motion["X"];
                    Y.value = frame.motion["Y"];
                    Z.value = frame.motion["Z"];

                    X.LostFocus += HandleTextboxFramedataChange;
                    Y.LostFocus += HandleTextboxFramedataChange;
                    Z.LostFocus += HandleTextboxFramedataChange;

                    newPanel.Children.Add(Frame);
                    newPanel.Children.Add(X);
                    newPanel.Children.Add(Y);
                    newPanel.Children.Add(Z);

                    StackPanel.Children.Add(newPanel);
                }

                DrawGraphs(frameData);
            }
        }