Esempio n. 1
0
        /// <summary>
        /// Edits the specified game specific value.
        /// </summary>
        /// <remarks>
        /// This method writes the given value in the specified game specific value, if it
        /// is owned by the mod being upgraded. If the specified edit is not owned by the
        /// mod being upgraded, the edit is archived in the install log.
        ///
        /// If the edit was not previously installed by the mod, then the normal install
        /// rules apply, including confirming overwrite if applicable.
        /// </remarks>
        /// <param name="p_strKey">The key of the edited Game Specific Value.</param>
        /// <param name="p_bteValue">The value to install.</param>
        /// <returns><c>true</c> if the value was set; <c>false</c> otherwise.</returns>
        public override bool EditGameSpecificValue(string p_strKey, byte[] p_bteValue)
        {
            IList <IMod> lstInstallers = InstallLog.GetGameSpecificValueEditInstallers(p_strKey);

            if (lstInstallers.Contains(Mod, ModComparer.Filename))
            {
                if (!ModComparer.Filename.Equals(lstInstallers[lstInstallers.Count - 1], Mod))
                {
                    InstallLog.ReplaceGameSpecificValueEdit(Mod, p_strKey, p_bteValue);
                }
                else
                {
                    ShaderEdit  sedShader  = new ShaderEdit(p_strKey);
                    SDPArchives sdpManager = new SDPArchives(GameModeInfo, FileUtility);
                    if (!TouchedFiles.Contains(sdpManager.GetPath(sedShader.Package)))
                    {
                        TouchedFiles.Add(sdpManager.GetPath(sedShader.Package));
                        TransactionalFileManager.Snapshot(sdpManager.GetPath(sedShader.Package));
                    }
                    byte[] oldData;
                    if (!sdpManager.EditShader(sedShader.Package, sedShader.ShaderName, p_bteValue, out oldData))
                    {
                        throw new Exception("Failed to edit the shader");
                    }
                }
                OriginallyInstalledEdits.Remove(p_strKey);
                return(true);
            }

            return(base.EditGameSpecificValue(p_strKey, p_bteValue));
        }
        /// <summary>
        /// Sets the specified value in the specified Ini file to the given value.
        /// </summary>
        /// <remarks>
        /// This method writes the given value in the specified Ini value, if it is owned
        /// by the mod being upgraded. If the specified Ini edit is not owned by the mod
        /// being upgraded, the Ini edit is archived in the install log.
        ///
        /// If the Ini edit was not previously installed by the mod, then the normal install
        /// rules apply, including confirming overwrite if applicable.
        /// </remarks>
        /// <param name="p_strSettingsFileName">The name of the settings file to edit.</param>
        /// <param name="p_strSection">The section in the Ini file to edit.</param>
        /// <param name="p_strKey">The key in the Ini file to edit.</param>
        /// <param name="p_strValue">The value to which to set the key.</param>
        /// <returns><c>true</c> if the value was set; <c>false</c>
        /// if the user chose not to overwrite the existing value.</returns>
        public override bool EditIni(string p_strSettingsFileName, string p_strSection, string p_strKey, string p_strValue)
        {
            IList <IMod> lstInstallers = InstallLog.GetIniEditInstallers(p_strSettingsFileName, p_strSection, p_strKey);

            if (lstInstallers.Contains(Mod, ModComparer.Filename))
            {
                if (!ModComparer.Filename.Equals(lstInstallers[lstInstallers.Count - 1], Mod))
                {
                    InstallLog.ReplaceIniEdit(Mod, p_strSettingsFileName, p_strSection, p_strKey, p_strValue);
                }
                else
                {
                    if (!TouchedFiles.Contains(p_strSettingsFileName))
                    {
                        TouchedFiles.Add(p_strSettingsFileName);
                        TransactionalFileManager.Snapshot(p_strSettingsFileName);
                    }
                    IniMethods.WritePrivateProfileString(p_strSection, p_strKey, p_strValue, p_strSettingsFileName);
                }
                IniEdit iniEdit = new IniEdit(p_strSettingsFileName, p_strSection, p_strKey);
                OriginallyInstalledEdits.Remove(iniEdit);
                return(true);
            }

            return(base.EditIni(p_strSettingsFileName, p_strSection, p_strKey, p_strValue));
        }