Ejemplo n.º 1
0
        public void Generate(CampaignTemplate campaignTemplate, string campaignFilePath)
        {
            string campaignName      = Path.GetFileNameWithoutExtension(campaignFilePath);
            string campaignDirectory = Path.GetDirectoryName(campaignFilePath);

            DCSMissionDateTime date = GenerateCampaignDate(campaignTemplate);

            using (MissionGenerator generator = new MissionGenerator())
            {
                for (int i = 0; i < campaignTemplate.MissionsCount; i++)
                {
                    // Increment the date by a few days for each mission after the first
                    if (i > 0)
                    {
                        IncrementDate(ref date);
                    }

                    MissionTemplate template = CreateMissionTemplate(campaignTemplate, i);

                    DCSMission mission = generator.Generate(template);
                    mission.MissionName  = $"{campaignName}, phase {i + 1}";
                    mission.DateTime.Day = date.Day; mission.DateTime.Month = date.Month; mission.DateTime.Year = date.Year;

                    MizFile miz = mission.ExportToMiz();
                    miz.SaveToFile(Path.Combine(campaignDirectory, $"{campaignName}{i + 1:00}.miz"));
                }
            }

            CreateImageFiles(campaignTemplate, campaignFilePath);
            CreateCMPFile(campaignTemplate, campaignFilePath);
        }
        /// <summary>
        /// Generates mission(s) from command line arguments.
        /// </summary>
        /// <param name="args">Command line arguments</param>
        /// <returns>True if everything when wrong, false otherwise</returns>
        public bool DoCommandLine(params string[] args)
        {
            ParseCommandLineArguments(args, out string[] templateFiles, out int missionCount);

            if (templateFiles.Length == 0)
            {
                DebugLog.Instance.WriteLine("No mission template files provided", DebugLogMessageErrorLevel.Error);
                return(false);
            }

            using (MissionGenerator generator = new MissionGenerator())
            {
                foreach (string t in templateFiles)
                {
                    using (MissionTemplate template = new MissionTemplate(t))
                    {
                        for (int i = 0; i < missionCount; i++)
                        {
                            DCSMission mission = generator.Generate(template);
                            if (mission == null)
                            {
                                DebugLog.Instance.WriteLine($"Failed to generate a mission from template {Path.GetFileName(t)}", DebugLogMessageErrorLevel.Warning);
                                continue;
                            }

                            string mizFileName = Path.Combine(Application.StartupPath, Path.GetFileNameWithoutExtension(t) + ".miz");
                            mizFileName = GetUnusedFileName(mizFileName);

                            MizFile miz = mission.ExportToMiz();
                            if ((miz == null) || !miz.SaveToFile(mizFileName))
                            {
                                DebugLog.Instance.WriteLine($"Failed to export .miz file from template {Path.GetFileName(t)}", DebugLogMessageErrorLevel.Warning);
                                continue;
                            }
                            else
                            {
                                DebugLog.Instance.WriteLine($"Mission {Path.GetFileName(mizFileName)} exported to .miz file from template {Path.GetFileName(t)}");
                            }
                        }
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        private void ExportToMiz(string filePath)
        {
            if (Mission == null)
            {
                return;                  // Mission not generated, nothing to export
            }
            using (MizFile miz = Mission.ExportToMiz())
            {
                PrintStatusLabelOutput("Miz export");

                if (miz == null) // Something went wrong during the .miz export
                {
                    return;
                }

                miz.SaveToFile(filePath);
            }
        }
Ejemplo n.º 4
0
        public void Generate(CampaignTemplate campaignTemplate, string campaignFilePath)
        {
            string campaignName      = Path.GetFileNameWithoutExtension(campaignFilePath);
            string campaignDirectory = Path.GetDirectoryName(campaignFilePath);

            DCSMissionDateTime date = GenerateCampaignDate(campaignTemplate);

            using (MissionGenerator generator = new MissionGenerator())
            {
                for (int i = 0; i < campaignTemplate.MissionsCount; i++)
                {
                    MissionTemplate template = CreateMissionTemplate(campaignTemplate, i, campaignName, ref date);

                    DCSMission mission = generator.Generate(template);
                    MizFile    miz     = mission.ExportToMiz();
                    miz.SaveToFile(Path.Combine(campaignDirectory, $"{campaignName}{i + 1:00}.miz"));
                }
            }

            CreateImageFiles(campaignTemplate, campaignFilePath);
            CreateCMPFile(campaignTemplate, campaignFilePath);
        }