예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        internal static void SetSaveDirs(Model.Model model)
        {
            foreach (var gd in model.GameData)
            {
                if (gd.Value.SaveDir.StartsWith("??") || gd.Value.SaveDir.Contains("."))
                {
                    gd.Value.SaveDir = Tools.HashGenerator.GetHash(gd.Value.LaunchFile).ToString("x8");
                }

                gd.Value.GameSetting.PreviousOfficialEmulationState = gd.Value.GameSetting.OfficialEmulationState;

                if (gd.Value.ShaderCacheFileSize == -1)
                {
                    var      version = CemuFeatures.GetLatestVersion(model);
                    FileInfo info    = new FileInfo(Path.Combine(SpecialFolders.ShaderCacheFolderCemu(version), gd.Value.SaveDir + ".bin"));
                    if (File.Exists(info.FullName))
                    {
                        gd.Value.ShaderCacheFileSize = (int)info.Length;
                    }
                    else
                    {
                        gd.Value.ShaderCacheFileSize = 999;
                    }
                }
            }
        }
예제 #2
0
        private void CopySaves()
        {
            // Copy saves
            DirectoryInfo src     = new DirectoryInfo(SpecialFolders.CurrentUserSaveDirCemu(runningVersion, runningGame));
            DirectoryInfo dest    = new DirectoryInfo(SpecialFolders.CurrentUserSaveDirBudford(Model, Model.CurrentUser, runningGame, ""));
            DirectoryInfo src255  = new DirectoryInfo(SpecialFolders.CommonUserFolderCemu(runningVersion, runningGame));
            DirectoryInfo dest255 = new DirectoryInfo(SpecialFolders.CommonSaveDirBudford(Model, runningGame, ""));

            if (Directory.Exists(src.FullName))
            {
                if (File.Exists(Path.Combine(src.FullName, "Budford.lck")))
                {
                    // Delete the lock file, to allow Budford to overwrite the Cemu save in future.
                    File.Delete(Path.Combine(src.FullName, "Budford.lck"));
                }

                if (src.GetDirectories().Any() || src.GetFiles().Any() || (Directory.Exists(src255.FullName) && (src255.GetFiles().Any() || src255.GetDirectories().Any())))
                {
                    if (!Directory.Exists(dest.FullName))
                    {
                        dest.Create();
                    }
                    if (!Directory.Exists(dest255.FullName))
                    {
                        dest255.Create();
                    }

                    FileManager.CopyFilesRecursively(src, dest, false, true);
                    FileManager.CopyFilesRecursively(src255, dest255, false, true);
                }
            }
        }
예제 #3
0
        private static void CopyFolderToBudford(Model.Model model, string[] data, int minVersion)
        {
            string sourceFolder = Path.Combine(SpecialFolders.BudfordDir(model), data[1]);

            if (Directory.Exists(sourceFolder))
            {
                foreach (var v in model.Settings.InstalledVersions)
                {
                    if (v.VersionNumber >= minVersion)
                    {
                        string destinationFolder = Path.Combine(v.Folder, data[2]);
                        if (!Directory.Exists(destinationFolder))
                        {
                            Directory.CreateDirectory(destinationFolder);
                        }

                        foreach (var file in Directory.EnumerateFiles(sourceFolder))
                        {
                            string destinationFile = Path.Combine(destinationFolder, Path.GetFileName(file));
                            if (!File.Exists(destinationFile))
                            {
                                File.Copy(file, destinationFile);
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 /// <param name="version"></param>
 private static void DeleteShaderCacheIfRequired(Model.Model model, InstalledVersion version)
 {
     if (model.Settings.DisableShaderCache)
     {
         DirectoryInfo di1 = new DirectoryInfo(Path.Combine(SpecialFolders.ShaderCacheFolderCemu(version), "transferable"));
         foreach (FileInfo file in di1.GetFiles())
         {
             file.Delete();
         }
         DirectoryInfo di2 = new DirectoryInfo(Path.Combine(SpecialFolders.ShaderCacheFolderCemu(version), "shaderCache", "precompiled"));
         foreach (FileInfo file in di2.GetFiles())
         {
             file.Delete();
         }
     }
 }
예제 #5
0
        private static void SetupCafeLibs(Model.Model model, GameInformation game)
        {
            string cafeLibs = Path.Combine(runningVersion.Folder, "cafeLibs");

            if (!Directory.Exists(cafeLibs))
            {
                Directory.CreateDirectory(cafeLibs);
            }
            FileManager.ClearFolder(cafeLibs);

            if (game != null)
            {
                if (game.GameSetting.UseCafeLibs == 1)
                {
                    File.Copy(Path.Combine(SpecialFolders.CafeLibDirBudford(model), "snd_user.rpl"), Path.Combine(cafeLibs, "snd_user.rpl"));
                    File.Copy(Path.Combine(SpecialFolders.CafeLibDirBudford(model), "snduser2.rpl"), Path.Combine(cafeLibs, "snduser2.rpl"));
                }
            }
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="game"></param>
        internal void CreateSaveSnapshot(Model.Model model, GameInformation game)
        {
            if (!game.SaveDir.StartsWith("??"))
            {
                if (runningVersion == null)
                {
                    SetCemuVersion(model, game);
                }
                DirectoryInfo saveDir     = new DirectoryInfo(SpecialFolders.CurrentUserSaveDirBudford(model, "", game, ""));
                string        snapShotDir = "S_" + saveDir.EnumerateDirectories().Count();

                DirectoryInfo src  = new DirectoryInfo(SpecialFolders.CurrentUserSaveDirCemu(runningVersion, game));
                DirectoryInfo dest = new DirectoryInfo(SpecialFolders.CurrentUserSaveDirBudford(model, model.CurrentUser, game, snapShotDir));
                UpdateFolder(src, dest);

                src  = new DirectoryInfo(SpecialFolders.CommonUserFolderCemu(runningVersion, game));
                dest = new DirectoryInfo(SpecialFolders.CommonSaveDirBudford(model, game, snapShotDir));

                UpdateFolder(src, dest);
            }
        }
예제 #7
0
        private static void CopySingleFileToCemu(Model.Model model, string[] data)
        {
            string destinationFile   = Path.Combine(SpecialFolders.BudfordDir(model), data[1], data[0]);
            string destinationFolder = Path.Combine(SpecialFolders.BudfordDir(model), data[1]);

            if (!Directory.Exists(destinationFolder))
            {
                Directory.CreateDirectory(destinationFolder);
            }
            if (!File.Exists(destinationFile))
            {
                foreach (var v in model.Settings.InstalledVersions)
                {
                    string sourceFile = Path.Combine(v.Folder, data[2], data[0]);
                    if (File.Exists(sourceFile))
                    {
                        File.Copy(sourceFile, destinationFile);
                        break;
                    }
                }
            }
        }
예제 #8
0
        private void CopyShaderCaches()
        {
            // Copy shader caches...
            FileInfo srcFile = new FileInfo(SpecialFolders.ShaderCacheCemu(runningVersion, runningGame));

            if (File.Exists(srcFile.FullName))
            {
                FileInfo destFile = new FileInfo(SpecialFolders.ShaderCacheBudford(Model, runningGame));
                if (!File.Exists(destFile.FullName) || destFile.Length < srcFile.Length)
                {
                    string folder = Path.GetDirectoryName(destFile.FullName);
                    if (!Directory.Exists(folder))
                    {
                        if (folder != null)
                        {
                            Directory.CreateDirectory(folder);
                        }
                    }
                    File.Copy(srcFile.FullName, destFile.FullName, true);
                }
            }
        }
예제 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="game"></param>
        internal void CopyLargestShaderCacheToCemu(GameInformation game)
        {
            if (runningVersion == null)
            {
                SetCemuVersion(Model, game);
            }

            if (runningVersion != null && runningVersion.VersionNumber >= 170)
            {
                if (!game.SaveDir.StartsWith("??"))
                {
                    FileInfo src = new FileInfo(SpecialFolders.ShaderCacheBudford(Model, game));
                    if (File.Exists(src.FullName))
                    {
                        FileInfo dest = new FileInfo(SpecialFolders.ShaderCacheCemu(runningVersion, game));
                        if (!File.Exists(dest.FullName) || dest.Length < src.Length)
                        {
                            File.Copy(src.FullName, dest.FullName, true);
                        }
                    }
                }
            }
        }
예제 #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="game"></param>
        private void CopyLatestSaveToCemu(GameInformation game)
        {
            if (!game.SaveDir.StartsWith("??"))
            {
                DirectoryInfo src  = new DirectoryInfo(SpecialFolders.CurrentUserSaveDirBudford(Model, Model.CurrentUser, game, ""));
                DirectoryInfo dest = new DirectoryInfo(SpecialFolders.CurrentUserSaveDirCemu(runningVersion, game));

                string lockFileName = Path.Combine(dest.FullName, "Budford.lck");
                if (File.Exists(lockFileName))
                {
                    // This save has been locked, which means budford launched the game, but wasn't running with it exitted.
                    // In this case we won't overwrite the save as it is sure to be newer
                    return;
                }

                UpdateFolder(src, dest, true);

                src  = new DirectoryInfo(SpecialFolders.CommonSaveDirBudford(Model, game, ""));
                dest = new DirectoryInfo(SpecialFolders.CommonUserFolderCemu(runningVersion, game));
                UpdateFolder(src, dest);

                CreateLockFile(lockFileName);
            }
        }