/// <summary>
        /// Directly copies some simple values (theater database entry ID, etc.) from the template.
        /// </summary>
        /// <param name="mission">The mission</param>
        /// <param name="template">Mission template to use</param>
        private void CopyTemplateValues(DCSMission mission, MissionTemplate template)
        {
            mission.Coalitions[(int)Coalition.Blue] = template.GetCoalition(Coalition.Blue);
            mission.Coalitions[(int)Coalition.Red]  = template.GetCoalition(Coalition.Red);
            mission.CivilianTraffic      = template.OptionsCivilianTraffic;
            mission.CoalitionPlayer      = template.ContextCoalitionPlayer;
            mission.Weather.CloudsPreset = template.EnvironmentCloudPreset.Get();
            mission.RadioAssists         = !template.Realism.Contains(RealismOption.DisableDCSRadioAssists);
            mission.Theater      = template.ContextTheater;
            mission.CountryBlues = new List <Country> {
                Country.CJTFBlue
            };
            mission.CountryReds = new List <Country> {
                Country.CJTFRed
            };
            var countries = template.PlayerFlightGroups.Select(x => x.Country).Distinct().ToList();

            if (template.ContextCoalitionPlayer == Coalition.Blue)
            {
                mission.CountryBlues.AddRange(countries);
            }
            else
            {
                mission.CountryReds.AddRange(countries);
            }
            mission.CountryBlues   = mission.CountryBlues.Distinct().ToList();
            mission.CountryReds    = mission.CountryReds.Distinct().ToList();
            mission.EndMode        = template.OptionsEndMode;
            mission.RealismOptions = template.Realism;
        }
예제 #2
0
        /// <summary>
        /// Directly copies some simple values (theater database entry ID, etc.) from the template.
        /// </summary>
        /// <param name="mission">The mission</param>
        /// <param name="template">Mission template to use</param>
        private void CopyTemplateValues(DCSMission mission, MissionTemplate template)
        {
            mission.Coalitions[(int)Coalition.Blue] = template.GetCoalition(Coalition.Blue);
            mission.Coalitions[(int)Coalition.Red]  = template.GetCoalition(Coalition.Red);
            mission.CoalitionPlayer     = template.ContextCoalitionPlayer;
            mission.Theater             = template.TheaterID;
            mission.PlayerStartLocation = template.PlayerStartLocation;
            mission.EndMode             = template.OptionsEndMode;

            // "Runway" start locations is not available in MP missions, change to "Parking hot".
            if ((template.GetMissionType() != MissionType.SinglePlayer) &&
                (template.PlayerStartLocation == PlayerStartLocation.Runway))
            {
                mission.PlayerStartLocation = PlayerStartLocation.ParkingHot;
            }
        }
        /// <summary>
        /// Directly copies some simple values (theater database entry ID, etc.) from the template.
        /// </summary>
        /// <param name="mission">The mission</param>
        /// <param name="template">Mission template to use</param>
        private void CopyTemplateValues(DCSMission mission, MissionTemplate template)
        {
            mission.Coalitions[(int)Coalition.Blue] = template.GetCoalition(Coalition.Blue);
            mission.Coalitions[(int)Coalition.Red]  = template.GetCoalition(Coalition.Red);
            mission.CivilianTraffic     = template.OptionsCivilianTraffic;
            mission.CoalitionPlayer     = template.ContextCoalitionPlayer;
            mission.RadioAssists        = template.OptionsPreferences.Contains(MissionTemplatePreferences.DCSRadioAssists);
            mission.Theater             = template.TheaterID;
            mission.PlayerStartLocation = template.PlayerStartLocation;
            mission.EndMode             = template.OptionsEndMode;
            mission.RealismOptions      = template.OptionsRealism;

            // "Runway" start locations is not available in MP missions, change to "Parking hot".
            if ((template.GetMissionType() != MissionType.SinglePlayer) &&
                (template.PlayerStartLocation == PlayerStartLocation.Runway))
            {
                mission.PlayerStartLocation = PlayerStartLocation.ParkingHot;
            }
        }
        private string CreateHTMLBriefing(
            DCSMission mission, MissionTemplate template, string description,
            List <string> tasks, List <string> remarks,
            List <UnitFlightGroupBriefingDescription> flightGroups, DBEntryTheaterAirbase airbaseDB,
            DBEntryCoalition[] coalitionsDB, DBEntryObjective objectiveDB)
        {
            DebugLog.Instance.WriteLine("Generating HTML mission briefing...", 2);

            if (!File.Exists(HTML_TEMPLATE_FILE)) // Briefing template not found
            {
                DebugLog.Instance.WriteLine("HTML template file not found.", 1, DebugLogMessageErrorLevel.Warning);
                return("HTML template file not found.");
            }

            string briefing = File.ReadAllText(HTML_TEMPLATE_FILE);

            // Title
            briefing = briefing.Replace("$MISSIONNAME$", mission.MissionName);
            briefing = briefing.Replace("$MISSIONTYPE$",
                                        GeneratorTools.RemoveAfterComma(objectiveDB.ID) + " mission " +
                                        ((template.GetMissionType() == MissionType.SinglePlayer) ?
                                         "(single-player)" : $"({template.GetPlayerCount()}-players multiplayer)"));

            // Situation summary
            briefing = briefing.Replace("$LONGDATE$", mission.DateTime.ToDateString(true));
            briefing = briefing.Replace("$LONGTIME$", mission.DateTime.ToTimeString());
            briefing = briefing.Replace("$SHORTDATE$", mission.DateTime.ToDateString(false));
            briefing = briefing.Replace("$SHORTTIME$", mission.DateTime.ToTimeString());
            briefing = briefing.Replace("$WEATHER$", GeneratorTools.GetEnumString(mission.Weather.WeatherLevel));
            briefing = briefing.Replace("$WIND$", GeneratorTools.GetEnumString(mission.Weather.WindLevel));
            briefing = briefing.Replace("$WINDSPEED$", mission.Weather.WindSpeedAverage.ToString("F0"));

            // Friends and enemies
            briefing = briefing.Replace("$PLAYERCOALITION$", GeneratorTools.RemoveAfterComma(template.GetCoalition(mission.CoalitionPlayer)));
            briefing = briefing.Replace("$ENEMYCOALITION$", GeneratorTools.RemoveAfterComma(template.GetCoalition(mission.CoalitionEnemy)));

            // Description
            briefing = briefing.Replace("$DESCRIPTION$", description.Replace("\n", "<br />"));

            // Tasks
            string tasksHTML = "";

            foreach (string task in tasks)
            {
                tasksHTML += $"<li>{task}</li>";
            }
            briefing = briefing.Replace("$TASKS$", tasksHTML);

            // Remarks
            string remarksHTML = "";

            foreach (string remark in remarks)
            {
                remarksHTML += $"<li>{remark}</li>";
            }
            briefing = briefing.Replace("$REMARKS$", remarksHTML);

            // Flight groups
            string flightGroupsHTML = "";

            foreach (UnitFlightGroupBriefingDescription fg in flightGroups)
            {
                flightGroupsHTML +=
                    "<tr>" +
                    $"<td>{fg.Callsign}</td>" +
                    $"<td>{fg.Count}×{fg.Type}</td>" +
                    $"<td>{fg.Task}</td><td>{fg.Radio}</td>" +
                    $"<td>{fg.Remarks}</td>" +
                    "</tr>";
            }
            briefing = briefing.Replace("$FLIGHTGROUPS$", flightGroupsHTML);

            // Airbases
            string airbasesHTML =
                "<tr>" +
                $"<td>{airbaseDB.Name}</td>" +
                $"<td>{airbaseDB.Runways}</td>" +
                $"<td>{airbaseDB.ATC}</td>" +
                $"<td>{airbaseDB.ILS}</td>" +
                $"<td>{airbaseDB.TACAN}</td>" +
                "</tr>";

            briefing = briefing.Replace("$AIRBASES$", airbasesHTML);

            string carrierHTML = "";

            foreach (var carrier in mission.Carriers)
            {
                carrierHTML +=
                    "<tr>" +
                    $"<td>{carrier.Units[0].Name}</td>" +
                    $"<td>{carrier.RadioFrequency.ToString("n3")}{carrier.RadioModulation}</td>" +
                    $"<td>{carrier.ILS}</td>" +
                    $"<td>{carrier.TACAN.ToString()}</td>" +
                    "</tr>";
            }
            briefing = briefing.Replace("$CARRIERS$", carrierHTML);


            // Waypoints
            string      waypointsHTML = "";
            double      distance;
            double      totalDistance   = 0.0;
            Coordinates currentPosition = mission.InitialPosition;

            waypointsHTML += $"<tr><td><strong>TAKEOFF</strong></td><td>-</td><td>-</td></tr>";
            foreach (DCSMissionWaypoint wp in mission.Waypoints)
            {
                distance        = currentPosition.GetDistanceFrom(wp.Coordinates);
                totalDistance  += distance;
                currentPosition = wp.Coordinates;

                waypointsHTML +=
                    $"<tr><td>{wp.Name}</td>" +
                    $"<td>{GeneratorTools.ConvertDistance(distance, template.BriefingUnitSystem)}</td>" +
                    $"<td>{GeneratorTools.ConvertDistance(totalDistance, template.BriefingUnitSystem)}</td></tr>";
            }
            distance       = currentPosition.GetDistanceFrom(mission.InitialPosition);
            totalDistance += distance;
            waypointsHTML += $"<tr><td><strong>LANDING</strong></td>" +
                             $"<td>{GeneratorTools.ConvertDistance(distance, template.BriefingUnitSystem)}</td>" +
                             $"<td>{GeneratorTools.ConvertDistance(totalDistance, template.BriefingUnitSystem)}</td></tr>";
            briefing = briefing.Replace("$WAYPOINTS$", waypointsHTML);

            return(briefing);
        }