Example #1
0
        public bool BackupFiles()
        {
            Console.WriteLine("Backing up files prior to update...");
            installPath    = installFinder.Find();
            savedGamesPath = savedGamesFinder.Find();

            if (installPath == null || savedGamesPath == null)
            {
                return(false);
            }

            try
            {
                if (Directory.Exists(backupPath))
                {
                    Directory.Delete(backupPath, true);
                }

                CopyFolder(".", backupPath, excludeFiles);

                Directory.CreateDirectory(backupPath + "\\DCS_Backup_Hooks");
                string KIModFile       = savedGamesPath + "\\Hooks\\KI_ServerGameGUI.lua";
                string BackupKIModFile = backupPath + "\\DCS_Backup_Hooks\\KI_ServerGameGUI.lua";
                if (File.Exists(KIModFile))
                {
                    File.Copy(KIModFile, BackupKIModFile, true);
                }

                Directory.CreateDirectory(backupPath + "\\DCS_Backup_Core");
                string MissionScriptingFile       = installPath + "\\Scripts\\MissionScripting.lua";
                string BackupMissionScriptingFile = backupPath + "\\DCS_Backup_Core\\MissionScripting.lua";
                if (File.Exists(MissionScriptingFile))
                {
                    File.Copy(MissionScriptingFile, BackupMissionScriptingFile, true);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error backing up files - " + ex.Message);
                return(false);
            }

            return(true);
        }
Example #2
0
        public bool Update()
        {
            string installPath = installFinder.Find();

            if (installPath == null)
            {
                return(false);
            }

            string savedGamesPath = savedGamesFinder.Find();

            if (savedGamesPath == null)
            {
                return(false);
            }

            Console.WriteLine("Updating Files");

            string ScriptsPath = savedGamesPath + "\\Scripts";

            if (!TryCreateDirectory(ScriptsPath))
            {
                return(false);
            }

            string HooksPath = savedGamesPath + "\\Scripts\\Hooks";

            if (!TryCreateDirectory(HooksPath))
            {
                return(false);
            }

            string MissionsPath = savedGamesPath + "\\Missions\\Kaukasus Insurgency";

            if (!TryCreateDirectory(MissionsPath))
            {
                return(false);
            }

            if (!TryCreateDirectory(MissionsPath + "\\Server") ||
                !TryCreateDirectory(MissionsPath + "\\GameEvents") ||
                !TryCreateDirectory(MissionsPath + "\\SlingloadEvents"))
            {
                return(false);
            }

            {
                string KIServerModNewPath = extractPath + "\\ki\\DCSMod\\Hooks\\KI_ServerGameGUI.lua";
                string DestPath           = HooksPath + "\\KI_ServerGameGUI.lua";

                if (!TryCopyFile(KIServerModNewPath, DestPath))
                {
                    Console.WriteLine("Could not update KI_ServerGameGUI.lua because of an error");
                    return(false);
                }
                else
                {
                    Console.WriteLine("Updated: " + DestPath);
                }
            }

            {
                string JsonModPath = extractPath + "\\ki\\DCSMod\\JSON.lua";
                string DestPath    = savedGamesPath + "\\JSON.lua";

                if (!TryCopyFile(JsonModPath, DestPath))
                {
                    Console.WriteLine("Could not update JSON.lua because of an error");
                    return(false);
                }
                else
                {
                    Console.WriteLine("Updated: " + DestPath);
                }
            }

            {
                Console.WriteLine("Unrestricting core files in DCS");
                string missionScriptingPath = extractPath + "\\ki\\DCSCore\\MissionScripting.lua";
                string DestPath             = installPath + "\\Scripts\\MissionScripting.lua";

                if (!TryCopyFile(missionScriptingPath, DestPath))
                {
                    Console.WriteLine("Could not update KI_ServerGameGUI.lua because of an error");
                    return(false);
                }
                else
                {
                    Console.WriteLine("Updated: " + DestPath);
                }
            }

            try
            {
                CopyFolder(extractPath + "\\ki", ".");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error applying updates - " + ex.Message);
                return(false);
            }

            DCSMissionReader rdr = new DCSMissionReader();

            rdr.UpdateScriptLoadPath(extractPath + "\\ki\\DCSMissions\\KIAlpha.miz", Path.GetFullPath(".\\DCSScripts"));



            return(true);
        }