예제 #1
0
        /// <summary>
        /// Writes the given value to both the Fallout INI file and the default Fallout INI file.
        /// </summary>
        /// <param name="p_strSection">The section containing the key whose value is to be written.</param>
        /// <param name="p_strValueKey">The key whose value is to be written.</param>
        /// <param name="p_intValue">The value to write.</param>
        private void WriteIniInt(string p_strSection, string p_strValueKey, Int32 p_intValue)
        {
            IniMethods.WritePrivateProfileInt32(p_strSection, p_strValueKey, p_intValue, GameMode.SettingsFiles.IniPath);
            string strIniPath = ((FalloutNVSettingsFiles)GameMode.SettingsFiles).FODefaultIniPath;

            if (File.Exists(strIniPath))
            {
                IniMethods.WritePrivateProfileInt32(p_strSection, p_strValueKey, p_intValue, strIniPath);
            }
        }
        /// <summary>
        /// Disables AI.
        /// </summary>
        protected override void RemoveAI()
        {
            string strFalloutIniPath = GameMode.SettingsFiles.IniPath;

            IniMethods.WritePrivateProfileInt32("Archive", "bInvalidateOlderFiles", 0, strFalloutIniPath);
            IniMethods.WritePrivateProfileInt32("General", "bLoadFaceGenHeadEGTFiles", 0, strFalloutIniPath);
            IniMethods.WritePrivateProfileString("Archive", "SInvalidationFile", "ArchiveInvalidation.txt", strFalloutIniPath);
            File.Delete(Path.Combine(GameMode.PluginDirectory, AI_BSA));
            IniMethods.WritePrivateProfileString("Archive", "SArchiveList", GetBSAList(), strFalloutIniPath);
        }
        /// <summary>
        /// Enables AI.
        /// </summary>
        protected override void ApplyAI()
        {
            string strPluginsPath = GameMode.PluginDirectory;

            foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("Fallout - *.bsa"))
            {
                fi.LastWriteTime = new DateTime(2008, 10, 1);
            }
            foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("Anchorage - *.bsa"))
            {
                fi.LastWriteTime = new DateTime(2008, 10, 2);
            }
            foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("ThePitt - *.bsa"))
            {
                fi.LastWriteTime = new DateTime(2008, 10, 3);
            }
            foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("BrokenSteel - *.bsa"))
            {
                fi.LastWriteTime = new DateTime(2008, 10, 4);
            }
            foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("PointLookout - *.bsa"))
            {
                fi.LastWriteTime = new DateTime(2008, 10, 5);
            }
            foreach (FileInfo fi in new DirectoryInfo(strPluginsPath).GetFiles("Zeta - *.bsa"))
            {
                fi.LastWriteTime = new DateTime(2008, 10, 6);
            }

            string strFalloutIniPath = GameMode.SettingsFiles.IniPath;

            IniMethods.WritePrivateProfileInt32("Archive", "bInvalidateOlderFiles", 1, strFalloutIniPath);
            IniMethods.WritePrivateProfileInt32("General", "bLoadFaceGenHeadEGTFiles", 1, strFalloutIniPath);
            IniMethods.WritePrivateProfileString("Archive", "SInvalidationFile", "", strFalloutIniPath);
            File.Delete(Path.Combine(strPluginsPath, "archiveinvalidation.txt"));
            File.WriteAllBytes(Path.Combine(strPluginsPath, AI_BSA), new byte[] {
                0x42, 0x53, 0x41, 0x00, 0x67, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00,
                0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
                0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
                0x36, 0x00, 0x00, 0x00, 0x01, 0x00, 0x61, 0x00, 0x01, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x61, 0x00
            });
            IniMethods.WritePrivateProfileString("Archive", "SArchiveList", AI_BSA + ", " + GetBSAList(), strFalloutIniPath);
        }
        /// <summary>
        /// Enables AI.
        /// </summary>
        protected override void ApplyAI()
        {
            var pluginsPath = GameMode.PluginDirectory;

            try
            {
                foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("Fallout - *.bsa"))
                {
                    fi.LastWriteTime = new DateTime(2008, 10, 1);
                }

                foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("Anchorage - *.bsa"))
                {
                    fi.LastWriteTime = new DateTime(2008, 10, 2);
                }

                foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("ThePitt - *.bsa"))
                {
                    fi.LastWriteTime = new DateTime(2008, 10, 3);
                }

                foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("BrokenSteel - *.bsa"))
                {
                    fi.LastWriteTime = new DateTime(2008, 10, 4);
                }

                foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("PointLookout - *.bsa"))
                {
                    fi.LastWriteTime = new DateTime(2008, 10, 5);
                }

                foreach (var fi in new DirectoryInfo(pluginsPath).GetFiles("Zeta - *.bsa"))
                {
                    fi.LastWriteTime = new DateTime(2008, 10, 6);
                }

                var falloutIniPath = GameMode.SettingsFiles.IniPath;

                IniMethods.WritePrivateProfileInt32("Archive", "bInvalidateOlderFiles", 1, falloutIniPath);
                IniMethods.WritePrivateProfileInt32("General", "bLoadFaceGenHeadEGTFiles", 1, falloutIniPath);
                IniMethods.WritePrivateProfileString("Archive", "SInvalidationFile", "", falloutIniPath);
                File.Delete(Path.Combine(pluginsPath, "archiveinvalidation.txt"));
                File.WriteAllBytes(Path.Combine(pluginsPath, AI_BSA), new byte[]
                {
                    0x42, 0x53, 0x41, 0x00, 0x67, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00,
                    0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
                    0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
                    0x36, 0x00, 0x00, 0x00, 0x01, 0x00, 0x61, 0x00, 0x01, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x61, 0x00
                });
                IniMethods.WritePrivateProfileString("Archive", "SArchiveList", AI_BSA + ", " + GetBSAList(), falloutIniPath);
            }
            catch (Exception ex)
            {
                Trace.TraceError("ApplyAI - Could not apply ArchiveInvalidation.");
                TraceUtil.TraceException(ex);

                MessageBox.Show(
                    "Could not apply Archive Invalidation, at least one file could not be modified.\n" +
                    "Please try again, or check trace log for more info.\n\n" +
                    ex.Message,
                    "Archive Invalidation failed",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }