コード例 #1
0
ファイル: CemuSettings.cs プロジェクト: SteveLever73/Budford
        /// <summary>
        ///
        /// </summary>
        void WriteGraphicsPacks(InstalledVersion version)
        {
            EnsureGraphicPackExists();
            EnableDefaultGraphicsPack();
            DeleteBudfordPacks(version);

            SetClarityPreset();
            SetFps();

            int packs = CopyBudfordPacks(version);

            if (packs > 0)
            {
                int gfxPackStartOffset = SetNumberOfPacks(version, packs);

                packIndex = 0;
                foreach (var pack in settings.graphicsPacks)
                {
                    AppendGraphicsPack(version.Folder, gfxPackStartOffset, pack);
                }

                if (resolutionPack != null)
                {
                    AppendGraphicsPack(version.Folder, gfxPackStartOffset, resolutionPack);
                }

                PadWithZero(version, packs, gfxPackStartOffset);
            }
        }
コード例 #2
0
 private static void RepairFonts(Unpacker unpacker, InstalledVersion v)
 {
     if (!v.HasFonts)
     {
         unpacker.Unpack("sharedFonts.zip", v.Folder);
     }
 }
コード例 #3
0
 internal static bool DownloadLatestVersion(Form parent, Settings settings)
 {
     using (FormWebpageDownload dlc = new FormWebpageDownload(CemuUrl, "Latest Version"))
     {
         dlc.ShowDialog(parent);
         foreach (var line in dlc.Result.Split('\n'))
         {
             if (line.Contains("name=\"download\""))
             {
                 string[] toks           = line.Split('=');
                 string   ver            = toks[1].Substring(1, toks[1].LastIndexOf('\"') - 1);
                 int      currentVersion = InstalledVersion.GetVersionNumber(Path.GetFileName(ver));
                 if (!IsInstalled(currentVersion, settings))
                 {
                     return(true);
                 }
                 else
                 {
                     MessageBox.Show(Resources.CemuFeatures_DownloadLatestVersion_The_latest_version_of_Cemu_is_already_installed_, Resources.CemuFeatures_DownloadLatestVersion_Information___);
                     return(false);
                 }
             }
         }
     }
     return(false);
 }
コード例 #4
0
 private static void RepairControllers(Model.Model model, InstalledVersion v)
 {
     if (!v.HasControllerProfiles)
     {
         CopyLatestControllerProfiles(model, v);
     }
 }
コード例 #5
0
        public void CheckForUpdates()
        {
            var installedVersionResult = ScriptBlock.Create("Get-Module JournalCli -ListAvailable | select version").Invoke();

            InstalledVersion = (Version)installedVersionResult[0].Properties["Version"].Value;

            var sb     = ScriptBlock.Create("Find-Module JournalCli | select version");
            var ps     = sb.GetPowerShell();
            var result = ps.BeginInvoke();

            if (!result.AsyncWaitHandle.WaitOne(12000))
            {
                throw new TimeoutException("Unable to retrieve module update information within 12 seconds.");
            }

            var availableVersionsResults = ps.EndInvoke(result).ReadAll();
            var availableVersions        = availableVersionsResults.Select(x => new Version((string)x.Properties["Version"].Value)).ToList();

            NewVersion = availableVersions.FirstOrDefault(x => x.IsBeta() == InstalledVersion.IsBeta());

            if (NewVersion == null)
            {
                throw new InvalidOperationException("Unable to locate an appropriate new version of the module. Missing registered repository?");
            }
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="maxVersion"></param>
        /// <returns></returns>
        internal static InstalledVersion GetLatestVersion(Model.Model model, int maxVersion = int.MaxValue)
        {
            InstalledVersion latest = null;
            int latestVersion       = 0;

            foreach (var v in model.Settings.InstalledVersions)
            {
                int version = v.VersionNumber;

                if (v.VersionNumber >= latestVersion)
                {
                    if (v.VersionNumber < maxVersion)
                    {
                        if (version == latestVersion)
                        {
                            if (v.IsLatest)
                            {
                                latest        = v;
                                latestVersion = v.VersionNumber;
                            }
                        }
                        else
                        {
                            latest        = v;
                            latestVersion = version;
                        }
                    }
                }
            }
            return(latest);
        }
コード例 #7
0
        /// <summary>
        /// Applies the open data migrations.
        /// </summary>
        public override void ApplyMigrations()
        {
            // initialize the storage of installed versions
            InitInstalledVersions();

            // find the latest version installed on the database
            List <InstalledVersion> installedVersions = GetInstalledVersionsSorted();

            long versionNumberOnDatabase = 0;

            if (installedVersions.Any())
            {
                versionNumberOnDatabase = installedVersions.Last().VersionNumber;
            }

            // apply the open migrations
            for (long versionNumber = versionNumberOnDatabase + 1; versionNumber <= CurrentVersionNumber; versionNumber++)
            {
                using (T unitOfWork = m_unitOfWorkFactory.CreateUnitOfWork())
                {
                    try
                    {
                        unitOfWork.BeginTransaction();

                        Stopwatch stopwatch = Stopwatch.StartNew();

                        ApplyMigration(unitOfWork, versionNumber, out string description, out string checksum);

                        stopwatch.Stop();

                        InstalledVersion installedVersion = new InstalledVersion()
                        {
                            VersionNumber = versionNumber,
                            Description   = description,
                            Installed     = DateTimeOffset.UtcNow,
                            ExecutionTime = stopwatch.ElapsedMilliseconds,
                            Checksum      = checksum
                        };

                        m_databaseHelper.SaveInstalledVersion(unitOfWork, installedVersion);

                        unitOfWork.Commit();
                    }
                    catch (Exception exc)
                    {
                        unitOfWork?.Rollback();

                        if (exc is MigrationFailedException)
                        {
                            throw;
                        }
                        else
                        {
                            throw new MigrationFailedException("Migration to version number " + versionNumber + " failed. See inner exception for details.", exc);
                        }
                    }
                }
            }
        }
コード例 #8
0
 private static void CopyPatchFiles(InstalledVersion onlineSource, InstalledVersion onlineDestination)
 {
     Directory.CreateDirectory(Path.Combine(onlineSource.Folder, "mlc01", "sys", "title", "0005001b", "10056000", "content"));
     File.Copy(Path.Combine(onlineSource.Folder, "mlc01", "sys", "title", "0005001b", "10056000", "content", "FFLResHigh.dat"), Path.Combine(onlineDestination.Folder, "mlc01", "sys", "title", "0005001b", "10056000", "content", "FFLResHigh.dat"), true);
     File.Copy(Path.Combine(onlineSource.Folder, "mlc01", "sys", "title", "0005001b", "10056000", "content", "FFLResHighLG.dat"), Path.Combine(onlineDestination.Folder, "mlc01", "sys", "title", "0005001b", "10056000", "content", "FFLResHighLG.dat"), true);
     File.Copy(Path.Combine(onlineSource.Folder, "mlc01", "sys", "title", "0005001b", "10056000", "content", "FFLResMiddle.dat"), Path.Combine(onlineDestination.Folder, "mlc01", "sys", "title", "0005001b", "10056000", "content", "FFLResMiddle.dat"), true);
     File.Copy(Path.Combine(onlineSource.Folder, "mlc01", "sys", "title", "0005001b", "10056000", "content", "FFLResMiddleLG.dat"), Path.Combine(onlineDestination.Folder, "mlc01", "sys", "title", "0005001b", "10056000", "content", "FFLResMiddleLG.dat"), true);
 }
コード例 #9
0
            public void ToString_ContainsApplicationPath()
            {
                var appPath = @"x:\app\path";

                var text = new InstalledVersion(appPath, VsVersion.Vs2010, "Community").ToString();

                Assert.That(text, Does.Contain(appPath));
            }
コード例 #10
0
            public void ToString_ContainsVsVersion()
            {
                var vsVersion = VsVersion.Vs2017;

                var text = new InstalledVersion(@"x:\app\path", vsVersion, "Community").ToString();

                Assert.That(text, Does.Contain(vsVersion.ToString()));
            }
コード例 #11
0
            public void ToString_ContainsProduct()
            {
                var product = "Enterprise";

                var text = new InstalledVersion(@"x:\app\path", VsVersion.Vs2010, product).ToString();

                Assert.That(text, Does.Contain(product));
            }
コード例 #12
0
                public void FilterProduct(string applicationPath, string product, string filterProduct, bool expect)
                {
                    var installedVersion = new InstalledVersion(applicationPath, VsVersion.Vs2010, product);
                    var commandLine      = new CommandLine(product: filterProduct);

                    var include = Program.Filter(installedVersion, commandLine);

                    Assert.That(include, Is.EqualTo(expect));
                }
コード例 #13
0
                public void FilterVsVersion(VsVersion vsVersion, VsVersion filterVsVersion, bool expect)
                {
                    var installedVersion = new InstalledVersion(null, vsVersion, "Community");
                    var commandLine      = new CommandLine(vsVersion: filterVsVersion);

                    var include = Program.Filter(installedVersion, commandLine);

                    Assert.That(include, Is.EqualTo(expect));
                }
コード例 #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="version"></param>
        /// <param name="game"></param>
        /// <returns></returns>
        internal static string CurrentUserSaveDirCemu(InstalledVersion version, GameInformation game)
        {
            string gameId = game.TitleId.Replace("00050000", "");

            if (version.VersionNumber >= 1110)
            {
                return(Path.Combine(version.Folder, "mlc01", "usr", "save", "00050000", gameId, "user", "80000001"));
            }
            return(Path.Combine(version.Folder, "mlc01", "emulatorSave", game.SaveDir));
        }
コード例 #15
0
ファイル: Launcher.cs プロジェクト: SteveLever73/Budford
        private static void SafeCopy(InstalledVersion version, string source, string destination)
        {
            string fileName = Path.Combine(version.Folder, "controllerProfiles", source);

            if (File.Exists(fileName))
            {
                string backUpFileName = Path.Combine(version.Folder, "controllerProfiles", destination);
                File.Copy(fileName, backUpFileName, true);
            }
        }
コード例 #16
0
ファイル: CemuSettings.cs プロジェクト: SteveLever73/Budford
 private static void PadWithZero(InstalledVersion version, int packs, int gfxPackStartOffset)
 {
     using (FileStream fn = new FileStream(Path.Combine(version.Folder, "settings.bin"), FileMode.Open, FileAccess.ReadWrite))
     {
         fn.Seek(gfxPackStartOffset + (9 * packs), SeekOrigin.Begin);
         for (int i = 0; i < 137; ++i)
         {
             fn.WriteByte(0);
         }
     }
 }
コード例 #17
0
        void DoTheCemuHook2()
        {
            InstalledVersion ver = model.Settings.InstalledVersions.FirstOrDefault(v => v.IsLatest);

            if (ver != null)
            {
                unpacker.Unpack(fileNames[4], ver.Folder);
                File.Copy(fileNames[4], "cemu_hook.zip", true);
                CemuFeatures.RepairInstalledVersions(this, model);
            }
        }
コード例 #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="version"></param>
 /// <returns></returns>
 internal static string ShaderCacheFolderCemu(InstalledVersion version)
 {
     if (version != null)
     {
         return(Path.Combine(version.Folder, "shaderCache", "transferable"));
     }
     else
     {
         return("");
     }
 }
コード例 #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="installedVersionsIn"></param>
        /// <param name="installedVersionIn"></param>
        public FormEditInstalledVersion(List <InstalledVersion> installedVersionsIn, InstalledVersion installedVersionIn)
        {
            InitializeComponent();

            installedVersions = installedVersionsIn;
            installedVersion  = installedVersionIn;

            originalName  = installedVersion.Name;
            textBox1.Text = originalName;
            textBox2.Text = installedVersion.Folder;
        }
コード例 #20
0
        public void GetInstalledVersions_CheckExtensionManagerWasCreated(InstalledVersion installedVersion)
        {
            using (var applicationContext = new ApplicationContext(installedVersion, true))
            {
                var remote = applicationContext.CreateInstance <Remote>();

                var exists = remote.WasCreated(installedVersion);

                Assert.That(exists, Is.True);
            }
        }
コード例 #21
0
        public void ExtensionManagerImplementationAssembly_HasExpectedVersion(InstalledVersion installedVersion)
        {
            using (var applicationContext = new ApplicationContext(installedVersion, true))
            {
                var remote = applicationContext.CreateInstance <Remote>();

                var version = remote.GetAssemblyVersion("Microsoft.VisualStudio.ExtensionManager.Implementation");

                var versionNumber = VsVersionUtil.GetVersionNumber(installedVersion.VsVersion);
                Assert.That(version.Major, Is.EqualTo(versionNumber));
            }
        }
コード例 #22
0
        private static void RepairOnlineFiles(Model.Model model, InstalledVersion v)
        {
            InstalledVersion onlineSource = GetLatestOnlineVersion(model);

            if (!v.HasOnlineFiles)
            {
                if (onlineSource != null)
                {
                    CopyOnlineFiles(onlineSource, v);
                }
            }
        }
コード例 #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InstalledVersion iv = new InstalledVersion();

            using (FormEditInstalledVersion eiv = new FormEditInstalledVersion(model.Settings.InstalledVersions, iv))
            {
                if (eiv.ShowDialog(this) == DialogResult.OK)
                {
                    model.Settings.InstalledVersions.Add(iv);
                    PopulateList();
                }
            }
        }
コード例 #24
0
        /// <summary>
        /// Saves the information about an installed data migration.
        /// </summary>
        /// <param name="unitOfWork">The unit of work to work with</param>
        /// <param name="installedVersion">The information of a version to save</param>
        public virtual void SaveInstalledVersion(SQLUnitOfWork unitOfWork, InstalledVersion installedVersion)
        {
            string insertScript = string.Format(
                "INSERT INTO {0} ({1}, {2}, {3}, {4}, {5}) VALUES (@VersionNumber, @Description, @Installed, @ExecutionTime, @Checksum)",
                m_installedVersionsTableName,
                ConvertToNameOnDatabase(nameof(InstalledVersion.VersionNumber)),
                ConvertToNameOnDatabase(nameof(InstalledVersion.Description)),
                ConvertToNameOnDatabase(nameof(InstalledVersion.Installed)),
                ConvertToNameOnDatabase(nameof(InstalledVersion.ExecutionTime)),
                ConvertToNameOnDatabase(nameof(InstalledVersion.Checksum))
                );

            using (IDbCommand command = unitOfWork.Connection.CreateCommand())
            {
                command.CommandText = insertScript;
                command.Transaction = unitOfWork.Transaction;

                IDbDataParameter parameter = command.CreateParameter();
                parameter.ParameterName = "VersionNumber";
                parameter.DbType        = DbType.Int64;
                parameter.Value         = installedVersion.VersionNumber;
                command.Parameters.Add(parameter);

                parameter = command.CreateParameter();
                parameter.ParameterName = "Description";
                parameter.DbType        = DbType.String;
                parameter.Value         = (object)TruncateStringToLength(installedVersion.Description, 1024) ?? DBNull.Value;
                command.Parameters.Add(parameter);

                parameter = command.CreateParameter();
                parameter.ParameterName = "Installed";
                parameter.DbType        = DbType.String;
                parameter.Value         = installedVersion.InstalledString;
                command.Parameters.Add(parameter);

                parameter = command.CreateParameter();
                parameter.ParameterName = "ExecutionTime";
                parameter.DbType        = DbType.Int64;
                parameter.Value         = installedVersion.ExecutionTime;
                command.Parameters.Add(parameter);

                parameter = command.CreateParameter();
                parameter.ParameterName = "Checksum";
                parameter.DbType        = DbType.String;
                parameter.Value         = (object)installedVersion.Checksum ?? DBNull.Value;
                command.Parameters.Add(parameter);

                command.ExecuteNonQuery();
            }
        }
コード例 #25
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void editToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count == 1)
     {
         InstalledVersion iv = (InstalledVersion)listView1.SelectedItems[0].Tag;
         using (FormEditInstalledVersion eiv = new FormEditInstalledVersion(model.Settings.InstalledVersions, iv))
         {
             if (eiv.ShowDialog(this) == DialogResult.OK)
             {
                 PopulateList();
             }
         }
     }
 }
コード例 #26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="v"></param>
        /// <returns></returns>
        private static string GetLinkType(Model.Model model, InstalledVersion v)
        {
            switch (v.DlcType)
            {
            case 0: return(model.Settings.MlcFolder == "" ? "No" : v.VersionNumber >= 1100 ? "Mlc" : "");

            case 1: return("Yes");

            case 2: return("Link");

            case 3: return("Dead");
            }
            return("??");
        }
コード例 #27
0
        private void ZipImport()
        {
            InstalledVersion version = model.Settings.InstalledVersions.FirstOrDefault(v => v.IsLatest);

            // Configure open file dialog box
            if (version != null)
            {
                string pluginFileName = Path.Combine(SpecialFolders.PlugInFolder(model), plugIn.FileName);

                if (!File.Exists(pluginFileName))
                {
                    using (OpenFileDialog dlg = new OpenFileDialog())
                    {
                        dlg.Filter = plugIn.FileName + Resources.FormExecutePlugIn_ZipImport____ + plugIn.FileName + Resources.FormExecutePlugIn_ZipImport__;

                        // Show open file dialog box
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (File.Exists(dlg.FileName))
                            {
                                File.Copy(dlg.FileName, Path.Combine(SpecialFolders.PlugInFolder(model), plugIn.FileName));
                            }
                        }
                    }
                }

                if (File.Exists(pluginFileName))
                {
                    ZipArchive zipArchive = ZipFile.OpenRead(pluginFileName);
                    foreach (var file in plugIn.Files)
                    {
                        if (File.Exists(Path.Combine(version.Folder, file.DestinationFolder, file.Name)))
                        {
                            if (!File.Exists(Path.Combine(version.Folder, file.DestinationFolder, "_" + file.Name)))
                            {
                                File.Move(Path.Combine(version.Folder, file.DestinationFolder, file.Name), Path.Combine(version.Folder, file.DestinationFolder, "_" + file.Name));
                            }
                        }
                        foreach (ZipArchiveEntry zippedFile in zipArchive.Entries)
                        {
                            if (zippedFile.FullName.Contains(file.SourceFolder + "/" + file.Name))
                            {
                                Unpacker.ExtractFile(zippedFile, Path.Combine(version.Folder, file.DestinationFolder, file.Name));
                            }
                        }
                    }
                }
            }
        }
コード例 #28
0
ファイル: ExtensionFile.cs プロジェクト: lulzzz/etltoolbox
 public void CheckIfHasValidVersion()
 {
     if (!Regex.IsMatch(Content, VERSIONMATCH))
     {
         IsValidExtension = false;
     }
     else
     {
         var match = Regex.Match(Content, VERSIONMATCH);
         if (!match.Captures[0].Value.ToLower().Contains(InstalledVersion.ToLower()))
         {
             IsValidExtension = false;
         }
     }
 }
コード例 #29
0
        internal static void DeleteShaderCache(InstalledVersion version)
        {
            DirectoryInfo di1 = new DirectoryInfo(Path.Combine(version.Folder, "shaderCache", "transferable"));

            foreach (FileInfo file in di1.GetFiles())
            {
                file.Delete();
            }
            DirectoryInfo di2 = new DirectoryInfo(Path.Combine(version.Folder, "shaderCache", "precompiled"));

            foreach (FileInfo file in di2.GetFiles())
            {
                file.Delete();
            }
        }
コード例 #30
0
ファイル: Launcher.cs プロジェクト: SteveLever73/Budford
 /// <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();
         }
     }
 }