Пример #1
0
 public MeshSceneNodeViewModel(Rmv2MeshNode node, PackFileService pfs, SkeletonAnimationLookUpHelper animLookUp, IComponentManager componentManager)
 {
     _meshNode = node;
     General   = new MeshSceneNodeViewModel_General(_meshNode);
     Animation = new MeshSceneNodeViewModel_Animation(pfs, _meshNode, animLookUp, componentManager);
     Graphics  = new MeshSceneNodeViewModel_Graphics(_meshNode, pfs);
 }
Пример #2
0
        public void CreateModPackFile()
        {
            PackFileService packFileService = new PackFileService(new PackFileDataBase(), null);
            var             packContainer   = packFileService.CreateNewPackFileContainer("MyTestPackFile", PackFileCAType.MOD);


            var packFile = new PackFile("ExampleFile.txt", new FileSystemSource(@"Data\FolderData\SubFolder0\Subfolder_0_file0.txt"));

            packFileService.AddFileToPack(packContainer, @"data\content\files", packFile);

            //var packFileContent = Encoding.UTF8.GetString(packFile.DataSource.ReadData());

            using (MemoryStream ms0 = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(ms0))
                    packFileService.Save(packContainer, writer);

                // Load it again
                var orgData = ms0.ToArray();
                using (MemoryStream ms1 = new MemoryStream(orgData))
                {
                    Assert.AreEqual(ms1.Length, orgData.Length);

                    using (BinaryReader reader = new BinaryReader(ms1))
                    {
                        var loadedPackFile = new PackFileContainer("File", reader);

                        Assert.AreEqual(packContainer.Header.Version, loadedPackFile.Header.Version);
                        Assert.AreEqual(packContainer.Header.FileType, loadedPackFile.Header.FileType);
                        Assert.AreEqual(1, loadedPackFile.Header.FileCount);
                        Assert.AreEqual(0, loadedPackFile.Header.ReferenceFileCount);
                    }
                }
            }
        }
        public static AnimationFragmentViewModel CreateFromFragment(PackFileService pfs, FileTypes.AnimationPack.AnimationFragment fragment, bool isEditable = true)
        {
            var viewModel = new AnimationFragmentViewModel(pfs, isEditable);

            viewModel.Load(fragment);
            return(viewModel);
        }
        public void LoadAllCaPacks()
        {
            PackFileService packFileService = new PackFileService(new PackFileDataBase(), null);
            var             result          = packFileService.LoadAllCaFiles(@"Data");

            Assert.IsTrue(result);
        }
Пример #5
0
        public static MetaDataFile ParseFile(PackFile file, PackFileService pf)
        {
            var fileContent   = file.DataSource.ReadData();
            var contentLength = fileContent.Count();


            MetaDataFile outputFile = new MetaDataFile()
            {
                FileName = pf.GetFullPath(file),
                Version  = BitConverter.ToInt32(fileContent, 0)
            };

            if (outputFile.Version != 2)
            {
                throw new Exception($"Unknown version - {outputFile.Version} for {outputFile.FileName}");
            }

            if (contentLength > 8)
            {
                MetaDataTagItem currentElement = null;
                int             numElements    = BitConverter.ToInt32(fileContent, 4);
                int             currentIndex   = 0 + 8; // First 4 bytes is the number of elements, next 2 is unknown
                while (currentIndex != contentLength && (currentElement = GetElement(currentIndex, fileContent, outputFile.FileName, out currentIndex)) != null)
                {
                    outputFile.TagItems.Add(currentElement);
                }

                if (numElements != outputFile.TagItems.Count)
                {
                    throw new Exception($"Not the expected amount elements. Expected {numElements}, got {outputFile.TagItems.Count}");
                }
            }

            return(outputFile);
        }
Пример #6
0
 public ModelSaverHelper(PackFileService packFileService, SceneManager sceneManager, KitbasherViewModel kitbasherViewModel, MainEditableNode editableMeshNode)
 {
     _packFileService    = packFileService;
     _sceneManager       = sceneManager;
     _kitbasherViewModel = kitbasherViewModel;
     _editableMeshNode   = editableMeshNode;
 }
Пример #7
0
        public Editor(PackFileService pfs, SkeletonAnimationLookUpHelper skeletonAnimationLookUpHelper, AssetViewModel rider, AssetViewModel mount, AssetViewModel newAnimation, IComponentManager componentManager)
        {
            _pfs              = pfs;
            _newAnimation     = newAnimation;
            _mount            = mount;
            _rider            = rider;
            _selectionManager = componentManager.GetComponent <SelectionManager>();

            DisplayGeneratedSkeleton = new NotifyAttr <bool>(true, (value) => _newAnimation.IsSkeletonVisible = value);
            DisplayGeneratedMesh     = new NotifyAttr <bool>(true, (value) => { if (_newAnimation.MainNode != null)
                                                                                {
                                                                                    _newAnimation.MainNode.IsVisible = value;
                                                                                }
                                                             });

            SelectedRiderBone   = new FilterCollection <SkeletonBoneNode>(null, (x) => UpdateCanSaveAndPreviewStates());
            MountLinkController = new MountLinkController(pfs, skeletonAnimationLookUpHelper, rider, mount, UpdateCanSaveAndPreviewStates);

            ActiveOutputFragment = new FilterCollection <AnimationFragment>(null, OutputFragmentSelected);
            ActiveOutputFragment.SearchFilter = (value, rx) => { return(rx.Match(value.FileName).Success); };

            ActiveFragmentSlot = new FilterCollection <FragmentStatusSlotItem>(null, (x) => UpdateCanSaveAndPreviewStates());
            ActiveFragmentSlot.SearchFilter = (value, rx) => { return(rx.Match(value.Entry.Value.Slot.Value).Success); };

            _mount.SkeletonChanged  += MountSkeletonChanged;
            _rider.SkeletonChanged  += RiderSkeletonChanges;
            _rider.AnimationChanged += RiderAnimationChanged;

            MountSkeletonChanged(_mount.Skeleton);
            RiderSkeletonChanges(_rider.Skeleton);
        }
        public void Basic()
        {
            PackFileService packFileService = new PackFileService(new PackFileDataBase());
            var             loadedPackFile  = packFileService.Load(@"Data\CaPackFile_01.pack");

            Assert.NotNull(loadedPackFile);
            var fileCount = loadedPackFile.FileList.Count;

            Assert.AreEqual(4, fileCount);
        }
        PackFile GetWarLionModel()
        {
            PackFileService packFileService = new PackFileService(new PackFileDataBase());
            var             loadedPackFile  = packFileService.Load(@"Data\variants_wp_.pack");

            var file = packFileService.FindFile(@"variantmeshes\wh_variantmodels\bc4\hef\hef_war_lion\hef_war_lion_02.rigid_model_v2");

            Assert.NotNull(file);
            return(file as PackFile);
        }
        PackFile GetWeaponModel()
        {
            PackFileService packFileService = new PackFileService(new PackFileDataBase());
            var             loadedPackFile  = packFileService.Load(@"Data\variants_wp_.pack");

            var file = packFileService.FindFile(@"variantmeshes\wh_variantmodels\hu1d\hef\hef_props\hef_ranger_sword_1h_03.rigid_model_v2");

            Assert.NotNull(file);
            return(file as PackFile);
        }
Пример #11
0
        public BatchProcessorService(PackFileService pfs, MountAnimationGeneratorService animationGenerator, BatchProcessOptions batchProcessOptions)
        {
            _animPackName = batchProcessOptions.AnimPackName;
            _animBinName  = batchProcessOptions.AnimBinName;
            _fragmentName = batchProcessOptions.FragmentName;

            _pfs = pfs;
            _animationGenerator  = animationGenerator;
            _batchProcessOptions = batchProcessOptions;
        }
Пример #12
0
        public MainDecoderViewModel(SchemaManager schemaManager, /* MetaDataFile metaDataFile,*/ PackFileService pf, bool allTablesReadOnly = true)
        {
            _pf            = pf;
            _schemaManager = schemaManager;

            TableDefinitionEditor = new TableDefinitionEditor(schemaManager, ActiveMentaDataContent, ActiveTableDefinition);
            DataTable             = new MetaDataTable(ActiveTableDefinition, ActiveMentaDataContent, pf, allTablesReadOnly);
            FieldExplorer         = new FieldExplorer(TableDefinitionEditor, ActiveMentaDataContent, ActiveTableDefinition);

            //ActiveMentaDataContent.File = metaDataFile;
        }
Пример #13
0
            public TextureViewModel(Rmv2MeshNode meshNode, PackFileService packfileService, TexureType texureType)
            {
                _packfileService = packfileService;
                _meshNode        = meshNode;
                _texureType      = texureType;
                Path             = _meshNode.MeshModel.GetTexture(texureType)?.Path;

                PreviewCommand = new RelayCommand(() => TexturePreviewController.CreateVindow(Path, _packfileService));
                BrowseCommand  = new RelayCommand(BrowseTexture);
                RemoveCommand  = new RelayCommand(RemoveTexture);
            }
        public void DeleteFolder()
        {
            PackFileService packFileService = new PackFileService(new PackFileDataBase(), null);
            var             loadedPackFile  = packFileService.Load(@"Data\CaPackFile_01.pack");

            packFileService.DeleteFolder(loadedPackFile, @"warmachines\tex");

            var fileCount = loadedPackFile.FileList.Count;

            Assert.AreEqual(2, fileCount);
        }
        public PackFileBrowserWindow(PackFileService packfileService)
        {
            ViewModel             = new PackFileBrowserViewModel(packfileService);
            ViewModel.ContextMenu = new OpenFileContexMenuHandler(packfileService);
            ViewModel.FileOpen   += ViewModel_FileOpen;
            ViewModel.Filter.AutoExapandResultsAfterLimitedCount = 50;
            InitializeComponent();
            DataContext = this;

            PreviewKeyDown += HandleEsc;
        }
Пример #16
0
        public MetaDataTable(TableDefinitionModel dbTableDefinition, ActiveMetaDataContentModel activeMetaDataContent, PackFileService pf, bool allTablesReadOnly)
        {
            ItemDoubleClickedCommand = new RelayCommand <DataTableRow>(OnItemDoubleClicked);

            _pf = pf;
            _dbTableDefinition     = dbTableDefinition;
            _activeMetaDataContent = activeMetaDataContent;
            _allTablesReadOnly     = allTablesReadOnly;

            _dbTableDefinition.DefinitionChanged          += (v) => Update();
            _activeMetaDataContent.SelectedTagItemChanged += ActiveMetaDataContent_SelectedTagItemChanged;
        }
        public void LoadCaPackFile()
        {
            var             packFileDb      = new PackFileDataBase();
            PackFileService packFileService = new PackFileService(packFileDb, null);
            var             result          = packFileService.Load(@"Data\CaPackFile_01.pack");

            Assert.NotNull(result);
            Assert.AreEqual(1, packFileDb.PackFiles.Count);
            var fileCount = packFileDb.PackFiles[0].FileList.Count;

            Assert.AreEqual(4, fileCount);
        }
        public void DeleteFile()
        {
            PackFileService packFileService = new PackFileService(new PackFileDataBase(), null);
            var             loadedPackFile  = packFileService.Load(@"Data\CaPackFile_01.pack");
            var             file            = packFileService.FindFile(@"warmachines\tex\dwf_gyrocopter_obisidan_01_diffuse.dds");

            packFileService.DeleteFile(loadedPackFile, file);

            var fileCount = loadedPackFile.FileList.Count;

            Assert.AreEqual(3, fileCount);
        }
        public MenuBarViewModel(IComponentManager componentManager, PackFileService packFileService, SkeletonAnimationLookUpHelper skeletonHelper)
        {
            _packFileService = packFileService;

            TransformTool = new TransformToolViewModel(componentManager);
            Gizmo         = new GizmoModeMenuBarViewModel(TransformTool, componentManager, _commandFactory);
            General       = new GeneralMenuBarViewModel(componentManager, _commandFactory);
            Tools         = new ToolsMenuBarViewModel(componentManager, _commandFactory, _packFileService, skeletonHelper);

            ImportReferenceCommand            = new RelayCommand(ImportReference);
            ImportReferenceCommand_PaladinVMD = new RelayCommand(ImportReference_PaladinVMD);
        }
        public void UnloadPackFile()
        {
            PackFileService packFileService = new PackFileService(new PackFileDataBase(), null);
            var             pack0           = packFileService.Load(@"Data\CaPackFile_01.pack");
            var             pack1           = packFileService.Load(@"Data\boot.pack");

            Assert.NotNull(pack0);
            Assert.NotNull(pack1);

            Assert.AreEqual(2, packFileService.Database.PackFiles.Count);
            packFileService.UnloadPackContainer(pack0);
            Assert.AreEqual(1, packFileService.Database.PackFiles.Count);
        }
        public void LoadBootPack()
        {
            PackFileService packFileService = new PackFileService(new PackFileDataBase(), null);
            var             pack0           = packFileService.Load(@"Data\boot.pack");


            var      file        = packFileService.FindFile(@"fx\cardcaps.txt");
            PackFile concretFile = file as PackFile;
            var      s           = Encoding.UTF8.GetString(concretFile.DataSource.ReadData());


            Assert.NotNull(pack0);
        }
 public MenuBarViewModel(IServiceProvider provider, PackFileService packfileService, ToolFactory toolFactory)
 {
     _serviceProvider             = provider;
     _packfileService             = packfileService;
     _toolFactory                 = toolFactory;
     OpenSettingsWindowCommand    = new RelayCommand(ShowSettingsDialog);
     OpenPackFileCommand          = new RelayCommand(OpenPackFile);
     CreateNewPackFileCommand     = new RelayCommand(CreatePackFile);
     OpenAssetEditorFolderCommand = new RelayCommand(OpenAssetEditorFolder);
     OpenKitbashEditorCommand     = new RelayCommand(OpenKitbasherTool);
     OpenAnimMetaDecocderCommand  = new RelayCommand(OpenAnimMetaDecocder);
     OpenMountCreatorCommand      = new RelayCommand(OpenMountCreator);
     OpenPropCreatorCommand       = new RelayCommand(OpenPropCreatorEditor);
 }
Пример #23
0
        public MeshSceneNodeViewModel_Graphics(Rmv2MeshNode meshNode, PackFileService pf)
        {
            _meshNode             = meshNode;
            ShaderName            = _meshNode.MeshModel.Header.ShaderParams.ShaderName;
            PossibleMaterialTypes = Enum.GetValues(typeof(GroupTypeEnum)).Cast <GroupTypeEnum>();
            PossibleVertexTypes   = Enum.GetValues(typeof(VertexFormat)).Cast <VertexFormat>();

            Textures = new Dictionary <TexureType, TextureViewModel>();
            Textures.Add(TexureType.Diffuse, new TextureViewModel(_meshNode, pf, TexureType.Diffuse));
            Textures.Add(TexureType.Specular, new TextureViewModel(_meshNode, pf, TexureType.Specular));
            Textures.Add(TexureType.Normal, new TextureViewModel(_meshNode, pf, TexureType.Normal));
            Textures.Add(TexureType.Mask, new TextureViewModel(_meshNode, pf, TexureType.Mask));
            Textures.Add(TexureType.Gloss, new TextureViewModel(_meshNode, pf, TexureType.Gloss));
        }
        public MainEditableNodeViewModel(MainEditableNode mainNode, SkeletonAnimationLookUpHelper skeletonAnimationLookUpHelper, AnimationControllerViewModel animationControllerViewModel, PackFileService pf)
        {
            _mainNode = mainNode;
            _skeletonAnimationLookUpHelper = skeletonAnimationLookUpHelper;
            _animationControllerViewModel  = animationControllerViewModel;
            _pf = pf;

            SkeletonNameList = _skeletonAnimationLookUpHelper.SkeletonFileNames;
            if (_mainNode.Model != null)
            {
                SkeletonName = SkeletonNameList.FirstOrDefault(x => x.Contains(_mainNode.Model.Header.SkeletonName));
                UpdateSkeletonName();
            }
        }
        public TexturePreviewController(string imagePath, TexturePreviewViewModel viewModel, PackFileService packFileService)
        {
            _imagePath       = imagePath;
            _viewModel       = viewModel;
            _packFileService = packFileService;

            _scene = new SceneContainer();
            _scene.Components.Add(new ResourceLibary(_scene, packFileService));
            _scene.ForceCreate();


            _resourceLib     = _scene.GetComponent <ResourceLibary>();
            _textureRenderer = new TextureToTextureRenderer(_scene.GraphicsDevice, new SpriteBatch(_scene.GraphicsDevice), _resourceLib);
            CreateImage();
        }
        public void AddFileToFolder()
        {
            PackFileService packFileService = new PackFileService(new PackFileDataBase());
            var             loadedPackFile  = packFileService.Load(@"Data\CaPackFile_01.pack");

            packFileService.AddFileToPack(loadedPackFile, @"warmachines\materials", TestPackFileHelper.CreatePackFile("TestFile.txt"));

            var newFileCount = loadedPackFile.FileList.Count;

            Assert.AreEqual(5, newFileCount);

            var file = packFileService.FindFile(@"warmachines\materials\TestFile.txt");

            Assert.NotNull(file);
        }
        public void AddFolderToChild()
        {
            PackFileService packFileService = new PackFileService(new PackFileDataBase());
            var             loadedPackFile  = packFileService.Load(@"Data\CaPackFile_01.pack");

            packFileService.AddFolderContent(loadedPackFile, @"warmachines\materials", @"Data\FolderData");

            var newFileCount = loadedPackFile.FileList.Count;

            Assert.AreEqual(9, newFileCount);

            var file = packFileService.FindFile(@"warmachines\materials\subFolder1\Subfolder_1_file1.txt");

            Assert.NotNull(file);
        }
Пример #28
0
        public static void Save(PackFileService packFileService, PackFile inputFile)
        {
            var selectedEditabelPackFile = packFileService.GetEditablePack();
            var filePackFileConainer     = packFileService.GetPackFileContainer(inputFile);

            if (selectedEditabelPackFile == null)
            {
                MessageBox.Show("No editable pack selected!");
                return;
            }

            if (filePackFileConainer != selectedEditabelPackFile)
            {
                var filePath = packFileService.GetFullPath(inputFile, filePackFileConainer);
                packFileService.CopyFileFromOtherPackFile(filePackFileConainer, filePath, selectedEditabelPackFile);
            }
        }
Пример #29
0
        public ModelLoaderService(PackFileService packFileService, ResourceLibary resourceLibary, AnimationControllerViewModel animationView, SceneManager sceneManager, IPackFile mainFile)
        {
            _packFileService = packFileService;
            _resourceLibary  = resourceLibary;
            _animationView   = animationView;
            _sceneManager    = sceneManager;

            var skeletonNode = _sceneManager.RootNode.AddObject(new SkeletonNode(resourceLibary.Content, animationView)
            {
                IsLockable = false
            }) as SkeletonNode;

            EditableMeshNode  = (MainEditableNode)_sceneManager.RootNode.AddObject(new MainEditableNode("Editable Model", skeletonNode, mainFile));
            ReferenceMeshRoot = sceneManager.RootNode.AddObject(new GroupNode("Reference meshs")
            {
                IsEditable = false, IsLockable = false
            });
        }
        public AnimationFragmentViewModel(PackFileService pf, bool isEditable = true)
        {
            SaveEnabled.Value = isEditable;
            _pf = pf;
            var possibleEnumValues = new ObservableCollection <string>();

            foreach (var slot in AnimationSlotTypeHelper.Values)
            {
                possibleEnumValues.Add(slot.Value);
            }

            Factory.CreateColoumn("Slot", CellFactory.ColoumTypes.ComboBox, (x) => new TypedComboBoxCellItem <string>(x as string, possibleEnumValues)
            {
                IsEditable = isEditable
            });
            Factory.CreateColoumn("FileName", CellFactory.ColoumTypes.Default, (x) => new ValueCellItem <object>(x)
            {
                IsEditable = isEditable
            });
            Factory.CreateColoumn("MetaFile", CellFactory.ColoumTypes.Default, (x) => new ValueCellItem <object>(x)
            {
                IsEditable = isEditable
            });
            Factory.CreateColoumn("SoundMeta", CellFactory.ColoumTypes.Default, (x) => new ValueCellItem <object>(x)
            {
                IsEditable = isEditable
            });
            Factory.CreateColoumn("Unknown0", CellFactory.ColoumTypes.BitFlag, (x) => new BitflagCellItem((int)x, 6)
            {
                IsEditable = isEditable
            });
            Factory.CreateColoumn("Weapon", CellFactory.ColoumTypes.BitFlag, (x) => new BitflagCellItem((int)x, 6)
            {
                IsEditable = isEditable
            });
            Factory.CreateColoumn("Unknown1", CellFactory.ColoumTypes.Default, (x) => new ValueCellItem <object>(x)
            {
                IsEditable = isEditable
            });
            Factory.CreateColoumn("Unknown2", CellFactory.ColoumTypes.Bool, (x) => new BoolCellItem((bool)x)
            {
                IsEditable = isEditable
            });
        }