Пример #1
0
        /// <summary>
        ///
        /// </summary>
        internal void WriteSettingsBinFile()
        {
            InstalledVersion version;

            try
            {
                version = GetVersion();
            }
            catch (Exception)
            {
                MessageBox.Show(Resources.CemuSettings_WriteSettingsBinFile_Unable_to_get_version, Resources.CemuSettings_WriteSettingsBinFile_Error_);
                return;
            }

            if (version != null)
            {
                if (version.Folder != null)
                {
                    try
                    {
                        SetOffsets(version.Version);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Resources.CemuSettings_WriteSettingsBinFile_Unable_to_set_settings_bin_offsets_for_ + version.Folder + Resources.CemuSettings_WriteSettingsBinFile_ + ex.Message, Resources.CemuSettings_WriteSettingsBinFile_Error_);
                        return;
                    }


                    try
                    {
                        if (File.Exists(Path.Combine(version.Folder, "settings.bin")))
                        {
                            File.Delete(Path.Combine(version.Folder, "settings.bin"));
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Resources.CemuSettings_WriteSettingsBinFile_ + ex.Message, Resources.CemuSettings_WriteSettingsBinFile_Error_);
                    }
                    bool canCreate;
                    try
                    {
                        canCreate = !File.Exists(Path.Combine(version.Folder, "settings.bin"));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Resources.CemuSettings_WriteSettingsBinFile_ + ex.Message, Resources.CemuSettings_WriteSettingsBinFile_Error_);
                        return;
                    }
                    try
                    {
                        if (canCreate)
                        {
                            // No settings file, so lets build our own..
                            using (FileStream fn = new FileStream(Path.Combine(version.Folder, "settings.bin"), FileMode.Create, FileAccess.ReadWrite))
                            {
                                foreach (int file in settingsFile)
                                {
                                    fn.WriteByte((byte)file);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Resources.CemuSettings_WriteSettingsBinFile_Unable_to_Create_settings_bin_file_for_ + version.Folder + ex.Message, Resources.CemuSettings_WriteSettingsBinFile_Error_);
                        return;
                    }

                    try
                    {
                        FileManager.GrantAccess(Path.Combine(version.Folder, "settings.bin"));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Resources.CemuSettings_WriteSettingsBinFile_Failed_to_grant_all_users_access_to_settings_bin_for_ + version.Folder + ex.Message, Resources.CemuSettings_WriteSettingsBinFile_Warning);
                        return;
                    }


                    if (information != null)
                    {
                        try
                        {
                            WriteGraphicsPacks(version);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(Resources.CemuSettings_WriteSettingsBinFile_Failed_to_write_graphics_pack_hash_to_settings_bin_for_ + version.Folder + ex.Message, Resources.CemuSettings_WriteSettingsBinFile_Error_);
                            return;
                        }
                        try
                        {
                            WriteGameProfile(version.Folder);
                            WriteSettings(version.Folder);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(Resources.CemuSettings_WriteSettingsBinFile_Failed_to__write_settings_to_settings_bin_for_ + version.Folder + ex.Message, Resources.CemuSettings_WriteSettingsBinFile_Error_);
                        }
                    }
                }
            }
        }