Exemple #1
0
        public ManageVmmDependenciesViewModel(VmmItem vmm)
        {
            Vmm          = vmm;
            Dependencies = Vmm.Dependencies.ToList();

            ListInstalledMods();
        }
Exemple #2
0
        public void ExtractPersonPose(ZipArchive zip, VmmItem vmm)
        {
            string poseRoot    = ConfigurationService.PersonPoseFolder;
            string poseModPath = Path.Combine(poseRoot, vmm.ModPath);

            var jsonFile     = zip.Entries.Single(e => e.Name.Contains(".json"));
            var textureFiles = zip.Entries.Where(e => e.Name.Contains(".jpg") || e.Name.Contains(".png"));
            var textFiles    = zip.Entries.Where(e => e.Name.Contains(".txt"));

            if (!Directory.Exists(poseModPath))
            {
                Directory.CreateDirectory(poseModPath);
            }

            jsonFile.ExtractToFile(Path.Combine(poseModPath, jsonFile.Name));

            foreach (var texture in textureFiles)
            {
                texture.ExtractToFile(Path.Combine(poseModPath, texture.Name));
            }

            foreach (var textFile in textFiles)
            {
                textFile.ExtractToFile(Path.Combine(poseModPath, textFile.Name));
            }

            vmm.InstallLog.Add(poseModPath);

            ExtractMorphs(zip, vmm);
        }
Exemple #3
0
        private void FinalizeJson(string jsonPath, ZipArchive zip, VmmItem vmm)
        {
            string json = string.Empty;

            using (var reader = new StreamReader(jsonPath))
            {
                json = reader.ReadToEnd();
            }

            json = json.Replace(@"\dev\", $"\\{vmm.ModVersion.ToString("0.0#")}\\");

            string tempPath = Path.Combine(ConfigurationService.FinalizationFolder, Path.GetFileName(jsonPath));

            using (var writer = new StreamWriter(tempPath, false))
            {
                writer.Write(json);
                writer.Flush();
            }

            string tempFile = jsonPath.Replace($"{ConfigurationService.Instance.VamLocation + @"\"}", string.Empty);

            tempFile = tempFile.Replace(@"\dev\", $"{@"\" + vmm.ModVersion.ToString("0.0#") + @"\"}");

            zip.CreateEntryFromFile(tempPath, tempFile, CompressionLevel.Fastest);
        }
Exemple #4
0
        public List <VmmItem> ListInstalledMods()
        {
            var vmmList = new List <VmmItem>();

            if (ConfigurationService.HasConfiguration)
            {
                var files = Directory.GetFiles(
                    ConfigurationService.Instance.VamLocation
                    , "*.vmm"
                    , SearchOption.AllDirectories
                    );

                foreach (var path in files)
                {
                    var vmm = new VmmItem();
                    using (var file = File.OpenText(path))
                    {
                        var json = file.ReadToEnd();
                        vmm = JsonConvert.DeserializeObject <VmmItem>(json);
                        vmmList.Add(vmm);
                    }
                }
            }

            return(vmmList.OrderBy(m => m.DisplayName).ToList());
        }
Exemple #5
0
 public NewModViewModel()
 {
     Vmm = new VmmItem
     {
         Author     = ConfigurationService.Instance.Author,
         ModVersion = 0.1f
     };
 }
Exemple #6
0
        private void FinalizeVmm(ZipArchive zip, VmmItem vmm)
        {
            new ModService().SaveVmmFile(vmm, true);
            string vmmPath = Path.Combine(ConfigurationService.FinalizationFolder, vmm.ModPathAndFilename);
            string zipPath = ConfigurationService.VamModManagerFolder.Replace($"{ConfigurationService.Instance.VamLocation + @"\"}", string.Empty);

            zipPath = Path.Combine(zipPath, vmm.ModPathAndFilename);
            zip.CreateEntryFromFile(vmmPath, zipPath, CompressionLevel.Fastest);
        }
Exemple #7
0
        public FinalizeModViewModel(VmmItem vmm)
        {
            Vmm = vmm;

            //list excluded mod folder in service, takes vmm.  check each dir for empty and set bool
            ExcludedModFolders = new ManagedModService().ListEmptyModFolders(vmm)
                                 .Where(f => f.DisplayName != "VaM Mod Manager")
                                 .ToList();
        }
Exemple #8
0
        public IList <VmmItem> ListAvailableMods()
        {
            var mods = new List <VmmItem>();

            if (ConfigurationService.HasConfiguration)
            {
                var modLocation = ConfigurationService.Instance.ModLocation;
                if (Directory.Exists(modLocation))
                {
                    //NEED TO FILTER FILE TYPES
                    var files = Directory.GetFiles(modLocation);

                    foreach (var path in files)
                    {
                        if (File.Exists(path))
                        {
                            using (var zip = ZipFile.Open(path, ZipArchiveMode.Read))
                            {
                                var     vmmFile = zip.Entries.SingleOrDefault(f => f.FullName.Contains(".vmm"));
                                VmmItem vmm     = null;
                                if (vmmFile != null)
                                {
                                    using (var stream = vmmFile.Open())
                                    {
                                        using (var reader = new StreamReader(stream))
                                        {
                                            var json = reader.ReadToEnd();
                                            vmm = JsonConvert.DeserializeObject <VmmItem>(json);
                                            //vmm.VacName = Path.GetFileName(path);
                                        }
                                    }
                                }
                                else if (vmm == null)
                                {
                                    vmm = new VmmItem
                                    {
                                        Author  = "UNSUPPORTED MOD",
                                        ModType = ModTypeEnum.Unsupported,
                                        //VacName = Path.GetFileName(path)
                                    };
                                }

                                mods.Add(vmm);
                            }
                        }
                    }
                }
            }

            var installed = ListInstalledMods();

            mods = mods.Where(m => !installed.Any(i => i.ModType != ModTypeEnum.InDevelopment && i.VmmFilename == m.VmmFilename)).ToList();
            return(mods.OrderBy(m => m.DisplayName).ToList());
        }
Exemple #9
0
        public List <ModFolderItem> ListEmptyModFolders(VmmItem vmm)
        {
            var paths = ListModFolders(vmm);

            for (int i = 0; i < paths.Count; i++)
            {
                bool hasContent = Directory.GetFiles(paths[i].FolderPath).Any() || Directory.GetDirectories(paths[i].FolderPath).Any();
                paths[i].IsExcludedFromFinalization = !hasContent;
            }

            return(paths);
        }
Exemple #10
0
        public List <ModFolderItem> ListModFolders(VmmItem vmm, bool isFinalization = false)
        {
            var paths = ListBaseVamFolders();

            for (int i = 0; i < paths.Count; i++)
            {
                paths[i].FolderPath = Path.Combine(paths[i].FolderPath, vmm.ModPath);

                if (isFinalization)
                {
                    paths[i].FolderPath = paths[i].FolderPath.Replace(ConfigurationService.Instance.VamLocation,
                                                                      ConfigurationService.FinalizationFolder);
                }
            }

            return(paths);
        }
Exemple #11
0
        public void ExtractAudio(ZipArchive zip, VmmItem vmm)
        {
            var sounds = zip.Entries.Where(e => e.Name.Contains(".wav") || e.Name.Contains(".mp3") || e.Name.Contains(".ogg"));

            string dir;

            if (sounds.Count() > 0)
            {
                dir = Path.Combine(ConfigurationService.SceneFolder, vmm.ModPath);
                dir = Path.Combine(dir, "audio");

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                if (!vmm.MaintainOriginalDirectoryStructure)
                {
                    foreach (var sound in sounds)
                    {
                        sound.ExtractToFile(Path.Combine(dir, sound.Name));
                    }
                }
                else
                {
                    string targetPath        = string.Empty;
                    string targetPathAndFile = string.Empty;
                    foreach (var sound in sounds)
                    {
                        targetPathAndFile = Path.Combine(dir, sound.FullName);
                        targetPath        = targetPathAndFile.Replace(sound.Name, string.Empty);

                        if (!Directory.Exists(targetPath))
                        {
                            Directory.CreateDirectory(targetPath);
                        }

                        sound.ExtractToFile(targetPathAndFile);
                    }
                }

                vmm.InstallLog.Add(dir);
            }
        }
Exemple #12
0
        public void ExtractTextures(ZipArchive zip, VmmItem vmm)
        {
            //png jpg
            var textures = zip.Entries.Where(e => e.Name.Contains(".jpg") || e.Name.Contains(".png"));

            string dir;

            if (textures.Count() > 0)
            {
                dir = Path.Combine(ConfigurationService.TexturesFolder, vmm.ModPath);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                if (!vmm.MaintainOriginalDirectoryStructure)
                {
                    foreach (var texture in textures)
                    {
                        texture.ExtractToFile(Path.Combine(dir, texture.Name));
                    }
                }
                else
                {
                    string targetPath        = string.Empty;
                    string targetPathAndFile = string.Empty;
                    foreach (var texture in textures)
                    {
                        targetPathAndFile = Path.Combine(dir, texture.FullName);
                        targetPath        = targetPathAndFile.Replace(texture.Name, string.Empty);

                        if (!Directory.Exists(targetPath))
                        {
                            Directory.CreateDirectory(targetPath);
                        }

                        texture.ExtractToFile(targetPathAndFile);
                    }
                }

                vmm.InstallLog.Add(dir);
            }
        }
Exemple #13
0
        public void SaveVmmFile(VmmItem vmm, bool isFinalize = false)
        {
            string path = ModTypeToVamPath(vmm.ModType);

            path = Path.Combine(path, vmm.ModPath);

            if (isFinalize)
            {
                path = Path.Combine(ConfigurationService.FinalizationFolder, vmm.ModPath);
            }

            Directory.CreateDirectory(path);

            using (var file = File.CreateText(Path.Combine(path, vmm.VmmFilename)))
            {
                var json = JsonConvert.SerializeObject(vmm);
                file.Write(json);
            }
        }
Exemple #14
0
        public void CreateMod(VmmItem vmm)
        {
            vmm.ModType = ModTypeEnum.InDevelopment;

            var paths = ListModFolders(vmm);

            CreateModFolders(paths);

            //save the inital vmm file to the Vam Mod Manager Folder
            new ModService().SaveVmmFile(vmm);

            //copy the default scene to use as a starting point
            var defaultScenePath = Path.Combine(ConfigurationService.SceneFolderMeshedVR, @"default.json");
            var modScenePath     = Path.Combine(ConfigurationService.SceneFolder, vmm.ModPath);

            modScenePath = Path.Combine(modScenePath, $"{vmm.ModName}.json");

            File.Copy(defaultScenePath, modScenePath);
        }
Exemple #15
0
        public void ExtractScripts(ZipArchive zip, VmmItem vmm)
        {
            var scripts = zip.Entries.Where(e => e.Name.Contains(".cs") || e.Name.Contains(".cslist"));

            string dir;

            if (scripts.Count() > 0)
            {
                dir = Path.Combine(ConfigurationService.ScriptsFolder, vmm.ModPath);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                if (!vmm.MaintainOriginalDirectoryStructure)
                {
                    foreach (var script in scripts)
                    {
                        script.ExtractToFile(Path.Combine(dir, script.Name));
                    }
                }
                else
                {
                    string targetPath        = string.Empty;
                    string targetPathAndFile = string.Empty;
                    foreach (var script in scripts)
                    {
                        targetPathAndFile = Path.Combine(dir, script.FullName);
                        targetPath        = targetPathAndFile.Replace(script.Name, string.Empty);

                        if (!Directory.Exists(targetPath))
                        {
                            Directory.CreateDirectory(targetPath);
                        }

                        script.ExtractToFile(targetPathAndFile);
                    }
                }

                vmm.InstallLog.Add(dir);
            }
        }
Exemple #16
0
        public void ExtractMorphs(ZipArchive zip, VmmItem vmm)
        {
            var femaleMorphs          = zip.Entries.Where(e => (e.Name.Contains(".dsf") || e.Name.Contains(".vmi") || e.Name.Contains(".vmb")) && (e.FullName.Contains(@"female\") || e.FullName.Contains(@"female/")));
            var femaleGenitaliaMorphs = zip.Entries.Where(e => (e.Name.Contains(".dsf") || e.Name.Contains(".vmi") || e.Name.Contains(".vmb")) && (e.FullName.Contains(@"female_genitalia\") || e.FullName.Contains(@"female_genitalia/")));

            string dir;

            if (femaleMorphs.Count() > 0)
            {
                dir = Path.Combine(ConfigurationService.MorphsFemaleFolder, vmm.ModPath);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                foreach (var morph in femaleMorphs)
                {
                    morph.ExtractToFile(Path.Combine(dir, morph.Name));
                }

                vmm.InstallLog.Add(dir);
            }

            if (femaleGenitaliaMorphs.Count() > 0)
            {
                dir = Path.Combine(ConfigurationService.MorphsFemaleGenitaliaFolder, vmm.ModPath);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                foreach (var morph in femaleGenitaliaMorphs)
                {
                    morph.ExtractToFile(Path.Combine(dir, morph.Name));
                }

                vmm.InstallLog.Add(dir);
            }
        }
Exemple #17
0
        /// <summary>
        /// Uninstall a mod that was install with VaM Mod Manager
        /// </summary>
        /// <param name="path">Path to the .vmm file for the mod.</param>
        public void UninstallMod(string path)
        {
            if (File.Exists(path))
            {
                var vmm = new VmmItem();
                using (var file = File.OpenText(path))
                {
                    var json = file.ReadToEnd();
                    vmm = JsonConvert.DeserializeObject <VmmItem>(json);
                }

                foreach (var item in vmm.InstallLog)
                {
                    Directory.Delete(item, true);

                    var parent = Directory.GetParent(item);
                    if (parent.GetFiles().Count() == 0 && parent.GetDirectories().Count() == 0)
                    {
                        Directory.Delete(parent.FullName);
                    }
                }
            }
        }
Exemple #18
0
 public AddVmmViewModel()
 {
     Vmm = new VmmItem();
 }
Exemple #19
0
 public EditVmmViewModel(VmmItem vmm)
 {
     Vmm = vmm;
 }
Exemple #20
0
        public void FinalizeMod(VmmItem vmm, List <ModFolderItem> excludedModFolders)
        {
            if (vmm.ModType == ModTypeEnum.InDevelopment)
            {
                throw new Exception("You can not finalize a mod when the type is set to In Development.");
            }

            //create vac file
            string finalVacPath            = ConfigurationService.Instance.ModLocation;
            string finalVacPathAndFilename = Path.Combine(finalVacPath, vmm.VacFilename);

            //create empty temp directory to target zipfile at
            var finalizePath = ConfigurationService.FinalizationFolder;

            Directory.CreateDirectory(finalizePath);

            if (!File.Exists(finalVacPathAndFilename))
            {
                ZipFile.CreateFromDirectory(finalizePath, finalVacPathAndFilename);
            }

            using (var zip = ZipFile.Open(finalVacPathAndFilename, ZipArchiveMode.Update))
            {
                //NOTE: This is a bit of a hack.  Since the path is pulled from the Vmm item itself, we need to trick it into thinking it is still in development
                //so we can grab all the files from the dev folders...
                //Should find a better solution later.
                var cacheType = vmm.ModType;
                vmm.ModType = ModTypeEnum.InDevelopment;

                //look in mod dev folders then set the type back
                var paths = ListModFolders(vmm, false);

                vmm.ModType = cacheType;

                //if not empty copy path and contents to vac
                foreach (var p in paths)
                {
                    //if author choose to exclude this folder, skip it and continue
                    string absPath = Path.GetFullPath(p.FolderPath);
                    if (excludedModFolders.Any(f => absPath.Contains(f.FolderPath)))
                    {
                        continue;
                    }

                    if (Directory.Exists(p.FolderPath))
                    {
                        var files = Directory.GetFiles(p.FolderPath, "*", SearchOption.AllDirectories);

                        if (files.Length > 0)
                        {
                            foreach (var file in files)
                            {
                                if (file.Contains(".json"))
                                {
                                    FinalizeJson(file, zip, vmm);
                                    continue;
                                }

                                if (file.Contains(".vmm"))
                                {
                                    FinalizeVmm(zip, vmm);
                                    continue;
                                }

                                string newFile = file.Replace($"{ConfigurationService.Instance.VamLocation + @"\"}", string.Empty);
                                newFile = newFile.Replace(@"\dev\", $"{@"\" + vmm.ModVersion.ToString("0.0#") + @"\"}");

                                zip.CreateEntryFromFile(file, newFile, CompressionLevel.Fastest);
                            }
                        }
                    }
                }
            }

            Directory.Delete(finalizePath, true);

            //finally, increment the version number for dev.
            vmm.ModType     = ModTypeEnum.InDevelopment;
            vmm.ModVersion += 0.1f;
            new ModService().SaveVmmFile(vmm);
        }
Exemple #21
0
        public void DeleteMod(VmmItem vmm)
        {
            var paths = ListModFolders(vmm);

            DeleteModFolders(paths);
        }
Exemple #22
0
 public void ExtractPersonAppearanceAndPose(ZipArchive zip, VmmItem vmm)
 {
     //Looks like this might get phased out.  Maybe only used by the game?
 }
Exemple #23
0
        public void InstallVac(string path)
        {
            if (File.Exists(path))
            {
                using (var zip = ZipFile.Open(path, ZipArchiveMode.Read))
                {
                    var     vmmFile = zip.Entries.SingleOrDefault(f => f.FullName.Contains(".vmm"));
                    VmmItem vmm     = null;
                    if (vmmFile != null)
                    {
                        using (var stream = vmmFile.Open())
                        {
                            using (var reader = new StreamReader(stream))
                            {
                                var json = reader.ReadToEnd();
                                vmm = JsonConvert.DeserializeObject <VmmItem>(json);
                            }
                        }
                    }

                    if (vmm == null)
                    {
                        vmm = new VmmItem
                        {
                            ModType = ModTypeEnum.Unsupported,
                            //VacName = Path.GetFileNameWithoutExtension(path)
                        };
                    }

                    //There should only be one json file for a mod
                    var jsonFile = zip.Entries.SingleOrDefault(f => f.FullName.Contains(".json"));

                    if (vmm.ModType == ModTypeEnum.Unsupported && jsonFile != null)
                    {
                        using (var stream = jsonFile.Open())
                        {
                            using (var reader = new StreamReader(stream))
                            {
                                var json = reader.ReadToEnd();
                                vmm.ModType = GetModType(json);
                            }
                        }
                    }

                    switch (vmm.ModType)
                    {
                    case ModTypeEnum.Scene:
                        ExtractScene(zip, vmm);
                        ExtractAudio(zip, vmm);
                        ExtractMorphs(zip, vmm);
                        ExtractScripts(zip, vmm);
                        break;

                    case ModTypeEnum.Look:
                        ExtractPersonAppearance(zip, vmm);
                        break;

                    case ModTypeEnum.Pose:
                        ExtractPersonPose(zip, vmm);
                        break;

                    case ModTypeEnum.Plugin:
                        ExtractScripts(zip, vmm);
                        ExtractMorphs(zip, vmm);
                        break;

                    case ModTypeEnum.Texture:
                        ExtractTextures(zip, vmm);
                        break;
                        //case ModTypeEnum.Wardrobe:
                        //    ExtractWardrobe(zip, vmm);
                        //    break;
                    }

                    SaveVmmFile(vmm);
                }
            }
        }